@ai-stack/payloadcms 3.2.8-beta → 3.2.9-beta

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.
Files changed (44) hide show
  1. package/README.md +11 -2
  2. package/dist/ai/schemas/lexicalJsonSchema.d.ts +373 -1
  3. package/dist/ai/schemas/lexicalJsonSchema.d.ts.map +1 -1
  4. package/dist/ai/schemas/lexicalJsonSchema.js +13 -9
  5. package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
  6. package/dist/collections/Instructions.d.ts.map +1 -1
  7. package/dist/collections/Instructions.js +17 -28
  8. package/dist/collections/Instructions.js.map +1 -1
  9. package/dist/endpoints/fetchFields.d.ts +2 -1
  10. package/dist/endpoints/fetchFields.d.ts.map +1 -1
  11. package/dist/endpoints/fetchFields.js +33 -17
  12. package/dist/endpoints/fetchFields.js.map +1 -1
  13. package/dist/fields/ComposeField/ComposeField.js +3 -2
  14. package/dist/fields/ComposeField/ComposeField.js.map +1 -1
  15. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +1 -1
  16. package/dist/fields/LexicalEditor/ComposeFeatureComponent.js +3 -2
  17. package/dist/fields/LexicalEditor/ComposeFeatureComponent.js.map +1 -1
  18. package/dist/init.d.ts.map +1 -1
  19. package/dist/init.js +5 -3
  20. package/dist/init.js.map +1 -1
  21. package/dist/plugin.js +3 -3
  22. package/dist/plugin.js.map +1 -1
  23. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +1 -0
  24. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
  25. package/dist/providers/InstructionsProvider/InstructionsProvider.js +11 -4
  26. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  27. package/dist/types.d.ts +11 -2
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/types.js.map +1 -1
  30. package/dist/ui/Compose/Compose.d.ts +2 -1
  31. package/dist/ui/Compose/Compose.d.ts.map +1 -1
  32. package/dist/ui/Compose/Compose.js +5 -4
  33. package/dist/ui/Compose/Compose.js.map +1 -1
  34. package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +1 -1
  35. package/dist/ui/Compose/hooks/menu/TranslateMenu.js +4 -0
  36. package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
  37. package/dist/ui/Compose/hooks/menu/useMenu.d.ts +2 -2
  38. package/dist/ui/Compose/hooks/menu/useMenu.d.ts.map +1 -1
  39. package/dist/ui/Compose/hooks/menu/useMenu.js +8 -4
  40. package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
  41. package/dist/utilities/isPluginActivated.d.ts +1 -1
  42. package/dist/utilities/isPluginActivated.d.ts.map +1 -1
  43. package/dist/utilities/isPluginActivated.js.map +1 -1
  44. package/package.json +6 -6
package/README.md CHANGED
@@ -37,7 +37,9 @@ Want to dive deeper?
37
37
  - 🖼️ **Image Generation** powered by OpenAI
38
38
 
39
39
  ### Other Features
40
+ - 🔌 **Bring your own model** ([Setup guide](https://github.com/ashbuilds/payload-ai/blob/main/guide.md#5-add-custom-model))
40
41
  - 🎛️ **Field-level Prompt Customization**
42
+ - 🔐 **Access Control Support**
41
43
  - 🧠 **Prompt Editor** (Beta)
42
44
  - 📊 **Document Analyzer** (Coming Soon)
43
45
  - ✅ **Fact Checking** (Coming Soon)
@@ -79,7 +81,15 @@ export default buildConfig({
79
81
  [Posts.slug]: true,
80
82
  },
81
83
  debugging: false,
82
- disableSponsorMessage: false
84
+ disableSponsorMessage: false,
85
+
86
+ /* Enable to restrict access to AI plugin settings only to admin users
87
+ access: {
88
+ settings: ({ req }: { req: PayloadRequest }) => {
89
+ return req.user?.role === 'admin';
90
+ },
91
+ },
92
+ */
83
93
  }),
84
94
  ],
85
95
  // ... your existing Payload configuration
@@ -133,7 +143,6 @@ If not specified, the [default](src/ai/models/openai/openai.ts) OpenAI endpoint
133
143
 
134
144
  For detailed guidance on personalizing and configuring the plugin to match your needs, check out the **[Complete Guide](guide.md)**. It walks you through every step, from setting up fields to generating amazing content!
135
145
 
136
-
137
146
  ### Enabling AI for Custom Components
138
147
 
139
148
  > **⚠️ Note:** Custom fields don't fully adhere to the Payload schema, making it difficult to determine which components support injecting ComposeField as a Description.
@@ -371,5 +371,377 @@ export declare const documentSchema: {
371
371
  };
372
372
  required: string[];
373
373
  };
374
- export declare const lexicalJsonSchema: (customNodes?: any[]) => any;
374
+ export declare const lexicalJsonSchema: (customNodes?: any[]) => {
375
+ type: string;
376
+ $schema: string;
377
+ additionalProperties: boolean;
378
+ definitions: {
379
+ TextNode: {
380
+ type: string;
381
+ additionalProperties: boolean;
382
+ properties: {
383
+ type: {
384
+ type: string;
385
+ enum: string[];
386
+ };
387
+ detail: {
388
+ type: string;
389
+ description: string;
390
+ enum: number[];
391
+ examples: {
392
+ description: string;
393
+ value: number;
394
+ }[];
395
+ };
396
+ direction: {
397
+ type: string[];
398
+ enum: string[];
399
+ };
400
+ format: {
401
+ type: string;
402
+ description: string;
403
+ };
404
+ indent: {
405
+ type: string;
406
+ };
407
+ mode: {
408
+ type: string;
409
+ description: string;
410
+ enum: number[];
411
+ examples: {
412
+ description: string;
413
+ value: number;
414
+ }[];
415
+ };
416
+ style: {
417
+ type: string;
418
+ description: string;
419
+ };
420
+ text: {
421
+ type: string;
422
+ };
423
+ version: {
424
+ type: string;
425
+ };
426
+ };
427
+ required: string[];
428
+ };
429
+ TableCellNode: {
430
+ type: string;
431
+ additionalProperties: boolean;
432
+ properties: {
433
+ type: {
434
+ type: string;
435
+ enum: string[];
436
+ };
437
+ children: {
438
+ type: string;
439
+ items: {
440
+ $ref: string;
441
+ };
442
+ };
443
+ colSpan: {
444
+ type: string;
445
+ };
446
+ direction: {
447
+ type: string[];
448
+ enum: string[];
449
+ };
450
+ headerState: {
451
+ type: string;
452
+ };
453
+ indent: {
454
+ type: string;
455
+ };
456
+ version: {
457
+ type: string;
458
+ };
459
+ width: {
460
+ type: string[];
461
+ enum: any[];
462
+ };
463
+ };
464
+ required: string[];
465
+ };
466
+ TableRowNode: {
467
+ type: string;
468
+ additionalProperties: boolean;
469
+ properties: {
470
+ type: {
471
+ type: string;
472
+ enum: string[];
473
+ };
474
+ children: {
475
+ type: string;
476
+ items: {
477
+ $ref: string;
478
+ };
479
+ };
480
+ height: {
481
+ type: string;
482
+ };
483
+ };
484
+ required: string[];
485
+ };
486
+ TableNode: {
487
+ type: string;
488
+ additionalProperties: boolean;
489
+ properties: {
490
+ type: {
491
+ type: string;
492
+ enum: string[];
493
+ };
494
+ children: {
495
+ type: string;
496
+ items: {
497
+ $ref: string;
498
+ };
499
+ };
500
+ };
501
+ required: string[];
502
+ };
503
+ HeadingNode: {
504
+ type: string;
505
+ additionalProperties: boolean;
506
+ properties: {
507
+ type: {
508
+ type: string;
509
+ enum: string[];
510
+ };
511
+ children: {
512
+ type: string;
513
+ items: {
514
+ anyOf: {
515
+ $ref: string;
516
+ }[];
517
+ };
518
+ };
519
+ direction: {
520
+ type: string[];
521
+ enum: string[];
522
+ };
523
+ indent: {
524
+ type: string;
525
+ };
526
+ tag: {
527
+ type: string;
528
+ enum: string[];
529
+ };
530
+ version: {
531
+ type: string;
532
+ };
533
+ };
534
+ required: string[];
535
+ };
536
+ ParagraphNode: {
537
+ type: string;
538
+ additionalProperties: boolean;
539
+ properties: {
540
+ type: {
541
+ type: string;
542
+ enum: string[];
543
+ };
544
+ children: {
545
+ type: string;
546
+ items: {
547
+ anyOf: {
548
+ $ref: string;
549
+ }[];
550
+ };
551
+ };
552
+ direction: {
553
+ type: string[];
554
+ enum: string[];
555
+ };
556
+ format: {
557
+ type: string;
558
+ enum: string[];
559
+ };
560
+ indent: {
561
+ type: string;
562
+ };
563
+ textFormat: {
564
+ type: string;
565
+ };
566
+ textStyle: {
567
+ type: string;
568
+ description: string;
569
+ };
570
+ version: {
571
+ type: string;
572
+ };
573
+ };
574
+ required: string[];
575
+ };
576
+ LinkNode: {
577
+ type: string;
578
+ additionalProperties: boolean;
579
+ properties: {
580
+ type: {
581
+ type: string;
582
+ enum: string[];
583
+ };
584
+ children: {
585
+ type: string;
586
+ items: {
587
+ $ref: string;
588
+ };
589
+ };
590
+ url: {
591
+ type: string;
592
+ };
593
+ };
594
+ required: string[];
595
+ };
596
+ ListItemNode: {
597
+ type: string;
598
+ additionalProperties: boolean;
599
+ properties: {
600
+ indent: {
601
+ type: string;
602
+ enum: number[];
603
+ };
604
+ type: {
605
+ type: string;
606
+ enum: string[];
607
+ };
608
+ children: {
609
+ type: string;
610
+ items: {
611
+ anyOf: {
612
+ $ref: string;
613
+ }[];
614
+ };
615
+ };
616
+ };
617
+ required: string[];
618
+ };
619
+ ListNode: {
620
+ type: string;
621
+ additionalProperties: boolean;
622
+ properties: {
623
+ type: {
624
+ type: string;
625
+ enum: string[];
626
+ };
627
+ children: {
628
+ type: string;
629
+ items: {
630
+ $ref: string;
631
+ };
632
+ };
633
+ listType: {
634
+ type: string;
635
+ enum: string[];
636
+ };
637
+ };
638
+ required: string[];
639
+ };
640
+ QuoteNode: {
641
+ type: string;
642
+ additionalProperties: boolean;
643
+ properties: {
644
+ type: {
645
+ type: string;
646
+ enum: string[];
647
+ };
648
+ children: {
649
+ type: string;
650
+ items: {
651
+ anyOf: {
652
+ $ref: string;
653
+ }[];
654
+ };
655
+ };
656
+ };
657
+ required: string[];
658
+ };
659
+ CodeNode: {
660
+ type: string;
661
+ additionalProperties: boolean;
662
+ properties: {
663
+ type: {
664
+ type: string;
665
+ enum: string[];
666
+ };
667
+ code: {
668
+ type: string;
669
+ };
670
+ language: {
671
+ type: string;
672
+ };
673
+ };
674
+ required: string[];
675
+ };
676
+ HorizontalRuleNode: {
677
+ type: string;
678
+ additionalProperties: boolean;
679
+ properties: {
680
+ type: {
681
+ type: string;
682
+ enum: string[];
683
+ };
684
+ };
685
+ required: string[];
686
+ };
687
+ ImageNode: {
688
+ type: string;
689
+ additionalProperties: boolean;
690
+ properties: {
691
+ type: {
692
+ type: string;
693
+ enum: string[];
694
+ };
695
+ alt: {
696
+ type: string;
697
+ };
698
+ caption: {
699
+ type: string;
700
+ items: {
701
+ $ref: string;
702
+ };
703
+ };
704
+ src: {
705
+ type: string;
706
+ };
707
+ };
708
+ required: string[];
709
+ };
710
+ RootNode: {
711
+ type: string;
712
+ additionalProperties: boolean;
713
+ properties: {
714
+ type: {
715
+ type: string;
716
+ enum: string[];
717
+ };
718
+ children: {
719
+ type: string;
720
+ items: {
721
+ anyOf: {
722
+ $ref: string;
723
+ }[];
724
+ };
725
+ };
726
+ direction: {
727
+ type: string[];
728
+ enum: string[];
729
+ };
730
+ indent: {
731
+ type: string;
732
+ };
733
+ version: {
734
+ type: string;
735
+ };
736
+ };
737
+ required: string[];
738
+ };
739
+ };
740
+ properties: {
741
+ root: {
742
+ $ref: string;
743
+ };
744
+ };
745
+ required: string[];
746
+ };
375
747
  //# sourceMappingURL=lexicalJsonSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lexicalJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmW1B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,mBAAgB,QAajD,CAAA"}
1
+ {"version":3,"file":"lexicalJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsW1B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,mBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAejD,CAAA"}
@@ -392,6 +392,9 @@ export const documentSchema = {
392
392
  type: 'object',
393
393
  additionalProperties: false,
394
394
  properties: {
395
+ // NOTE: Do not change the position of "indent", models like gpt generate properties as they are
396
+ // defined in schema, moving the position of property "indent"
397
+ // can cause issue with schema validation while streaming generated json to lexical editor
395
398
  indent: {
396
399
  type: 'number',
397
400
  enum: [
@@ -641,15 +644,16 @@ export const documentSchema = {
641
644
  ]
642
645
  };
643
646
  export const lexicalJsonSchema = (customNodes = [])=>{
644
- const schema = JSON.parse(JSON.stringify(documentSchema));
645
- // Add custom nodes to the Node definition
646
- if (customNodes.length > 0) {
647
- customNodes.forEach((customNode, index)=>{
648
- const customNodeName = `CustomNode${index + 1}`;
649
- schema.definitions[customNodeName] = customNode;
650
- schema.definitions.Node.oneOf.push({
651
- $ref: `#/definitions/${customNodeName}`
652
- });
647
+ const schema = structuredClone(documentSchema);
648
+ if (Array.isArray(customNodes) && customNodes.length > 0) {
649
+ customNodes.forEach((nodeObj)=>{
650
+ for (const [nodeName, nodeDefinition] of Object.entries(nodeObj)){
651
+ schema.definitions[nodeName] = nodeDefinition;
652
+ const anyOfList = schema?.definitions?.RootNode?.properties?.children?.items?.anyOf;
653
+ anyOfList.push({
654
+ $ref: `#/definitions/${nodeName}`
655
+ });
656
+ }
653
657
  });
654
658
  }
655
659
  return schema;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["export const documentSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/LinkNode' }],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: { type: 'string', enum: ['start', 'center', 'right'] },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n indent: { type: 'number', enum: [0, 1] },\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/ParagraphNode' }, { $ref: '#/definitions/ListNode' }],\n },\n },\n },\n required: ['indent', 'type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/ParagraphNode' }],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes = []) => {\n const schema = JSON.parse(JSON.stringify(documentSchema))\n\n // Add custom nodes to the Node definition\n if (customNodes.length > 0) {\n customNodes.forEach((customNode, index) => {\n const customNodeName = `CustomNode${index + 1}`\n schema.definitions[customNodeName] = customNode\n schema.definitions.Node.oneOf.push({ $ref: `#/definitions/${customNodeName}` })\n })\n }\n\n return schema\n}\n"],"names":["documentSchema","type","$schema","additionalProperties","definitions","TextNode","properties","enum","detail","description","examples","value","direction","format","indent","mode","style","text","version","required","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","JSON","parse","stringify","length","forEach","customNode","index","customNodeName","Node","oneOf","push"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB;IAC5BC,MAAM;IACNC,SAAS;IACTC,sBAAsB;IACtBC,aAAa;QACX,wBAAwB;QACxBC,UAAU;YACRJ,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAO;gBAAC;gBACvCC,QAAQ;oBACNP,MAAM;oBACNQ,aAAa;oBACbF,MAAM;wBACJ;wBACA;wBACA;wBACA;qBACD;oBACDG,UAAU;wBACR;4BAAED,aAAa;4BAAsBE,OAAO;wBAAE;wBAC9C;4BAAEF,aAAa;4BAAiBE,OAAO;wBAAE;wBACzC;4BAAEF,aAAa;4BAAeE,OAAO;wBAAE;wBACvC;4BAAEF,aAAa;4BAA+BE,OAAO;wBAAE;qBACxD;gBACH;gBACAC,WAAW;oBACTX,MAAM;wBA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M,GAAG,GAAG;QAC1BL,YAAYM,OAAO,CAAC,CAACC,YAAYC;YAC/B,MAAMC,iBAAiB,CAAC,UAAU,EAAED,QAAQ,GAAG;YAC/CP,OAAOlD,WAAW,CAAC0D,eAAe,GAAGF;YACrCN,OAAOlD,WAAW,CAAC2D,IAAI,CAACC,KAAK,CAACC,IAAI,CAAC;gBAAE1C,MAAM,CAAC,cAAc,EAAEuC,gBAAgB;YAAC;QAC/E;IACF;IAEA,OAAOR;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["export const documentSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/LinkNode' }],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: { type: 'string', enum: ['start', 'center', 'right'] },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n // NOTE: Do not change the position of \"indent\", models like gpt generate properties as they are\n // defined in schema, moving the position of property \"indent\"\n // can cause issue with schema validation while streaming generated json to lexical editor\n indent: { type: 'number', enum: [0, 1] },\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/ParagraphNode' }, { $ref: '#/definitions/ListNode' }],\n },\n },\n },\n required: ['indent', 'type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/ParagraphNode' }],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes = []) => {\n const schema = structuredClone(documentSchema)\n\n if (Array.isArray(customNodes) && customNodes.length > 0) {\n customNodes.forEach((nodeObj) => {\n for (const [nodeName, nodeDefinition] of Object.entries(nodeObj)) {\n schema.definitions[nodeName] = nodeDefinition\n const anyOfList = schema?.definitions?.RootNode?.properties?.children?.items?.anyOf\n\n anyOfList.push({ $ref: `#/definitions/${nodeName}` })\n }\n })\n }\n\n return schema\n}\n"],"names":["documentSchema","type","$schema","additionalProperties","definitions","TextNode","properties","enum","detail","description","examples","value","direction","format","indent","mode","style","text","version","required","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","structuredClone","Array","isArray","length","forEach","nodeObj","nodeName","nodeDefinition","Object","entries","anyOfList","push"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB;IAC5BC,MAAM;IACNC,SAAS;IACTC,sBAAsB;IACtBC,aAAa;QACX,wBAAwB;QACxBC,UAAU;YACRJ,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAO;gBAAC;gBACvCC,QAAQ;oBACNP,MAAM;oBACNQ,aAAa;oBACbF,MAAM;wBACJ;wBACA;wBACA;wBACA;qBACD;oBACDG,UAAU;wBACR;4BAAED,aAAa;4BAAsBE,OAAO;wBAAE;wBAC9C;4BAAEF,aAAa;4BAAiBE,OAAO;wBAAE;wBACzC;4BAAEF,aAAa;4BAAeE,OAAO;wBAAE;wBACvC;4BAAEF,aAAa;4BAA+BE,OAAO;wBAAE;qBACxD;gBACH;gBACAC,WAAW;oBACTX,MAAM;wBAAC;wBAAU;qBAAO;oBACxBM,MAAM;wBAAC;wBAAO;qBAAK;gBACrB;gBACAM,QAAQ;oBACNZ,MAAM;oBACNQ,aAAa,CAAC;;;;;;;;;;;;;;;;;;4CAkBoB,CAAC;gBACrC;gBACAK,QAAQ;oBAAEb,MAAM;gBAA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,GAAGC;gBAC/B,MAAMG,YAAYX,QAAQlD,aAAa8C,UAAU5C,YAAYe,UAAUC,OAAOS;gBAE9EkC,UAAUC,IAAI,CAAC;oBAAE3C,MAAM,CAAC,cAAc,EAAEsC,UAAU;gBAAC;YACrD;QACF;IACF;IAEA,OAAOP;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAiChD,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,EAC1B,UAAU,OAAO,CAAC,gBAAgB,CAAC,KAElC,gBAuKA,CAAA"}
1
+ {"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAiChD,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,EAC1B,UAAU,OAAO,CAAC,gBAAgB,CAAC,KAElC,gBAoKA,CAAA"}
@@ -1,5 +1,5 @@
1
- import { getGenerationModels } from '../utilities/getGenerationModels.js';
2
1
  import { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js';
2
+ import { getGenerationModels } from '../utilities/getGenerationModels.js';
3
3
  const groupSettings = (pluginConfig)=>getGenerationModels(pluginConfig).reduce((fields, model)=>{
4
4
  if (model.settings) {
5
5
  fields.push(model.settings);
@@ -106,8 +106,6 @@ export const instructionsCollection = (pluginConfig, options)=>({
106
106
  type: 'tabs',
107
107
  tabs: [
108
108
  {
109
- // TODO: Add some info about the field to guide user
110
- // TODO: Add some info about the field to guide user
111
109
  description: 'The Prompt field allows you to define dynamic templates using placeholders (e.g., {{ fieldName }}) to customize output based on your data fields.',
112
110
  fields: [
113
111
  {
@@ -125,16 +123,16 @@ export const instructionsCollection = (pluginConfig, options)=>({
125
123
  label: 'Prompt'
126
124
  },
127
125
  {
126
+ admin: {
127
+ condition: (_, current)=>{
128
+ return current['field-type'] === 'richText';
129
+ }
130
+ },
128
131
  description: '',
129
132
  fields: [
130
133
  {
131
134
  name: 'system',
132
135
  type: 'textarea',
133
- admin: {
134
- condition: (_, current)=>{
135
- return current['field-type'] === 'richText';
136
- }
137
- },
138
136
  defaultValue: `INSTRUCTIONS:
139
137
  You are a highly skilled and professional blog writer,
140
138
  renowned for crafting engaging and well-organized articles.
@@ -146,31 +144,22 @@ informative and accurate but also captivating and beautifully structured.`,
146
144
  label: 'System prompt'
147
145
  },
148
146
  {
149
- // Note: Update when tabs PR is merged: https://github.com/payloadcms/payload/pull/8406
150
- // admin: {
151
- // condition: (_, current) => {
152
- // console.log('condition in tab', current)
153
- // return current['field-type'] === 'richText'
154
- // },
155
- // },
156
- // Note: Update when tabs PR is merged: https://github.com/payloadcms/payload/pull/8406
157
- // admin: {
158
- // condition: (_, current) => {
159
- // console.log('condition in tab', current)
160
- // return current['field-type'] === 'richText'
161
- // },
162
- // },
147
+ admin: {
148
+ condition: (_, current)=>{
149
+ return current['field-type'] === 'richText';
150
+ }
151
+ },
163
152
  description: '',
164
153
  fields: [
165
154
  {
166
- /**TODO's:
155
+ /** TODO:
167
156
  * - Layouts can be saved in as an array
168
- * - user can add their own layout to collections and use it later for generate specific rich text
169
- * - user can select previously added layout
170
- */ /**TODO's:
157
+ * - User can add their own layout to collections and use it later for generate specific rich text
158
+ * - User can select previously added layout
159
+ */ /** TODO:
171
160
  * - Layouts can be saved in as an array
172
- * - user can add their own layout to collections and use it later for generate specific rich text
173
- * - user can select previously added layout
161
+ * - User can add their own layout to collections and use it later for generate specific rich text
162
+ * - User can select previously added layout
174
163
  */ name: 'layout',
175
164
  type: 'textarea',
176
165
  admin: {