@payloadcms/db-postgres 0.1.0-beta.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/README.md +32 -0
  2. package/dist/connect.d.ts.map +1 -1
  3. package/dist/connect.js +28 -19
  4. package/dist/createMigration.d.ts.map +1 -1
  5. package/dist/createMigration.js +29 -19
  6. package/dist/createVersion.js +2 -2
  7. package/dist/extendViteConfig.d.ts +4 -0
  8. package/dist/extendViteConfig.d.ts.map +1 -0
  9. package/dist/extendViteConfig.js +38 -0
  10. package/dist/extendWebpackConfig.d.ts +4 -0
  11. package/dist/extendWebpackConfig.d.ts.map +1 -0
  12. package/dist/extendWebpackConfig.js +45 -0
  13. package/dist/find/buildFindManyArgs.js +3 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +16 -5
  16. package/dist/init.d.ts.map +1 -1
  17. package/dist/init.js +2 -4
  18. package/dist/migrate.d.ts.map +1 -1
  19. package/dist/migrate.js +63 -39
  20. package/dist/migrateDown.d.ts +3 -0
  21. package/dist/migrateDown.d.ts.map +1 -0
  22. package/dist/migrateDown.js +71 -0
  23. package/dist/migrateFresh.d.ts +6 -0
  24. package/dist/migrateFresh.d.ts.map +1 -0
  25. package/dist/migrateFresh.js +81 -0
  26. package/dist/migrateRefresh.d.ts +6 -0
  27. package/dist/migrateRefresh.d.ts.map +1 -0
  28. package/dist/migrateRefresh.js +109 -0
  29. package/dist/migrateReset.d.ts +6 -0
  30. package/dist/migrateReset.d.ts.map +1 -0
  31. package/dist/migrateReset.js +89 -0
  32. package/dist/queries/getTableColumnFromPath.js +2 -2
  33. package/dist/schema/build.d.ts +2 -1
  34. package/dist/schema/build.d.ts.map +1 -1
  35. package/dist/schema/build.js +14 -11
  36. package/dist/schema/createIndex.d.ts +1 -1
  37. package/dist/schema/createIndex.d.ts.map +1 -1
  38. package/dist/schema/createIndex.js +12 -3
  39. package/dist/schema/traverseFields.d.ts.map +1 -1
  40. package/dist/schema/traverseFields.js +19 -14
  41. package/dist/transform/read/index.js +4 -4
  42. package/dist/types.d.ts +7 -4
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/update.d.ts.map +1 -1
  45. package/dist/update.js +51 -5
  46. package/dist/upsertRow/index.js +2 -2
  47. package/dist/utilities/createMigrationTable.d.ts.map +1 -1
  48. package/dist/utilities/createMigrationTable.js +1 -2
  49. package/dist/utilities/parseError.d.ts +5 -0
  50. package/dist/utilities/parseError.d.ts.map +1 -0
  51. package/dist/utilities/parseError.js +24 -0
  52. package/mock.js +1 -0
  53. package/package.json +5 -4
  54. package/src/index.ts +18 -5
  55. package/dist/mock.js +0 -13
  56. package/dist/webpack.d.ts +0 -3
  57. package/dist/webpack.d.ts.map +0 -1
  58. package/dist/webpack.js +0 -32
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "parseError", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseError;
9
+ }
10
+ });
11
+ const _pg = require("pg");
12
+ const parseError = (err, msg)=>{
13
+ let formattedMsg = `${msg}`;
14
+ if (err instanceof Error) {
15
+ formattedMsg += ` ${err.message}.`;
16
+ if (err instanceof _pg.DatabaseError) {
17
+ msg += `: ${err.message}`;
18
+ if (err.hint) msg += ` ${err.hint}.`;
19
+ }
20
+ }
21
+ return formattedMsg;
22
+ };
23
+
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGFyc2VFcnJvci50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBEYXRhYmFzZUVycm9yIH0gZnJvbSAncGcnXG5cbi8qKlxuICogRm9ybWF0IGVycm9yIG1lc3NhZ2Ugd2l0aCBoaW50IGlmIGF2YWlsYWJsZVxuICovXG5leHBvcnQgY29uc3QgcGFyc2VFcnJvciA9IChlcnI6IHVua25vd24sIG1zZzogc3RyaW5nKTogc3RyaW5nID0+IHtcbiAgbGV0IGZvcm1hdHRlZE1zZyA9IGAke21zZ31gXG4gIGlmIChlcnIgaW5zdGFuY2VvZiBFcnJvcikge1xuICAgIGZvcm1hdHRlZE1zZyArPSBgICR7ZXJyLm1lc3NhZ2V9LmBcbiAgICBpZiAoZXJyIGluc3RhbmNlb2YgRGF0YWJhc2VFcnJvcikge1xuICAgICAgbXNnICs9IGA6ICR7ZXJyLm1lc3NhZ2V9YFxuICAgICAgaWYgKGVyci5oaW50KSBtc2cgKz0gYCAke2Vyci5oaW50fS5gXG4gICAgfVxuICB9XG4gIHJldHVybiBmb3JtYXR0ZWRNc2dcbn1cbiJdLCJuYW1lcyI6WyJwYXJzZUVycm9yIiwiZXJyIiwibXNnIiwiZm9ybWF0dGVkTXNnIiwiRXJyb3IiLCJtZXNzYWdlIiwiRGF0YWJhc2VFcnJvciIsImhpbnQiXSwibWFwcGluZ3MiOiI7Ozs7K0JBS2FBOzs7ZUFBQUE7OztvQkFMaUI7QUFLdkIsTUFBTUEsYUFBYSxDQUFDQyxLQUFjQztJQUN2QyxJQUFJQyxlQUFlLENBQUMsRUFBRUQsSUFBSSxDQUFDO0lBQzNCLElBQUlELGVBQWVHLE9BQU87UUFDeEJELGdCQUFnQixDQUFDLENBQUMsRUFBRUYsSUFBSUksT0FBTyxDQUFDLENBQUMsQ0FBQztRQUNsQyxJQUFJSixlQUFlSyxpQkFBYSxFQUFFO1lBQ2hDSixPQUFPLENBQUMsRUFBRSxFQUFFRCxJQUFJSSxPQUFPLENBQUMsQ0FBQztZQUN6QixJQUFJSixJQUFJTSxJQUFJLEVBQUVMLE9BQU8sQ0FBQyxDQUFDLEVBQUVELElBQUlNLElBQUksQ0FBQyxDQUFDLENBQUM7UUFDdEM7SUFDRjtJQUNBLE9BQU9KO0FBQ1QifQ==
package/mock.js ADDED
@@ -0,0 +1 @@
1
+ export const postgresAdapter = () => ({})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "0.1.0-beta.9",
3
+ "version": "0.1.0",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": "https://github.com/payloadcms/payload",
6
6
  "license": "MIT",
@@ -24,8 +24,8 @@
24
24
  "devDependencies": {
25
25
  "@types/pg": "8.10.2",
26
26
  "@types/to-snake-case": "1.0.0",
27
- "payload": "2.0.0-beta.9",
28
- "@payloadcms/eslint-config": "0.0.1"
27
+ "@payloadcms/eslint-config": "0.0.1",
28
+ "payload": "2.0.0-beta.31"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "better-sqlite3": "^8.5.0"
@@ -34,7 +34,8 @@
34
34
  "registry": "https://registry.npmjs.org/"
35
35
  },
36
36
  "files": [
37
- "dist"
37
+ "dist",
38
+ "mock.js"
38
39
  ],
39
40
  "scripts": {
40
41
  "build": "pnpm build:swc && pnpm build:types",
package/src/index.ts CHANGED
@@ -5,8 +5,6 @@ import { createDatabaseAdapter } from 'payload/database'
5
5
 
6
6
  import type { Args, PostgresAdapter, PostgresAdapterResult } from './types'
7
7
 
8
- export type { MigrateDownArgs, MigrateUpArgs } from './types'
9
-
10
8
  import { connect } from './connect'
11
9
  import { create } from './create'
12
10
  import { createGlobal } from './createGlobal'
@@ -17,6 +15,8 @@ import { deleteMany } from './deleteMany'
17
15
  import { deleteOne } from './deleteOne'
18
16
  import { deleteVersions } from './deleteVersions'
19
17
  import { destroy } from './destroy'
18
+ import { extendViteConfig } from './extendViteConfig'
19
+ import { extendWebpackConfig } from './extendWebpackConfig'
20
20
  import { find } from './find'
21
21
  import { findGlobal } from './findGlobal'
22
22
  import { findGlobalVersions } from './findGlobalVersions'
@@ -24,6 +24,10 @@ import { findOne } from './findOne'
24
24
  import { findVersions } from './findVersions'
25
25
  import { init } from './init'
26
26
  import { migrate } from './migrate'
27
+ import { migrateDown } from './migrateDown'
28
+ import { migrateFresh } from './migrateFresh'
29
+ import { migrateRefresh } from './migrateRefresh'
30
+ import { migrateReset } from './migrateReset'
27
31
  import { migrateStatus } from './migrateStatus'
28
32
  import { queryDrafts } from './queryDrafts'
29
33
  import { beginTransaction } from './transactions/beginTransaction'
@@ -33,19 +37,25 @@ import { updateOne } from './update'
33
37
  import { updateGlobal } from './updateGlobal'
34
38
  import { updateGlobalVersion } from './updateGlobalVersion'
35
39
  import { updateVersion } from './updateVersion'
36
- import { webpack } from './webpack'
40
+
41
+ export type { MigrateDownArgs, MigrateUpArgs } from './types'
37
42
 
38
43
  export function postgresAdapter(args: Args): PostgresAdapterResult {
39
44
  function adapter({ payload }: { payload: Payload }) {
40
45
  const migrationDir = args.migrationDir || path.resolve(process.cwd(), 'src/migrations')
46
+
47
+ extendWebpackConfig(payload.config)
48
+ extendViteConfig(payload.config)
49
+
41
50
  return createDatabaseAdapter<PostgresAdapter>({
42
- ...args,
43
51
  name: 'postgres',
44
52
 
45
53
  // Postgres-specific
46
54
  drizzle: undefined,
47
55
  enums: {},
48
56
  pool: undefined,
57
+ poolOptions: args.pool,
58
+ push: args.push,
49
59
  relations: {},
50
60
  schema: {},
51
61
  sessions: {},
@@ -72,6 +82,10 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
72
82
  findVersions,
73
83
  init,
74
84
  migrate,
85
+ migrateDown,
86
+ migrateFresh,
87
+ migrateRefresh,
88
+ migrateReset,
75
89
  migrateStatus,
76
90
  migrationDir,
77
91
  payload,
@@ -81,7 +95,6 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
81
95
  updateGlobalVersion,
82
96
  updateOne,
83
97
  updateVersion,
84
- webpack,
85
98
  })
86
99
  }
87
100
 
package/dist/mock.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "postgresAdapter", {
6
- enumerable: true,
7
- get: function() {
8
- return postgresAdapter;
9
- }
10
- });
11
- const postgresAdapter = ()=>({});
12
-
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tb2NrLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjb25zdCBwb3N0Z3Jlc0FkYXB0ZXIgPSAoKSA9PiAoe30pXG4iXSwibmFtZXMiOlsicG9zdGdyZXNBZGFwdGVyIl0sIm1hcHBpbmdzIjoiOzs7OytCQUFhQTs7O2VBQUFBOzs7QUFBTixNQUFNQSxrQkFBa0IsSUFBTyxDQUFBLENBQUMsQ0FBQSJ9
package/dist/webpack.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Webpack } from 'payload/database';
2
- export declare const webpack: Webpack;
3
- //# sourceMappingURL=webpack.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI/C,eAAO,MAAM,OAAO,EAAE,OAcrB,CAAA"}
package/dist/webpack.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "webpack", {
6
- enumerable: true,
7
- get: function() {
8
- return webpack;
9
- }
10
- });
11
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- const webpack = (config)=>{
18
- const aliasPath = _path.default.resolve(__dirname, 'mock.js');
19
- return {
20
- ...config,
21
- resolve: {
22
- ...config.resolve || {},
23
- alias: {
24
- ...config.resolve?.alias || {},
25
- '@payloadcms/db-postgres': aliasPath,
26
- [_path.default.resolve(__dirname, './index')]: aliasPath
27
- }
28
- }
29
- };
30
- };
31
-
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy93ZWJwYWNrLnRzIl0sInNvdXJjZXNDb250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