@payloadcms/db-postgres 3.0.0-alpha.40 → 3.0.0-alpha.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +4 -48
  3. package/dist/connect.js.map +1 -0
  4. package/dist/create.js +1 -1
  5. package/dist/create.js.map +1 -0
  6. package/dist/createGlobal.js +1 -1
  7. package/dist/createGlobal.js.map +1 -0
  8. package/dist/createGlobalVersion.js +1 -1
  9. package/dist/createGlobalVersion.js.map +1 -0
  10. package/dist/createMigration.js +1 -1
  11. package/dist/createMigration.js.map +1 -0
  12. package/dist/createVersion.js +1 -1
  13. package/dist/createVersion.js.map +1 -0
  14. package/dist/deleteMany.js +1 -1
  15. package/dist/deleteMany.js.map +1 -0
  16. package/dist/deleteOne.js +1 -1
  17. package/dist/deleteOne.js.map +1 -0
  18. package/dist/deleteVersions.js +1 -1
  19. package/dist/deleteVersions.js.map +1 -0
  20. package/dist/destroy.d.ts.map +1 -1
  21. package/dist/destroy.js +8 -3
  22. package/dist/destroy.js.map +1 -0
  23. package/dist/find/buildFindManyArgs.js +1 -1
  24. package/dist/find/buildFindManyArgs.js.map +1 -0
  25. package/dist/find/chainMethods.js +1 -1
  26. package/dist/find/chainMethods.js.map +1 -0
  27. package/dist/find/findMany.js +1 -1
  28. package/dist/find/findMany.js.map +1 -0
  29. package/dist/find/traverseFields.js +1 -1
  30. package/dist/find/traverseFields.js.map +1 -0
  31. package/dist/find.js +1 -1
  32. package/dist/find.js.map +1 -0
  33. package/dist/findGlobal.js +1 -1
  34. package/dist/findGlobal.js.map +1 -0
  35. package/dist/findGlobalVersions.js +1 -1
  36. package/dist/findGlobalVersions.js.map +1 -0
  37. package/dist/findOne.js +1 -1
  38. package/dist/findOne.js.map +1 -0
  39. package/dist/findVersions.js +1 -1
  40. package/dist/findVersions.js.map +1 -0
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -0
  43. package/dist/init.js +1 -1
  44. package/dist/init.js.map +1 -0
  45. package/dist/migrate.js +1 -1
  46. package/dist/migrate.js.map +1 -0
  47. package/dist/migrateDown.js +1 -1
  48. package/dist/migrateDown.js.map +1 -0
  49. package/dist/migrateFresh.js +1 -1
  50. package/dist/migrateFresh.js.map +1 -0
  51. package/dist/migrateRefresh.js +1 -1
  52. package/dist/migrateRefresh.js.map +1 -0
  53. package/dist/migrateReset.js +1 -1
  54. package/dist/migrateReset.js.map +1 -0
  55. package/dist/migrateStatus.js +1 -1
  56. package/dist/migrateStatus.js.map +1 -0
  57. package/dist/queries/buildAndOrConditions.js +1 -1
  58. package/dist/queries/buildAndOrConditions.js.map +1 -0
  59. package/dist/queries/buildQuery.js +1 -1
  60. package/dist/queries/buildQuery.js.map +1 -0
  61. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +1 -1
  62. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  63. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +1 -1
  64. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  65. package/dist/queries/createJSONQuery/index.js +1 -1
  66. package/dist/queries/createJSONQuery/index.js.map +1 -0
  67. package/dist/queries/getTableColumnFromPath.js +1 -1
  68. package/dist/queries/getTableColumnFromPath.js.map +1 -0
  69. package/dist/queries/operatorMap.js +1 -1
  70. package/dist/queries/operatorMap.js.map +1 -0
  71. package/dist/queries/parseParams.js +1 -1
  72. package/dist/queries/parseParams.js.map +1 -0
  73. package/dist/queries/sanitizeQueryValue.js +1 -1
  74. package/dist/queries/sanitizeQueryValue.js.map +1 -0
  75. package/dist/queryDrafts.js +1 -1
  76. package/dist/queryDrafts.js.map +1 -0
  77. package/dist/schema/build.js +1 -1
  78. package/dist/schema/build.js.map +1 -0
  79. package/dist/schema/createIndex.js +1 -1
  80. package/dist/schema/createIndex.js.map +1 -0
  81. package/dist/schema/idToUUID.js +1 -1
  82. package/dist/schema/idToUUID.js.map +1 -0
  83. package/dist/schema/parentIDColumnMap.js +1 -1
  84. package/dist/schema/parentIDColumnMap.js.map +1 -0
  85. package/dist/schema/setColumnID.js +1 -1
  86. package/dist/schema/setColumnID.js.map +1 -0
  87. package/dist/schema/traverseFields.js +1 -1
  88. package/dist/schema/traverseFields.js.map +1 -0
  89. package/dist/schema/validateExistingBlockIsIdentical.js +1 -1
  90. package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -0
  91. package/dist/transactions/beginTransaction.js +1 -1
  92. package/dist/transactions/beginTransaction.js.map +1 -0
  93. package/dist/transactions/commitTransaction.js +1 -1
  94. package/dist/transactions/commitTransaction.js.map +1 -0
  95. package/dist/transactions/rollbackTransaction.js +1 -1
  96. package/dist/transactions/rollbackTransaction.js.map +1 -0
  97. package/dist/transform/read/hasManyNumber.js +1 -1
  98. package/dist/transform/read/hasManyNumber.js.map +1 -0
  99. package/dist/transform/read/hasManyText.js +1 -1
  100. package/dist/transform/read/hasManyText.js.map +1 -0
  101. package/dist/transform/read/index.js +1 -1
  102. package/dist/transform/read/index.js.map +1 -0
  103. package/dist/transform/read/relationship.js +1 -1
  104. package/dist/transform/read/relationship.js.map +1 -0
  105. package/dist/transform/read/traverseFields.js +1 -1
  106. package/dist/transform/read/traverseFields.js.map +1 -0
  107. package/dist/transform/write/array.js +1 -1
  108. package/dist/transform/write/array.js.map +1 -0
  109. package/dist/transform/write/blocks.js +1 -1
  110. package/dist/transform/write/blocks.js.map +1 -0
  111. package/dist/transform/write/index.js +1 -1
  112. package/dist/transform/write/index.js.map +1 -0
  113. package/dist/transform/write/numbers.js +1 -1
  114. package/dist/transform/write/numbers.js.map +1 -0
  115. package/dist/transform/write/relationships.js +1 -1
  116. package/dist/transform/write/relationships.js.map +1 -0
  117. package/dist/transform/write/selects.js +1 -1
  118. package/dist/transform/write/selects.js.map +1 -0
  119. package/dist/transform/write/texts.js +1 -1
  120. package/dist/transform/write/texts.js.map +1 -0
  121. package/dist/transform/write/traverseFields.js +1 -1
  122. package/dist/transform/write/traverseFields.js.map +1 -0
  123. package/dist/transform/write/types.js +1 -1
  124. package/dist/transform/write/types.js.map +1 -0
  125. package/dist/types.js +1 -1
  126. package/dist/types.js.map +1 -0
  127. package/dist/update.js +1 -1
  128. package/dist/update.js.map +1 -0
  129. package/dist/updateGlobal.js +1 -1
  130. package/dist/updateGlobal.js.map +1 -0
  131. package/dist/updateGlobalVersion.js +1 -1
  132. package/dist/updateGlobalVersion.js.map +1 -0
  133. package/dist/updateVersion.js +1 -1
  134. package/dist/updateVersion.js.map +1 -0
  135. package/dist/upsertRow/deleteExistingArrayRows.js +1 -1
  136. package/dist/upsertRow/deleteExistingArrayRows.js.map +1 -0
  137. package/dist/upsertRow/deleteExistingRowsByPath.js +1 -1
  138. package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -0
  139. package/dist/upsertRow/index.js +1 -1
  140. package/dist/upsertRow/index.js.map +1 -0
  141. package/dist/upsertRow/insertArrays.js +1 -1
  142. package/dist/upsertRow/insertArrays.js.map +1 -0
  143. package/dist/upsertRow/types.js +1 -1
  144. package/dist/upsertRow/types.js.map +1 -0
  145. package/dist/utilities/appendPrefixToKeys.js +1 -1
  146. package/dist/utilities/appendPrefixToKeys.js.map +1 -0
  147. package/dist/utilities/createBlocksMap.js +1 -1
  148. package/dist/utilities/createBlocksMap.js.map +1 -0
  149. package/dist/utilities/createMigrationTable.js +1 -1
  150. package/dist/utilities/createMigrationTable.js.map +1 -0
  151. package/dist/utilities/createRelationshipMap.js +1 -1
  152. package/dist/utilities/createRelationshipMap.js.map +1 -0
  153. package/dist/utilities/hasLocalesTable.js +1 -1
  154. package/dist/utilities/hasLocalesTable.js.map +1 -0
  155. package/dist/utilities/isArrayOfRows.js +1 -1
  156. package/dist/utilities/isArrayOfRows.js.map +1 -0
  157. package/dist/utilities/migrationTableExists.js +1 -1
  158. package/dist/utilities/migrationTableExists.js.map +1 -0
  159. package/dist/utilities/parseError.js +1 -1
  160. package/dist/utilities/parseError.js.map +1 -0
  161. package/dist/utilities/pushDevSchema.d.ts +9 -0
  162. package/dist/utilities/pushDevSchema.d.ts.map +1 -0
  163. package/dist/utilities/pushDevSchema.js +56 -0
  164. package/dist/utilities/pushDevSchema.js.map +1 -0
  165. package/package.json +3 -3
@@ -21,4 +21,4 @@ export const findVersions = async function findVersions({ collection, limit, loc
21
21
  });
22
22
  };
23
23
 
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9maW5kVmVyc2lvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBGaW5kVmVyc2lvbnMgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCwgU2FuaXRpemVkQ29sbGVjdGlvbkNvbmZpZyB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGJ1aWxkVmVyc2lvbkNvbGxlY3Rpb25GaWVsZHMgfSBmcm9tICdwYXlsb2FkL3ZlcnNpb25zJ1xuaW1wb3J0IHRvU25ha2VDYXNlIGZyb20gJ3RvLXNuYWtlLWNhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgZmluZE1hbnkgfSBmcm9tICcuL2ZpbmQvZmluZE1hbnkuanMnXG5cbmV4cG9ydCBjb25zdCBmaW5kVmVyc2lvbnM6IEZpbmRWZXJzaW9ucyA9IGFzeW5jIGZ1bmN0aW9uIGZpbmRWZXJzaW9ucyhcbiAgdGhpczogUG9zdGdyZXNBZGFwdGVyLFxuICB7XG4gICAgY29sbGVjdGlvbixcbiAgICBsaW1pdCxcbiAgICBsb2NhbGUsXG4gICAgcGFnZSxcbiAgICBwYWdpbmF0aW9uLFxuICAgIHJlcSA9IHt9IGFzIFBheWxvYWRSZXF1ZXN0LFxuICAgIHNraXAsXG4gICAgc29ydDogc29ydEFyZyxc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bUJBQWtCO0FBQy9ELE9BQU9DLGlCQUFpQixnQkFBZTtBQUl2QyxTQUFTQyxRQUFRLFFBQVEscUJBQW9CO0FBRTdDLE9BQU8sTUFBTUMsZUFBNkIsZUFBZUEsYUFFdkQsRUFDRUMsVUFBVSxFQUNWQyxLQUFLLEVBQ0xDLE1BQU0sRUFDTkMsSUFBSSxFQUNKQyxVQUFVLEVBQ1ZDLE1BQU0sQ0FBQyxDQUFtQixFQUMxQkMsSUFBSSxFQUNKQyxNQUFNQyxPQUFPLEVBQ2JDLEtBQUssRUFDTjtJQUVELE1BQU1DLG1CQUE4QyxJQUFJLENBQUNDLE9BQU8sQ0FBQ0MsV0FBVyxDQUFDWixXQUFXLENBQUNhLE1BQU07SUFDL0YsTUFBTU4sT0FBTyxPQUFPQyxZQUFZLFdBQVdBLFVBQVVFLGlCQUFpQkksV0FBVztJQUVqRixNQUFNQyxZQUFZLENBQUMsQ0FBQyxFQUFFbEIsWUFBWUcsWUFBWSxFQUFFLENBQUM7SUFDakQsTUFBTWdCLFNBQVNwQiw2QkFBNkJjO0lBRTVDLE9BQU9aLFNBQVM7UUFDZG1CLFNBQVMsSUFBSTtRQUNiRDtRQUNBZjtRQUNBQztRQUNBQztRQUNBQztRQUNBQztRQUNBQztRQUNBQztRQUNBUTtRQUNBTjtJQUNGO0FBQ0YsRUFBQyJ9
24
+ //# sourceMappingURL=findVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { FindVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","findMany","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","fields","adapter"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAY,CAAC,CAAC,EAAElB,YAAYG,YAAY,EAAE,CAAC;IACjD,MAAMgB,SAASpB,6BAA6Bc;IAE5C,OAAOZ,SAAS;QACdmB,SAAS,IAAI;QACbD;QACAf;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
package/dist/index.js CHANGED
@@ -128,4 +128,4 @@ export function postgresAdapter(args) {
128
128
  return srcDir;
129
129
  }
130
130
 
131
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFB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O1FBQ3pCLE9BQU9BO0lBQ1Q7SUFFQSxJQUFJMUQsR0FBRzhELFVBQVUsQ0FBQ0YsVUFBVTtRQUMxQixPQUFPQTtJQUNUO0lBRUEsSUFBSTVELEdBQUc4RCxVQUFVLENBQUNELHFCQUFxQjtRQUNyQyxPQUFPQTtJQUNUO0lBRUEsT0FBT0g7QUFDVCJ9
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { DatabaseAdapterObj } from 'payload/database'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { createDatabaseAdapter } from 'payload/database'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrate } from './migrate.js'\nimport { migrateDown } from './migrateDown.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { migrateRefresh } from './migrateRefresh.js'\nimport { migrateReset } from './migrateReset.js'\nimport { migrateStatus } from './migrateStatus.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateOne } from './update.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateVersion } from './updateVersion.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n const idType = args.idType || 'serial'\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n\n // Postgres-specific\n drizzle: undefined,\n enums: {},\n fieldConstraints: {},\n idType,\n logger: args.logger,\n pgSchema: undefined,\n pool: undefined,\n poolOptions: args.pool,\n push: args.push,\n relations: {},\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tables: {},\n\n // DatabaseAdapter\n beginTransaction,\n commitTransaction,\n connect,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n /**\n * This represents how a default ID is treated in Payload as were a field type\n */\n defaultIDType: idType === 'serial' ? 'number' : 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n payload,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: 'number',\n init: adapter,\n }\n}\n\n/**\n * Attempt to find migrations directory.\n *\n * Checks for the following directories in order:\n * - `migrationDir` argument from Payload config\n * - `src/migrations`\n * - `dist/migrations`\n * - `migrations`\n *\n * Defaults to `src/migrations`\n *\n * @param migrationDir\n * @returns\n */\nfunction findMigrationDir(migrationDir?: string): string {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src/migrations')\n const distDir = path.resolve(cwd, 'dist/migrations')\n const relativeMigrations = path.resolve(cwd, 'migrations')\n\n // Use arg if provided\n if (migrationDir) return migrationDir\n\n // Check other common locations\n if (fs.existsSync(srcDir)) {\n return srcDir\n }\n\n if (fs.existsSync(distDir)) {\n return distDir\n }\n\n if (fs.existsSync(relativeMigrations)) {\n return relativeMigrations\n }\n\n return srcDir\n}\n"],"names":["fs","path","createDatabaseAdapter","connect","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findOne","findVersions","init","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","postgresAdapter","args","adapter","payload","migrationDir","findMigrationDir","idType","name","drizzle","undefined","enums","fieldConstraints","logger","pgSchema","pool","poolOptions","push","relations","schema","schemaName","sessions","tables","defaultIDType","cwd","process","srcDir","resolve","distDir","relativeMigrations","existsSync"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,qBAAqB,QAAQ,mBAAkB;AAIxD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB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OAAO,CAACH,KAAK;IACjC,MAAMI,UAAU3D,KAAK0D,OAAO,CAACH,KAAK;IAClC,MAAMK,qBAAqB5D,KAAK0D,OAAO,CAACH,KAAK;IAE7C,sBAAsB;IACtB,IAAInB,cAAc,OAAOA;IAEzB,+BAA+B;IAC/B,IAAIrC,GAAG8D,UAAU,CAACJ,SAAS;QACzB,OAAOA;IACT;IAEA,IAAI1D,GAAG8D,UAAU,CAACF,UAAU;QAC1B,OAAOA;IACT;IAEA,IAAI5D,GAAG8D,UAAU,CAACD,qBAAqB;QACrC,OAAOA;IACT;IAEA,OAAOH;AACT"}
package/dist/init.js CHANGED
@@ -73,4 +73,4 @@ export const init = function init() {
73
73
  });
74
74
  };
75
75
 
76
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbml0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXBhcmFtLXJlYXNzaWduICovXG5pbXBvcnQgdHlwZSB7IEluaXQgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBTYW5pdGl6ZWRDb2xsZWN0aW9uQ29uZmlnIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgcGdFbnVtLCBwZ1NjaGVtYSwgcGdUYWJsZSB9IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUnXG5pbXBvcnQgeyBidWlsZFZlcnNpb25Db2xsZWN0aW9uRmllbGRzLCBidWlsZFZlcnNpb25HbG9iYWxGaWVsZHMgfSBmcm9tICdwYXlsb2FkL3ZlcnNpb25zJ1xuaW1wb3J0IHRvU25ha2VDYXNlIGZyb20gJ3RvLXNuYWtlLWNhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgYnVpbGRUYWJsZSB9I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EJDLFlBQVk7WUFDWkMsZ0JBQWdCLENBQUMsQ0FBQ1MsUUFBUVIsVUFBVUM7WUFDcENDLGVBQWU7WUFDZkMsUUFBUUssT0FBT0wsTUFBTTtZQUNyQlY7WUFDQVcsWUFBWTtRQUNkO1FBRUEsSUFBSUksT0FBT1IsUUFBUSxFQUFFO1lBQ25CLE1BQU1LLG9CQUFvQixDQUFDLENBQUMsRUFBRVosVUFBVSxFQUFFLENBQUM7WUFDM0MsTUFBTWEsZ0JBQWdCOUIseUJBQXlCZ0M7WUFFL0M5QixXQUFXO2dCQUNUaUIsU0FBUyxJQUFJO2dCQUNiQyxjQUFjO2dCQUNkQyxvQkFBb0I7Z0JBQ3BCQyxZQUFZO2dCQUNaQyxnQkFBZ0IsQ0FBQyxDQUFDUyxPQUFPUixRQUFRLEVBQUVDO2dCQUNuQ0MsZUFBZTtnQkFDZkMsUUFBUUc7Z0JBQ1JiLFdBQVdZO2dCQUNYRCxZQUFZO1lBQ2Q7UUFDRjtJQUNGO0FBQ0YsRUFBQyJ9
76
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Init } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\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.schemaName) {\n this.pgSchema = pgSchema(this.schemaName)\n } else {\n this.pgSchema = { table: pgTable }\n }\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = pgEnum(\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 const tableName = toSnakeCase(collection.slug)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n })\n\n if (collection.versions) {\n const versionsTableName = `_${tableName}_v`\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = toSnakeCase(global.slug)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n })\n\n if (global.versions) {\n const versionsTableName = `_${tableName}_v`\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n })\n }\n })\n}\n"],"names":["pgEnum","pgSchema","pgTable","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","buildTable","init","schemaName","table","payload","config","localization","enums","enum__locales","locales","map","code","collections","forEach","collection","tableName","slug","adapter","buildNumbers","buildRelationships","buildTexts","disableNotNull","versions","drafts","disableUnique","fields","timestamps","versionsTableName","versionFields","globals","global"],"mappings":"AAAA,oCAAoC,GAIpC,SAASA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,sBAAqB;AAC/D,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AACzF,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,UAAU,QAAQ,oBAAmB;AAE9C,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,I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AAC,CAACS,QAAQR,UAAUC;YACpCC,eAAe;YACfC,QAAQK,OAAOL,MAAM;YACrBV;YACAW,YAAY;QACd;QAEA,IAAII,OAAOR,QAAQ,EAAE;YACnB,MAAMK,oBAAoB,CAAC,CAAC,EAAEZ,UAAU,EAAE,CAAC;YAC3C,MAAMa,gBAAgB9B,yBAAyBgC;YAE/C9B,WAAW;gBACTiB,SAAS,IAAI;gBACbC,cAAc;gBACdC,oBAAoB;gBACpBC,YAAY;gBACZC,gBAAgB,CAAC,CAACS,OAAOR,QAAQ,EAAEC;gBACnCC,eAAe;gBACfC,QAAQG;gBACRb,WAAWY;gBACXD,YAAY;YACd;QACF;IACF;AACF,EAAC"}
package/dist/migrate.js CHANGED
@@ -94,4 +94,4 @@ async function runMigrationFile(payload, migration, batch) {
94
94
  }
95
95
  }
96
96
 
97
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXJlc3RyaWN0ZWQtc3ludGF4LCBuby1hd2FpdC1pbi1sb29wICovXG5pbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBNaWdyYXRpb24gfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7XG4gIGNvbW1pdFRyYW5zYWN0aW9uLFxuICBpbml0VHJhbnNhY3Rpb24sXG4gIGtpbGxUcmFuc2FjdGlvbixcbiAgcmVhZE1pZ3JhdGlvbkZpbGVzLFxufSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHByb21wdHMgZnJvbSAncHJvbXB0cydcblxuaW1wb3J0IHR5cGUgeyBQb3N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NQUFNbkQsZ0JBQWdCMkM7UUFDdEJwQyxRQUFRRyxNQUFNLENBQUMwQyxLQUFLLENBQUM7WUFDbkJEO1lBQ0F2QyxLQUFLUCxXQUFXOEMsS0FBSyxDQUFDLHdCQUF3QixFQUFFaEIsVUFBVVIsSUFBSSxDQUFDLENBQUM7UUFDbEU7SUFDRjtBQUNGIn0=
97
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrate.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { Payload } from 'payload'\nimport type { Migration } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport {\n commitTransaction,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload/database'\nimport prompts from 'prompts'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { createMigrationTable } from './utilities/createMigrationTable.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrate(this: PostgresAdapter): Promise<void> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n if (!migrationFiles.length) {\n payload.logger.info({ msg: 'No migrations to run.' })\n return\n }\n\n let latestBatch = 0\n let migrationsInDB = []\n\n const hasMigrationTable = await migrationTableExists(this.drizzle)\n\n if (hasMigrationTable) {\n ;({ docs: migrationsInDB } = await payload.find({\n collection: 'payload-migrations',\n limit: 0,\n sort: '-name',\n }))\n if (Number(migrationsInDB?.[0]?.batch) > 0) {\n latestBatch = Number(migrationsInDB[0]?.batch)\n }\n } else {\n await createMigrationTable(this)\n }\n\n if (migrationsInDB.find((m) => m.batch === -1)) {\n const { confirm: runMigrations } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message:\n \"It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database.\\n\\n\" +\n \"If you'd like to run migrations, data loss will occur. Would you like to proceed?\",\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!runMigrations) {\n process.exit(0)\n }\n }\n\n const newBatch = latestBatch + 1\n\n // Execute 'up' function for each migration sequentially\n for (const migration of migrationFiles) {\n const alreadyRan = migrationsInDB.find((existing) => existing.name === migration.name)\n\n // If already ran, skip\n if (alreadyRan) {\n continue // eslint-disable-line no-continue\n }\n\n await runMigrationFile(payload, migration, newBatch)\n }\n}\n\nasync function runMigrationFile(payload: Payload, migration: Migration, batch: number) {\n const { generateDrizzleJson } = await import('drizzle-kit/payload')\n\n const start = Date.now()\n const req = { payload } as PayloadRequest\n\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n\n const pgAdapter = payload.db as PostgresAdapter\n const drizzleJSON = generateDrizzleJson(pgAdapter.schema)\n\n try {\n await initTransaction(req)\n await migration.up({ payload, req })\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n batch,\n schema: drizzleJSON,\n },\n req,\n })\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}`),\n })\n }\n}\n"],"names":["commitTransaction","initTransaction","killTransaction","readMigrationFiles","prompts","createMigrationTable","migrationTableExists","parseError","migrate","payload","migrationFiles","length","logger","info","msg","latestBatch","migrationsInDB","hasMigrationTable","drizzle","docs","find","collection","limit","sort","Number","batch","m","confirm","runMigrations","name","type","initial","message","onCancel","process","exit","newBatch","migration","alreadyRan","existing","runMigrationFile","generateDrizzleJson","start","Date","now","req","pgAdapter","db","drizzleJSON","schema","up","create","data","err","error"],"mappings":"AAAA,yDAAyD,GAKzD,SACEA,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,mBAAkB;AACzB,OAAOC,aAAa,UAAS;AAI7B,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ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0FBSyxDQUFDO2dCQUNuQkQ7Z0JBQ0FwQixLQUFLVCxXQUFXNkIsS0FBSyxDQUFDLHFCQUFxQixFQUFFZixjQUFjRyxJQUFJLENBQUMsZUFBZSxDQUFDO1lBQ2xGO1lBQ0FjLFFBQVFDLElBQUksQ0FBQztRQUNmO0lBQ0Y7QUFDRiJ9
63
+ //# sourceMappingURL=migrateDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { PayloadRequest } from 'payload/types'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrateDown(this: PostgresAdapter): Promise<void> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n payload,\n })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to rollback.' })\n return\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const latestBatchMigrations = existingMigrations.filter(({ batch }) => batch === latestBatch)\n\n for (const migration of latestBatchMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n const req = { payload } as PayloadRequest\n\n try {\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this.drizzle)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n\n payload.logger.error({\n err,\n msg: parseError(err, `Error migrating down ${migrationFile.name}. Rolling back.`),\n })\n process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateDown","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","latestBatchMigrations","filter","batch","migration","migrationFile","find","m","name","Error","start","Date","now","req","down","tableExists","drizzle","delete","id","collection","err","error","process","exit"],"mappings":"AAAA,yDAAyD,GAGzD,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,mBAAkB;AAIzB,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMV,cAAc;QAC9DO;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACxD;IACF;IAEAP,QAAQK,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eAAe,EAAED,mBAAmBE,MAAM,CAAC,cAAc,CAAC;IACnG;IAEA,MAAMI,wBAAwBN,mBAAmBO,MAAM,CAAC,CAAC,EAAEC,KAAK,EAAE,GAAKA,UAAUP;IAEjF,KAAK,MAAMQ,aAAaH,sBAAuB;QAC7C,MAAMI,gBAAgBX,eAAeY,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAC1E,IAAI,CAACH,eAAe;YAClB,MAAM,IAAII,MAAM,CAAC,UAAU,EAAEL,UAAUI,IAAI,CAAC,mBAAmB,CAAC;QAClE;QAEA,MAAME,QAAQC,KAAKC,GAAG;QACtB,MAAMC,MAAM;YAAEpB;QAAQ;QAEtB,IAAI;YACFA,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,gBAAgB,EAAEK,cAAcG,IAAI,CAAC,CAAC;YAAC;YACnE,MAAMrB,gBAAgB0B;YACtB,MAAMR,cAAcS,IAAI,CAAC;gBAAErB;gBAASoB;YAAI;YACxCpB,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAClBC,KAAK,CAAC,gBAAgB,EAAEK,cAAcG,IAAI,CAAC,EAAE,EAAEG,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YACxE;YAEA,MAAMK,cAAc,MAAMzB,qBAAqB,IAAI,CAAC0B,OAAO;YAC3D,IAAID,aAAa;gBACf,MAAMtB,QAAQwB,MAAM,CAAC;oBACnBC,IAAId,UAAUc,EAAE;oBAChBC,YAAY;oBACZN;gBACF;YACF;YAEA,MAAM5B,kBAAkB4B;QAC1B,EAAE,OAAOO,KAAc;YACrB,MAAMhC,gBAAgByB;YAEtBpB,QAAQK,MAAM,CAACuB,KAAK,CAAC;gBACnBD;gBACApB,KAAKT,WAAW6B,KAAK,CAAC,qBAAqB,EAAEf,cAAcG,IAAI,CAAC,eAAe,CAAC;YAClF;YACAc,QAAQC,IAAI,CAAC;QACf;IACF;AACF"}
@@ -69,4 +69,4 @@ import { parseError } from './utilities/parseError.js';
69
69
  }
70
70
  }
71
71
 
72
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlRnJlc2gudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IHNxbCB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHtcbiAgY29tbWl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0JBQWdCMEI7WUFDdEJwQixRQUFRVSxNQUFNLENBQUNxQixLQUFLLENBQUM7Z0JBQ25CRDtnQkFDQWxCLEtBQUtmLFdBQVdpQyxLQUFLLENBQUMsd0JBQXdCLEVBQUVULFVBQVVsQixJQUFJLENBQUMsY0FBYyxDQUFDO1lBQ2hGO1FBQ0Y7SUFDRjtBQUNGIn0=
72
+ //# sourceMappingURL=migrateFresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport {\n commitTransaction,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload/database'\nimport prompts from 'prompts'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Drop the current database and run all migrate up functions\n */\nexport async function migrateFresh(\n this: PostgresAdapter,\n { forceAcceptWarning = false },\n): Promise<void> {\n const { payload } = this\n\n if (forceAcceptWarning === false) {\n const { confirm: acceptWarning } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`,\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!acceptWarning) {\n process.exit(0)\n }\n }\n\n payload.logger.info({\n msg: `Dropping database.`,\n })\n\n await this.drizzle.execute(\n sql.raw(`drop schema ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};`),\n )\n\n const migrationFiles = await readMigrationFiles({ payload })\n payload.logger.debug({\n msg: `Found ${migrationFiles.length} migration files.`,\n })\n\n const req = { payload } as PayloadRequest\n // Run all migrate up\n for (const migration of migrationFiles) {\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n await migration.up({ payload, req })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n batch: 1,\n },\n req,\n })\n await commitTransaction(req)\n\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back`),\n })\n }\n }\n}\n"],"names":["sql","commitTransaction","initTransaction","killTransaction","readMigrationFiles","prompts","parseError","migrateFresh","forceAcceptWarning","payload","confirm","acceptWarning","name","type","initial","message","onCancel","process","exit","logger","info","msg","drizzle","execute","raw","schemaName","migrationFiles","debug","length","req","migration","start","Date","now","up","create","collection","data","batch","err","error"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SACEC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,mBAAkB;AACzB,OAAOC,aAAa,UAAS;AAI7B,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC,aAEpB,EAAEC,qBAAqB,KAAK,EAAE;IAE9B,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IAExB,IAAID,uBAAuB,OAAO;QAChC,MAAM,EAAEE,SAASC,aAAa,EAAE,GAAG,MAAMN,QACvC;YACEO,MAAM;YACNC,MAAM;YACNC,SAAS;YACTC,SAAS,CAAC,+FAA+F,CAAC;QAC5G,GACA;YACEC,UAAU;gBACRC,QAAQC,IAAI,CAAC;YACf;QACF;QAGF,IAAI,CAACP,eAAe;YAClBM,QAAQC,IAAI,CAAC;QACf;IACF;IAEAT,QAAQU,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,kBAAkB,CAAC;IAC3B;IAEA,MAAM,IAAI,CAACC,OAAO,CAACC,OAAO,CACxBvB,IAAIwB,GAAG,CAAC,CAAC,YAAY,EAAE,IAAI,CAACC,UAAU,IAAI,SAAS;gBACvC,EAAE,IAAI,CAACA,UAAU,IAAI,SAAS,CAAC,CAAC;IAG9C,MAAMC,iBAAiB,MAAMtB,mBAAmB;QAAEK;IAAQ;IAC1DA,QAAQU,MAAM,CAACQ,KAAK,CAAC;QACnBN,KAAK,CAAC,MAAM,EAAEK,eAAeE,MAAM,CAAC,iBAAiB,CAAC;IACxD;IAEA,MAAMC,MAAM;QAAEpB;IAAQ;IACtB,qBAAqB;IACrB,KAAK,MAAMqB,aAAaJ,eAAgB;QACtCjB,QAAQU,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK,CAAC,WAAW,EAAES,UAAUlB,IAAI,CAAC,CAAC;QAAC;QAC1D,IAAI;YACF,MAAMmB,QAAQC,KAAKC,GAAG;YACtB,MAAM/B,gBAAgB2B;YACtB,MAAMC,UAAUI,EAAE,CAAC;gBAAEzB;gBAASoB;YAAI;YAClC,MAAMpB,QAAQ0B,MAAM,CAAC;gBACnBC,YAAY;gBACZC,MAAM;oBACJzB,MAAMkB,UAAUlB,IAAI;oBACpB0B,OAAO;gBACT;gBACAT;YACF;YACA,MAAM5B,kBAAkB4B;YAExBpB,QAAQU,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,WAAW,EAAES,UAAUlB,IAAI,CAAC,EAAE,EAAEoB,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YAAC;QACtF,EAAE,OAAOQ,KAAc;YACrB,MAAMpC,gBAAgB0B;YACtBpB,QAAQU,MAAM,CAACqB,KAAK,CAAC;gBACnBD;gBACAlB,KAAKf,WAAWiC,KAAK,CAAC,wBAAwB,EAAET,UAAUlB,IAAI,CAAC,cAAc,CAAC;YAChF;QACF;IACF;AACF"}
@@ -99,4 +99,4 @@ import { parseError } from './utilities/parseError.js';
99
99
  }
100
100
  }
101
101
 
102
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlUmVmcmVzaC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tYXdhaXQtaW4tbG9vcCAqL1xuaW1wb3J0IHR5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FDQW5CLEtBQUtULFdBQVc0QixLQUFLLENBQUMsd0JBQXdCLEVBQUVoQixVQUFVSSxJQUFJLENBQUMsZUFBZSxDQUFDO1lBQ2pGO1FBQ0Y7SUFDRjtBQUNGIn0=
102
+ //# sourceMappingURL=migrateRefresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { PayloadRequest } from 'payload/types'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Run all migration down functions before running up\n */\nexport async function migrateRefresh(this: PostgresAdapter) {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n payload,\n })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to rollback.' })\n return\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const req = { payload } as PayloadRequest\n\n // Reverse order of migrations to rollback\n existingMigrations.reverse()\n\n for (const migration of existingMigrations) {\n try {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n payload.logger.info({ msg: `Migrating down: ${migration.name}` })\n const start = Date.now()\n await initTransaction(req)\n await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this.drizzle)\n if (tableExists) {\n await payload.delete({\n collection: 'payload-migrations',\n req,\n where: {\n name: {\n equals: migration.name,\n },\n },\n })\n }\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n process.exit(1)\n }\n }\n\n // Run all migrate up\n for (const migration of migrationFiles) {\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n await migration.up({ payload, req })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n executed: true,\n },\n req,\n })\n await commitTransaction(req)\n\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateRefresh","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","down","tableExists","drizzle","delete","collection","where","equals","err","error","process","exit","up","create","data","executed"],"mappings":"AAAA,yDAAyD,GAGzD,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,mBAAkB;AAIzB,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMV,cAAc;QAC9DO;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACxD;IACF;IAEAP,QAAQK,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eAAe,EAAED,mBAAmBE,MAAM,CAAC,cAAc,CAAC;IACnG;IA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CAAC;YAAEC,KAAK,CAAC,WAAW,EAAEG,UAAUI,IAAI,CAAC,CAAC;QAAC;QAC1D,IAAI;YACF,MAAME,QAAQC,KAAKC,GAAG;YACtB,MAAMxB,gBAAgBc;YACtB,MAAME,UAAUoB,EAAE,CAAC;gBAAE9B;gBAASQ;YAAI;YAClC,MAAMR,QAAQ+B,MAAM,CAAC;gBACnBR,YAAY;gBACZS,MAAM;oBACJlB,MAAMJ,UAAUI,IAAI;oBACpBmB,UAAU;gBACZ;gBACAzB;YACF;YACA,MAAMhB,kBAAkBgB;YAExBR,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,WAAW,EAAEG,UAAUI,IAAI,CAAC,EAAE,EAAEG,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YAAC;QACtF,EAAE,OAAOU,KAAc;YACrB,MAAM/B,gBAAgBa;YACtBR,QAAQK,MAAM,CAACsB,KAAK,CAAC;gBACnBD;gBACAnB,KAAKT,WAAW4B,KAAK,CAAC,wBAAwB,EAAEhB,UAAUI,IAAI,CAAC,eAAe,CAAC;YACjF;QACF;IACF;AACF"}
@@ -79,4 +79,4 @@ import { migrationTableExists } from './utilities/migrationTableExists.js';
79
79
  }
80
80
  }
81
81
 
82
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlUmVzZXQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tcmVzdHJpY3RlZC1zeW50YXgsIG5vLWF3YWl0LWluLWxvb3AgKi9cbmltcG9ydCB0eXBlIHsgUGF5bG9hZFJlcXVlc3QgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQge1xuICBjb21taXRUcmFuc2FjdGlvbixcbiAgZ2V0TWlncmF0aW9ucyxcbiAgaW5pdFRyYW5zYWN0aW9uLFxuICBraWxsVHJhbnNhY3Rpb24sXG4gIHJl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RQyxJQUFJLENBQUM7UUFDZjtJQUNGO0lBRUEsdUJBQXVCO0lBRXZCLE1BQU1ULGNBQWMsTUFBTXBCLHFCQUFxQixJQUFJLENBQUNxQixPQUFPO0lBQzNELElBQUlELGFBQWE7UUFDZixJQUFJO1lBQ0YsTUFBTWxCLFFBQVFvQixNQUFNLENBQUM7Z0JBQ25CRSxZQUFZO2dCQUNaTSxPQUFPO29CQUNMQyxPQUFPO3dCQUNMQyxRQUFRLENBQUM7b0JBQ1g7Z0JBQ0Y7WUFDRjtRQUNGLEVBQUUsT0FBT1AsS0FBYztZQUNyQnZCLFFBQVFJLE1BQU0sQ0FBQ3FCLEtBQUssQ0FBQztnQkFBRUEsT0FBT0Y7Z0JBQUtqQixLQUFLO1lBQStCO1FBQ3pFO0lBQ0Y7QUFDRiJ9
82
+ //# sourceMappingURL=migrateReset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { PayloadRequest } from 'payload/types'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\n/**\n * Run all migrate down functions\n */\nexport async function migrateReset(this: PostgresAdapter): Promise<void> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations } = await getMigrations({ payload })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to reset.' })\n return\n }\n\n const req = { payload } as PayloadRequest\n\n // Rollback all migrations in order\n for (const migration of existingMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n try {\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this.drizzle)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\n } catch (err: unknown) {\n let msg = `Error running migration ${migrationFile.name}.`\n\n if (err instanceof Error) msg += ` ${err.message}`\n\n await killTransaction(req)\n payload.logger.error({\n err,\n msg,\n })\n process.exit(1)\n }\n }\n\n // Delete dev migration\n\n const tableExists = await migrationTableExists(this.drizzle)\n if (tableExists) {\n try {\n await payload.delete({\n collection: 'payload-migrations',\n where: {\n batch: {\n equals: -1,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({ error: err, msg: 'Error deleting dev migration' })\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","migrateReset","payload","migrationFiles","existingMigrations","length","logger","info","msg","req","migration","migrationFile","find","m","name","Error","start","Date","now","down","tableExists","drizzle","delete","id","collection","err","message","error","process","exit","where","batch","equals"],"mappings":"AAAA,yDAAyD,GAGzD,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,mBAAkB;AAIzB,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMJ,mBAAmB;QAAEG;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAE,GAAG,MAAMR,cAAc;QAAEM;IAAQ;IAE7D,IAAI,CAACE,oBAAoBC,QAAQ;QAC/BH,QAAQI,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA0B;QACrD;IACF;IAEA,MAAMC,MAAM;QAAEP;IAAQ;IAEtB,mCAAmC;IACnC,KAAK,MAAMQ,aAAaN,mBAAoB;QAC1C,MAAMO,gBAAgBR,eAAe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kFBa0IsRUFBRSxHQUFHLE1BQU1WLGNBQWM7WUFBRUk7UUFBUSxFQUFDO0lBQzVEO0lBRUEsSUFBSSxDQUFDQyxlQUFlSSxNQUFNLEVBQUU7UUFDMUJMLFFBQVFFLE1BQU0sQ0FBQ08sSUFBSSxDQUFDO1lBQUVMLEtBQUs7UUFBdUI7UUFDbEQ7SUFDRjtJQUVBLGlEQUFpRDtJQUNqRCxNQUFNTSxXQUFXVCxlQUFlVSxHQUFHLENBQUMsQ0FBQ0M7UUFDbkMsTUFBTUMsb0JBQW9CUCxtQkFBbUJRLElBQUksQ0FBQyxDQUFDQyxJQUFNQSxFQUFFQyxJQUFJLEtBQUtKLFVBQVVJLElBQUk7UUFDbEYsT0FBTztZQUNMQyxNQUFNTCxVQUFVSSxJQUFJO1lBQ3BCLHNEQUFzRDtZQUN0REUsT0FBT0wsbUJBQW1CTTtZQUMxQkMsS0FBS1Asb0JBQW9CLFFBQVE7UUFDbkM7SUFDRjtJQUVBLE1BQU1RLElBQUksSUFBSTFCO0lBRWRlLFNBQVNZLE9BQU8sQ0FBQyxDQUFDQztRQUNoQkYsRUFBRUcsTUFBTSxDQUFDRCxHQUFHO1lBQ1ZFLE9BQU9GLEVBQUVILEdBQUcsS0FBSyxRQUFRLFVBQVU7UUFDckM7SUFDRjtJQUNBQyxFQUFFSyxVQUFVO0FBQ2QifQ==
44
+ //# sourceMappingURL=migrateStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrateStatus.ts"],"sourcesContent":["import { Table } from 'console-table-printer'\nimport { getMigrations, readMigrationFiles } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\nexport async function migrateStatus(this: PostgresAdapter): Promise<void> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n payload.logger.debug({\n msg: `Found ${migrationFiles.length} migration files.`,\n })\n\n let existingMigrations = []\n const hasMigrationTable = await migrationTableExists(this.drizzle)\n\n if (hasMigrationTable) {\n ;({ existingMigrations } = await getMigrations({ payload }))\n }\n\n if (!migrationFiles.length) {\n payload.logger.info({ msg: 'No migrations found.' })\n return\n }\n\n // Compare migration files to existing migrations\n const statuses = migrationFiles.map((migration) => {\n const existingMigration = existingMigrations.find((m) => m.name === migration.name)\n return {\n Name: migration.name,\n // eslint-disable-next-line perfectionist/sort-objects\n Batch: existingMigration?.batch,\n Ran: existingMigration ? 'Yes' : 'No',\n }\n })\n\n const p = new Table()\n\n statuses.forEach((s) => {\n p.addRow(s, {\n color: s.Ran === 'Yes' ? 'green' : 'red',\n })\n })\n p.printTable()\n}\n"],"names":["Table","getMigrations","readMigrationFiles","migrationTableExists","migrateStatus","payload","migrationFiles","logger","debug","msg","length","existingMigrations","hasMigrationTable","drizzle","info","statuses","map","migration","existingMigration","find","m","name","Name","Batch","batch","Ran","p","forEach","s","addRow","color","printTable"],"mappings":"AAAA,SAASA,KAAK,QAAQ,wBAAuB;AAC7C,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,mBAAkB;AAIpE,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMJ,mBAAmB;QAAEG;IAAQ;IAE1DA,QAAQE,MAAM,CAACC,KAAK,CAAC;QACnBC,KAAK,CAAC,MAAM,EAAEH,eAAeI,MAAM,CAAC,iBAAiB,CAAC;IACxD;IAEA,IAAIC,qBAAqB,EAAE;IAC3B,MAAMC,oBAAoB,MAAMT,qBAAqB,IAAI,CAACU,OAAO;IAEjE,IAAID,mBAAmB;QACnB,CAAA,EAAED,kBAAkB,EAAE,GAAG,MAAMV,cAAc;YAAEI;QAAQ,EAAC;IAC5D;IAEA,IAAI,CAACC,eAAeI,MAAM,EAAE;QAC1BL,QAAQE,MAAM,CAACO,IAAI,CAAC;YAAEL,KAAK;QAAuB;QAClD;IACF;IAEA,iDAAiD;IACjD,MAAMM,WAAWT,eAAeU,GAAG,CAAC,CAACC;QACnC,MAAMC,oBAAoBP,mBAAmBQ,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAClF,OAAO;YACLC,MAAML,UAAUI,IAAI;YACpB,sDAAsD;YACtDE,OAAOL,mBAAmBM;YAC1BC,KAAKP,oBAAoB,QAAQ;QACnC;IACF;IAEA,MAAMQ,IAAI,IAAI1B;IAEde,SAASY,OAAO,CAAC,CAACC;QAChBF,EAAEG,MAAM,CAACD,GAAG;YACVE,OAAOF,EAAEH,GAAG,KAAK,QAAQ,UAAU;QACrC;IACF;IACAC,EAAEK,UAAU;AACd"}
@@ -26,4 +26,4 @@ export async function buildAndOrConditions({ adapter, fields, joinAliases, joins
26
26
  return completedConditions;
27
27
  }
28
28
 
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL2J1aWxkQW5kT3JDb25kaXRpb25zLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgU1FMIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgdHlwZSB7IEZpZWxkLCBXaGVyZSB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0eXBlIHsgR2VuZXJpY0NvbHVtbiwgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5pbXBvcnQgdHlwZSB7IEJ1aWxkUXVlcnlKb2luQWxpYXNlcywgQnVpbGRRdWVyeUpvaW5zIH0gZnJvbSAnLi9idWlsZFF1ZXJ5LmpzJ1xuXG5pbXBvcnQgeyBwYXJzZVBhcmFtcyB9IGZyb20gJy4vcGFyc2VQYXJhbXMuanMnXG5cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBidWlsZEFuZE9yQ29uZGl0aW9ucyh7XG4gIGFkYXB0ZXIsXG4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HNEQUFzRDtRQUN0RCxJQUFJLE9BQU9FLGNBQWMsVUFBVTtZQUNqQyw0Q0FBNEM7WUFDNUMsTUFBTUMsU0FBUyxNQUFNWixZQUFZO2dCQUMvQkU7Z0JBQ0FDO2dCQUNBQztnQkFDQUM7Z0JBQ0FDO2dCQUNBQztnQkFDQUM7Z0JBQ0FDLE9BQU9FO1lBQ1Q7WUFDQSxJQUFJQyxVQUFVQyxPQUFPQyxJQUFJLENBQUNGLFFBQVFHLE1BQU0sR0FBRyxHQUFHO2dCQUM1Q0wsb0JBQW9CTSxJQUFJLENBQUNKO1lBQzNCO1FBQ0Y7SUFDRjtJQUNBLE9BQU9GO0FBQ1QifQ==
29
+ //# sourceMappingURL=buildAndOrConditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, Where } from 'payload/types'\n\nimport type { GenericColumn, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport async function buildAndOrConditions({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where,\n}: {\n adapter: PostgresAdapter\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n locale?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: Where[]\n}): Promise<SQL[]> {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n // eslint-disable-next-line no-restricted-syntax\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n // eslint-disable-next-line no-await-in-loop\n const result = await parseParams({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where: condition,\n })\n if (result && Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","adapter","fields","joinAliases","joins","locale","selectFields","tableName","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAMA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,qBAAqB,EACzCC,OAAO,EACPC,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,MAAM,EACNC,YAAY,EACZC,SAAS,EACTC,KAAK,EAYN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAC7C,gDAAgD;IAChD,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,4CAA4C;YAC5C,MAAMC,SAAS,MAAMZ,YAAY;gBAC/BE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIC,UAAUC,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAC5CL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
@@ -73,4 +73,4 @@ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, ta
73
73
  };
74
74
  export default buildQuery;
75
75
 
76
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL2J1aWxkUXVlcnkudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBTUUwgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB0eXBlIHsgUGdUYWJsZVdpdGhDb2x1bW5zIH0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG9ydCB0eXBlIHsgRmllbGQsIFdoZXJlIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgYXNjLCBkZXNjIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHs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QVFDLE1BQU0sR0FBR2IsUUFBUVMsTUFBTSxDQUFDTCxVQUFVLENBQUNJLEVBQUU7UUFDL0M7SUFDRjtJQUVBLElBQUlJLFFBQVFDLE1BQU0sRUFBRTtRQUNsQk4sYUFBYUosSUFBSSxHQUFHUyxRQUFRQyxNQUFNO0lBQ3BDO0lBRUEsSUFBSVI7SUFFSixJQUFJQyxpQkFBaUJzQixPQUFPQyxJQUFJLENBQUN2QixlQUFld0IsTUFBTSxHQUFHLEdBQUc7UUFDMUR6QixRQUFRLE1BQU1QLFlBQVk7WUFDeEJFO1lBQ0FDO1lBQ0FVO1lBQ0FEO1lBQ0FSO1lBQ0FLO1lBQ0FIO1lBQ0FDLE9BQU9DO1FBQ1Q7SUFDRjtJQUVBLE9BQU87UUFDTEs7UUFDQUQ7UUFDQUU7UUFDQUw7UUFDQUY7SUFDRjtBQUNGO0FBRUEsZUFBZU4sV0FBVSJ9
76
+ //# sourceMappingURL=buildQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, Where } from 'payload/types'\n\nimport { asc, desc } from 'drizzle-orm'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\n\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\nimport { parseParams } from './parseParams.js'\n\nexport type BuildQueryJoins = Record<string, SQL>\n\nexport type BuildQueryJoinAliases = {\n condition: SQL\n table: GenericTable | PgTableWithColumns<any>\n}[]\n\ntype BuildQueryArgs = {\n adapter: PostgresAdapter\n fields: Field[]\n locale?: string\n sort?: string\n tableName: string\n where: Where\n}\n\ntype Result = {\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n orderBy: {\n column: GenericColumn\n order: typeof asc | typeof desc\n }\n selectFields: Record<string, GenericColumn>\n where: SQL\n}\nconst buildQuery = async function buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: incomingWhere,\n}: BuildQueryArgs): Promise<Result> {\n const selectFields: Record<string, GenericColumn> = {\n id: adapter.tables[tableName].id,\n }\n const joins: BuildQueryJoins = {}\n const joinAliases: BuildQueryJoinAliases = []\n\n const orderBy: Result['orderBy'] = {\n column: null,\n order: null,\n }\n\n if (sort) {\n let sortPath\n\n if (sort[0] === '-') {\n sortPath = sort.substring(1)\n orderBy.order = desc\n } else {\n sortPath = sort\n orderBy.order = asc\n }\n\n try {\n const { columnName: sortTableColumnName, table: sortTable } = getTableColumnFromPath({\n adapter,\n collectionPath: sortPath,\n fields,\n joinAliases,\n joins,\n locale,\n pathSegments: sortPath.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: sortPath,\n })\n orderBy.column = sortTable?.[sortTableColumnName]\n } catch (err) {\n // continue\n }\n }\n\n if (!orderBy?.column) {\n orderBy.order = desc\n const createdAt = adapter.tables[tableName]?.createdAt\n\n if (createdAt) {\n orderBy.column = createdAt\n } else {\n orderBy.column = adapter.tables[tableName].id\n }\n }\n\n if (orderBy.column) {\n selectFields.sort = orderBy.column\n }\n\n let where: SQL\n\n if (incomingWhere && Object.keys(incomingWhere).length > 0) {\n where = await parseParams({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\n joinAliases,\n joins,\n orderBy,\n selectFields,\n where,\n }\n}\n\nexport default buildQuery\n"],"names":["asc","desc","getTableColumnFromPath","parseParams","buildQuery","adapter","fields","locale","sort","tableName","where","incomingWhere","selectFields","id","tables","joins","joinAliases","orderBy","column","order","sortPath","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","err","createdAt","Object","keys","length"],"mappings":"AAIA,SAASA,GAAG,EAAEC,IAAI,QAAQ,cAAa;AAIvC,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,WAAW,QAAQ,mBAAkB;AA4B9C,MAAMC,aAAa,e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GAAG;QAC1DzB,QAAQ,MAAMP,YAAY;YACxBE;YACAC;YACAU;YACAD;YACAR;YACAK;YACAH;YACAC,OAAOC;QACT;IACF;IAEA,OAAO;QACLK;QACAD;QACAE;QACAL;QACAF;IACF;AACF;AAEA,eAAeN,WAAU"}
@@ -11,4 +11,4 @@ export const convertPathToJSONTraversal = (incomingSegments)=>{
11
11
  }, '');
12
12
  };
13
13
 
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9jb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBmb3JtYXRKU09OUGF0aFNlZ21lbnQgfSBmcm9tICcuL2Zvcm1hdEpTT05QYXRoU2VnbWVudC5qcydcblxuZXhwb3J0IGNvbnN0IGNvbnZlcnRQYXRoVG9KU09OVHJhdmVyc2FsID0gKGluY29taW5nU2VnbWVudHM6IHN0cmluZ1tdKSA9PiB7XG4gIGNvbnN0IHNlZ21lbnRzID0gWy4uLmluY29taW5nU2VnbWVudHNdXG4gIHNlZ21lbnRzLnNoaWZ0KClcblxuICByZXR1cm4gc2VnbWVudHMucmVkdWNlKChyZXMsIHNlZ21lbnQsIGkpID0+IHtcbiAgICBjb25zdCBmb3JtYXR0ZWRTZWdtZW50ID0gZm9ybWF0SlNPTlBhdGhTZWdtZW50KHNlZ21lbnQpXG5cbiAgICBpZiAoaSArIDEgPT09IHNlZ21lbnRzLmxlbmd0aCkgcmV0dXJuIGAke3Jlc30tPj4ke2Zvcm1hdHRlZFNlZ21lbnR9YFxuICAgIHJldHVybiBgJHtyZXN9LT4ke2Zvcm1hdHRlZFNlZ21lbnR9YFxuICB9LCAnJylcbn1cbiJdLCJuYW1lcyI6WyJmb3JtYXRKU09OUGF0aFNlZ21lbnQiLCJjb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbCIsImluY29taW5nU2VnbWVudHMiLCJzZWdtZW50cyIsInNoaWZ0IiwicmVkdWNlIiwicmVzIiwic2VnbWVudCIsImkiLCJmb3JtYXR0ZWRTZWdtZW50IiwibGVuZ3RoIl0sIm1hcHBpbmdzIjoiQUFBQSxTQUFTQSxxQkFBcUIsUUFBUSw2QkFBNEI7QUFFbEUsT0FBTyxNQUFNQyw2QkFBNkIsQ0FBQ0M7SUFDekMsTUFBTUMsV0FBVztXQUFJRDtLQUFpQjtJQUN0Q0MsU0FBU0MsS0FBSztJQUVkLE9BQU9ELFNBQVNFLE1BQU0sQ0FBQyxDQUFDQyxLQUFLQyxTQUFTQztRQUNwQyxNQUFNQyxtQkFBbUJULHNCQUFzQk87UUFFL0MsSUFBSUMsSUFBSSxNQUFNTCxTQUFTTyxNQUFNLEVBQUUsT0FBTyxDQUFDLEVBQUVKLElBQUksR0FBRyxFQUFFRyxpQkFBaUIsQ0FBQztRQUNwRSxPQUFPLENBQUMsRUFBRUgsSUFBSSxFQUFFLEVBQUVHLGlCQUFpQixDQUFDO0lBQ3RDLEdBQUc7QUFDTCxFQUFDIn0=
14
+ //# sourceMappingURL=convertPathToJSONTraversal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/queries/createJSONQuery/convertPathToJSONTraversal.ts"],"sourcesContent":["import { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nexport const convertPathToJSONTraversal = (incomingSegments: string[]) => {\n const segments = [...incomingSegments]\n segments.shift()\n\n return segments.reduce((res, segment, i) => {\n const formattedSegment = formatJSONPathSegment(segment)\n\n if (i + 1 === segments.length) return `${res}->>${formattedSegment}`\n return `${res}->${formattedSegment}`\n }, '')\n}\n"],"names":["formatJSONPathSegment","convertPathToJSONTraversal","incomingSegments","segments","shift","reduce","res","segment","i","formattedSegment","length"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,6BAA4B;AAElE,OAAO,MAAMC,6BAA6B,CAACC;IACzC,MAAMC,WAAW;WAAID;KAAiB;IACtCC,SAASC,KAAK;IAEd,OAAOD,SAASE,MAAM,CAAC,CAACC,KAAKC,SAASC;QACpC,MAAMC,mBAAmBT,sBAAsBO;QAE/C,IAAIC,IAAI,MAAML,SAASO,MAAM,EAAE,OAAO,CAAC,EAAEJ,IAAI,GAAG,EAAEG,iBAAiB,CAAC;QACpE,OAAO,CAAC,EAAEH,IAAI,EAAE,EAAEG,iBAAiB,CAAC;IACtC,GAAG;AACL,EAAC"}
@@ -2,4 +2,4 @@ export const formatJSONPathSegment = (segment)=>{
2
2
  return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment;
3
3
  };
4
4
 
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9mb3JtYXRKU09OUGF0aFNlZ21lbnQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IGZvcm1hdEpTT05QYXRoU2VnbWVudCA9IChzZWdtZW50OiBzdHJpbmcpID0+IHtcbiAgcmV0dXJuIE51bWJlci5pc05hTihwYXJzZUludChzZWdtZW50KSkgPyBgJyR7c2VnbWVudH0nYCA6IHNlZ21lbnRcbn1cbiJdLCJuYW1lcyI6WyJmb3JtYXRKU09OUGF0aFNlZ21lbnQiLCJzZWdtZW50IiwiTnVtYmVyIiwiaXNOYU4iLCJwYXJzZUludCJdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxNQUFNQSx3QkFBd0IsQ0FBQ0M7SUFDcEMsT0FBT0MsT0FBT0MsS0FBSyxDQUFDQyxTQUFTSCxZQUFZLENBQUMsQ0FBQyxFQUFFQSxRQUFRLENBQUMsQ0FBQyxHQUFHQTtBQUM1RCxFQUFDIn0=
5
+ //# sourceMappingURL=formatJSONPathSegment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/queries/createJSONQuery/formatJSONPathSegment.ts"],"sourcesContent":["export const formatJSONPathSegment = (segment: string) => {\n return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment\n}\n"],"names":["formatJSONPathSegment","segment","Number","isNaN","parseInt"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,CAACC;IACpC,OAAOC,OAAOC,KAAK,CAACC,SAASH,YAAY,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,GAAGA;AAC5D,EAAC"}
@@ -51,4 +51,4 @@ export const createJSONQuery = ({ operator, pathSegments, treatAsArray, treatRoo
51
51
  });
52
52
  };
53
53
 
54
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9xdWVyaWVzL2NyZWF0ZUpTT05RdWVyeS9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjb252ZXJ0UGF0aFRvSlNPTlRyYXZlcnNhbCB9IGZyb20gJy4vY29udmVydFBhdGhUb0pTT05UcmF2ZXJzYWwuanMnXG5pbXBvcnQgeyBmb3JtYXRKU09OUGF0aFNlZ21lbnQgfSBmcm9tICcuL2Zvcm1hdEpTT05QYXRoU2VnbWVudC5qcydcblxuY29uc3Qgb3BlcmF0b3JNYXAgPSB7XG4gIGNvbnRhaW5zOiAnfionLFxuICBlcXVhbHM6ICc9JyxcbiAgbGlrZTogJ34qJyxcbn1cblxudHlwZSBGcm9tQXJyYXlBcmdzID0ge1xuICBpc1Jvb3Q/OiB0cnVlXG4gIG9wZXJhdG9yOiBzdHJpbmdcbiAgcGF0aFNlZ21lbnRzOiBzdHJpbmdbXVxuICB0cmVhdEFzQXJyYXk/OiBzdHJpbmdbXVxuICB2YWx1ZTogdW5rbm93blxufVxuXG5jb25zdCBmcm9tQXJyYXkgPSAoeyBpc1Jvb3QsIG9wZXJhdG9yLCBwYXRoU2VnbWVudHMsIHRyZWF0QXNBcnJheSwgdmFsdWUgfTogRnJvbUFycmF5QXJncykg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Q0FBQztJQUVyRSxPQUFPLENBQUM7OzhCQUVvQixFQUFFUSxjQUFjLEtBQUssRUFBRUgsTUFBTTtVQUNqRCxFQUFFSSxnQkFBZ0I7UUFDdEJWO1FBQ0FDLGNBQWNHO1FBQ2RGO1FBQ0FDO0lBQ0YsR0FBRztHQUNKLENBQUM7QUFDSjtBQVNBLE1BQU1RLG1CQUFtQixDQUFDLEVBQUVYLFFBQVEsRUFBRUMsWUFBWSxFQUFFRSxLQUFLLEVBQXdCO0lBQy9FLE1BQU1TLFlBQVlwQiwyQkFBMkJTO0lBQzdDLE9BQU8sQ0FBQyxFQUFFQSxZQUFZLENBQUMsRUFBRSxDQUFDLEVBQUVXLFVBQVUsQ0FBQyxFQUFFbEIsV0FBVyxDQUFDTSxTQUFTLENBQUMsRUFBRSxFQUFFRyxNQUFNLENBQUMsQ0FBQztBQUM3RTtBQVVBLE9BQU8sTUFBTU8sa0JBQWtCLENBQUMsRUFDOUJWLFFBQVEsRUFDUkMsWUFBWSxFQUNaQyxZQUFZLEVBQ1pXLGdCQUFnQixFQUNoQlYsS0FBSyxFQUNBO0lBQ0wsSUFBSVUsa0JBQWtCO1FBQ3BCLE9BQU9mLFVBQVU7WUFDZkMsUUFBUTtZQUNSQztZQUNBQztZQUNBQztZQUNBQztRQUNGO0lBQ0Y7SUFFQSxJQUFJRCxhQUFhWSxRQUFRLENBQUNiLFlBQVksQ0FBQyxFQUFFLEdBQUc7UUFDMUMsT0FBT0gsVUFBVTtZQUNmRTtZQUNBQztZQUNBQztZQUNBQztRQUNGO0lBQ0Y7SUFFQSxPQUFPUSxpQkFBaUI7UUFBRVg7UUFBVUM7UUFBY0M7UUFBY0M7SUFBTTtBQUN4RSxFQUFDIn0=
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/queries/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","includ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,OAAOH,UAAU;YACfE;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOQ,iBAAiB;QAAEX;QAAUC;QAAcC;QAAcC;IAAM;AACxE,EAAC"}
@@ -365,4 +365,4 @@ import { v4 as uuid } from 'uuid';
365
365
  throw new APIError(`Cannot find field for path at ${fieldPath}`);
366
366
  };
367
367
 
368
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL2dldFRhYmxlQ29sdW1uRnJvbVBhdGgudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tcGFyYW0tcmVhc3NpZ24gKi9cbmltcG9ydCB0eXBlIHsgU1FMIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgdHlwZSB7IFBnVGFibGVXaXRoQ29sdW1ucyB9IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUnXG5pbXBvcnQgdHlwZSB7IEZpZWxkLCBGaWVsZEFmZmVjdGluZ0RhdGEsIE51bWJlckZpZWxkLCBUYWJBc0ZpZWxkLCBUZXh0RmllbGQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyBhbmQsIGVxLCBsaWtlLCBzcWwgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB7IGFsaWFzIH0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG9ydCB7IEFQSUVycm9yIH0gZnJvbSAncGF5bG9hZC9lcnJvcnMnXG5pbXBvcnQgeyBmaWVsZEFmZmVjdHNEYXRhLCB0YWJIYXNOYW1lIH0gZnJvbSAncGF5bG9hZC90eXBlcydcbmltcG9ydCB7IGZsYXR0ZW5Ub3BMZXZlbEZpZWxkcyB9IGZyb20gJ3BheWxvYWQvdXRpbGl0aWVzJ1xuaW1wb3J0IHRvU25ha2VDYXNlIGZyb20gJ3RvLXNuYWtlLWNhc2UnXG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biAgICAgICAgICBjb25zdHJhaW50cyxcbiAgICAgICAgICBmaWVsZHM6IGZpZWxkLnRhYnMubWFwKCh0YWIpID0+ICh7XG4gICAgICAgICAgICAuLi50YWIsXG4gICAgICAgICAgICB0eXBlOiAndGFiJyxcbiAgICAgICAgICB9KSksXG4gICAgICAgICAgam9pbkFsaWFzZXMsXG4gICAgICAgICAgam9pbnMsXG4gICAgICAgICAgbG9jYWxlLFxuICAgICAgICAgIHBhdGhTZWdtZW50czogcGF0aFNlZ21lbnRzLnNsaWNlKDEpLFxuICAgICAgICAgIHJvb3RUYWJsZU5hbWUsXG4gICAgICAgICAgc2VsZWN0RmllbGRzLFxuICAgICAgICAgIHRhYmxlTmFtZTogbmV3VGFibGVOYW1lLFxuICAgICAgICAgIHRhYmxlTmFtZVN1ZmZpeCxcbiAgICAgICAgICB2YWx1ZSxcbiAgICAgICAgfSlcbiAgICAgIH1cbiAgICAgIGNhc2UgJ3RhYic6IHtcbiAgICAgICAgaWYgKHRhYkhhc05hbWUoZmllbGQpKSB7XG4gICAgICAgICAgcmV0dXJuIGdldFRhYmxlQ29sdW1uRnJvbVBhdGgoe1xuICAgICAgICAgICAgYWRhcHRlcixcbiAgICAgICAgICAgIGFsaWFzVGFibGUsXG4gICAgICAgICAgICBjb2xsZWN0aW9uUGF0aCxcbiAgICAgICAgICAgIGNvbHVtblByZWZpeDogYCR7Y29sdW1uUHJlZml4fSR7ZmllbGQubmFtZX1fYCxcbiAgICAgICAgICAgIGNvbnN0cmFpbnRQYXRoOiBgJHtjb25zdHJhaW50UGF0aH0ke2ZpZWxkLm5hbWV9LmAsXG4gICAgICAgICAgICBjb25zdHJhaW50cyxcbiAgICAgICAgICAgIGZpZWxkczogZmllbGQuZmllbGRzLFxuICAgICAgICAgICAgam9pbkFsaWFzZXMsXG4gICAgICAgICAgICBqb2lucyxcbiAgICAgICAgICAgIGxvY2FsZSxcbiAgICAgICAgICAgIHBhdGhTZWdtZW50czogcGF0aFNlZ21lbnRzLnNsaWNlKDEpLFxuICAgICAgICAgICAgcm9vdFRhYmxlTmFtZSxcbiAgICAgICAgICAgIHNlbGVjdEZpZWxkcyxcbiAgICAgICAgICAgIHRhYmxlTmFtZTogbmV3VGFibGVOYW1lLFxuICAgICAgICAgICAgdGFibGVOYW1lU3VmZml4OiBgJHt0YWJsZU5hbWVTdWZmaXh9JHt0b1NuYWtlQ2FzZShmaWVsZC5uYW1lKX1fYCxcbiAgICAgICAgICAgIHZhbHVlLFxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGdldFRhYmxlQ29sdW1uRnJvbVBhdGgoe1xuICAgICAgICAgIGFkYXB0ZXIsXG4gICAgICAgICAgYWxpYXNUYWJsZSxcbiAgICAgICAgICBjb2xsZWN0aW9uUGF0aCxcbiAgICAgICAgICBjb2x1bW5QcmVmaXgsXG4gICAgICAgICAgY29uc3RyYWludFBhdGgsXG4gICAgICAgICAgY29uc3RyYWludHMsXG4gICAgICAgICAgZmllbGRzOiBmaWVsZC5maWVsZHMsXG4gICAgICAgICAgam9pbkFsaWFzZXMsXG4gICAgICAgICAgam9pbnMsXG4gICAgICAgICAgbG9jYWxlLFxuICAgICAgICAgIHBhdGhTZWdtZW50czogcGF0aFNlZ21lbnRzLnNsaWNlKDEpLFxuICAgICAgICAgIHJvb3RUYWJsZU5hbWUsXG4gICAgICAgICAgc2VsZWN0RmllbGRzLFxuICAgICAgICAgIHRhYmxlTmFtZTogbmV3VGFibGVOYW1lLFxuICAgICAgICAgIHRhYmxlTmFtZVN1ZmZpeCxcbiAgICAgICAgICB2YWx1ZSxcbiAgICAgICAgfSlcbiAgICAgIH1cblxuICAgICAgY2FzZSAnZ3JvdXAnOiB7XG4gICAgICAgIGlmIChsb2NhbGUgJiYgZmllbGQubG9jYWxpemVkICYmIGFkYXB0ZXIucGF5bG9hZC5jb25maWcubG9jYWxpemF0aW9uKSB7XG4gICAgICAgICAgbmV3VGFibGVOYW1lID0gYCR7dGFibGVOYW1lfV9sb2NhbGVzYFxuXG4gICAgICAgICAgam9pbnNbdGFibGVOYW1lXSA9IGVxKFxuICAgICAgICAgICAgYWRhcHRlci50YWJsZXNbdGFibGVOYW1lXS5pZCxcbiAgICAgICAgICAgIGFkYXB0ZXIudGFibGVzW25ld1RhYmxlTmFtZV0uX3BhcmVudElELFxuICAgICAgICAgIClcbiAgICAgICAgICBpZiAobG9jYWxlICE9PSAnYWxsJykge1xuICAgICAgICAgICAgY29uc3RyYWludHMucHVzaCh7XG4gICAgICAgICAgICAgIGNvbHVtbk5hbWU6ICdfbG9jYWxlJyxcbiAgICAgICAgICAgICAgdGFibGU6IGFkYXB0ZXIudGFibGVzW25ld1RhYmxlTmFtZV0sXG4gICAgICAgICAgICAgIHZhbHVlOiBsb2NhbGUsXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZ2V0VGFibGVDb2x1bW5Gcm9tUGF0aCh7XG4gICAgICAgICAgYWRhcHRlcixcbiAgICAgICAgICBhbGlhc1RhYmxlLFxuICAgICAgICAgIGNvbGxlY3Rpb25QYXRoLFxuICAgICAgICAgIGNvbHVtblByZWZpeDogYCR7Y29sdW1uUHJlZml4fSR7ZmllbGQubmFtZX1fYCxcbiAgICAgICAgICBjb25zdHJhaW50UGF0aDogYCR7Y29uc3RyYWludFBhdGh9JHtmaWVsZC5uYW1lfS5gLFxuICAgICAgICAgIGNvbnN0cmFpbnRzLFxuICAgICAgICAgIGZpZWxkczogZmllbGQuZmllbGRzLFxuICAgICAgICAgIGpvaW5BbGlhc2VzLFxuICAgICAgICAgIGpvaW5zLFxuICAgICAgICAgIGxvY2FsZSxcbiAgICAgICAgICBwYXRoU2VnbWVudHM6IHBhdGhTZWdtZW50cy5zbGljZSgxKSxcbiAgICAgICAgICByb290VGFibGVOYW1lLFxuICAgICAgICAgIHNlbGVjdEZpZWxkcyxcbiAgICAgICAgICB0YWJsZU5hbWU6IG5ld1RhYmxlTmFt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AgICAgICAgICAgIGFkYXB0ZXIudGFibGVzW3RhYmxlTmFtZV0uaWQsXG4gICAgICAgICAgICBhZGFwdGVyLnRhYmxlc1tuZXdUYWJsZU5hbWVdLl9wYXJlbnRJRCxcbiAgICAgICAgICApXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGdldFRhYmxlQ29sdW1uRnJvbVBhdGgoe1xuICAgICAgICAgIGFkYXB0ZXIsXG4gICAgICAgICAgY29sbGVjdGlvblBhdGgsXG4gICAgICAgICAgY29uc3RyYWludFBhdGgsXG4gICAgICAgICAgY29uc3RyYWludHMsXG4gICAgICAgICAgZmllbGRzOiBmaWVsZC5maWVsZHMsXG4gICAgICAgICAgam9pbkFsaWFzZXMsXG4gICAgICAgICAgam9pbnMsXG4gICAgICAgICAgbG9jYWxlLFxuICAgICAgICAgIHBhdGhTZWdtZW50czogcGF0aFNlZ21lbnRzLnNsaWNlKDEpLFxuICAgICAgICAgIHJvb3RUYWJsZU5hbWUsXG4gICAgICAgICAgc2VsZWN0RmllbGRzLFxuICAgICAgICAgIHRhYmxlTmFtZTogbmV3VGFibGVOYW1lLFxuICAgICAgICAgIHZhbHVlLFxuICAgICAgICB9KVxuICAgICAgfVxuXG4gICAgICBjYXNlICdibG9ja3MnOiB7XG4gICAgICAgIGxldCBibG9ja1RhYmxlQ29sdW1uOiBUYWJsZUNvbHVtblxuICAgICAgICBsZXQgbmV3VGFibGVOYW1lOiBzdHJpbmdcblxuICAgICAgICAvLyBoYW5kbGUgYmxvY2tUeXBlIHF1ZXJpZXNcbiAgICAgICAgaWYgKHBhdGhTZWdtZW50c1sxXSA9PT0gJ2Jsb2NrVHlwZScpIHtcbiAgICAgICAgICAvLyBmaW5kIHRoZSBibG9jayBjb25maWcgdXNpbmcgdGhlIHZhbHVlXG4gICAgICAgICAgY29uc3QgYmxvY2tUeXBlcyA9IEFycmF5LmlzQXJyYXkodmFsdWUpID8gdmFsdWUgOiBbdmFsdWVdXG4gICAgICAgICAgYmxvY2tUeXBlcy5mb3JFYWNoKChibG9ja1R5cGUpID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGJsb2NrID0gZmllbGQuYmxvY2tzLmZpbmQoKGJsb2NrKSA9PiBibG9jay5zbHVnID09PSBibG9ja1R5cGUpXG4gICAgICAgICAgICBuZXdUYWJsZU5hbWUgPSBgJHt0YWJsZU5hbWV9X2Jsb2Nrc18ke3RvU25ha2VDYXNlKGJsb2NrLnNsdWcpfWBcbiAgICAgICAgICAgIGpvaW5zW25ld1RhYmxlTmFtZV0gPSBlcShcbiAgICAgICAgICAgICAgYWRhcHRlci50YWJsZXNbdGFibGVOYW1lXS5pZCxcbiAgICAgICAgICAgICAgYWRhcHRlci50YWJsZXNbbmV3VGFibGVOYW1lXS5fcGFyZW50SUQsXG4gICAgICAgICAgICApXG4gICAgICAgICAgICBjb25zdHJhaW50cy5wdXNoKHtcbiAgICAgICAgICAgICAgY29sdW1uTmFtZTogJ19wYXRoJyxcbiAgICAgICAgICAgICAgdGFibGU6IGFkYXB0ZXIudGFibGVzW25ld1RhYmxlTmFtZV0sXG4gICAgICAgICAgICAgIHZhbHVlOiBwYXRoU2VnbWVudHNbMF0sXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH0pXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNvbnN0cmFpbnRzLFxuICAgICAgICAgICAgZmllbGQsXG4gICAgICAgICAgICBnZXROb3ROdWxsQ29sdW1uQnlWYWx1ZTogKCkgPT4gJ2lkJyxcbiAgICAgICAgICAgIHRhYmxlOiBhZGFwdGVyLnRhYmxlc1t0YWJsZU5hbWVdLFxuICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGhhc0Jsb2NrRmllbGQgPSBmaWVsZC5ibG9ja3Muc29tZSgoYmxvY2spID0+IHtcbiAgICAgICAgICBuZXdUYWJsZU5hbWUgPSBgJHt0YWJsZU5hbWV9X2Jsb2Nrc18ke3RvU25ha2VDYXNlKGJsb2NrLnNsdWcpfWBcbiAgICAgICAgICBjb25zdHJhaW50UGF0aCA9IGAke2NvbnN0cmFpbnRQYXRofSR7ZmllbGQubmFtZX0uJS5gXG4gICAgICAgICAgbGV0IHJlc3VsdFxuICAgICAgICAgIGNvbnN0IGJsb2NrQ29uc3RyYWludHMgPSBbXVxuICAgICAgICAgIGNvbnN0IGJsb2NrU2VsZWN0RmllbGRzID0ge31cbiAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmVzdWx0ID0gZ2V0VGFibGVDb2x1bW5Gcm9tUGF0aCh7XG4gICAgICAgICAgICAgIGFkYXB0ZXIsXG4gICAgICAgICAgICAgIGNvbGxlY3Rpb25QYXRoLFxuICAgICAgICAgICAgICBjb25zdHJhaW50UGF0aCxcbiAgICAgICAgICAgICAgY29uc3RyYWludHM6IGJsb2NrQ29uc3RyYWludHMsXG4gICAgICAgICAgICAgIGZpZWxkczogYmxvY2suZmllbGRzLFxuICAgICAgICAgICAgICBqb2luQWxpYXNlcyxcbiAgICAgICAgICAgICAgam9pbnMsXG4gICAgICAgICAgICAgIGxvY2FsZSxcbiAgICAgICAgICAgICAgcGF0aFNlZ21lbnRzOiBwYXRoU2VnbWVudHMuc2xpY2UoMSksXG4gICAgICAgICAgICAgIHJvb3RUYWJsZU5hbWUsXG4gICAgICAgICAgICAgIHNlbGVjdEZpZWxkczogYmxvY2tTZWxlY3RGaWVsZHMsXG4gICAgICAgICAgICAgIHRhYmxlTmFtZTogbmV3VGFibGVOYW1lLFxuICAgICAgICAgICAgICB2YWx1ZSxcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICAgIC8vIHRoaXMgaXMgZmluZSwgbm90IGV2ZXJ5IGJsb2NrIHdpbGwgaGF2ZSB0aGUgZmllbGRcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKCFyZXN1bHQpIHtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIH1cbiAgICAgICAgICBibG9ja1RhYmxlQ29sdW1uID0gcmVzdWx0XG4gICAgICAgICAgY29uc3RyYWludHMgPSBjb25zdHJhaW50cy5jb25jYXQoYmxvY2tDb25zdHJhaW50cylcbiAgICAgICAgICBzZWxlY3RGaWVsZHMgPSB7IC4uLnNlbGVjdEZpZWxkcywgLi4uYmxvY2tTZWxlY3RGaWVsZHMgfVxuICAgICAgICAgIGlmIChmaWVsZC5sb2NhbGl6ZWQgJiYgYWRhcHRlci5wYXlsb2FkLmNvbmZpZy5sb2NhbGl6YXRpb24pIHtcbiAgICAgICAgICAgIGpvaW5zW25ld1RhYmxlTmFtZV0gPSBhbmQoXG4gICAgICAgICAgICAgIGVxKGFkYXB0ZXIudGFibGVzW3RhYmxlTmFtZV0uaWQsIGFkYXB0ZXIudGFibGVzW25ld1RhYmxlTmFtZV0uX3BhcmVudElEKSxcbiAgICAgICAgICAgICAgZXEoYWRhcHRlci50YWJsZXNbbmV3VGFibGVOYW1lXS5fbG9jYWxlLCBsb2NhbGUpLFxuICAgICAgICAgICAgKVxuICAgICAgICAgICAgaWYgKGxvY2FsZSkge1xuICAgICAgICAgICAgICBjb25zdHJhaW50cy5wdXNoKHtcbiAgICAgICAgICAgICAgICBjb2x1bW5OYW1lOiAnX2xvY2FsZScsXG4gICAgICAgICAgICAgICAgdGFibGU6IGFkYXB0ZXIudGFibGVzW25ld1RhYmxlTmFtZV0sXG4gICAgICAgICAgICAgICAgdmFsdWU6IGxvY2FsZSxcbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgam9pbnNbbmV3VGFibGVOYW1lXSA9IGVxKFxuICAgICAgICAgICAgICBhZGFwdGVyLnRhYmxlc1t0YWJsZU5hbWVdLmlkLFxuICAgICAgICAgICAgICBhZGFwdGVyLnRhYmxlc1tuZXdUYWJsZU5hbWVdLl9wYXJlbnRJRCxcbiAgICAgICAgICAgIClcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHRydWVcbiAgICAgICAgfSlcbiAgICAgICAgaWYgKGhhc0Jsb2NrRmllbGQpIHtcbiAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgY29sdW1uTmFtZTogYmxvY2tUYWJsZUNvbHVtbi5jb2x1bW5OYW1lLFxuICAgICAgICAgICAgY29uc3RyYWludHMsXG4gICAgICAgICAgICBmaWVsZDogYmxvY2tUYWJsZUNvbHVtbi5maWVsZCxcbiAgICAgICAgICAgIHBhdGhTZWdtZW50czogcGF0aFNlZ21lbnRzLnNsaWNlKDEpLFxuICAgICAgICAgICAgcmF3Q29sdW1uOiBibG9ja1RhYmxlQ29sdW1uLnJhd0NvbHVtbixcbiAgICAgICAgICAgIHRhYmxlOiBibG9ja1RhYmxlQ29sdW1uLnRhYmxlLFxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBicmVha1xuICAgICAgfVxuXG4gICAgICBjYXNlICdyZWxhdGlvbnNoaXAnOlxuICAgICAgY2FzZSAndXBsb2FkJzoge1xuICAgICAgICBsZXQgcmVsYXRpb25zaGlwRmllbGRzXG4gICAgICAgIGNvbnN0IHJlbGF0aW9uVGFibGVOYW1lID0gYCR7cm9vdFRhYmxlTmFtZX1fcmVsc2BcbiAgICAgICAgY29uc3QgbmV3Q29sbGVjdGlvblBhdGggPSBwYXRoU2VnbWVudHMuc2xpY2UoMSkuam9pbignLicpXG4gICAgICAgIGNvbnN0IGFsaWFzUmVsYXRpb25zaGlwVGFibGVOYW1lID0gdXVpZCgpXG4gICAgICAgIGNvbnN0IGFsaWFzUmVsYXRpb25zaGlwVGFibGUgPSBhbGlhcyhcbiAgICAgICAgICBhZGFwdGVyLnRhYmxlc1tyZWxhdGlvblRhYmxlTmFtZV0sXG4gICAgICAgICAgYWxpYXNSZWxhdGlvbnNoaXBUYWJsZU5hbWUsXG4gICAgICAgIClcblxuICAgICAgICAvLyBKb2luIGluIHRoZSByZWxhdGlvbnNoaXBzIHRh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uaWQsIGFsaWFzUmVsYXRpb25zaGlwVGFibGVbYCR7ZmllbGQucmVsYXRpb25Ub31JRGBdKSxcbiAgICAgICAgICAgIHRhYmxlOiBuZXdBbGlhc1RhYmxlLFxuICAgICAgICAgIH0pXG5cbiAgICAgICAgICBpZiAobmV3Q29sbGVjdGlvblBhdGggPT09ICcnIHx8IG5ld0NvbGxlY3Rpb25QYXRoID09PSAnaWQnKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBjb2x1bW5OYW1lOiBgJHtmaWVsZC5yZWxhdGlvblRvfUlEYCxcbiAgICAgICAgICAgICAgY29uc3RyYWludHMsXG4gICAgICAgICAgICAgIGZpZWxkLFxuICAgICAgICAgICAgICB0YWJsZTogYWxpYXNSZWxhdGlvbnNoaXBUYWJsZSxcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAobmV3Q29sbGVjdGlvblBhdGggPT09ICd2YWx1ZScpIHtcbiAgICAgICAgICBjb25zdCB0YWJsZUNvbHVtbnNOYW1lcyA9IGZpZWxkLnJlbGF0aW9uVG8ubWFwKFxuICAgICAgICAgICAgKHJlbGF0aW9uVG8pID0+IGBcIiR7YWxpYXNSZWxhdGlvbnNoaXBUYWJsZU5hbWV9XCIuXCIke3RvU25ha2VDYXNlKHJlbGF0aW9uVG8pfV9pZFwiYCxcbiAgICAgICAgICApXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNvbnN0cmFpbnRzLFxuICAgICAgICAgICAgZmllbGQsXG4gICAgICAgICAgICByYXdDb2x1bW46IHNxbC5yYXcoYENPQUxFU0NFKCR7dGFibGVDb2x1bW5zTmFtZXMuam9pbignLCAnKX0pYCksXG4gICAgICAgICAgICB0YWJsZTogYWxpYXNSZWxhdGlvbnNoaXBUYWJsZSxcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAobmV3Q29sbGVjdGlvblBhdGggPT09ICdyZWxhdGlvblRvJykge1xuICAgICAgICAgIGNvbnN0IHJlbGF0aW9uVG8gPSBBcnJheS5pc0FycmF5KGZpZWxkLnJlbGF0aW9uVG8pID8gZmllbGQucmVsYXRpb25UbyA6IFtmaWVsZC5yZWxhdGlvblRvXVxuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNvbnN0cmFpbnRzLFxuICAgICAgICAgICAgZmllbGQsXG4gICAgICAgICAgICBnZXROb3ROdWxsQ29sdW1uQnlWYWx1ZTogKHZhbCkgPT4ge1xuICAgICAgICAgICAgICBjb25zdCBtYXRjaGVkUmVsYXRpb24gPSByZWxhdGlvblRvLmZpbmQoKHJlbGF0aW9uKSA9PiByZWxhdGlvbiA9PT0gdmFsKVxuICAgICAgICAgICAgICBpZiAobWF0Y2hlZFJlbGF0aW9uKSByZXR1cm4gYCR7bWF0Y2hlZFJlbGF0aW9ufUlEYFxuICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgdGFibGU6IGFsaWFzUmVsYXRpb25zaGlwVGFibGUsXG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRocm93IG5ldyBBUElFcnJvcignTm90IHN1cHBvcnRlZCcpXG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZ2V0VGFibGVDb2x1bW5Gcm9tUGF0aCh7XG4gICAgICAgICAgYWRhcHRlcixcbiAgICAgICAgICBhbGlhc1RhYmxlOiBuZXdBbGlhc1RhYmxlLFxuICAgICAgICAgIGNvbGxlY3Rpb25QYXRoOiBuZXdDb2xsZWN0aW9uUGF0aCxcbiAgICAgICAgICBjb25zdHJhaW50cyxcbiAgICAgICAgICBmaWVsZHM6IHJlbGF0aW9uc2hpcEZpZWxkcyxcbiAgICAgICAgICBqb2luQWxpYXNlcyxcbiAgICAgICAgICBqb2lucyxcbiAgICAgICAgICBsb2NhbGUsXG4gICAgICAgICAgcGF0aFNlZ21l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