diff --git a/src/bin/generateTypes.ts b/src/bin/generateTypes.ts index b1a6fa323..8016c1679 100644 --- a/src/bin/generateTypes.ts +++ b/src/bin/generateTypes.ts @@ -390,6 +390,7 @@ function configToJsonSchema(config: SanitizedConfig): JSONSchema4 { export function generateTypes(): void { const logger = Logger(); const config = loadConfig(); + const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile; logger.info('Compiling TS types for Collections and Globals...'); @@ -402,8 +403,8 @@ export function generateTypes(): void { singleQuote: true, }, }).then((compiled) => { - fs.writeFileSync(config.typescript.outputFile, compiled); - logger.info(`Types written to ${config.typescript.outputFile}`); + fs.writeFileSync(outputFile, compiled); + logger.info(`Types written to ${outputFile}`); }); } diff --git a/test/access-control/payload-types.ts b/test/access-control/payload-types.ts index 867e05f97..1a6091d0a 100644 --- a/test/access-control/payload-types.ts +++ b/test/access-control/payload-types.ts @@ -52,7 +52,7 @@ export interface RestrictedVersion { */ export interface SiblingDatum { id: string; - array?: { + array: { allowPublicReadability?: boolean; text?: string; id?: string; diff --git a/test/admin/payload-types.ts b/test/admin/payload-types.ts index 8416d61e0..b1e2c80c4 100644 --- a/test/admin/payload-types.ts +++ b/test/admin/payload-types.ts @@ -6,6 +6,14 @@ */ export interface Config {} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "global". + */ +export interface Global { + id: string; + title?: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "posts". diff --git a/test/array-update/payload-types.ts b/test/array-update/payload-types.ts index 5dfead267..4e850b84c 100644 --- a/test/array-update/payload-types.ts +++ b/test/array-update/payload-types.ts @@ -12,7 +12,7 @@ export interface Config {} */ export interface Array { id: string; - array?: { + array: { required: string; optional?: string; id?: string; diff --git a/test/auth/payload-types.ts b/test/auth/payload-types.ts index fe69f8482..197be7312 100644 --- a/test/auth/payload-types.ts +++ b/test/auth/payload-types.ts @@ -12,6 +12,7 @@ export interface Config {} */ export interface User { id: string; + roles: ('admin' | 'editor' | 'moderator' | 'user' | 'viewer')[]; enableAPIKey?: boolean; apiKey?: string; apiKeyIndex?: string; @@ -20,7 +21,6 @@ export interface User { resetPasswordExpiration?: string; loginAttempts?: number; lockUntil?: string; - roles: ('admin' | 'editor' | 'moderator' | 'user' | 'viewer')[]; createdAt: string; updatedAt: string; } diff --git a/test/buildConfig.ts b/test/buildConfig.ts index c4ea2888a..3b5c9b76c 100644 --- a/test/buildConfig.ts +++ b/test/buildConfig.ts @@ -3,9 +3,6 @@ import { Config, SanitizedConfig } from '../src/config/types'; import { buildConfig as buildPayloadConfig } from '../src/config/build'; const baseConfig: Config = { - typescript: { - outputFile: process.env.PAYLOAD_TS_OUTPUT_PATH, - }, telemetry: false, }; diff --git a/test/fields-relationship/payload-types.ts b/test/fields-relationship/payload-types.ts index 518524429..e668538a5 100644 --- a/test/fields-relationship/payload-types.ts +++ b/test/fields-relationship/payload-types.ts @@ -78,32 +78,6 @@ export interface RelationWithTitle { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "group-nested-relation-with-title". - */ -export interface GroupNestedRelationWithTitle { - id: string; - group?: { - relation?: string | NestedRelationWithTitle; - }; - createdAt: string; - updatedAt: string; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "nested-relation-with-title". - */ -export interface NestedRelationWithTitle { - id: string; - group?: { - subGroup?: { - relation?: string | RelationOne; - }; - }; - createdAt: string; - updatedAt: string; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "users". diff --git a/test/globals/payload-types.ts b/test/globals/payload-types.ts new file mode 100644 index 000000000..a73ed769e --- /dev/null +++ b/test/globals/payload-types.ts @@ -0,0 +1,41 @@ +/* tslint:disable */ +/** + * This file was automatically generated by Payload CMS. + * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config, + * and re-run `payload generate:types` to regenerate this file. + */ + +export interface Config {} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "global". + */ +export interface Global { + id: string; + title?: string; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "array". + */ +export interface Array { + id: string; + array: { + text?: string; + id?: string; + }[]; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "users". + */ +export interface User { + id: string; + email?: string; + resetPasswordToken?: string; + resetPasswordExpiration?: string; + loginAttempts?: number; + lockUntil?: string; + createdAt: string; + updatedAt: string; +} diff --git a/test/localization/payload-types.ts b/test/localization/payload-types.ts index 8717f4083..6bfc1edbe 100644 --- a/test/localization/payload-types.ts +++ b/test/localization/payload-types.ts @@ -6,6 +6,21 @@ */ export interface Config {} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "users". + */ +export interface User { + id: string; + relation?: string | LocalizedPost; + email?: string; + resetPasswordToken?: string; + resetPasswordExpiration?: string; + loginAttempts?: number; + lockUntil?: string; + createdAt: string; + updatedAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "localized-posts". @@ -81,17 +96,3 @@ export interface Dummy { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "users". - */ -export interface User { - id: string; - email?: string; - resetPasswordToken?: string; - resetPasswordExpiration?: string; - loginAttempts?: number; - lockUntil?: string; - createdAt: string; - updatedAt: string; -} diff --git a/test/uploads/payload-types.ts b/test/uploads/payload-types.ts index 7a846af56..8c8ceb6ed 100644 --- a/test/uploads/payload-types.ts +++ b/test/uploads/payload-types.ts @@ -28,8 +28,8 @@ export interface Media { filesize?: number; width?: number; height?: number; - sizes?: { - maintainedAspectRatio?: { + sizes: { + maintainedAspectRatio: { url?: string; width?: number; height?: number; @@ -37,7 +37,7 @@ export interface Media { filesize?: number; filename?: string; }; - tablet?: { + tablet: { url?: string; width?: number; height?: number; @@ -45,7 +45,7 @@ export interface Media { filesize?: number; filename?: string; }; - mobile?: { + mobile: { url?: string; width?: number; height?: number; @@ -53,7 +53,7 @@ export interface Media { filesize?: number; filename?: string; }; - icon?: { + icon: { url?: string; width?: number; height?: number; @@ -65,6 +65,19 @@ export interface Media { createdAt: string; updatedAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "unstored-media". + */ +export interface UnstoredMedia { + id: string; + url?: string; + filename?: string; + mimeType?: string; + filesize?: number; + createdAt: string; + updatedAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "users". diff --git a/test/versions/payload-types.ts b/test/versions/payload-types.ts index 545c3ef3f..07ed78d49 100644 --- a/test/versions/payload-types.ts +++ b/test/versions/payload-types.ts @@ -8,10 +8,34 @@ export interface Config {} /** * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "slugname". + * via the `definition` "autosave-global". */ -export interface Slugname { +export interface AutosaveGlobal { id: string; + title: string; + _status?: 'draft' | 'published'; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "autosave-posts". + */ +export interface AutosavePost { + id: string; + title: string; + description: string; + _status?: 'draft' | 'published'; + createdAt: string; + updatedAt: string; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "draft-posts". + */ +export interface DraftPost { + id: string; + title: string; + description: string; + _status?: 'draft' | 'published'; createdAt: string; updatedAt: string; }