payload 3.80.0-internal-debug.4c84b90 → 3.80.0-internal.0311fce
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/elements/Nav.d.ts +10 -0
- package/dist/admin/elements/Nav.d.ts.map +1 -1
- package/dist/admin/elements/Nav.js.map +1 -1
- package/dist/admin/functions/index.d.ts +1 -38
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +5 -4
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/hierarchyList.d.ts +9 -0
- package/dist/admin/views/hierarchyList.d.ts.map +1 -0
- package/dist/admin/views/hierarchyList.js +3 -0
- package/dist/admin/views/hierarchyList.js.map +1 -0
- package/dist/admin/views/index.d.ts +1 -3
- package/dist/admin/views/index.d.ts.map +1 -1
- package/dist/admin/views/index.js.map +1 -1
- package/dist/admin/views/list.d.ts +37 -1
- package/dist/admin/views/list.d.ts.map +1 -1
- package/dist/admin/views/list.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +1 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.js +7 -0
- package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
- package/dist/collections/config/client.d.ts +3 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +11 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.js +1 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +3 -7
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +29 -7
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.js +17 -17
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/findByID.js +3 -3
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +5 -4
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +0 -10
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -15
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +3 -26
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +27 -13
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
- package/dist/database/sanitizeJoinQuery.js +6 -0
- package/dist/database/sanitizeJoinQuery.js.map +1 -1
- package/dist/exports/shared.d.ts +2 -3
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -2
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +4 -0
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
- package/dist/fields/config/sanitizeJoinField.js +3 -0
- package/dist/fields/config/sanitizeJoinField.js.map +1 -1
- package/dist/globals/config/types.d.ts +4 -0
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.d.ts +8 -0
- package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -0
- package/dist/hierarchy/addHierarchyToCollection.js +62 -0
- package/dist/hierarchy/addHierarchyToCollection.js.map +1 -0
- package/dist/hierarchy/buildParentField.d.ts +11 -0
- package/dist/hierarchy/buildParentField.d.ts.map +1 -0
- package/dist/hierarchy/buildParentField.js +42 -0
- package/dist/hierarchy/buildParentField.js.map +1 -0
- package/dist/hierarchy/constants.d.ts +15 -0
- package/dist/hierarchy/constants.d.ts.map +1 -0
- package/dist/hierarchy/constants.js +11 -0
- package/dist/hierarchy/constants.js.map +1 -0
- package/dist/hierarchy/createFolderField.d.ts +39 -0
- package/dist/hierarchy/createFolderField.d.ts.map +1 -0
- package/dist/hierarchy/createFolderField.js +54 -0
- package/dist/hierarchy/createFolderField.js.map +1 -0
- package/dist/hierarchy/createFoldersCollection.d.ts +57 -0
- package/dist/hierarchy/createFoldersCollection.d.ts.map +1 -0
- package/dist/hierarchy/createFoldersCollection.js +63 -0
- package/dist/hierarchy/createFoldersCollection.js.map +1 -0
- package/dist/hierarchy/createTagField.d.ts +44 -0
- package/dist/hierarchy/createTagField.d.ts.map +1 -0
- package/dist/hierarchy/createTagField.js +48 -0
- package/dist/hierarchy/createTagField.js.map +1 -0
- package/dist/hierarchy/createTagsCollection.d.ts +54 -0
- package/dist/hierarchy/createTagsCollection.d.ts.map +1 -0
- package/dist/hierarchy/createTagsCollection.js +56 -0
- package/dist/hierarchy/createTagsCollection.js.map +1 -0
- package/dist/hierarchy/endpoints/findRelated.d.ts +7 -0
- package/dist/hierarchy/endpoints/findRelated.d.ts.map +1 -0
- package/dist/hierarchy/endpoints/findRelated.js +36 -0
- package/dist/hierarchy/endpoints/findRelated.js.map +1 -0
- package/dist/hierarchy/getInitialTreeData.d.ts +24 -0
- package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -0
- package/dist/hierarchy/getInitialTreeData.js +120 -0
- package/dist/hierarchy/getInitialTreeData.js.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts +14 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.js +21 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.js.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts +27 -0
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterRead.js +64 -0
- package/dist/hierarchy/hooks/collectionAfterRead.js.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts +19 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.js +90 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.js.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts +15 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.js +20 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.js.map +1 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts +8 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js +108 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js.map +1 -0
- package/dist/hierarchy/injectHierarchyButton.d.ts +14 -0
- package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -0
- package/dist/hierarchy/injectHierarchyButton.js +37 -0
- package/dist/hierarchy/injectHierarchyButton.js.map +1 -0
- package/dist/hierarchy/operations/findRelatedDocuments.d.ts +24 -0
- package/dist/hierarchy/operations/findRelatedDocuments.d.ts.map +1 -0
- package/dist/hierarchy/operations/findRelatedDocuments.js +73 -0
- package/dist/hierarchy/operations/findRelatedDocuments.js.map +1 -0
- package/dist/hierarchy/operations/index.d.ts +2 -0
- package/dist/hierarchy/operations/index.d.ts.map +1 -0
- package/dist/hierarchy/operations/index.js +3 -0
- package/dist/hierarchy/operations/index.js.map +1 -0
- package/dist/hierarchy/resolveHierarchyCollections.d.ts +23 -0
- package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -0
- package/dist/hierarchy/resolveHierarchyCollections.js +312 -0
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts +14 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.js +125 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -0
- package/dist/hierarchy/types.d.ts +137 -0
- package/dist/hierarchy/types.d.ts.map +1 -0
- package/dist/hierarchy/types.js +6 -0
- package/dist/hierarchy/types.js.map +1 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts +71 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts.map +1 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js +65 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js.map +1 -0
- package/dist/hierarchy/utils/computePaths.d.ts +31 -0
- package/dist/hierarchy/utils/computePaths.d.ts.map +1 -0
- package/dist/hierarchy/utils/computePaths.js +371 -0
- package/dist/hierarchy/utils/computePaths.js.map +1 -0
- package/dist/hierarchy/utils/findUseAsTitle.d.ts +6 -0
- package/dist/hierarchy/utils/findUseAsTitle.d.ts.map +1 -0
- package/dist/hierarchy/utils/findUseAsTitle.js +72 -0
- package/dist/hierarchy/utils/findUseAsTitle.js.map +1 -0
- package/dist/hierarchy/utils/getAncestors.d.ts +34 -0
- package/dist/hierarchy/utils/getAncestors.d.ts.map +1 -0
- package/dist/hierarchy/utils/getAncestors.js +94 -0
- package/dist/hierarchy/utils/getAncestors.js.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.d.ts +30 -0
- package/dist/hierarchy/utils/getLocalizedValue.d.ts.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.js +46 -0
- package/dist/hierarchy/utils/getLocalizedValue.js.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.spec.js +250 -0
- package/dist/hierarchy/utils/getLocalizedValue.spec.js.map +1 -0
- package/dist/index.bundled.d.ts +574 -284
- package/dist/index.d.ts +23 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +8 -4
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +7 -4
- package/dist/preferences/keys.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +7 -3
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +23 -33
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +75 -1
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/extractID.js +1 -1
- package/dist/utilities/extractID.js.map +1 -1
- package/dist/utilities/formatAdminURL.d.ts +13 -2
- package/dist/utilities/formatAdminURL.d.ts.map +1 -1
- package/dist/utilities/formatAdminURL.js.map +1 -1
- package/package.json +2 -2
- package/dist/admin/views/folderList.d.ts +0 -56
- package/dist/admin/views/folderList.d.ts.map +0 -1
- package/dist/admin/views/folderList.js +0 -3
- package/dist/admin/views/folderList.js.map +0 -1
- package/dist/folders/addFolderCollection.d.ts +0 -10
- package/dist/folders/addFolderCollection.d.ts.map +0 -1
- package/dist/folders/addFolderCollection.js +0 -26
- package/dist/folders/addFolderCollection.js.map +0 -1
- package/dist/folders/addFolderFieldToCollection.d.ts +0 -8
- package/dist/folders/addFolderFieldToCollection.d.ts.map +0 -1
- package/dist/folders/addFolderFieldToCollection.js +0 -20
- package/dist/folders/addFolderFieldToCollection.js.map +0 -1
- package/dist/folders/buildFolderField.d.ts +0 -8
- package/dist/folders/buildFolderField.d.ts.map +0 -1
- package/dist/folders/buildFolderField.js +0 -87
- package/dist/folders/buildFolderField.js.map +0 -1
- package/dist/folders/constants.d.ts +0 -3
- package/dist/folders/constants.d.ts.map +0 -1
- package/dist/folders/constants.js +0 -4
- package/dist/folders/constants.js.map +0 -1
- package/dist/folders/createFolderCollection.d.ts +0 -11
- package/dist/folders/createFolderCollection.d.ts.map +0 -1
- package/dist/folders/createFolderCollection.js +0 -115
- package/dist/folders/createFolderCollection.js.map +0 -1
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts +0 -8
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts.map +0 -1
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.js +0 -15
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.js.map +0 -1
- package/dist/folders/hooks/dissasociateAfterDelete.d.ts +0 -8
- package/dist/folders/hooks/dissasociateAfterDelete.d.ts.map +0 -1
- package/dist/folders/hooks/dissasociateAfterDelete.js +0 -20
- package/dist/folders/hooks/dissasociateAfterDelete.js.map +0 -1
- package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts +0 -5
- package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts.map +0 -1
- package/dist/folders/hooks/ensureSafeCollectionsChange.js +0 -107
- package/dist/folders/hooks/ensureSafeCollectionsChange.js.map +0 -1
- package/dist/folders/hooks/reparentChildFolder.d.ts +0 -24
- package/dist/folders/hooks/reparentChildFolder.d.ts.map +0 -1
- package/dist/folders/hooks/reparentChildFolder.js +0 -72
- package/dist/folders/hooks/reparentChildFolder.js.map +0 -1
- package/dist/folders/types.d.ts +0 -118
- package/dist/folders/types.d.ts.map +0 -1
- package/dist/folders/types.js +0 -3
- package/dist/folders/types.js.map +0 -1
- package/dist/folders/utils/buildFolderWhereConstraints.d.ts +0 -13
- package/dist/folders/utils/buildFolderWhereConstraints.d.ts.map +0 -1
- package/dist/folders/utils/buildFolderWhereConstraints.js +0 -45
- package/dist/folders/utils/buildFolderWhereConstraints.js.map +0 -1
- package/dist/folders/utils/formatFolderOrDocumentItem.d.ts +0 -12
- package/dist/folders/utils/formatFolderOrDocumentItem.d.ts.map +0 -1
- package/dist/folders/utils/formatFolderOrDocumentItem.js +0 -30
- package/dist/folders/utils/formatFolderOrDocumentItem.js.map +0 -1
- package/dist/folders/utils/getFolderBreadcrumbs.d.ts +0 -14
- package/dist/folders/utils/getFolderBreadcrumbs.d.ts.map +0 -1
- package/dist/folders/utils/getFolderBreadcrumbs.js +0 -45
- package/dist/folders/utils/getFolderBreadcrumbs.js.map +0 -1
- package/dist/folders/utils/getFolderData.d.ts +0 -33
- package/dist/folders/utils/getFolderData.d.ts.map +0 -1
- package/dist/folders/utils/getFolderData.js +0 -88
- package/dist/folders/utils/getFolderData.js.map +0 -1
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts +0 -24
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts.map +0 -1
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js +0 -66
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js.map +0 -1
- package/dist/folders/utils/getOrphanedDocs.d.ts +0 -15
- package/dist/folders/utils/getOrphanedDocs.d.ts.map +0 -1
- package/dist/folders/utils/getOrphanedDocs.js +0 -40
- package/dist/folders/utils/getOrphanedDocs.js.map +0 -1
|
@@ -471,7 +471,9 @@ describe('configToJSONSchema', ()=>{
|
|
|
471
471
|
],
|
|
472
472
|
items: {
|
|
473
473
|
oneOf: [
|
|
474
|
-
|
|
474
|
+
{
|
|
475
|
+
$ref: '#/definitions/SharedBlock'
|
|
476
|
+
}
|
|
475
477
|
]
|
|
476
478
|
}
|
|
477
479
|
}
|
|
@@ -512,6 +514,78 @@ describe('configToJSONSchema', ()=>{
|
|
|
512
514
|
// @ts-expect-error
|
|
513
515
|
expect(schema.definitions.test.properties.title.required).toStrictEqual(false);
|
|
514
516
|
});
|
|
517
|
+
it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async ()=>{
|
|
518
|
+
const namedBlock = {
|
|
519
|
+
slug: 'myBlock',
|
|
520
|
+
interfaceName: 'MyBlock',
|
|
521
|
+
fields: [
|
|
522
|
+
{
|
|
523
|
+
name: 'text',
|
|
524
|
+
type: 'text'
|
|
525
|
+
}
|
|
526
|
+
]
|
|
527
|
+
};
|
|
528
|
+
// @ts-expect-error
|
|
529
|
+
const config = {
|
|
530
|
+
collections: [
|
|
531
|
+
{
|
|
532
|
+
slug: 'test',
|
|
533
|
+
fields: [
|
|
534
|
+
{
|
|
535
|
+
name: 'arr',
|
|
536
|
+
type: 'array',
|
|
537
|
+
fields: [
|
|
538
|
+
{
|
|
539
|
+
name: 'blocks',
|
|
540
|
+
type: 'blocks',
|
|
541
|
+
blocks: [
|
|
542
|
+
namedBlock
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
name: 'grp',
|
|
549
|
+
type: 'group',
|
|
550
|
+
fields: [
|
|
551
|
+
{
|
|
552
|
+
name: 'blocks',
|
|
553
|
+
type: 'blocks',
|
|
554
|
+
blocks: [
|
|
555
|
+
namedBlock
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
]
|
|
559
|
+
}
|
|
560
|
+
],
|
|
561
|
+
timestamps: false
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
};
|
|
565
|
+
const sanitizedConfig = await sanitizeConfig(config);
|
|
566
|
+
// Without forceInlineBlocks: blocks field uses $ref
|
|
567
|
+
const schemaDefault = configToJSONSchema(sanitizedConfig, 'text');
|
|
568
|
+
const arrItemsDefault = schemaDefault.definitions.test.properties.arr.items;
|
|
569
|
+
const arrBlocksDefault = arrItemsDefault.properties.blocks.items.oneOf[0];
|
|
570
|
+
expect(arrBlocksDefault).toStrictEqual({
|
|
571
|
+
$ref: '#/definitions/MyBlock'
|
|
572
|
+
});
|
|
573
|
+
// With forceInlineBlocks: blocks field is inlined, no $ref
|
|
574
|
+
const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {
|
|
575
|
+
forceInlineBlocks: true
|
|
576
|
+
});
|
|
577
|
+
const arrItemsInline = schemaInline.definitions.test.properties.arr.items;
|
|
578
|
+
const arrBlocksInline = arrItemsInline.properties.blocks.items.oneOf[0];
|
|
579
|
+
expect(arrBlocksInline).not.toHaveProperty('$ref');
|
|
580
|
+
expect(arrBlocksInline.properties?.blockType).toStrictEqual({
|
|
581
|
+
const: 'myBlock'
|
|
582
|
+
});
|
|
583
|
+
const grpBlocksInline = schemaInline.definitions.test.properties.grp.properties.blocks.items.oneOf[0];
|
|
584
|
+
expect(grpBlocksInline).not.toHaveProperty('$ref');
|
|
585
|
+
expect(grpBlocksInline.properties?.blockType).toStrictEqual({
|
|
586
|
+
const: 'myBlock'
|
|
587
|
+
});
|
|
588
|
+
});
|
|
515
589
|
});
|
|
516
590
|
|
|
517
591
|
//# sourceMappingURL=configToJSONSchema.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [expectedBlockSchema],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","SharedBlock","defaultValue"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMV,eAAeE;QAC7C,MAAMS,SAASV,mBAAmBS,iBAAiB;QAEnDX,OAAOY,QAAQC,aAAaC,MAAMC,aAAa,CAAC;YAC9CP,MAAM;YACNQ,sBAAsB;YACtBC,YAAY;gBACVC,IAAI;oBACFV,MAAM;gBACR;gBACAW,m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ClCwB,UAAU;oBAAE7C,MAAM;wBAAC;wBAAS;qBAAO;oBAAEY,OAAO;wBAAEZ,MAAM;oBAAS;gBAAE;YACjE;YACAC,UAAU;gBAAC;aAAY;QACzB;QAEAT,OAAOY,QAAQC,aAAaC,MAAMC,aAAa,CAAC;YAC9CP,MAAM;YACNQ,sBAAsB;YACtBK,OAAO;YACPJ,YAAY;gBACVC,IAAI;oBACFV,MAAM;gBACR;gBACA8C,gBAAgB;oBACd9C,MAAM;wBAAC;wBAAS;qBAAO;oBACvBY,OAAO;wBACLM,OAAO;4BAAC0B;yBAAoB;oBAC9B;gBACF;YACF;YACA3C,UAAU;gBAAC;aAAK;QAClB;QAEA,2EAA2E;QAC3ET,OAAOY,QAAQC,aAAa0C,aAAaxC,aAAa,CAACqC;IACzD;IAEArD,GAAG,6CAA6C;QAC9C,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNC,UAAU;4BACV+C,cAAc;4BACdjB,kBAAkB;gCAChB,IAAO,CAAA;wCACL/B,MAAM;wCACNC,UAAU;oCACZ,CAAA;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMV,eAAeE;QAC7C,MAAMS,SAASV,mBAAmBS,iBAAiB;QAEnD,mBAAmB;QACnBX,OAAOY,OAAOC,WAAW,CAACC,IAAI,CAACG,UAAU,CAACI,KAAK,CAACZ,QAAQ,EAAEM,aAAa,CAAC;IAC1E;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/definitions/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const schemaDefault = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/definitions/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.definitions!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","$ref","SharedBlock","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","not","toHaveProperty","grpBlocksInline","grp"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,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CAACG,UAAU,CAAE4C,GAAG,CAACzC,KAAK;QAC3E,MAAM+C,kBAAkB,AAACD,eAAejD,UAAU,CAAEK,MAAM,CAACF,KAAK,CAAiBM,KAAK,AAAC,CAAC,EAAE;QAC1F1B,OAAOmE,iBAAiBC,GAAG,CAACC,cAAc,CAAC;QAC3CrE,OAAOmE,gBAAgBlD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;QAE/E,MAAMyC,kBAAkB,AACtBP,aAAalD,WAAW,CAAEC,IAAI,CAACG,UAAU,CAAEsD,GAAG,CAACtD,UAAU,CAAEK,MAAM,CAACF,KAAK,CACvEM,KAAK,AAAC,CAAC,EAAE;QACX1B,OAAOsE,iBAAiBF,GAAG,CAACC,cAAc,CAAC;QAC3CrE,OAAOsE,gBAAgBrD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;IACjF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/extractID.ts"],"sourcesContent":["export const extractID = <IDType extends number | string>(\n objectOrID: { id: IDType } | IDType,\n): IDType => {\n if (typeof objectOrID === 'string' || typeof objectOrID === 'number') {\n return objectOrID\n }\n\n return objectOrID
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/extractID.ts"],"sourcesContent":["export const extractID = <IDType extends number | string>(\n objectOrID: { id: IDType } | IDType,\n): IDType => {\n if (typeof objectOrID === 'string' || typeof objectOrID === 'number') {\n return objectOrID\n }\n\n return objectOrID?.id\n}\n"],"names":["extractID","objectOrID","id"],"mappings":"AAAA,OAAO,MAAMA,YAAY,CACvBC;IAEA,IAAI,OAAOA,eAAe,YAAY,OAAOA,eAAe,UAAU;QACpE,OAAOA;IACT;IAEA,OAAOA,YAAYC;AACrB,EAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import type { Config } from '../config/types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Builds correct URLs for admin panel and API routing.
|
|
4
|
+
* Use this for both admin routes (`adminRoute`) and API routes (`apiRoute`).
|
|
5
|
+
*
|
|
4
6
|
* Its primary responsibilities are:
|
|
5
|
-
* 1. Read from your `routes.admin` config and appropriately handle `"/"`
|
|
7
|
+
* 1. Read from your `routes.admin` or `routes.api` config and appropriately handle `"/"` paths
|
|
6
8
|
* 2. Prepend the `basePath` from your Next.js config, if specified
|
|
7
9
|
* 3. Return relative or absolute URLs, as needed
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Admin route
|
|
13
|
+
* formatAdminURL({ adminRoute, path: `/collections/${slug}` })
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // API route with query params
|
|
17
|
+
* const queryString = qs.stringify({ where, limit, page }, { addQueryPrefix: true })
|
|
18
|
+
* formatAdminURL({ apiRoute: api, path: `/${slug}${queryString}`, serverURL })
|
|
8
19
|
*/
|
|
9
20
|
type BaseFormatURLArgs = {
|
|
10
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatAdminURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatAdminURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD
|
|
1
|
+
{"version":3,"file":"formatAdminURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatAdminURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,KAAK,iBAAiB,GAAG;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAE7B,KAAK,aAAa,GACd,CAAC;IACC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACC,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;CAC/C,GAAG,iBAAiB,CAAC,CAAA;AAE1B,eAAO,MAAM,cAAc,SAAU,aAAa,KAAG,MAyBpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/formatAdminURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/formatAdminURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\n/**\n * Builds correct URLs for admin panel and API routing.\n * Use this for both admin routes (`adminRoute`) and API routes (`apiRoute`).\n *\n * Its primary responsibilities are:\n * 1. Read from your `routes.admin` or `routes.api` config and appropriately handle `\"/\"` paths\n * 2. Prepend the `basePath` from your Next.js config, if specified\n * 3. Return relative or absolute URLs, as needed\n *\n * @example\n * // Admin route\n * formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n *\n * @example\n * // API route with query params\n * const queryString = qs.stringify({ where, limit, page }, { addQueryPrefix: true })\n * formatAdminURL({ apiRoute: api, path: `/${slug}${queryString}`, serverURL })\n */\ntype BaseFormatURLArgs = {\n /**\n * The subpath of your application, if specified.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath\n * @example '/docs'\n */\n basePath?: string\n includeBasePath?: boolean\n path?: '' | `/${string}` | null\n /**\n * Return a relative URL, e.g. ignore `serverURL`.\n * Useful for route-matching, etc.\n */\n relative?: boolean\n} & Pick<Config, 'serverURL'>\n\ntype FormatURLArgs =\n | ({\n adminRoute: NonNullable<Config['routes']>['admin']\n apiRoute?: never\n } & BaseFormatURLArgs)\n | ({\n adminRoute?: never\n apiRoute: NonNullable<Config['routes']>['api']\n } & BaseFormatURLArgs)\n\nexport const formatAdminURL = (args: FormatURLArgs): string => {\n const {\n adminRoute,\n apiRoute,\n includeBasePath: includeBasePathArg,\n path = '',\n relative = false,\n serverURL,\n } = args\n const basePath = process.env.NEXT_BASE_PATH || args.basePath || ''\n const routePath = adminRoute || apiRoute\n const segments = [routePath && routePath !== '/' && routePath, path && path].filter(Boolean)\n const pathname = segments.join('') || '/'\n const pathnameWithBase = (basePath + pathname).replace(/\\/$/, '') || '/'\n const includeBasePath = includeBasePathArg ?? (adminRoute ? false : true)\n\n if (relative || !serverURL) {\n if (includeBasePath && basePath) {\n return pathnameWithBase\n }\n return pathname\n }\n\n const serverURLObj = new URL(serverURL)\n return new URL(pathnameWithBase, serverURLObj.origin).toString()\n}\n"],"names":["formatAdminURL","args","adminRoute","apiRoute","includeBasePath","includeBasePathArg","path","relative","serverURL","basePath","process","env","NEXT_BASE_PATH","routePath","segments","filter","Boolean","pathname","join","pathnameWithBase","replace","serverURLObj","URL","origin","toString"],"mappings":"AA8CA,OAAO,MAAMA,iBAAiB,CAACC;IAC7B,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,iBAAiBC,kBAAkB,EACnCC,OAAO,EAAE,EACTC,WAAW,KAAK,EAChBC,SAAS,EACV,GAAGP;IACJ,MAAMQ,WAAWC,QAAQC,GAAG,CAACC,cAAc,IAAIX,KAAKQ,QAAQ,IAAI;IAChE,MAAMI,YAAYX,cAAcC;IAChC,MAAMW,WAAW;QAACD,aAAaA,cAAc,OAAOA;QAAWP,QAAQA;KAAK,CAACS,MAAM,CAACC;IACpF,MAAMC,WAAWH,SAASI,IAAI,CAAC,OAAO;IACtC,MAAMC,mBAAmB,AAACV,CAAAA,WAAWQ,QAAO,EAAGG,OAAO,CAAC,OAAO,OAAO;IACrE,MAAMhB,kBAAkBC,sBAAuBH,CAAAA,aAAa,QAAQ,IAAG;IAEvE,IAAIK,YAAY,CAACC,WAAW;QAC1B,IAAIJ,mBAAmBK,UAAU;YAC/B,OAAOU;QACT;QACA,OAAOF;IACT;IAEA,MAAMI,eAAe,IAAIC,IAAId;IAC7B,OAAO,IAAIc,IAAIH,kBAAkBE,aAAaE,MAAM,EAAEC,QAAQ;AAChE,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.80.0-internal
|
|
3
|
+
"version": "3.80.0-internal.0311fce",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"undici": "7.18.2",
|
|
116
116
|
"uuid": "10.0.0",
|
|
117
117
|
"ws": "^8.16.0",
|
|
118
|
-
"@payloadcms/translations": "3.80.0-internal
|
|
118
|
+
"@payloadcms/translations": "3.80.0-internal.0311fce"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { ServerProps } from '../../config/types.js';
|
|
2
|
-
import type { FolderBreadcrumb, FolderOrDocument, FolderSortKeys } from '../../folders/types.js';
|
|
3
|
-
import type { SanitizedCollectionConfig } from '../../index.js';
|
|
4
|
-
export type FolderListViewSlots = {
|
|
5
|
-
AfterFolderList?: React.ReactNode;
|
|
6
|
-
AfterFolderListTable?: React.ReactNode;
|
|
7
|
-
BeforeFolderList?: React.ReactNode;
|
|
8
|
-
BeforeFolderListTable?: React.ReactNode;
|
|
9
|
-
Description?: React.ReactNode;
|
|
10
|
-
listMenuItems?: React.ReactNode[];
|
|
11
|
-
};
|
|
12
|
-
export type FolderListViewServerPropsOnly = {
|
|
13
|
-
collectionConfig: SanitizedCollectionConfig;
|
|
14
|
-
documents: FolderOrDocument[];
|
|
15
|
-
subfolders: FolderOrDocument[];
|
|
16
|
-
} & ServerProps;
|
|
17
|
-
export type FolderListViewServerProps = FolderListViewClientProps & FolderListViewServerPropsOnly;
|
|
18
|
-
export type FolderListViewClientProps = {
|
|
19
|
-
activeCollectionFolderSlugs?: SanitizedCollectionConfig['slug'][];
|
|
20
|
-
allCollectionFolderSlugs: SanitizedCollectionConfig['slug'][];
|
|
21
|
-
allowCreateCollectionSlugs: SanitizedCollectionConfig['slug'][];
|
|
22
|
-
baseFolderPath: `/${string}`;
|
|
23
|
-
beforeActions?: React.ReactNode[];
|
|
24
|
-
breadcrumbs: FolderBreadcrumb[];
|
|
25
|
-
collectionSlug?: SanitizedCollectionConfig['slug'];
|
|
26
|
-
disableBulkDelete?: boolean;
|
|
27
|
-
disableBulkEdit?: boolean;
|
|
28
|
-
documents: FolderOrDocument[];
|
|
29
|
-
enableRowSelections?: boolean;
|
|
30
|
-
folderAssignedCollections?: SanitizedCollectionConfig['slug'][];
|
|
31
|
-
folderFieldName: string;
|
|
32
|
-
folderID: null | number | string;
|
|
33
|
-
FolderResultsComponent: React.ReactNode;
|
|
34
|
-
search?: string;
|
|
35
|
-
sort?: FolderSortKeys;
|
|
36
|
-
subfolders: FolderOrDocument[];
|
|
37
|
-
viewPreference: 'grid' | 'list';
|
|
38
|
-
} & FolderListViewSlots;
|
|
39
|
-
export type FolderListViewSlotSharedClientProps = {
|
|
40
|
-
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
41
|
-
hasCreatePermission: boolean;
|
|
42
|
-
newDocumentURL: string;
|
|
43
|
-
};
|
|
44
|
-
export type BeforeFolderListClientProps = FolderListViewSlotSharedClientProps;
|
|
45
|
-
export type BeforeFolderListServerPropsOnly = {} & FolderListViewServerPropsOnly;
|
|
46
|
-
export type BeforeFolderListServerProps = BeforeFolderListClientProps & BeforeFolderListServerPropsOnly;
|
|
47
|
-
export type BeforeFolderListTableClientProps = FolderListViewSlotSharedClientProps;
|
|
48
|
-
export type BeforeFolderListTableServerPropsOnly = {} & FolderListViewServerPropsOnly;
|
|
49
|
-
export type BeforeFolderListTableServerProps = BeforeFolderListTableClientProps & BeforeFolderListTableServerPropsOnly;
|
|
50
|
-
export type AfterFolderListClientProps = FolderListViewSlotSharedClientProps;
|
|
51
|
-
export type AfterFolderListServerPropsOnly = {} & FolderListViewServerPropsOnly;
|
|
52
|
-
export type AfterFolderListServerProps = AfterFolderListClientProps & AfterFolderListServerPropsOnly;
|
|
53
|
-
export type AfterFolderListTableClientProps = FolderListViewSlotSharedClientProps;
|
|
54
|
-
export type AfterFolderListTableServerPropsOnly = {} & FolderListViewServerPropsOnly;
|
|
55
|
-
export type AfterFolderListTableServerProps = AfterFolderListTableClientProps & AfterFolderListTableServerPropsOnly;
|
|
56
|
-
//# sourceMappingURL=folderList.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"folderList.d.ts","sourceRoot":"","sources":["../../../src/admin/views/folderList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAChG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACjC,oBAAoB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtC,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,qBAAqB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;CAClC,CAAA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AAyB,CAAC,MAAM,CAAC,CAAA;IACjD,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAGD,MAAM,MAAM,2BAA2B,GAAG,mCAAmC,CAAA;AAC7E,MAAM,MAAM,+BAA+B,GAAG,EAAE,GAAG,6BAA6B,CAAA;AAChF,MAAM,MAAM,2BAA2B,GAAG,2BAA2B,GACnE,+BAA+B,CAAA;AAGjC,MAAM,MAAM,gCAAgC,GAAG,mCAAmC,CAAA;AAClF,MAAM,MAAM,oCAAoC,GAAG,EAAE,GAAG,6BAA6B,CAAA;AACrF,MAAM,MAAM,gCAAgC,GAAG,gCAAgC,GAC7E,oCAAoC,CAAA;AAGtC,MAAM,MAAM,0BAA0B,GAAG,mCAAmC,CAAA;AAC5E,MAAM,MAAM,8BAA8B,GAAG,EAAE,GAAG,6BAA6B,CAAA;AAC/E,MAAM,MAAM,0BAA0B,GAAG,0BAA0B,GAAG,8BAA8B,CAAA;AAGpG,MAAM,MAAM,+BAA+B,GAAG,mCAAmC,CAAA;AACjF,MAAM,MAAM,mCAAmC,GAAG,EAAE,GAAG,6BAA6B,CAAA;AACpF,MAAM,MAAM,+BAA+B,GAAG,+BAA+B,GAC3E,mCAAmC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/views/folderList.ts"],"sourcesContent":["import type { ServerProps } from '../../config/types.js'\nimport type { FolderBreadcrumb, FolderOrDocument, FolderSortKeys } from '../../folders/types.js'\nimport type { SanitizedCollectionConfig } from '../../index.js'\nexport type FolderListViewSlots = {\n AfterFolderList?: React.ReactNode\n AfterFolderListTable?: React.ReactNode\n BeforeFolderList?: React.ReactNode\n BeforeFolderListTable?: React.ReactNode\n Description?: React.ReactNode\n listMenuItems?: React.ReactNode[]\n}\n\nexport type FolderListViewServerPropsOnly = {\n collectionConfig: SanitizedCollectionConfig\n documents: FolderOrDocument[]\n subfolders: FolderOrDocument[]\n} & ServerProps\n\nexport type FolderListViewServerProps = FolderListViewClientProps & FolderListViewServerPropsOnly\n\nexport type FolderListViewClientProps = {\n activeCollectionFolderSlugs?: SanitizedCollectionConfig['slug'][]\n allCollectionFolderSlugs: SanitizedCollectionConfig['slug'][]\n allowCreateCollectionSlugs: SanitizedCollectionConfig['slug'][]\n baseFolderPath: `/${string}`\n beforeActions?: React.ReactNode[]\n breadcrumbs: FolderBreadcrumb[]\n collectionSlug?: SanitizedCollectionConfig['slug']\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n documents: FolderOrDocument[]\n enableRowSelections?: boolean\n folderAssignedCollections?: SanitizedCollectionConfig['slug'][]\n folderFieldName: string\n folderID: null | number | string\n FolderResultsComponent: React.ReactNode\n search?: string\n sort?: FolderSortKeys\n subfolders: FolderOrDocument[]\n viewPreference: 'grid' | 'list'\n} & FolderListViewSlots\n\nexport type FolderListViewSlotSharedClientProps = {\n collectionSlug: SanitizedCollectionConfig['slug']\n hasCreatePermission: boolean\n newDocumentURL: string\n}\n\n// BeforeFolderList\nexport type BeforeFolderListClientProps = FolderListViewSlotSharedClientProps\nexport type BeforeFolderListServerPropsOnly = {} & FolderListViewServerPropsOnly\nexport type BeforeFolderListServerProps = BeforeFolderListClientProps &\n BeforeFolderListServerPropsOnly\n\n// BeforeFolderListTable\nexport type BeforeFolderListTableClientProps = FolderListViewSlotSharedClientProps\nexport type BeforeFolderListTableServerPropsOnly = {} & FolderListViewServerPropsOnly\nexport type BeforeFolderListTableServerProps = BeforeFolderListTableClientProps &\n BeforeFolderListTableServerPropsOnly\n\n// AfterFolderList\nexport type AfterFolderListClientProps = FolderListViewSlotSharedClientProps\nexport type AfterFolderListServerPropsOnly = {} & FolderListViewServerPropsOnly\nexport type AfterFolderListServerProps = AfterFolderListClientProps & AfterFolderListServerPropsOnly\n\n// AfterFolderListTable\nexport type AfterFolderListTableClientProps = FolderListViewSlotSharedClientProps\nexport type AfterFolderListTableServerPropsOnly = {} & FolderListViewServerPropsOnly\nexport type AfterFolderListTableServerProps = AfterFolderListTableClientProps &\n AfterFolderListTableServerPropsOnly\n"],"names":[],"mappings":"AAoEA,WACqC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Config, SanitizedConfig } from '../config/types.js';
|
|
2
|
-
import type { CollectionConfig } from '../index.js';
|
|
3
|
-
export declare function addFolderCollection({ collectionSpecific, config, folderEnabledCollections, richTextSanitizationPromises, validRelationships, }: {
|
|
4
|
-
collectionSpecific: boolean;
|
|
5
|
-
config: NonNullable<Config>;
|
|
6
|
-
folderEnabledCollections: CollectionConfig[];
|
|
7
|
-
richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>;
|
|
8
|
-
validRelationships?: string[];
|
|
9
|
-
}): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=addFolderCollection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addFolderCollection.d.ts","sourceRoot":"","sources":["../../src/folders/addFolderCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,wBAAsB,mBAAmB,CAAC,EACxC,kBAAkB,EAClB,MAAM,EACN,wBAAwB,EACxB,4BAAiC,EACjC,kBAAuB,GACxB,EAAE;IACD,kBAAkB,EAAE,OAAO,CAAA;IAC3B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC3B,wBAAwB,EAAE,gBAAgB,EAAE,CAAA;IAC5C,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B,GAAG,OAAO,CAAC,IAAI,CAAC,CAgChB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { sanitizeCollection } from '../collections/config/sanitize.js';
|
|
2
|
-
import { createFolderCollection } from './createFolderCollection.js';
|
|
3
|
-
export async function addFolderCollection({ collectionSpecific, config, folderEnabledCollections, richTextSanitizationPromises = [], validRelationships = [] }) {
|
|
4
|
-
if (config.folders === false) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
let folderCollectionConfig = createFolderCollection({
|
|
8
|
-
slug: config.folders.slug,
|
|
9
|
-
collectionSpecific,
|
|
10
|
-
debug: config.folders.debug,
|
|
11
|
-
folderEnabledCollections,
|
|
12
|
-
folderFieldName: config.folders.fieldName
|
|
13
|
-
});
|
|
14
|
-
const collectionIndex = config.collections.push(folderCollectionConfig);
|
|
15
|
-
if (Array.isArray(config.folders?.collectionOverrides) && config?.folders.collectionOverrides.length) {
|
|
16
|
-
for (const override of config.folders.collectionOverrides){
|
|
17
|
-
folderCollectionConfig = await override({
|
|
18
|
-
collection: folderCollectionConfig
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const sanitizedCollectionWithOverrides = await sanitizeCollection(config, folderCollectionConfig, richTextSanitizationPromises, validRelationships);
|
|
23
|
-
config.collections[collectionIndex - 1] = sanitizedCollectionWithOverrides;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=addFolderCollection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/folders/addFolderCollection.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../config/types.js'\nimport type { CollectionConfig } from '../index.js'\n\nimport { sanitizeCollection } from '../collections/config/sanitize.js'\nimport { createFolderCollection } from './createFolderCollection.js'\n\nexport async function addFolderCollection({\n collectionSpecific,\n config,\n folderEnabledCollections,\n richTextSanitizationPromises = [],\n validRelationships = [],\n}: {\n collectionSpecific: boolean\n config: NonNullable<Config>\n folderEnabledCollections: CollectionConfig[]\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n validRelationships?: string[]\n}): Promise<void> {\n if (config.folders === false) {\n return\n }\n\n let folderCollectionConfig = createFolderCollection({\n slug: config.folders!.slug as string,\n collectionSpecific,\n debug: config.folders!.debug,\n folderEnabledCollections,\n folderFieldName: config.folders!.fieldName as string,\n })\n\n const collectionIndex = config.collections!.push(folderCollectionConfig)\n\n if (\n Array.isArray(config.folders?.collectionOverrides) &&\n config?.folders.collectionOverrides.length\n ) {\n for (const override of config.folders.collectionOverrides) {\n folderCollectionConfig = await override({ collection: folderCollectionConfig })\n }\n }\n\n const sanitizedCollectionWithOverrides = await sanitizeCollection(\n config as unknown as Config,\n folderCollectionConfig,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n config.collections![collectionIndex - 1] = sanitizedCollectionWithOverrides\n}\n"],"names":["sanitizeCollection","createFolderCollection","addFolderCollection","collectionSpecific","config","folderEnabledCollections","richTextSanitizationPromises","validRelationships","folders","folderCollectionConfig","slug","debug","folderFieldName","fieldName","collectionIndex","collections","push","Array","isArray","collectionOverrides","length","override","collection","sanitizedCollectionWithOverrides"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,sBAAsB,QAAQ,8BAA6B;AAEpE,OAAO,eAAeC,oBAAoB,EACxCC,kBAAkB,EAClBC,MAAM,EACNC,wBAAwB,EACxBC,+BAA+B,EAAE,EACjCC,qBAAqB,EAAE,EAOxB;IACC,IAAIH,OAAOI,OAAO,KAAK,OAAO;QAC5B;IACF;IAEA,IAAIC,yBAAyBR,uBAAuB;QAClDS,MAAMN,OAAOI,OAAO,CAAEE,IAAI;QAC1BP;QACAQ,OAAOP,OAAOI,OAAO,CAAEG,KAAK;QAC5BN;QACAO,iBAAiBR,OAAOI,OAAO,CAAEK,SAAS;IAC5C;IAEA,MAAMC,kBAAkBV,OAAOW,WAAW,CAAEC,IAAI,CAACP;IAEjD,IACEQ,MAAMC,OAAO,CAACd,OAAOI,OAAO,EAAEW,wBAC9Bf,QAAQI,QAAQW,oBAAoBC,QACpC;QACA,KAAK,MAAMC,YAAYjB,OAAOI,OAAO,CAACW,mBAAmB,CAAE;YACzDV,yBAAyB,MAAMY,SAAS;gBAAEC,YAAYb;YAAuB;QAC/E;IACF;IAEA,MAAMc,mCAAmC,MAAMvB,mBAC7CI,QACAK,wBACAH,8BACAC;IAGFH,OAAOW,WAAW,AAAC,CAACD,kBAAkB,EAAE,GAAGS;AAC7C"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig } from '../index.js';
|
|
2
|
-
export declare const addFolderFieldToCollection: ({ collection, collectionSpecific, folderFieldName, folderSlug, }: {
|
|
3
|
-
collection: SanitizedCollectionConfig;
|
|
4
|
-
collectionSpecific: boolean;
|
|
5
|
-
folderFieldName: string;
|
|
6
|
-
folderSlug: string;
|
|
7
|
-
}) => void;
|
|
8
|
-
//# sourceMappingURL=addFolderFieldToCollection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addFolderFieldToCollection.d.ts","sourceRoot":"","sources":["../../src/folders/addFolderFieldToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAI5D,eAAO,MAAM,0BAA0B,qEAKpC;IACD,UAAU,EAAE,yBAAyB,CAAA;IACrC,kBAAkB,EAAE,OAAO,CAAA;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,IAkBH,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { buildFolderField } from './buildFolderField.js';
|
|
2
|
-
export const addFolderFieldToCollection = ({ collection, collectionSpecific, folderFieldName, folderSlug })=>{
|
|
3
|
-
collection.fields.push(buildFolderField({
|
|
4
|
-
collectionSpecific,
|
|
5
|
-
folderFieldName,
|
|
6
|
-
folderSlug,
|
|
7
|
-
overrides: {
|
|
8
|
-
admin: {
|
|
9
|
-
allowCreate: false,
|
|
10
|
-
allowEdit: false,
|
|
11
|
-
components: {
|
|
12
|
-
Cell: '@payloadcms/next/rsc#FolderTableCell',
|
|
13
|
-
Field: '@payloadcms/next/rsc#FolderField'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=addFolderFieldToCollection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/folders/addFolderFieldToCollection.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../index.js'\n\nimport { buildFolderField } from './buildFolderField.js'\n\nexport const addFolderFieldToCollection = ({\n collection,\n collectionSpecific,\n folderFieldName,\n folderSlug,\n}: {\n collection: SanitizedCollectionConfig\n collectionSpecific: boolean\n folderFieldName: string\n folderSlug: string\n}): void => {\n collection.fields.push(\n buildFolderField({\n collectionSpecific,\n folderFieldName,\n folderSlug,\n overrides: {\n admin: {\n allowCreate: false,\n allowEdit: false,\n components: {\n Cell: '@payloadcms/next/rsc#FolderTableCell',\n Field: '@payloadcms/next/rsc#FolderField',\n },\n },\n },\n }),\n )\n}\n"],"names":["buildFolderField","addFolderFieldToCollection","collection","collectionSpecific","folderFieldName","folderSlug","fields","push","overrides","admin","allowCreate","allowEdit","components","Cell","Field"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,6BAA6B,CAAC,EACzCC,UAAU,EACVC,kBAAkB,EAClBC,eAAe,EACfC,UAAU,EAMX;IACCH,WAAWI,MAAM,CAACC,IAAI,CACpBP,iBAAiB;QACfG;QACAC;QACAC;QACAG,WAAW;YACTC,OAAO;gBACLC,aAAa;gBACbC,WAAW;gBACXC,YAAY;oBACVC,MAAM;oBACNC,OAAO;gBACT;YACF;QACF;IACF;AAEJ,EAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SingleRelationshipField } from '../fields/config/types.js';
|
|
2
|
-
export declare const buildFolderField: ({ collectionSpecific, folderFieldName, folderSlug, overrides, }: {
|
|
3
|
-
collectionSpecific: boolean;
|
|
4
|
-
folderFieldName: string;
|
|
5
|
-
folderSlug: string;
|
|
6
|
-
overrides?: Partial<SingleRelationshipField>;
|
|
7
|
-
}) => SingleRelationshipField;
|
|
8
|
-
//# sourceMappingURL=buildFolderField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildFolderField.d.ts","sourceRoot":"","sources":["../../src/folders/buildFolderField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAKxE,eAAO,MAAM,gBAAgB,oEAK1B;IACD,kBAAkB,EAAE,OAAO,CAAA;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA;CAC7C,KAAG,uBA4FH,CAAA"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { extractID } from '../utilities/extractID.js';
|
|
2
|
-
export const buildFolderField = ({ collectionSpecific, folderFieldName, folderSlug, overrides = {} })=>{
|
|
3
|
-
const field = {
|
|
4
|
-
name: folderFieldName,
|
|
5
|
-
type: 'relationship',
|
|
6
|
-
admin: {},
|
|
7
|
-
hasMany: false,
|
|
8
|
-
index: true,
|
|
9
|
-
label: 'Folder',
|
|
10
|
-
relationTo: folderSlug,
|
|
11
|
-
validate: async (value, { collectionSlug, data, overrideAccess, previousValue, req })=>{
|
|
12
|
-
if (!collectionSpecific) {
|
|
13
|
-
// if collection scoping is not enabled, no validation required since folders can contain any type of document
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (!value) {
|
|
17
|
-
// no folder, no validation required
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
const newID = extractID(value);
|
|
21
|
-
if (previousValue && extractID(previousValue) === newID) {
|
|
22
|
-
// value did not change, no validation required
|
|
23
|
-
return true;
|
|
24
|
-
} else {
|
|
25
|
-
// need to validat the folder value allows this collection type
|
|
26
|
-
let parentFolder = null;
|
|
27
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
28
|
-
// need to populate the value with the document
|
|
29
|
-
parentFolder = await req.payload.findByID({
|
|
30
|
-
id: newID,
|
|
31
|
-
collection: folderSlug,
|
|
32
|
-
depth: 0,
|
|
33
|
-
overrideAccess,
|
|
34
|
-
req,
|
|
35
|
-
select: {
|
|
36
|
-
folderType: true
|
|
37
|
-
},
|
|
38
|
-
user: req.user
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (parentFolder && collectionSlug) {
|
|
42
|
-
const parentFolderTypes = parentFolder.folderType || [];
|
|
43
|
-
// if the parent folder has no folder types, it accepts all collections
|
|
44
|
-
if (parentFolderTypes.length === 0) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
// validation for a folder document
|
|
48
|
-
if (collectionSlug === folderSlug) {
|
|
49
|
-
// ensure the parent accepts ALL folder types
|
|
50
|
-
const folderTypes = 'folderType' in data ? data.folderType : [];
|
|
51
|
-
const invalidSlugs = folderTypes.filter((validCollectionSlug)=>{
|
|
52
|
-
return !parentFolderTypes.includes(validCollectionSlug);
|
|
53
|
-
});
|
|
54
|
-
if (invalidSlugs.length === 0) {
|
|
55
|
-
return true;
|
|
56
|
-
} else {
|
|
57
|
-
return `Folder with ID ${newID} does not allow documents of type ${invalidSlugs.join(', ')}`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// validation for a non-folder document
|
|
61
|
-
if (parentFolderTypes.includes(collectionSlug)) {
|
|
62
|
-
return true;
|
|
63
|
-
} else {
|
|
64
|
-
return `Folder with ID ${newID} does not allow documents of type ${collectionSlug}`;
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
return `Folder with ID ${newID} not found in collection ${folderSlug}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
if (overrides?.admin) {
|
|
73
|
-
field.admin = {
|
|
74
|
-
...field.admin,
|
|
75
|
-
...overrides.admin || {}
|
|
76
|
-
};
|
|
77
|
-
if (overrides.admin.components) {
|
|
78
|
-
field.admin.components = {
|
|
79
|
-
...field.admin.components,
|
|
80
|
-
...overrides.admin.components || {}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return field;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
//# sourceMappingURL=buildFolderField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/folders/buildFolderField.ts"],"sourcesContent":["import type { SingleRelationshipField } from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\n\nimport { extractID } from '../utilities/extractID.js'\n\nexport const buildFolderField = ({\n collectionSpecific,\n folderFieldName,\n folderSlug,\n overrides = {},\n}: {\n collectionSpecific: boolean\n folderFieldName: string\n folderSlug: string\n overrides?: Partial<SingleRelationshipField>\n}): SingleRelationshipField => {\n const field: SingleRelationshipField = {\n name: folderFieldName,\n type: 'relationship',\n admin: {},\n hasMany: false,\n index: true,\n label: 'Folder',\n relationTo: folderSlug,\n validate: async (value, { collectionSlug, data, overrideAccess, previousValue, req }) => {\n if (!collectionSpecific) {\n // if collection scoping is not enabled, no validation required since folders can contain any type of document\n return true\n }\n\n if (!value) {\n // no folder, no validation required\n return true\n }\n\n const newID = extractID<Document>(value)\n if (previousValue && extractID<Document>(previousValue) === newID) {\n // value did not change, no validation required\n return true\n } else {\n // need to validat the folder value allows this collection type\n let parentFolder: Document = null\n if (typeof value === 'string' || typeof value === 'number') {\n // need to populate the value with the document\n parentFolder = await req.payload.findByID({\n id: newID,\n collection: folderSlug,\n depth: 0, // no need to populate nested folders\n overrideAccess,\n req,\n select: {\n folderType: true, // only need to check folderType\n },\n user: req.user,\n })\n }\n\n if (parentFolder && collectionSlug) {\n const parentFolderTypes: string[] = (parentFolder.folderType as string[]) || []\n\n // if the parent folder has no folder types, it accepts all collections\n if (parentFolderTypes.length === 0) {\n return true\n }\n\n // validation for a folder document\n if (collectionSlug === folderSlug) {\n // ensure the parent accepts ALL folder types\n const folderTypes: string[] = 'folderType' in data ? (data.folderType as string[]) : []\n const invalidSlugs = folderTypes.filter((validCollectionSlug: string) => {\n return !parentFolderTypes.includes(validCollectionSlug)\n })\n if (invalidSlugs.length === 0) {\n return true\n } else {\n return `Folder with ID ${newID} does not allow documents of type ${invalidSlugs.join(', ')}`\n }\n }\n\n // validation for a non-folder document\n if (parentFolderTypes.includes(collectionSlug)) {\n return true\n } else {\n return `Folder with ID ${newID} does not allow documents of type ${collectionSlug}`\n }\n } else {\n return `Folder with ID ${newID} not found in collection ${folderSlug}`\n }\n }\n },\n }\n\n if (overrides?.admin) {\n field.admin = {\n ...field.admin,\n ...(overrides.admin || {}),\n }\n\n if (overrides.admin.components) {\n field.admin.components = {\n ...field.admin.components,\n ...(overrides.admin.components || {}),\n }\n }\n }\n\n return field\n}\n"],"names":["extractID","buildFolderField","collectionSpecific","folderFieldName","folderSlug","overrides","field","name","type","admin","hasMany","index","label","relationTo","validate","value","collectionSlug","data","overrideAccess","previousValue","req","newID","parentFolder","payload","findByID","id","collection","depth","select","folderType","user","parentFolderTypes","length","folderTypes","invalidSlugs","filter","validCollectionSlug","includes","join","components"],"mappings":"AAGA,SAASA,SAAS,QAAQ,4BAA2B;AAErD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,kBAAkB,EAClBC,eAAe,EACfC,UAAU,EACVC,YAAY,CAAC,CAAC,EAMf;IACC,MAAMC,QAAiC;QACrCC,MAAMJ;QACNK,MAAM;QACNC,OAAO,CAAC;QACRC,SAAS;QACTC,OAAO;QACPC,OAAO;QACPC,YAAYT;QACZU,UAAU,OAAOC,OAAO,EAAEC,cAAc,EAAEC,IAAI,EAAEC,cAAc,EAAEC,aAAa,EAAEC,GAAG,EAAE;YAClF,IAAI,CAAClB,oBAAoB;gBAC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L,OAAO,CAAC,eAAe,EAAEK,MAAM,yBAAyB,EAAEjB,YAAY;gBACxE;YACF;QACF;IACF;IAEA,IAAIC,WAAWI,OAAO;QACpBH,MAAMG,KAAK,GAAG;YACZ,GAAGH,MAAMG,KAAK;YACd,GAAIJ,UAAUI,KAAK,IAAI,CAAC,CAAC;QAC3B;QAEA,IAAIJ,UAAUI,KAAK,CAAC8B,UAAU,EAAE;YAC9BjC,MAAMG,KAAK,CAAC8B,UAAU,GAAG;gBACvB,GAAGjC,MAAMG,KAAK,CAAC8B,UAAU;gBACzB,GAAIlC,UAAUI,KAAK,CAAC8B,UAAU,IAAI,CAAC,CAAC;YACtC;QACF;IACF;IAEA,OAAOjC;AACT,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/folders/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,oBAAoB,CAAA;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/folders/constants.ts"],"sourcesContent":["export const foldersSlug = 'payload-folders'\nexport const parentFolderFieldName = 'folder'\n"],"names":["foldersSlug","parentFolderFieldName"],"mappings":"AAAA,OAAO,MAAMA,cAAc,kBAAiB;AAC5C,OAAO,MAAMC,wBAAwB,SAAQ"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig } from '../collections/config/types.js';
|
|
2
|
-
type CreateFolderCollectionArgs = {
|
|
3
|
-
collectionSpecific: boolean;
|
|
4
|
-
debug?: boolean;
|
|
5
|
-
folderEnabledCollections: CollectionConfig[];
|
|
6
|
-
folderFieldName: string;
|
|
7
|
-
slug: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const createFolderCollection: ({ slug, collectionSpecific, debug, folderEnabledCollections, folderFieldName, }: CreateFolderCollectionArgs) => CollectionConfig;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=createFolderCollection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFolderCollection.d.ts","sourceRoot":"","sources":["../../src/folders/createFolderCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAUtE,KAAK,0BAA0B,GAAG;IAChC,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,wBAAwB,EAAE,gBAAgB,EAAE,CAAA;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AACD,eAAO,MAAM,sBAAsB,oFAMhC,0BAA0B,KAAG,gBAqG/B,CAAA"}
|