payload 3.0.0-beta.3 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +2 -0
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/PreviewButton.d.ts +2 -1
- package/dist/admin/elements/PreviewButton.d.ts.map +1 -1
- package/dist/admin/elements/PreviewButton.js.map +1 -1
- package/dist/admin/elements/PublishButton.d.ts +2 -1
- package/dist/admin/elements/PublishButton.d.ts.map +1 -1
- package/dist/admin/elements/PublishButton.js.map +1 -1
- package/dist/admin/elements/SaveButton.d.ts +2 -1
- package/dist/admin/elements/SaveButton.d.ts.map +1 -1
- package/dist/admin/elements/SaveButton.js.map +1 -1
- package/dist/admin/elements/SaveDraftButton.d.ts +2 -1
- package/dist/admin/elements/SaveDraftButton.d.ts.map +1 -1
- package/dist/admin/elements/SaveDraftButton.js.map +1 -1
- package/dist/admin/elements/WithServerSideProps.d.ts +5 -0
- package/dist/admin/elements/WithServerSideProps.d.ts.map +1 -0
- package/dist/admin/elements/WithServerSideProps.js +3 -0
- package/dist/admin/elements/WithServerSideProps.js.map +1 -0
- package/dist/admin/forms/FieldDescription.d.ts +4 -2
- package/dist/admin/forms/FieldDescription.d.ts.map +1 -1
- package/dist/admin/forms/FieldDescription.js.map +1 -1
- package/dist/admin/forms/RowLabel.d.ts +2 -1
- package/dist/admin/forms/RowLabel.d.ts.map +1 -1
- package/dist/admin/forms/RowLabel.js.map +1 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/executeAuthStrategies.d.ts +3 -2
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.js.map +1 -1
- package/dist/auth/getFieldsToSign.d.ts +2 -2
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +3 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/bin/loader/index.d.ts.map +1 -1
- package/dist/bin/loader/index.js +4 -0
- package/dist/bin/loader/index.js.map +1 -1
- package/dist/collections/config/client.d.ts +11 -11
- package/dist/collections/config/types.d.ts +7 -6
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js +3 -5
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +1 -4
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/config/find.d.ts.map +1 -1
- package/dist/config/find.js +20 -9
- package/dist/config/find.js.map +1 -1
- package/dist/config/types.d.ts +20 -14
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -1
- package/dist/exports/utilities.d.ts +1 -2
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +1 -2
- package/dist/exports/utilities.js.map +1 -1
- package/dist/fields/config/client.d.ts +102 -102
- package/dist/fields/config/sanitize.spec.js +4 -1
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +45 -46
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.d.ts +2 -2
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.js.map +1 -1
- package/dist/fields/validations.d.ts +4 -4
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +5 -9
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js +6 -1
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/config/types.d.ts +1 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/preferences/operations/update.d.ts +1 -1
- package/dist/preferences/types.d.ts +1 -2
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +34 -1
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/isEntityHidden.d.ts +2 -2
- package/dist/utilities/isEntityHidden.d.ts.map +1 -1
- package/dist/utilities/isEntityHidden.js.map +1 -1
- package/dist/utilities/isReactComponent.d.ts +2 -0
- package/dist/utilities/isReactComponent.d.ts.map +1 -1
- package/dist/utilities/isReactComponent.js +8 -2
- package/dist/utilities/isReactComponent.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts +2 -2
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +12 -0
- package/utilities.d.ts +1 -2
- package/utilities.js +1 -2
- package/dist/utilities/getIDType.d.ts +0 -4
- package/dist/utilities/getIDType.d.ts.map +0 -1
- package/dist/utilities/getIDType.js +0 -8
- package/dist/utilities/getIDType.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { User } from '../auth/index.js';
|
|
2
1
|
import type { PayloadRequest } from '../types/index.js';
|
|
3
2
|
export type PreferenceRequest = {
|
|
4
3
|
key: string;
|
|
5
4
|
overrideAccess?: boolean;
|
|
6
5
|
req: PayloadRequest;
|
|
7
|
-
user:
|
|
6
|
+
user: PayloadRequest['user'];
|
|
8
7
|
};
|
|
9
8
|
export type PreferenceUpdateRequest = PreferenceRequest & {
|
|
10
9
|
value: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/preferences/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/preferences/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAE5E,MAAM,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAA;AAE3C,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB,CAAC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,oBAAoB,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,iBAAiB,CAAA;CAC1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { User } from '../auth/index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user:
|
|
1
|
+
{"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { User } from '../auth/index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user: PayloadRequest['user']\n}\n\nexport type PreferenceUpdateRequest = PreferenceRequest & { value: unknown }\n\nexport type CollapsedPreferences = string[]\n\nexport type TabsPreferences = Array<{\n [path: string]: number\n}>\n\nexport type InsideFieldsPreferences = {\n collapsed: CollapsedPreferences\n tabIndex: number\n}\nexport type FieldsPreferences = {\n [key: string]: InsideFieldsPreferences\n}\n\nexport type DocumentPreferences = {\n fields: FieldsPreferences\n}\n"],"names":[],"rangeMappings":"","mappings":"AA0BA,WAEC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { I18n, TFunction } from '@payloadcms/translations';
|
|
3
3
|
import type DataLoader from 'dataloader';
|
|
4
|
-
import type { User } from '../auth/types.js';
|
|
5
4
|
import type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js';
|
|
6
5
|
import type payload from '../index.js';
|
|
6
|
+
import type { GeneratedTypes } from '../index.js';
|
|
7
7
|
import type { validOperators } from './constants.js';
|
|
8
8
|
export type { Payload as Payload } from '../index.js';
|
|
9
9
|
export type UploadEdits = {
|
|
@@ -18,7 +18,7 @@ export type UploadEdits = {
|
|
|
18
18
|
y?: number;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export type CustomPayloadRequest<U =
|
|
21
|
+
export type CustomPayloadRequest<U = unknown> = {
|
|
22
22
|
context: RequestContext;
|
|
23
23
|
/** Data from the request body */
|
|
24
24
|
data?: Record<string, unknown>;
|
|
@@ -71,9 +71,9 @@ export type CustomPayloadRequest<U = any> = {
|
|
|
71
71
|
*/
|
|
72
72
|
transactionIDPromise?: Promise<void>;
|
|
73
73
|
/** The signed in user */
|
|
74
|
-
user: (U &
|
|
74
|
+
user: (U & GeneratedTypes['user']) | null;
|
|
75
75
|
} & Pick<URL, 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'>;
|
|
76
|
-
export type PayloadRequest<U =
|
|
76
|
+
export type PayloadRequest<U = unknown> = Partial<Request> & Required<Pick<Request, 'headers'>> & CustomPayloadRequest<U>;
|
|
77
77
|
export interface RequestContext {
|
|
78
78
|
[key: string]: unknown;
|
|
79
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AAGxC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,CAAC,CAAC,EAAE,MAAM,CAAA;QACV,CAAC,CAAC,EAAE,MAAM,CAAA;KACX,CAAA;IACD,UAAU,CAAC,EAAE;QACX,CAAC,CAAC,EAAE,MAAM,CAAA;QACV,CAAC,CAAC,EAAE,MAAM,CAAA;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ent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { User } from '../auth/types.js'\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type UploadEdits = {\n crop?: {\n height?: number\n width?: number\n x?: number\n y?: number\n }\n focalPoint?: {\n x?: number\n y?: number\n }\n}\n\nexport type CustomPayloadRequest<U =
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { User } from '../auth/types.js'\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { GeneratedTypes } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type UploadEdits = {\n crop?: {\n height?: number\n width?: number\n x?: number\n y?: number\n }\n focalPoint?: {\n x?: number\n y?: number\n }\n}\n\nexport type CustomPayloadRequest<U = unknown> = {\n context: RequestContext\n /** Data from the request body */\n data?: Record<string, unknown>\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n /**\n * The files that were uploaded during this request\n */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: string\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'REST' | 'local'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n */\n transactionID?: number | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed in user */\n user: (U & GeneratedTypes['user']) | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\nexport type PayloadRequest<U = unknown> = Partial<Request> &\n Required<Pick<Request, 'headers'>> &\n CustomPayloadRequest<U>\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\nexport type WhereField = {\n [key in Operator]?: unknown\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"rangeMappings":";;","mappings":"AA4GA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAKnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,2BAA2B,CAAA;AAClF,OAA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aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,GAChC,WAAW,CA2Bb"}
|
|
@@ -48,6 +48,37 @@ function generateEntitySchemas(entities) {
|
|
|
48
48
|
required: Object.keys(properties)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
function generateAuthEntitySchemas(entities) {
|
|
52
|
+
const properties = [
|
|
53
|
+
...entities
|
|
54
|
+
].filter(({ auth })=>Boolean(auth)).map(({ slug })=>{
|
|
55
|
+
return {
|
|
56
|
+
allOf: [
|
|
57
|
+
{
|
|
58
|
+
$ref: `#/definitions/${slug}`
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'object',
|
|
62
|
+
additionalProperties: false,
|
|
63
|
+
properties: {
|
|
64
|
+
collection: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
enum: [
|
|
67
|
+
slug
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: [
|
|
72
|
+
'collection'
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
}, {});
|
|
78
|
+
return {
|
|
79
|
+
oneOf: properties
|
|
80
|
+
};
|
|
81
|
+
}
|
|
51
82
|
/**
|
|
52
83
|
* Returns a JSON Schema Type with 'null' added if the field is not required.
|
|
53
84
|
*/ export function withNullableJSONSchemaType(fieldType, isRequired) {
|
|
@@ -489,9 +520,11 @@ export function entityToJSONSchema(config, incomingEntity, interfaceNameDefiniti
|
|
|
489
520
|
type: 'object',
|
|
490
521
|
properties: {
|
|
491
522
|
collections: generateEntitySchemas(config.collections || []),
|
|
492
|
-
globals: generateEntitySchemas(config.globals || [])
|
|
523
|
+
globals: generateEntitySchemas(config.globals || []),
|
|
524
|
+
user: generateAuthEntitySchemas(config.collections)
|
|
493
525
|
},
|
|
494
526
|
required: [
|
|
527
|
+
'user',
|
|
495
528
|
'collections',
|
|
496
529
|
'globals'
|
|
497
530
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) return false\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) return true\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) return fieldType\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) requiredFieldNames.add(field.name)\n\n let fieldSchema: JSONSchema4\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n enum: optionEnums,\n },\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: optionEnums,\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'upload': {\n fieldSchema = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n if (!isRequired) fieldSchema.oneOf.push({ type: 'null' })\n break\n }\n\n case 'blocks': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n },\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n requiredFieldNames.add(tab.name)\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n): JSONSchema4 {\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n const entityDefinitions: { [k: string]: JSONSchema4 } = [\n ...config.globals,\n ...config.collections,\n ].reduce((acc, entity) => {\n acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType)\n return acc\n }, {})\n\n return {\n additionalProperties: false,\n definitions: { ...entityDefinitions, ...Object.fromEntries(interfaceNameDefinitions) },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n collections: generateEntitySchemas(config.collections || []),\n globals: generateEntitySchemas(config.globals || []),\n },\n required: ['collections', 'globals'],\n title: 'Config',\n }\n}\n"],"names":["pluralize","singular","fieldAffectsData","tabHasName","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","config","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","editor","outputSchema","enum","optionEnums","maxItems","minItems","Array","isArray","relationTo","oneOf","relation","const","blocks","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","Map","from","entityToJSONSchema","incomingEntity","defaultIDType","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","auth","disableLocalStrategy","configToJSONSchema","entityDefinitions","globals","collections","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAOrB,SAASE,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,oBAAmB;AAC3C,SAASC,yBAAyB,QAAQ,iCAAgC;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C,sBAAsB;QACzEV,OAAOnE,MAAM,CAACwB,IAAI,CAAC;YACjBU,MAAM;YACNnC,MAAM;QACR;IACF;IAEA,iGAAiG;IACjG,MAAM2B,yBAAyBpC,0BAA0B;QAAEsC;QAAQsC;IAAc;IAEjF,OAAO;QACLnE,MAAM;QACNkB,sBAAsB;QACtBmD;QACA,GAAG3C,mBAAmBC,wBAAwByC,OAAOnE,MAAM,EAAE2B,0BAA0BC,OAAO;IAChG;AACF;AAEA;;CAEC,GACD,OAAO,SAASkD,mBACdlD,MAAuB,EACvBsC,aAAiC;IAEjC,yJAAyJ;IACzJ,MAAMvC,2BAAqD,IAAImC;IAE/D,gLAAgL;IAChL,+CAA+C;IAC/C,MAAMiB,oBAAkD;WACnDnD,OAAOoD,OAAO;WACdpD,OAAOqD,WAAW;KACtB,CAACpE,MAAM,CAAC,CAACC,KAAKqD;QACbrD,GAAG,CAACqD,OAAOpD,IAAI,CAAC,GAAGiD,mBAAmBpC,QAAQuC,QAAQxC,0BAA0BuC;QAChF,OAAOpD;IACT,GAAG,CAAC;IAEJ,OAAO;QACLG,sBAAsB;QACtBiE,aAAa;YAAE,GAAGH,iBAAiB;YAAE,GAAG7D,OAAOa,WAAW,CAACJ,yBAAyB;QAAC;QACrF,wJAAwJ;QACxJ5B,MAAM;QACNa,YAAY;YACVqE,aAAavE,sBAAsBkB,OAAOqD,WAAW,IAAI,EAAE;YAC3DD,SAAStE,sBAAsBkB,OAAOoD,OAAO,IAAI,EAAE;QACrD;QACAlF,UAAU;YAAC;YAAe;SAAU;QACpCsE,OAAO;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) return false\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) return true\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return {\n allOf: [\n { $ref: `#/definitions/${slug}` },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n collection: { type: 'string', enum: [slug] },\n },\n required: ['collection'],\n },\n ],\n }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) return fieldType\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) requiredFieldNames.add(field.name)\n\n let fieldSchema: JSONSchema4\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n enum: optionEnums,\n },\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: optionEnums,\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'upload': {\n fieldSchema = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n if (!isRequired) fieldSchema.oneOf.push({ type: 'null' })\n break\n }\n\n case 'blocks': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n },\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n requiredFieldNames.add(tab.name)\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n): JSONSchema4 {\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n const entityDefinitions: { [k: string]: JSONSchema4 } = [\n ...config.globals,\n ...config.collections,\n ].reduce((acc, entity) => {\n acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType)\n return acc\n }, {})\n\n return {\n additionalProperties: false,\n definitions: { ...entityDefinitions, ...Object.fromEntries(interfaceNameDefinitions) },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n collections: generateEntitySchemas(config.collections || []),\n globals: generateEntitySchemas(config.globals || []),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'collections', 'globals'],\n title: 'Config',\n }\n}\n"],"names":["pluralize","singular","fieldAffectsData","tabHasName","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateAuthEntitySchemas","filter","auth","allOf","collection","enum","oneOf","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","config","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","editor","outputSchema","optionEnums","maxItems","minItems","Array","isArray","relationTo","relation","const","blocks","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","Map","from","entityToJSONSchema","incomingEntity","defaultIDType","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","configToJSONSchema","entityDefinitions","globals","collections","definitions","user"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAOrB,SAASE,gBAAgB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AAC,GAAGsD,mBAAmBlC,QAAQqC,QAAQtC,0BAA0BqC;QAChF,OAAOzD;IACT,GAAG,CAAC;IAEJ,OAAO;QACLG,sBAAsB;QACtBqE,aAAa;YAAE,GAAGH,iBAAiB;YAAE,GAAGjE,OAAOoB,WAAW,CAACJ,yBAAyB;QAAC;QACrF,wJAAwJ;QACxJnC,MAAM;QACNa,YAAY;YACVyE,aAAa3E,sBAAsByB,OAAOkD,WAAW,IAAI,EAAE;YAC3DD,SAAS1E,sBAAsByB,OAAOiD,OAAO,IAAI,EAAE;YACnDG,MAAMnE,0BAA0Be,OAAOkD,WAAW;QACpD;QACAvF,UAAU;YAAC;YAAQ;YAAe;SAAU;QAC5C2E,OAAO;IACT;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PayloadRequest } from 'payload/types';
|
|
2
2
|
import type { SanitizedCollectionConfig } from '../collections/config/types.js';
|
|
3
3
|
import type { SanitizedGlobalConfig } from '../globals/config/types.js';
|
|
4
4
|
export declare const isEntityHidden: ({ hidden, user, }: {
|
|
5
5
|
hidden: SanitizedCollectionConfig['admin']['hidden'] | SanitizedGlobalConfig['admin']['hidden'];
|
|
6
|
-
user:
|
|
6
|
+
user: PayloadRequest['user'];
|
|
7
7
|
}) => boolean;
|
|
8
8
|
//# sourceMappingURL=isEntityHidden.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEntityHidden.d.ts","sourceRoot":"","sources":["../../src/utilities/isEntityHidden.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"isEntityHidden.d.ts","sourceRoot":"","sources":["../../src/utilities/isEntityHidden.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAEvE,eAAO,MAAM,cAAc,sBAGxB;IACD,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC/F,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,YAEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/isEntityHidden.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/isEntityHidden.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload/types'\n\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nexport const isEntityHidden = ({\n hidden,\n user,\n}: {\n hidden: SanitizedCollectionConfig['admin']['hidden'] | SanitizedGlobalConfig['admin']['hidden']\n user: PayloadRequest['user']\n}) => {\n return typeof hidden === 'function' ? hidden({ user }) : hidden === true\n}\n"],"names":["isEntityHidden","hidden","user"],"rangeMappings":";;;;","mappings":"AAKA,OAAO,MAAMA,iBAAiB,CAAC,EAC7BC,MAAM,EACNC,IAAI,EAIL;IACC,OAAO,OAAOD,WAAW,aAAaA,OAAO;QAAEC;IAAK,KAAKD,WAAW;AACtE,EAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
export declare function isReactServerComponent<T extends any>(component: React.ComponentType | any): component is T;
|
|
3
|
+
export declare function isReactClientComponent<T extends any>(component: React.ComponentType | any): component is T;
|
|
2
4
|
export declare function isReactComponent<T extends any>(component: React.ComponentType | any): component is T;
|
|
3
5
|
export declare function isPlainFunction<T extends Function>(fn: any): fn is T;
|
|
4
6
|
//# sourceMappingURL=isReactComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isReactComponent.d.ts","sourceRoot":"","sources":["../../src/utilities/isReactComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAC5C,SAAS,EAAE,KAAK,CAAC,aAAa,GAAG,GAAG,GACnC,SAAS,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"isReactComponent.d.ts","sourceRoot":"","sources":["../../src/utilities/isReactComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,GAAG,EAClD,SAAS,EAAE,KAAK,CAAC,aAAa,GAAG,GAAG,GACnC,SAAS,IAAI,CAAC,CAEhB;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,GAAG,EAClD,SAAS,EAAE,KAAK,CAAC,aAAa,GAAG,GAAG,GACnC,SAAS,IAAI,CAAC,CAGhB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAC5C,SAAS,EAAE,KAAK,CAAC,aAAa,GAAG,GAAG,GACnC,SAAS,IAAI,CAAC,CAEhB;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,EAAE,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,CAAC,CAEpE"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { isValidElement } from 'react';
|
|
2
2
|
import { isPlainObject } from './isPlainObject.js';
|
|
3
|
+
export function isReactServerComponent(component) {
|
|
4
|
+
return typeof component === 'function' && isValidElement(component);
|
|
5
|
+
}
|
|
6
|
+
export function isReactClientComponent(component) {
|
|
7
|
+
// Do this to test for client components (`use client` directive) bc they import as empty objects
|
|
8
|
+
return typeof component === 'object' && !isPlainObject(component);
|
|
9
|
+
}
|
|
3
10
|
export function isReactComponent(component) {
|
|
4
|
-
return
|
|
5
|
-
typeof component === 'object' && !isPlainObject(component);
|
|
11
|
+
return isReactServerComponent(component) || isReactClientComponent(component);
|
|
6
12
|
}
|
|
7
13
|
export function isPlainFunction(fn) {
|
|
8
14
|
return typeof fn === 'function' && !isReactComponent(fn);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/isReactComponent.ts"],"sourcesContent":["import type React from 'react'\n\nimport { isValidElement } from 'react'\n\nimport { isPlainObject } from './isPlainObject.js'\n\nexport function
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/isReactComponent.ts"],"sourcesContent":["import type React from 'react'\n\nimport { isValidElement } from 'react'\n\nimport { isPlainObject } from './isPlainObject.js'\n\nexport function isReactServerComponent<T extends any>(\n component: React.ComponentType | any,\n): component is T {\n return typeof component === 'function' && isValidElement(component)\n}\n\nexport function isReactClientComponent<T extends any>(\n component: React.ComponentType | any,\n): component is T {\n // Do this to test for client components (`use client` directive) bc they import as empty objects\n return typeof component === 'object' && !isPlainObject(component)\n}\n\nexport function isReactComponent<T extends any>(\n component: React.ComponentType | any,\n): component is T {\n return isReactServerComponent(component) || isReactClientComponent(component)\n}\n\nexport function isPlainFunction<T extends Function>(fn: any): fn is T {\n return typeof fn === 'function' && !isReactComponent(fn)\n}\n"],"names":["isValidElement","isPlainObject","isReactServerComponent","component","isReactClientComponent","isReactComponent","isPlainFunction","fn"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,QAAO;AAEtC,SAASC,aAAa,QAAQ,qBAAoB;AAElD,OAAO,SAASC,uBACdC,SAAoC;IAEpC,OAAO,OAAOA,cAAc,cAAcH,eAAeG;AAC3D;AAEA,OAAO,SAASC,uBACdD,SAAoC;IAEpC,iGAAiG;IACjG,OAAO,OAAOA,cAAc,YAAY,CAACF,cAAcE;AACzD;AAEA,OAAO,SAASE,iBACdF,SAAoC;IAEpC,OAAOD,uBAAuBC,cAAcC,uBAAuBD;AACrE;AAEA,OAAO,SAASG,gBAAoCC,EAAO;IACzD,OAAO,OAAOA,OAAO,cAAc,CAACF,iBAAiBE;AACvD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { User } from '../../../auth/types.js';
|
|
2
1
|
import type { Payload } from '../../../index.js';
|
|
2
|
+
import type { PayloadRequest } from '../../../types/index.js';
|
|
3
3
|
export type AdminInitEvent = {
|
|
4
4
|
domainID?: string;
|
|
5
5
|
type: 'admin-init';
|
|
@@ -8,7 +8,7 @@ export type AdminInitEvent = {
|
|
|
8
8
|
type Args = {
|
|
9
9
|
headers: Request['headers'];
|
|
10
10
|
payload: Payload;
|
|
11
|
-
user:
|
|
11
|
+
user: PayloadRequest['user'];
|
|
12
12
|
};
|
|
13
13
|
export declare const adminInit: ({ headers, payload, user }: Args) => void;
|
|
14
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminInit.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/events/adminInit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adminInit.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/events/adminInit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,YAAY,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,CAAA;AACD,eAAO,MAAM,SAAS,+BAAgC,IAAI,KAAG,IAuB5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/telemetry/events/adminInit.ts"],"sourcesContent":["import type { User } from '../../../auth/types.js'\nimport type { Payload } from '../../../index.js'\n\nimport { sendEvent } from '../index.js'\nimport { oneWayHash } from '../oneWayHash.js'\n\nexport type AdminInitEvent = {\n domainID?: string\n type: 'admin-init'\n userID?: string\n}\n\ntype Args = {\n headers: Request['headers']\n payload: Payload\n user:
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/telemetry/events/adminInit.ts"],"sourcesContent":["import type { User } from '../../../auth/types.js'\nimport type { Payload } from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\nimport { sendEvent } from '../index.js'\nimport { oneWayHash } from '../oneWayHash.js'\n\nexport type AdminInitEvent = {\n domainID?: string\n type: 'admin-init'\n userID?: string\n}\n\ntype Args = {\n headers: Request['headers']\n payload: Payload\n user: PayloadRequest['user']\n}\nexport const adminInit = ({ headers, payload, user }: Args): void => {\n const host = headers.get('host')\n\n let domainID: string\n let userID: string\n\n if (host) {\n domainID = oneWayHash(host, payload.secret)\n }\n\n if (user?.id) {\n userID = oneWayHash(String(user.id), payload.secret)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n sendEvent({\n event: {\n type: 'admin-init',\n domainID,\n userID,\n },\n payload,\n })\n}\n"],"names":["sendEvent","oneWayHash","adminInit","headers","payload","user","host","get","domainID","userID","secret","id","String","event","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,cAAa;AACvC,SAASC,UAAU,QAAQ,mBAAkB;AAa7C,OAAO,MAAMC,YAAY,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAQ;IACxD,MAAMC,OAAOH,QAAQI,GAAG,CAAC;IAEzB,IAAIC;IACJ,IAAIC;IAEJ,IAAIH,MAAM;QACRE,WAAWP,WAAWK,MAAMF,QAAQM,MAAM;IAC5C;IAEA,IAAIL,MAAMM,IAAI;QACZF,SAASR,WAAWW,OAAOP,KAAKM,EAAE,GAAGP,QAAQM,MAAM;IACrD;IAEA,mEAAmE;IACnEV,UAAU;QACRa,OAAO;YACLC,MAAM;YACNN;YACAC;QACF;QACAL;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"sanitize-filename": "1.6.3",
|
|
50
50
|
"scheduler": "0.23.0",
|
|
51
51
|
"scmp": "2.1.0",
|
|
52
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
52
|
+
"@payloadcms/translations": "3.0.0-beta.5"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@monaco-editor/react": "4.5.1",
|
package/src/index.ts
CHANGED
|
@@ -52,7 +52,9 @@ import { validateSchema } from './config/validate.js'
|
|
|
52
52
|
import buildEmail from './email/build.js'
|
|
53
53
|
import { defaults as emailDefaults } from './email/defaults.js'
|
|
54
54
|
import sendEmail from './email/sendEmail.js'
|
|
55
|
+
import { fieldAffectsData } from './exports/types.js'
|
|
55
56
|
import localGlobalOperations from './globals/operations/local/index.js'
|
|
57
|
+
import flattenFields from './utilities/flattenTopLevelFields.js'
|
|
56
58
|
import Logger from './utilities/logger.js'
|
|
57
59
|
import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit.js'
|
|
58
60
|
|
|
@@ -340,8 +342,17 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
340
342
|
}
|
|
341
343
|
|
|
342
344
|
this.config.collections.forEach((collection) => {
|
|
345
|
+
const customID = flattenFields(collection.fields).find(
|
|
346
|
+
(field) => fieldAffectsData(field) && field.name === 'id',
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
let customIDType
|
|
350
|
+
|
|
351
|
+
if (customID?.type === 'number' || customID?.type === 'text') customIDType = customID.type
|
|
352
|
+
|
|
343
353
|
this.collections[collection.slug] = {
|
|
344
354
|
config: collection,
|
|
355
|
+
customIDType,
|
|
345
356
|
}
|
|
346
357
|
})
|
|
347
358
|
|
|
@@ -473,6 +484,7 @@ type GeneratedTypes = {
|
|
|
473
484
|
globals: {
|
|
474
485
|
[slug: number | string | symbol]: GlobalTypeWithID & Record<string, unknown>
|
|
475
486
|
}
|
|
487
|
+
user: TypeWithID & Record<string, unknown> & { collection: string }
|
|
476
488
|
}
|
|
477
489
|
|
|
478
490
|
type Payload = BasePayload<GeneratedTypes>
|
package/utilities.d.ts
CHANGED
|
@@ -14,13 +14,12 @@ export { fieldSchemaToJSON } from './dist/utilities/fieldSchemaToJSON.js';
|
|
|
14
14
|
export { default as flattenTopLevelFields } from './dist/utilities/flattenTopLevelFields.js';
|
|
15
15
|
export { formatLabels, formatNames, toWords } from './dist/utilities/formatLabels.js';
|
|
16
16
|
export { getCollectionIDFieldTypes } from './dist/utilities/getCollectionIDFieldTypes.js';
|
|
17
|
-
export { getIDType } from './dist/utilities/getIDType.js';
|
|
18
17
|
export { getObjectDotNotation } from './dist/utilities/getObjectDotNotation.js';
|
|
19
18
|
export { default as getUniqueListBy } from './dist/utilities/getUniqueListBy.js';
|
|
20
19
|
export { isEntityHidden } from './dist/utilities/isEntityHidden.js';
|
|
21
20
|
export { isNumber } from './dist/utilities/isNumber.js';
|
|
22
21
|
export { isPlainObject } from './dist/utilities/isPlainObject.js';
|
|
23
|
-
export { isPlainFunction, isReactComponent } from './dist/utilities/isReactComponent.js';
|
|
22
|
+
export { isPlainFunction, isReactClientComponent, isReactComponent, isReactServerComponent, } from './dist/utilities/isReactComponent.js';
|
|
24
23
|
export { isValidID } from './dist/utilities/isValidID.js';
|
|
25
24
|
export { default as isolateObjectProperty } from './dist/utilities/isolateObjectProperty.js';
|
|
26
25
|
export { mapAsync } from './dist/utilities/mapAsync.js';
|
package/utilities.js
CHANGED
|
@@ -14,13 +14,12 @@ export { fieldSchemaToJSON } from './dist/utilities/fieldSchemaToJSON.js';
|
|
|
14
14
|
export { default as flattenTopLevelFields } from './dist/utilities/flattenTopLevelFields.js';
|
|
15
15
|
export { formatLabels, formatNames, toWords } from './dist/utilities/formatLabels.js';
|
|
16
16
|
export { getCollectionIDFieldTypes } from './dist/utilities/getCollectionIDFieldTypes.js';
|
|
17
|
-
export { getIDType } from './dist/utilities/getIDType.js';
|
|
18
17
|
export { getObjectDotNotation } from './dist/utilities/getObjectDotNotation.js';
|
|
19
18
|
export { default as getUniqueListBy } from './dist/utilities/getUniqueListBy.js';
|
|
20
19
|
export { isEntityHidden } from './dist/utilities/isEntityHidden.js';
|
|
21
20
|
export { isNumber } from './dist/utilities/isNumber.js';
|
|
22
21
|
export { isPlainObject } from './dist/utilities/isPlainObject.js';
|
|
23
|
-
export { isPlainFunction, isReactComponent } from './dist/utilities/isReactComponent.js';
|
|
22
|
+
export { isPlainFunction, isReactClientComponent, isReactComponent, isReactServerComponent } from './dist/utilities/isReactComponent.js';
|
|
24
23
|
export { isValidID } from './dist/utilities/isValidID.js';
|
|
25
24
|
export { default as isolateObjectProperty } from './dist/utilities/isolateObjectProperty.js';
|
|
26
25
|
export { mapAsync } from './dist/utilities/mapAsync.js';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BaseDatabaseAdapter } from '../database/types.js';
|
|
2
|
-
import type { Field } from '../fields/config/types.js';
|
|
3
|
-
export declare const getIDType: (idField: Field | null, defaultIDType: BaseDatabaseAdapter['defaultIDType'] | null) => 'ObjectID' | 'number' | 'text';
|
|
4
|
-
//# sourceMappingURL=getIDType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/getIDType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAEtD,eAAO,MAAM,SAAS,YACX,KAAK,GAAG,IAAI,iBACN,mBAAmB,CAAC,eAAe,CAAC,GAAG,IAAI,KACzD,UAAU,GAAG,QAAQ,GAAG,MAK1B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getIDType.ts"],"sourcesContent":["import type { BaseDatabaseAdapter } from '../database/types.js'\nimport type { Field } from '../fields/config/types.js'\n\nexport const getIDType = (\n idField: Field | null,\n defaultIDType: BaseDatabaseAdapter['defaultIDType'] | null,\n): 'ObjectID' | 'number' | 'text' => {\n if (idField) {\n return idField.type === 'number' ? 'number' : 'text'\n }\n return defaultIDType || 'ObjectID'\n}\n"],"names":["getIDType","idField","defaultIDType","type"],"rangeMappings":";;;;;","mappings":"AAGA,OAAO,MAAMA,YAAY,CACvBC,SACAC;IAEA,IAAID,SAAS;QACX,OAAOA,QAAQE,IAAI,KAAK,WAAW,WAAW;IAChD;IACA,OAAOD,iBAAiB;AAC1B,EAAC"}
|