From 3a47e487d205c757b140641c7975da4e91ad9bb0 Mon Sep 17 00:00:00 2001 From: Steeve Pastorelli Date: Thu, 4 Jan 2024 15:10:20 +0100 Subject: [PATCH] Review: rename eventCreatedAt to eventTimestamp --- integrations/github/src/index.ts | 2 +- integrations/github/src/sync.ts | 16 ++++++++-------- integrations/github/src/webhooks.ts | 4 ++-- integrations/gitlab/src/index.ts | 2 +- integrations/gitlab/src/sync.ts | 16 ++++++++-------- integrations/gitlab/src/webhooks.ts | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/integrations/github/src/index.ts b/integrations/github/src/index.ts index b3d84934a..475cdfd3f 100644 --- a/integrations/github/src/index.ts +++ b/integrations/github/src/index.ts @@ -354,7 +354,7 @@ const handleSpaceContentUpdated: EventCallback< } await triggerExport(context, spaceInstallation, { - eventCreatedAt: new Date(revision.createdAt), + eventTimestamp: new Date(revision.createdAt), }); }; diff --git a/integrations/github/src/sync.ts b/integrations/github/src/sync.ts index 703bab2d4..6c65245c6 100644 --- a/integrations/github/src/sync.ts +++ b/integrations/github/src/sync.ts @@ -45,16 +45,16 @@ export async function triggerImport( updateGitInfo?: boolean; /** - * The date/time of the event that triggers the import. + * The timestamp of the event that triggers the import. * * This is to help ensures that Git sync import and export operations are executed * in the same order on GitBook and on the remote repository. */ - eventCreatedAt?: Date; + eventTimestamp?: Date; } = {} ) { const { api } = context; - const { force = false, updateGitInfo = false, standalone, eventCreatedAt } = options; + const { force = false, updateGitInfo = false, standalone, eventTimestamp } = options; const config = getSpaceConfigOrThrow(spaceInstallation); assertIsDefined(config.branch, { label: 'config.branch' }); @@ -76,7 +76,7 @@ export async function triggerImport( repoProjectDirectory: config.projectDirectory, repoCacheID: config.key, force, - timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined, + timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined, standalone: !!standalone, ...(updateGitInfo ? { gitInfo: { provider: 'github', url: repoURL } } : {}), }); @@ -96,16 +96,16 @@ export async function triggerExport( updateGitInfo?: boolean; /** - * The date/time of the event that triggers the export. + * The timestamp of the event that triggers the export. * * This is to help ensures that Git sync import and export operations are executed * in the same order on GitBook and on the remote repository. */ - eventCreatedAt?: Date; + eventTimestamp?: Date; } = {} ) { const { api } = context; - const { force = false, updateGitInfo = false, eventCreatedAt } = options; + const { force = false, updateGitInfo = false, eventTimestamp } = options; const config = getSpaceConfigOrThrow(spaceInstallation); assertIsDefined(config.branch, { label: 'config.branch' }); @@ -129,7 +129,7 @@ export async function triggerExport( repoProjectDirectory: config.projectDirectory, repoCacheID: config.key, force, - timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined, + timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined, commitMessage: getCommitMessageForRevision(config, revision), ...(updateGitInfo ? { gitInfo: { provider: 'github', url: repoURL } } : {}), }); diff --git a/integrations/github/src/webhooks.ts b/integrations/github/src/webhooks.ts index c117d084b..7693d5839 100644 --- a/integrations/github/src/webhooks.ts +++ b/integrations/github/src/webhooks.ts @@ -85,7 +85,7 @@ export async function handlePushEvent( }); await triggerImport(context, spaceInstallation, { - eventCreatedAt: payload.head_commit?.timestamp + eventTimestamp: payload.head_commit?.timestamp ? new Date(payload.head_commit?.timestamp) : undefined, }); @@ -151,7 +151,7 @@ export async function handlePullRequestEvents( standalone: { ref: headRef, }, - eventCreatedAt: + eventTimestamp: payload.action === 'opened' ? new Date(payload.pull_request.created_at) : new Date(payload.pull_request.updated_at), diff --git a/integrations/gitlab/src/index.ts b/integrations/gitlab/src/index.ts index e2952a175..d601b301e 100644 --- a/integrations/gitlab/src/index.ts +++ b/integrations/gitlab/src/index.ts @@ -265,7 +265,7 @@ const handleSpaceContentUpdated: EventCallback< } await triggerExport(context, spaceInstallation, { - eventCreatedAt: new Date(revision.createdAt), + eventTimestamp: new Date(revision.createdAt), }); }; diff --git a/integrations/gitlab/src/sync.ts b/integrations/gitlab/src/sync.ts index 21282822a..aafb88bf9 100644 --- a/integrations/gitlab/src/sync.ts +++ b/integrations/gitlab/src/sync.ts @@ -45,16 +45,16 @@ export async function triggerImport( updateGitInfo?: boolean; /** - * The date/time of the event that triggers the import. + * The timestamp of the event that triggers the import. * * This is to help ensures that Git sync import and export operations are executed * in the same order on GitBook and on the remote repository. */ - eventCreatedAt?: Date; + eventTimestamp?: Date; } = {} ) { const { api } = context; - const { force = false, updateGitInfo = false, standalone, eventCreatedAt } = options; + const { force = false, updateGitInfo = false, standalone, eventTimestamp } = options; const config = getSpaceConfigOrThrow(spaceInstallation); assertIsDefined(config.branch, { label: 'config.branch' }); @@ -76,7 +76,7 @@ export async function triggerImport( repoProjectDirectory: config.projectDirectory, repoCacheID: config.key, force, - timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined, + timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined, standalone: !!standalone, ...(updateGitInfo ? { gitInfo: { provider: 'gitlab', url: repoURL } } : {}), }); @@ -96,16 +96,16 @@ export async function triggerExport( updateGitInfo?: boolean; /** - * The date/time of the event that triggers the export. + * The timestamp of the event that triggers the export. * * This is to help ensures that Git sync import and export operations are executed * in the same order on GitBook and on the remote repository. */ - eventCreatedAt?: Date; + eventTimestamp?: Date; } = {} ) { const { api } = context; - const { force = false, updateGitInfo = false, eventCreatedAt } = options; + const { force = false, updateGitInfo = false, eventTimestamp } = options; const config = getSpaceConfigOrThrow(spaceInstallation); assertIsDefined(config.branch, { label: 'config.branch' }); @@ -129,7 +129,7 @@ export async function triggerExport( repoProjectDirectory: config.projectDirectory, repoCacheID: config.key, force, - timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined, + timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined, commitMessage: getCommitMessageForRevision(config, revision), ...(updateGitInfo ? { gitInfo: { provider: 'gitlab', url: repoURL } } : {}), }); diff --git a/integrations/gitlab/src/webhooks.ts b/integrations/gitlab/src/webhooks.ts index a439caf9c..a267416ba 100644 --- a/integrations/gitlab/src/webhooks.ts +++ b/integrations/gitlab/src/webhooks.ts @@ -133,7 +133,7 @@ export async function handlePushEvent(context: GitLabRuntimeContext, payload: Gi }); await triggerImport(context, spaceInstallation, { - eventCreatedAt: headCommit ? new Date(headCommit.timestamp) : undefined, + eventTimestamp: headCommit ? new Date(headCommit.timestamp) : undefined, }); } catch (error) { logger.error( @@ -194,7 +194,7 @@ export async function handleMergeRequestEvent( standalone: { ref: sourceRef, }, - eventCreatedAt: + eventTimestamp: payload.object_attributes.action === 'open' ? new Date(payload.object_attributes.created_at) : new Date(payload.object_attributes.updated_at),