diff --git a/scripts/regenerate-templates-types.sh b/scripts/regenerate-templates-types.sh new file mode 100755 index 00000000000..89f527ee76f --- /dev/null +++ b/scripts/regenerate-templates-types.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Path to the templates directory +TEMPLATES_DIR="./templates" + +# Directories to exclude +EXCLUDE_DIRS=("_data" "_template") # Add names of directories to exclude + +# Function to process a template directory asynchronously +process_template() { + TEMPLATE_DIR="$1" + DIR_NAME=$(basename "$TEMPLATE_DIR") + + echo "Processing $TEMPLATE_DIR" + + # Navigate into the template directory + cd "$TEMPLATE_DIR" + + # Check if pnpm-lock.yaml exists initially + if [[ -f "pnpm-lock.yaml" ]]; then + LOCK_FILE_EXISTED=true + else + LOCK_FILE_EXISTED=false + fi + + # Run the commands + rm -rf node_modules pnpm-lock.yaml + pnpm i --ignore-workspace + BLOB_READ_WRITE_TOKEN=vercel_blob_rw_abc123_xyz789 pnpm payload generate:types + + # Reset any changes to pnpm-lock.yaml in git + if git diff --quiet pnpm-lock.yaml; then + echo "No changes to pnpm-lock.yaml" + else + echo "Resetting changes to pnpm-lock.yaml" + git checkout -- pnpm-lock.yaml + fi + + # Remove pnpm-lock.yaml if it didn’t exist initially + if [[ "$LOCK_FILE_EXISTED" == false ]]; then + echo "Removing pnpm-lock.yaml as it didn't exist before." + rm -f pnpm-lock.yaml + fi + + # Navigate back to the original directory + cd - > /dev/null +} + +# Loop through each directory in the templates folder +for TEMPLATE_DIR in "$TEMPLATES_DIR"/*; do + if [ -d "$TEMPLATE_DIR" ]; then + DIR_NAME=$(basename "$TEMPLATE_DIR") + + # Check if the directory is in the exclusion list + if [[ " ${EXCLUDE_DIRS[@]} " =~ " $DIR_NAME " ]]; then + echo "Skipping $TEMPLATE_DIR" + continue + fi + + # Process the template directory asynchronously + process_template "$TEMPLATE_DIR" & + fi +done + +# Wait for all background jobs to finish +wait +echo "All templates processed." diff --git a/templates/blank/src/payload-types.ts b/templates/blank/src/payload-types.ts index d98da0d0485..d50c1fb1dc3 100644 --- a/templates/blank/src/payload-types.ts +++ b/templates/blank/src/payload-types.ts @@ -13,17 +13,31 @@ export interface Config { collections: { users: User; media: Media; + 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; }; + collectionsJoins: {}; + collectionsSelect: { + users: UsersSelect | UsersSelect; + media: MediaSelect | MediaSelect; + 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; + 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; + 'payload-migrations': PayloadMigrationsSelect | PayloadMigrationsSelect; + }; db: { defaultIDType: string; }; globals: {}; + globalsSelect: {}; locale: null; user: User & { collection: 'users'; }; + jobs: { + tasks: unknown; + workflows: unknown; + }; } export interface UserAuthOperations { forgotPassword: { @@ -79,6 +93,29 @@ export interface Media { focalX?: number | null; focalY?: number | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents". + */ +export interface PayloadLockedDocument { + id: string; + document?: + | ({ + relationTo: 'users'; + value: string | User; + } | null) + | ({ + relationTo: 'media'; + value: string | Media; + } | null); + globalSlug?: string | null; + user: { + relationTo: 'users'; + value: string | User; + }; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-preferences". @@ -113,6 +150,71 @@ export interface PayloadMigration { updatedAt: string; createdAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "users_select". + */ +export interface UsersSelect { + updatedAt?: T; + createdAt?: T; + email?: T; + resetPasswordToken?: T; + resetPasswordExpiration?: T; + salt?: T; + hash?: T; + loginAttempts?: T; + lockUntil?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "media_select". + */ +export interface MediaSelect { + alt?: T; + updatedAt?: T; + createdAt?: T; + url?: T; + thumbnailURL?: T; + filename?: T; + mimeType?: T; + filesize?: T; + width?: T; + height?: T; + focalX?: T; + focalY?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents_select". + */ +export interface PayloadLockedDocumentsSelect { + document?: T; + globalSlug?: T; + user?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-preferences_select". + */ +export interface PayloadPreferencesSelect { + user?: T; + key?: T; + value?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-migrations_select". + */ +export interface PayloadMigrationsSelect { + name?: T; + batch?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "auth". diff --git a/templates/with-payload-cloud/src/payload-types.ts b/templates/with-payload-cloud/src/payload-types.ts index d98da0d0485..d50c1fb1dc3 100644 --- a/templates/with-payload-cloud/src/payload-types.ts +++ b/templates/with-payload-cloud/src/payload-types.ts @@ -13,17 +13,31 @@ export interface Config { collections: { users: User; media: Media; + 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; }; + collectionsJoins: {}; + collectionsSelect: { + users: UsersSelect | UsersSelect; + media: MediaSelect | MediaSelect; + 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; + 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; + 'payload-migrations': PayloadMigrationsSelect | PayloadMigrationsSelect; + }; db: { defaultIDType: string; }; globals: {}; + globalsSelect: {}; locale: null; user: User & { collection: 'users'; }; + jobs: { + tasks: unknown; + workflows: unknown; + }; } export interface UserAuthOperations { forgotPassword: { @@ -79,6 +93,29 @@ export interface Media { focalX?: number | null; focalY?: number | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents". + */ +export interface PayloadLockedDocument { + id: string; + document?: + | ({ + relationTo: 'users'; + value: string | User; + } | null) + | ({ + relationTo: 'media'; + value: string | Media; + } | null); + globalSlug?: string | null; + user: { + relationTo: 'users'; + value: string | User; + }; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-preferences". @@ -113,6 +150,71 @@ export interface PayloadMigration { updatedAt: string; createdAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "users_select". + */ +export interface UsersSelect { + updatedAt?: T; + createdAt?: T; + email?: T; + resetPasswordToken?: T; + resetPasswordExpiration?: T; + salt?: T; + hash?: T; + loginAttempts?: T; + lockUntil?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "media_select". + */ +export interface MediaSelect { + alt?: T; + updatedAt?: T; + createdAt?: T; + url?: T; + thumbnailURL?: T; + filename?: T; + mimeType?: T; + filesize?: T; + width?: T; + height?: T; + focalX?: T; + focalY?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents_select". + */ +export interface PayloadLockedDocumentsSelect { + document?: T; + globalSlug?: T; + user?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-preferences_select". + */ +export interface PayloadPreferencesSelect { + user?: T; + key?: T; + value?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-migrations_select". + */ +export interface PayloadMigrationsSelect { + name?: T; + batch?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "auth". diff --git a/templates/with-vercel-mongodb/src/payload-types.ts b/templates/with-vercel-mongodb/src/payload-types.ts index d98da0d0485..d50c1fb1dc3 100644 --- a/templates/with-vercel-mongodb/src/payload-types.ts +++ b/templates/with-vercel-mongodb/src/payload-types.ts @@ -13,17 +13,31 @@ export interface Config { collections: { users: User; media: Media; + 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; }; + collectionsJoins: {}; + collectionsSelect: { + users: UsersSelect | UsersSelect; + media: MediaSelect | MediaSelect; + 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; + 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; + 'payload-migrations': PayloadMigrationsSelect | PayloadMigrationsSelect; + }; db: { defaultIDType: string; }; globals: {}; + globalsSelect: {}; locale: null; user: User & { collection: 'users'; }; + jobs: { + tasks: unknown; + workflows: unknown; + }; } export interface UserAuthOperations { forgotPassword: { @@ -79,6 +93,29 @@ export interface Media { focalX?: number | null; focalY?: number | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents". + */ +export interface PayloadLockedDocument { + id: string; + document?: + | ({ + relationTo: 'users'; + value: string | User; + } | null) + | ({ + relationTo: 'media'; + value: string | Media; + } | null); + globalSlug?: string | null; + user: { + relationTo: 'users'; + value: string | User; + }; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-preferences". @@ -113,6 +150,71 @@ export interface PayloadMigration { updatedAt: string; createdAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "users_select". + */ +export interface UsersSelect { + updatedAt?: T; + createdAt?: T; + email?: T; + resetPasswordToken?: T; + resetPasswordExpiration?: T; + salt?: T; + hash?: T; + loginAttempts?: T; + lockUntil?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "media_select". + */ +export interface MediaSelect { + alt?: T; + updatedAt?: T; + createdAt?: T; + url?: T; + thumbnailURL?: T; + filename?: T; + mimeType?: T; + filesize?: T; + width?: T; + height?: T; + focalX?: T; + focalY?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-locked-documents_select". + */ +export interface PayloadLockedDocumentsSelect { + document?: T; + globalSlug?: T; + user?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-preferences_select". + */ +export interface PayloadPreferencesSelect { + user?: T; + key?: T; + value?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "payload-migrations_select". + */ +export interface PayloadMigrationsSelect { + name?: T; + batch?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "auth".