github Sitecore/marketplace-sdk @sitecore-marketplace-sdk/xmc@0.2.1

one day ago

Patch Changes

  • fec9f87: # experimental_XMC

    🚀 What's New

    Server-side API Support

    experimental_XMC enables API access to Sitecore APIs without requiring the Client SDK mode. Perfect for server-side applications that need to communicate with Sitecore APIs.

    Setup

    import { experimental_createXMCClient } from '@sitecore-marketplace-sdk/xmc';
    
    // No Host SDK required
    const xmc = await experimental_createXMCClient({
      getAccessToken: () => auth0.getAccessTokenSilently(),
    });

    Enhanced Type Safety

    import { experimental_Sites } from '@sitecore-marketplace-sdk/xmc';
    
    // Optional: Full IntelliSense support with types
    const response = await xmc.sites.listLanguages();
    let data: experimental_Sites.ListLanguagesResponse = response.data!;

    🎯 Quick Start

    1. Install and Import

    import { experimental_createXMCClient } from '@sitecore-marketplace-sdk/xmc';
    // Optional: import types for enhanced IntelliSense
    import { experimental_Sites } from '@sitecore-marketplace-sdk/xmc';

    2. Initialize with Auth

    const xmc = await experimental_createXMCClient({
      getAccessToken: () => auth0.getAccessTokenSilently(),
    });

    3. Use APIs

    // Sites API
    const languages = await xmc.sites.listLanguages({
      query: { sitecoreContextId: 'your-context-id' },
    });
    
    // Pages API
    const pages = await xmc.pages.search({
      query: { sitecoreContextId: 'your-context-id' },
    });
    
    // Authoring API
    const result = await xmc.authoring.graphql({
      body: {
        query: `query {
          sites {
            name
          }
        }`,
      },
      query: { sitecoreContextId: 'your-context-id' },
    });
    
    // Content Transfer API
    const transfer = await xmc.contentTransfer.createContentTransfer({
      body: {
        configuration: {
          dataTrees: [
            {
              itemPath: '/sitecore/content/Home',
              scope: 'SingleItem',
              mergeStrategy: 'OverrideExistingItem',
            },
          ],
        },
        transferId: crypto.randomUUID(),
      },
      query: { sitecoreContextId: 'your-context-id' },
    });
    
    // Preview API
    const previewContent = await xmc.preview.graphql({
      body: {
        query: `query {
          item(path: "/sitecore/content/Home", language: "en") {
            id
            name
            path
            fields {
              name
              value
            }
          }
        }`,
      },
      query: { sitecoreContextId: 'your-context-id' },
    });
    
    // Live API
    const liveContent = await xmc.live.graphql({
      body: {
        query: `query {
          item(path: "/sitecore/content/Home", language: "en") {
            id
            name
            path
            fields {
              name
              value
            }
          }
        }`,
      },
      query: { sitecoreContextId: 'your-context-id' },
    });

    🔧 Use Cases

    Server-Side Applications

    // Node.js server, Azure Functions, AWS Lambda, etc.
    const xmc = await experimental_createXMCClient({
      getAccessToken: () => getServerSideToken(),
    });
    
    // Direct API calls without browser context
    const languages = await xmc.sites.listLanguages();

    🎨 Optional Type Support

    For enhanced IntelliSense, you can optionally import type namespaces:

    • experimental_Sites.* - Sites API types
    • experimental_Pages.* - Pages API types
    • experimental_Authoring.* - Authoring API types
    • experimental_ContentTransfer.* - Content Transfer API types
    • experimental_Content.* - Content API types

Don't miss a new marketplace-sdk release

NewReleases is sending notifications on new releases.