@payloadcms/drizzle 4.0.0-internal.697830c → 4.0.0-internal.77191e5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +2 -7
- package/dist/createTableName.js.map +1 -1
- package/dist/exports/postgres.d.ts +2 -0
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +2 -0
- package/dist/exports/postgres.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildPolymorphicJoinQuery.d.ts +38 -0
- package/dist/find/buildPolymorphicJoinQuery.d.ts.map +1 -0
- package/dist/find/buildPolymorphicJoinQuery.js +135 -0
- package/dist/find/buildPolymorphicJoinQuery.js.map +1 -0
- package/dist/find/buildPolymorphicJoinWhere.d.ts +20 -0
- package/dist/find/buildPolymorphicJoinWhere.d.ts.map +1 -0
- package/dist/find/buildPolymorphicJoinWhere.js +301 -0
- package/dist/find/buildPolymorphicJoinWhere.js.map +1 -0
- package/dist/find/createPolymorphicJoinWherePlan.d.ts +37 -0
- package/dist/find/createPolymorphicJoinWherePlan.d.ts.map +1 -0
- package/dist/find/createPolymorphicJoinWherePlan.js +191 -0
- package/dist/find/createPolymorphicJoinWherePlan.js.map +1 -0
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +19 -191
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +35 -13
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.d.ts +2 -1
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +12 -2
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts +4 -2
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +21 -7
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.d.ts +2 -1
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +14 -3
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.d.ts +2 -1
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +12 -2
- package/dist/migrateReset.js.map +1 -1
- package/dist/migrateStatus.d.ts +2 -1
- package/dist/migrateStatus.d.ts.map +1 -1
- package/dist/migrateStatus.js +11 -6
- package/dist/migrateStatus.js.map +1 -1
- package/dist/postgres/createDatabase.d.ts.map +1 -1
- package/dist/postgres/createExtensions.d.ts.map +1 -1
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -1
- package/dist/postgres/createJSONQuery/index.js +3 -3
- package/dist/postgres/createJSONQuery/index.js.map +1 -1
- package/dist/postgres/init.d.ts.map +1 -1
- package/dist/postgres/init.js +6 -0
- package/dist/postgres/init.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts +15 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts.map +1 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js +25 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js.map +1 -0
- package/dist/postgres/query/postgresUnaccent.d.ts +13 -0
- package/dist/postgres/query/postgresUnaccent.d.ts.map +1 -0
- package/dist/postgres/query/postgresUnaccent.js +40 -0
- package/dist/postgres/query/postgresUnaccent.js.map +1 -0
- package/dist/postgres/schema/buildDrizzleTable.d.ts.map +1 -1
- package/dist/postgres/schema/geometryColumn.d.ts +2 -2
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -1
- package/dist/postgres/types.d.ts +13 -2
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/queries/addJoinTable.d.ts +1 -1
- package/dist/queries/addJoinTable.d.ts.map +1 -1
- package/dist/queries/buildOperatorConstraint.d.ts +22 -0
- package/dist/queries/buildOperatorConstraint.d.ts.map +1 -0
- package/dist/queries/buildOperatorConstraint.js +63 -0
- package/dist/queries/buildOperatorConstraint.js.map +1 -0
- package/dist/queries/buildOrderBy.d.ts +1 -1
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/getTableAlias.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +12 -3
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +59 -27
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/operatorMap.d.ts +7 -3
- package/dist/queries/operatorMap.d.ts.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +262 -10
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/resolveRelationshipPath.d.ts +36 -0
- package/dist/queries/resolveRelationshipPath.d.ts.map +1 -0
- package/dist/queries/resolveRelationshipPath.js +66 -0
- package/dist/queries/resolveRelationshipPath.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/validateOperatorHandlers.d.ts +8 -0
- package/dist/queries/validateOperatorHandlers.d.ts.map +1 -0
- package/dist/queries/validateOperatorHandlers.js +30 -0
- package/dist/queries/validateOperatorHandlers.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/buildDrizzleRelations.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +5 -5
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js +3 -2
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js.map +1 -1
- package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/index.js +6 -5
- package/dist/sqlite/createJSONQuery/index.js.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/numbers.d.ts.map +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/selects.d.ts.map +1 -1
- package/dist/transform/write/texts.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +8 -14
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +50 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +37 -0
- package/dist/updateJobs.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +41 -1
- package/dist/updateOne.js.map +1 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/handleUpsertError.d.ts.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +25 -5
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts.map +1 -1
- package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.d.ts.map +1 -1
- package/dist/utilities/buildCreateMigration.d.ts.map +1 -1
- package/dist/utilities/buildCreateMigration.js +12 -8
- package/dist/utilities/buildCreateMigration.js.map +1 -1
- package/dist/utilities/buildForeignKeyName.d.ts.map +1 -1
- package/dist/utilities/buildForeignKeyName.js +3 -2
- package/dist/utilities/buildForeignKeyName.js.map +1 -1
- package/dist/utilities/buildIndexName.d.ts.map +1 -1
- package/dist/utilities/buildIndexName.js +3 -2
- package/dist/utilities/buildIndexName.js.map +1 -1
- package/dist/utilities/checkTruncatedIdentifiers.d.ts +13 -0
- package/dist/utilities/checkTruncatedIdentifiers.d.ts.map +1 -0
- package/dist/utilities/checkTruncatedIdentifiers.js +56 -0
- package/dist/utilities/checkTruncatedIdentifiers.js.map +1 -0
- package/dist/utilities/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.js +3 -0
- package/dist/utilities/createSchemaGenerator.js.map +1 -1
- package/dist/utilities/escapeSQLValue.d.ts.map +1 -1
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -1
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getArrayRelationName.d.ts.map +1 -1
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -1
- package/dist/utilities/getMigrationTemplate.d.ts.map +1 -1
- package/dist/utilities/getNameFromDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getPrimaryDb.d.ts +1 -1
- package/dist/utilities/getPrimaryDb.d.ts.map +1 -1
- package/dist/utilities/getTransaction.d.ts +1 -1
- package/dist/utilities/getTransaction.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -1
- package/dist/utilities/isUUIDType.d.ts.map +1 -1
- package/dist/utilities/json.d.ts.map +1 -1
- package/dist/utilities/migrationTableExists.d.ts.map +1 -1
- package/dist/utilities/parseError.d.ts.map +1 -1
- package/dist/utilities/parseJSONPathSegment.d.ts +9 -0
- package/dist/utilities/parseJSONPathSegment.d.ts.map +1 -0
- package/dist/utilities/parseJSONPathSegment.js +17 -0
- package/dist/utilities/parseJSONPathSegment.js.map +1 -0
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/rawConstraint.d.ts.map +1 -1
- package/dist/utilities/sanitizePathSegment.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +1 -5
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/utilities/validateIdentifierLength.d.ts +12 -0
- package/dist/utilities/validateIdentifierLength.d.ts.map +1 -0
- package/dist/utilities/validateIdentifierLength.js +18 -0
- package/dist/utilities/validateIdentifierLength.js.map +1 -0
- package/package.json +3 -3
- package/dist/upsertRow/handleUpsertError.spec.js +0 -42
- package/dist/upsertRow/handleUpsertError.spec.js.map +0 -1
- package/dist/utilities/isValidStringID.spec.js +0 -15
- package/dist/utilities/isValidStringID.spec.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildCreateMigration.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type { CreateMigration
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildCreateMigration.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nexport const buildCreateMigration = ({\n executeMethod,\n filename,\n sanitizeStatements,\n}: {\n executeMethod: string\n filename: string\n sanitizeStatements: (args: { sqlExecute: string; statements: string[] }) => string\n}): CreateMigration => {\n const dirname = path.dirname(filename)\n return async function createMigration(\n this: DrizzleAdapter,\n { file, forceAcceptWarning, migrationName, payload, shouldPrompt = true, skipEmpty },\n ) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n const { generateDrizzleJson, generateMigration, upSnapshot } = this.requireDrizzleKit()\n\n const drizzleJsonAfter = await generateDrizzleJson(this.schema)\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n\n const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n imports = predefinedMigration.imports\n downSQL = predefinedMigration.downSQL\n upSQL = predefinedMigration.upSQL\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n if (typeof predefinedMigration.dynamic === 'function') {\n const dynamicResult = await predefinedMigration.dynamic({ filePath, payload })\n\n if (dynamicResult.upSQL) {\n upSQL = dynamicResult.upSQL\n }\n\n if (dynamicResult.downSQL) {\n downSQL = dynamicResult.downSQL\n }\n\n if (dynamicResult.imports) {\n imports = dynamicResult.imports\n }\n }\n\n let drizzleJsonBefore = this.defaultDrizzleSnapshot as DrizzleSnapshotJSON\n\n if (this.schemaName) {\n drizzleJsonBefore.schemas = {\n [this.schemaName]: this.schemaName,\n }\n }\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'))\n\n if (upSnapshot && drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upSnapshot(drizzleJsonBefore)\n }\n }\n\n payload.logger.info('Starting migration: generating UP statements...')\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n\n payload.logger.info('Migration UP complete. Generating DOWN statements...')\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n\n payload.logger.info('Migration DOWN statements generation complete.')\n\n const sqlExecute = `await db.${executeMethod}(` + 'sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsUp })\n }\n if (sqlStatementsDown?.length) {\n downSQL = sanitizeStatements({ sqlExecute, statements: sqlStatementsDown })\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n if (skipEmpty || !shouldPrompt) {\n return { created: false }\n }\n\n const { confirm: shouldCreateBlankMigration } = await prompts({\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n })\n\n if (!shouldCreateBlankMigration) {\n return { created: false }\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n const data = getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n packageName: payload.db.packageName,\n upSQL: upSQL || ` // Migration code`,\n })\n\n const fullPath = `${filePath}.ts`\n\n // write migration\n fs.writeFileSync(fullPath, data)\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${fullPath}` })\n\n return { created: true, path: fullPath }\n }\n}\n"],"names":["fs","path","getPredefinedMigration","writeMigrationIndex","prompts","getMigrationTemplate","buildCreateMigration","executeMethod","filename","sanitizeStatements","dirname","createMigration","file","forceAcceptWarning","migrationName","payload","shouldPrompt","skipEmpty","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upSnapshot","requireDrizzleKit","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","predefinedMigration","timestamp","name","slice","join","fileName","filePath","dynamic","dynamicResult","drizzleJsonBefore","defaultDrizzleSnapshot","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","logger","info","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","statements","created","confirm","shouldCreateBlankMigration","type","initial","message","writeFileSync","stringify","data","packageName","fullPath","migrationsDir","msg"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,UAAS;AACrE,OAAOC,aAAa,UAAS;AAI7B,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,aAAa,EACbC,QAAQ,EACRC,kBAAkB,EAKnB;IACC,MAAMC,UAAUT,KAAKS,OAAO,CAACF;IAC7B,OAAO,eAAeG,gBAEpB,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,E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O6B,UAAU,CAAC9B,SAAS8B,UAAU,CAACvD,oBAAoB;gBAC7D,IAAII,aAAa,CAACD,cAAc;oBAC9B,OAAO;wBAAEsD,SAAS;oBAAM;gBAC1B;gBAEA,MAAM,EAAEC,SAASC,0BAA0B,EAAE,GAAG,MAAMpE,QAAQ;oBAC5DsC,MAAM;oBACN+B,MAAM;oBACNC,SAAS;oBACTC,SAAS;gBACX;gBAEA,IAAI,CAACH,4BAA4B;oBAC/B,OAAO;wBAAEF,SAAS;oBAAM;gBAC1B;YACF;YAEA,eAAe;YACftE,GAAG4E,aAAa,CAAC,GAAG9B,SAAS,KAAK,CAAC,EAAEa,KAAKkB,SAAS,CAAClD,kBAAkB,MAAM;QAC9E;QAEA,MAAMmD,OAAOzE,qBAAqB;YAChCiC,SAASA,WAAW,CAAC,mBAAmB,CAAC;YACzCD;YACA0C,aAAahE,QAAQI,EAAE,CAAC4D,WAAW;YACnCxC,OAAOA,SAAS,CAAC,mBAAmB,CAAC;QACvC;QAEA,MAAMyC,WAAW,GAAGlC,SAAS,GAAG,CAAC;QAEjC,kBAAkB;QAClB9C,GAAG4E,aAAa,CAACI,UAAUF;QAE3B3E,oBAAoB;YAAE8E,eAAelE,QAAQI,EAAE,CAACC,YAAY;QAAC;QAE7DL,QAAQgD,MAAM,CAACC,IAAI,CAAC;YAAEkB,KAAK,CAAC,qBAAqB,EAAEF,UAAU;QAAC;QAE9D,OAAO;YAAEV,SAAS;YAAMrE,MAAM+E;QAAS;IACzC;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildForeignKeyName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildForeignKeyName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"buildForeignKeyName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildForeignKeyName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,mBAAmB,+BAI7B;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAkBH,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { maxGeneratedIdentifierLength } from './validateIdentifierLength.js';
|
|
1
2
|
export const buildForeignKeyName = ({ name, adapter, number = 0 })=>{
|
|
2
3
|
let foreignKeyName = `${name}${number ? `_${number}` : ''}_fk`;
|
|
3
|
-
if (foreignKeyName.length >
|
|
4
|
+
if (foreignKeyName.length > maxGeneratedIdentifierLength) {
|
|
4
5
|
const suffix = `${number ? `_${number}` : ''}_fk`;
|
|
5
|
-
foreignKeyName = `${name.slice(0,
|
|
6
|
+
foreignKeyName = `${name.slice(0, maxGeneratedIdentifierLength - suffix.length)}${suffix}`;
|
|
6
7
|
}
|
|
7
8
|
if (!adapter.foreignKeys.has(foreignKeyName)) {
|
|
8
9
|
adapter.foreignKeys.add(foreignKeyName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildForeignKeyName.ts"],"sourcesContent":["import type { DrizzleAdapter } from '../types.js'\n\nexport const buildForeignKeyName = ({\n name,\n adapter,\n number = 0,\n}: {\n adapter: DrizzleAdapter\n name: string\n number?: number\n}): string => {\n let foreignKeyName = `${name}${number ? `_${number}` : ''}_fk`\n\n if (foreignKeyName.length >
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildForeignKeyName.ts"],"sourcesContent":["import type { DrizzleAdapter } from '../types.js'\n\nimport { maxGeneratedIdentifierLength } from './validateIdentifierLength.js'\n\nexport const buildForeignKeyName = ({\n name,\n adapter,\n number = 0,\n}: {\n adapter: DrizzleAdapter\n name: string\n number?: number\n}): string => {\n let foreignKeyName = `${name}${number ? `_${number}` : ''}_fk`\n\n if (foreignKeyName.length > maxGeneratedIdentifierLength) {\n const suffix = `${number ? `_${number}` : ''}_fk`\n foreignKeyName = `${name.slice(0, maxGeneratedIdentifierLength - suffix.length)}${suffix}`\n }\n\n if (!adapter.foreignKeys.has(foreignKeyName)) {\n adapter.foreignKeys.add(foreignKeyName)\n return foreignKeyName\n }\n\n return buildForeignKeyName({\n name,\n adapter,\n number: number + 1,\n })\n}\n"],"names":["maxGeneratedIdentifierLength","buildForeignKeyName","name","adapter","number","foreignKeyName","length","suffix","slice","foreignKeys","has","add"],"mappings":"AAEA,SAASA,4BAA4B,QAAQ,gCAA+B;AAE5E,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,IAAI,EACJC,OAAO,EACPC,SAAS,CAAC,EAKX;IACC,IAAIC,iBAAiB,GAAGH,OAAOE,SAAS,CAAC,CAAC,EAAEA,QAAQ,GAAG,GAAG,GAAG,CAAC;IAE9D,IAAIC,eAAeC,MAAM,GAAGN,8BAA8B;QACxD,MAAMO,SAAS,GAAGH,SAAS,CAAC,CAAC,EAAEA,QAAQ,GAAG,GAAG,GAAG,CAAC;QACjDC,iBAAiB,GAAGH,KAAKM,KAAK,CAAC,GAAGR,+BAA+BO,OAAOD,MAAM,IAAIC,QAAQ;IAC5F;IAEA,IAAI,CAACJ,QAAQM,WAAW,CAACC,GAAG,CAACL,iBAAiB;QAC5CF,QAAQM,WAAW,CAACE,GAAG,CAACN;QACxB,OAAOA;IACT;IAEA,OAAOJ,oBAAoB;QACzBC;QACAC;QACAC,QAAQA,SAAS;IACnB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIndexName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildIndexName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"buildIndexName.d.ts","sourceRoot":"","sources":["../../src/utilities/buildIndexName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,cAAc,6CAKxB;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAmBH,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { maxGeneratedIdentifierLength } from './validateIdentifierLength.js';
|
|
1
2
|
export const buildIndexName = ({ name, adapter, appendSuffix = true, number = 0 })=>{
|
|
2
3
|
let indexName = `${name}${number ? `_${number}` : ''}${appendSuffix ? '_idx' : ''}`;
|
|
3
|
-
if (indexName.length >
|
|
4
|
+
if (indexName.length > maxGeneratedIdentifierLength) {
|
|
4
5
|
const suffix = `${number ? `_${number}` : ''}${appendSuffix ? '_idx' : ''}`;
|
|
5
|
-
indexName = `${name.slice(0,
|
|
6
|
+
indexName = `${name.slice(0, maxGeneratedIdentifierLength - suffix.length)}${suffix}`;
|
|
6
7
|
}
|
|
7
8
|
if (!adapter.indexes.has(indexName) && !(indexName in adapter.rawTables)) {
|
|
8
9
|
adapter.indexes.add(indexName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildIndexName.ts"],"sourcesContent":["import type { DrizzleAdapter } from '../types.js'\n\nexport const buildIndexName = ({\n name,\n adapter,\n appendSuffix = true,\n number = 0,\n}: {\n adapter: DrizzleAdapter\n appendSuffix?: boolean\n name: string\n number?: number\n}): string => {\n let indexName = `${name}${number ? `_${number}` : ''}${appendSuffix ? '_idx' : ''}`\n\n if (indexName.length >
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildIndexName.ts"],"sourcesContent":["import type { DrizzleAdapter } from '../types.js'\n\nimport { maxGeneratedIdentifierLength } from './validateIdentifierLength.js'\n\nexport const buildIndexName = ({\n name,\n adapter,\n appendSuffix = true,\n number = 0,\n}: {\n adapter: DrizzleAdapter\n appendSuffix?: boolean\n name: string\n number?: number\n}): string => {\n let indexName = `${name}${number ? `_${number}` : ''}${appendSuffix ? '_idx' : ''}`\n\n if (indexName.length > maxGeneratedIdentifierLength) {\n const suffix = `${number ? `_${number}` : ''}${appendSuffix ? '_idx' : ''}`\n indexName = `${name.slice(0, maxGeneratedIdentifierLength - suffix.length)}${suffix}`\n }\n\n if (!adapter.indexes.has(indexName) && !(indexName in adapter.rawTables)) {\n adapter.indexes.add(indexName)\n return indexName\n }\n\n return buildIndexName({\n name,\n adapter,\n appendSuffix,\n number: number + 1,\n })\n}\n"],"names":["maxGeneratedIdentifierLength","buildIndexName","name","adapter","appendSuffix","number","indexName","length","suffix","slice","indexes","has","rawTables","add"],"mappings":"AAEA,SAASA,4BAA4B,QAAQ,gCAA+B;AAE5E,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,IAAI,EACJC,OAAO,EACPC,eAAe,IAAI,EACnBC,SAAS,CAAC,EAMX;IACC,IAAIC,YAAY,GAAGJ,OAAOG,SAAS,CAAC,CAAC,EAAEA,QAAQ,GAAG,KAAKD,eAAe,SAAS,IAAI;IAEnF,IAAIE,UAAUC,MAAM,GAAGP,8BAA8B;QACnD,MAAMQ,SAAS,GAAGH,SAAS,CAAC,CAAC,EAAEA,QAAQ,GAAG,KAAKD,eAAe,SAAS,IAAI;QAC3EE,YAAY,GAAGJ,KAAKO,KAAK,CAAC,GAAGT,+BAA+BQ,OAAOD,MAAM,IAAIC,QAAQ;IACvF;IAEA,IAAI,CAACL,QAAQO,OAAO,CAACC,GAAG,CAACL,cAAc,CAAEA,CAAAA,aAAaH,QAAQS,SAAS,AAAD,GAAI;QACxET,QAAQO,OAAO,CAACG,GAAG,CAACP;QACpB,OAAOA;IACT;IAEA,OAAOL,eAAe;QACpBC;QACAC;QACAC;QACAC,QAAQA,SAAS;IACnB;AACF,EAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DrizzleAdapter } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Warns about identifiers Postgres will silently truncate past 63 chars, and throws
|
|
4
|
+
* when two of them truncate to the same name (a schema Postgres can't create anyway).
|
|
5
|
+
*
|
|
6
|
+
* Base table/enum names throw during construction, so this only covers concatenated
|
|
7
|
+
* identifiers: companion tables, columns, and inline index/foreign key names.
|
|
8
|
+
*/
|
|
9
|
+
export declare const checkTruncatedIdentifiers: ({ adapter, logWarnings, }: {
|
|
10
|
+
adapter: Pick<DrizzleAdapter, 'payload' | 'rawTables'>;
|
|
11
|
+
logWarnings: boolean;
|
|
12
|
+
}) => void;
|
|
13
|
+
//# sourceMappingURL=checkTruncatedIdentifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTruncatedIdentifiers.d.ts","sourceRoot":"","sources":["../../src/utilities/checkTruncatedIdentifiers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAOjD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,8BAGnC;IACD,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,WAAW,CAAC,CAAA;IACtD,WAAW,EAAE,OAAO,CAAA;CACrB,KAAG,IAgEH,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
2
|
+
import { maxIdentifierLength } from './validateIdentifierLength.js';
|
|
3
|
+
const truncate = (name)=>name.length > maxIdentifierLength ? name.slice(0, maxIdentifierLength) : name;
|
|
4
|
+
/**
|
|
5
|
+
* Warns about identifiers Postgres will silently truncate past 63 chars, and throws
|
|
6
|
+
* when two of them truncate to the same name (a schema Postgres can't create anyway).
|
|
7
|
+
*
|
|
8
|
+
* Base table/enum names throw during construction, so this only covers concatenated
|
|
9
|
+
* identifiers: companion tables, columns, and inline index/foreign key names.
|
|
10
|
+
*/ export const checkTruncatedIdentifiers = ({ adapter, logWarnings })=>{
|
|
11
|
+
const truncatedNames = new Set();
|
|
12
|
+
const collisions = new Set();
|
|
13
|
+
// finalName -> originalName, per namespace, to detect post-truncation collisions
|
|
14
|
+
const tableNames = new Map();
|
|
15
|
+
const indexNames = new Map();
|
|
16
|
+
const foreignKeyNames = new Map();
|
|
17
|
+
const check = (original, seen)=>{
|
|
18
|
+
const final = truncate(original);
|
|
19
|
+
const existing = seen.get(final);
|
|
20
|
+
if (existing !== undefined && existing !== original) {
|
|
21
|
+
collisions.add(`"${existing}" and "${original}" both become "${final}"`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
seen.set(final, original);
|
|
25
|
+
if (final !== original) {
|
|
26
|
+
truncatedNames.add(original);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
for(const tableName in adapter.rawTables){
|
|
30
|
+
const table = adapter.rawTables[tableName];
|
|
31
|
+
check(table.name, tableNames);
|
|
32
|
+
// Columns only collide with other columns in the same table.
|
|
33
|
+
const columnNames = new Map();
|
|
34
|
+
for(const columnKey in table.columns){
|
|
35
|
+
check(table.columns[columnKey].name, columnNames);
|
|
36
|
+
}
|
|
37
|
+
if (table.indexes) {
|
|
38
|
+
for(const indexKey in table.indexes){
|
|
39
|
+
check(table.indexes[indexKey].name, indexNames);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (table.foreignKeys) {
|
|
43
|
+
for(const foreignKeyKey in table.foreignKeys){
|
|
44
|
+
check(table.foreignKeys[foreignKeyKey].name, foreignKeyNames);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (collisions.size > 0) {
|
|
49
|
+
throw new APIError(`Multiple identifiers exceed Postgres's ${maxIdentifierLength}-character limit and truncate to the same name, which Postgres cannot create: ${Array.from(collisions).join('; ')}. Use the dbName property to give them shorter, distinct names.`);
|
|
50
|
+
}
|
|
51
|
+
if (logWarnings && truncatedNames.size > 0) {
|
|
52
|
+
adapter.payload.logger.warn(`The following identifiers exceed Postgres's ${maxIdentifierLength}-character limit and will be silently truncated, which can leave the database out of sync with your Payload schema: ${Array.from(truncatedNames).join(', ')}. Use the dbName property to shorten them.`);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=checkTruncatedIdentifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/checkTruncatedIdentifiers.ts"],"sourcesContent":["import { APIError } from 'payload'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { maxIdentifierLength } from './validateIdentifierLength.js'\n\nconst truncate = (name: string): string =>\n name.length > maxIdentifierLength ? name.slice(0, maxIdentifierLength) : name\n\n/**\n * Warns about identifiers Postgres will silently truncate past 63 chars, and throws\n * when two of them truncate to the same name (a schema Postgres can't create anyway).\n *\n * Base table/enum names throw during construction, so this only covers concatenated\n * identifiers: companion tables, columns, and inline index/foreign key names.\n */\nexport const checkTruncatedIdentifiers = ({\n adapter,\n logWarnings,\n}: {\n adapter: Pick<DrizzleAdapter, 'payload' | 'rawTables'>\n logWarnings: boolean\n}): void => {\n const truncatedNames = new Set<string>()\n const collisions = new Set<string>()\n\n // finalName -> originalName, per namespace, to detect post-truncation collisions\n const tableNames = new Map<string, string>()\n const indexNames = new Map<string, string>()\n const foreignKeyNames = new Map<string, string>()\n\n const check = (original: string, seen: Map<string, string>) => {\n const final = truncate(original)\n\n const existing = seen.get(final)\n if (existing !== undefined && existing !== original) {\n collisions.add(`\"${existing}\" and \"${original}\" both become \"${final}\"`)\n return\n }\n\n seen.set(final, original)\n\n if (final !== original) {\n truncatedNames.add(original)\n }\n }\n\n for (const tableName in adapter.rawTables) {\n const table = adapter.rawTables[tableName]\n\n check(table.name, tableNames)\n\n // Columns only collide with other columns in the same table.\n const columnNames = new Map<string, string>()\n for (const columnKey in table.columns) {\n check(table.columns[columnKey].name, columnNames)\n }\n\n if (table.indexes) {\n for (const indexKey in table.indexes) {\n check(table.indexes[indexKey].name, indexNames)\n }\n }\n\n if (table.foreignKeys) {\n for (const foreignKeyKey in table.foreignKeys) {\n check(table.foreignKeys[foreignKeyKey].name, foreignKeyNames)\n }\n }\n }\n\n if (collisions.size > 0) {\n throw new APIError(\n `Multiple identifiers exceed Postgres's ${maxIdentifierLength}-character limit and truncate to the same name, which Postgres cannot create: ${Array.from(\n collisions,\n ).join('; ')}. Use the dbName property to give them shorter, distinct names.`,\n )\n }\n\n if (logWarnings && truncatedNames.size > 0) {\n adapter.payload.logger.warn(\n `The following identifiers exceed Postgres's ${maxIdentifierLength}-character limit and will be silently truncated, which can leave the database out of sync with your Payload schema: ${Array.from(\n truncatedNames,\n ).join(', ')}. Use the dbName property to shorten them.`,\n )\n }\n}\n"],"names":["APIError","maxIdentifierLength","truncate","name","length","slice","checkTruncatedIdentifiers","adapter","logWarnings","truncatedNames","Set","collisions","tableNames","Map","indexNames","foreignKeyNames","check","original","seen","final","existing","get","undefined","add","set","tableName","rawTables","table","columnNames","columnKey","columns","indexes","indexKey","foreignKeys","foreignKeyKey","size","Array","from","join","payload","logger","warn"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAIlC,SAASC,mBAAmB,QAAQ,gCAA+B;AAEnE,MAAMC,WAAW,CAACC,OAChBA,KAAKC,MAAM,GAAGH,sBAAsBE,KAAKE,KAAK,CAAC,GAAGJ,uBAAuBE;AAE3E;;;;;;CAMC,GACD,OAAO,MAAMG,4BAA4B,CAAC,EACxCC,OAAO,EACPC,WAAW,EAIZ;IACC,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,aAAa,IAAID;IAEvB,iFAAiF;IACjF,MAAME,aAAa,IAAIC;IACvB,MAAMC,aAAa,IAAID;IACvB,MAAME,kBAAkB,IAAIF;IAE5B,MAAMG,QAAQ,CAACC,UAAkBC;QAC/B,MAAMC,QAAQjB,SAASe;QAEvB,MAAMG,WAAWF,KAAKG,GAAG,CAACF;QAC1B,IAAIC,aAAaE,aAAaF,aAAaH,UAAU;YACnDN,WAAWY,GAAG,CAAC,CAAC,CAAC,EA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"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,SAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,SAyC/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,SAAU,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAqBrF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,4GAO/B;IACD,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,cAmTH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createSchemaGenerator.ts"],"sourcesContent":["import type { GenerateSchema } from 'payload'\n\nimport { existsSync } from 'fs'\nimport { writeFile } from 'fs/promises'\nimport path from 'path'\n\nimport type { ColumnToCodeConverter, DrizzleAdapter } from '../types.js'\n\n/**\n * @example\n * console.log(sanitizeObjectKey(\"oneTwo\")); // oneTwo\n * console.log(sanitizeObjectKey(\"one-two\")); // 'one-two'\n * console.log(sanitizeObjectKey(\"_one$Two3\")); // _one$Two3\n * console.log(sanitizeObjectKey(\"3invalid\")); // '3invalid'\n */\nconst sanitizeObjectKey = (key: string) => {\n // Regular expression for a valid identifier\n const identifierRegex = /^[a-z_$][\\w$]*$/i\n if (identifierRegex.test(key)) {\n return key\n }\n\n return `'${key}'`\n}\n\n/**\n * @example\n * (columns default-valuesID) -> columns['default-valuesID']\n * (columns defaultValues) -> columns.defaultValues\n */\nconst accessProperty = (objName: string, key: string) => {\n const sanitized = sanitizeObjectKey(key)\n\n if (sanitized.startsWith(\"'\")) {\n return `${objName}[${sanitized}]`\n }\n\n return `${objName}.${key}`\n}\n\nexport const createSchemaGenerator = ({\n columnToCodeConverter,\n corePackageSuffix,\n defaultOutputFile,\n enumImport,\n schemaImport,\n tableImport,\n}: {\n columnToCodeConverter: ColumnToCodeConverter\n corePackageSuffix: string\n defaultOutputFile?: string\n enumImport?: string\n schemaImport?: string\n tableImport: string\n}): GenerateSchema => {\n return async function generateSchema(\n this: DrizzleAdapter,\n { log = true, outputFile = defaultOutputFile, prettify = true } = {},\n ) {\n const importDeclarations: Record<string, Set<string>> = {}\n\n const tableDeclarations: string[] = []\n const enumDeclarations: string[] = []\n const relationsDeclarations: string[] = []\n\n const addImport = (from: string, name: string) => {\n if (!importDeclarations[from]) {\n importDeclarations[from] = new Set()\n }\n\n importDeclarations[from].add(name)\n }\n\n const corePackage = `${this.packageName}/drizzle/${corePackageSuffix}`\n\n let schemaDeclaration: null | string = null\n\n if (this.schemaName) {\n addImport(corePackage, schemaImport)\n schemaDeclaration = `export const db_schema = ${schemaImport}('${this.schemaName}')`\n }\n\n const enumFn = this.schemaName ? `db_schema.enum` : enumImport\n\n const enumsList: string[] = []\n const addEnum = (name: string, options: string[]) => {\n if (enumsList.some((each) => each === name)) {\n return\n }\n enumsList.push(name)\n enumDeclarations.push(\n `export const ${name} = ${enumFn}('${name}', [${options.map((option) => `'${option}'`).join(', ')}])`,\n )\n }\n\n if (this.payload.config.localization && enumImport) {\n addEnum('enum__locales', this.payload.config.localization.localeCodes)\n }\n\n const tableFn = this.schemaName ? `db_schema.table` : tableImport\n\n if (!this.schemaName) {\n addImport(corePackage, tableImport)\n }\n\n addImport(corePackage, 'index')\n addImport(corePackage, 'uniqueIndex')\n addImport(corePackage, 'foreignKey')\n\n addImport(`${this.packageName}/drizzle`, 'sql')\n addImport(`${this.packageName}/drizzle`, 'relations')\n\n const fkGraph: Record<string, Set<string>> = {}\n\n for (const tableName in this.rawTables) {\n fkGraph[tableName] = new Set()\n const table = this.rawTables[tableName]\n\n for (const colKey in table.columns) {\n const col = table.columns[colKey]\n\n if (col.reference && col.reference.table !== tableName) {\n fkGraph[tableName].add(col.reference.table)\n }\n }\n }\n\n const canReach = (from: string, target: string, visited: Set<string>): boolean => {\n if (from === target) {\n return true\n }\n\n if (visited.has(from)) {\n return false\n }\n\n visited.add(from)\n\n for (const neighbor of fkGraph[from] ?? []) {\n if (canReach(neighbor, target, visited)) {\n return true\n }\n }\n\n return false\n }\n\n const circularEdges = new Set<string>()\n\n for (const tableA in fkGraph) {\n for (const tableB of fkGraph[tableA]) {\n if (canReach(tableB, tableA, new Set())) {\n circularEdges.add(`${tableA}:${tableB}`)\n }\n }\n }\n\n for (const tableName in this.rawTables) {\n const table = this.rawTables[tableName]\n\n const extrasDeclarations: string[] = []\n\n if (table.indexes) {\n for (const key in table.indexes) {\n const index = table.indexes[key]\n let indexDeclaration = `${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`\n indexDeclaration += `.on(${typeof index.on === 'string' ? `${accessProperty('columns', index.on)}` : `${index.on.map((on) => `${accessProperty('columns', on)}`).join(', ')}`}),`\n extrasDeclarations.push(indexDeclaration)\n }\n }\n\n if (table.foreignKeys) {\n for (const key in table.foreignKeys) {\n const foreignKey = table.foreignKeys[key]\n\n let foreignKeyDeclaration = `foreignKey({\n columns: [${foreignKey.columns.map((col) => `columns['${col}']`).join(', ')}],\n foreignColumns: [${foreignKey.foreignColumns.map((col) => `${accessProperty(col.table, col.name)}`).join(', ')}],\n name: '${foreignKey.name}'\n })`\n\n if (foreignKey.onDelete) {\n foreignKeyDeclaration += `.onDelete('${foreignKey.onDelete}')`\n }\n if (foreignKey.onUpdate) {\n foreignKeyDeclaration += `.onUpdate('${foreignKey.onDelete}')`\n }\n\n foreignKeyDeclaration += ','\n\n extrasDeclarations.push(foreignKeyDeclaration)\n }\n }\n\n const tableCode = `\nexport const ${tableName} = ${tableFn}('${tableName}', {\n${Object.entries(table.columns)\n .map(\n ([key, column]) =>\n ` ${sanitizeObjectKey(key)}: ${columnToCodeConverter({\n adapter: this,\n addEnum,\n addImport,\n circularEdges,\n column,\n locales: this.payload.config.localization\n ? this.payload.config.localization.localeCodes\n : undefined,\n tableKey: tableName,\n })},`,\n )\n .join('\\n')}\n}${\n extrasDeclarations.length\n ? `, (columns) => [\n ${extrasDeclarations.join(' ')}\n]`\n : ''\n }\n)\n`\n\n tableDeclarations.push(tableCode)\n }\n\n for (const tableName in this.rawRelations) {\n const relations = this.rawRelations[tableName]\n const properties: string[] = []\n\n for (const key in relations) {\n const relation = relations[key]\n let declaration: string\n\n if (relation.type === 'one') {\n declaration = `${sanitizeObjectKey(key)}: one(${relation.to}, {\n ${relation.fields.some((field) => field.table !== tableName) ? '// @ts-expect-error Drizzle TypeScript bug for ONE relationships with a field in different table' : ''}\n fields: [${relation.fields.map((field) => `${accessProperty(field.table, field.name)}`).join(', ')}],\n references: [${relation.references.map((col) => `${accessProperty(relation.to, col)}`).join(', ')}],\n ${relation.relationName ? `relationName: '${relation.relationName}',` : ''}\n }),`\n } else {\n declaration = `${sanitizeObjectKey(key)}: many(${relation.to}, {\n ${relation.relationName ? `relationName: '${relation.relationName}',` : ''}\n }),`\n }\n\n properties.push(declaration)\n }\n\n // beautify / lintify relations callback output, when no many for example, don't add it\n const args = []\n\n if (Object.values(relations).some((rel) => rel.type === 'one')) {\n args.push('one')\n }\n\n if (Object.values(relations).some((rel) => rel.type === 'many')) {\n args.push('many')\n }\n\n const arg = args.length ? `{ ${args.join(', ')} }` : ''\n\n const declaration = `export const relations_${tableName} = relations(${tableName}, (${arg}) => ({\n ${properties.join('\\n ')}\n }))`\n\n relationsDeclarations.push(declaration)\n }\n\n if (enumDeclarations.length && !this.schemaName) {\n addImport(corePackage, enumImport)\n }\n\n const importDeclarationsSanitized: string[] = []\n\n for (const moduleName in importDeclarations) {\n const moduleImports = importDeclarations[moduleName]\n\n importDeclarationsSanitized.push(\n `import { ${Array.from(moduleImports).join(', ')} } from '${moduleName}'`,\n )\n }\n\n const schemaType = `\ntype DatabaseSchema = {\n ${[\n this.schemaName ? 'db_schema' : null,\n ...enumsList,\n ...Object.keys(this.rawTables),\n ...Object.keys(this.rawRelations).map((table) => `relations_${table}`),\n ]\n .filter(Boolean)\n .map((name) => `${name}: typeof ${name}`)\n .join('\\n ')}\n}\n `\n\n const finalDeclaration = `\ndeclare module '${this.packageName}' {\n export interface GeneratedDatabaseSchema {\n schema: DatabaseSchema\n }\n}\n `\n\n const warning = `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:db-schema\\` to regenerate this file.\n */\n`\n\n const importTypes = `import type {} from '${this.packageName}'`\n\n let code = [\n warning,\n importTypes,\n ...importDeclarationsSanitized,\n schemaDeclaration,\n ...enumDeclarations,\n ...tableDeclarations,\n ...relationsDeclarations,\n schemaType,\n finalDeclaration,\n ]\n .filter(Boolean)\n .join('\\n')\n\n if (!outputFile) {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src')\n\n if (existsSync(srcDir)) {\n outputFile = path.resolve(srcDir, 'payload-generated-schema.ts')\n } else {\n outputFile = path.resolve(cwd, 'payload-generated-schema.ts')\n }\n }\n\n if (prettify) {\n try {\n const prettier = await eval('import(\"prettier\")')\n const configPath = await prettier.resolveConfigFile()\n const config = configPath ? await prettier.resolveConfig(configPath) : {}\n code = await prettier.format(code, { ...config, parser: 'typescript' })\n } catch {\n /* empty */\n }\n }\n\n await writeFile(outputFile, code, 'utf-8')\n\n if (log) {\n this.payload.logger.info(`Written ${outputFile}`)\n }\n }\n}\n"],"names":["existsSync","writeFile","path","sanitizeObjectKey","key","identifierRegex","test","accessProperty","objName","sanitized","startsWith","createSchemaGenerator","columnToCodeConverter","corePackageSuffix","defaultOutputFile","enumImport","schemaImport","tableImport","generateSchema","log","outputFile","prettify","importDeclarations","tableDeclarations","enumDeclarations","relationsDeclarations","addImport","from","name","Set","add","corePackage","packageName","schemaDeclaration","schemaName","enumFn","enumsList","addEnum","options","some","each","push","map","option","join","payload","config","localization","localeCodes","tableFn","fkGraph","tableName","rawTables","table","colKey","columns","col","reference","canReach","target","visited","has","neighbor","circularEdges","tableA","tableB","extrasDeclarations","indexes","index","indexDeclaration","unique","on","foreignKeys","foreignKey","foreignKeyDeclaration","foreignColumns","onDelete","onUpdate","tableCode","Object","entries","column","adapter","locales","undefined","tableKey","length","rawRelations","relations","properties","relation","declaration","type","to","fields","field","references","relationName","args","values","rel","arg","importDeclarationsSanitized","moduleName","moduleImports","Array","schemaType","keys","filter","Boolean","finalDeclaration","warning","importTypes","code","cwd","process","srcDir","resolve","prettier","eval","configPath","resolveConfigFile","resolveConfig","format","parser","logger","info"],"mappings":"AAEA,SAASA,UAAU,QAAQ,KAAI;AAC/B,SAASC,SAAS,QAAQ,cAAa;AACvC,OAAOC,UAAU,OAAM;AAIvB;;;;;;CAMC,GACD,MAAMC,oBAAoB,CAACC;IACzB,4CAA4C;IAC5C,MAAMC,kBAAkB;IACxB,IAAIA,gBAAgBC,IAAI,CAACF,MAAM;QAC7B,OAAOA;IACT;IAEA,OAAO,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC;AACnB;AAEA;;;;CAIC,GACD,MAAMG,iBAAiB,CAACC,SAAiBJ;IACvC,MAAMK,YAAYN,kBAAkBC;IAEpC,IAAIK,UAAUC,UAAU,CAAC,MAAM;QAC7B,OAAO,GAAGF,QAAQ,CAAC,EAAEC,UAAU,CAAC,CAAC;IACnC;IAEA,OAAO,GAAGD,QAAQ,CAAC,EAAEJ,KAAK;AAC5B;AAEA,OAAO,MAAMO,wBAAwB,CAAC,EACpCC,qBAAqB,EACrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,WAAW,EAQZ;IACC,OAAO,eAAeC,eAEpB,EAAEC,MAAM,IAAI,EAAEC,aAAaN,iBAAiB,EAAEO,WAAW,IAAI,EAAE,GAAG,CAAC,CAAC;QAEpE,MAAMC,qBAAkD,CAAC;QAEzD,MAAMC,oBAA8B,EAAE;QACtC,MAAMC,mBAA6B,EAAE;QACrC,MAAMC,wBAAkC,EAAE;QAE1C,MAAMC,YAAY,CAACC,MAAcC;YAC/B,IAAI,CAACN,k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MC,KAAK;gBAC5B,MAAMC,aAAa,MAAMF,SAASG,iBAAiB;gBACnD,MAAM3E,SAAS0E,aAAa,MAAMF,SAASI,aAAa,CAACF,cAAc,CAAC;gBACxEP,OAAO,MAAMK,SAASK,MAAM,CAACV,MAAM;oBAAE,GAAGnE,MAAM;oBAAE8E,QAAQ;gBAAa;YACvE,EAAE,OAAM;YACN,SAAS,GACX;QACF;QAEA,MAAM3H,UAAUmB,YAAY6F,MAAM;QAElC,IAAI9F,KAAK;YACP,IAAI,CAAC0B,OAAO,CAACgF,MAAM,CAACC,IAAI,CAAC,CAAC,QAAQ,EAAE1G,YAAY;QAClD;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createSchemaGenerator.ts"],"sourcesContent":["import type { GenerateSchema } from 'payload'\n\nimport { existsSync } from 'fs'\nimport { writeFile } from 'fs/promises'\nimport path from 'path'\n\nimport type { ColumnToCodeConverter, DrizzleAdapter } from '../types.js'\n\n/**\n * @example\n * console.log(sanitizeObjectKey(\"oneTwo\")); // oneTwo\n * console.log(sanitizeObjectKey(\"one-two\")); // 'one-two'\n * console.log(sanitizeObjectKey(\"_one$Two3\")); // _one$Two3\n * console.log(sanitizeObjectKey(\"3invalid\")); // '3invalid'\n */\nconst sanitizeObjectKey = (key: string) => {\n // Regular expression for a valid identifier\n const identifierRegex = /^[a-z_$][\\w$]*$/i\n if (identifierRegex.test(key)) {\n return key\n }\n\n return `'${key}'`\n}\n\n/**\n * @example\n * (columns default-valuesID) -> columns['default-valuesID']\n * (columns defaultValues) -> columns.defaultValues\n */\nconst accessProperty = (objName: string, key: string) => {\n const sanitized = sanitizeObjectKey(key)\n\n if (sanitized.startsWith(\"'\")) {\n return `${objName}[${sanitized}]`\n }\n\n return `${objName}.${key}`\n}\n\nexport const createSchemaGenerator = ({\n columnToCodeConverter,\n corePackageSuffix,\n defaultOutputFile,\n enumImport,\n schemaImport,\n tableImport,\n}: {\n columnToCodeConverter: ColumnToCodeConverter\n corePackageSuffix: string\n defaultOutputFile?: string\n enumImport?: string\n schemaImport?: string\n tableImport: string\n}): GenerateSchema => {\n return async function generateSchema(\n this: DrizzleAdapter,\n { log = true, outputFile = defaultOutputFile, prettify = true } = {},\n ) {\n const importDeclarations: Record<string, Set<string>> = {}\n\n const tableDeclarations: string[] = []\n const enumDeclarations: string[] = []\n const relationsDeclarations: string[] = []\n\n const addImport = (from: string, name: string) => {\n if (!importDeclarations[from]) {\n importDeclarations[from] = new Set()\n }\n\n importDeclarations[from].add(name)\n }\n\n const corePackage = `${this.packageName}/drizzle/${corePackageSuffix}`\n\n let schemaDeclaration: null | string = null\n\n if (this.schemaName) {\n addImport(corePackage, schemaImport)\n schemaDeclaration = `export const db_schema = ${schemaImport}('${this.schemaName}')`\n }\n\n const enumFn = this.schemaName ? `db_schema.enum` : enumImport\n\n const enumsList: string[] = []\n const addEnum = (name: string, options: string[]) => {\n if (enumsList.some((each) => each === name)) {\n return\n }\n enumsList.push(name)\n enumDeclarations.push(\n `export const ${name} = ${enumFn}('${name}', [${options.map((option) => `'${option}'`).join(', ')}])`,\n )\n }\n\n if (this.payload.config.localization && enumImport) {\n addEnum('enum__locales', this.payload.config.localization.localeCodes)\n }\n\n const tableFn = this.schemaName ? `db_schema.table` : tableImport\n\n if (!this.schemaName) {\n addImport(corePackage, tableImport)\n }\n\n addImport(corePackage, 'index')\n addImport(corePackage, 'uniqueIndex')\n addImport(corePackage, 'foreignKey')\n\n addImport(`${this.packageName}/drizzle`, 'sql')\n addImport(`${this.packageName}/drizzle`, 'relations')\n\n const fkGraph: Record<string, Set<string>> = {}\n\n for (const tableName in this.rawTables) {\n fkGraph[tableName] = new Set()\n const table = this.rawTables[tableName]\n\n for (const colKey in table.columns) {\n const col = table.columns[colKey]\n\n if (col.reference && col.reference.table !== tableName) {\n fkGraph[tableName].add(col.reference.table)\n }\n }\n }\n\n const canReach = (from: string, target: string, visited: Set<string>): boolean => {\n if (from === target) {\n return true\n }\n\n if (visited.has(from)) {\n return false\n }\n\n visited.add(from)\n\n for (const neighbor of fkGraph[from] ?? []) {\n if (canReach(neighbor, target, visited)) {\n return true\n }\n }\n\n return false\n }\n\n const circularEdges = new Set<string>()\n\n for (const tableA in fkGraph) {\n for (const tableB of fkGraph[tableA]) {\n if (canReach(tableB, tableA, new Set())) {\n circularEdges.add(`${tableA}:${tableB}`)\n }\n }\n }\n\n for (const tableName in this.rawTables) {\n const table = this.rawTables[tableName]\n\n const extrasDeclarations: string[] = []\n\n if (table.indexes) {\n for (const key in table.indexes) {\n const index = table.indexes[key]\n let indexDeclaration = `${index.unique ? 'uniqueIndex' : 'index'}('${index.name}')`\n indexDeclaration += `.on(${typeof index.on === 'string' ? `${accessProperty('columns', index.on)}` : `${index.on.map((on) => `${accessProperty('columns', on)}`).join(', ')}`}),`\n extrasDeclarations.push(indexDeclaration)\n }\n }\n\n if (table.foreignKeys) {\n for (const key in table.foreignKeys) {\n const foreignKey = table.foreignKeys[key]\n\n let foreignKeyDeclaration = `foreignKey({\n columns: [${foreignKey.columns.map((col) => `columns['${col}']`).join(', ')}],\n foreignColumns: [${foreignKey.foreignColumns.map((col) => `${accessProperty(col.table, col.name)}`).join(', ')}],\n name: '${foreignKey.name}'\n })`\n\n if (foreignKey.onDelete) {\n foreignKeyDeclaration += `.onDelete('${foreignKey.onDelete}')`\n }\n if (foreignKey.onUpdate) {\n foreignKeyDeclaration += `.onUpdate('${foreignKey.onDelete}')`\n }\n\n foreignKeyDeclaration += ','\n\n extrasDeclarations.push(foreignKeyDeclaration)\n }\n }\n\n const tableCode = `\nexport const ${tableName} = ${tableFn}('${tableName}', {\n${Object.entries(table.columns)\n .map(\n ([key, column]) =>\n ` ${sanitizeObjectKey(key)}: ${columnToCodeConverter({\n adapter: this,\n addEnum,\n addImport,\n circularEdges,\n column,\n locales: this.payload.config.localization\n ? this.payload.config.localization.localeCodes\n : undefined,\n tableKey: tableName,\n })},`,\n )\n .join('\\n')}\n}${\n extrasDeclarations.length\n ? `, (columns) => [\n ${extrasDeclarations.join(' ')}\n]`\n : ''\n }\n)\n`\n\n tableDeclarations.push(tableCode)\n }\n\n for (const tableName in this.rawRelations) {\n const relations = this.rawRelations[tableName]\n const properties: string[] = []\n\n for (const key in relations) {\n const relation = relations[key]\n let declaration: string\n\n if (relation.type === 'one') {\n declaration = `${sanitizeObjectKey(key)}: one(${relation.to}, {\n ${relation.fields.some((field) => field.table !== tableName) ? '// @ts-expect-error Drizzle TypeScript bug for ONE relationships with a field in different table' : ''}\n fields: [${relation.fields.map((field) => `${accessProperty(field.table, field.name)}`).join(', ')}],\n references: [${relation.references.map((col) => `${accessProperty(relation.to, col)}`).join(', ')}],\n ${relation.relationName ? `relationName: '${relation.relationName}',` : ''}\n }),`\n } else {\n declaration = `${sanitizeObjectKey(key)}: many(${relation.to}, {\n ${relation.relationName ? `relationName: '${relation.relationName}',` : ''}\n }),`\n }\n\n properties.push(declaration)\n }\n\n // beautify / lintify relations callback output, when no many for example, don't add it\n const args = []\n\n if (Object.values(relations).some((rel) => rel.type === 'one')) {\n args.push('one')\n }\n\n if (Object.values(relations).some((rel) => rel.type === 'many')) {\n args.push('many')\n }\n\n const arg = args.length ? `{ ${args.join(', ')} }` : ''\n\n const declaration = `export const relations_${tableName} = relations(${tableName}, (${arg}) => ({\n ${properties.join('\\n ')}\n }))`\n\n relationsDeclarations.push(declaration)\n }\n\n if (enumDeclarations.length && !this.schemaName) {\n addImport(corePackage, enumImport)\n }\n\n const importDeclarationsSanitized: string[] = []\n\n for (const moduleName in importDeclarations) {\n const moduleImports = importDeclarations[moduleName]\n\n importDeclarationsSanitized.push(\n `import { ${Array.from(moduleImports).join(', ')} } from '${moduleName}'`,\n )\n }\n\n const schemaType = `\ntype DatabaseSchema = {\n ${[\n this.schemaName ? 'db_schema' : null,\n ...enumsList,\n ...Object.keys(this.rawTables),\n ...Object.keys(this.rawRelations).map((table) => `relations_${table}`),\n ]\n .filter(Boolean)\n .map((name) => `${name}: typeof ${name}`)\n .join('\\n ')}\n}\n `\n\n const finalDeclaration = `\ndeclare module '${this.packageName}' {\n export interface GeneratedDatabaseSchema {\n schema: DatabaseSchema\n }\n}\n `\n\n const warning = `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:db-schema\\` to regenerate this file.\n */\n`\n\n const importTypes = `import type {} from '${this.packageName}'`\n\n let code = [\n warning,\n importTypes,\n ...importDeclarationsSanitized,\n schemaDeclaration,\n ...enumDeclarations,\n ...tableDeclarations,\n ...relationsDeclarations,\n schemaType,\n finalDeclaration,\n ]\n .filter(Boolean)\n .join('\\n')\n\n if (!outputFile) {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src')\n\n if (existsSync(srcDir)) {\n outputFile = path.resolve(srcDir, 'payload-generated-schema.ts')\n } else {\n outputFile = path.resolve(cwd, 'payload-generated-schema.ts')\n }\n }\n\n if (prettify) {\n try {\n const prettier = await eval('import(\"prettier\")')\n const configPath = await prettier.resolveConfigFile()\n const config = configPath ? await prettier.resolveConfig(configPath) : {}\n code = await prettier.format(code, { ...config, parser: 'typescript' })\n } catch {\n /* empty */\n }\n }\n\n await writeFile(outputFile, code, 'utf-8')\n\n if (log) {\n this.payload.logger.info(`Written ${outputFile}`)\n }\n\n return { outputFile }\n }\n}\n"],"names":["existsSync","writeFile","path","sanitizeObjectKey","key","identifierRegex","test","accessProperty","objName","sanitized","startsWith","createSchemaGenerator","columnToCodeConverter","corePackageSuffix","defaultOutputFile","enumImport","schemaImport","tableImport","generateSchema","log","outputFile","prettify","importDeclarations","tableDeclarations","enumDeclarations","relationsDeclarations","addImport","from","name","Set","add","corePackage","packageName","schemaDeclaration","schemaName","enumFn","enumsList","addEnum","options","some","each","push","map","option","join","payload","config","localization","localeCodes","tableFn","fkGraph","tableName","rawTables","table","colKey","columns","col","reference","canReach","target","visited","has","neighbor","circularEdges","tableA","tableB","extrasDeclarations","indexes","index","indexDeclaration","unique","on","foreignKeys","foreignKey","foreignKeyDeclaration","foreignColumns","onDelete","onUpdate","tableCode","Object","entries","column","adapter","locales","undefined","tableKey","length","rawRelations","relations","properties","relation","declaration","type","to","fields","field","references","relationName","args","values","rel","arg","importDeclarationsSanitized","moduleName","moduleImports","Array","schemaType","keys","filter","Boolean","finalDeclaration","warning","importTypes","code","cwd","process","srcDir","resolve","prettier","eval","configPath","resolveConfigFile","resolveConfig","format","parser","logger","info"],"mappings":"AAEA,SAASA,UAAU,QAAQ,KAAI;AAC/B,SAASC,SAAS,QAAQ,cAAa;AACvC,OAAOC,UAAU,OAAM;AAIvB;;;;;;CAMC,GACD,MAAMC,oBAAoB,CAACC;IACzB,4CAA4C;IAC5C,MAAMC,kBAAkB;IACxB,IAAIA,gBAAgBC,IAAI,CAACF,MAAM;QAC7B,OAAOA;IACT;IAEA,OAAO,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC;AACnB;AAEA;;;;CAIC,GACD,MAAMG,iBAAiB,CAACC,SAAiBJ;IACvC,MAAMK,YAAYN,kBAAkBC;IAEpC,IAAIK,UAAUC,UAAU,CAAC,MAAM;QAC7B,OAAO,GAAGF,QAAQ,CAAC,EAAEC,UAAU,CAAC,CAAC;IACnC;IAEA,OAAO,GAAGD,QAAQ,CAAC,EAAEJ,KAAK;AAC5B;AAEA,OAAO,MAAMO,wBAAwB,CAAC,EACpCC,qBAAqB,EACrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,WAAW,EAQZ;IACC,OAAO,eAAeC,eAEpB,EAAEC,MAAM,IAAI,EAAEC,aAAaN,iBAAiB,EAAEO,WAAW,IAAI,EAAE,GAAG,CAAC,CAAC;QAEpE,MAAMC,qBAAkD,CAAC;QAEzD,MAAMC,oBAA8B,EAAE;QACtC,MAAMC,mBAA6B,EAAE;QACrC,MAAMC,wBAAkC,EAAE;QAE1C,MAAMC,YAAY,CAACC,MAAcC;YAC/B,IAAI,CAACN,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AMC,KAAK;gBAC5B,MAAMC,aAAa,MAAMF,SAASG,iBAAiB;gBACnD,MAAM3E,SAAS0E,aAAa,MAAMF,SAASI,aAAa,CAACF,cAAc,CAAC;gBACxEP,OAAO,MAAMK,SAASK,MAAM,CAACV,MAAM;oBAAE,GAAGnE,MAAM;oBAAE8E,QAAQ;gBAAa;YACvE,EAAE,OAAM;YACN,SAAS,GACX;QACF;QAEA,MAAM3H,UAAUmB,YAAY6F,MAAM;QAElC,IAAI9F,KAAK;YACP,IAAI,CAAC0B,OAAO,CAACgF,MAAM,CAACC,IAAI,CAAC,CAAC,QAAQ,EAAE1G,YAAY;QAClD;QAEA,OAAO;YAAEA;QAAW;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAoBzE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeSchemaHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/executeSchemaHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B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AAO,kBAAkB,CAAA;IACtC,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,kBAAkB,sBAA6B,IAAI,KAAG,OAAO,CAAC,IAAI,CAkB9E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oCAAqC,IAAI,KAAG,IAkC1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,gCAI9B;IACD,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB,WAMA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,6BAG7B;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,sBAEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,SAAU,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,8CAK9B,qBAAqB,KAAG,MAS1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,UAAW,KAAK,KAAG,MAEtD,CAAA"}
|
|
@@ -2,5 +2,5 @@ import type { DrizzleAdapter, DrizzleTransaction } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Returns the correct database instance for reads that are part of a write operation.
|
|
4
4
|
*/
|
|
5
|
-
export declare const getPrimaryDb: (adapter: DrizzleAdapter, db: DrizzleAdapter[
|
|
5
|
+
export declare const getPrimaryDb: (adapter: DrizzleAdapter, db: DrizzleAdapter['drizzle'] | DrizzleTransaction) => import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> | import("../types.js").PostgresDB | DrizzleTransaction;
|
|
6
6
|
//# sourceMappingURL=getPrimaryDb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,YACd,cAAc,MACnB,cAAc,CAAC,SAAS,CAAC,GAAG,kBAAkB,+HAMnD,CAAA"}
|
|
@@ -9,5 +9,5 @@ import type { DrizzleAdapter } from '../types.js';
|
|
|
9
9
|
* When read replicas are configured and a write happened recently, returns the
|
|
10
10
|
* unwrapped primary to avoid replication-lag stale reads.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getTransaction: <T extends DrizzleAdapter = DrizzleAdapter>(adapter: T, req?: Partial<PayloadRequest>) => Promise<T[
|
|
12
|
+
export declare const getTransaction: <T extends DrizzleAdapter = DrizzleAdapter>(adapter: T, req?: Partial<PayloadRequest>) => Promise<T['drizzle']>;
|
|
13
13
|
//# sourceMappingURL=getTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,GAAG,cAAc,WACnE,CAAC,QACJ,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAStB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,mCAGzB;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,KAAG,OAyBH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,UAC7B,OAAO,KACb,KAAK,IAAI;IACV,UAAU,EAAE,cAAc,CAAA;IAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CASvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,OAAmD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,WAC9D,cAAc,SAChB,CAAC,iBAGT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,YACtB,cAAc,OAClB,cAAc,GAAG,UAAU,KAC/B,OAAO,CAAC,OAAO,CA2BjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,QAAS,OAAO,OAAO,MAAM,KAAG,MAUtD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJSONPathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/parseJSONPathSegment.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAIL,eAAO,MAAM,oBAAoB,YAAa,MAAM,KAAG,eActD,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sanitizePathSegment } from './sanitizePathSegment.js';
|
|
2
|
+
const ARRAY_INDEX_REGEX = /^\d+$/;
|
|
3
|
+
export const parseJSONPathSegment = (segment)=>{
|
|
4
|
+
const sanitizedSegment = sanitizePathSegment(segment);
|
|
5
|
+
if (ARRAY_INDEX_REGEX.test(sanitizedSegment)) {
|
|
6
|
+
return {
|
|
7
|
+
type: 'arrayIndex',
|
|
8
|
+
value: sanitizedSegment
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
type: 'objectKey',
|
|
13
|
+
value: sanitizedSegment
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=parseJSONPathSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/parseJSONPathSegment.ts"],"sourcesContent":["import { sanitizePathSegment } from './sanitizePathSegment.js'\n\nexport type JSONPathSegment =\n | {\n type: 'arrayIndex'\n value: string\n }\n | {\n type: 'objectKey'\n value: string\n }\n\nconst ARRAY_INDEX_REGEX = /^\\d+$/\n\nexport const parseJSONPathSegment = (segment: string): JSONPathSegment => {\n const sanitizedSegment = sanitizePathSegment(segment)\n\n if (ARRAY_INDEX_REGEX.test(sanitizedSegment)) {\n return {\n type: 'arrayIndex',\n value: sanitizedSegment,\n }\n }\n\n return {\n type: 'objectKey',\n value: sanitizedSegment,\n }\n}\n"],"names":["sanitizePathSegment","ARRAY_INDEX_REGEX","parseJSONPathSegment","segment","sanitizedSegment","test","type","value"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,2BAA0B;AAY9D,MAAMC,oBAAoB;AAE1B,OAAO,MAAMC,uBAAuB,CAACC;IACnC,MAAMC,mBAAmBJ,oBAAoBG;IAE7C,IAAIF,kBAAkBI,IAAI,CAACD,mBAAmB;QAC5C,OAAO;YACLE,MAAM;YACNC,OAAOH;QACT;IACF;IAEA,OAAO;QACLE,MAAM;QACNC,OAAOH;IACT;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AAUvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AAUvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAmB,cAAc,kBA6F1D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO;;;CAG1C,CAAA;AAEF,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,UAAU,CAAC,OAAO,aAAa,CAExF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,YAAa,MAAM,KAAG,MAQrD,CAAA"}
|
|
@@ -3,11 +3,7 @@ import type { RawTable } from '../types.js';
|
|
|
3
3
|
type Args = {
|
|
4
4
|
block: Block;
|
|
5
5
|
localized: boolean;
|
|
6
|
-
|
|
7
|
-
* @todo make required in v4.0. Usually you'd wanna pass this in
|
|
8
|
-
*/
|
|
9
|
-
parentIsLocalized?: boolean;
|
|
10
|
-
rootTableName: string;
|
|
6
|
+
parentIsLocalized: boolean;
|
|
11
7
|
table: RawTable;
|
|
12
8
|
tableLocales?: RawTable;
|
|
13
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB
|
|
1
|
+
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,KAAK,EAAE,QAAQ,CAAA;IACf,YAAY,CAAC,EAAE,QAAQ,CAAA;CACxB,CAAA;AA+DD;;GAEG;AACH,eAAO,MAAM,gCAAgC,kEAM1C,IAAI,KAAG,OAwBT,CAAA;AAED,eAAO,MAAM,2BAA2B,eAAwC,CAAA;AAChF,eAAO,MAAM,qBAAqB,UAAW,cAAc,SAAS,MAAM,SAEzE,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,cAAc,qBAAqB,MAAM,WAMrF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n parentIsLocalized: boolean\n table: RawTable\n tableLocales?: RawTable\n}\n\nconst getFlattenedFieldNames = (args: {\n fields: Field[]\n parentIsLocalized: boolean\n prefix?: string\n}): { localized?: boolean; name: string }[] => {\n const { fields, parentIsLocalized, prefix = '' } = args\n return fields.reduce((fieldsToUse, field) => {\n let fieldPrefix = prefix\n\n if (\n ['array', 'blocks', 'relationship', 'upload'].includes(field.type) ||\n ('hasMany' in field && field.hasMany === true)\n ) {\n return fieldsToUse\n }\n\n if (fieldHasSubFields(field)) {\n fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix\n return [\n ...fieldsToUse,\n ...getFlattenedFieldNames({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || ('localized' in field && field.localized),\n prefix: fieldPrefix,\n }),\n ]\n }\n\n if (field.type === 'tabs') {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce((tabFields, tab) => {\n fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix\n return [\n ...tabFields,\n ...(tabHasName(tab)\n ? [{ ...tab, type: 'tab' }]\n : getFlattenedFieldNames({\n fields: tab.fields,\n parentIsLocalized: parentIsLocalized || tab.localized,\n prefix: fieldPrefix,\n })),\n ]\n }, []),\n ]\n }\n\n if (fieldAffectsData(field)) {\n return [\n ...fieldsToUse,\n {\n name: `${fieldPrefix}${field.name}`,\n localized: fieldShouldBeLocalized({ field, parentIsLocalized }),\n },\n ]\n }\n\n return fieldsToUse\n }, [])\n}\n\n/**\n * returns true if all the fields in a block are identical to the existing table\n */\nexport const validateExistingBlockIsIdentical = ({\n block,\n localized,\n parentIsLocalized,\n table,\n tableLocales,\n}: Args): boolean => {\n const fieldNames = getFlattenedFieldNames({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || localized,\n })\n\n const missingField =\n // ensure every field from the config is in the matching table\n fieldNames.find(({ name, localized }) => {\n const fieldTable = localized && tableLocales ? tableLocales : table\n return Object.keys(fieldTable.columns).indexOf(name) === -1\n }) ||\n // ensure every table column is matched for every field from the config\n Object.keys(table).find((fieldName) => {\n if (!['_locale', '_order', '_parentID', '_path', '_uuid'].includes(fieldName)) {\n return fieldNames.findIndex((field) => field.name) === -1\n }\n })\n\n if (missingField) {\n return false\n }\n\n return Boolean(localized) === Boolean(table.columns._locale)\n}\n\nexport const InternalBlockTableNameIndex = Symbol('InternalBlockTableNameIndex')\nexport const setInternalBlockIndex = (block: FlattenedBlock, index: number) => {\n block[InternalBlockTableNameIndex] = index\n}\n\nexport const resolveBlockTableName = (block: FlattenedBlock, originalTableName: string) => {\n if (!block[InternalBlockTableNameIndex]) {\n return originalTableName\n }\n\n return `${originalTableName}_${block[InternalBlockTableNameIndex]}`\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","fieldShouldBeLocalized","tabHasName","getFlattenedFieldNames","args","fields","parentIsLocalized","prefix","reduce","fieldsToUse","field","fieldPrefix","includes","type","hasMany","name","localized","tabs","tabFields","tab","validateExistingBlockIsIdentical","block","table","tableLocales","fieldNames","missingField","find","fieldTable","Object","keys","columns","indexOf","fieldName","findIndex","Boolean","_locale","InternalBlockTableNameIndex","Symbol","setInternalBlockIndex","index","resolveBlockTableName","originalTableName"],"mappings":"AAEA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAYvB,MAAMC,yBAAyB,CAACC;IAK9B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,SAAS,EAAE,EAAE,GAAGH;IACnD,OAAOC,OAAOG,MAAM,CAAC,CAACC,aAAaC;QACjC,IAAIC,cAAcJ;QAElB,IACE;YAAC;YAAS;YAAU;YAAgB;SAAS,CAACK,QAAQ,CAACF,MAAMG,IAAI,KAChE,aAAaH,SAASA,MAAMI,OAAO,KAAK,MACzC;YACA,OAAOL;QACT;QAEA,IAAIT,kBAAkBU,QAAQ;YAC5BC,cAAc,UAAUD,QAAQ,GAAGH,SAASG,MAAMK,IAAI,CAAC,CAAC,CAAC,GAAGR;YAC5D,OAAO;mBACFE;mBACAN,uBAAuB;oBACxBE,QAAQK,MAAML,MAAM;oBACpBC,mBAAmBA,qBAAsB,eAAeI,SAASA,MAAMM,SAAS;oBAChFT,QAAQI;gBACV;aACD;QACH;QAEA,IAAID,MAAMG,IAAI,KAAK,QAAQ;YACzB,OAAO;mBACFJ;mBACAC,MAAMO,IAAI,CAACT,MAAM,CAAC,CAACU,WAAWC;oBAC/BR,c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S,QAAQlB,eAAekB,QAAQZ,MAAMQ,OAAO,CAACK,OAAO;AAC7D,EAAC;AAED,OAAO,MAAMC,8BAA8BC,OAAO,+BAA8B;AAChF,OAAO,MAAMC,wBAAwB,CAACjB,OAAuBkB;IAC3DlB,KAAK,CAACe,4BAA4B,GAAGG;AACvC,EAAC;AAED,OAAO,MAAMC,wBAAwB,CAACnB,OAAuBoB;IAC3D,IAAI,CAACpB,KAAK,CAACe,4BAA4B,EAAE;QACvC,OAAOK;IACT;IAEA,OAAO,GAAGA,kBAAkB,CAAC,EAAEpB,KAAK,CAACe,4BAA4B,EAAE;AACrE,EAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Postgres max identifier length (NAMEDATALEN - 1). */
|
|
2
|
+
export declare const maxIdentifierLength = 63;
|
|
3
|
+
/**
|
|
4
|
+
* Cap for builder-generated identifiers (`buildIndexName`/`buildForeignKeyName`). Sits
|
|
5
|
+
* below `maxIdentifierLength` to leave headroom for the appended `_idx`/`_fk`/`_N` suffixes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const maxGeneratedIdentifierLength: number;
|
|
8
|
+
/**
|
|
9
|
+
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateIdentifierLength: (name: string) => string;
|
|
12
|
+
//# sourceMappingURL=validateIdentifierLength.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateIdentifierLength.d.ts","sourceRoot":"","sources":["../../src/utilities/validateIdentifierLength.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAA0B,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,KAAG,MAUvD,CAAA"}
|