@mendix/extensions-api - v0.5.0
    Preparing search index...

    Interface ICustomBlobDocumentApi

    API for registering custom blob document types. For registering corresponding editors, see IEditorApi.registerEditorForCustomDocument.

    interface ICustomBlobDocumentApi {
        _apiId: "mendix.CustomBlobDocumentApi";
        addEventListener<K extends "documentsChanged">(
            eventType: K,
            listener: EventHandler<CustomBlobDocumentApiEventMap, K>,
        ): DisposeListener;
        createDocument<TBlob extends object>(
            creationOptions: CustomBlobDocumentCreationOptions<TBlob>,
        ): Promise<{ documentId: string }>;
        deleteDocument(id: string): Promise<void>;
        getDocumentById<TBlob extends object>(
            id: string,
        ): Promise<DocumentLookupResult<TBlob>>;
        getDocumentsOfType(type: string): Promise<DocumentsOfTypeResult>;
        registerDocumentType<TBlob extends object>(
            registrationOptions: CustomBlobDocumentRegistrationOptions<TBlob>,
            serializationCallback?: (blob: TBlob) => Promise<undefined | string>,
            deserializationCallback?: (data: string) => Promise<undefined | TBlob>,
        ): Promise<void>;
        removeEventListener<K extends "documentsChanged">(
            eventType: K,
            listener: EventHandler<CustomBlobDocumentApiEventMap, K>,
        ): void;
        updateDocumentContent<TBlob extends object>(
            documentId: string,
            content: TBlob,
        ): Promise<void>;
    }

    Hierarchy (View Summary)

    • IComponentApi<CustomBlobDocumentApiEventMap>
      • ICustomBlobDocumentApi
    Index

    Properties

    _apiId: "mendix.CustomBlobDocumentApi"

    Unique identifier that can be used to register or retrieve a specific API.

    Example: mendix.EditorsAPI, mycompany.MyFunkyAPI

    Methods

    • Adds an event listener for the specified event type.

      Type Parameters

      • K extends "documentsChanged"

      Parameters

      • eventType: K

        The type of event to listen for.

      • listener: EventHandler<CustomBlobDocumentApiEventMap, K>

        The event listener to add.

      Returns DisposeListener

      A function that can be called to remove the event listener.

    • Creates a new custom blob document of the given type in the given container. The document type must be registered before creation. If no content is provided, the default content from the registration will be used.

      Type Parameters

      • TBlob extends object

      Parameters

      Returns Promise<{ documentId: string }>

      The ID of the newly created document, or undefined if creation failed.

      Error if the document type is not registered, the provided content cannot be serialized or the document content size exceeds allowed maximum.

    • Deletes the document with the given ID.

      Parameters

      • id: string

        ID of the document to delete

      Returns Promise<void>

    • Loads the custom document with the given ID. Returns appropriate error if the document does not exist or if the deserialization of the document contents fails (see DocumentLookupResult).

      Type Parameters

      • TBlob extends object

      Parameters

      • id: string

        The ID of the document to load.

      Returns Promise<DocumentLookupResult<TBlob>>

    • Registers a new type of custom blob document. This only registers the document type. It does not create new documents and does not register any associated editors.

      Type Parameters

      • TBlob extends object

      Parameters

      • registrationOptions: CustomBlobDocumentRegistrationOptions<TBlob>

        Options required to register a new document type, see CustomBlobDocumentRegistrationOptions

      • OptionalserializationCallback: (blob: TBlob) => Promise<undefined | string>

        Optional function that will be called to convert the document contents to a string. Defaults to JSON.stringify

      • OptionaldeserializationCallback: (data: string) => Promise<undefined | TBlob>

        Optional function that will be called to convert the string back to the document contents. Defaults to JSON.parse

      Returns Promise<void>

      Error if the document type is already registered, registration options cannot be validated or the default contents exceeds maximum size limits.

    • Removes an event listener for the specified event type.

      Type Parameters

      • K extends "documentsChanged"

      Parameters

      • eventType: K

        The type of event to remove the listener from.

      • listener: EventHandler<CustomBlobDocumentApiEventMap, K>

        The event listener to remove.

      Returns void

    • Updates the contents of the document with the given ID.

      Type Parameters

      • TBlob extends object

      Parameters

      • documentId: string

        ID of the document to update

      • content: TBlob

        New content for the document. The content is serialized using the given serializer.

      Returns Promise<void>

      Error if the document type is not registered, the content cannot be serialized, the document with ID does not exist or the updated content size exceeds allowed maximum.