11import type {
22 Cascade ,
33 FileInput ,
4+ Input ,
5+ InputType ,
46 RichTextInput ,
57 SnippetConfig ,
8+ Structure ,
9+ StructureValue ,
610 UrlInput ,
711} from '@cloudcannon/configuration-types' ;
812
@@ -210,7 +214,7 @@ export interface EditOptions {
210214 /** Optional style information */
211215 style ?: string | null ;
212216 /** The mouse event that triggered the edit */
213- e : MouseEvent ;
217+ e ? : MouseEvent ;
214218}
215219
216220/**
@@ -235,7 +239,7 @@ export interface AddArrayItemOptions extends ArrayOptions {
235239 /** The value to insert */
236240 value : any ;
237241 /** The mouse event that triggered the addition */
238- e : MouseEvent ;
242+ e ? : MouseEvent ;
239243}
240244
241245/**
@@ -256,6 +260,10 @@ export interface RemoveArrayItemOptions extends ArrayOptions {
256260 index : number ;
257261}
258262
263+ export interface GetInputConfigOptions {
264+ slug : string ;
265+ }
266+
259267/**
260268 * Options for getting the current value in the v2 API
261269 */
@@ -495,15 +503,17 @@ export interface CloudCannonJavaScriptV1APIFile {
495503 releaseLock ( ) : Promise < { readOnly : boolean } > ;
496504
497505 addEventListener (
498- event : 'change' | 'delete' | 'create' ,
506+ event : 'change' | 'delete' ,
499507 listener : EventListenerOrEventListenerObject | null ,
500508 options ?: EventListenerOptions | boolean
501509 ) : void ;
502510 removeEventListener (
503- event : 'change' | 'delete' | 'create' ,
511+ event : 'change' | 'delete' ,
504512 listener : EventListenerOrEventListenerObject | null ,
505513 options ?: EventListenerOptions | boolean
506514 ) : void ;
515+
516+ getInputConfig ( options : GetInputConfigOptions ) : Promise < Input | undefined > ;
507517}
508518
509519export interface CloudCannonJavaScriptV1APICollection {
@@ -528,17 +538,45 @@ export interface CloudCannonJavaScriptV1APICollection {
528538 // add(options: any): Promise<CloudCannonJavaScriptV1APIFile>;
529539
530540 addEventListener (
531- event : 'change' | 'delete' | 'create' ,
541+ event : 'change' | 'delete' ,
532542 listener : EventListenerOrEventListenerObject | null ,
533543 options ?: EventListenerOptions | boolean
534544 ) : void ;
535545 removeEventListener (
536- event : 'change' | 'delete' | 'create' ,
546+ event : 'change' | 'delete' ,
537547 listener : EventListenerOrEventListenerObject | null ,
538548 options ?: EventListenerOptions | boolean
539549 ) : void ;
540550}
541551
552+ export interface CloudCannonJavaScriptV1APIDataset {
553+ /**
554+ * The key of the dataset
555+ */
556+ datasetKey : string ;
557+
558+ /**
559+ * Gets the items in a dataset
560+ * @returns Promise that resolves with the items in the collection
561+ */
562+ items ( ) : Promise < CloudCannonJavaScriptV1APIFile [ ] | CloudCannonJavaScriptV1APIFile > ;
563+
564+ addEventListener (
565+ event : 'change' | 'delete' ,
566+ listener : EventListenerOrEventListenerObject | null ,
567+ options ?: EventListenerOptions | boolean
568+ ) : void ;
569+ removeEventListener (
570+ event : 'change' | 'delete' ,
571+ listener : EventListenerOrEventListenerObject | null ,
572+ options ?: EventListenerOptions | boolean
573+ ) : void ;
574+ }
575+
576+ export interface CloudCannonJavaScriptV1APITextEditableRegion {
577+ setContent : ( content ?: string | null ) => void ;
578+ }
579+
542580export interface CloudCannonJavaScriptV1API {
543581 /**
544582 * Gets prefetched files
@@ -573,27 +611,44 @@ export interface CloudCannonJavaScriptV1API {
573611 * @param inputConfig - Optional configuration for the input
574612 * @returns Promise that resolves with the path of the uploaded file
575613 */
576- upload (
614+ uploadFile (
577615 file : File ,
578616 inputConfig : RichTextInput | UrlInput | FileInput | undefined
579617 ) : Promise < string | undefined > ;
580618
581619 currentFile ( ) : CloudCannonJavaScriptV1APIFile ;
582620 file ( path : string ) : CloudCannonJavaScriptV1APIFile ;
583621 collection ( key : string ) : CloudCannonJavaScriptV1APICollection ;
622+ dataset ( key : string ) : CloudCannonJavaScriptV1APIDataset ;
584623 files ( ) : Promise < CloudCannonJavaScriptV1APIFile [ ] > ;
585624 collections ( ) : Promise < CloudCannonJavaScriptV1APICollection [ ] > ;
586625
587626 addEventListener (
588- event : 'change' | 'delete' | 'create' ,
627+ event : 'change' | 'delete' ,
589628 listener : EventListenerOrEventListenerObject | null ,
590629 options ?: EventListenerOptions | boolean
591630 ) : void ;
592631 removeEventListener (
593- event : 'change' | 'delete' | 'create' ,
632+ event : 'change' | 'delete' ,
594633 listener : EventListenerOrEventListenerObject | null ,
595634 options ?: EventListenerOptions | boolean
596635 ) : void ;
636+
637+ isAPIFile ( obj : unknown ) : obj is CloudCannonJavaScriptV1APIFile ;
638+ isAPICollection ( obj : unknown ) : obj is CloudCannonJavaScriptV1APICollection ;
639+ isAPIDataset ( obj : unknown ) : obj is CloudCannonJavaScriptV1APIDataset ;
640+ findStructure ( structure : Structure , value : any ) : StructureValue | undefined ;
641+ getInputType ( key : string | undefined , value ?: unknown , inputConfig ?: Input ) : InputType ;
642+
643+ createTextEditableRegion (
644+ element : HTMLElement ,
645+ onChange : ( content ?: string | null ) => void ,
646+ options ?: {
647+ elementType ?: string ;
648+ editableType ?: string ;
649+ inputConfig ?: RichTextInput ;
650+ }
651+ ) : Promise < CloudCannonJavaScriptV1APITextEditableRegion > ;
597652}
598653
599654export type CloudCannonJavaScriptAPIVersions = 'v0' | 'v1' ;
0 commit comments