@payloadcms/db-sqlite 3.73.0-internal.f0458fb → 3.73.0
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/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +12 -0
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/blocks-as-json.d.ts +3 -0
- package/dist/predefinedMigrations/blocks-as-json.d.ts.map +1 -0
- package/dist/predefinedMigrations/blocks-as-json.js +6 -0
- package/dist/predefinedMigrations/blocks-as-json.js.map +1 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,SAAS,CAAA;AAQjD,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,SAAS,CAAA;AAQjD,eAAO,MAAM,OAAO,EAAE,OAkErB,CAAA"}
|
package/dist/connect.js
CHANGED
|
@@ -8,6 +8,18 @@ export const connect = async function connect(options = {
|
|
|
8
8
|
try {
|
|
9
9
|
if (!this.client) {
|
|
10
10
|
this.client = createClient(this.clientConfig);
|
|
11
|
+
if (this.busyTimeout > 0) {
|
|
12
|
+
await this.client.execute(`PRAGMA busy_timeout = ${this.busyTimeout};`);
|
|
13
|
+
}
|
|
14
|
+
if (this.wal) {
|
|
15
|
+
const result = await this.client.execute('PRAGMA journal_mode;');
|
|
16
|
+
if (result.rows[0]?.journal_mode !== 'wal') {
|
|
17
|
+
this.payload.logger.info(`[db-sqlite] Enabling WAL mode with journal size limit ${this.wal.journalSizeLimit}.`);
|
|
18
|
+
await this.client.execute(`PRAGMA journal_mode = WAL;`);
|
|
19
|
+
await this.client.execute(`PRAGMA journal_size_limit = ${this.wal.journalSizeLimit};`);
|
|
20
|
+
}
|
|
21
|
+
await this.client.execute(`PRAGMA synchronous = ${this.wal.synchronous};`);
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
24
|
const logger = this.logger || false;
|
|
13
25
|
this.drizzle = drizzle(this.client, {
|
package/dist/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration } from 'payload'\n\nimport { createClient } from '@libsql/client'\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/libsql'\n\nimport type { SQLiteAdapter } from './types.js'\n\nexport const connect: Connect = async function connect(\n this: SQLiteAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n if (!this.client) {\n this.client = createClient(this.clientConfig)\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.client, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n this.payload.logger.error({ err, msg: `Error: cannot connect to SQLite: ${message}` })\n if (typeof this.rejectInitializing === 'function') {\n this.rejectInitializing()\n }\n throw new Error(`Error: cannot connect to SQLite: ${message}`)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') {\n this.resolveInitializing()\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations as Migration[] })\n }\n}\n"],"names":["createClient","pushDevSchema","drizzle","connect","options","hotReload","client","clientConfig","
|
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration } from 'payload'\n\nimport { createClient } from '@libsql/client'\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/libsql'\n\nimport type { SQLiteAdapter } from './types.js'\n\nexport const connect: Connect = async function connect(\n this: SQLiteAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n if (!this.client) {\n this.client = createClient(this.clientConfig)\n\n if (this.busyTimeout > 0) {\n await this.client.execute(`PRAGMA busy_timeout = ${this.busyTimeout};`)\n }\n\n if (this.wal) {\n const result = await this.client.execute('PRAGMA journal_mode;')\n\n if (result.rows[0]?.journal_mode !== 'wal') {\n this.payload.logger.info(\n `[db-sqlite] Enabling WAL mode with journal size limit ${this.wal.journalSizeLimit}.`,\n )\n await this.client.execute(`PRAGMA journal_mode = WAL;`)\n await this.client.execute(`PRAGMA journal_size_limit = ${this.wal.journalSizeLimit};`)\n }\n\n await this.client.execute(`PRAGMA synchronous = ${this.wal.synchronous};`)\n }\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.client, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n this.payload.logger.error({ err, msg: `Error: cannot connect to SQLite: ${message}` })\n if (typeof this.rejectInitializing === 'function') {\n this.rejectInitializing()\n }\n throw new Error(`Error: cannot connect to SQLite: ${message}`)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') {\n this.resolveInitializing()\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations as Migration[] })\n }\n}\n"],"names":["createClient","pushDevSchema","drizzle","connect","options","hotReload","client","clientConfig","busyTimeout","execute","wal","result","rows","journal_mode","payload","logger","info","journalSizeLimit","synchronous","schema","process","env","PAYLOAD_DROP_DATABASE","dropDatabase","adapter","err","message","Error","String","error","msg","rejectInitializing","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"AAGA,SAASA,YAAY,QAAQ,iBAAgB;AAC7C,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,OAAO,QAAQ,qBAAoB;AAI5C,OAAO,MAAMC,UAAmB,eAAeA,QAE7CC,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI;QACF,IAAI,CAAC,IAAI,CAACE,MAAM,EAAE;YAChB,IAAI,CAACA,MAAM,GAAGN,aAAa,IAAI,CAACO,YAAY;YAE5C,IAAI,IAAI,CAACC,WAAW,GAAG,GAAG;gBACxB,MAAM,IAAI,CAACF,MAAM,CAACG,OAAO,CAAC,CAAC,sBAAsB,EAAE,IAAI,CAACD,WAAW,CAAC,CAAC,CAAC;YACxE;YAEA,IAAI,IAAI,CAACE,GAAG,EAAE;gBACZ,MAAMC,SAAS,MAAM,IAAI,CAACL,MAAM,CAACG,OAAO,CAAC;gBAEzC,IAAIE,OAAOC,IAAI,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M,CAAC,iCAAiC,EAAED,SAAS;IAC/D;IAEA,wCAAwC;IACxC,IACEN,QAAQC,GAAG,CAACW,QAAQ,KAAK,gBACzBZ,QAAQC,GAAG,CAACY,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMjC,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACkC,mBAAmB,KAAK,YAAY;QAClD,IAAI,CAACA,mBAAmB;IAC1B;IAEA,IAAIf,QAAQC,GAAG,CAACW,QAAQ,KAAK,gBAAgB,IAAI,CAACI,cAAc,EAAE;QAChE,MAAM,IAAI,CAACC,OAAO,CAAC;YAAEC,YAAY,IAAI,CAACF,cAAc;QAAgB;IACtE;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { getBlocksToJsonMigrator } from '@payloadcms/drizzle'\n"],"names":["getBlocksToJsonMigrator"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,sBAAqB"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AA2D1D,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAa,MAAM,YAAY,CAAA;AAMhE,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAkL3E;AAED;;GAEG;AACH,YAAY,EACV,IAAI,IAAI,iBAAiB,EACzB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,OAAO,EACP,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,MAAM,EACN,MAAM,EACN,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { beginTransaction, buildCreateMigration, commitTransaction, count, countGlobalVersions, countVersions, create, createGlobal, createGlobalVersion, createSchemaGenerator, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findDistinct, findGlobal, findGlobalVersions, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateJobs, updateMany, updateOne, updateVersion, upsert } from '@payloadcms/drizzle';
|
|
1
|
+
import { beginTransaction, buildCreateMigration, commitTransaction, count, countGlobalVersions, countVersions, create, createBlocksToJsonMigrator, createGlobal, createGlobalVersion, createSchemaGenerator, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findDistinct, findGlobal, findGlobalVersions, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateJobs, updateMany, updateOne, updateVersion, upsert } from '@payloadcms/drizzle';
|
|
2
2
|
import { columnToCodeConverter, convertPathToJSONTraversal, countDistinct, createJSONQuery, defaultDrizzleSnapshot, deleteWhere, dropDatabase, execute, init, insert, requireDrizzleKit } from '@payloadcms/drizzle/sqlite';
|
|
3
3
|
import { like, notLike } from 'drizzle-orm';
|
|
4
4
|
import { createDatabaseAdapter, defaultBeginTransaction, findMigrationDir } from 'payload';
|
|
@@ -24,13 +24,38 @@ export function sqliteAdapter(args) {
|
|
|
24
24
|
like,
|
|
25
25
|
not_like: notLike
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
let wal = false;
|
|
28
|
+
const defaultJournalSizeLimit = 67108864 // 64MB
|
|
29
|
+
;
|
|
30
|
+
if (args.wal && !args.client.url.startsWith('file:')) {
|
|
31
|
+
payload.logger.warn('[db-sqlite] WAL mode is not supported for in-memory or TCP database connections. Disabling WAL.');
|
|
32
|
+
args.wal = false;
|
|
33
|
+
}
|
|
34
|
+
if (!args.wal) {
|
|
35
|
+
wal = false;
|
|
36
|
+
} else if (args.wal === true) {
|
|
37
|
+
wal = {
|
|
38
|
+
journalSizeLimit: defaultJournalSizeLimit,
|
|
39
|
+
synchronous: 'FULL'
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
wal = {
|
|
43
|
+
journalSizeLimit: args.wal.journalSizeLimit ?? defaultJournalSizeLimit,
|
|
44
|
+
synchronous: args.wal.synchronous ?? 'FULL'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const executeMethod = 'run';
|
|
48
|
+
const sanitizeStatements = ({ sqlExecute, statements })=>{
|
|
49
|
+
return statements.map((statement)=>`${sqlExecute}${statement?.replaceAll('`', '\\`')}\`)`).join('\n');
|
|
50
|
+
};
|
|
51
|
+
const adapter = createDatabaseAdapter({
|
|
28
52
|
name: 'sqlite',
|
|
29
53
|
afterSchemaInit: args.afterSchemaInit ?? [],
|
|
30
54
|
allowIDOnCreate,
|
|
31
55
|
autoIncrement: args.autoIncrement ?? false,
|
|
32
56
|
beforeSchemaInit: args.beforeSchemaInit ?? [],
|
|
33
57
|
blocksAsJSON: args.blocksAsJSON ?? false,
|
|
58
|
+
busyTimeout: args.busyTimeout ?? 0,
|
|
34
59
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
35
60
|
client: undefined,
|
|
36
61
|
clientConfig: args.client,
|
|
@@ -54,6 +79,7 @@ export function sqliteAdapter(args) {
|
|
|
54
79
|
logger: args.logger,
|
|
55
80
|
operators,
|
|
56
81
|
prodMigrations: args.prodMigrations,
|
|
82
|
+
wal,
|
|
57
83
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
58
84
|
push: args.push,
|
|
59
85
|
rawRelations: {},
|
|
@@ -84,11 +110,9 @@ export function sqliteAdapter(args) {
|
|
|
84
110
|
createGlobalVersion,
|
|
85
111
|
createJSONQuery,
|
|
86
112
|
createMigration: buildCreateMigration({
|
|
87
|
-
executeMethod
|
|
113
|
+
executeMethod,
|
|
88
114
|
filename,
|
|
89
|
-
sanitizeStatements
|
|
90
|
-
return statements.map((statement)=>`${sqlExecute}${statement?.replaceAll('`', '\\`')}\`)`).join('\n');
|
|
91
|
-
}
|
|
115
|
+
sanitizeStatements
|
|
92
116
|
}),
|
|
93
117
|
createVersion,
|
|
94
118
|
defaultIDType: payloadIDType,
|
|
@@ -128,6 +152,12 @@ export function sqliteAdapter(args) {
|
|
|
128
152
|
updateVersion,
|
|
129
153
|
upsert
|
|
130
154
|
});
|
|
155
|
+
adapter.blocksToJsonMigrator = createBlocksToJsonMigrator({
|
|
156
|
+
adapter: adapter,
|
|
157
|
+
executeMethod,
|
|
158
|
+
sanitizeStatements
|
|
159
|
+
});
|
|
160
|
+
return adapter;
|
|
131
161
|
}
|
|
132
162
|
return {
|
|
133
163
|
name: 'sqlite',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Operators } from '@payloadcms/drizzle'\nimport type { DatabaseAdapterObj, Payload } from 'payload'\n\nimport {\n beginTransaction,\n buildCreateMigration,\n commitTransaction,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createSchemaGenerator,\n createVersion,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n operatorMap,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateJobs,\n updateMany,\n updateOne,\n updateVersion,\n upsert,\n} from '@payloadcms/drizzle'\nimport {\n columnToCodeConverter,\n convertPathToJSONTraversal,\n countDistinct,\n createJSONQuery,\n defaultDrizzleSnapshot,\n deleteWhere,\n dropDatabase,\n execute,\n init,\n insert,\n requireDrizzleKit,\n} from '@payloadcms/drizzle/sqlite'\nimport { like, notLike } from 'drizzle-orm'\nimport { createDatabaseAdapter, defaultBeginTransaction, findMigrationDir } from 'payload'\nimport { fileURLToPath } from 'url'\n\nimport type { Args, SQLiteAdapter } from './types.js'\n\nimport { connect } from './connect.js'\n\nconst filename = fileURLToPath(import.meta.url)\n\nexport function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {\n const sqliteIDType = args.idType || 'number'\n const payloadIDType = sqliteIDType === 'uuid' ? 'text' : 'number'\n const allowIDOnCreate = args.allowIDOnCreate ?? false\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing: () => void = () => {}\n let rejectInitializing: () => void = () => {}\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n // sqlite's like operator is case-insensitive, so we overwrite the DrizzleAdapter operators to not use ilike\n const operators = {\n ...operatorMap,\n contains: like,\n like,\n not_like: notLike,\n } as unknown as Operators\n\n return createDatabaseAdapter<SQLiteAdapter>({\n name: 'sqlite',\n afterSchemaInit: args.afterSchemaInit ?? [],\n allowIDOnCreate,\n autoIncrement: args.autoIncrement ?? false,\n beforeSchemaInit: args.beforeSchemaInit ?? [],\n blocksAsJSON: args.blocksAsJSON ?? false,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n client: undefined,\n clientConfig: args.client,\n defaultDrizzleSnapshot,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n drizzle: undefined,\n features: {\n json: true,\n },\n fieldConstraints: {},\n findDistinct,\n generateSchema: createSchemaGenerator({\n columnToCodeConverter,\n corePackageSuffix: 'sqlite-core',\n defaultOutputFile: args.generateSchemaOutputFile,\n tableImport: 'sqliteTable',\n }),\n idType: sqliteIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n operators,\n prodMigrations: args.prodMigrations,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n push: args.push,\n rawRelations: {},\n rawTables: {},\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n transactionOptions: args.transactionOptions || undefined,\n updateJobs,\n updateMany,\n versionsSuffix: args.versionsSuffix || '_v',\n // DatabaseAdapter\n beginTransaction: args.transactionOptions ? beginTransaction : defaultBeginTransaction(),\n commitTransaction,\n connect,\n convertPathToJSONTraversal,\n count,\n countDistinct,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createJSONQuery,\n createMigration: buildCreateMigration({\n executeMethod: 'run',\n filename,\n sanitizeStatements({ sqlExecute, statements }) {\n return statements\n .map((statement) => `${sqlExecute}${statement?.replaceAll('`', '\\\\`')}\\`)`)\n .join('\\n')\n },\n }),\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n deleteWhere,\n destroy,\n dropDatabase,\n execute,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n foreignKeys: new Set(),\n indexes: new Set<string>(),\n init,\n insert,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n packageName: '@payloadcms/db-sqlite',\n payload,\n queryDrafts,\n rejectInitializing,\n requireDrizzleKit,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n upsert,\n })\n }\n\n return {\n name: 'sqlite',\n allowIDOnCreate,\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\n/**\n * @todo deprecate /types subpath export in 4.0\n */\nexport type {\n Args as SQLiteAdapterArgs,\n CountDistinct,\n DeleteWhere,\n DropDatabase,\n Execute,\n GeneratedDatabaseSchema,\n GenericColumns,\n GenericRelation,\n GenericTable,\n IDType,\n Insert,\n MigrateDownArgs,\n MigrateUpArgs,\n SQLiteAdapter,\n SQLiteSchemaHook,\n} from './types.js'\n\nexport { sql } from 'drizzle-orm'\n"],"names":["beginTransaction","buildCreateMigration","commitTransaction","count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createSchemaGenerator","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","columnToCodeConverter","convertPathToJSONTraversal","countDistinct","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","requireDrizzleKit","like","notLike","createDatabaseAdapter","defaultBeginTransaction","findMigrationDir","fileURLToPath","connect","filename","url","sqliteAdapter","args","sqliteIDType","idType","payloadIDType","allowIDOnCreate","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","operators","contains","not_like","name","afterSchemaInit","autoIncrement","beforeSchemaInit","blocksAsJSON","client","undefined","clientConfig","drizzle","features","json","fieldConstraints","generateSchema","corePackageSuffix","defaultOutputFile","generateSchemaOutputFile","tableImport","localesSuffix","logger","prodMigrations","push","rawRelations","rawTables","relations","relationshipsSuffix","schema","schemaName","sessions","tableNameMap","Map","tables","transactionOptions","versionsSuffix","createMigration","executeMethod","sanitizeStatements","sqlExecute","statements","map","statement","replaceAll","join","defaultIDType","foreignKeys","Set","indexes","packageName","sql"],"mappings":"AAGA,SACEA,gBAAgB,EAChBC,oBAAoB,EACpBC,iBAAiB,EACjBC,KAAK,EACLC,mBAAmB,EACnBC,aAAa,EACbC,MAAM,EACNC,YAAY,EACZC,mBAAmB,EACnBC,qBAAqB,EACrBC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,OAAO,EACPC,IAAI,EACJC,YAAY,EACZC,UAAU,EACVC,kBAAkB,EAClBC,OAAO,EACPC,YAAY,EACZC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,EACnBC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,aAAa,EACbC,MAAM,QACD,sBAAqB;AAC5B,SACEC,qBAAqB,EACrBC,0BAA0B,EAC1BC,aAAa,EACbC,eAAe,EACfC,sBAAsB,EACtBC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,IAAI,EACJC,MAAM,EACNC,iBAAiB,QACZ,6BAA4B;AACnC,SAASC,IAAI,EAAEC,OAAO,QAAQ,cAAa;AAC3C,SAASC,qBAAqB,EAAEC,uBAAuB,EAAEC,gBAAgB,QAAQ,UAAS;AAC1F,SAASC,aAAa,QAAQ,MAAK;AAInC,SAASC,OAAO,QAAQ,eAAc;AAEtC,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAE9C,OAAO,SAASC,cAAcC,IAAU;IACtC,MAAMC,eAAeD,KAAKE,MAAM,IAAI;IACpC,MAAMC,gBAAgBF,iBAAiB,SAAS,SAAS;IACzD,MAAMG,kBAAkBJ,KAAKI,eAAe,IAAI;IAEhD,SAASC,QAAQ,EAAEC,OAAO,EAAwB;QAChD,MAAMC,eAAeb,iBAAiBM,KAAKO,YAAY;QACvD,IAAIC,sBAAkC,KAAO;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AmBmD;YAC/DjD;YACAoD;YACAhB;YACAnC;YACAoC;YACAnC;YACAC;YACAC;YACAC;YACAC;YACAgC;YACAoE,iBAAiB3G,qBAAqB;gBACpC4G,eAAe;gBACftD;gBACAuD,oBAAmB,EAAEC,UAAU,EAAEC,UAAU,EAAE;oBAC3C,OAAOA,WACJC,GAAG,CAAC,CAACC,YAAc,GAAGH,aAAaG,WAAWC,WAAW,KAAK,OAAO,GAAG,CAAC,EACzEC,IAAI,CAAC;gBACV;YACF;YACA1G;YACA2G,eAAexD;YACflD;YACAC;YACAC;YACA6B;YACA5B;YACA6B;YACAC;YACA7B;YACAE;YACAC;YACAC;YACAC;YACAkG,aAAa,IAAIC;YACjBC,SAAS,IAAID;YACb1E;YACAC;YACAzB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAuC;YACAwD,aAAa;YACbzD;YACApC;YACAuC;YACApB;YACAmB;YACArC;YACAC;YACAC;YACAG;YACAC;YACAC;QACF;IACF;IAEA,OAAO;QACLuC,MAAM;QACNb;QACAuD,eAAexD;QACfhB,MAAMkB;IACR;AACF;AAuBA,SAAS2D,GAAG,QAAQ,cAAa"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { DrizzleAdapter, Operators } from '@payloadcms/drizzle'\nimport type { DatabaseAdapterObj, Payload } from 'payload'\n\nimport {\n beginTransaction,\n buildCreateMigration,\n commitTransaction,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createBlocksToJsonMigrator,\n createGlobal,\n createGlobalVersion,\n createSchemaGenerator,\n createVersion,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n operatorMap,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateJobs,\n updateMany,\n updateOne,\n updateVersion,\n upsert,\n} from '@payloadcms/drizzle'\nimport {\n columnToCodeConverter,\n convertPathToJSONTraversal,\n countDistinct,\n createJSONQuery,\n defaultDrizzleSnapshot,\n deleteWhere,\n dropDatabase,\n execute,\n init,\n insert,\n requireDrizzleKit,\n} from '@payloadcms/drizzle/sqlite'\nimport { like, notLike } from 'drizzle-orm'\nimport { createDatabaseAdapter, defaultBeginTransaction, findMigrationDir } from 'payload'\nimport { fileURLToPath } from 'url'\n\nimport type { Args, SQLiteAdapter, WalConfig } from './types.js'\n\nimport { connect } from './connect.js'\n\nconst filename = fileURLToPath(import.meta.url)\n\nexport function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {\n const sqliteIDType = args.idType || 'number'\n const payloadIDType = sqliteIDType === 'uuid' ? 'text' : 'number'\n const allowIDOnCreate = args.allowIDOnCreate ?? false\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing: () => void = () => {}\n let rejectInitializing: () => void = () => {}\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n // sqlite's like operator is case-insensitive, so we overwrite the DrizzleAdapter operators to not use ilike\n const operators = {\n ...operatorMap,\n contains: like,\n like,\n not_like: notLike,\n } as unknown as Operators\n\n let wal: false | WalConfig = false\n\n const defaultJournalSizeLimit = 67108864 // 64MB\n\n if (args.wal && !args.client.url.startsWith('file:')) {\n payload.logger.warn(\n '[db-sqlite] WAL mode is not supported for in-memory or TCP database connections. Disabling WAL.',\n )\n args.wal = false\n }\n\n if (!args.wal) {\n wal = false\n } else if (args.wal === true) {\n wal = { journalSizeLimit: defaultJournalSizeLimit, synchronous: 'FULL' }\n } else {\n wal = {\n journalSizeLimit: args.wal.journalSizeLimit ?? defaultJournalSizeLimit,\n synchronous: args.wal.synchronous ?? 'FULL',\n }\n }\n\n const executeMethod = 'run'\n const sanitizeStatements = ({\n sqlExecute,\n statements,\n }: {\n sqlExecute: string\n statements: string[]\n }) => {\n return statements\n .map((statement) => `${sqlExecute}${statement?.replaceAll('`', '\\\\`')}\\`)`)\n .join('\\n')\n }\n\n const adapter = createDatabaseAdapter<SQLiteAdapter>({\n name: 'sqlite',\n afterSchemaInit: args.afterSchemaInit ?? [],\n allowIDOnCreate,\n autoIncrement: args.autoIncrement ?? false,\n beforeSchemaInit: args.beforeSchemaInit ?? [],\n blocksAsJSON: args.blocksAsJSON ?? false,\n busyTimeout: args.busyTimeout ?? 0,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n client: undefined,\n clientConfig: args.client,\n defaultDrizzleSnapshot,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n drizzle: undefined,\n features: {\n json: true,\n },\n fieldConstraints: {},\n findDistinct,\n generateSchema: createSchemaGenerator({\n columnToCodeConverter,\n corePackageSuffix: 'sqlite-core',\n defaultOutputFile: args.generateSchemaOutputFile,\n tableImport: 'sqliteTable',\n }),\n idType: sqliteIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n operators,\n prodMigrations: args.prodMigrations,\n wal,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n push: args.push,\n rawRelations: {},\n rawTables: {},\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n transactionOptions: args.transactionOptions || undefined,\n updateJobs,\n updateMany,\n versionsSuffix: args.versionsSuffix || '_v',\n // DatabaseAdapter\n beginTransaction: args.transactionOptions ? beginTransaction : defaultBeginTransaction(),\n commitTransaction,\n connect,\n convertPathToJSONTraversal,\n count,\n countDistinct,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createJSONQuery,\n createMigration: buildCreateMigration({\n executeMethod,\n filename,\n sanitizeStatements,\n }),\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n deleteWhere,\n destroy,\n dropDatabase,\n execute,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n foreignKeys: new Set(),\n indexes: new Set<string>(),\n init,\n insert,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n packageName: '@payloadcms/db-sqlite',\n payload,\n queryDrafts,\n rejectInitializing,\n requireDrizzleKit,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n upsert,\n })\n\n adapter.blocksToJsonMigrator = createBlocksToJsonMigrator({\n adapter: adapter as unknown as DrizzleAdapter,\n executeMethod,\n sanitizeStatements,\n })\n\n return adapter\n }\n\n return {\n name: 'sqlite',\n allowIDOnCreate,\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\n/**\n * @todo deprecate /types subpath export in 4.0\n */\nexport type {\n Args as SQLiteAdapterArgs,\n CountDistinct,\n DeleteWhere,\n DropDatabase,\n Execute,\n GeneratedDatabaseSchema,\n GenericColumns,\n GenericRelation,\n GenericTable,\n IDType,\n Insert,\n MigrateDownArgs,\n MigrateUpArgs,\n SQLiteAdapter,\n SQLiteSchemaHook,\n} from './types.js'\n\nexport { sql } from 'drizzle-orm'\n"],"names":["beginTransaction","buildCreateMigration","commitTransaction","count","countGlobalVersions","countVersions","create","createBlocksToJsonMigrator","createGlobal","createGlobalVersion","createSchemaGenerator","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","columnToCodeConverter","convertPathToJSONTraversal","countDistinct","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","requireDrizzleKit","like","notLike","createDatabaseAdapter","defaultBeginTransaction","findMigrationDir","fileURLToPath","connect","filename","url","sqliteAdapter","args","sqliteIDType","idType","payloadIDType","allowIDOnCreate","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","operators","contains","not_like","wal","defaultJournalSizeLimit","client","startsWith","logger","warn","journalSizeLimit","synchronous","executeMethod","sanitizeStatements","sqlExecute","statements","map","statement","replaceAll","join","name","afterSchemaInit","autoIncrement","beforeSchemaInit","blocksAsJSON","busyTimeout","undefined","clientConfig","drizzle","features","json","fieldConstraints","generateSchema","corePackageSuffix","defaultOutputFile","generateSchemaOutputFile","tableImport","localesSuffix","prodMigrations","push","rawRelations","rawTables","relations","relationshipsSuffix","schema","schemaName","sessions","tableNameMap","Map","tables","transactionOptions","versionsSuffix","createMigration","defaultIDType","foreignKeys","Set","indexes","packageName","blocksToJsonMigrator","sql"],"mappings":"AAGA,SACEA,gBAAgB,EAChBC,oBAAoB,EACpBC,iBAAiB,EACjBC,KAAK,EACLC,mBAAmB,EACnBC,aAAa,EACbC,MAAM,EACNC,0BAA0B,EAC1BC,YAAY,EACZC,mBAAmB,EACnBC,qBAAqB,EACrBC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,OAAO,EACPC,IAAI,EACJC,YAAY,EACZC,UAAU,EACVC,kBAAkB,EAClBC,OAAO,EACPC,YAAY,EACZC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,EACnBC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,aAAa,EACbC,MAAM,QACD,sBAAqB;AAC5B,SACEC,qBAAqB,EACrBC,0BAA0B,EAC1BC,aAAa,EACbC,eAAe,EACfC,sBAAsB,EACtBC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,IAAI,EACJC,MAAM,EACNC,iBAAiB,QACZ,6BAA4B;AACnC,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AAkB,GAAG1H,mBAAmBoD;YAC/DlD;YACAqD;YACAhB;YACApC;YACAqC;YACApC;YACAC;YACAC;YACAE;YACAC;YACAgC;YACAmF,iBAAiB3H,qBAAqB;gBACpCmF;gBACA5B;gBACA6B;YACF;YACA1E;YACAkH,eAAe/D;YACflD;YACAC;YACAC;YACA6B;YACA5B;YACA6B;YACAC;YACA7B;YACAE;YACAC;YACAC;YACAC;YACAyG,aAAa,IAAIC;YACjBC,SAAS,IAAID;YACbjF;YACAC;YACAzB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAuC;YACA+D,aAAa;YACbhE;YACApC;YACAuC;YACApB;YACAmB;YACArC;YACAC;YACAC;YACAG;YACAC;YACAC;QACF;QAEA2B,QAAQkE,oBAAoB,GAAG3H,2BAA2B;YACxDyD,SAASA;YACToB;YACAC;QACF;QAEA,OAAOrB;IACT;IAEA,OAAO;QACL4B,MAAM;QACN7B;QACA8D,eAAe/D;QACfhB,MAAMkB;IACR;AACF;AAuBA,SAASmE,GAAG,QAAQ,cAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks-as-json.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/blocks-as-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAIvD,eAAO,MAAM,OAAO,EAAE,wBAEpB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/blocks-as-json.ts"],"sourcesContent":["import type { DynamicMigrationTemplate } from 'payload'\n\nimport { buildDynamicPredefinedBlocksToJsonMigration } from '@payloadcms/drizzle'\n\nexport const dynamic: DynamicMigrationTemplate = buildDynamicPredefinedBlocksToJsonMigration({\n packageName: '@payloadcms/db-sqlite',\n})\n"],"names":["buildDynamicPredefinedBlocksToJsonMigration","dynamic","packageName"],"mappings":"AAEA,SAASA,2CAA2C,QAAQ,sBAAqB;AAEjF,OAAO,MAAMC,UAAoCD,4CAA4C;IAC3FE,aAAa;AACf,GAAE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -42,7 +42,13 @@ export type Args = {
|
|
|
42
42
|
* To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull)
|
|
43
43
|
*/
|
|
44
44
|
beforeSchemaInit?: SQLiteSchemaHook[];
|
|
45
|
+
/**
|
|
46
|
+
* Maximum time in milliseconds to wait when the database is locked.
|
|
47
|
+
* @default 0
|
|
48
|
+
*/
|
|
49
|
+
busyTimeout?: number;
|
|
45
50
|
client: Config;
|
|
51
|
+
wal?: boolean | Partial<WalConfig>;
|
|
46
52
|
} & BaseSQLiteArgs;
|
|
47
53
|
export type GenericColumns = {
|
|
48
54
|
[x: string]: AnySQLiteColumn;
|
|
@@ -89,10 +95,32 @@ type ResolveSchemaType<T> = 'schema' extends keyof T ? T['schema'] : GeneratedDa
|
|
|
89
95
|
type Drizzle = {
|
|
90
96
|
$client: Client;
|
|
91
97
|
} & LibSQLDatabase<ResolveSchemaType<GeneratedDatabaseSchema>>;
|
|
98
|
+
export type WalConfig = {
|
|
99
|
+
/**
|
|
100
|
+
* Maximum size of the WAL file before it is written back to the main database.
|
|
101
|
+
* @default 67108864 (64MB)
|
|
102
|
+
*/
|
|
103
|
+
journalSizeLimit: number;
|
|
104
|
+
/**
|
|
105
|
+
* Controls how often data is synced to disk:
|
|
106
|
+
* - 'EXTRA': Highest data safety
|
|
107
|
+
* - 'FULL': Safe and balanced
|
|
108
|
+
* - 'NORMAL': Moderate safety, better performance
|
|
109
|
+
* - 'OFF': Fastest, but risk of data loss
|
|
110
|
+
*
|
|
111
|
+
* @default 'FULL'
|
|
112
|
+
*/
|
|
113
|
+
synchronous: 'EXTRA' | 'FULL' | 'NORMAL' | 'OFF';
|
|
114
|
+
};
|
|
92
115
|
export type SQLiteAdapter = {
|
|
116
|
+
busyTimeout: number;
|
|
93
117
|
client: Client;
|
|
94
118
|
clientConfig: Args['client'];
|
|
95
119
|
drizzle: Drizzle;
|
|
120
|
+
/**
|
|
121
|
+
* Write-Ahead Logging (WAL) configuration. If false or not set, WAL mode is disabled.
|
|
122
|
+
*/
|
|
123
|
+
wal: false | WalConfig;
|
|
96
124
|
} & BaseSQLiteAdapter & SQLiteDrizzleAdapter;
|
|
97
125
|
export type IDType = 'integer' | 'numeric' | 'text';
|
|
98
126
|
export type MigrateUpArgs = {
|
|
@@ -160,6 +188,7 @@ export type MigrateDownArgs = {
|
|
|
160
188
|
declare module 'payload' {
|
|
161
189
|
interface DatabaseAdapter extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>, DrizzleAdapter {
|
|
162
190
|
beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>;
|
|
191
|
+
busyTimeout: number;
|
|
163
192
|
drizzle: Drizzle;
|
|
164
193
|
/**
|
|
165
194
|
* An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,oCAAoC,EACpC,sBAAsB,EACtB,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AAE,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3C,EAAE,CAAA;QACH,IAAI,EAAE,OAAO,CAAA;QACb,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAAC,CAAA;QACtD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,kBAAkB,EAAE,uBAAuB,CAAA;QAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;CACF"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Client, Config, ResultSet } from '@libsql/client'\nimport type { extendDrizzleTable, Operators } from '@payloadcms/drizzle'\nimport type { BaseSQLiteAdapter, BaseSQLiteArgs } from '@payloadcms/drizzle/sqlite'\nimport type { BuildQueryJoinAliases, DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm'\nimport type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type {\n AnySQLiteColumn,\n SQLiteColumn,\n SQLiteInsertOnConflictDoUpdateConfig,\n SQLiteTableWithColumns,\n SQLiteTransactionConfig,\n} from 'drizzle-orm/sqlite-core'\nimport type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw'\nimport type { Payload, PayloadRequest } from 'payload'\n\ntype SQLiteSchema = {\n relations: Record<string, GenericRelation>\n tables: Record<string, SQLiteTableWithColumns<any>>\n}\n\ntype SQLiteSchemaHookArgs = {\n extendTable: typeof extendDrizzleTable\n schema: SQLiteSchema\n}\n\nexport type SQLiteSchemaHook = (args: SQLiteSchemaHookArgs) => Promise<SQLiteSchema> | SQLiteSchema\n\nexport type Args = {\n /**\n * Transform the schema after it's built.\n * You can use it to customize the schema with features that aren't supported by Payload.\n * Examples may include: composite indices, generated columns, vectors\n */\n afterSchemaInit?: SQLiteSchemaHook[]\n /**\n * Enable this flag if you want to thread your own ID to create operation data, for example:\n * ```ts\n * // doc created with id 1\n * const doc = await payload.create({ collection: 'posts', data: {id: 1, title: \"my title\"}})\n * ```\n */\n allowIDOnCreate?: boolean\n /**\n * Enable [AUTOINCREMENT](https://www.sqlite.org/autoinc.html) for Primary Keys.\n * This ensures that the same ID cannot be reused from previously deleted rows.\n */\n autoIncrement?: boolean\n /**\n * Transform the schema before it's built.\n * You can use it to preserve an existing database schema and if there are any collissions Payload will override them.\n * To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull)\n */\n beforeSchemaInit?: SQLiteSchemaHook[]\n client: Config\n} & BaseSQLiteArgs\n\nexport type GenericColumns = {\n [x: string]: AnySQLiteColumn\n}\n\nexport type GenericTable = SQLiteTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type CountDistinct = (args: {\n column?: SQLiteColumn<any>\n db: LibSQLDatabase\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: LibSQLDatabase\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: SQLiteAdapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: LibSQLDatabase\n drizzle?: LibSQLDatabase\n raw?: string\n sql?: SQL<unknown>\n}) => SQLiteRaw<Promise<T>> | SQLiteRaw<ResultSet>\n\nexport type Insert = (args: {\n db: LibSQLDatabase\n onConflictDoUpdate?: SQLiteInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\n// Explicitly omit drizzle property for complete override in SQLiteAdapter, required in ts 5.5\ntype SQLiteDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'idType'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport interface GeneratedDatabaseSchema {\n schemaUntyped: Record<string, unknown>\n}\n\ntype ResolveSchemaType<T> = 'schema' extends keyof T\n ? T['schema']\n : GeneratedDatabaseSchema['schemaUntyped']\n\ntype Drizzle = { $client: Client } & LibSQLDatabase<ResolveSchemaType<GeneratedDatabaseSchema>>\n\nexport type SQLiteAdapter = {\n client: Client\n clientConfig: Args['client']\n drizzle: Drizzle\n} & BaseSQLiteAdapter &\n SQLiteDrizzleAdapter\n\nexport type IDType = 'integer' | 'numeric' | 'text'\n\nexport type MigrateUpArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\nexport type MigrateDownArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>\n drizzle: Drizzle\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, GenericRelation | GenericTable>\n tableNameMap: Map<string, string>\n transactionOptions: SQLiteTransactionConfig\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Client, Config, ResultSet } from '@libsql/client'\nimport type { extendDrizzleTable, Operators } from '@payloadcms/drizzle'\nimport type { BaseSQLiteAdapter, BaseSQLiteArgs } from '@payloadcms/drizzle/sqlite'\nimport type { BuildQueryJoinAliases, DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm'\nimport type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type {\n AnySQLiteColumn,\n SQLiteColumn,\n SQLiteInsertOnConflictDoUpdateConfig,\n SQLiteTableWithColumns,\n SQLiteTransactionConfig,\n} from 'drizzle-orm/sqlite-core'\nimport type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw'\nimport type { Payload, PayloadRequest } from 'payload'\n\ntype SQLiteSchema = {\n relations: Record<string, GenericRelation>\n tables: Record<string, SQLiteTableWithColumns<any>>\n}\n\ntype SQLiteSchemaHookArgs = {\n extendTable: typeof extendDrizzleTable\n schema: SQLiteSchema\n}\n\nexport type SQLiteSchemaHook = (args: SQLiteSchemaHookArgs) => Promise<SQLiteSchema> | SQLiteSchema\n\nexport type Args = {\n /**\n * Transform the schema after it's built.\n * You can use it to customize the schema with features that aren't supported by Payload.\n * Examples may include: composite indices, generated columns, vectors\n */\n afterSchemaInit?: SQLiteSchemaHook[]\n /**\n * Enable this flag if you want to thread your own ID to create operation data, for example:\n * ```ts\n * // doc created with id 1\n * const doc = await payload.create({ collection: 'posts', data: {id: 1, title: \"my title\"}})\n * ```\n */\n allowIDOnCreate?: boolean\n /**\n * Enable [AUTOINCREMENT](https://www.sqlite.org/autoinc.html) for Primary Keys.\n * This ensures that the same ID cannot be reused from previously deleted rows.\n */\n autoIncrement?: boolean\n /**\n * Transform the schema before it's built.\n * You can use it to preserve an existing database schema and if there are any collissions Payload will override them.\n * To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull)\n */\n beforeSchemaInit?: SQLiteSchemaHook[]\n /**\n * Maximum time in milliseconds to wait when the database is locked.\n * @default 0\n */\n busyTimeout?: number\n client: Config\n wal?: boolean | Partial<WalConfig>\n} & BaseSQLiteArgs\n\nexport type GenericColumns = {\n [x: string]: AnySQLiteColumn\n}\n\nexport type GenericTable = SQLiteTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type CountDistinct = (args: {\n column?: SQLiteColumn<any>\n db: LibSQLDatabase\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: LibSQLDatabase\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: SQLiteAdapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: LibSQLDatabase\n drizzle?: LibSQLDatabase\n raw?: string\n sql?: SQL<unknown>\n}) => SQLiteRaw<Promise<T>> | SQLiteRaw<ResultSet>\n\nexport type Insert = (args: {\n db: LibSQLDatabase\n onConflictDoUpdate?: SQLiteInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\n// Explicitly omit drizzle property for complete override in SQLiteAdapter, required in ts 5.5\ntype SQLiteDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'idType'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport interface GeneratedDatabaseSchema {\n schemaUntyped: Record<string, unknown>\n}\n\ntype ResolveSchemaType<T> = 'schema' extends keyof T\n ? T['schema']\n : GeneratedDatabaseSchema['schemaUntyped']\n\ntype Drizzle = { $client: Client } & LibSQLDatabase<ResolveSchemaType<GeneratedDatabaseSchema>>\n\nexport type WalConfig = {\n /**\n * Maximum size of the WAL file before it is written back to the main database.\n * @default 67108864 (64MB)\n */\n journalSizeLimit: number\n\n /**\n * Controls how often data is synced to disk:\n * - 'EXTRA': Highest data safety\n * - 'FULL': Safe and balanced\n * - 'NORMAL': Moderate safety, better performance\n * - 'OFF': Fastest, but risk of data loss\n *\n * @default 'FULL'\n */\n synchronous: 'EXTRA' | 'FULL' | 'NORMAL' | 'OFF'\n}\n\nexport type SQLiteAdapter = {\n busyTimeout: number\n client: Client\n clientConfig: Args['client']\n drizzle: Drizzle\n /**\n * Write-Ahead Logging (WAL) configuration. If false or not set, WAL mode is disabled.\n */\n wal: false | WalConfig\n} & BaseSQLiteAdapter &\n SQLiteDrizzleAdapter\n\nexport type IDType = 'integer' | 'numeric' | 'text'\n\nexport type MigrateUpArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-sqlite'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\nexport type MigrateDownArgs = {\n /**\n * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: Drizzle\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-sqlite'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>\n busyTimeout: number\n drizzle: Drizzle\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, GenericRelation | GenericTable>\n tableNameMap: Map<string, string>\n transactionOptions: SQLiteTransactionConfig\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAkMA,WA8BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-sqlite",
|
|
3
|
-
"version": "3.73.0
|
|
3
|
+
"version": "3.73.0",
|
|
4
4
|
"description": "The officially supported SQLite database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
"prompts": "2.4.2",
|
|
71
71
|
"to-snake-case": "1.0.0",
|
|
72
72
|
"uuid": "9.0.0",
|
|
73
|
-
"@payloadcms/drizzle": "3.73.0
|
|
73
|
+
"@payloadcms/drizzle": "3.73.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/pg": "8.10.2",
|
|
77
77
|
"@types/to-snake-case": "1.0.0",
|
|
78
78
|
"@types/uuid": "10.0.0",
|
|
79
79
|
"@payloadcms/eslint-config": "3.28.0",
|
|
80
|
-
"payload": "3.73.0
|
|
80
|
+
"payload": "3.73.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"payload": "3.73.0
|
|
83
|
+
"payload": "3.73.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "pnpm build:swc && pnpm build:types",
|