UNPKG

@kontent-ai/sync-sdk

Version:
37 lines 1.19 kB
import { getInitQuery } from "../queries/init-query.js"; import { getSyncQuery } from "../queries/sync-query.js"; /** * Creates a new sync client instance using fluent API. * * You may choose to use public, preview or secure API. * * Options can be set within the 'create' function. * * @param environmentId - The Id of the Kontent.ai environment. */ export function getSyncClient(environmentId) { return { publicApi: () => { return withClient({ apiMode: "public", environmentId }); }, previewApi: (deliveryApiKey) => { return withClient({ apiMode: "preview", environmentId, deliveryApiKey }); }, secureApi: (deliveryApiKey) => { return withClient({ apiMode: "secure", environmentId, deliveryApiKey }); }, }; } function withClient(requiredConfig) { return { create: (options) => createSyncClient({ ...requiredConfig, ...options }), }; } function createSyncClient(config) { return { config, init: () => getInitQuery(config), sync: (continuationToken) => getSyncQuery(config, continuationToken), }; } //# sourceMappingURL=sync-client.js.map