-
Notifications
You must be signed in to change notification settings - Fork 2
Adds server to server support for XMC module #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1a719e2
adds experimental type
c041625
updates schemawith security
656c636
adds support for all apis
5cc9105
adds tests
977a078
adds changesets
e379e6a
removes unused codes
82c06f8
Adds TURBO SCM base
45f0d30
Test PKG old verison
d660bd6
hide getaccess token
31a0c2d
adds documentation
e0b063e
fixes env dependency on window
bfc2f69
exports xmc experimental as client
6f25e61
updates experimental docs
09fb19e
updates experimental xmc demo with nextjs example
682a3a9
Fixes experimental_xmc doc
a4083f4
fixes experimental xmc doc env names
a5ebea9
updated documentation with https requirement
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
--- | ||
'@sitecore-marketplace-sdk/xmc': patch | ||
--- | ||
|
||
# Experimental XMC - Server-to-Server API Access | ||
|
||
## 🚀 What's New | ||
|
||
### Server-to-Server Support | ||
|
||
EXPERIMENTAL_XMC enables API access to Sitecore APIs without requiring the Host SDK or Client SDK mode. Perfect for server-side applications that need to communicate with Sitecore APIs. | ||
|
||
### Setup | ||
|
||
```typescript | ||
import { EXPERIMENTAL_XMC } from '@sitecore-marketplace-sdk/xmc'; | ||
|
||
// No Host SDK required | ||
const xmc = new EXPERIMENTAL_XMC({ | ||
getAccessToken: () => auth0.getAccessTokenSilently(), | ||
}); | ||
``` | ||
|
||
### Enhanced Type Safety | ||
|
||
```typescript | ||
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 - Server-to-Server | ||
|
||
### 1. Install and Import | ||
|
||
```typescript | ||
import { EXPERIMENTAL_XMC } from '@sitecore-marketplace-sdk/xmc'; | ||
// Optional: import types for enhanced IntelliSense | ||
import { EXPERIMENTAL_Sites } from '@sitecore-marketplace-sdk/xmc'; | ||
``` | ||
|
||
### 2. Initialize with Auth | ||
|
||
```typescript | ||
const xmc = new EXPERIMENTAL_XMC({ | ||
getAccessToken: () => auth0.getAccessTokenSilently(), | ||
}); | ||
``` | ||
|
||
### 3. Use APIs | ||
|
||
```typescript | ||
// 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 | ||
|
||
```typescript | ||
// Node.js server, Azure Functions, AWS Lambda, etc. | ||
const xmc = new EXPERIMENTAL_XMC({ | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { createClient } from '@hey-api/openapi-ts'; | ||
import { defineAugmentationConfig } from './plugins/augmentation'; | ||
import { defineClientTransformerConfig } from './plugins/client-transformer/config'; | ||
|
||
import { defineSchemaPatcherConfig } from './plugins/schema-patcher'; | ||
import { defineNamespaceTransformerConfig } from './plugins/namespace-transformer'; | ||
|
||
createClient({ | ||
input: 'https://api-docs.sitecore.com/_spec/xmc/sites-api/index.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/experimental/client-sites', | ||
}, | ||
plugins: [ | ||
defineSchemaPatcherConfig(), | ||
'@hey-api/client-fetch', | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
defineNamespaceTransformerConfig({ | ||
namespace: 'EXPERIMENTAL_Sites', | ||
}), | ||
], | ||
}); | ||
|
||
createClient({ | ||
input: 'https://api-docs.sitecore.com/_spec/xmc/pages-api/index.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/experimental/client-pages', | ||
}, | ||
plugins: [ | ||
defineSchemaPatcherConfig(), | ||
'@hey-api/client-fetch', | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
defineNamespaceTransformerConfig({ | ||
namespace: 'EXPERIMENTAL_Pages', | ||
}), | ||
], | ||
}); | ||
|
||
createClient({ | ||
input: './schema/experimental/authoring.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/experimental/client-authoring', | ||
}, | ||
plugins: [ | ||
defineSchemaPatcherConfig(), | ||
'@hey-api/client-fetch', | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
defineNamespaceTransformerConfig({ | ||
namespace: 'EXPERIMENTAL_Authoring', | ||
}), | ||
], | ||
}); | ||
|
||
createClient({ | ||
input: './schema/experimental/content-transfer.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/experimental/client-content-transfer', | ||
}, | ||
plugins: [ | ||
defineSchemaPatcherConfig(), | ||
'@hey-api/client-fetch', | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
defineNamespaceTransformerConfig({ | ||
namespace: 'EXPERIMENTAL_ContentTransfer', | ||
}), | ||
], | ||
}); | ||
|
||
createClient({ | ||
input: './schema/experimental/content.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/experimental/client-content', | ||
}, | ||
plugins: [ | ||
defineSchemaPatcherConfig(), | ||
'@hey-api/client-fetch', | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
defineNamespaceTransformerConfig({ | ||
namespace: 'EXPERIMENTAL_Content', | ||
}), | ||
], | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Plugin } from '@hey-api/openapi-ts'; | ||
|
||
import { handler } from './plugin'; | ||
import type { Config } from './types'; | ||
|
||
export const defaultNamespaceTransformerConfig: Plugin.Config<Config> = { | ||
_dependencies: ['@hey-api/client-fetch', '@hey-api/typescript'], | ||
_handler: handler, | ||
_handlerLegacy: () => {}, | ||
name: '@sitecore-marketplace/namespace-transformer', | ||
output: 'client', | ||
namespace: '', | ||
}; | ||
|
||
/** | ||
* Type helper for `my-plugin` plugin, returns {@link Plugin.Config} object | ||
*/ | ||
export const defineNamespaceTransformerConfig: Plugin.DefineConfig<Config> = (config) => ({ | ||
...defaultNamespaceTransformerConfig, | ||
...config, | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { defaultNamespaceTransformerConfig, defineNamespaceTransformerConfig } from './config'; | ||
export type { Config } from './types'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.