@payloadcms/db-postgres 3.0.0-canary.98cbdb9 → 3.0.0-canary.99cbde3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +25 -6
  3. package/dist/connect.js.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +32 -19
  7. package/dist/index.js.map +1 -1
  8. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
  9. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +72 -67
  10. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
  11. package/dist/predefinedMigrations/v2-v3/index.js +2 -2
  12. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  13. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  14. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +9 -3
  15. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  16. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  17. package/dist/predefinedMigrations/v2-v3/traverseFields.js +32 -32
  18. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  19. package/dist/types.d.ts +31 -106
  20. package/dist/types.d.ts.map +1 -1
  21. package/dist/types.js.map +1 -1
  22. package/license.md +22 -0
  23. package/package.json +19 -10
  24. package/dist/countDistinct.d.ts +0 -3
  25. package/dist/countDistinct.d.ts.map +0 -1
  26. package/dist/countDistinct.js +0 -24
  27. package/dist/countDistinct.js.map +0 -1
  28. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  29. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  30. package/dist/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  31. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  32. package/dist/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  33. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  34. package/dist/createJSONQuery/formatJSONPathSegment.js +0 -5
  35. package/dist/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  36. package/dist/createJSONQuery/index.d.ts +0 -10
  37. package/dist/createJSONQuery/index.d.ts.map +0 -1
  38. package/dist/createJSONQuery/index.js +0 -54
  39. package/dist/createJSONQuery/index.js.map +0 -1
  40. package/dist/createMigration.d.ts +0 -3
  41. package/dist/createMigration.d.ts.map +0 -1
  42. package/dist/createMigration.js +0 -91
  43. package/dist/createMigration.js.map +0 -1
  44. package/dist/defaultSnapshot.d.ts +0 -3
  45. package/dist/defaultSnapshot.d.ts.map +0 -1
  46. package/dist/defaultSnapshot.js +0 -17
  47. package/dist/defaultSnapshot.js.map +0 -1
  48. package/dist/deleteWhere.d.ts +0 -3
  49. package/dist/deleteWhere.d.ts.map +0 -1
  50. package/dist/deleteWhere.js +0 -6
  51. package/dist/deleteWhere.js.map +0 -1
  52. package/dist/dropDatabase.d.ts +0 -3
  53. package/dist/dropDatabase.d.ts.map +0 -1
  54. package/dist/dropDatabase.js +0 -9
  55. package/dist/dropDatabase.js.map +0 -1
  56. package/dist/execute.d.ts +0 -3
  57. package/dist/execute.d.ts.map +0 -1
  58. package/dist/execute.js +0 -11
  59. package/dist/execute.js.map +0 -1
  60. package/dist/getMigrationTemplate.d.ts +0 -4
  61. package/dist/getMigrationTemplate.d.ts.map +0 -1
  62. package/dist/getMigrationTemplate.js +0 -13
  63. package/dist/getMigrationTemplate.js.map +0 -1
  64. package/dist/init.d.ts +0 -3
  65. package/dist/init.d.ts.map +0 -1
  66. package/dist/init.js +0 -95
  67. package/dist/init.js.map +0 -1
  68. package/dist/insert.d.ts +0 -3
  69. package/dist/insert.d.ts.map +0 -1
  70. package/dist/insert.js +0 -12
  71. package/dist/insert.js.map +0 -1
  72. package/dist/requireDrizzleKit.d.ts +0 -3
  73. package/dist/requireDrizzleKit.d.ts.map +0 -1
  74. package/dist/requireDrizzleKit.js +0 -5
  75. package/dist/requireDrizzleKit.js.map +0 -1
  76. package/dist/schema/build.d.ts +0 -38
  77. package/dist/schema/build.d.ts.map +0 -1
  78. package/dist/schema/build.js +0 -369
  79. package/dist/schema/build.js.map +0 -1
  80. package/dist/schema/createIndex.d.ts +0 -12
  81. package/dist/schema/createIndex.d.ts.map +0 -1
  82. package/dist/schema/createIndex.js +0 -18
  83. package/dist/schema/createIndex.js.map +0 -1
  84. package/dist/schema/idToUUID.d.ts +0 -3
  85. package/dist/schema/idToUUID.d.ts.map +0 -1
  86. package/dist/schema/idToUUID.js +0 -11
  87. package/dist/schema/idToUUID.js.map +0 -1
  88. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  89. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  90. package/dist/schema/parentIDColumnMap.js +0 -9
  91. package/dist/schema/parentIDColumnMap.js.map +0 -1
  92. package/dist/schema/setColumnID.d.ts +0 -11
  93. package/dist/schema/setColumnID.d.ts.map +0 -1
  94. package/dist/schema/setColumnID.js +0 -24
  95. package/dist/schema/setColumnID.js.map +0 -1
  96. package/dist/schema/traverseFields.d.ts +0 -36
  97. package/dist/schema/traverseFields.d.ts.map +0 -1
  98. package/dist/schema/traverseFields.js +0 -613
  99. package/dist/schema/traverseFields.js.map +0 -1
  100. package/dist/schema/withDefault.d.ts +0 -4
  101. package/dist/schema/withDefault.d.ts.map +0 -1
  102. package/dist/schema/withDefault.js +0 -10
  103. package/dist/schema/withDefault.js.map +0 -1
@@ -1,54 +0,0 @@
1
- import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js';
2
- import { formatJSONPathSegment } from './formatJSONPathSegment.js';
3
- const operatorMap = {
4
- contains: '~*',
5
- equals: '=',
6
- like: '~*'
7
- };
8
- const fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value })=>{
9
- const newPathSegments = pathSegments.slice(isRoot ? 1 : 2);
10
- const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`;
11
- newPathSegments.unshift(alias);
12
- const arrayElements = isRoot ? pathSegments[0] : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`;
13
- return `EXISTS (
14
- SELECT 1
15
- FROM jsonb_array_elements(${arrayElements}) AS ${alias}
16
- WHERE ${createJSONQuery({
17
- operator,
18
- pathSegments: newPathSegments,
19
- treatAsArray,
20
- value
21
- })}
22
- )`;
23
- };
24
- const createConstraint = ({ operator, pathSegments, value })=>{
25
- const jsonQuery = convertPathToJSONTraversal(pathSegments);
26
- return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`;
27
- };
28
- export const createJSONQuery = ({ operator, pathSegments, treatAsArray, treatRootAsArray, value })=>{
29
- if (treatRootAsArray) {
30
- return fromArray({
31
- isRoot: true,
32
- operator,
33
- pathSegments,
34
- treatAsArray,
35
- value
36
- });
37
- }
38
- if (treatAsArray.includes(pathSegments[1])) {
39
- return fromArray({
40
- operator,
41
- pathSegments,
42
- treatAsArray,
43
- value
44
- });
45
- }
46
- return createConstraint({
47
- operator,
48
- pathSegments,
49
- treatAsArray,
50
- value
51
- });
52
- };
53
-
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createJSONQuery/index.ts"],"sourcesContent":["import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js'\nimport { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nconst operatorMap = {\n contains: '~*',\n equals: '=',\n like: '~*',\n}\n\ntype FromArrayArgs = {\n isRoot?: true\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value }: FromArrayArgs) => {\n const newPathSegments = pathSegments.slice(isRoot ? 1 : 2)\n const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`\n\n newPathSegments.unshift(alias)\n\n const arrayElements = isRoot\n ? pathSegments[0]\n : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`\n\n return `EXISTS (\n SELECT 1\n FROM jsonb_array_elements(${arrayElements}) AS ${alias}\n WHERE ${createJSONQuery({\n operator,\n pathSegments: newPathSegments,\n treatAsArray,\n value,\n })}\n )`\n}\n\ntype CreateConstraintArgs = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst createConstraint = ({ operator, pathSegments, value }: CreateConstraintArgs): string => {\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`\n}\n\ntype Args = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n treatRootAsArray?: boolean\n value: unknown\n}\n\nexport const createJSONQuery = ({\n operator,\n pathSegments,\n treatAsArray,\n treatRootAsArray,\n value,\n}: Args): string => {\n if (treatRootAsArray) {\n return fromArray({\n isRoot: true,\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n if (treatAsArray.includes(pathSegments[1])) {\n return fromArray({\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n return createConstraint({ operator, pathSegments, treatAsArray, value })\n}\n"],"names":["convertPathToJSONTraversal","formatJSONPathSegment","operatorMap","contains","equals","like","fromArray","isRoot","operator","pathSegments","treatAsArray","value","newPathSegments","slice","alias","length","unshift","arrayElements","createJSONQuery","createConstraint","jsonQuery","treatRootAsArray","includes"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,cAAc;IAClBC,UAAU;IACVC,QAAQ;IACRC,MAAM;AACR;AAUA,MAAMC,YAAY,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,YAAY,EAAEC,KAAK,EAAiB;IACvF,MAAMC,kBAAkBH,aAAaI,KAAK,CAACN,SAAS,IAAI;IACxD,MAAMO,QAAQ,CAAC,EAAEL,YAAY,CAACF,SAAS,IAAI,EAAE,CAAC,OAAO,EAAEK,gBAAgBG,MAAM,CAAC,CAAC;IAE/EH,gBAAgBI,OAAO,CAACF;IAExB,MAAMG,gBAAgBV,SAClBE,YAAY,CAAC,EAAE,GACf,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,IAAI,EAAER,sBAAsBQ,YAAY,CAAC,EAAE,EAAE,CAAC;IAErE,OAAO,CAAC;;8BAEoB,EAAEQ,cAAc,KAAK,EAAEH,MAAM;UACjD,EAAEI,gBAAgB;QACtBV;QACAC,cAAcG;QACdF;QACAC;IACF,GAAG;GACJ,CAAC;AACJ;AASA,MAAMQ,mBAAmB,CAAC,EAAEX,QAAQ,EAAEC,YAAY,EAAEE,KAAK,EAAwB;IAC/E,MAAMS,YAAYpB,2BAA2BS;IAC7C,OAAO,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,EAAEW,UAAU,CAAC,EAAElB,WAAW,CAACM,SAAS,CAAC,EAAE,EAAEG,MAAM,CAAC,CAAC;AAC7E;AAUA,OAAO,MAAMO,kBAAkB,CAAC,EAC9BV,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZW,gBAAgB,EAChBV,KAAK,EACA;IACL,IAAIU,kBAAkB;QACpB,OAAOf,UAAU;YACfC,QAAQ;YACRC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,IAAID,aAAaY,QAAQ,CAACb,YAAY,CAAC,EAAE,GAAG;QAC1C,OAAOH,UAAU;YACfE;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOQ,iBAAiB;QAAEX;QAAUC;QAAcC;QAAcC;IAAM;AACxE,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { CreateMigration } from 'payload';
2
- export declare const createMigration: CreateMigration;
3
- //# sourceMappingURL=createMigration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB9C,eAAO,MAAM,eAAe,EAAE,eAwG7B,CAAA"}
@@ -1,91 +0,0 @@
1
- import fs from 'fs';
2
- import { createRequire } from 'module';
3
- import path from 'path';
4
- import { getPredefinedMigration, writeMigrationIndex } from 'payload';
5
- import prompts from 'prompts';
6
- import { fileURLToPath } from 'url';
7
- import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
8
- import { getMigrationTemplate } from './getMigrationTemplate.js';
9
- const require = createRequire(import.meta.url);
10
- export const createMigration = async function createMigration({ file, forceAcceptWarning, migrationName, payload }) {
11
- const filename = fileURLToPath(import.meta.url);
12
- const dirname = path.dirname(filename);
13
- const dir = payload.db.migrationDir;
14
- if (!fs.existsSync(dir)) {
15
- fs.mkdirSync(dir);
16
- }
17
- const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api');
18
- const drizzleJsonAfter = generateDrizzleJson(this.schema);
19
- const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
20
- const formattedDate = yyymmdd.replace(/\D/g, '');
21
- const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
22
- let imports = '';
23
- let downSQL;
24
- let upSQL;
25
- ({ downSQL, imports, upSQL } = await getPredefinedMigration({
26
- dirname,
27
- file,
28
- migrationName,
29
- payload
30
- }));
31
- const timestamp = `${formattedDate}_${formattedTime}`;
32
- const name = migrationName || file?.split('/').slice(2).join('/');
33
- const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
34
- const filePath = `${dir}/${fileName}`;
35
- let drizzleJsonBefore = defaultDrizzleSnapshot;
36
- if (this.schemaName) {
37
- drizzleJsonBefore.schemas = {
38
- [this.schemaName]: this.schemaName
39
- };
40
- }
41
- if (!upSQL) {
42
- // Get latest migration snapshot
43
- const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
44
- if (latestSnapshot) {
45
- drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
46
- if (drizzleJsonBefore.version < drizzleJsonAfter.version) {
47
- drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore);
48
- }
49
- }
50
- const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
51
- const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
52
- const sqlExecute = 'await payload.db.drizzle.execute(sql`';
53
- if (sqlStatementsUp?.length) {
54
- upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
55
- }
56
- if (sqlStatementsDown?.length) {
57
- downSQL = `${sqlExecute}\n ${sqlStatementsDown?.join('\n')}\`)`;
58
- }
59
- if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
60
- const { confirm: shouldCreateBlankMigration } = await prompts({
61
- name: 'confirm',
62
- type: 'confirm',
63
- initial: false,
64
- message: 'No schema changes detected. Would you like to create a blank migration file?'
65
- }, {
66
- onCancel: ()=>{
67
- process.exit(0);
68
- }
69
- });
70
- if (!shouldCreateBlankMigration) {
71
- process.exit(0);
72
- }
73
- }
74
- // write schema
75
- fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
76
- }
77
- // write migration
78
- fs.writeFileSync(`${filePath}.ts`, getMigrationTemplate({
79
- downSQL: downSQL || ` // Migration code`,
80
- imports,
81
- upSQL: upSQL || ` // Migration code`
82
- }));
83
- writeMigrationIndex({
84
- migrationsDir: payload.db.migrationDir
85
- });
86
- payload.logger.info({
87
- msg: `Migration created at ${filePath}.ts`
88
- });
89
- };
90
-
91
- //# sourceMappingURL=createMigration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { defaultDrizzleSnapshot } from './defaultSnapshot.js'\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nconst require = createRequire(import.meta.url)\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = defaultDrizzleSnapshot\n\n if (this.schemaName) {\n drizzleJsonBefore.schemas = {\n [this.schemaName]: this.schemaName,\n }\n }\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'))\n\n if (drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore)\n }\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await payload.db.drizzle.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","writeMigrationIndex","prompts","fileURLToPath","defaultDrizzleSnapshot","getMigrationTemplate","require","url","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upPgSnapshot","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","migrationsDir","logger","info","msg"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,SAASC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B,EAAE,GAAG,MAAM1D,QACpD;gBACEmC,MAAM;gBACNwB,MAAM;gBACNC,SAAS;gBACTC,SAAS;YACX,GACA;gBACEC,UAAU;oBACRC,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACN,4BAA4B;gBAC/BK,QAAQC,IAAI,CAAC;YACf;QACF;QAEA,eAAe;QACfrE,GAAGsE,aAAa,CAAC,CAAC,EAAE1B,SAAS,KAAK,CAAC,EAAEU,KAAKiB,SAAS,CAAC7C,kBAAkB,MAAM;IAC9E;IAEA,kBAAkB;IAClB1B,GAAGsE,aAAa,CACd,CAAC,EAAE1B,SAAS,GAAG,CAAC,EAChBpC,qBAAqB;QACnB6B,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCD;QACAE,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAGFlC,oBAAoB;QAAEoE,eAAezD,QAAQI,EAAE,CAACC,YAAY;IAAC;IAE7DL,QAAQ0D,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAE/B,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DrizzleSnapshotJSON } from 'drizzle-kit/api';
2
- export declare const defaultDrizzleSnapshot: DrizzleSnapshotJSON;
3
- //# sourceMappingURL=defaultSnapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultSnapshot.d.ts","sourceRoot":"","sources":["../src/defaultSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,eAAO,MAAM,sBAAsB,EAAE,mBAcpC,CAAA"}
@@ -1,17 +0,0 @@
1
- export const defaultDrizzleSnapshot = {
2
- id: '00000000-0000-0000-0000-000000000000',
3
- _meta: {
4
- columns: {},
5
- schemas: {},
6
- tables: {}
7
- },
8
- dialect: 'postgresql',
9
- enums: {},
10
- prevId: '00000000-0000-0000-0000-00000000000',
11
- schemas: {},
12
- sequences: {},
13
- tables: {},
14
- version: '7'
15
- };
16
-
17
- //# sourceMappingURL=defaultSnapshot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/defaultSnapshot.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\n\nexport const defaultDrizzleSnapshot: DrizzleSnapshotJSON = {\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'postgresql',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n sequences: {},\n tables: {},\n version: '7',\n}\n"],"names":["defaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","sequences","version"],"mappings":"AAEA,OAAO,MAAMA,yBAA8C;IACzDC,IAAI;IACJC,OAAO;QACLC,SAAS,CAAC;QACVC,SAAS,CAAC;QACVC,QAAQ,CAAC;IACX;IACAC,SAAS;IACTC,OAAO,CAAC;IACRC,QAAQ;IACRJ,SAAS,CAAC;IACVK,WAAW,CAAC;IACZJ,QAAQ,CAAC;IACTK,SAAS;AACX,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DeleteWhere } from './types.js';
2
- export declare const deleteWhere: DeleteWhere;
3
- //# sourceMappingURL=deleteWhere.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteWhere.d.ts","sourceRoot":"","sources":["../src/deleteWhere.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,eAAO,MAAM,WAAW,EAAE,WAGzB,CAAA"}
@@ -1,6 +0,0 @@
1
- export const deleteWhere = async function deleteWhere({ db, tableName, where }) {
2
- const table = this.tables[tableName];
3
- await db.delete(table).where(where);
4
- };
5
-
6
- //# sourceMappingURL=deleteWhere.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deleteWhere.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { DeleteWhere } from './types.js'\n\nexport const deleteWhere: DeleteWhere = async function deleteWhere({ db, tableName, where }) {\n const table = this.tables[tableName]\n await (db as TransactionPg).delete(table).where(where)\n}\n"],"names":["deleteWhere","db","tableName","where","table","tables","delete"],"mappings":"AAIA,OAAO,MAAMA,cAA2B,eAAeA,YAAY,EAAEC,EAAE,EAAEC,SAAS,EAAEC,KAAK,EAAE;IACzF,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,MAAM,AAACD,GAAqBK,MAAM,CAACF,OAAOD,KAAK,CAACA;AAClD,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { DropDatabase } from './types.js';
2
- export declare const dropDatabase: DropDatabase;
3
- //# sourceMappingURL=dropDatabase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropDatabase.d.ts","sourceRoot":"","sources":["../src/dropDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,eAAO,MAAM,YAAY,EAAE,YAM1B,CAAA"}
@@ -1,9 +0,0 @@
1
- export const dropDatabase = async function dropDatabase({ adapter }) {
2
- await adapter.execute({
3
- drizzle: adapter.drizzle,
4
- raw: `drop schema if exists ${this.schemaName || 'public'} cascade;
5
- create schema ${this.schemaName || 'public'};`
6
- });
7
- };
8
-
9
- //# sourceMappingURL=dropDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/dropDatabase.ts"],"sourcesContent":["import type { DropDatabase } from './types.js'\n\nexport const dropDatabase: DropDatabase = async function dropDatabase({ adapter }) {\n await adapter.execute({\n drizzle: adapter.drizzle,\n raw: `drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};`,\n })\n}\n"],"names":["dropDatabase","adapter","execute","drizzle","raw","schemaName"],"mappings":"AAEA,OAAO,MAAMA,eAA6B,eAAeA,aAAa,EAAEC,OAAO,EAAE;IAC/E,MAAMA,QAAQC,OAAO,CAAC;QACpBC,SAASF,QAAQE,OAAO;QACxBC,KAAK,CAAC,sBAAsB,EAAE,IAAI,CAACC,UAAU,IAAI,SAAS;kBAC5C,EAAE,IAAI,CAACA,UAAU,IAAI,SAAS,CAAC,CAAC;IAChD;AACF,EAAC"}
package/dist/execute.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Execute } from './types.js';
2
- export declare const execute: Execute<any>;
3
- //# sourceMappingURL=execute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,OAAO,CAAC,GAAG,CAQhC,CAAA"}
package/dist/execute.js DELETED
@@ -1,11 +0,0 @@
1
- import { sql } from 'drizzle-orm';
2
- export const execute = function execute({ db, drizzle, raw, sql: statement }) {
3
- const executeFrom = db ?? drizzle;
4
- if (raw) {
5
- return executeFrom.execute(sql.raw(raw));
6
- } else {
7
- return executeFrom.execute(sql`${statement}`);
8
- }
9
- };
10
-
11
- //# sourceMappingURL=execute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/execute.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\n\nimport type { Execute } from './types.js'\n\nexport const execute: Execute<any> = function execute({ db, drizzle, raw, sql: statement }) {\n const executeFrom = db ?? drizzle\n\n if (raw) {\n return executeFrom.execute(sql.raw(raw))\n } else {\n return executeFrom.execute(sql`${statement}`)\n }\n}\n"],"names":["sql","execute","db","drizzle","raw","statement","executeFrom"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,UAAwB,SAASA,QAAQ,EAAEC,EAAE,EAAEC,OAAO,EAAEC,GAAG,EAAEJ,KAAKK,SAAS,EAAE;IACxF,MAAMC,cAAcJ,MAAMC;IAE1B,IAAIC,KAAK;QACP,OAAOE,YAAYL,OAAO,CAACD,IAAII,GAAG,CAACA;IACrC,OAAO;QACL,OAAOE,YAAYL,OAAO,CAACD,GAAG,CAAC,EAAEK,UAAU,CAAC;IAC9C;AACF,EAAC"}
@@ -1,4 +0,0 @@
1
- import type { MigrationTemplateArgs } from 'payload';
2
- export declare const indent: (text: string) => string;
3
- export declare const getMigrationTemplate: ({ downSQL, imports, upSQL, }: MigrationTemplateArgs) => string;
4
- //# sourceMappingURL=getMigrationTemplate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../src/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,SAAU,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,iCAI9B,qBAAqB,KAAG,MAS1B,CAAA"}
@@ -1,13 +0,0 @@
1
- export const indent = (text)=>text.split('\n').map((line)=>` ${line}`).join('\n');
2
- export const getMigrationTemplate = ({ downSQL, imports, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
3
- ${imports ? `${imports}\n` : ''}
4
- export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
5
- ${indent(upSQL)}
6
- }
7
-
8
- export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
9
- ${indent(downSQL)}
10
- }
11
- `;
12
-
13
- //# sourceMappingURL=getMigrationTemplate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/getMigrationTemplate.ts"],"sourcesContent":["import type { MigrationTemplateArgs } from 'payload'\n\nexport const indent = (text: string) =>\n text\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')\n\nexport const getMigrationTemplate = ({\n downSQL,\n imports,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${indent(upSQL)}\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${indent(downSQL)}\n}\n`\n"],"names":["indent","text","split","map","line","join","getMigrationTemplate","downSQL","imports","upSQL"],"mappings":"AAEA,OAAO,MAAMA,SAAS,CAACC,OACrBA,KACGC,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAAS,CAAC,EAAE,EAAEA,KAAK,CAAC,EACzBC,IAAI,CAAC,MAAK;AAEf,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,OAAO,EACPC,OAAO,EACPC,KAAK,EACiB,GAAa,CAAC;AACtC,EAAED,UAAU,CAAC,EAAEA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAER,OAAOS,OAAO;;;;AAIhB,EAAET,OAAOO,SAAS;;AAElB,CAAC,CAAA"}
package/dist/init.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Init } from 'payload';
2
- export declare const init: Init;
3
- //# sourceMappingURL=init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;AAY9D,eAAO,MAAM,IAAI,EAAE,IAqGlB,CAAA"}
package/dist/init.js DELETED
@@ -1,95 +0,0 @@
1
- import { createTableName } from '@payloadcms/drizzle';
2
- import { uniqueIndex } from 'drizzle-orm/pg-core';
3
- import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
4
- import toSnakeCase from 'to-snake-case';
5
- import { buildTable } from './schema/build.js';
6
- export const init = function init() {
7
- if (this.payload.config.localization) {
8
- this.enums.enum__locales = this.pgSchema.enum('_locales', this.payload.config.localization.locales.map(({ code })=>code));
9
- }
10
- this.payload.config.collections.forEach((collection)=>{
11
- createTableName({
12
- adapter: this,
13
- config: collection
14
- });
15
- if (collection.versions) {
16
- createTableName({
17
- adapter: this,
18
- config: collection,
19
- versions: true,
20
- versionsCustomName: true
21
- });
22
- }
23
- });
24
- this.payload.config.collections.forEach((collection)=>{
25
- const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
26
- const baseExtraConfig = {};
27
- if (collection.upload.filenameCompoundIndex) {
28
- const indexName = `${tableName}_filename_compound_idx`;
29
- baseExtraConfig.filename_compound_index = (cols)=>{
30
- const colsConstraint = collection.upload.filenameCompoundIndex.map((f)=>{
31
- return cols[f];
32
- });
33
- return uniqueIndex(indexName).on(colsConstraint[0], ...colsConstraint.slice(1));
34
- };
35
- }
36
- buildTable({
37
- adapter: this,
38
- baseExtraConfig,
39
- disableNotNull: !!collection?.versions?.drafts,
40
- disableUnique: false,
41
- fields: collection.fields,
42
- tableName,
43
- timestamps: collection.timestamps,
44
- versions: false
45
- });
46
- if (collection.versions) {
47
- const versionsTableName = this.tableNameMap.get(`_${toSnakeCase(collection.slug)}${this.versionsSuffix}`);
48
- const versionFields = buildVersionCollectionFields(collection);
49
- buildTable({
50
- adapter: this,
51
- disableNotNull: !!collection.versions?.drafts,
52
- disableUnique: true,
53
- fields: versionFields,
54
- tableName: versionsTableName,
55
- timestamps: true,
56
- versions: true
57
- });
58
- }
59
- });
60
- this.payload.config.globals.forEach((global)=>{
61
- const tableName = createTableName({
62
- adapter: this,
63
- config: global
64
- });
65
- buildTable({
66
- adapter: this,
67
- disableNotNull: !!global?.versions?.drafts,
68
- disableUnique: false,
69
- fields: global.fields,
70
- tableName,
71
- timestamps: false,
72
- versions: false
73
- });
74
- if (global.versions) {
75
- const versionsTableName = createTableName({
76
- adapter: this,
77
- config: global,
78
- versions: true,
79
- versionsCustomName: true
80
- });
81
- const versionFields = buildVersionGlobalFields(global);
82
- buildTable({
83
- adapter: this,
84
- disableNotNull: !!global.versions?.drafts,
85
- disableUnique: true,
86
- fields: versionFields,
87
- tableName: versionsTableName,
88
- timestamps: true,
89
- versions: true
90
- });
91
- }
92
- });
93
- };
94
-
95
- //# sourceMappingURL=init.js.map
package/dist/init.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport { createTableName } from '@payloadcms/drizzle'\nimport { uniqueIndex } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { BaseExtraConfig } from './schema/build.js'\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\n if (this.payload.config.localization) {\n this.enums.enum__locales = this.pgSchema.enum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n createTableName({\n adapter: this,\n config: collection,\n })\n\n if (collection.versions) {\n createTableName({\n adapter: this,\n config: collection,\n versions: true,\n versionsCustomName: true,\n })\n }\n })\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const baseExtraConfig: BaseExtraConfig = {}\n\n if (collection.upload.filenameCompoundIndex) {\n const indexName = `${tableName}_filename_compound_idx`\n\n baseExtraConfig.filename_compound_index = (cols) => {\n const colsConstraint = collection.upload.filenameCompoundIndex.map((f) => {\n return cols[f]\n })\n return uniqueIndex(indexName).on(colsConstraint[0], ...colsConstraint.slice(1))\n }\n }\n\n buildTable({\n adapter: this,\n baseExtraConfig,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = this.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${this.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = createTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = createTableName({\n adapter: this,\n config: global,\n versions: true,\n versionsCustomName: true,\n })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["createTableName","uniqueIndex","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","buildTable","init","payload","config","localization","enums","enum__locales","pgSchema","enum","locales","map","code","collections","forEach","collection","adapter","versions","versionsCustomName","tableName","tableNameMap","get","slug","baseExtraConfig","upload","filenameCompoundIndex","indexName","filename_compound_index","cols","colsConstraint","f","on","slice","disableNotNull","drafts","disableUnique","fields","timestamps","versionsTableName","versionsSuffix","versionFields","globals","global"],"mappings":"AAEA,SAASA,eAAe,QAAQ,sBAAqB;AACrD,SAASC,WAAW,QAAQ,sBAAqB;AACjD,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,UAAU,QAAQ,oBAAmB;AAE9C,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACpC,IAAI,CAACC,KAAK,CAACC,aAAa,GAAG,IAAI,CAACC,QAAQ,CAACC,IAAI,CAC3C,YACA,IAAI,CAACN,OAAO,CAACC,MAAM,CAACC,YAAY,CAACK,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE/D;IAEA,IAAI,CAACT,OAAO,CAACC,MAAM,CAAC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iB;gBACvCC,eAAe;gBACfC,QAAQI;gBACRrB,WAAWmB;gBACXD,YAAY;gBACZpB,UAAU;YACZ;QACF;IACF;IAEA,IAAI,CAACd,OAAO,CAACC,MAAM,CAACqC,OAAO,CAAC3B,OAAO,CAAC,CAAC4B;QACnC,MAAMvB,YAAYvB,gBAAgB;YAAEoB,SAAS,IAAI;YAAEZ,QAAQsC;QAAO;QAElEzC,WAAW;YACTe,SAAS,IAAI;YACbiB,gBAAgB,CAAC,CAACS,QAAQzB,UAAUiB;YACpCC,eAAe;YACfC,QAAQM,OAAON,MAAM;YACrBjB;YACAkB,YAAY;YACZpB,UAAU;QACZ;QAEA,IAAIyB,OAAOzB,QAAQ,EAAE;YACnB,MAAMqB,oBAAoB1C,gBAAgB;gBACxCoB,SAAS,IAAI;gBACbZ,QAAQsC;gBACRzB,UAAU;gBACVC,oBAAoB;YACtB;YACA,MAAMsB,gBAAgBzC,yBAAyB2C;YAE/CzC,WAAW;gBACTe,SAAS,IAAI;gBACbiB,gBAAgB,CAAC,CAACS,OAAOzB,QAAQ,EAAEiB;gBACnCC,eAAe;gBACfC,QAAQI;gBACRrB,WAAWmB;gBACXD,YAAY;gBACZpB,UAAU;YACZ;QACF;IACF;AACF,EAAC"}
package/dist/insert.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Insert } from './types.js';
2
- export declare const insert: Insert;
3
- //# sourceMappingURL=insert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
package/dist/insert.js DELETED
@@ -1,12 +0,0 @@
1
- export const insert = async function insert({ db, onConflictDoUpdate, tableName, values }) {
2
- const table = this.tables[tableName];
3
- let result;
4
- if (onConflictDoUpdate) {
5
- result = await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning();
6
- } else {
7
- result = await db.insert(table).values(values).returning();
8
- }
9
- return result;
10
- };
11
-
12
- //# sourceMappingURL=insert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/insert.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { Insert } from './types.js'\n\nexport const insert: Insert = async function insert({\n db,\n onConflictDoUpdate,\n tableName,\n values,\n}): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n let result\n\n if (onConflictDoUpdate) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoUpdate(onConflictDoUpdate)\n .returning()\n } else {\n result = await (db as TransactionPg).insert(table).values(values).returning()\n }\n\n return result\n}\n"],"names":["insert","db","onConflictDoUpdate","tableName","values","table","tables","result","returning"],"mappings":"AAIA,OAAO,MAAMA,SAAiB,eAAeA,OAAO,EAClDC,EAAE,EACFC,kBAAkB,EAClBC,SAAS,EACTC,MAAM,EACP;IACC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,IAAII;IAEJ,IAAIL,oBAAoB;QACtBK,SAAS,MAAM,AAACN,GACbD,MAAM,CAACK,OACPD,MAAM,CAACA,QACPF,kBAAkB,CAACA,oBACnBM,SAAS;IACd,OAAO;QACLD,SAAS,MAAM,AAACN,GAAqBD,MAAM,CAACK,OAAOD,MAAM,CAACA,QAAQI,SAAS;IAC7E;IAEA,OAAOD;AACT,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { RequireDrizzleKit } from '@payloadcms/drizzle/types';
2
- export declare const requireDrizzleKit: RequireDrizzleKit;
3
- //# sourceMappingURL=requireDrizzleKit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../src/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,eAAO,MAAM,iBAAiB,EAAE,iBAAoD,CAAA"}
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'module';
2
- const require = createRequire(import.meta.url);
3
- export const requireDrizzleKit = ()=>require('drizzle-kit/api');
4
-
5
- //# sourceMappingURL=requireDrizzleKit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/requireDrizzleKit.ts"],"sourcesContent":["import type { RequireDrizzleKit } from '@payloadcms/drizzle/types'\n\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\nexport const requireDrizzleKit: RequireDrizzleKit = () => require('drizzle-kit/api')\n"],"names":["createRequire","require","url","requireDrizzleKit"],"mappings":"AAEA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAC7C,OAAO,MAAMC,oBAAuC,IAAMF,QAAQ,mBAAkB"}
@@ -1,38 +0,0 @@
1
- import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
2
- import type { Field } from 'payload';
3
- import type { GenericColumns, PostgresAdapter } from '../types.js';
4
- export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
5
- export type RelationMap = Map<string, {
6
- localized: boolean;
7
- target: string;
8
- type: 'many' | 'one';
9
- }>;
10
- type Args = {
11
- adapter: PostgresAdapter;
12
- baseColumns?: Record<string, PgColumnBuilder>;
13
- /**
14
- * After table is created, run these functions to add extra config to the table
15
- * ie. indexes, multiple columns, etc
16
- */
17
- baseExtraConfig?: BaseExtraConfig;
18
- buildNumbers?: boolean;
19
- buildRelationships?: boolean;
20
- disableNotNull: boolean;
21
- disableUnique: boolean;
22
- fields: Field[];
23
- rootRelationsToBuild?: RelationMap;
24
- rootRelationships?: Set<string>;
25
- rootTableIDColType?: string;
26
- rootTableName?: string;
27
- tableName: string;
28
- timestamps?: boolean;
29
- versions: boolean;
30
- };
31
- type Result = {
32
- hasManyNumberField: 'index' | boolean;
33
- hasManyTextField: 'index' | boolean;
34
- relationsToBuild: RelationMap;
35
- };
36
- export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, disableNotNull, disableUnique, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions, }: Args) => Result;
37
- export {};
38
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAgBpC,OAAO,KAAK,EAAE,cAAc,EAAwB,eAAe,EAAE,MAAM,aAAa,CAAA;AAMxF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC,CAAA;AAEnG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,oBAAoB,CAAC,EAAE,WAAW,CAAA;IAClC,iBAAiB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