@payloadcms/db-d1-sqlite 0.0.1-beta.0 → 3.58.0-internal.8775d75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +29 -2
  2. package/dist/connect.d.ts +3 -0
  3. package/dist/connect.d.ts.map +1 -0
  4. package/dist/connect.js +53 -0
  5. package/dist/connect.js.map +1 -0
  6. package/dist/drizzle-proxy/d1.d.ts +2 -0
  7. package/dist/drizzle-proxy/d1.d.ts.map +1 -0
  8. package/dist/drizzle-proxy/d1.js +3 -0
  9. package/dist/drizzle-proxy/d1.js.map +1 -0
  10. package/dist/drizzle-proxy/index.d.ts +2 -0
  11. package/dist/drizzle-proxy/index.d.ts.map +1 -0
  12. package/dist/drizzle-proxy/index.js +3 -0
  13. package/dist/drizzle-proxy/index.js.map +1 -0
  14. package/dist/drizzle-proxy/relations.d.ts +2 -0
  15. package/dist/drizzle-proxy/relations.d.ts.map +1 -0
  16. package/dist/drizzle-proxy/relations.js +3 -0
  17. package/dist/drizzle-proxy/relations.js.map +1 -0
  18. package/dist/drizzle-proxy/sqlite-core.d.ts +2 -0
  19. package/dist/drizzle-proxy/sqlite-core.d.ts.map +1 -0
  20. package/dist/drizzle-proxy/sqlite-core.js +3 -0
  21. package/dist/drizzle-proxy/sqlite-core.js.map +1 -0
  22. package/dist/execute.d.ts +3 -0
  23. package/dist/execute.d.ts.map +1 -0
  24. package/dist/execute.js +28 -0
  25. package/dist/execute.js.map +1 -0
  26. package/dist/exports/types-deprecated.d.ts +62 -0
  27. package/dist/exports/types-deprecated.d.ts.map +1 -0
  28. package/dist/exports/types-deprecated.js +5 -0
  29. package/dist/exports/types-deprecated.js.map +1 -0
  30. package/dist/index.d.ts +9 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +140 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/types.d.ts +162 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +3 -0
  37. package/dist/types.js.map +1 -0
  38. package/package.json +88 -1
  39. package/.prettierignore +0 -12
  40. package/.swcrc +0 -24
  41. package/eslint.config.js +0 -18
  42. package/src/addresses/addressesCollection.ts +0 -76
  43. package/src/addresses/defaultAddressFields.ts +0 -83
  44. package/src/addresses/defaultCountries.ts +0 -50
  45. package/src/carts/beforeChange.ts +0 -51
  46. package/src/carts/cartsCollection.ts +0 -146
  47. package/src/currencies/index.ts +0 -29
  48. package/src/endpoints/confirmOrder.ts +0 -312
  49. package/src/endpoints/initiatePayment.ts +0 -322
  50. package/src/exports/addresses.ts +0 -2
  51. package/src/exports/currencies.ts +0 -1
  52. package/src/exports/fields.ts +0 -5
  53. package/src/exports/orders.ts +0 -1
  54. package/src/exports/payments/stripe.ts +0 -1
  55. package/src/exports/plugin.ts +0 -1
  56. package/src/exports/products.ts +0 -1
  57. package/src/exports/react.ts +0 -8
  58. package/src/exports/transactions.ts +0 -1
  59. package/src/exports/translations.ts +0 -1
  60. package/src/exports/types.ts +0 -7
  61. package/src/exports/ui.ts +0 -3
  62. package/src/exports/variants.ts +0 -5
  63. package/src/fields/amountField.ts +0 -43
  64. package/src/fields/cartItemsField.ts +0 -84
  65. package/src/fields/currencyField.ts +0 -39
  66. package/src/fields/inventoryField.ts +0 -22
  67. package/src/fields/pricesField.ts +0 -65
  68. package/src/fields/statusField.ts +0 -57
  69. package/src/fields/variantsFields.ts +0 -56
  70. package/src/index.ts +0 -275
  71. package/src/orders/ordersCollection.ts +0 -157
  72. package/src/payments/adapters/stripe/confirmOrder.ts +0 -123
  73. package/src/payments/adapters/stripe/endpoints/webhooks.ts +0 -69
  74. package/src/payments/adapters/stripe/index.ts +0 -135
  75. package/src/payments/adapters/stripe/initiatePayment.ts +0 -131
  76. package/src/products/productsCollection.ts +0 -78
  77. package/src/react/provider/index.tsx +0 -893
  78. package/src/react/provider/types.ts +0 -184
  79. package/src/react/provider/utilities.ts +0 -22
  80. package/src/transactions/transactionsCollection.ts +0 -166
  81. package/src/translations/en.ts +0 -64
  82. package/src/translations/index.ts +0 -11
  83. package/src/translations/translation-schema.json +0 -35
  84. package/src/types.ts +0 -403
  85. package/src/ui/PriceInput/FormattedInput.tsx +0 -134
  86. package/src/ui/PriceInput/index.scss +0 -28
  87. package/src/ui/PriceInput/index.tsx +0 -43
  88. package/src/ui/PriceInput/utilities.ts +0 -46
  89. package/src/ui/PriceRowLabel/index.css +0 -13
  90. package/src/ui/PriceRowLabel/index.tsx +0 -56
  91. package/src/ui/VariantOptionsSelector/ErrorBox.tsx +0 -27
  92. package/src/ui/VariantOptionsSelector/OptionsSelect.tsx +0 -78
  93. package/src/ui/VariantOptionsSelector/index.css +0 -37
  94. package/src/ui/VariantOptionsSelector/index.tsx +0 -83
  95. package/src/utilities/defaultProductsValidation.ts +0 -42
  96. package/src/utilities/errorCodes.ts +0 -14
  97. package/src/utilities/getCollectionSlugMap.ts +0 -84
  98. package/src/utilities/sanitizePluginConfig.ts +0 -80
  99. package/src/variants/variantOptionsCollection.ts +0 -59
  100. package/src/variants/variantTypesCollection.ts +0 -55
  101. package/src/variants/variantsCollection/hooks/beforeChange.ts +0 -47
  102. package/src/variants/variantsCollection/hooks/validateOptions.ts +0 -72
  103. package/src/variants/variantsCollection/index.ts +0 -119
  104. package/tsconfig.json +0 -7
  105. package/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Payload Ecommerce
1
+ # Payload SQLite Adapter
2
2
 
3
- A set of utilities... more to come
3
+ Official SQLite adapter for [Payload](https://payloadcms.com).
4
+
5
+ - [Main Repository](https://github.com/payloadcms/payload)
6
+ - [Payload Docs](https://payloadcms.com/docs)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @payloadcms/db-sqlite
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { buildConfig } from 'payload/config'
18
+ import { sqliteAdapter } from '@payloadcms/db-sqlite'
19
+
20
+ export default buildConfig({
21
+ db: sqliteAdapter({
22
+ client: {
23
+ url: process.env.DATABASE_URI,
24
+ },
25
+ }),
26
+ // ...rest of config
27
+ })
28
+ ```
29
+
30
+ More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview).
@@ -0,0 +1,3 @@
1
+ import type { Connect } from 'payload';
2
+ export declare const connect: Connect;
3
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,SAAS,CAAA;AAOjD,eAAO,MAAM,OAAO,EAAE,OAoDrB,CAAA"}
@@ -0,0 +1,53 @@
1
+ import { pushDevSchema } from '@payloadcms/drizzle';
2
+ import { drizzle } from 'drizzle-orm/d1';
3
+ export const connect = async function connect(options = {
4
+ hotReload: false
5
+ }) {
6
+ const { hotReload } = options;
7
+ this.schema = {
8
+ ...this.tables,
9
+ ...this.relations
10
+ };
11
+ try {
12
+ const logger = this.logger || false;
13
+ this.drizzle = drizzle(this.binding, {
14
+ logger,
15
+ schema: this.schema
16
+ });
17
+ this.client = this.drizzle.$client;
18
+ if (!hotReload) {
19
+ if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
20
+ this.payload.logger.info(`---- DROPPING TABLES ----`);
21
+ await this.dropDatabase({
22
+ adapter: this
23
+ });
24
+ this.payload.logger.info('---- DROPPED TABLES ----');
25
+ }
26
+ }
27
+ } catch (err) {
28
+ const message = err instanceof Error ? err.message : String(err);
29
+ this.payload.logger.error({
30
+ err,
31
+ msg: `Error: cannot connect to SQLite: ${message}`
32
+ });
33
+ if (typeof this.rejectInitializing === 'function') {
34
+ this.rejectInitializing();
35
+ }
36
+ console.error(err);
37
+ process.exit(1);
38
+ }
39
+ // Only push schema if not in production
40
+ if (process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_MIGRATING !== 'true' && this.push !== false) {
41
+ await pushDevSchema(this);
42
+ }
43
+ if (typeof this.resolveInitializing === 'function') {
44
+ this.resolveInitializing();
45
+ }
46
+ if (process.env.NODE_ENV === 'production' && this.prodMigrations) {
47
+ await this.migrate({
48
+ migrations: this.prodMigrations
49
+ });
50
+ }
51
+ };
52
+
53
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle'\nimport type { Connect, Migration } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/d1'\n\nimport type { SQLiteD1Adapter } from './types.js'\n\nexport const connect: Connect = async function connect(\n this: SQLiteD1Adapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n ...this.tables,\n ...this.relations,\n }\n\n try {\n const logger = this.logger || false\n\n this.drizzle = drizzle(this.binding, { logger, schema: this.schema })\n this.client = this.drizzle.$client as any\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 console.error(err)\n process.exit(1)\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":["pushDevSchema","drizzle","connect","options","hotReload","schema","tables","relations","logger","binding","client","$client","process","env","PAYLOAD_DROP_DATABASE","payload","info","dropDatabase","adapter","err","message","Error","String","error","msg","rejectInitializing","console","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"AAGA,SAASA,aAAa,QAAQ,sBAAqB;AACnD,SAASC,OAAO,QAAQ,iBAAgB;AAIxC,OAAO,MAAMC,UAAmB,eAAeA,QAE7CC,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI,CAACE,MAAM,GAAG;QACZ,GAAG,IAAI,CAACC,MAAM;QACd,GAAG,IAAI,CAACC,SAAS;IACnB;IAEA,IAAI;QACF,MAAMC,SAAS,IAAI,CAACA,MAAM,IAAI;QAE9B,IAAI,CAACP,OAAO,GAAGA,QAAQ,IAAI,CAACQ,OAAO,EAAE;YAAED;YAAQH,QAAQ,IAAI,CAACA,MAAM;QAAC;QACnE,IAAI,CAACK,MAAM,GAAG,IAAI,CAACT,OAAO,CAACU,OAAO;QAElC,IAAI,CAACP,WAAW;YACd,IAAIQ,QAAQC,GAAG,CAACC,qBAAqB,KAAK,QAAQ;gBAChD,IAAI,CAACC,OAAO,CAACP,MAAM,CAACQ,IAAI,CAAC,CAAC,yBAAyB,CAAC;gBACpD,MAAM,IAAI,CAACC,YAAY,CAAC;oBAAEC,SAAS,IAAI;gBAAC;gBACxC,IAAI,CAACH,OAAO,CAACP,MAAM,CAACQ,IAAI,CAAC;YAC3B;QACF;IACF,EAAE,OAAOG,KAAK;QACZ,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAGE,OAAOH;QAC5D,IAAI,CAACJ,OAAO,CAACP,MAAM,CAACe,KAAK,CAAC;YAAEJ;YAAKK,KAAK,CAAC,iCAAiC,EAAEJ,SAAS;QAAC;QACpF,IAAI,OAAO,IAAI,CAACK,kBAAkB,KAAK,YAAY;YACjD,IAAI,CAACA,kBAAkB;QACzB;QACAC,QAAQH,KAAK,CAACJ;QACdP,QAAQe,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACEf,QAAQC,GAAG,CAACe,QAAQ,KAAK,gBACzBhB,QAAQC,GAAG,CAACgB,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAM9B,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAAC+B,mBAAmB,KAAK,YAAY;QAClD,IAAI,CAACA,mBAAmB;IAC1B;IAEA,IAAInB,QAAQC,GAAG,CAACe,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,2 @@
1
+ export * from 'drizzle-orm/d1';
2
+ //# sourceMappingURL=d1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d1.d.ts","sourceRoot":"","sources":["../../src/drizzle-proxy/d1.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from 'drizzle-orm/d1';
2
+
3
+ //# sourceMappingURL=d1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drizzle-proxy/d1.ts"],"sourcesContent":["export * from 'drizzle-orm/d1'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAgB"}
@@ -0,0 +1,2 @@
1
+ export * from 'drizzle-orm';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drizzle-proxy/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from 'drizzle-orm';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drizzle-proxy/index.ts"],"sourcesContent":["export * from 'drizzle-orm'\n"],"names":[],"mappings":"AAAA,cAAc,cAAa"}
@@ -0,0 +1,2 @@
1
+ export * from 'drizzle-orm/relations';
2
+ //# sourceMappingURL=relations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/drizzle-proxy/relations.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from 'drizzle-orm/relations';
2
+
3
+ //# sourceMappingURL=relations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drizzle-proxy/relations.ts"],"sourcesContent":["export * from 'drizzle-orm/relations'\n"],"names":[],"mappings":"AAAA,cAAc,wBAAuB"}
@@ -0,0 +1,2 @@
1
+ export * from 'drizzle-orm/sqlite-core';
2
+ //# sourceMappingURL=sqlite-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-core.d.ts","sourceRoot":"","sources":["../../src/drizzle-proxy/sqlite-core.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from 'drizzle-orm/sqlite-core';
2
+
3
+ //# sourceMappingURL=sqlite-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drizzle-proxy/sqlite-core.ts"],"sourcesContent":["export * from 'drizzle-orm/sqlite-core'\n"],"names":[],"mappings":"AAAA,cAAc,0BAAyB"}
@@ -0,0 +1,3 @@
1
+ import type { Execute } from '@payloadcms/drizzle';
2
+ export declare const execute: Execute<any>;
3
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAuClD,eAAO,MAAM,OAAO,EAAE,OAAO,CAAC,GAAG,CA2BhC,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { sql } from 'drizzle-orm';
2
+ export const execute = function execute({ db, drizzle, raw, sql: statement }) {
3
+ const executeFrom = db ?? drizzle;
4
+ const mapToLibSql = (query)=>{
5
+ const execute = query.execute;
6
+ query.execute = async ()=>{
7
+ const result = await execute();
8
+ const resultLibSQL = {
9
+ columns: undefined,
10
+ columnTypes: undefined,
11
+ lastInsertRowid: BigInt(result.meta.last_row_id),
12
+ rows: result.results,
13
+ rowsAffected: result.meta.rows_written
14
+ };
15
+ return Object.assign(result, resultLibSQL);
16
+ };
17
+ return query;
18
+ };
19
+ if (raw) {
20
+ const result = mapToLibSql(executeFrom.run(sql.raw(raw)));
21
+ return result;
22
+ } else {
23
+ const result = mapToLibSql(executeFrom.run(statement));
24
+ return result;
25
+ }
26
+ };
27
+
28
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/execute.ts"],"sourcesContent":["import type { Execute } from '@payloadcms/drizzle'\nimport type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw'\n\nimport { sql } from 'drizzle-orm'\n\ninterface D1Meta {\n changed_db: boolean\n changes: number\n duration: number\n last_row_id: number\n rows_read: number\n rows_written: number\n /**\n * True if-and-only-if the database instance that executed the query was the primary.\n */\n served_by_primary?: boolean\n /**\n * The region of the database instance that executed the query.\n */\n served_by_region?: string\n size_after: number\n timings?: {\n /**\n * The duration of the SQL query execution by the database instance. It doesn't include any network time.\n */\n sql_duration_ms: number\n }\n}\n\ninterface D1Response {\n error?: never\n meta: D1Meta & Record<string, unknown>\n success: true\n}\n\ntype D1Result<T = unknown> = {\n results: T[]\n} & D1Response\n\nexport const execute: Execute<any> = function execute({ db, drizzle, raw, sql: statement }) {\n const executeFrom: any = (db ?? drizzle)!\n const mapToLibSql = (query: SQLiteRaw<D1Result<unknown>>): any => {\n const execute = query.execute\n query.execute = async () => {\n const result: D1Result = await execute()\n const resultLibSQL = {\n columns: undefined,\n columnTypes: undefined,\n lastInsertRowid: BigInt(result.meta.last_row_id),\n rows: result.results as any[],\n rowsAffected: result.meta.rows_written,\n }\n\n return Object.assign(result, resultLibSQL)\n }\n\n return query\n }\n\n if (raw) {\n const result = mapToLibSql(executeFrom.run(sql.raw(raw)))\n return result\n } else {\n const result = mapToLibSql(executeFrom.run(statement))\n return result\n }\n}\n"],"names":["sql","execute","db","drizzle","raw","statement","executeFrom","mapToLibSql","query","result","resultLibSQL","columns","undefined","columnTypes","lastInsertRowid","BigInt","meta","last_row_id","rows","results","rowsAffected","rows_written","Object","assign","run"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAoCjC,OAAO,MAAMC,UAAwB,SAASA,QAAQ,EAAEC,EAAE,EAAEC,OAAO,EAAEC,GAAG,EAAEJ,KAAKK,SAAS,EAAE;IACxF,MAAMC,cAAoBJ,MAAMC;IAChC,MAAMI,cAAc,CAACC;QACnB,MAAMP,UAAUO,MAAMP,OAAO;QAC7BO,MAAMP,OAAO,GAAG;YACd,MAAMQ,SAAmB,MAAMR;YAC/B,MAAMS,eAAe;gBACnBC,SAASC;gBACTC,aAAaD;gBACbE,iBAAiBC,OAAON,OAAOO,IAAI,CAACC,WAAW;gBAC/CC,MAAMT,OAAOU,OAAO;gBACpBC,cAAcX,OAAOO,IAAI,CAACK,YAAY;YACxC;YAEA,OAAOC,OAAOC,MAAM,CAACd,QAAQC;QAC/B;QAEA,OAAOF;IACT;IAEA,IAAIJ,KAAK;QACP,MAAMK,SAASF,YAAYD,YAAYkB,GAAG,CAACxB,IAAII,GAAG,CAACA;QACnD,OAAOK;IACT,OAAO;QACL,MAAMA,SAASF,YAAYD,YAAYkB,GAAG,CAACnB;QAC3C,OAAOI;IACT;AACF,EAAC"}
@@ -0,0 +1,62 @@
1
+ import type { Args as _Args, CountDistinct as _CountDistinct, DeleteWhere as _DeleteWhere, DropDatabase as _DropDatabase, Execute as _Execute, GeneratedDatabaseSchema as _GeneratedDatabaseSchema, GenericColumns as _GenericColumns, GenericRelation as _GenericRelation, GenericTable as _GenericTable, IDType as _IDType, Insert as _Insert, MigrateDownArgs as _MigrateDownArgs, MigrateUpArgs as _MigrateUpArgs, SQLiteD1Adapter as _SQLiteAdapter, SQLiteSchemaHook as _SQLiteSchemaHook } from '../types.js';
2
+ /**
3
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
4
+ */
5
+ export type SQLiteAdapter = _SQLiteAdapter;
6
+ /**
7
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
8
+ */
9
+ export type Args = _Args;
10
+ /**
11
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
12
+ */
13
+ export type CountDistinct = _CountDistinct;
14
+ /**
15
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
16
+ */
17
+ export type DeleteWhere = _DeleteWhere;
18
+ /**
19
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
20
+ */
21
+ export type DropDatabase = _DropDatabase;
22
+ /**
23
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
24
+ */
25
+ export type Execute<T> = _Execute<T>;
26
+ /**
27
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
28
+ */
29
+ export type GeneratedDatabaseSchema = _GeneratedDatabaseSchema;
30
+ /**
31
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
32
+ */
33
+ export type GenericColumns = _GenericColumns;
34
+ /**
35
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
36
+ */
37
+ export type GenericRelation = _GenericRelation;
38
+ /**
39
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
40
+ */
41
+ export type GenericTable = _GenericTable;
42
+ /**
43
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
44
+ */
45
+ export type IDType = _IDType;
46
+ /**
47
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
48
+ */
49
+ export type Insert = _Insert;
50
+ /**
51
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
52
+ */
53
+ export type MigrateDownArgs = _MigrateDownArgs;
54
+ /**
55
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
56
+ */
57
+ export type MigrateUpArgs = _MigrateUpArgs;
58
+ /**
59
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
60
+ */
61
+ export type SQLiteSchemaHook = _SQLiteSchemaHook;
62
+ //# sourceMappingURL=types-deprecated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-deprecated.d.ts","sourceRoot":"","sources":["../../src/exports/types-deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,IAAI,KAAK,EACb,aAAa,IAAI,cAAc,EAC/B,WAAW,IAAI,YAAY,EAC3B,YAAY,IAAI,aAAa,EAC7B,OAAO,IAAI,QAAQ,EACnB,uBAAuB,IAAI,wBAAwB,EACnD,cAAc,IAAI,eAAe,EACjC,eAAe,IAAI,gBAAgB,EACnC,YAAY,IAAI,aAAa,EAC7B,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,eAAe,IAAI,gBAAgB,EACnC,aAAa,IAAI,cAAc,EAC/B,eAAe,IAAI,cAAc,EACjC,gBAAgB,IAAI,iBAAiB,EACtC,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAA;AAC1C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,CAAA;AACtC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CAAA;AACxC;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAA;AACpC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAA;AAC9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,CAAA;AAC5C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA;AAC9C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CAAA;AACxC;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,CAAA;AAC5B;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,CAAA;AAC5B;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA;AAC9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAA;AAC1C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @deprecated - import from `@payloadcms/db-sqlite` instead
3
+ */ export { };
4
+
5
+ //# sourceMappingURL=types-deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/types-deprecated.ts"],"sourcesContent":["import type {\n Args as _Args,\n CountDistinct as _CountDistinct,\n DeleteWhere as _DeleteWhere,\n DropDatabase as _DropDatabase,\n Execute as _Execute,\n GeneratedDatabaseSchema as _GeneratedDatabaseSchema,\n GenericColumns as _GenericColumns,\n GenericRelation as _GenericRelation,\n GenericTable as _GenericTable,\n IDType as _IDType,\n Insert as _Insert,\n MigrateDownArgs as _MigrateDownArgs,\n MigrateUpArgs as _MigrateUpArgs,\n SQLiteD1Adapter as _SQLiteAdapter,\n SQLiteSchemaHook as _SQLiteSchemaHook,\n} from '../types.js'\n\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type SQLiteAdapter = _SQLiteAdapter\n\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type Args = _Args\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type CountDistinct = _CountDistinct\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type DeleteWhere = _DeleteWhere\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type DropDatabase = _DropDatabase\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type Execute<T> = _Execute<T>\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type GeneratedDatabaseSchema = _GeneratedDatabaseSchema\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type GenericColumns = _GenericColumns\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type GenericRelation = _GenericRelation\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type GenericTable = _GenericTable\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type IDType = _IDType\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type Insert = _Insert\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type MigrateDownArgs = _MigrateDownArgs\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type MigrateUpArgs = _MigrateUpArgs\n/**\n * @deprecated - import from `@payloadcms/db-sqlite` instead\n */\nexport type SQLiteSchemaHook = _SQLiteSchemaHook\n"],"names":[],"mappings":"AA2EA;;CAEC,GACD,WAAgD"}
@@ -0,0 +1,9 @@
1
+ import type { DatabaseAdapterObj } from 'payload';
2
+ import type { Args, SQLiteD1Adapter } from './types.js';
3
+ export declare function sqliteD1Adapter(args: Args): DatabaseAdapterObj<SQLiteD1Adapter>;
4
+ /**
5
+ * @todo deprecate /types subpath export in 4.0
6
+ */
7
+ export type { Args as SQLiteAdapterArgs, CountDistinct, DeleteWhere, DropDatabase, Execute, GeneratedDatabaseSchema, GenericColumns, GenericRelation, GenericTable, IDType, Insert, MigrateDownArgs, MigrateUpArgs, SQLiteD1Adapter as SQLiteAdapter, SQLiteSchemaHook, } from './types.js';
8
+ export { sql } from 'drizzle-orm';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAwD1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAOvD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAuI/E;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,eAAe,IAAI,aAAa,EAChC,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,140 @@
1
+ import { beginTransaction, buildCreateMigration, commitTransaction, count, countGlobalVersions, countVersions, create, createGlobal, createGlobalVersion, createSchemaGenerator, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findGlobal, findGlobalVersions, findMigrationDir, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateJobs, updateMany, updateOne, updateVersion } from '@payloadcms/drizzle';
2
+ import { columnToCodeConverter, convertPathToJSONTraversal, countDistinct, createJSONQuery, defaultDrizzleSnapshot, deleteWhere, dropDatabase, init, insert, requireDrizzleKit } from '@payloadcms/drizzle/sqlite';
3
+ import { like, notLike } from 'drizzle-orm';
4
+ import { createDatabaseAdapter, defaultBeginTransaction } from 'payload';
5
+ import { fileURLToPath } from 'url';
6
+ import { connect } from './connect.js';
7
+ import { execute } from './execute.js';
8
+ const filename = fileURLToPath(import.meta.url);
9
+ export function sqliteD1Adapter(args) {
10
+ const sqliteIDType = args.idType || 'number';
11
+ const payloadIDType = sqliteIDType === 'uuid' ? 'text' : 'number';
12
+ const allowIDOnCreate = args.allowIDOnCreate ?? false;
13
+ function adapter({ payload }) {
14
+ const migrationDir = findMigrationDir(args.migrationDir);
15
+ let resolveInitializing = ()=>{};
16
+ let rejectInitializing = ()=>{};
17
+ const initializing = new Promise((res, rej)=>{
18
+ resolveInitializing = res;
19
+ rejectInitializing = rej;
20
+ });
21
+ // sqlite's like operator is case-insensitive, so we overwrite the DrizzleAdapter operators to not use ilike
22
+ const operators = {
23
+ ...operatorMap,
24
+ contains: like,
25
+ like,
26
+ not_like: notLike
27
+ };
28
+ return createDatabaseAdapter({
29
+ name: 'sqlite',
30
+ afterSchemaInit: args.afterSchemaInit ?? [],
31
+ allowIDOnCreate,
32
+ autoIncrement: args.autoIncrement ?? false,
33
+ beforeSchemaInit: args.beforeSchemaInit ?? [],
34
+ binding: args.binding,
35
+ // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
36
+ client: undefined,
37
+ defaultDrizzleSnapshot,
38
+ // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
39
+ drizzle: undefined,
40
+ features: {
41
+ json: true
42
+ },
43
+ fieldConstraints: {},
44
+ generateSchema: createSchemaGenerator({
45
+ columnToCodeConverter,
46
+ corePackageSuffix: 'sqlite-core',
47
+ defaultOutputFile: args.generateSchemaOutputFile,
48
+ tableImport: 'sqliteTable'
49
+ }),
50
+ idType: sqliteIDType,
51
+ initializing,
52
+ localesSuffix: args.localesSuffix || '_locales',
53
+ logger: args.logger,
54
+ operators,
55
+ prodMigrations: args.prodMigrations,
56
+ // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
57
+ push: args.push,
58
+ rawRelations: {},
59
+ rawTables: {},
60
+ relations: {},
61
+ relationshipsSuffix: args.relationshipsSuffix || '_rels',
62
+ schema: {},
63
+ schemaName: args.schemaName,
64
+ sessions: {},
65
+ tableNameMap: new Map(),
66
+ tables: {},
67
+ // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
68
+ execute,
69
+ // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
70
+ transactionOptions: args.transactionOptions || undefined,
71
+ updateJobs,
72
+ updateMany,
73
+ versionsSuffix: args.versionsSuffix || '_v',
74
+ // DatabaseAdapter
75
+ beginTransaction: args.transactionOptions ? beginTransaction : defaultBeginTransaction(),
76
+ commitTransaction,
77
+ connect,
78
+ convertPathToJSONTraversal,
79
+ count,
80
+ countDistinct,
81
+ countGlobalVersions,
82
+ countVersions,
83
+ create,
84
+ createGlobal,
85
+ createGlobalVersion,
86
+ createJSONQuery,
87
+ createMigration: buildCreateMigration({
88
+ executeMethod: 'run',
89
+ filename,
90
+ sanitizeStatements ({ sqlExecute, statements }) {
91
+ return statements.map((statement)=>`${sqlExecute}${statement?.replaceAll('`', '\\`')}\`)`).join('\n');
92
+ }
93
+ }),
94
+ createVersion,
95
+ defaultIDType: payloadIDType,
96
+ deleteMany,
97
+ deleteOne,
98
+ deleteVersions,
99
+ deleteWhere,
100
+ destroy,
101
+ dropDatabase,
102
+ find,
103
+ findGlobal,
104
+ findGlobalVersions,
105
+ findOne,
106
+ findVersions,
107
+ indexes: new Set(),
108
+ init,
109
+ insert,
110
+ migrate,
111
+ migrateDown,
112
+ migrateFresh,
113
+ migrateRefresh,
114
+ migrateReset,
115
+ migrateStatus,
116
+ migrationDir,
117
+ packageName: '@payloadcms/db-d1-sqlite',
118
+ payload,
119
+ queryDrafts,
120
+ rejectInitializing,
121
+ requireDrizzleKit,
122
+ resolveInitializing,
123
+ rollbackTransaction,
124
+ updateGlobal,
125
+ updateGlobalVersion,
126
+ updateOne,
127
+ updateVersion,
128
+ upsert: updateOne
129
+ });
130
+ }
131
+ return {
132
+ name: 'd1-sqlite',
133
+ allowIDOnCreate,
134
+ defaultIDType: payloadIDType,
135
+ init: adapter
136
+ };
137
+ }
138
+ export { sql } from 'drizzle-orm';
139
+
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 findGlobal,\n findGlobalVersions,\n findMigrationDir,\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} from '@payloadcms/drizzle'\nimport {\n columnToCodeConverter,\n convertPathToJSONTraversal,\n countDistinct,\n createJSONQuery,\n defaultDrizzleSnapshot,\n deleteWhere,\n dropDatabase,\n init,\n insert,\n requireDrizzleKit,\n} from '@payloadcms/drizzle/sqlite'\nimport { like, notLike } from 'drizzle-orm'\nimport { createDatabaseAdapter, defaultBeginTransaction } from 'payload'\nimport { fileURLToPath } from 'url'\n\nimport type { Args, SQLiteD1Adapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { execute } from './execute.js'\n\nconst filename = fileURLToPath(import.meta.url)\n\nexport function sqliteD1Adapter(args: Args): DatabaseAdapterObj<SQLiteD1Adapter> {\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<SQLiteD1Adapter>({\n name: 'sqlite',\n afterSchemaInit: args.afterSchemaInit ?? [],\n allowIDOnCreate,\n autoIncrement: args.autoIncrement ?? false,\n beforeSchemaInit: args.beforeSchemaInit ?? [],\n binding: args.binding,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n client: undefined,\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 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 execute,\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 find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\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-d1-sqlite',\n payload,\n queryDrafts,\n rejectInitializing,\n requireDrizzleKit,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n upsert: updateOne,\n })\n }\n\n return {\n name: 'd1-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 SQLiteD1Adapter as 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","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","columnToCodeConverter","convertPathToJSONTraversal","countDistinct","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","init","insert","requireDrizzleKit","like","notLike","createDatabaseAdapter","defaultBeginTransaction","fileURLToPath","connect","execute","filename","url","sqliteD1Adapter","args","sqliteIDType","idType","payloadIDType","allowIDOnCreate","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","operators","contains","not_like","name","afterSchemaInit","autoIncrement","beforeSchemaInit","binding","client","undefined","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","indexes","Set","packageName","upsert","sql"],"mappings":"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"}
@@ -0,0 +1,162 @@
1
+ import type { ResultSet } from '@libsql/client';
2
+ import type { BuildQueryJoinAliases, DrizzleAdapter, extendDrizzleTable } from '@payloadcms/drizzle';
3
+ import type { BaseSQLiteAdapter, BaseSQLiteArgs } from '@payloadcms/drizzle/sqlite';
4
+ import type { DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm';
5
+ import type { AnyD1Database, DrizzleD1Database } from 'drizzle-orm/d1';
6
+ import type { LibSQLDatabase } from 'drizzle-orm/libsql';
7
+ import type { AnySQLiteColumn, SQLiteInsertOnConflictDoUpdateConfig, SQLiteTableWithColumns, SQLiteTransactionConfig } from 'drizzle-orm/sqlite-core';
8
+ import type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw';
9
+ import type { Payload, PayloadRequest } from 'payload';
10
+ type SQLiteSchema = {
11
+ relations: Record<string, GenericRelation>;
12
+ tables: Record<string, SQLiteTableWithColumns<any>>;
13
+ };
14
+ type SQLiteSchemaHookArgs = {
15
+ extendTable: typeof extendDrizzleTable;
16
+ schema: SQLiteSchema;
17
+ };
18
+ export type SQLiteSchemaHook = (args: SQLiteSchemaHookArgs) => Promise<SQLiteSchema> | SQLiteSchema;
19
+ export type Args = {
20
+ binding: AnyD1Database;
21
+ } & BaseSQLiteArgs;
22
+ export type GenericColumns = {
23
+ [x: string]: AnySQLiteColumn;
24
+ };
25
+ export type GenericTable = SQLiteTableWithColumns<{
26
+ columns: GenericColumns;
27
+ dialect: string;
28
+ name: string;
29
+ schema: string;
30
+ }>;
31
+ export type GenericRelation = Relations<string, Record<string, Relation<string>>>;
32
+ export type CountDistinct = (args: {
33
+ db: LibSQLDatabase;
34
+ joins: BuildQueryJoinAliases;
35
+ tableName: string;
36
+ where: SQL;
37
+ }) => Promise<number>;
38
+ export type DeleteWhere = (args: {
39
+ db: LibSQLDatabase;
40
+ tableName: string;
41
+ where: SQL;
42
+ }) => Promise<void>;
43
+ export type DropDatabase = (args: {
44
+ adapter: SQLiteD1Adapter;
45
+ }) => Promise<void>;
46
+ export type Execute<T> = (args: {
47
+ db?: LibSQLDatabase;
48
+ drizzle?: LibSQLDatabase;
49
+ raw?: string;
50
+ sql?: SQL<unknown>;
51
+ }) => SQLiteRaw<Promise<T>> | SQLiteRaw<ResultSet>;
52
+ export type Insert = (args: {
53
+ db: LibSQLDatabase;
54
+ onConflictDoUpdate?: SQLiteInsertOnConflictDoUpdateConfig<any>;
55
+ tableName: string;
56
+ values: Record<string, unknown> | Record<string, unknown>[];
57
+ }) => Promise<Record<string, unknown>[]>;
58
+ type SQLiteDrizzleAdapter = Omit<DrizzleAdapter, 'countDistinct' | 'deleteWhere' | 'drizzle' | 'dropDatabase' | 'execute' | 'idType' | 'insert' | 'operators' | 'relations'>;
59
+ export interface GeneratedDatabaseSchema {
60
+ schemaUntyped: Record<string, unknown>;
61
+ }
62
+ type Drizzle = {
63
+ $client: AnyD1Database;
64
+ } & DrizzleD1Database<Record<string, any>>;
65
+ export type SQLiteD1Adapter = {
66
+ binding: Args['binding'];
67
+ client: AnyD1Database;
68
+ drizzle: Drizzle;
69
+ } & BaseSQLiteAdapter & SQLiteDrizzleAdapter;
70
+ export type IDType = 'integer' | 'numeric' | 'text';
71
+ export type MigrateUpArgs = {
72
+ /**
73
+ * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.
74
+ * @example
75
+ * ```ts
76
+ * import { type MigrateUpArgs, sql } from '@payloadcms/db-sqlite'
77
+ *
78
+ * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
79
+ * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)
80
+ * }
81
+ * ```
82
+ */
83
+ db: Drizzle;
84
+ /**
85
+ * The Payload instance that you can use to execute Local API methods
86
+ * To use the current transaction you must pass `req` to arguments
87
+ * @example
88
+ * ```ts
89
+ * import { type MigrateUpArgs } from '@payloadcms/db-sqlite'
90
+ *
91
+ * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
92
+ * const posts = await payload.find({ collection: 'posts', req })
93
+ * }
94
+ * ```
95
+ */
96
+ payload: Payload;
97
+ /**
98
+ * The `PayloadRequest` object that contains the current transaction
99
+ */
100
+ req: PayloadRequest;
101
+ };
102
+ export type MigrateDownArgs = {
103
+ /**
104
+ * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction.
105
+ * @example
106
+ * ```ts
107
+ * import { type MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
108
+ *
109
+ * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
110
+ * const { rows: posts } = await db.run(sql`SELECT * FROM posts`)
111
+ * }
112
+ * ```
113
+ */
114
+ db: Drizzle;
115
+ /**
116
+ * The Payload instance that you can use to execute Local API methods
117
+ * To use the current transaction you must pass `req` to arguments
118
+ * @example
119
+ * ```ts
120
+ * import { type MigrateDownArgs } from '@payloadcms/db-sqlite'
121
+ *
122
+ * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
123
+ * const posts = await payload.find({ collection: 'posts', req })
124
+ * }
125
+ * ```
126
+ */
127
+ payload: Payload;
128
+ /**
129
+ * The `PayloadRequest` object that contains the current transaction
130
+ */
131
+ req: PayloadRequest;
132
+ };
133
+ declare module 'payload' {
134
+ interface DatabaseAdapter extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>, DrizzleAdapter {
135
+ beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>;
136
+ drizzle: Drizzle;
137
+ /**
138
+ * 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
139
+ * Used for returning properly formed errors from unique fields
140
+ */
141
+ fieldConstraints: Record<string, Record<string, string>>;
142
+ idType: Args['idType'];
143
+ initializing: Promise<void>;
144
+ localesSuffix?: string;
145
+ logger: DrizzleConfig['logger'];
146
+ prodMigrations?: {
147
+ down: (args: MigrateDownArgs) => Promise<void>;
148
+ name: string;
149
+ up: (args: MigrateUpArgs) => Promise<void>;
150
+ }[];
151
+ push: boolean;
152
+ rejectInitializing: () => void;
153
+ relationshipsSuffix?: string;
154
+ resolveInitializing: () => void;
155
+ schema: Record<string, GenericRelation | GenericTable>;
156
+ tableNameMap: Map<string, string>;
157
+ transactionOptions: SQLiteTransactionConfig;
158
+ versionsSuffix?: string;
159
+ }
160
+ }
161
+ export {};
162
+ //# sourceMappingURL=types.d.ts.map