@payloadcms/db-postgres 0.1.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/dist/connect.js +82 -0
  2. package/dist/create.js +32 -0
  3. package/dist/createGlobal.js +32 -0
  4. package/dist/createGlobalVersion.js +48 -0
  5. package/dist/createMigration.js +85 -0
  6. package/dist/createVersion.js +54 -0
  7. package/dist/deleteMany.js +44 -0
  8. package/dist/deleteOne.js +47 -0
  9. package/dist/deleteVersions.js +46 -0
  10. package/dist/destroy.js +16 -0
  11. package/dist/find/buildFindManyArgs.js +61 -0
  12. package/dist/find/chainMethods.js +21 -0
  13. package/dist/find/findMany.js +197 -0
  14. package/dist/find/traverseFields.js +118 -0
  15. package/dist/find.js +35 -0
  16. package/dist/findGlobal.js +38 -0
  17. package/dist/findGlobalVersions.js +39 -0
  18. package/dist/findOne.js +49 -0
  19. package/dist/findVersions.js +39 -0
  20. package/dist/index.js +95 -0
  21. package/dist/init.js +74 -0
  22. package/dist/migrate.js +81 -0
  23. package/dist/migrateStatus.js +54 -0
  24. package/dist/mock.js +13 -0
  25. package/dist/queries/buildAndOrConditions.js +39 -0
  26. package/dist/queries/buildQuery.js +80 -0
  27. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +24 -0
  28. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +15 -0
  29. package/dist/queries/createJSONQuery/index.js +64 -0
  30. package/dist/queries/getTableColumnFromPath.js +333 -0
  31. package/dist/queries/operatorMap.js +34 -0
  32. package/dist/queries/parseParams.js +146 -0
  33. package/dist/queries/sanitizeQueryValue.js +79 -0
  34. package/dist/queryDrafts.js +56 -0
  35. package/dist/reference.js +76 -0
  36. package/dist/schema/build.js +245 -0
  37. package/dist/schema/createIndex.js +19 -0
  38. package/dist/schema/parentIDColumnMap.js +18 -0
  39. package/dist/schema/traverseFields.js +430 -0
  40. package/dist/schema/validateExistingBlockIsIdentical.js +34 -0
  41. package/dist/transactions/beginTransaction.js +51 -0
  42. package/dist/transactions/commitTransaction.js +24 -0
  43. package/dist/transactions/rollbackTransaction.js +20 -0
  44. package/dist/transform/read/hasManyNumber.js +20 -0
  45. package/dist/transform/read/index.js +42 -0
  46. package/dist/transform/read/relationship.js +74 -0
  47. package/dist/transform/read/traverseFields.js +325 -0
  48. package/dist/transform/write/array.js +55 -0
  49. package/dist/transform/write/blocks.js +56 -0
  50. package/dist/transform/write/index.js +46 -0
  51. package/dist/transform/write/numbers.js +21 -0
  52. package/dist/transform/write/relationships.js +33 -0
  53. package/dist/transform/write/selects.js +29 -0
  54. package/dist/transform/write/traverseFields.js +379 -0
  55. package/dist/transform/write/types.js +6 -0
  56. package/dist/types.js +6 -0
  57. package/dist/update.js +48 -0
  58. package/dist/updateGlobal.js +39 -0
  59. package/dist/updateGlobalVersion.js +50 -0
  60. package/dist/updateVersion.js +50 -0
  61. package/dist/upsertRow/deleteExistingArrayRows.js +20 -0
  62. package/dist/upsertRow/deleteExistingRowsByPath.js +43 -0
  63. package/dist/upsertRow/index.js +243 -0
  64. package/dist/upsertRow/insertArrays.js +64 -0
  65. package/dist/upsertRow/types.js +6 -0
  66. package/dist/utilities/appendPrefixToKeys.js +16 -0
  67. package/dist/utilities/createBlocksMap.js +39 -0
  68. package/dist/utilities/createMigrationTable.js +23 -0
  69. package/dist/utilities/createRelationshipMap.js +29 -0
  70. package/dist/utilities/hasLocalesTable.js +21 -0
  71. package/dist/utilities/isArrayOfRows.js +15 -0
  72. package/dist/utilities/migrationTableExists.js +19 -0
  73. package/dist/webpack.js +30 -0
  74. package/package.json +47 -0
package/dist/index.js ADDED
@@ -0,0 +1,95 @@
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 _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ const _database = require("payload/database");
13
+ const _connect = require("./connect");
14
+ const _create = require("./create");
15
+ const _createGlobal = require("./createGlobal");
16
+ const _createGlobalVersion = require("./createGlobalVersion");
17
+ const _createMigration = require("./createMigration");
18
+ const _createVersion = require("./createVersion");
19
+ const _deleteMany = require("./deleteMany");
20
+ const _deleteOne = require("./deleteOne");
21
+ const _deleteVersions = require("./deleteVersions");
22
+ const _destroy = require("./destroy");
23
+ const _find = require("./find");
24
+ const _findGlobal = require("./findGlobal");
25
+ const _findGlobalVersions = require("./findGlobalVersions");
26
+ const _findOne = require("./findOne");
27
+ const _findVersions = require("./findVersions");
28
+ const _init = require("./init");
29
+ const _migrate = require("./migrate");
30
+ const _migrateStatus = require("./migrateStatus");
31
+ const _queryDrafts = require("./queryDrafts");
32
+ const _beginTransaction = require("./transactions/beginTransaction");
33
+ const _commitTransaction = require("./transactions/commitTransaction");
34
+ const _rollbackTransaction = require("./transactions/rollbackTransaction");
35
+ const _update = require("./update");
36
+ const _updateGlobal = require("./updateGlobal");
37
+ const _updateGlobalVersion = require("./updateGlobalVersion");
38
+ const _updateVersion = require("./updateVersion");
39
+ const _webpack = require("./webpack");
40
+ function _interop_require_default(obj) {
41
+ return obj && obj.__esModule ? obj : {
42
+ default: obj
43
+ };
44
+ }
45
+ function postgresAdapter(args) {
46
+ function adapter({ payload }) {
47
+ const migrationDir = args.migrationDir || _path.default.resolve(__dirname, '../../../migrations');
48
+ return (0, _database.createDatabaseAdapter)({
49
+ ...args,
50
+ name: 'postgres',
51
+ // Postgres-specific
52
+ db: undefined,
53
+ enums: {},
54
+ pool: undefined,
55
+ relations: {},
56
+ schema: {},
57
+ sessions: {},
58
+ tables: {},
59
+ // DatabaseAdapter
60
+ beginTransaction: _beginTransaction.beginTransaction,
61
+ commitTransaction: _commitTransaction.commitTransaction,
62
+ connect: _connect.connect,
63
+ create: _create.create,
64
+ createGlobal: _createGlobal.createGlobal,
65
+ createGlobalVersion: _createGlobalVersion.createGlobalVersion,
66
+ createMigration: _createMigration.createMigration,
67
+ createVersion: _createVersion.createVersion,
68
+ defaultIDType: 'number',
69
+ deleteMany: _deleteMany.deleteMany,
70
+ deleteOne: _deleteOne.deleteOne,
71
+ deleteVersions: _deleteVersions.deleteVersions,
72
+ destroy: _destroy.destroy,
73
+ find: _find.find,
74
+ findGlobal: _findGlobal.findGlobal,
75
+ findGlobalVersions: _findGlobalVersions.findGlobalVersions,
76
+ findOne: _findOne.findOne,
77
+ findVersions: _findVersions.findVersions,
78
+ init: _init.init,
79
+ migrate: _migrate.migrate,
80
+ migrateStatus: _migrateStatus.migrateStatus,
81
+ migrationDir,
82
+ payload,
83
+ queryDrafts: _queryDrafts.queryDrafts,
84
+ rollbackTransaction: _rollbackTransaction.rollbackTransaction,
85
+ updateGlobal: _updateGlobal.updateGlobal,
86
+ updateGlobalVersion: _updateGlobalVersion.updateGlobalVersion,
87
+ updateOne: _update.updateOne,
88
+ updateVersion: _updateVersion.updateVersion,
89
+ webpack: _webpack.webpack
90
+ });
91
+ }
92
+ return adapter;
93
+ }
94
+
95
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuaW1wb3J0IHsgY3JlYXRlRGF0YWJhc2VBZGFwdGVyIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcblxuaW1wb3J0IHR5cGUgeyBBcmdzLCBQb3N0Z3Jlc0FkYXB0ZXIsIFBvc3RncmVzQWRhcHRlclJlc3VsdCB9IGZyb20gJy4vdHlwZXMnXG5cbmltcG9ydCB7IGNvbm5lY3QgfSBmcm9tICcuL2Nvbm5lY3QnXG5pbXBvcnQgeyBjcmVhdGUgfSBmcm9tICcuL2NyZWF0ZSdcbmltcG9ydCB7IGNyZWF0ZUdsb2JhbCB9IGZyb20gJy4vY3JlYXRlR2xvY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UFDbkJDLFdBQUFBLGlCQUFTO1lBQ1RDLGVBQUFBLDRCQUFhO1lBQ2JDLFNBQUFBLGdCQUFPO1FBQ1Q7SUFDRjtJQUVBLE9BQU8zQztBQUNUIn0=
package/dist/init.js ADDED
@@ -0,0 +1,74 @@
1
+ /* eslint-disable no-param-reassign */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "init", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return init;
9
+ }
10
+ });
11
+ const _pgcore = require("drizzle-orm/pg-core");
12
+ const _versions = require("payload/versions");
13
+ const _tosnakecase = /*#__PURE__*/ _interop_require_default(require("to-snake-case"));
14
+ const _build = require("./schema/build");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ const init = async function init() {
21
+ if (this.payload.config.localization) {
22
+ this.enums.enum__locales = (0, _pgcore.pgEnum)('_locales', // TODO: types out of sync with core, monorepo please
23
+ // this.payload.config.localization.localeCodes,
24
+ this.payload.config.localization.locales.map(({ code })=>code));
25
+ }
26
+ this.payload.config.collections.forEach((collection)=>{
27
+ const tableName = (0, _tosnakecase.default)(collection.slug);
28
+ (0, _build.buildTable)({
29
+ adapter: this,
30
+ buildRelationships: true,
31
+ disableUnique: false,
32
+ fields: collection.fields,
33
+ tableName,
34
+ timestamps: collection.timestamps
35
+ });
36
+ if (collection.versions) {
37
+ const versionsTableName = `_${tableName}_v`;
38
+ const versionFields = (0, _versions.buildVersionCollectionFields)(collection);
39
+ (0, _build.buildTable)({
40
+ adapter: this,
41
+ buildRelationships: true,
42
+ disableUnique: true,
43
+ fields: versionFields,
44
+ tableName: versionsTableName,
45
+ timestamps: true
46
+ });
47
+ }
48
+ });
49
+ this.payload.config.globals.forEach((global)=>{
50
+ const tableName = (0, _tosnakecase.default)(global.slug);
51
+ (0, _build.buildTable)({
52
+ adapter: this,
53
+ buildRelationships: true,
54
+ disableUnique: false,
55
+ fields: global.fields,
56
+ tableName,
57
+ timestamps: false
58
+ });
59
+ if (global.versions) {
60
+ const versionsTableName = `_${tableName}_v`;
61
+ const versionFields = (0, _versions.buildVersionGlobalFields)(global);
62
+ (0, _build.buildTable)({
63
+ adapter: this,
64
+ buildRelationships: true,
65
+ disableUnique: true,
66
+ fields: versionFields,
67
+ tableName: versionsTableName,
68
+ timestamps: true
69
+ });
70
+ }
71
+ });
72
+ };
73
+
74
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbml0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXBhcmFtLXJlYXNzaWduICovXG5pbXBvcnQgdHlwZSB7IEluaXQgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBTYW5pdGl6ZWRDb2xsZWN0aW9uQ29uZmlnIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgcGdFbnVtIH0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG9ydCB7IGJ1aWxkVmVyc2lvbkNvbGxlY3Rpb25GaWVsZHMsIGJ1aWxkVmVyc2lvbkdsb2JhbEZpZWxkcyB9IGZyb20gJ3BheWxvYWQvdmVyc2lvbnMnXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuL3R5cGVzJ1xuXG5pbXBvcnQgeyBidWlsZFRhYmxlIH0gZnJvbSAnLi9zY2hlbWEvYnVpbGQnXG5cbmV4cG9ydCBjb25zdCBpbml0OiBJbml0ID0gYXN5bmMgZnVuY3Rpb24gaW5pdCh0aGlzOiBQb3N0Z3Jlc0FkYXB0ZXIpIHtcbiAgaWYgKHRoaXMucGF5bG9hZC5jb25maWc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QUFPTCxRQUFRLEVBQUU7WUFDbkIsTUFBTUMsb0JBQW9CLENBQUMsQ0FBQyxFQUFFVixVQUFVLEVBQUUsQ0FBQztZQUMzQyxNQUFNVyxnQkFBZ0JJLElBQUFBLGtDQUF3QixFQUFDRDtZQUUvQ1gsSUFBQUEsaUJBQVUsRUFBQztnQkFDVEMsU0FBUyxJQUFJO2dCQUNiQyxvQkFBb0I7Z0JBQ3BCQyxlQUFlO2dCQUNmQyxRQUFRSTtnQkFDUlgsV0FBV1U7Z0JBQ1hGLFlBQVk7WUFDZDtRQUNGO0lBQ0Y7QUFDRiJ9
@@ -0,0 +1,81 @@
1
+ /* eslint-disable no-restricted-syntax, no-await-in-loop */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "migrate", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return migrate;
9
+ }
10
+ });
11
+ const _utils = require("drizzle-kit/utils");
12
+ const _database = require("payload/database");
13
+ const _pg = require("pg");
14
+ const _createMigrationTable = require("./utilities/createMigrationTable");
15
+ const _migrationTableExists = require("./utilities/migrationTableExists");
16
+ async function migrate() {
17
+ const { payload } = this;
18
+ const migrationFiles = await (0, _database.readMigrationFiles)({
19
+ payload
20
+ });
21
+ let latestBatch = 0;
22
+ let existingMigrations = [];
23
+ const hasMigrationTable = await (0, _migrationTableExists.migrationTableExists)(this.db);
24
+ if (hasMigrationTable) {
25
+ ({ docs: existingMigrations } = await payload.find({
26
+ collection: 'payload-migrations',
27
+ limit: 0,
28
+ sort: '-name'
29
+ }));
30
+ if (typeof existingMigrations[0]?.batch !== 'undefined') {
31
+ latestBatch = Number(existingMigrations[0]?.batch);
32
+ }
33
+ } else {
34
+ await (0, _createMigrationTable.createMigrationTable)(this.db);
35
+ }
36
+ const newBatch = latestBatch + 1;
37
+ // Execute 'up' function for each migration sequentially
38
+ for (const migration of migrationFiles){
39
+ const existingMigration = existingMigrations.find((existing)=>existing.name === migration.name);
40
+ // Run migration if not found in database
41
+ if (existingMigration) {
42
+ continue; // eslint-disable-line no-continue
43
+ }
44
+ const start = Date.now();
45
+ payload.logger.info({
46
+ msg: `Migrating: ${migration.name}`
47
+ });
48
+ const pgAdapter = payload.db// TODO: Fix this typing
49
+ ;
50
+ const drizzleJSON = (0, _utils.generateDrizzleJson)(pgAdapter.schema);
51
+ try {
52
+ await migration.up({
53
+ payload
54
+ });
55
+ payload.logger.info({
56
+ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
57
+ });
58
+ await payload.create({
59
+ collection: 'payload-migrations',
60
+ data: {
61
+ name: migration.name,
62
+ batch: newBatch,
63
+ schema: drizzleJSON
64
+ }
65
+ });
66
+ } catch (err) {
67
+ let msg = `Error running migration ${migration.name}`;
68
+ if (err instanceof _pg.DatabaseError) {
69
+ msg += `: ${err.message}`;
70
+ if (err.hint) msg += `. ${err.hint}`;
71
+ }
72
+ payload.logger.error({
73
+ err,
74
+ msg
75
+ });
76
+ throw err;
77
+ }
78
+ }
79
+ }
80
+
81
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXJlc3RyaWN0ZWQtc3ludGF4LCBuby1hd2FpdC1pbi1sb29wICovXG5pbXBvcnQgeyBnZW5lcmF0ZURyaXp6bGVKc29uIH0gZnJvbSAnZHJpenpsZS1raXQvdXRpbHMnXG5pbXBvcnQgeyByZWFkTWlncmF0aW9uRmlsZXMgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHsgRGF0YWJhc2VFcnJvciB9IGZyb20gJ3BnJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMnXG5cbmltcG9ydCB7IGNyZWF0ZU1pZ3JhdGlvblRhYmxlIH0gZnJvbSAnL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QUFJLENBQUMsQ0FBQztZQUN0QztZQUVBckMsUUFBUXdCLE1BQU0sQ0FBQ2MsS0FBSyxDQUFDO2dCQUFFSjtnQkFBS1I7WUFBSTtZQUNoQyxNQUFNUTtRQUNSO0lBQ0Y7QUFDRiJ9
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "migrateStatus", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return migrateStatus;
9
+ }
10
+ });
11
+ const _consoletableprinter = require("console-table-printer");
12
+ const _database = require("payload/database");
13
+ const _migrationTableExists = require("./utilities/migrationTableExists");
14
+ async function migrateStatus() {
15
+ const { payload } = this;
16
+ const migrationFiles = await (0, _database.readMigrationFiles)({
17
+ payload
18
+ });
19
+ payload.logger.debug({
20
+ msg: `Found ${migrationFiles.length} migration files.`
21
+ });
22
+ let existingMigrations = [];
23
+ const hasMigrationTable = await (0, _migrationTableExists.migrationTableExists)(this.db);
24
+ if (hasMigrationTable) {
25
+ ({ existingMigrations } = await (0, _database.getMigrations)({
26
+ payload
27
+ }));
28
+ }
29
+ if (!migrationFiles.length) {
30
+ payload.logger.info({
31
+ msg: 'No migrations found.'
32
+ });
33
+ return;
34
+ }
35
+ // Compare migration files to existing migrations
36
+ const statuses = migrationFiles.map((migration)=>{
37
+ const existingMigration = existingMigrations.find((m)=>m.name === migration.name);
38
+ return {
39
+ Name: migration.name,
40
+ // eslint-disable-next-line perfectionist/sort-objects
41
+ Batch: existingMigration?.batch,
42
+ Ran: existingMigration ? 'Yes' : 'No'
43
+ };
44
+ });
45
+ const p = new _consoletableprinter.Table();
46
+ statuses.forEach((s)=>{
47
+ p.addRow(s, {
48
+ color: s.Ran === 'Yes' ? 'green' : 'red'
49
+ });
50
+ });
51
+ p.printTable();
52
+ }
53
+
54
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdy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BRUMsSUFBSSxLQUFLSixVQUFVSSxJQUFJO1FBQ2xGLE9BQU87WUFDTEMsTUFBTUwsVUFBVUksSUFBSTtZQUNwQixzREFBc0Q7WUFDdERFLE9BQU9MLG1CQUFtQk07WUFDMUJDLEtBQUtQLG9CQUFvQixRQUFRO1FBQ25DO0lBQ0Y7SUFFQSxNQUFNUSxJQUFJLElBQUlDLDBCQUFLO0lBRW5CWixTQUFTYSxPQUFPLENBQUMsQ0FBQ0M7UUFDaEJILEVBQUVJLE1BQU0sQ0FBQ0QsR0FBRztZQUNWRSxPQUFPRixFQUFFSixHQUFHLEtBQUssUUFBUSxVQUFVO1FBQ3JDO0lBQ0Y7SUFDQUMsRUFBRU0sVUFBVTtBQUNkIn0=
package/dist/mock.js ADDED
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "buildAndOrConditions", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return buildAndOrConditions;
9
+ }
10
+ });
11
+ const _parseParams = require("./parseParams");
12
+ async function buildAndOrConditions({ adapter, fields, joinAliases, joins, locale, selectFields, tableName, where }) {
13
+ const completedConditions = [];
14
+ // Loop over all AND / OR operations and add them to the AND / OR query param
15
+ // Operations should come through as an array
16
+ // eslint-disable-next-line no-restricted-syntax
17
+ for (const condition of where){
18
+ // If the operation is properly formatted as an object
19
+ if (typeof condition === 'object') {
20
+ // eslint-disable-next-line no-await-in-loop
21
+ const result = await (0, _parseParams.parseParams)({
22
+ adapter,
23
+ fields,
24
+ joinAliases,
25
+ joins,
26
+ locale,
27
+ selectFields,
28
+ tableName,
29
+ where: condition
30
+ });
31
+ if (result && Object.keys(result).length > 0) {
32
+ completedConditions.push(result);
33
+ }
34
+ }
35
+ }
36
+ return completedConditions;
37
+ }
38
+
39
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL2J1aWxkQW5kT3JDb25kaXRpb25zLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgU1FMIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgdHlwZSB7IEZpZWxkLCBXaGVyZSB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0eXBlIHsgR2VuZXJpY0NvbHVtbiwgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMnXG5pbXBvcnQgdHlwZSB7IEJ1aWxkUXVlcnlKb2luQWxpYXNlcywgQnVpbGRRdWVyeUpvaW5zIH0gZnJvbSAnLi9idWlsZFF1ZXJ5J1xuXG5pbXBvcnQgeyBwYXJzZVBhcmFtcyB9IGZyb20gJy4vcGFyc2VQYXJhbXMnXG5cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBidWlsZEFuZE9yQ29uZGl0aW9ucyh7XG4gIGFkYXB0ZXIsXG4gIGZpZWxkcyxcbiAgam9pbkFsaWFzZXMsXG4gIGpvaW5zLFxuICBsb2NhbGUs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VDLE1BQU1DLFNBQVMsTUFBTUMsSUFBQUEsd0JBQVcsRUFBQztnQkFDL0JYO2dCQUNBQztnQkFDQUM7Z0JBQ0FDO2dCQUNBQztnQkFDQUM7Z0JBQ0FDO2dCQUNBQyxPQUFPRTtZQUNUO1lBQ0EsSUFBSUMsVUFBVUUsT0FBT0MsSUFBSSxDQUFDSCxRQUFRSSxNQUFNLEdBQUcsR0FBRztnQkFDNUNOLG9CQUFvQk8sSUFBSSxDQUFDTDtZQUMzQjtRQUNGO0lBQ0Y7SUFDQSxPQUFPRjtBQUNUIn0=
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _drizzleorm = require("drizzle-orm");
12
+ const _getTableColumnFromPath = require("./getTableColumnFromPath");
13
+ const _parseParams = require("./parseParams");
14
+ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, tableName, where: incomingWhere }) {
15
+ const selectFields = {
16
+ id: adapter.tables[tableName].id
17
+ };
18
+ const joins = {};
19
+ const joinAliases = [];
20
+ const orderBy = {
21
+ column: null,
22
+ order: null
23
+ };
24
+ if (sort) {
25
+ let sortPath;
26
+ if (sort[0] === '-') {
27
+ sortPath = sort.substring(1);
28
+ orderBy.order = _drizzleorm.desc;
29
+ } else {
30
+ sortPath = sort;
31
+ orderBy.order = _drizzleorm.asc;
32
+ }
33
+ const { columnName: sortTableColumnName, table: sortTable } = (0, _getTableColumnFromPath.getTableColumnFromPath)({
34
+ adapter,
35
+ collectionPath: sortPath,
36
+ fields,
37
+ joinAliases,
38
+ joins,
39
+ locale,
40
+ pathSegments: sortPath.replace(/__/g, '.').split('.'),
41
+ selectFields,
42
+ tableName
43
+ });
44
+ orderBy.column = sortTable[sortTableColumnName];
45
+ } else {
46
+ orderBy.order = _drizzleorm.desc;
47
+ const createdAt = adapter.tables[tableName]?.createdAt;
48
+ if (createdAt) {
49
+ orderBy.column = createdAt;
50
+ } else {
51
+ orderBy.column = adapter.tables[tableName].id;
52
+ }
53
+ }
54
+ if (orderBy.column) {
55
+ selectFields.sort = orderBy.column;
56
+ }
57
+ let where;
58
+ if (incomingWhere && Object.keys(incomingWhere).length > 0) {
59
+ where = await (0, _parseParams.parseParams)({
60
+ adapter,
61
+ fields,
62
+ joinAliases,
63
+ joins,
64
+ locale,
65
+ selectFields,
66
+ tableName,
67
+ where: incomingWhere
68
+ });
69
+ }
70
+ return {
71
+ joinAliases,
72
+ joins,
73
+ orderBy,
74
+ selectFields,
75
+ where
76
+ };
77
+ };
78
+ const _default = buildQuery;
79
+
80
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL2J1aWxkUXVlcnkudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBTUUwgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB0eXBlIHsgRmllbGQsIFdoZXJlIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgYXNjLCBkZXNjIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHsgR2VuZXJpY0NvbHVtbiwgR2VuZXJpY1RhYmxlLCBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZ2V0VGFibGVDb2x1bW5Gcm9tUGF0aCB9IGZyb20gJy4vZ2V0VGFibGVDb2x1bW5Gcm9tUGF0aCdcbmltcG9ydCB7IHBhcnNlUGFyYW1zIH0gZnJvbSAnLi9wYXJzZVBhcmFtcydcblxuZXhwb3J0IHR5cGUgQnVpbGRRdWVyeUpvaW5zID0gUmVjb3JkPHN0cmluZywgU1FMPlxuXG5leHBvcnQgdHlwZSBCdWlsZFF1ZXJ5Sm9pbkFsaWFz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UFLLENBQUM7WUFDakRwQjtZQUNBSDtRQUNGO1FBRUFRLFFBQVFDLE1BQU0sR0FBR1MsU0FBUyxDQUFDRixvQkFBb0I7SUFDakQsT0FBTztRQUNMUixRQUFRRSxLQUFLLEdBQUdHLGdCQUFJO1FBQ3BCLE1BQU1XLFlBQVk1QixRQUFRUyxNQUFNLENBQUNMLFVBQVUsRUFBRXdCO1FBRTdDLElBQUlBLFdBQVc7WUFDYmhCLFFBQVFDLE1BQU0sR0FBR2U7UUFDbkIsT0FBTztZQUNMaEIsUUFBUUMsTUFBTSxHQUFHYixRQUFRUyxNQUFNLENBQUNMLFVBQVUsQ0FBQ0ksRUFBRTtRQUMvQztJQUNGO0lBRUEsSUFBSUksUUFBUUMsTUFBTSxFQUFFO1FBQ2xCTixhQUFhSixJQUFJLEdBQUdTLFFBQVFDLE1BQU07SUFDcEM7SUFFQSxJQUFJUjtJQUVKLElBQUlDLGlCQUFpQnVCLE9BQU9DLElBQUksQ0FBQ3hCLGVBQWV5QixNQUFNLEdBQUcsR0FBRztRQUMxRDFCLFFBQVEsTUFBTTJCLElBQUFBLHdCQUFXLEVBQUM7WUFDeEJoQztZQUNBQztZQUNBVTtZQUNBRDtZQUNBUjtZQUNBSztZQUNBSDtZQUNBQyxPQUFPQztRQUNUO0lBQ0Y7SUFFQSxPQUFPO1FBQ0xLO1FBQ0FEO1FBQ0FFO1FBQ0FMO1FBQ0FGO0lBQ0Y7QUFDRjtNQUVBLFdBQWVOIn0=
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "convertPathToJSONTraversal", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return convertPathToJSONTraversal;
9
+ }
10
+ });
11
+ const _formatJSONPathSegment = require("./formatJSONPathSegment");
12
+ const convertPathToJSONTraversal = (incomingSegments)=>{
13
+ const segments = [
14
+ ...incomingSegments
15
+ ];
16
+ segments.shift();
17
+ return segments.reduce((res, segment, i)=>{
18
+ const formattedSegment = (0, _formatJSONPathSegment.formatJSONPathSegment)(segment);
19
+ if (i + 1 === segments.length) return `${res}->>${formattedSegment}`;
20
+ return `${res}->${formattedSegment}`;
21
+ }, '');
22
+ };
23
+
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9jb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBmb3JtYXRKU09OUGF0aFNlZ21lbnQgfSBmcm9tICcuL2Zvcm1hdEpTT05QYXRoU2VnbWVudCdcblxuZXhwb3J0IGNvbnN0IGNvbnZlcnRQYXRoVG9KU09OVHJhdmVyc2FsID0gKGluY29taW5nU2VnbWVudHM6IHN0cmluZ1tdKSA9PiB7XG4gIGNvbnN0IHNlZ21lbnRzID0gWy4uLmluY29taW5nU2VnbWVudHNdXG4gIHNlZ21lbnRzLnNoaWZ0KClcblxuICByZXR1cm4gc2VnbWVudHMucmVkdWNlKChyZXMsIHNlZ21lbnQsIGkpID0+IHtcbiAgICBjb25zdCBmb3JtYXR0ZWRTZWdtZW50ID0gZm9ybWF0SlNPTlBhdGhTZWdtZW50KHNlZ21lbnQpXG5cbiAgICBpZiAoaSArIDEgPT09IHNlZ21lbnRzLmxlbmd0aCkgcmV0dXJuIGAke3Jlc30tPj4ke2Zvcm1hdHRlZFNlZ21lbnR9YFxuICAgIHJldHVybiBgJHtyZXN9LT4ke2Zvcm1hdHRlZFNlZ21lbnR9YFxuICB9LCAnJylcbn1cbiJdLCJuYW1lcyI6WyJjb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbCIsImluY29taW5nU2VnbWVudHMiLCJzZWdtZW50cyIsInNoaWZ0IiwicmVkdWNlIiwicmVzIiwic2VnbWVudCIsImkiLCJmb3JtYXR0ZWRTZWdtZW50IiwiZm9ybWF0SlNPTlBhdGhTZWdtZW50IiwibGVuZ3RoIl0sIm1hcHBpbmdzIjoiOzs7OytCQUVhQTs7O2VBQUFBOzs7dUNBRnlCO0FBRS9CLE1BQU1BLDZCQUE2QixDQUFDQztJQUN6QyxNQUFNQyxXQUFXO1dBQUlEO0tBQWlCO0lBQ3RDQyxTQUFTQyxLQUFLO0lBRWQsT0FBT0QsU0FBU0UsTUFBTSxDQUFDLENBQUNDLEtBQUtDLFNBQVNDO1FBQ3BDLE1BQU1DLG1CQUFtQkMsSUFBQUEsNENBQXFCLEVBQUNIO1FBRS9DLElBQUlDLElBQUksTUFBTUwsU0FBU1EsTUFBTSxFQUFFLE9BQU8sQ0FBQyxFQUFFTCxJQUFJLEdBQUcsRUFBRUcsaUJBQWlCLENBQUM7UUFDcEUsT0FBTyxDQUFDLEVBQUVILElBQUksRUFBRSxFQUFFRyxpQkFBaUIsQ0FBQztJQUN0QyxHQUFHO0FBQ0wifQ==
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "formatJSONPathSegment", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return formatJSONPathSegment;
9
+ }
10
+ });
11
+ const formatJSONPathSegment = (segment)=>{
12
+ return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment;
13
+ };
14
+
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9mb3JtYXRKU09OUGF0aFNlZ21lbnQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IGZvcm1hdEpTT05QYXRoU2VnbWVudCA9IChzZWdtZW50OiBzdHJpbmcpID0+IHtcbiAgcmV0dXJuIE51bWJlci5pc05hTihwYXJzZUludChzZWdtZW50KSkgPyBgJyR7c2VnbWVudH0nYCA6IHNlZ21lbnRcbn1cbiJdLCJuYW1lcyI6WyJmb3JtYXRKU09OUGF0aFNlZ21lbnQiLCJzZWdtZW50IiwiTnVtYmVyIiwiaXNOYU4iLCJwYXJzZUludCJdLCJtYXBwaW5ncyI6Ijs7OzsrQkFBYUE7OztlQUFBQTs7O0FBQU4sTUFBTUEsd0JBQXdCLENBQUNDO0lBQ3BDLE9BQU9DLE9BQU9DLEtBQUssQ0FBQ0MsU0FBU0gsWUFBWSxDQUFDLENBQUMsRUFBRUEsUUFBUSxDQUFDLENBQUMsR0FBR0E7QUFDNUQifQ==
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createJSONQuery", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createJSONQuery;
9
+ }
10
+ });
11
+ const _convertPathToJSONTraversal = require("./convertPathToJSONTraversal");
12
+ const _formatJSONPathSegment = require("./formatJSONPathSegment");
13
+ const operatorMap = {
14
+ contains: '~*',
15
+ equals: '=',
16
+ like: '~*'
17
+ };
18
+ const fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value })=>{
19
+ const newPathSegments = pathSegments.slice(isRoot ? 1 : 2);
20
+ const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`;
21
+ newPathSegments.unshift(alias);
22
+ const arrayElements = isRoot ? pathSegments[0] : `${pathSegments[0]} -> ${(0, _formatJSONPathSegment.formatJSONPathSegment)(pathSegments[1])}`;
23
+ return `EXISTS (
24
+ SELECT 1
25
+ FROM jsonb_array_elements(${arrayElements}) AS ${alias}
26
+ WHERE ${createJSONQuery({
27
+ operator,
28
+ pathSegments: newPathSegments,
29
+ treatAsArray,
30
+ value
31
+ })}
32
+ )`;
33
+ };
34
+ const createConstraint = ({ operator, pathSegments, value })=>{
35
+ const jsonQuery = (0, _convertPathToJSONTraversal.convertPathToJSONTraversal)(pathSegments);
36
+ return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`;
37
+ };
38
+ const createJSONQuery = ({ operator, pathSegments, treatAsArray, treatRootAsArray, value })=>{
39
+ if (treatRootAsArray) {
40
+ return fromArray({
41
+ isRoot: true,
42
+ operator,
43
+ pathSegments,
44
+ treatAsArray,
45
+ value
46
+ });
47
+ }
48
+ if (treatAsArray.includes(pathSegments[1])) {
49
+ return fromArray({
50
+ operator,
51
+ pathSegments,
52
+ treatAsArray,
53
+ value
54
+ });
55
+ }
56
+ return createConstraint({
57
+ operator,
58
+ pathSegments,
59
+ treatAsArray,
60
+ value
61
+ });
62
+ };
63
+
64
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbCB9IGZyb20gJy4vY29udmVydFBhdGhUb0pTT05UcmF2ZXJzYWwnXG5pbXBvcnQgeyBmb3JtYXRKU09OUGF0aFNlZ21lbnQgfSBmcm9tICcuL2Zvcm1hdEpTT05QYXRoU2VnbWVudCdcblxuY29uc3Qgb3BlcmF0b3JNYXAgPSB7XG4gIGNvbnRhaW5zOiAnfionLFxuICBlcXVhbHM6ICc9JyxcbiAgbGlrZTogJ34qJyxcbn1cblxudHlwZSBGcm9tQXJyYXlBcmdzID0ge1xuICBpc1Jvb3Q/OiB0cnVlXG4gIG9wZXJhdG9yOiBzdHJpbmdcbiAgcGF0aFNlZ21lbnRzOiBzdHJpbmdbXVxuICB0cmVhdEFzQXJyYXk/OiBzdHJpbmdbXVxuICB2YWx1ZTogdW5rbm93blxufVxuXG5jb25zdCBmcm9tQXJyYXkgPSAoeyBpc1Jvb3QsIG9wZXJhdG9yLCBwYXRoU2VnbWVudHMsIHRyZWF0QXNBcnJheSwgdmFsdWUgf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