Compare commits
13 Commits
v3.0.0-alp
...
v3.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81b33cee5c | ||
|
|
020dcaad75 | ||
|
|
9bc56bcfc7 | ||
|
|
8325fadeb3 | ||
|
|
d54275b3bd | ||
|
|
29d20423a3 | ||
|
|
e539816253 | ||
|
|
922ce9ef5f | ||
|
|
b73ec6ae94 | ||
|
|
4a11bf956d | ||
|
|
3b3bb6c80a | ||
|
|
0f323ff2e3 | ||
|
|
3305c65ae6 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload-monorepo",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces:": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-mongodb",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "The officially supported MongoDB database adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -45,7 +45,9 @@ export const createMigration: CreateMigration = async function createMigration({
|
||||
|
||||
// Check if predefined migration exists
|
||||
if (fs.existsSync(cleanPath)) {
|
||||
let migration = await eval(`${require ? 'require' : 'import'}(${cleanPath})`)
|
||||
let migration = await eval(
|
||||
`${typeof require === 'function' ? 'require' : 'import'}(${cleanPath})`,
|
||||
)
|
||||
if ('default' in migration) migration = migration.default
|
||||
const { down, up } = migration
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-postgres",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "The officially supported Postgres database adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -3,15 +3,17 @@ import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'
|
||||
import type { CreateMigration } from 'payload/database'
|
||||
|
||||
import fs from 'fs'
|
||||
import { createRequire } from 'module'
|
||||
import prompts from 'prompts'
|
||||
|
||||
import type { PostgresAdapter } from './types.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
const migrationTemplate = (
|
||||
upSQL?: string,
|
||||
downSQL?: string,
|
||||
) => `import { MigrateUpArgs, MigrateDownArgs } from '@payloadcms/db-postgres'
|
||||
import { sql } from 'drizzle-orm'
|
||||
) => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ payload }: MigrateUpArgs): Promise<void> {
|
||||
${
|
||||
@@ -60,9 +62,7 @@ export const createMigration: CreateMigration = async function createMigration(
|
||||
fs.mkdirSync(dir)
|
||||
}
|
||||
|
||||
const { generateDrizzleJson, generateMigration } = require
|
||||
? require('drizzle-kit/payload')
|
||||
: await import('drizzle-kit/payload')
|
||||
const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')
|
||||
|
||||
const [yyymmdd, hhmmss] = new Date().toISOString().split('T')
|
||||
const formattedDate = yyymmdd.replace(/\D/g, '')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Payload } from 'payload'
|
||||
import type { DatabaseAdapterObj } from 'payload/database'
|
||||
export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
@@ -38,7 +39,7 @@ import { updateGlobal } from './updateGlobal.js'
|
||||
import { updateGlobalVersion } from './updateGlobalVersion.js'
|
||||
import { updateVersion } from './updateVersion.js'
|
||||
|
||||
export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
|
||||
export { sql } from 'drizzle-orm'
|
||||
|
||||
export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
|
||||
function adapter({ payload }: { payload: Payload }) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { Payload } from 'payload'
|
||||
import type { Migration } from 'payload/database'
|
||||
import type { PayloadRequest } from 'payload/types'
|
||||
|
||||
import { createRequire } from 'module'
|
||||
import {
|
||||
commitTransaction,
|
||||
initTransaction,
|
||||
@@ -17,6 +18,8 @@ import { createMigrationTable } from './utilities/createMigrationTable.js'
|
||||
import { migrationTableExists } from './utilities/migrationTableExists.js'
|
||||
import { parseError } from './utilities/parseError.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
export async function migrate(this: PostgresAdapter): Promise<void> {
|
||||
const { payload } = this
|
||||
const migrationFiles = await readMigrationFiles({ payload })
|
||||
@@ -82,9 +85,7 @@ export async function migrate(this: PostgresAdapter): Promise<void> {
|
||||
}
|
||||
|
||||
async function runMigrationFile(payload: Payload, migration: Migration, batch: number) {
|
||||
const { generateDrizzleJson } = require
|
||||
? require('drizzle-kit/payload')
|
||||
: await import('drizzle-kit/payload')
|
||||
const { generateDrizzleJson } = require('drizzle-kit/payload')
|
||||
|
||||
const start = Date.now()
|
||||
const req = { payload } as PayloadRequest
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core'
|
||||
import { createRequire } from 'module'
|
||||
import prompts from 'prompts'
|
||||
|
||||
import type { PostgresAdapter } from '../types.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
/**
|
||||
* Pushes the development schema to the database using Drizzle.
|
||||
*
|
||||
@@ -11,9 +14,7 @@ import type { PostgresAdapter } from '../types.js'
|
||||
* @returns {Promise<void>} - A promise that resolves once the schema push is complete.
|
||||
*/
|
||||
export const pushDevSchema = async (db: PostgresAdapter) => {
|
||||
const { pushSchema } = require
|
||||
? require('drizzle-kit/payload')
|
||||
: await import('drizzle-kit/payload')
|
||||
const { pushSchema } = require('drizzle-kit/payload')
|
||||
|
||||
// This will prompt if clarifications are needed for Drizzle to push new schema
|
||||
const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/graphql",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.d.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/next",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"main": "./src/index.js",
|
||||
"types": "./src/index.js",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
||||
"license": "MIT",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -37,7 +37,7 @@ export const readMigrationFiles = async ({
|
||||
files.map(async (filePath) => {
|
||||
// eval used to circumvent errors bundling
|
||||
let migration = await eval(
|
||||
`${require ? 'require' : 'import'}('${filePath.replaceAll('\\', '/')}')`,
|
||||
`${typeof require === 'function' ? 'require' : 'import'}('${filePath.replaceAll('\\', '/')}')`,
|
||||
)
|
||||
if ('default' in migration) migration = migration.default
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
||||
return create<T>(this, options)
|
||||
}
|
||||
|
||||
db: BaseDatabaseAdapter
|
||||
db: DatabaseAdapter
|
||||
|
||||
decrypt = decrypt
|
||||
|
||||
@@ -469,6 +469,6 @@ interface RequestContext {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
// type DatabaseAdapter = BaseDatabaseAdapter
|
||||
type DatabaseAdapter = BaseDatabaseAdapter
|
||||
|
||||
export type { GeneratedTypes, Payload, RequestContext }
|
||||
export type { DatabaseAdapter, GeneratedTypes, Payload, RequestContext }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-cloud-storage",
|
||||
"description": "The official cloud storage plugin for Payload CMS",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-cloud",
|
||||
"description": "The official Payload Cloud plugin",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-form-builder",
|
||||
"description": "Form builder plugin for Payload CMS",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-nested-docs",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "The official Nested Docs plugin for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-redirects",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-search",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-seo",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-lexical",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "The officially supported Lexical richtext adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-slate",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"description": "The officially supported Slate richtext adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/translations",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"main": "./src/exports/index.ts",
|
||||
"types": "./src/types.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/ui",
|
||||
"version": "3.0.0-alpha.50",
|
||||
"version": "3.0.0-alpha.53",
|
||||
"type": "module",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -367,6 +367,7 @@ describe('admin', () => {
|
||||
test('collection — should render preview button when `admin.preview` is set', async () => {
|
||||
const collectionWithPreview = new AdminUrlUtil(serverURL, postsCollectionSlug)
|
||||
await page.goto(collectionWithPreview.create)
|
||||
await page.waitForURL(collectionWithPreview.create)
|
||||
await page.locator('#field-title').fill(title)
|
||||
await saveDocAndAssert(page)
|
||||
await expect(page.locator('.btn.preview-btn')).toBeVisible()
|
||||
@@ -375,6 +376,7 @@ describe('admin', () => {
|
||||
test('collection — should not render preview button when `admin.preview` is not set', async () => {
|
||||
const collectionWithoutPreview = new AdminUrlUtil(serverURL, group1Collection1Slug)
|
||||
await page.goto(collectionWithoutPreview.create)
|
||||
await page.waitForURL(collectionWithoutPreview.create)
|
||||
await page.locator('#field-title').fill(title)
|
||||
await saveDocAndAssert(page)
|
||||
await expect(page.locator('.btn.preview-btn')).toBeHidden()
|
||||
@@ -769,6 +771,7 @@ describe('admin', () => {
|
||||
|
||||
test('should link second cell', async () => {
|
||||
const { id } = await createPost()
|
||||
await page.reload()
|
||||
const linkCell = page.locator(`${tableRowLocator} td`).nth(1).locator('a')
|
||||
await expect(linkCell).toHaveAttribute('href', `/admin/collections/posts/${id}`)
|
||||
|
||||
@@ -1180,6 +1183,7 @@ describe('admin', () => {
|
||||
})
|
||||
|
||||
test('should select multiple rows', async () => {
|
||||
await page.reload()
|
||||
const selectAll = page.locator('.checkbox-input:has(#select-all)')
|
||||
await page.locator('.row-1 .cell-_select input').check()
|
||||
|
||||
@@ -1251,6 +1255,7 @@ describe('admin', () => {
|
||||
})
|
||||
|
||||
test('should sort', async () => {
|
||||
await page.reload()
|
||||
const upChevron = page.locator('#heading-number .sort-column__asc')
|
||||
const downChevron = page.locator('#heading-number .sort-column__desc')
|
||||
|
||||
|
||||
@@ -15,6 +15,19 @@ import {
|
||||
} from './slugs.js'
|
||||
|
||||
export const seed = async (_payload) => {
|
||||
if (_payload.db.name === 'mongoose') {
|
||||
await Promise.all(
|
||||
_payload.config.collections.map(async (coll) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
_payload.db?.collections[coll.slug]?.ensureIndexes(function (err) {
|
||||
if (err) reject(err)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
await executePromises(
|
||||
[
|
||||
() =>
|
||||
|
||||
@@ -396,6 +396,8 @@ describe('fields - relationship', () => {
|
||||
)
|
||||
await button.click()
|
||||
|
||||
await wait(500)
|
||||
|
||||
const documentDrawer = page.locator('[id^=doc-drawer_relation-one_1_]')
|
||||
await expect(documentDrawer).toBeVisible()
|
||||
})
|
||||
|
||||
@@ -1917,9 +1917,10 @@ describe('fields', () => {
|
||||
|
||||
test('should upload using the document drawer', async () => {
|
||||
await uploadImage()
|
||||
await wait(500)
|
||||
// Open the media drawer and create a png upload
|
||||
await page.locator('.field-type.upload .upload__toggler.doc-drawer__toggler').click()
|
||||
await wait(500) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers
|
||||
await wait(1000) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers
|
||||
await page
|
||||
.locator('[id^=doc-drawer_uploads_1_] .file-field__upload input[type="file"]')
|
||||
.setInputFiles(path.resolve(dirname, './uploads/payload.png'))
|
||||
@@ -1945,8 +1946,8 @@ describe('fields', () => {
|
||||
|
||||
test('should clear selected upload', async () => {
|
||||
await uploadImage()
|
||||
await wait(1000) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers
|
||||
await page.locator('.field-type.upload .upload__toggler.doc-drawer__toggler').click()
|
||||
await wait(500) // TODO: Fix this. Need to wait a bit until the form in the drawer mounted, otherwise values sometimes disappear. This is an issue for all drawers
|
||||
|
||||
await page
|
||||
.locator('[id^=doc-drawer_uploads_1_] .file-field__upload input[type="file"]')
|
||||
|
||||
@@ -12,13 +12,17 @@ export default async () => {
|
||||
(!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongodb') &&
|
||||
!global._mongoMemoryServer
|
||||
) {
|
||||
global._mongoMemoryServer = await MongoMemoryReplSet.create({
|
||||
const db = await MongoMemoryReplSet.create({
|
||||
replSet: {
|
||||
count: 3,
|
||||
dbName: 'payloadmemory',
|
||||
},
|
||||
})
|
||||
|
||||
process.env.MONGODB_MEMORY_SERVER_URI = global._mongoMemoryServer.getUri()
|
||||
global._mongoMemoryServer = db
|
||||
|
||||
process.env.MONGODB_MEMORY_SERVER_URI = `${global._mongoMemoryServer.getUri()}&retryWrites=true`
|
||||
|
||||
console.log(process.env.MONGODB_MEMORY_SERVER_URI)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user