Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MockRepository

Hierarchy

Index

Constructors

constructor

Properties

Authentication

Authentication: MockAuthService

Reference to the Authentication Service used by the current repository

Config

Reference to the configuration used by the current repository

Events

Events: RepositoryEventHub = new RepositoryEventHub()

HttpProviderRef

HttpProviderRef: MockHttpProvider

Reference to the Http Provider used by the current repository

Accessors

Content

ODataBaseUrl

  • get ODataBaseUrl(): string

Methods

Ajax

  • Ajax<T>(path: string, method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE", returnsType?: undefined | object, body?: any, additionalHeaders?: object[]): Observable<T>
  • Public endpoint for making Ajax calls to the Repository

    Type parameters

    • T

    Parameters

    • path: string

      The Path for the call

    • method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"

      The method type

    • Optional returnsType: undefined | object

      The expected return type

    • Optional body: any

      The post body (optional)

    • Optional additionalHeaders: object[]

    Returns Observable<T>

    An observable, which will be updated with the response.

CopyBatch

  • Executes a CopyBatch request to copy multiple content by a single request.

    Usage: ```ts repository.CopyBatch([content1, content2...], 'Root/NewFolder').subscribe(()=>{ console.log('Contents copied.') })

    Parameters

    • contentList: any[]

      An array of content to copy. Can be a content (with path) or a Path

    • targetPath: string

      The target Path

    • Default value rootContent: Content = this._staticContent.PortalRoot

      The context node, the PortalRoot by default

    Returns Observable<ODataBatchResponse<ISavedContent>>

CreateContent

  • CreateContent<TContentType>(options: TContentType, contentType: object): ContentInternal<TContentType> & TContentType
  • Shortcut to Content.Create. Creates a new, unsaved Content instance

    Type parameters

    • TContentType

    Parameters

    • options: TContentType

      An object with the initial content data

    • contentType: object
      • constructor: function
        • new __type(...args: any[]): TContentType
        • Parameters

          • Rest ...args: any[]

          Returns TContentType

    Returns ContentInternal<TContentType> & TContentType

    the created, unsaved content instance

CreateQuery

  • Creates a Content Query on a Repositoy instance, at Root level (path e.g.: '/OData.svc/Root' ) Usage: ```ts const query = repository.CreateQuery(q => q.TypeIs(ContentTypes.Folder) .Top(10))

    query.Exec().subscribe(res => { console.log('Folders count: ', res.Count); console.log('Folders: ', res.Result); } ```

    Type parameters

    Parameters

    Returns FinializedQuery<T>

    An observable with the Query result.

DeleteBatch

  • Executes a DeleteBatch request to delete multiple content by a single request.

    Usage:

    repository.DeleteBatch([content1, content2...], true).subscribe(()=>{
     console.log('Contents deleted.')
    })
    

    Parameters

    • contentList: any[]

      An array of content to be deleted. Can be a content (with id and/or path), a Path or an Id

    • Default value permanent: boolean = false
    • Default value rootContent: ContentInternal<PortalRoot> & PortalRoot & ISavedContent = this._staticContent.PortalRoot

      The context node, the PortalRoot by default

    Returns Observable<ODataBatchResponse<ISavedContent>>

GetAllContentTypes

  • Returns the list of all ContentTypes in the system.

    Returns Observable<ContentType[]>

    Returns an RxJS observable that you can subscribe of in your code.

    let getAllContentTypes = GetAllContentTypes();
    getAllContentTypes.subscribe({
     next: response => {
         console.log('success');
     },
     error: error => console.error('something wrong occurred: ' + error.responseJSON.error.message.value),
     complete: () => console.log('done'),
    });
    

GetCurrentUser

GetODataApi

GetSchema

  • GetSchema<TType>(currentType: object): Schema
  • Returns the Content Type Schema of the given Content Type;

    Type parameters

    Parameters

    • currentType: object
      • constructor: function
        • new __type(...args: any[]): TType
        • Parameters

          • Rest ...args: any[]

          Returns TType

    Returns Schema

    var genericContentSchema = SenseNet.Content.getSchema(Content);
    

GetSchemaByName

  • GetSchemaByName(schemaName: string): Schema

GetVersionInfo

  • Gets the complete version information about the core product and the installed applications. This function is accessible only for administrators by default. You can learn more about the subject in the SnAdmin article. You can read detailed description of the function result.

    Returns Observable<VersionInfo>

    Returns an RxJS observable that you can subscribe of in your code.

    let getVersionInfo = GetVersionInfo();
    getVersionInfo.subscribe({
     next: response => {
         console.log('success');
     },
     error: error => console.error('something wrong occurred: ' + error.responseJSON.error.message.value),
     complete: () => console.log('done'),
    });
    

HandleLoadedContent

  • Creates a Content instance that is loaded from the Repository. This method should be used only to instantiate content from payload received from the backend.

    Type parameters

    Parameters

    • contentData: T & ISavedContent

      An object with the Content data

    • Optional contentType: undefined | object

      The Content type.

    Returns SavedContent<T>

    var content = SenseNet.Content.HandleLoadedContent({ Id: 123456, Path: 'Root/Example', DisplayName: 'My folder' }, ContentTypes.Folder); // content is an instance of the Folder with the DisplayName 'My folder'
    

Load

  • Load<TContentType>(idOrPath: string | number, odataOptions?: IODataParams<TContentType>, version?: undefined | string): Observable<SavedContent<TContentType>>
  • Requests a Content by the given id.

    Type parameters

    Parameters

    • idOrPath: string | number

      Id of the requested Content.

    • Optional odataOptions: IODataParams<TContentType>
    • Optional version: undefined | string

      A string containing the version of the requested Content.

    Returns Observable<SavedContent<TContentType>>

    Returns an RxJS observable that you can subscribe of in your code.

    var content = SenseNet.Content.Load(1234, { expand: 'Avatar' }, 'A.1', ContentTypes.User);
    content
        .map(response => response.d)
        .subscribe({
           next: response => {
               //do something with the response
           },
           error: error => console.error('something wrong occurred: ' + error.responseJSON.error.message.value),
           complete: () => console.log('done'),
    })
    

MoveBatch

  • Executes a MoveBatch request to move multiple content by a single request.

    Usage: ```ts repository.MoveBatch([content1, content2...], 'Root/NewFolder').subscribe(()=>{ console.log('Contents moved.') })

    Parameters

    • contentList: any[]

      An array of content to move. Can be a content (with path) or a Path

    • targetPath: string

      The target Path

    • Default value rootContent: Content = this._staticContent.PortalRoot

      The context node, the PortalRoot by default

    Returns Observable<ODataBatchResponse<ISavedContent>>

ParseContent

  • ParseContent<T>(stringifiedContent: string): T
  • Parses a Content instance from a stringified SerializedContent instance

    throws

    Error if the Content belongs to another Repository (based it's Origin)

    Type parameters

    Parameters

    • stringifiedContent: string

      The stringified SerializedContent

    Returns T

    The loaded Content

SetSchemas

  • SetSchemas(newSchemas: Schema[]): void

UploadFile

UploadFromDropEvent

UploadTextAsFile

WaitForAuthStateReady

Generated using TypeDoc