@payloadcms/db-postgres 3.0.0-canary.d6053cd → 3.0.0-canary.d894ac7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +10 -6
- package/dist/connect.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -67
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.js +2 -2
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/types.d.ts +42 -78
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -41
- package/dist/count.js.map +0 -1
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -19
- package/dist/create.js.map +0 -1
- package/dist/createGlobal.d.ts +0 -4
- package/dist/createGlobal.d.ts.map +0 -1
- package/dist/createGlobal.js +0 -19
- package/dist/createGlobal.js.map +0 -1
- package/dist/createGlobalVersion.d.ts +0 -4
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -33
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createMigration.d.ts +0 -3
- package/dist/createMigration.d.ts.map +0 -1
- package/dist/createMigration.js +0 -102
- package/dist/createMigration.js.map +0 -1
- package/dist/createVersion.d.ts +0 -4
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -40
- package/dist/createVersion.js.map +0 -1
- package/dist/deleteMany.d.ts +0 -3
- package/dist/deleteMany.d.ts.map +0 -1
- package/dist/deleteMany.js +0 -28
- package/dist/deleteMany.js.map +0 -1
- package/dist/deleteOne.d.ts +0 -3
- package/dist/deleteOne.d.ts.map +0 -1
- package/dist/deleteOne.js +0 -59
- package/dist/deleteOne.js.map +0 -1
- package/dist/deleteVersions.d.ts +0 -3
- package/dist/deleteVersions.d.ts.map +0 -1
- package/dist/deleteVersions.js +0 -31
- package/dist/deleteVersions.js.map +0 -1
- package/dist/destroy.d.ts +0 -3
- package/dist/destroy.d.ts.map +0 -1
- package/dist/destroy.js +0 -15
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -17
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -65
- package/dist/find/buildFindManyArgs.js.map +0 -1
- package/dist/find/chainMethods.d.ts +0 -16
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -12
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/find/findMany.d.ts +0 -21
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -152
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -17
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -156
- package/dist/find/traverseFields.js.map +0 -1
- package/dist/find.d.ts +0 -3
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -21
- package/dist/find.js.map +0 -1
- package/dist/findGlobal.d.ts +0 -3
- package/dist/findGlobal.d.ts.map +0 -1
- package/dist/findGlobal.js +0 -23
- package/dist/findGlobal.js.map +0 -1
- package/dist/findGlobalVersions.d.ts +0 -3
- package/dist/findGlobalVersions.d.ts.map +0 -1
- package/dist/findGlobalVersions.js +0 -24
- package/dist/findGlobalVersions.js.map +0 -1
- package/dist/findOne.d.ts +0 -4
- package/dist/findOne.d.ts.map +0 -1
- package/dist/findOne.js +0 -21
- package/dist/findOne.js.map +0 -1
- package/dist/findVersions.d.ts +0 -3
- package/dist/findVersions.d.ts.map +0 -1
- package/dist/findVersions.js +0 -24
- package/dist/findVersions.js.map +0 -1
- package/dist/init.d.ts +0 -3
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -91
- package/dist/init.js.map +0 -1
- package/dist/migrate.d.ts +0 -3
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -99
- package/dist/migrate.js.map +0 -1
- package/dist/migrateDown.d.ts +0 -3
- package/dist/migrateDown.d.ts.map +0 -1
- package/dist/migrateDown.js +0 -63
- package/dist/migrateDown.js.map +0 -1
- package/dist/migrateFresh.d.ts +0 -8
- package/dist/migrateFresh.d.ts.map +0 -1
- package/dist/migrateFresh.js +0 -72
- package/dist/migrateFresh.js.map +0 -1
- package/dist/migrateRefresh.d.ts +0 -6
- package/dist/migrateRefresh.d.ts.map +0 -1
- package/dist/migrateRefresh.js +0 -102
- package/dist/migrateRefresh.js.map +0 -1
- package/dist/migrateReset.d.ts +0 -6
- package/dist/migrateReset.d.ts.map +0 -1
- package/dist/migrateReset.js +0 -82
- package/dist/migrateReset.js.map +0 -1
- package/dist/migrateStatus.d.ts +0 -3
- package/dist/migrateStatus.d.ts.map +0 -1
- package/dist/migrateStatus.js +0 -44
- package/dist/migrateStatus.js.map +0 -1
- package/dist/queries/buildAndOrConditions.d.ts +0 -16
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -28
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -30
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -72
- package/dist/queries/buildQuery.js.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts +0 -10
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/index.js +0 -54
- package/dist/queries/createJSONQuery/index.js.map +0 -1
- package/dist/queries/getTableColumnFromPath.d.ts +0 -50
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -516
- package/dist/queries/getTableColumnFromPath.js.map +0 -1
- package/dist/queries/operatorMap.d.ts +0 -18
- package/dist/queries/operatorMap.d.ts.map +0 -1
- package/dist/queries/operatorMap.js +0 -24
- package/dist/queries/operatorMap.js.map +0 -1
- package/dist/queries/parseParams.d.ts +0 -16
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -183
- package/dist/queries/parseParams.js.map +0 -1
- package/dist/queries/sanitizeQueryValue.d.ts +0 -15
- package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
- package/dist/queries/sanitizeQueryValue.js +0 -89
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -22
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -30
- package/dist/queries/selectDistinct.js.map +0 -1
- package/dist/queryDrafts.d.ts +0 -3
- package/dist/queryDrafts.d.ts.map +0 -1
- package/dist/queryDrafts.js +0 -40
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/build.d.ts +0 -34
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -369
- package/dist/schema/build.js.map +0 -1
- package/dist/schema/createIndex.d.ts +0 -12
- package/dist/schema/createIndex.d.ts.map +0 -1
- package/dist/schema/createIndex.js +0 -18
- package/dist/schema/createIndex.js.map +0 -1
- package/dist/schema/createTableName.d.ts +0 -30
- package/dist/schema/createTableName.d.ts.map +0 -1
- package/dist/schema/createTableName.js +0 -31
- package/dist/schema/createTableName.js.map +0 -1
- package/dist/schema/idToUUID.d.ts +0 -3
- package/dist/schema/idToUUID.d.ts.map +0 -1
- package/dist/schema/idToUUID.js +0 -11
- package/dist/schema/idToUUID.js.map +0 -1
- package/dist/schema/parentIDColumnMap.d.ts +0 -4
- package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
- package/dist/schema/parentIDColumnMap.js +0 -9
- package/dist/schema/parentIDColumnMap.js.map +0 -1
- package/dist/schema/setColumnID.d.ts +0 -11
- package/dist/schema/setColumnID.d.ts.map +0 -1
- package/dist/schema/setColumnID.js +0 -24
- package/dist/schema/setColumnID.js.map +0 -1
- package/dist/schema/traverseFields.d.ts +0 -36
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -614
- package/dist/schema/traverseFields.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
- package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
- package/dist/transactions/beginTransaction.d.ts +0 -3
- package/dist/transactions/beginTransaction.d.ts.map +0 -1
- package/dist/transactions/beginTransaction.js +0 -51
- package/dist/transactions/beginTransaction.js.map +0 -1
- package/dist/transactions/commitTransaction.d.ts +0 -3
- package/dist/transactions/commitTransaction.d.ts.map +0 -1
- package/dist/transactions/commitTransaction.js +0 -15
- package/dist/transactions/commitTransaction.js.map +0 -1
- package/dist/transactions/rollbackTransaction.d.ts +0 -3
- package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
- package/dist/transactions/rollbackTransaction.js +0 -14
- package/dist/transactions/rollbackTransaction.js.map +0 -1
- package/dist/transform/read/hasManyNumber.d.ts +0 -10
- package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
- package/dist/transform/read/hasManyNumber.js +0 -10
- package/dist/transform/read/hasManyNumber.js.map +0 -1
- package/dist/transform/read/hasManyText.d.ts +0 -10
- package/dist/transform/read/hasManyText.d.ts.map +0 -1
- package/dist/transform/read/hasManyText.js +0 -10
- package/dist/transform/read/hasManyText.js.map +0 -1
- package/dist/transform/read/index.d.ts +0 -13
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -44
- package/dist/transform/read/index.js.map +0 -1
- package/dist/transform/read/relationship.d.ts +0 -10
- package/dist/transform/read/relationship.d.ts.map +0 -1
- package/dist/transform/read/relationship.js +0 -60
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -57
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -435
- package/dist/transform/read/traverseFields.js.map +0 -1
- package/dist/transform/write/array.d.ts +0 -26
- package/dist/transform/write/array.d.ts.map +0 -1
- package/dist/transform/write/array.js +0 -58
- package/dist/transform/write/array.js.map +0 -1
- package/dist/transform/write/blocks.d.ts +0 -25
- package/dist/transform/write/blocks.d.ts.map +0 -1
- package/dist/transform/write/blocks.js +0 -54
- package/dist/transform/write/blocks.js.map +0 -1
- package/dist/transform/write/index.d.ts +0 -13
- package/dist/transform/write/index.d.ts.map +0 -1
- package/dist/transform/write/index.js +0 -41
- package/dist/transform/write/index.js.map +0 -1
- package/dist/transform/write/numbers.d.ts +0 -8
- package/dist/transform/write/numbers.d.ts.map +0 -1
- package/dist/transform/write/numbers.js +0 -11
- package/dist/transform/write/numbers.js.map +0 -1
- package/dist/transform/write/relationships.d.ts +0 -10
- package/dist/transform/write/relationships.d.ts.map +0 -1
- package/dist/transform/write/relationships.js +0 -23
- package/dist/transform/write/relationships.js.map +0 -1
- package/dist/transform/write/selects.d.ts +0 -8
- package/dist/transform/write/selects.d.ts.map +0 -1
- package/dist/transform/write/selects.js +0 -20
- package/dist/transform/write/selects.js.map +0 -1
- package/dist/transform/write/texts.d.ts +0 -8
- package/dist/transform/write/texts.d.ts.map +0 -1
- package/dist/transform/write/texts.js +0 -11
- package/dist/transform/write/texts.js.map +0 -1
- package/dist/transform/write/traverseFields.d.ts +0 -50
- package/dist/transform/write/traverseFields.d.ts.map +0 -1
- package/dist/transform/write/traverseFields.js +0 -445
- package/dist/transform/write/traverseFields.js.map +0 -1
- package/dist/transform/write/types.d.ts +0 -43
- package/dist/transform/write/types.d.ts.map +0 -1
- package/dist/transform/write/types.js +0 -3
- package/dist/transform/write/types.js.map +0 -1
- package/dist/update.d.ts +0 -3
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -54
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -4
- package/dist/updateGlobal.d.ts.map +0 -1
- package/dist/updateGlobal.js +0 -25
- package/dist/updateGlobal.js.map +0 -1
- package/dist/updateGlobalVersion.d.ts +0 -4
- package/dist/updateGlobalVersion.d.ts.map +0 -1
- package/dist/updateGlobalVersion.js +0 -36
- package/dist/updateGlobalVersion.js.map +0 -1
- package/dist/updateVersion.d.ts +0 -4
- package/dist/updateVersion.d.ts.map +0 -1
- package/dist/updateVersion.js +0 -36
- package/dist/updateVersion.js.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
- package/dist/upsertRow/index.d.ts +0 -4
- package/dist/upsertRow/index.d.ts.map +0 -1
- package/dist/upsertRow/index.js +0 -281
- package/dist/upsertRow/index.js.map +0 -1
- package/dist/upsertRow/insertArrays.d.ts +0 -13
- package/dist/upsertRow/insertArrays.d.ts.map +0 -1
- package/dist/upsertRow/insertArrays.js +0 -68
- package/dist/upsertRow/insertArrays.js.map +0 -1
- package/dist/upsertRow/types.d.ts +0 -32
- package/dist/upsertRow/types.d.ts.map +0 -1
- package/dist/upsertRow/types.js +0 -3
- package/dist/upsertRow/types.js.map +0 -1
- package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
- package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
- package/dist/utilities/appendPrefixToKeys.js +0 -6
- package/dist/utilities/appendPrefixToKeys.js.map +0 -1
- package/dist/utilities/createBlocksMap.d.ts +0 -5
- package/dist/utilities/createBlocksMap.d.ts.map +0 -1
- package/dist/utilities/createBlocksMap.js +0 -29
- package/dist/utilities/createBlocksMap.js.map +0 -1
- package/dist/utilities/createMigrationTable.d.ts +0 -3
- package/dist/utilities/createMigrationTable.d.ts.map +0 -1
- package/dist/utilities/createMigrationTable.js +0 -13
- package/dist/utilities/createMigrationTable.js.map +0 -1
- package/dist/utilities/createRelationshipMap.d.ts +0 -2
- package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
- package/dist/utilities/createRelationshipMap.js +0 -19
- package/dist/utilities/createRelationshipMap.js.map +0 -1
- package/dist/utilities/hasLocalesTable.d.ts +0 -3
- package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
- package/dist/utilities/hasLocalesTable.js +0 -11
- package/dist/utilities/hasLocalesTable.js.map +0 -1
- package/dist/utilities/isArrayOfRows.d.ts +0 -2
- package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
- package/dist/utilities/isArrayOfRows.js +0 -5
- package/dist/utilities/isArrayOfRows.js.map +0 -1
- package/dist/utilities/migrationTableExists.d.ts +0 -3
- package/dist/utilities/migrationTableExists.d.ts.map +0 -1
- package/dist/utilities/migrationTableExists.js +0 -9
- package/dist/utilities/migrationTableExists.js.map +0 -1
- package/dist/utilities/parseError.d.ts +0 -5
- package/dist/utilities/parseError.d.ts.map +0 -1
- package/dist/utilities/parseError.js +0 -17
- package/dist/utilities/parseError.js.map +0 -1
- package/dist/utilities/pushDevSchema.d.ts +0 -9
- package/dist/utilities/pushDevSchema.d.ts.map +0 -1
- package/dist/utilities/pushDevSchema.js +0 -58
- package/dist/utilities/pushDevSchema.js.map +0 -1
package/dist/types.d.ts
CHANGED
@@ -1,100 +1,64 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type { PgTableFn } from 'drizzle-orm/pg-core
|
5
|
-
import type { BaseDatabaseAdapter, Payload, PayloadRequest } from 'payload';
|
1
|
+
import type { BasePostgresAdapter, GenericEnum, MigrateDownArgs, MigrateUpArgs, PostgresDB } from '@payloadcms/drizzle/postgres';
|
2
|
+
import type { DrizzleAdapter } from '@payloadcms/drizzle/types';
|
3
|
+
import type { DrizzleConfig } from 'drizzle-orm';
|
4
|
+
import type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core';
|
6
5
|
import type { Pool, PoolConfig } from 'pg';
|
7
|
-
export type DrizzleDB = NodePgDatabase<Record<string, unknown>>;
|
8
6
|
export type Args = {
|
9
7
|
idType?: 'serial' | 'uuid';
|
10
8
|
localesSuffix?: string;
|
11
9
|
logger?: DrizzleConfig['logger'];
|
12
10
|
migrationDir?: string;
|
13
11
|
pool: PoolConfig;
|
12
|
+
prodMigrations?: {
|
13
|
+
down: (args: MigrateDownArgs) => Promise<void>;
|
14
|
+
name: string;
|
15
|
+
up: (args: MigrateUpArgs) => Promise<void>;
|
16
|
+
}[];
|
14
17
|
push?: boolean;
|
15
18
|
relationshipsSuffix?: string;
|
16
|
-
schemaName?: string;
|
17
|
-
versionsSuffix?: string;
|
18
|
-
};
|
19
|
-
export type GenericColumn = PgColumn<ColumnBaseConfig<ColumnDataType, string>, Record<string, unknown>>;
|
20
|
-
export type GenericColumns = {
|
21
|
-
[x: string]: GenericColumn;
|
22
|
-
};
|
23
|
-
export type GenericTable = PgTableWithColumns<{
|
24
|
-
columns: GenericColumns;
|
25
|
-
dialect: string;
|
26
|
-
name: string;
|
27
|
-
schema: undefined;
|
28
|
-
}>;
|
29
|
-
export type GenericEnum = PgEnum<[string, ...string[]]>;
|
30
|
-
export type GenericRelation = Relations<string, Record<string, Relation<string>>>;
|
31
|
-
export type DrizzleTransaction = PgTransaction<NodePgQueryResultHKT, Record<string, unknown>, ExtractTablesWithRelations<Record<string, unknown>>>;
|
32
|
-
export type PostgresAdapter = BaseDatabaseAdapter & {
|
33
|
-
drizzle: DrizzleDB;
|
34
|
-
enums: Record<string, GenericEnum>;
|
35
19
|
/**
|
36
|
-
*
|
37
|
-
*
|
20
|
+
* The schema name to use for the database
|
21
|
+
* @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.
|
38
22
|
*/
|
39
|
-
|
40
|
-
|
41
|
-
initializing: Promise<void>;
|
42
|
-
localesSuffix?: string;
|
43
|
-
logger: DrizzleConfig['logger'];
|
44
|
-
pgSchema?: {
|
45
|
-
table: PgTableFn;
|
46
|
-
} | PgSchema;
|
47
|
-
pool: Pool;
|
48
|
-
poolOptions: Args['pool'];
|
49
|
-
push: boolean;
|
50
|
-
rejectInitializing: () => void;
|
51
|
-
relations: Record<string, GenericRelation>;
|
52
|
-
relationshipsSuffix?: string;
|
53
|
-
resolveInitializing: () => void;
|
54
|
-
schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
|
55
|
-
schemaName?: Args['schemaName'];
|
56
|
-
sessions: {
|
57
|
-
[id: string]: {
|
58
|
-
db: DrizzleTransaction;
|
59
|
-
reject: () => Promise<void>;
|
60
|
-
resolve: () => Promise<void>;
|
61
|
-
};
|
62
|
-
};
|
63
|
-
tableNameMap: Map<string, string>;
|
64
|
-
tables: Record<string, GenericTable | PgTableWithColumns<any>>;
|
23
|
+
schemaName?: string;
|
24
|
+
transactionOptions?: PgTransactionConfig | false;
|
65
25
|
versionsSuffix?: string;
|
66
26
|
};
|
67
|
-
export type
|
68
|
-
|
69
|
-
|
70
|
-
}
|
71
|
-
export type MigrateUpArgs = {
|
72
|
-
payload: Payload;
|
73
|
-
req?: Partial<PayloadRequest>;
|
74
|
-
};
|
75
|
-
export type MigrateDownArgs = {
|
76
|
-
payload: Payload;
|
77
|
-
req?: Partial<PayloadRequest>;
|
78
|
-
};
|
27
|
+
export type PostgresAdapter = {
|
28
|
+
pool: Pool;
|
29
|
+
poolOptions: PoolConfig;
|
30
|
+
} & BasePostgresAdapter;
|
79
31
|
declare module 'payload' {
|
80
|
-
interface DatabaseAdapter extends Omit<Args, 'migrationDir' | 'pool'>,
|
81
|
-
|
32
|
+
interface DatabaseAdapter extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>, DrizzleAdapter {
|
33
|
+
beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>;
|
34
|
+
drizzle: PostgresDB;
|
82
35
|
enums: Record<string, GenericEnum>;
|
36
|
+
/**
|
37
|
+
* An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
|
38
|
+
* Used for returning properly formed errors from unique fields
|
39
|
+
*/
|
83
40
|
fieldConstraints: Record<string, Record<string, string>>;
|
84
|
-
|
41
|
+
idType: Args['idType'];
|
42
|
+
initializing: Promise<void>;
|
43
|
+
localesSuffix?: string;
|
44
|
+
logger: DrizzleConfig['logger'];
|
45
|
+
pgSchema?: {
|
46
|
+
table: PgTableFn;
|
47
|
+
} | PgSchema;
|
85
48
|
pool: Pool;
|
49
|
+
poolOptions: Args['pool'];
|
50
|
+
prodMigrations?: {
|
51
|
+
down: (args: MigrateDownArgs) => Promise<void>;
|
52
|
+
name: string;
|
53
|
+
up: (args: MigrateUpArgs) => Promise<void>;
|
54
|
+
}[];
|
86
55
|
push: boolean;
|
87
|
-
|
56
|
+
rejectInitializing: () => void;
|
88
57
|
relationshipsSuffix?: string;
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
reject: () => Promise<void>;
|
94
|
-
resolve: () => Promise<void>;
|
95
|
-
};
|
96
|
-
};
|
97
|
-
tables: Record<string, GenericTable>;
|
58
|
+
resolveInitializing: () => void;
|
59
|
+
schema: Record<string, unknown>;
|
60
|
+
schemaName?: Args['schemaName'];
|
61
|
+
tableNameMap: Map<string, string>;
|
98
62
|
versionsSuffix?: string;
|
99
63
|
}
|
100
64
|
}
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACX,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAE1C,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC1B,aAAa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EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC/B,QAAQ,CAAC,EAAE;YAAE,KAAK,EAAE,SAAS,CAAA;SAAE,GAAG,QAAQ,CAAA;QAC1C,IAAI,EAAE,IAAI,CAAA;QACV,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACzB,cAAc,CAAC,EAAE;YACf,IAAI,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;YAC9C,IAAI,EAAE,MAAM,CAAA;YACZ,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3C,EAAE,CAAA;QACH,IAAI,EAAE,OAAO,CAAA;QACb,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/B,UAAU,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC/B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;CACF"}
|
package/dist/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n BasePostgresAdapter,\n GenericEnum,\n MigrateDownArgs,\n MigrateUpArgs,\n PostgresDB,\n} from '@payloadcms/drizzle/postgres'\nimport type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { DrizzleConfig } from 'drizzle-orm'\nimport type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core'\nimport type { Pool, PoolConfig } from 'pg'\n\nexport type Args = {\n idType?: 'serial' | 'uuid'\n localesSuffix?: string\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push?: boolean\n relationshipsSuffix?: string\n /**\n * The schema name to use for the database\n * @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.\n */\n schemaName?: string\n transactionOptions?: PgTransactionConfig | false\n versionsSuffix?: string\n}\n\nexport type PostgresAdapter = {\n pool: Pool\n poolOptions: PoolConfig\n} & BasePostgresAdapter\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>\n drizzle: PostgresDB\n enums: Record<string, GenericEnum>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, unknown>\n schemaName?: Args['schemaName']\n tableNameMap: Map<string, string>\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAkCA,WAGuB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "3.0.0-canary.
|
3
|
+
"version": "3.0.0-canary.d894ac7",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -35,25 +35,25 @@
|
|
35
35
|
"mock.js"
|
36
36
|
],
|
37
37
|
"dependencies": {
|
38
|
-
"@libsql/client": "^0.5.2",
|
39
38
|
"console-table-printer": "2.11.2",
|
40
|
-
"drizzle-kit": "0.
|
41
|
-
"drizzle-orm": "0.
|
39
|
+
"drizzle-kit": "0.23.2-df9e596",
|
40
|
+
"drizzle-orm": "0.32.1",
|
42
41
|
"pg": "8.11.3",
|
43
42
|
"prompts": "2.4.2",
|
44
43
|
"to-snake-case": "1.0.0",
|
45
|
-
"uuid": "10.0.0"
|
44
|
+
"uuid": "10.0.0",
|
45
|
+
"@payloadcms/drizzle": "3.0.0-canary.d894ac7"
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
49
49
|
"@types/pg": "8.10.2",
|
50
50
|
"@types/to-snake-case": "1.0.0",
|
51
51
|
"esbuild": "0.23.0",
|
52
|
-
"
|
53
|
-
"
|
52
|
+
"payload": "3.0.0-canary.d894ac7",
|
53
|
+
"@payloadcms/eslint-config": "3.0.0-beta.59"
|
54
54
|
},
|
55
55
|
"peerDependencies": {
|
56
|
-
"payload": "3.0.0-canary.
|
56
|
+
"payload": "3.0.0-canary.d894ac7"
|
57
57
|
},
|
58
58
|
"scripts": {
|
59
59
|
"build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
|
@@ -61,6 +61,6 @@
|
|
61
61
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
62
62
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
63
63
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
64
|
-
"renamePredefinedMigrations": "
|
64
|
+
"renamePredefinedMigrations": "node --no-deprecation --import @swc-node/register/esm-register ./scripts/renamePredefinedMigrations.ts"
|
65
65
|
}
|
66
66
|
}
|
package/dist/count.d.ts
DELETED
package/dist/count.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA6B,MAAM,SAAS,CAAA;AAW/D,eAAO,MAAM,KAAK,EAAE,KA0CnB,CAAA"}
|
package/dist/count.js
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { chainMethods } from './find/chainMethods.js';
|
4
|
-
import buildQuery from './queries/buildQuery.js';
|
5
|
-
export const count = async function count({ collection, locale, req, where: whereArg }) {
|
6
|
-
const collectionConfig = this.payload.collections[collection].config;
|
7
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
|
8
|
-
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
9
|
-
const table = this.tables[tableName];
|
10
|
-
const { joins, where } = await buildQuery({
|
11
|
-
adapter: this,
|
12
|
-
fields: collectionConfig.fields,
|
13
|
-
locale,
|
14
|
-
tableName,
|
15
|
-
where: whereArg
|
16
|
-
});
|
17
|
-
const selectCountMethods = [];
|
18
|
-
Object.entries(joins).forEach(([joinTable, condition])=>{
|
19
|
-
if (joinTable) {
|
20
|
-
selectCountMethods.push({
|
21
|
-
args: [
|
22
|
-
this.tables[joinTable],
|
23
|
-
condition
|
24
|
-
],
|
25
|
-
method: 'leftJoin'
|
26
|
-
});
|
27
|
-
}
|
28
|
-
});
|
29
|
-
const countResult = await chainMethods({
|
30
|
-
methods: selectCountMethods,
|
31
|
-
query: db.select({
|
32
|
-
count: sql`count
|
33
|
-
(DISTINCT ${this.tables[tableName].id})`
|
34
|
-
}).from(table).where(where)
|
35
|
-
});
|
36
|
-
return {
|
37
|
-
totalDocs: Number(countResult[0].count)
|
38
|
-
};
|
39
|
-
};
|
40
|
-
|
41
|
-
//# sourceMappingURL=count.js.map
|
package/dist/count.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { Count, SanitizedCollectionConfig } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { ChainedMethods } from './find/chainMethods.js'\nimport type { PostgresAdapter } from './types.js'\n\nimport { chainMethods } from './find/chainMethods.js'\nimport buildQuery from './queries/buildQuery.js'\n\nexport const count: Count = async function count(\n this: PostgresAdapter,\n { collection, locale, req, where: whereArg },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const table = this.tables[tableName]\n\n const { joins, where } = await buildQuery({\n adapter: this,\n fields: collectionConfig.fields,\n locale,\n tableName,\n where: whereArg,\n })\n\n const selectCountMethods: ChainedMethods = []\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [this.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${this.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n\n return { totalDocs: Number(countResult[0].count) }\n}\n"],"names":["sql","toSnakeCase","chainMethods","buildQuery","count","collection","locale","req","where","whereArg","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","db","sessions","transactionID","drizzle","table","tables","joins","adapter","fields","selectCountMethods","Object","entries","forEach","joinTable","condition","push","args","method","countResult","methods","query","select","id","from","totalDocs","Number"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,gBAAg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,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAQrC,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
|
package/dist/create.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { upsertRow } from './upsertRow/index.js';
|
3
|
-
export const create = async function create({ collection: collectionSlug, data, req }) {
|
4
|
-
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
5
|
-
const collection = this.payload.collections[collectionSlug].config;
|
6
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
7
|
-
const result = await upsertRow({
|
8
|
-
adapter: this,
|
9
|
-
data,
|
10
|
-
db,
|
11
|
-
fields: collection.fields,
|
12
|
-
operation: 'create',
|
13
|
-
req,
|
14
|
-
tableName
|
15
|
-
});
|
16
|
-
return result;
|
17
|
-
};
|
18
|
-
|
19
|
-
//# sourceMappingURL=create.js.map
|
package/dist/create.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","operation"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAAC,MAAMF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IACrE,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYG,WAAWc,IAAI;IAEnE,MAAMC,SAAS,MAAMjB,UAAU;QAC7BkB,SAAS,IAAI;QACbd;QACAE;QACAa,QAAQjB,WAAWiB,MAAM;QACzBC,WAAW;QACXf;QACAQ;IACF;IAEA,OAAOI;AACT,EAAC"}
|
package/dist/createGlobal.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { CreateGlobalArgs } from 'payload';
|
2
|
-
import type { PostgresAdapter } from './types.js';
|
3
|
-
export declare function createGlobal<T extends Record<string, unknown>>(this: PostgresAdapter, { slug, data, req }: CreateGlobalArgs): Promise<T>;
|
4
|
-
//# sourceMappingURL=createGlobal.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAA;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAA0B,EAAE,EAAE,gBAAgB,GAC3D,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
package/dist/createGlobal.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { upsertRow } from './upsertRow/index.js';
|
3
|
-
export async function createGlobal({ slug, data, req = {} }) {
|
4
|
-
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
5
|
-
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
|
6
|
-
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
|
7
|
-
const result = await upsertRow({
|
8
|
-
adapter: this,
|
9
|
-
data,
|
10
|
-
db,
|
11
|
-
fields: globalConfig.fields,
|
12
|
-
operation: 'create',
|
13
|
-
req,
|
14
|
-
tableName
|
15
|
-
});
|
16
|
-
return result;
|
17
|
-
}
|
18
|
-
|
19
|
-
//# sourceMappingURL=createGlobal.js.map
|
package/dist/createGlobal.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs, PayloadRequest } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends Record<string, unknown>>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequest }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","createGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","result","adapter","fields","operation"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAoB;IAE5D,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAAC,MAAMF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IACrE,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAElF,MAAMY,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACjB,YAAYU,aAAaP,IAAI;IAErE,MAAMe,SAAS,MAAMjB,UAAa;QAChCkB,SAAS,IAAI;QACbf;QACAE;QACAc,QAAQV,aAAaU,MAAM;QAC3BC,WAAW;QACXhB;QACAU;IACF;IAEA,OAAOG;AACT"}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { CreateGlobalVersionArgs, TypeWithID, TypeWithVersion } from 'payload';
|
2
|
-
import type { PostgresAdapter } from './types.js';
|
3
|
-
export declare function createGlobalVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, globalSlug, req, versionData }: CreateGlobalVersionArgs): Promise<TypeWithVersion<T>>;
|
4
|
-
//# sourceMappingURL=createGlobalVersion.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAkB,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EAAE,QAAQ,EAAE,UAAU,EAAE,GAA0B,EAAE,WAAW,EAAE,EAAE,uBAAuB,+BAgC3F"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
2
|
-
import { buildVersionGlobalFields } from 'payload';
|
3
|
-
import toSnakeCase from 'to-snake-case';
|
4
|
-
import { upsertRow } from './upsertRow/index.js';
|
5
|
-
export async function createGlobalVersion({ autosave, globalSlug, req = {}, versionData }) {
|
6
|
-
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
7
|
-
const global = this.payload.globals.config.find(({ slug })=>slug === globalSlug);
|
8
|
-
const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`);
|
9
|
-
const result = await upsertRow({
|
10
|
-
adapter: this,
|
11
|
-
data: {
|
12
|
-
autosave,
|
13
|
-
latest: true,
|
14
|
-
version: versionData
|
15
|
-
},
|
16
|
-
db,
|
17
|
-
fields: buildVersionGlobalFields(global),
|
18
|
-
operation: 'create',
|
19
|
-
req,
|
20
|
-
tableName
|
21
|
-
});
|
22
|
-
const table = this.tables[tableName];
|
23
|
-
if (global.versions.drafts) {
|
24
|
-
await db.execute(sql`
|
25
|
-
UPDATE ${table}
|
26
|
-
SET latest = false
|
27
|
-
WHERE ${table.id} != ${result.id};
|
28
|
-
`);
|
29
|
-
}
|
30
|
-
return result;
|
31
|
-
}
|
32
|
-
|
33
|
-
//# sourceMappingURL=createGlobalVersion.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { CreateGlobalVersionArgs, PayloadRequest, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n { autosave, globalSlug, req = {} as PayloadRequest, versionData }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,wBAAwB,QAAQ,UAAS;AAClD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,WAAW,EAA2B;IAE1F,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAAC,MAAMH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IACrE,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IAEvE,MAAMa,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEnB,YAAYW,OAAOK,IAAI,EAAE,EAAE,IAAI,CAACI,cAAc,CAAC,CAAC;IAE5F,MAAMC,SAAS,MAAMpB,UAA8B;QACjDqB,SAAS,IAAI;QACbC,MAAM;YACJpB;YACAqB,QAAQ;YACRC,SAASnB;QACX;QACAC;QACAmB,QAAQ3B,yBAAyBY;QACjCgB,WAAW;QACXtB;QACAY;IACF;IAEA,MAAMW,QAAQ,IAAI,CAACC,MAAM,CAACZ,UAAU;IAEpC,IAAIN,OAAOmB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAMxB,GAAGyB,OAAO,CAAClC,GAAG,CAAC;aACZ,EAAE8B,MAAM;;YAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AA2CrE,eAAO,MAAM,eAAe,EAAE,eA6F7B,CAAA"}
|
package/dist/createMigration.js
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
/* eslint-disable no-restricted-syntax, no-await-in-loop */ import fs from 'fs';
|
2
|
-
import { createRequire } from 'module';
|
3
|
-
import path from 'path';
|
4
|
-
import { getPredefinedMigration } from 'payload';
|
5
|
-
import prompts from 'prompts';
|
6
|
-
import { fileURLToPath } from 'url';
|
7
|
-
const require = createRequire(import.meta.url);
|
8
|
-
const migrationTemplate = ({ downSQL, imports, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
9
|
-
${imports ? `${imports}\n` : ''}
|
10
|
-
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
|
11
|
-
${upSQL}
|
12
|
-
};
|
13
|
-
|
14
|
-
export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
|
15
|
-
${downSQL}
|
16
|
-
};
|
17
|
-
`;
|
18
|
-
const getDefaultDrizzleSnapshot = ()=>({
|
19
|
-
id: '00000000-0000-0000-0000-000000000000',
|
20
|
-
_meta: {
|
21
|
-
columns: {},
|
22
|
-
schemas: {},
|
23
|
-
tables: {}
|
24
|
-
},
|
25
|
-
dialect: 'pg',
|
26
|
-
enums: {},
|
27
|
-
prevId: '00000000-0000-0000-0000-00000000000',
|
28
|
-
schemas: {},
|
29
|
-
tables: {},
|
30
|
-
version: '5'
|
31
|
-
});
|
32
|
-
export const createMigration = async function createMigration({ file, forceAcceptWarning, migrationName, payload }) {
|
33
|
-
const filename = fileURLToPath(import.meta.url);
|
34
|
-
const dirname = path.dirname(filename);
|
35
|
-
const dir = payload.db.migrationDir;
|
36
|
-
if (!fs.existsSync(dir)) {
|
37
|
-
fs.mkdirSync(dir);
|
38
|
-
}
|
39
|
-
const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload');
|
40
|
-
const drizzleJsonAfter = generateDrizzleJson(this.schema);
|
41
|
-
const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
|
42
|
-
const formattedDate = yyymmdd.replace(/\D/g, '');
|
43
|
-
const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
|
44
|
-
let imports = '';
|
45
|
-
let downSQL;
|
46
|
-
let upSQL;
|
47
|
-
({ downSQL, imports, upSQL } = await getPredefinedMigration({
|
48
|
-
dirname,
|
49
|
-
file,
|
50
|
-
migrationName,
|
51
|
-
payload
|
52
|
-
}));
|
53
|
-
const timestamp = `${formattedDate}_${formattedTime}`;
|
54
|
-
const name = migrationName || file?.split('/').slice(2).join('/');
|
55
|
-
const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
|
56
|
-
const filePath = `${dir}/${fileName}`;
|
57
|
-
let drizzleJsonBefore = getDefaultDrizzleSnapshot();
|
58
|
-
if (!upSQL) {
|
59
|
-
// Get latest migration snapshot
|
60
|
-
const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
|
61
|
-
if (latestSnapshot) {
|
62
|
-
drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
|
63
|
-
}
|
64
|
-
const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
|
65
|
-
const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
|
66
|
-
const sqlExecute = 'await payload.db.drizzle.execute(sql`';
|
67
|
-
if (sqlStatementsUp?.length) {
|
68
|
-
upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
|
69
|
-
}
|
70
|
-
if (sqlStatementsDown?.length) {
|
71
|
-
downSQL = `${sqlExecute}\n ${sqlStatementsDown?.join('\n')}\`)`;
|
72
|
-
}
|
73
|
-
if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
|
74
|
-
const { confirm: shouldCreateBlankMigration } = await prompts({
|
75
|
-
name: 'confirm',
|
76
|
-
type: 'confirm',
|
77
|
-
initial: false,
|
78
|
-
message: 'No schema changes detected. Would you like to create a blank migration file?'
|
79
|
-
}, {
|
80
|
-
onCancel: ()=>{
|
81
|
-
process.exit(0);
|
82
|
-
}
|
83
|
-
});
|
84
|
-
if (!shouldCreateBlankMigration) {
|
85
|
-
process.exit(0);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
// write schema
|
90
|
-
fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
|
91
|
-
// write migration
|
92
|
-
fs.writeFileSync(`${filePath}.ts`, migrationTemplate({
|
93
|
-
downSQL: downSQL || ` // Migration code`,
|
94
|
-
imports,
|
95
|
-
upSQL: upSQL || ` // Migration code`
|
96
|
-
}));
|
97
|
-
payload.logger.info({
|
98
|
-
msg: `Migration created at ${filePath}.ts`
|
99
|
-
});
|
100
|
-
};
|
101
|
-
|
102
|
-
//# sourceMappingURL=createMigration.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst require = createRequire(import.meta.url)\n\nconst migrationTemplate = ({\n downSQL,\n imports,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL}\n};\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL}\n};\n`\n\nconst getDefaultDrizzleSnapshot = (): DrizzleSnapshotJSON => ({\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'pg',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '5',\n})\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = getDefaultDrizzleSnapshot()\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(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await payload.db.drizzle.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n migrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","prompts","fileURLToPath","require","url","migrationTemplate","downSQL","imports","upSQL","getDefaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","logger","info","msg"],"mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,OAAOC,aAAa,UAAS;AAC7B,SAASC,aAAa,QAAQ,MAAK;AAInC,MAAMC,UAAUL,cAAc,YAAYM,GAAG;AAE7C,MAAMC,oBAAoB,CAAC,EACzBC,OAAO,EACPC,OAAO,EACPC,KAAK,EACiB,GAAa,CAAC;AACtC,EAAED,UAAU,CAAC,EAAEA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAEC,MAAM;;;;AAIR,EAAEF,QAAQ;;AAEV,CAAC;AAED,MAAMG,4BAA4B,IAA4B,CAAA;QAC5DC,IAAI;QACJC,OAAO;YACLC,SAAS,CAAC;YACVC,SAAS,CAAC;YACVC,QAAQ,CAAC;QACX;QACAC,SAAS;QACTC,OAAO,CAAC;QACRC,QAAQ;QACRJ,SAAS,CAAC;QACVC,QAAQ,CAAC;QACTI,SAAS;IACX,CAAA;AAEA,OAAO,MAAMC,kBAAmC,eAAeA,gBAE7D,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAE;IAEpD,MAAMC,WAAWtB,cAAc,YAAYE,GAAG;IAC9C,MAAMqB,UAAU1B,KAAK0B,OAAO,CAACD;IAC7B,MAAME,MAAMH,QAAQI,EAAE,CAACC,YAAY;IACnC,IAAI,CAAC/B,GAAGgC,UAAU,CAACH,MAAM;QACvB7B,GAAGiC,SAAS,CAACJ;IACf;IACA,MAAM,EAAEK,mBAAmB,EAAEC,iBAAiB,EAAE,GAA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AMY,aAAa;QAEnB,IAAIF,iBAAiBG,QAAQ;YAC3BtD,QAAQ,CAAC,EAAEqD,WAAW,GAAG,EAAEF,iBAAiBb,KAAK,MAAM,GAAG,CAAC;QAC7D;QACA,IAAIc,mBAAmBE,QAAQ;YAC7BxD,UAAU,CAAC,EAAEuD,WAAW,GAAG,EAAED,mBAAmBd,KAAK,MAAM,GAAG,CAAC;QACjE;QAEA,IAAI,CAACtC,OAAOsD,UAAU,CAACxD,SAASwD,UAAU,CAACzC,oBAAoB;YAC7D,MAAM,EAAE0C,SAASC,0BAA0B,EAAE,GAAG,MAAM/D,QACpD;gBACE2C,MAAM;gBACNqB,MAAM;gBACNC,SAAS;gBACTC,SAAS;YACX,GACA;gBACEC,UAAU;oBACRC,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACN,4BAA4B;gBAC/BK,QAAQC,IAAI,CAAC;YACf;QACF;IACF;IAEA,eAAe;IACfzE,GAAG0E,aAAa,CAAC,CAAC,EAAEvB,SAAS,KAAK,CAAC,EAAEQ,KAAKgB,SAAS,CAACvC,kBAAkB,MAAM;IAE5E,kBAAkB;IAClBpC,GAAG0E,aAAa,CACd,CAAC,EAAEvB,SAAS,GAAG,CAAC,EAChB3C,kBAAkB;QAChBC,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCC;QACAC,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAEFe,QAAQkD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAE3B,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
|
package/dist/createVersion.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { CreateVersionArgs, TypeWithID, TypeWithVersion } from 'payload';
|
2
|
-
import type { PostgresAdapter } from './types.js';
|
3
|
-
export declare function createVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, collectionSlug, parent, req, versionData, }: CreateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
4
|
-
//# sourceMappingURL=createVersion.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAkB,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,cAAc,EACd,MAAM,EACN,GAA0B,EAC1B,WAAW,GACZ,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAsCxB"}
|
package/dist/createVersion.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
2
|
-
import { buildVersionCollectionFields } from 'payload';
|
3
|
-
import toSnakeCase from 'to-snake-case';
|
4
|
-
import { upsertRow } from './upsertRow/index.js';
|
5
|
-
export async function createVersion({ autosave, collectionSlug, parent, req = {}, versionData }) {
|
6
|
-
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
7
|
-
const collection = this.payload.collections[collectionSlug].config;
|
8
|
-
const defaultTableName = toSnakeCase(collection.slug);
|
9
|
-
const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`);
|
10
|
-
const version = {
|
11
|
-
...versionData
|
12
|
-
};
|
13
|
-
if (version.id) delete version.id;
|
14
|
-
const result = await upsertRow({
|
15
|
-
adapter: this,
|
16
|
-
data: {
|
17
|
-
autosave,
|
18
|
-
latest: true,
|
19
|
-
parent,
|
20
|
-
version
|
21
|
-
},
|
22
|
-
db,
|
23
|
-
fields: buildVersionCollectionFields(collection),
|
24
|
-
operation: 'create',
|
25
|
-
req,
|
26
|
-
tableName
|
27
|
-
});
|
28
|
-
const table = this.tables[tableName];
|
29
|
-
if (collection.versions.drafts) {
|
30
|
-
await db.execute(sql`
|
31
|
-
UPDATE ${table}
|
32
|
-
SET latest = false
|
33
|
-
WHERE ${table.id} != ${result.id}
|
34
|
-
AND ${table.parent} = ${parent}
|
35
|
-
`);
|
36
|
-
}
|
37
|
-
return result;
|
38
|
-
}
|
39
|
-
|
40
|
-
//# sourceMappingURL=createVersion.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, PayloadRequest, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n collectionSlug,\n parent,\n req = {} as PayloadRequest,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const defaultTableName = toSnakeCase(collection.slug)\n\n const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)\n\n const version = { ...versionData }\n if (version.id) delete version.id\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (collection.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id}\n AND ${table.parent} = ${parent}\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","createVersion","autosave","collectionSlug","parent","req","versionData","db","sessions","transactionID","drizzle","collection","payload","collections","config","defaultTableName","slug","tableName","tableNameMap","get","versionsSuffix","version","id","result","adapter","data","latest","fields","operation","table","tables","versions","drafts","execute"],"mappings":"AAEA,SAASA,G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