Initial commit

This commit is contained in:
Ammaar Reshi
2025-01-04 14:06:53 +00:00
parent 7082408604
commit d6025af146
23760 changed files with 3299690 additions and 0 deletions

64
node_modules/drizzle-orm/expo-sqlite/driver.cjs generated vendored Normal file
View File

@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var driver_exports = {};
__export(driver_exports, {
ExpoSQLiteDatabase: () => ExpoSQLiteDatabase,
drizzle: () => drizzle
});
module.exports = __toCommonJS(driver_exports);
var import_entity = require("../entity.cjs");
var import_logger = require("../logger.cjs");
var import_relations = require("../relations.cjs");
var import_db = require("../sqlite-core/db.cjs");
var import_dialect = require("../sqlite-core/dialect.cjs");
var import_session = require("./session.cjs");
class ExpoSQLiteDatabase extends import_db.BaseSQLiteDatabase {
static [import_entity.entityKind] = "ExpoSQLiteDatabase";
}
function drizzle(client, config = {}) {
const dialect = new import_dialect.SQLiteSyncDialect({ casing: config.casing });
let logger;
if (config.logger === true) {
logger = new import_logger.DefaultLogger();
} else if (config.logger !== false) {
logger = config.logger;
}
let schema;
if (config.schema) {
const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(
config.schema,
import_relations.createTableRelationsHelpers
);
schema = {
fullSchema: config.schema,
schema: tablesConfig.tables,
tableNamesMap: tablesConfig.tableNamesMap
};
}
const session = new import_session.ExpoSQLiteSession(client, dialect, schema, { logger });
const db = new ExpoSQLiteDatabase("sync", dialect, session, schema);
db.$client = client;
return db;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ExpoSQLiteDatabase,
drizzle
});
//# sourceMappingURL=driver.cjs.map

1
node_modules/drizzle-orm/expo-sqlite/driver.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/driver.ts"],"sourcesContent":["import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite';\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { ExpoSQLiteSession } from './session.ts';\n\nexport class ExpoSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>>\n\textends BaseSQLiteDatabase<'sync', SQLiteRunResult, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'ExpoSQLiteDatabase';\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: SQLiteDatabase,\n\tconfig: DrizzleConfig<TSchema> = {},\n): ExpoSQLiteDatabase<TSchema> & {\n\t$client: SQLiteDatabase;\n} {\n\tconst dialect = new SQLiteSyncDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new ExpoSQLiteSession(client, dialect, schema, { logger });\n\tconst db = new ExpoSQLiteDatabase('sync', dialect, session, schema) as ExpoSQLiteDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,oBAA8B;AAC9B,uBAKO;AACP,gBAAmC;AACnC,qBAAkC;AAElC,qBAAkC;AAE3B,MAAM,2BACJ,6BACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AACjD;AAEO,SAAS,QACf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,iCAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC/D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,iCAAkB,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACzE,QAAM,KAAK,IAAI,mBAAmB,QAAQ,SAAS,SAAS,MAAM;AAClE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}

10
node_modules/drizzle-orm/expo-sqlite/driver.d.cts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite';
import { entityKind } from "../entity.cjs";
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
import type { DrizzleConfig } from "../utils.cjs";
export declare class ExpoSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', SQLiteRunResult, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: SQLiteDatabase, config?: DrizzleConfig<TSchema>): ExpoSQLiteDatabase<TSchema> & {
$client: SQLiteDatabase;
};

10
node_modules/drizzle-orm/expo-sqlite/driver.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite';
import { entityKind } from "../entity.js";
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
import type { DrizzleConfig } from "../utils.js";
export declare class ExpoSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', SQLiteRunResult, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: SQLiteDatabase, config?: DrizzleConfig<TSchema>): ExpoSQLiteDatabase<TSchema> & {
$client: SQLiteDatabase;
};

42
node_modules/drizzle-orm/expo-sqlite/driver.js generated vendored Normal file
View File

@ -0,0 +1,42 @@
import { entityKind } from "../entity.js";
import { DefaultLogger } from "../logger.js";
import {
createTableRelationsHelpers,
extractTablesRelationalConfig
} from "../relations.js";
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
import { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
import { ExpoSQLiteSession } from "./session.js";
class ExpoSQLiteDatabase extends BaseSQLiteDatabase {
static [entityKind] = "ExpoSQLiteDatabase";
}
function drizzle(client, config = {}) {
const dialect = new SQLiteSyncDialect({ casing: config.casing });
let logger;
if (config.logger === true) {
logger = new DefaultLogger();
} else if (config.logger !== false) {
logger = config.logger;
}
let schema;
if (config.schema) {
const tablesConfig = extractTablesRelationalConfig(
config.schema,
createTableRelationsHelpers
);
schema = {
fullSchema: config.schema,
schema: tablesConfig.tables,
tableNamesMap: tablesConfig.tableNamesMap
};
}
const session = new ExpoSQLiteSession(client, dialect, schema, { logger });
const db = new ExpoSQLiteDatabase("sync", dialect, session, schema);
db.$client = client;
return db;
}
export {
ExpoSQLiteDatabase,
drizzle
};
//# sourceMappingURL=driver.js.map

1
node_modules/drizzle-orm/expo-sqlite/driver.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/driver.ts"],"sourcesContent":["import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite';\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { ExpoSQLiteSession } from './session.ts';\n\nexport class ExpoSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>>\n\textends BaseSQLiteDatabase<'sync', SQLiteRunResult, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'ExpoSQLiteDatabase';\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: SQLiteDatabase,\n\tconfig: DrizzleConfig<TSchema> = {},\n): ExpoSQLiteDatabase<TSchema> & {\n\t$client: SQLiteDatabase;\n} {\n\tconst dialect = new SQLiteSyncDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new ExpoSQLiteSession(client, dialect, schema, { logger });\n\tconst db = new ExpoSQLiteDatabase('sync', dialect, session, schema) as ExpoSQLiteDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAElC,SAAS,yBAAyB;AAE3B,MAAM,2BACJ,mBACT;AAAA,EACC,QAA0B,UAAU,IAAY;AACjD;AAEO,SAAS,QACf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC/D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,kBAAkB,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACzE,QAAM,KAAK,IAAI,mBAAmB,QAAQ,SAAS,SAAS,MAAM;AAClE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}

27
node_modules/drizzle-orm/expo-sqlite/index.cjs generated vendored Normal file
View File

@ -0,0 +1,27 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var expo_sqlite_exports = {};
module.exports = __toCommonJS(expo_sqlite_exports);
__reExport(expo_sqlite_exports, require("./driver.cjs"), module.exports);
__reExport(expo_sqlite_exports, require("./query.cjs"), module.exports);
__reExport(expo_sqlite_exports, require("./session.cjs"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
...require("./driver.cjs"),
...require("./query.cjs"),
...require("./session.cjs")
});
//# sourceMappingURL=index.cjs.map

1
node_modules/drizzle-orm/expo-sqlite/index.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './query.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,wBAAd;AACA,gCAAc,uBADd;AAEA,gCAAc,yBAFd;","names":[]}

3
node_modules/drizzle-orm/expo-sqlite/index.d.cts generated vendored Normal file
View File

@ -0,0 +1,3 @@
export * from "./driver.cjs";
export * from "./query.cjs";
export * from "./session.cjs";

3
node_modules/drizzle-orm/expo-sqlite/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
export * from "./driver.js";
export * from "./query.js";
export * from "./session.js";

4
node_modules/drizzle-orm/expo-sqlite/index.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
export * from "./driver.js";
export * from "./query.js";
export * from "./session.js";
//# sourceMappingURL=index.js.map

1
node_modules/drizzle-orm/expo-sqlite/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './query.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}

90
node_modules/drizzle-orm/expo-sqlite/migrator.cjs generated vendored Normal file
View File

@ -0,0 +1,90 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var migrator_exports = {};
__export(migrator_exports, {
migrate: () => migrate,
useMigrations: () => useMigrations
});
module.exports = __toCommonJS(migrator_exports);
var import_react = require("react");
async function readMigrationFiles({ journal, migrations }) {
const migrationQueries = [];
for await (const journalEntry of journal.entries) {
const query = migrations[`m${journalEntry.idx.toString().padStart(4, "0")}`];
if (!query) {
throw new Error(`Missing migration: ${journalEntry.tag}`);
}
try {
const result = query.split("--> statement-breakpoint").map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: ""
});
} catch {
throw new Error(`Failed to parse migration: ${journalEntry.tag}`);
}
}
return migrationQueries;
}
async function migrate(db, config) {
const migrations = await readMigrationFiles(config);
return db.dialect.migrate(migrations, db.session);
}
const useMigrations = (db, migrations) => {
const initialState = {
success: false,
error: void 0
};
const fetchReducer = (state2, action) => {
switch (action.type) {
case "migrating": {
return { ...initialState };
}
case "migrated": {
return { ...initialState, success: action.payload };
}
case "error": {
return { ...initialState, error: action.payload };
}
default: {
return state2;
}
}
};
const [state, dispatch] = (0, import_react.useReducer)(fetchReducer, initialState);
(0, import_react.useEffect)(() => {
dispatch({ type: "migrating" });
migrate(db, migrations).then(() => {
dispatch({ type: "migrated", payload: true });
}).catch((error) => {
dispatch({ type: "error", payload: error });
});
}, []);
return state;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
migrate,
useMigrations
});
//# sourceMappingURL=migrator.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/migrator.ts"],"sourcesContent":["import { useEffect, useReducer } from 'react';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { ExpoSQLiteDatabase } from './driver.ts';\n\ninterface MigrationConfig {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}\n\nasync function readMigrationFiles({ journal, migrations }: MigrationConfig): Promise<MigrationMeta[]> {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor await (const journalEntry of journal.entries) {\n\t\tconst query = migrations[`m${journalEntry.idx.toString().padStart(4, '0')}`];\n\n\t\tif (!query) {\n\t\t\tthrow new Error(`Missing migration: ${journalEntry.tag}`);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = query.split('--> statement-breakpoint').map((it) => {\n\t\t\t\treturn it;\n\t\t\t});\n\n\t\t\tmigrationQueries.push({\n\t\t\t\tsql: result,\n\t\t\t\tbps: journalEntry.breakpoints,\n\t\t\t\tfolderMillis: journalEntry.when,\n\t\t\t\thash: '',\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(`Failed to parse migration: ${journalEntry.tag}`);\n\t\t}\n\t}\n\n\treturn migrationQueries;\n}\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: ExpoSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = await readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session);\n}\n\ninterface State {\n\tsuccess: boolean;\n\terror?: Error;\n}\n\ntype Action =\n\t| { type: 'migrating' }\n\t| { type: 'migrated'; payload: true }\n\t| { type: 'error'; payload: Error };\n\nexport const useMigrations = (db: ExpoSQLiteDatabase<any>, migrations: {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}): State => {\n\tconst initialState: State = {\n\t\tsuccess: false,\n\t\terror: undefined,\n\t};\n\n\tconst fetchReducer = (state: State, action: Action): State => {\n\t\tswitch (action.type) {\n\t\t\tcase 'migrating': {\n\t\t\t\treturn { ...initialState };\n\t\t\t}\n\t\t\tcase 'migrated': {\n\t\t\t\treturn { ...initialState, success: action.payload };\n\t\t\t}\n\t\t\tcase 'error': {\n\t\t\t\treturn { ...initialState, error: action.payload };\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst [state, dispatch] = useReducer(fetchReducer, initialState);\n\n\tuseEffect(() => {\n\t\tdispatch({ type: 'migrating' });\n\t\tmigrate(db, migrations as any).then(() => {\n\t\t\tdispatch({ type: 'migrated', payload: true });\n\t\t}).catch((error) => {\n\t\t\tdispatch({ type: 'error', payload: error as Error });\n\t\t});\n\t}, []);\n\n\treturn state;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AAWtC,eAAe,mBAAmB,EAAE,SAAS,WAAW,GAA8C;AACrG,QAAM,mBAAoC,CAAC;AAE3C,mBAAiB,gBAAgB,QAAQ,SAAS;AACjD,UAAM,QAAQ,WAAW,IAAI,aAAa,IAAI,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAE3E,QAAI,CAAC,OAAO;AACX,YAAM,IAAI,MAAM,sBAAsB,aAAa,GAAG,EAAE;AAAA,IACzD;AAEA,QAAI;AACH,YAAM,SAAS,MAAM,MAAM,0BAA0B,EAAE,IAAI,CAAC,OAAO;AAClE,eAAO;AAAA,MACR,CAAC;AAED,uBAAiB,KAAK;AAAA,QACrB,KAAK;AAAA,QACL,KAAK,aAAa;AAAA,QAClB,cAAc,aAAa;AAAA,QAC3B,MAAM;AAAA,MACP,CAAC;AAAA,IACF,QAAQ;AACP,YAAM,IAAI,MAAM,8BAA8B,aAAa,GAAG,EAAE;AAAA,IACjE;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,MAAM,mBAAmB,MAAM;AAClD,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,OAAO;AACjD;AAYO,MAAM,gBAAgB,CAAC,IAA6B,eAK9C;AACZ,QAAM,eAAsB;AAAA,IAC3B,SAAS;AAAA,IACT,OAAO;AAAA,EACR;AAEA,QAAM,eAAe,CAACA,QAAc,WAA0B;AAC7D,YAAQ,OAAO,MAAM;AAAA,MACpB,KAAK,aAAa;AACjB,eAAO,EAAE,GAAG,aAAa;AAAA,MAC1B;AAAA,MACA,KAAK,YAAY;AAChB,eAAO,EAAE,GAAG,cAAc,SAAS,OAAO,QAAQ;AAAA,MACnD;AAAA,MACA,KAAK,SAAS;AACb,eAAO,EAAE,GAAG,cAAc,OAAO,OAAO,QAAQ;AAAA,MACjD;AAAA,MACA,SAAS;AACR,eAAOA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAW,cAAc,YAAY;AAE/D,8BAAU,MAAM;AACf,aAAS,EAAE,MAAM,YAAY,CAAC;AAC9B,YAAQ,IAAI,UAAiB,EAAE,KAAK,MAAM;AACzC,eAAS,EAAE,MAAM,YAAY,SAAS,KAAK,CAAC;AAAA,IAC7C,CAAC,EAAE,MAAM,CAAC,UAAU;AACnB,eAAS,EAAE,MAAM,SAAS,SAAS,MAAe,CAAC;AAAA,IACpD,CAAC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACR;","names":["state"]}

29
node_modules/drizzle-orm/expo-sqlite/migrator.d.cts generated vendored Normal file
View File

@ -0,0 +1,29 @@
import type { ExpoSQLiteDatabase } from "./driver.cjs";
interface MigrationConfig {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}
export declare function migrate<TSchema extends Record<string, unknown>>(db: ExpoSQLiteDatabase<TSchema>, config: MigrationConfig): Promise<void>;
interface State {
success: boolean;
error?: Error;
}
export declare const useMigrations: (db: ExpoSQLiteDatabase<any>, migrations: {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}) => State;
export {};

29
node_modules/drizzle-orm/expo-sqlite/migrator.d.ts generated vendored Normal file
View File

@ -0,0 +1,29 @@
import type { ExpoSQLiteDatabase } from "./driver.js";
interface MigrationConfig {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}
export declare function migrate<TSchema extends Record<string, unknown>>(db: ExpoSQLiteDatabase<TSchema>, config: MigrationConfig): Promise<void>;
interface State {
success: boolean;
error?: Error;
}
export declare const useMigrations: (db: ExpoSQLiteDatabase<any>, migrations: {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}) => State;
export {};

65
node_modules/drizzle-orm/expo-sqlite/migrator.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
import { useEffect, useReducer } from "react";
async function readMigrationFiles({ journal, migrations }) {
const migrationQueries = [];
for await (const journalEntry of journal.entries) {
const query = migrations[`m${journalEntry.idx.toString().padStart(4, "0")}`];
if (!query) {
throw new Error(`Missing migration: ${journalEntry.tag}`);
}
try {
const result = query.split("--> statement-breakpoint").map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: ""
});
} catch {
throw new Error(`Failed to parse migration: ${journalEntry.tag}`);
}
}
return migrationQueries;
}
async function migrate(db, config) {
const migrations = await readMigrationFiles(config);
return db.dialect.migrate(migrations, db.session);
}
const useMigrations = (db, migrations) => {
const initialState = {
success: false,
error: void 0
};
const fetchReducer = (state2, action) => {
switch (action.type) {
case "migrating": {
return { ...initialState };
}
case "migrated": {
return { ...initialState, success: action.payload };
}
case "error": {
return { ...initialState, error: action.payload };
}
default: {
return state2;
}
}
};
const [state, dispatch] = useReducer(fetchReducer, initialState);
useEffect(() => {
dispatch({ type: "migrating" });
migrate(db, migrations).then(() => {
dispatch({ type: "migrated", payload: true });
}).catch((error) => {
dispatch({ type: "error", payload: error });
});
}, []);
return state;
};
export {
migrate,
useMigrations
};
//# sourceMappingURL=migrator.js.map

1
node_modules/drizzle-orm/expo-sqlite/migrator.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/migrator.ts"],"sourcesContent":["import { useEffect, useReducer } from 'react';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { ExpoSQLiteDatabase } from './driver.ts';\n\ninterface MigrationConfig {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}\n\nasync function readMigrationFiles({ journal, migrations }: MigrationConfig): Promise<MigrationMeta[]> {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor await (const journalEntry of journal.entries) {\n\t\tconst query = migrations[`m${journalEntry.idx.toString().padStart(4, '0')}`];\n\n\t\tif (!query) {\n\t\t\tthrow new Error(`Missing migration: ${journalEntry.tag}`);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = query.split('--> statement-breakpoint').map((it) => {\n\t\t\t\treturn it;\n\t\t\t});\n\n\t\t\tmigrationQueries.push({\n\t\t\t\tsql: result,\n\t\t\t\tbps: journalEntry.breakpoints,\n\t\t\t\tfolderMillis: journalEntry.when,\n\t\t\t\thash: '',\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(`Failed to parse migration: ${journalEntry.tag}`);\n\t\t}\n\t}\n\n\treturn migrationQueries;\n}\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: ExpoSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = await readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session);\n}\n\ninterface State {\n\tsuccess: boolean;\n\terror?: Error;\n}\n\ntype Action =\n\t| { type: 'migrating' }\n\t| { type: 'migrated'; payload: true }\n\t| { type: 'error'; payload: Error };\n\nexport const useMigrations = (db: ExpoSQLiteDatabase<any>, migrations: {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}): State => {\n\tconst initialState: State = {\n\t\tsuccess: false,\n\t\terror: undefined,\n\t};\n\n\tconst fetchReducer = (state: State, action: Action): State => {\n\t\tswitch (action.type) {\n\t\t\tcase 'migrating': {\n\t\t\t\treturn { ...initialState };\n\t\t\t}\n\t\t\tcase 'migrated': {\n\t\t\t\treturn { ...initialState, success: action.payload };\n\t\t\t}\n\t\t\tcase 'error': {\n\t\t\t\treturn { ...initialState, error: action.payload };\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst [state, dispatch] = useReducer(fetchReducer, initialState);\n\n\tuseEffect(() => {\n\t\tdispatch({ type: 'migrating' });\n\t\tmigrate(db, migrations as any).then(() => {\n\t\t\tdispatch({ type: 'migrated', payload: true });\n\t\t}).catch((error) => {\n\t\t\tdispatch({ type: 'error', payload: error as Error });\n\t\t});\n\t}, []);\n\n\treturn state;\n};\n"],"mappings":"AAAA,SAAS,WAAW,kBAAkB;AAWtC,eAAe,mBAAmB,EAAE,SAAS,WAAW,GAA8C;AACrG,QAAM,mBAAoC,CAAC;AAE3C,mBAAiB,gBAAgB,QAAQ,SAAS;AACjD,UAAM,QAAQ,WAAW,IAAI,aAAa,IAAI,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAE3E,QAAI,CAAC,OAAO;AACX,YAAM,IAAI,MAAM,sBAAsB,aAAa,GAAG,EAAE;AAAA,IACzD;AAEA,QAAI;AACH,YAAM,SAAS,MAAM,MAAM,0BAA0B,EAAE,IAAI,CAAC,OAAO;AAClE,eAAO;AAAA,MACR,CAAC;AAED,uBAAiB,KAAK;AAAA,QACrB,KAAK;AAAA,QACL,KAAK,aAAa;AAAA,QAClB,cAAc,aAAa;AAAA,QAC3B,MAAM;AAAA,MACP,CAAC;AAAA,IACF,QAAQ;AACP,YAAM,IAAI,MAAM,8BAA8B,aAAa,GAAG,EAAE;AAAA,IACjE;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,MAAM,mBAAmB,MAAM;AAClD,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,OAAO;AACjD;AAYO,MAAM,gBAAgB,CAAC,IAA6B,eAK9C;AACZ,QAAM,eAAsB;AAAA,IAC3B,SAAS;AAAA,IACT,OAAO;AAAA,EACR;AAEA,QAAM,eAAe,CAACA,QAAc,WAA0B;AAC7D,YAAQ,OAAO,MAAM;AAAA,MACpB,KAAK,aAAa;AACjB,eAAO,EAAE,GAAG,aAAa;AAAA,MAC1B;AAAA,MACA,KAAK,YAAY;AAChB,eAAO,EAAE,GAAG,cAAc,SAAS,OAAO,QAAQ;AAAA,MACnD;AAAA,MACA,KAAK,SAAS;AACb,eAAO,EAAE,GAAG,cAAc,OAAO,OAAO,QAAQ;AAAA,MACjD;AAAA,MACA,SAAS;AACR,eAAOA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,cAAc,YAAY;AAE/D,YAAU,MAAM;AACf,aAAS,EAAE,MAAM,YAAY,CAAC;AAC9B,YAAQ,IAAI,UAAiB,EAAE,KAAK,MAAM;AACzC,eAAS,EAAE,MAAM,YAAY,SAAS,KAAK,CAAC;AAAA,IAC7C,CAAC,EAAE,MAAM,CAAC,UAAU;AACnB,eAAS,EAAE,MAAM,SAAS,SAAS,MAAe,CAAC;AAAA,IACpD,CAAC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACR;","names":["state"]}

71
node_modules/drizzle-orm/expo-sqlite/query.cjs generated vendored Normal file
View File

@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var query_exports = {};
__export(query_exports, {
useLiveQuery: () => useLiveQuery
});
module.exports = __toCommonJS(query_exports);
var import_expo_sqlite = require("expo-sqlite");
var import_react = require("react");
var import_entity = require("../entity.cjs");
var import_sql = require("../sql/sql.cjs");
var import_sqlite_core = require("../sqlite-core/index.cjs");
var import_query = require("../sqlite-core/query-builders/query.cjs");
var import_subquery = require("../subquery.cjs");
const useLiveQuery = (query, deps = []) => {
const [data, setData] = (0, import_react.useState)(
(0, import_entity.is)(query, import_query.SQLiteRelationalQuery) && query.mode === "first" ? void 0 : []
);
const [error, setError] = (0, import_react.useState)();
const [updatedAt, setUpdatedAt] = (0, import_react.useState)();
(0, import_react.useEffect)(() => {
const entity = (0, import_entity.is)(query, import_query.SQLiteRelationalQuery) ? query.table : query.config.table;
if ((0, import_entity.is)(entity, import_subquery.Subquery) || (0, import_entity.is)(entity, import_sql.SQL)) {
setError(new Error("Selecting from subqueries and SQL are not supported in useLiveQuery"));
return;
}
let listener;
const handleData = (data2) => {
setData(data2);
setUpdatedAt(/* @__PURE__ */ new Date());
};
query.then(handleData).catch(setError);
if ((0, import_entity.is)(entity, import_sqlite_core.SQLiteTable) || (0, import_entity.is)(entity, import_sqlite_core.SQLiteView)) {
const config = (0, import_entity.is)(entity, import_sqlite_core.SQLiteTable) ? (0, import_sqlite_core.getTableConfig)(entity) : (0, import_sqlite_core.getViewConfig)(entity);
listener = (0, import_expo_sqlite.addDatabaseChangeListener)(({ tableName }) => {
if (config.name === tableName) {
query.then(handleData).catch(setError);
}
});
}
return () => {
listener?.remove();
};
}, deps);
return {
data,
error,
updatedAt
};
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
useLiveQuery
});
//# sourceMappingURL=query.cjs.map

1
node_modules/drizzle-orm/expo-sqlite/query.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/query.ts"],"sourcesContent":["import { addDatabaseChangeListener } from 'expo-sqlite';\nimport { useEffect, useState } from 'react';\nimport { is } from '~/entity.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport type { AnySQLiteSelect } from '~/sqlite-core/index.ts';\nimport { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from '~/sqlite-core/index.ts';\nimport { SQLiteRelationalQuery } from '~/sqlite-core/query-builders/query.ts';\nimport { Subquery } from '~/subquery.ts';\n\nexport const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQLiteRelationalQuery<'sync', unknown>>(\n\tquery: T,\n\tdeps: unknown[] = [],\n) => {\n\tconst [data, setData] = useState<Awaited<T>>(\n\t\t(is(query, SQLiteRelationalQuery) && query.mode === 'first' ? undefined : []) as Awaited<T>,\n\t);\n\tconst [error, setError] = useState<Error>();\n\tconst [updatedAt, setUpdatedAt] = useState<Date>();\n\n\tuseEffect(() => {\n\t\tconst entity = is(query, SQLiteRelationalQuery) ? query.table : (query as AnySQLiteSelect).config.table;\n\n\t\tif (is(entity, Subquery) || is(entity, SQL)) {\n\t\t\tsetError(new Error('Selecting from subqueries and SQL are not supported in useLiveQuery'));\n\t\t\treturn;\n\t\t}\n\n\t\tlet listener: ReturnType<typeof addDatabaseChangeListener> | undefined;\n\n\t\tconst handleData = (data: any) => {\n\t\t\tsetData(data);\n\t\t\tsetUpdatedAt(new Date());\n\t\t};\n\n\t\tquery.then(handleData).catch(setError);\n\n\t\tif (is(entity, SQLiteTable) || is(entity, SQLiteView)) {\n\t\t\tconst config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);\n\t\t\tlistener = addDatabaseChangeListener(({ tableName }) => {\n\t\t\t\tif (config.name === tableName) {\n\t\t\t\t\tquery.then(handleData).catch(setError);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\tlistener?.remove();\n\t\t};\n\t}, deps);\n\n\treturn {\n\t\tdata,\n\t\terror,\n\t\tupdatedAt,\n\t} as const;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA0C;AAC1C,mBAAoC;AACpC,oBAAmB;AACnB,iBAAoB;AAEpB,yBAAuE;AACvE,mBAAsC;AACtC,sBAAyB;AAElB,MAAM,eAAe,CAC3B,OACA,OAAkB,CAAC,MACf;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI;AAAA,QACtB,kBAAG,OAAO,kCAAqB,KAAK,MAAM,SAAS,UAAU,SAAY,CAAC;AAAA,EAC5E;AACA,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAgB;AAC1C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAe;AAEjD,8BAAU,MAAM;AACf,UAAM,aAAS,kBAAG,OAAO,kCAAqB,IAAI,MAAM,QAAS,MAA0B,OAAO;AAElG,YAAI,kBAAG,QAAQ,wBAAQ,SAAK,kBAAG,QAAQ,cAAG,GAAG;AAC5C,eAAS,IAAI,MAAM,qEAAqE,CAAC;AACzF;AAAA,IACD;AAEA,QAAI;AAEJ,UAAM,aAAa,CAACA,UAAc;AACjC,cAAQA,KAAI;AACZ,mBAAa,oBAAI,KAAK,CAAC;AAAA,IACxB;AAEA,UAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAErC,YAAI,kBAAG,QAAQ,8BAAW,SAAK,kBAAG,QAAQ,6BAAU,GAAG;AACtD,YAAM,aAAS,kBAAG,QAAQ,8BAAW,QAAI,mCAAe,MAAM,QAAI,kCAAc,MAAM;AACtF,qBAAW,8CAA0B,CAAC,EAAE,UAAU,MAAM;AACvD,YAAI,OAAO,SAAS,WAAW;AAC9B,gBAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAAA,QACtC;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,MAAM;AACZ,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD,GAAG,IAAI;AAEP,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["data"]}

7
node_modules/drizzle-orm/expo-sqlite/query.d.cts generated vendored Normal file
View File

@ -0,0 +1,7 @@
import type { AnySQLiteSelect } from "../sqlite-core/index.cjs";
import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.cjs";
export declare const useLiveQuery: <T extends Pick<AnySQLiteSelect, "_" | "then"> | SQLiteRelationalQuery<"sync", unknown>>(query: T, deps?: unknown[]) => {
readonly data: Awaited<T>;
readonly error: Error | undefined;
readonly updatedAt: Date | undefined;
};

7
node_modules/drizzle-orm/expo-sqlite/query.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
import type { AnySQLiteSelect } from "../sqlite-core/index.js";
import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.js";
export declare const useLiveQuery: <T extends Pick<AnySQLiteSelect, "_" | "then"> | SQLiteRelationalQuery<"sync", unknown>>(query: T, deps?: unknown[]) => {
readonly data: Awaited<T>;
readonly error: Error | undefined;
readonly updatedAt: Date | undefined;
};

47
node_modules/drizzle-orm/expo-sqlite/query.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
import { addDatabaseChangeListener } from "expo-sqlite";
import { useEffect, useState } from "react";
import { is } from "../entity.js";
import { SQL } from "../sql/sql.js";
import { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from "../sqlite-core/index.js";
import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.js";
import { Subquery } from "../subquery.js";
const useLiveQuery = (query, deps = []) => {
const [data, setData] = useState(
is(query, SQLiteRelationalQuery) && query.mode === "first" ? void 0 : []
);
const [error, setError] = useState();
const [updatedAt, setUpdatedAt] = useState();
useEffect(() => {
const entity = is(query, SQLiteRelationalQuery) ? query.table : query.config.table;
if (is(entity, Subquery) || is(entity, SQL)) {
setError(new Error("Selecting from subqueries and SQL are not supported in useLiveQuery"));
return;
}
let listener;
const handleData = (data2) => {
setData(data2);
setUpdatedAt(/* @__PURE__ */ new Date());
};
query.then(handleData).catch(setError);
if (is(entity, SQLiteTable) || is(entity, SQLiteView)) {
const config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);
listener = addDatabaseChangeListener(({ tableName }) => {
if (config.name === tableName) {
query.then(handleData).catch(setError);
}
});
}
return () => {
listener?.remove();
};
}, deps);
return {
data,
error,
updatedAt
};
};
export {
useLiveQuery
};
//# sourceMappingURL=query.js.map

1
node_modules/drizzle-orm/expo-sqlite/query.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/expo-sqlite/query.ts"],"sourcesContent":["import { addDatabaseChangeListener } from 'expo-sqlite';\nimport { useEffect, useState } from 'react';\nimport { is } from '~/entity.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport type { AnySQLiteSelect } from '~/sqlite-core/index.ts';\nimport { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from '~/sqlite-core/index.ts';\nimport { SQLiteRelationalQuery } from '~/sqlite-core/query-builders/query.ts';\nimport { Subquery } from '~/subquery.ts';\n\nexport const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQLiteRelationalQuery<'sync', unknown>>(\n\tquery: T,\n\tdeps: unknown[] = [],\n) => {\n\tconst [data, setData] = useState<Awaited<T>>(\n\t\t(is(query, SQLiteRelationalQuery) && query.mode === 'first' ? undefined : []) as Awaited<T>,\n\t);\n\tconst [error, setError] = useState<Error>();\n\tconst [updatedAt, setUpdatedAt] = useState<Date>();\n\n\tuseEffect(() => {\n\t\tconst entity = is(query, SQLiteRelationalQuery) ? query.table : (query as AnySQLiteSelect).config.table;\n\n\t\tif (is(entity, Subquery) || is(entity, SQL)) {\n\t\t\tsetError(new Error('Selecting from subqueries and SQL are not supported in useLiveQuery'));\n\t\t\treturn;\n\t\t}\n\n\t\tlet listener: ReturnType<typeof addDatabaseChangeListener> | undefined;\n\n\t\tconst handleData = (data: any) => {\n\t\t\tsetData(data);\n\t\t\tsetUpdatedAt(new Date());\n\t\t};\n\n\t\tquery.then(handleData).catch(setError);\n\n\t\tif (is(entity, SQLiteTable) || is(entity, SQLiteView)) {\n\t\t\tconst config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);\n\t\t\tlistener = addDatabaseChangeListener(({ tableName }) => {\n\t\t\t\tif (config.name === tableName) {\n\t\t\t\t\tquery.then(handleData).catch(setError);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\tlistener?.remove();\n\t\t};\n\t}, deps);\n\n\treturn {\n\t\tdata,\n\t\terror,\n\t\tupdatedAt,\n\t} as const;\n};\n"],"mappings":"AAAA,SAAS,iCAAiC;AAC1C,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU;AACnB,SAAS,WAAW;AAEpB,SAAS,gBAAgB,eAAe,aAAa,kBAAkB;AACvE,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,MAAM,eAAe,CAC3B,OACA,OAAkB,CAAC,MACf;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,GAAG,OAAO,qBAAqB,KAAK,MAAM,SAAS,UAAU,SAAY,CAAC;AAAA,EAC5E;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAgB;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAe;AAEjD,YAAU,MAAM;AACf,UAAM,SAAS,GAAG,OAAO,qBAAqB,IAAI,MAAM,QAAS,MAA0B,OAAO;AAElG,QAAI,GAAG,QAAQ,QAAQ,KAAK,GAAG,QAAQ,GAAG,GAAG;AAC5C,eAAS,IAAI,MAAM,qEAAqE,CAAC;AACzF;AAAA,IACD;AAEA,QAAI;AAEJ,UAAM,aAAa,CAACA,UAAc;AACjC,cAAQA,KAAI;AACZ,mBAAa,oBAAI,KAAK,CAAC;AAAA,IACxB;AAEA,UAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAErC,QAAI,GAAG,QAAQ,WAAW,KAAK,GAAG,QAAQ,UAAU,GAAG;AACtD,YAAM,SAAS,GAAG,QAAQ,WAAW,IAAI,eAAe,MAAM,IAAI,cAAc,MAAM;AACtF,iBAAW,0BAA0B,CAAC,EAAE,UAAU,MAAM;AACvD,YAAI,OAAO,SAAS,WAAW;AAC9B,gBAAM,KAAK,UAAU,EAAE,MAAM,QAAQ;AAAA,QACtC;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,MAAM;AACZ,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD,GAAG,IAAI;AAEP,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["data"]}

147
node_modules/drizzle-orm/expo-sqlite/session.cjs generated vendored Normal file
View File

@ -0,0 +1,147 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var session_exports = {};
__export(session_exports, {
ExpoSQLitePreparedQuery: () => ExpoSQLitePreparedQuery,
ExpoSQLiteSession: () => ExpoSQLiteSession,
ExpoSQLiteTransaction: () => ExpoSQLiteTransaction
});
module.exports = __toCommonJS(session_exports);
var import_entity = require("../entity.cjs");
var import_logger = require("../logger.cjs");
var import_sql = require("../sql/sql.cjs");
var import_sqlite_core = require("../sqlite-core/index.cjs");
var import_session = require("../sqlite-core/session.cjs");
var import_utils = require("../utils.cjs");
class ExpoSQLiteSession extends import_session.SQLiteSession {
constructor(client, dialect, schema, options = {}) {
super(dialect);
this.client = client;
this.schema = schema;
this.logger = options.logger ?? new import_logger.NoopLogger();
}
static [import_entity.entityKind] = "ExpoSQLiteSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
const stmt = this.client.prepareSync(query.sql);
return new ExpoSQLitePreparedQuery(
stmt,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper
);
}
transaction(transaction, config = {}) {
const tx = new ExpoSQLiteTransaction("sync", this.dialect, this, this.schema);
this.run(import_sql.sql.raw(`begin${config?.behavior ? " " + config.behavior : ""}`));
try {
const result = transaction(tx);
this.run(import_sql.sql`commit`);
return result;
} catch (err) {
this.run(import_sql.sql`rollback`);
throw err;
}
}
}
class ExpoSQLiteTransaction extends import_sqlite_core.SQLiteTransaction {
static [import_entity.entityKind] = "ExpoSQLiteTransaction";
transaction(transaction) {
const savepointName = `sp${this.nestedIndex}`;
const tx = new ExpoSQLiteTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
this.session.run(import_sql.sql.raw(`savepoint ${savepointName}`));
try {
const result = transaction(tx);
this.session.run(import_sql.sql.raw(`release savepoint ${savepointName}`));
return result;
} catch (err) {
this.session.run(import_sql.sql.raw(`rollback to savepoint ${savepointName}`));
throw err;
}
}
}
class ExpoSQLitePreparedQuery extends import_session.SQLitePreparedQuery {
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
super("sync", executeMethod, query);
this.stmt = stmt;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [import_entity.entityKind] = "ExpoSQLitePreparedQuery";
run(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { changes, lastInsertRowId } = this.stmt.executeSync(params);
return {
changes,
lastInsertRowId
};
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return stmt.executeSync(params).getAllSync();
}
const rows = this.values(placeholderValues);
if (customResultMapper) {
return customResultMapper(rows);
}
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
}
get(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return stmt.executeSync(params).getFirstSync();
}
const rows = this.values(placeholderValues);
const row = rows[0];
if (!row) {
return void 0;
}
if (customResultMapper) {
return customResultMapper(rows);
}
return (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap);
}
values(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
return this.stmt.executeForRawResultSync(params).getAllSync();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ExpoSQLitePreparedQuery,
ExpoSQLiteSession,
ExpoSQLiteTransaction
});
//# sourceMappingURL=session.cjs.map

1
node_modules/drizzle-orm/expo-sqlite/session.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

47
node_modules/drizzle-orm/expo-sqlite/session.d.cts generated vendored Normal file
View File

@ -0,0 +1,47 @@
import type { SQLiteDatabase, SQLiteRunResult, SQLiteStatement } from 'expo-sqlite';
import { entityKind } from "../entity.cjs";
import type { Logger } from "../logger.cjs";
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
import { type Query } from "../sql/sql.cjs";
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.cjs";
import { SQLiteTransaction } from "../sqlite-core/index.cjs";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.cjs";
import { type PreparedQueryConfig as PreparedQueryConfigBase, type SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.cjs";
export interface ExpoSQLiteSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class ExpoSQLiteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', SQLiteRunResult, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: SQLiteDatabase, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: ExpoSQLiteSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): ExpoSQLitePreparedQuery<T>;
transaction<T>(transaction: (tx: ExpoSQLiteTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
}
export declare class ExpoSQLiteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', SQLiteRunResult, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: ExpoSQLiteTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class ExpoSQLitePreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{
type: 'sync';
run: SQLiteRunResult;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private stmt;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(stmt: SQLiteStatement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
run(placeholderValues?: Record<string, unknown>): SQLiteRunResult;
all(placeholderValues?: Record<string, unknown>): T['all'];
get(placeholderValues?: Record<string, unknown>): T['get'];
values(placeholderValues?: Record<string, unknown>): T['values'];
}
export {};

47
node_modules/drizzle-orm/expo-sqlite/session.d.ts generated vendored Normal file
View File

@ -0,0 +1,47 @@
import type { SQLiteDatabase, SQLiteRunResult, SQLiteStatement } from 'expo-sqlite';
import { entityKind } from "../entity.js";
import type { Logger } from "../logger.js";
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
import { type Query } from "../sql/sql.js";
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.js";
import { type PreparedQueryConfig as PreparedQueryConfigBase, type SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.js";
export interface ExpoSQLiteSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class ExpoSQLiteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', SQLiteRunResult, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: SQLiteDatabase, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: ExpoSQLiteSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): ExpoSQLitePreparedQuery<T>;
transaction<T>(transaction: (tx: ExpoSQLiteTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
}
export declare class ExpoSQLiteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', SQLiteRunResult, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: ExpoSQLiteTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class ExpoSQLitePreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{
type: 'sync';
run: SQLiteRunResult;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private stmt;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(stmt: SQLiteStatement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
run(placeholderValues?: Record<string, unknown>): SQLiteRunResult;
all(placeholderValues?: Record<string, unknown>): T['all'];
get(placeholderValues?: Record<string, unknown>): T['get'];
values(placeholderValues?: Record<string, unknown>): T['values'];
}
export {};

124
node_modules/drizzle-orm/expo-sqlite/session.js generated vendored Normal file
View File

@ -0,0 +1,124 @@
import { entityKind } from "../entity.js";
import { NoopLogger } from "../logger.js";
import { fillPlaceholders, sql } from "../sql/sql.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import {
SQLitePreparedQuery,
SQLiteSession
} from "../sqlite-core/session.js";
import { mapResultRow } from "../utils.js";
class ExpoSQLiteSession extends SQLiteSession {
constructor(client, dialect, schema, options = {}) {
super(dialect);
this.client = client;
this.schema = schema;
this.logger = options.logger ?? new NoopLogger();
}
static [entityKind] = "ExpoSQLiteSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
const stmt = this.client.prepareSync(query.sql);
return new ExpoSQLitePreparedQuery(
stmt,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper
);
}
transaction(transaction, config = {}) {
const tx = new ExpoSQLiteTransaction("sync", this.dialect, this, this.schema);
this.run(sql.raw(`begin${config?.behavior ? " " + config.behavior : ""}`));
try {
const result = transaction(tx);
this.run(sql`commit`);
return result;
} catch (err) {
this.run(sql`rollback`);
throw err;
}
}
}
class ExpoSQLiteTransaction extends SQLiteTransaction {
static [entityKind] = "ExpoSQLiteTransaction";
transaction(transaction) {
const savepointName = `sp${this.nestedIndex}`;
const tx = new ExpoSQLiteTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
this.session.run(sql.raw(`savepoint ${savepointName}`));
try {
const result = transaction(tx);
this.session.run(sql.raw(`release savepoint ${savepointName}`));
return result;
} catch (err) {
this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
throw err;
}
}
}
class ExpoSQLitePreparedQuery extends SQLitePreparedQuery {
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
super("sync", executeMethod, query);
this.stmt = stmt;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [entityKind] = "ExpoSQLitePreparedQuery";
run(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { changes, lastInsertRowId } = this.stmt.executeSync(params);
return {
changes,
lastInsertRowId
};
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return stmt.executeSync(params).getAllSync();
}
const rows = this.values(placeholderValues);
if (customResultMapper) {
return customResultMapper(rows);
}
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
}
get(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return stmt.executeSync(params).getFirstSync();
}
const rows = this.values(placeholderValues);
const row = rows[0];
if (!row) {
return void 0;
}
if (customResultMapper) {
return customResultMapper(rows);
}
return mapResultRow(fields, row, joinsNotNullableMap);
}
values(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
return this.stmt.executeForRawResultSync(params).getAllSync();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
export {
ExpoSQLitePreparedQuery,
ExpoSQLiteSession,
ExpoSQLiteTransaction
};
//# sourceMappingURL=session.js.map

1
node_modules/drizzle-orm/expo-sqlite/session.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long