Skip to content

Commit

Permalink
fixup refactor from pascal case and add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Sep 27, 2024
1 parent 25309d3 commit f26165d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/commands/syncModel/run/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logError, logInfo, LogOptions } from "../../../log.js";
import { printDiff } from "../../../modules/sync/printDiff.js";
import {
SyncEntities,
SyncEntityChoices,
syncEntityChoices,
SyncEntityName,
syncModelRunInternal,
SyncModelRunParams,
Expand Down Expand Up @@ -60,8 +60,8 @@ export const register: RegisterCommand = yargs =>
.option("entities", {
alias: "e",
type: "array",
choices: SyncEntityChoices,
describe: `Sync specified entties. Allowed entities are: ${SyncEntityChoices.join(", ")}`,
choices: syncEntityChoices,
describe: `Sync specified entties. Allowed entities are: ${syncEntityChoices.join(", ")}`,
demandOption: "You need to provide the what entities to sync.",
conflicts: "exclude",
})
Expand Down
23 changes: 20 additions & 3 deletions src/modules/sync/syncModelRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from "./utils/getContentModel.js";
import { validateDiffedModel, validateSyncModelFolder } from "./validation.js";

export const SyncEntityChoices = [
export const syncEntityChoices = [
"contentTypes",
"contentTypeSnippets",
"taxonomies",
Expand All @@ -36,7 +36,7 @@ export const SyncEntityChoices = [
"workflows",
] as const;

export type SyncEntityName = (typeof SyncEntityChoices)[number];
export type SyncEntityName = (typeof syncEntityChoices)[number];

type ExpectedSyncEntities = Record<SyncEntityName, ((entity: any) => boolean) | boolean>;

Expand Down Expand Up @@ -66,7 +66,24 @@ export type SyncModelRunParams = Readonly<
)
& LogOptions
>;

/**
* Synchronizes content model between two environments. This function can either synchronize
* from a source environment to a target environment or use a pre-defined folder containing the content model
* for synchronization.
*
* Warning!: Synchronizing workflows will make them accessible to all roles in your environment.
*
* @param {SyncModelRunParams} params - The parameters for running the synchronization.
* @param {string} params.targetEnvironmentId - The ID of the target environment where the content model will be synchronized.
* @param {string} params.targetApiKey - The API key for accessing the target environment.
* @param {SyncEntities} params.entities - The entities that need to be synchronized. It includes content types, snippets, taxonomies, etc. If entity is not specified, no items from the given entity will be synced. To sync all item form an entity use () => true.
* @param {string} [params.folderName] - Optional. The name of the folder containing the source content model to be synchronized.
* @param {string} [params.sourceEnvironmentId] - Optional. The ID of the source environment from which the content model will be fetched.
* @param {string} [params.sourceApiKey] - Optional. The API key for accessing the source environment.
* @param {LogOptions} params.logOptions - Optional. Configuration for logging options such as log level, output, etc.
*
* @returns {Promise<void>} A promise that resolves when the synchronization is complete.
*/
export const syncModelRun = async (params: SyncModelRunParams) => syncModelRunInternal(params, "sync-model-run-API");

export const syncModelRunInternal = async (
Expand Down

0 comments on commit f26165d

Please sign in to comment.