diff --git a/packages/manager/src/index.ts b/packages/manager/src/index.ts index d5df44543a..dcdba4d486 100644 --- a/packages/manager/src/index.ts +++ b/packages/manager/src/index.ts @@ -13,7 +13,10 @@ export { createSliceMachineManager } from "./managers/createSliceMachineManager" export { createSliceMachineManagerMiddleware } from "./managers/createSliceMachineManagerMiddleware"; export type { CreateSliceMachineManagerMiddlewareArgs } from "./managers/createSliceMachineManagerMiddleware"; -export type { Environment, Limit } from "./managers/prismicRepository/types"; +export type { + Environment, + PushChangesLimit, +} from "./managers/prismicRepository/types"; export type { PrismicAuthManager, diff --git a/packages/manager/src/managers/prismicRepository/PrismicRepositoryManager.ts b/packages/manager/src/managers/prismicRepository/PrismicRepositoryManager.ts index 3815160517..badf117b1a 100644 --- a/packages/manager/src/managers/prismicRepository/PrismicRepositoryManager.ts +++ b/packages/manager/src/managers/prismicRepository/PrismicRepositoryManager.ts @@ -23,13 +23,13 @@ import { BulkBody, ChangeTypes, ClientError, - Limit, - LimitType, + PushChangesLimit, + PushChangesLimitType, PrismicRepository, PrismicRepositoryRole, PrismicRepositoryUserAgent, PrismicRepositoryUserAgents, - RawLimit, + PushChangesRawLimit, TransactionalMergeArgs, TransactionalMergeReturnType, FrameworkWroomTelemetryID, @@ -421,7 +421,7 @@ export class PrismicRepositoryManager extends BaseManager { return this._decodeLimitOrThrow( await response.json(), response.status, - LimitType.SOFT, + PushChangesLimitType.SOFT, ); case 204: return null; @@ -431,7 +431,7 @@ export class PrismicRepositoryManager extends BaseManager { return this._decodeLimitOrThrow( await response.json(), response.status, - LimitType.HARD, + PushChangesLimitType.HARD, ); case 400: const text = await response.text(); @@ -509,9 +509,9 @@ export class PrismicRepositoryManager extends BaseManager { private _decodeLimitOrThrow( potentialLimit: unknown, statusCode: number, - limitType: LimitType, - ): Limit | null { - return fold( + limitType: PushChangesLimitType, + ): PushChangesLimit | null { + return fold( () => { const error: ClientError = { status: statusCode, @@ -521,12 +521,12 @@ export class PrismicRepositoryManager extends BaseManager { }; throw error; }, - (rawLimit: RawLimit) => { + (rawLimit: PushChangesRawLimit) => { const limit = { ...rawLimit, type: limitType }; return limit; }, - )(RawLimit.decode(potentialLimit)); + )(PushChangesRawLimit.decode(potentialLimit)); } private async _fetch(args: { diff --git a/packages/manager/src/managers/prismicRepository/types.ts b/packages/manager/src/managers/prismicRepository/types.ts index c0c59fc752..5ffca8c79c 100644 --- a/packages/manager/src/managers/prismicRepository/types.ts +++ b/packages/manager/src/managers/prismicRepository/types.ts @@ -85,7 +85,7 @@ export interface BulkBody extends Record { changes: AllChangeTypes[]; } -export const RawLimit = t.type({ +export const PushChangesRawLimit = t.type({ details: t.type({ customTypes: t.array( t.type({ @@ -96,13 +96,13 @@ export const RawLimit = t.type({ ), }), }); -export type RawLimit = t.TypeOf; -export enum LimitType { +export type PushChangesRawLimit = t.TypeOf; +export enum PushChangesLimitType { SOFT = "SOFT", HARD = "HARD", } -export type Limit = RawLimit & { - type: LimitType; +export type PushChangesLimit = PushChangesRawLimit & { + type: PushChangesLimitType; }; export interface ClientError { @@ -130,7 +130,7 @@ export type TransactionalMergeArgs = { changes: (CustomTypeChange | SliceChange)[]; }; -export type TransactionalMergeReturnType = Limit | null; +export type TransactionalMergeReturnType = PushChangesLimit | null; /** * Framework id sent to Segment from wroom. Property used for the "framework" diff --git a/packages/manager/src/managers/telemetry/types.ts b/packages/manager/src/managers/telemetry/types.ts index 144f95ec77..1d3c4a31af 100644 --- a/packages/manager/src/managers/telemetry/types.ts +++ b/packages/manager/src/managers/telemetry/types.ts @@ -1,5 +1,5 @@ import { CustomTypeFormat } from "../customTypes/types"; -import type { LimitType } from "../prismicRepository/types"; +import type { PushChangesLimitType } from "../prismicRepository/types"; export const SegmentEventType = { command_init_start: "command:init:start", @@ -248,7 +248,7 @@ type ChangesPushedSegmentEvent = SegmentEvent< type ChangesLimitReachSegmentEvent = SegmentEvent< typeof SegmentEventType.changes_limitReach, - { limitType: LimitType } + { limitType: PushChangesLimitType } >; type EditorWidgetUsedSegmentEvent = SegmentEvent< diff --git a/packages/slice-machine/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx b/packages/slice-machine/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx index 71a7bfc26a..e6e344331a 100644 --- a/packages/slice-machine/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +++ b/packages/slice-machine/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx @@ -9,11 +9,11 @@ import { isRemoteOnly } from "@lib/models/common/ModelData"; import { getModelId } from "@lib/models/common/ModelData"; import { AssociatedDocumentsCard } from "./AssociatedDocumentsCard"; import { SliceMachineDrawerUI } from "@components/SliceMachineDrawer"; -import { Limit } from "@slicemachine/manager"; +import { PushChangesLimit } from "@slicemachine/manager"; export const HardDeleteDocumentsDrawer: React.FunctionComponent<{ pushChanges: (confirmDeleteDocuments: boolean) => void; - modalData?: Limit; + modalData?: PushChangesLimit; onClose: () => void; }> = ({ pushChanges, modalData, onClose }) => { const { remoteOnlyCustomTypes } = useSelector( diff --git a/packages/slice-machine/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx b/packages/slice-machine/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx index 14b47582fd..ab914c4caf 100644 --- a/packages/slice-machine/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +++ b/packages/slice-machine/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx @@ -8,7 +8,7 @@ import { selectAllCustomTypes } from "@src/modules/availableCustomTypes"; import { getModelId } from "@lib/models/common/ModelData"; import { AssociatedDocumentsCard } from "./AssociatedDocumentsCard"; import { SliceMachineDrawerUI } from "@components/SliceMachineDrawer"; -import { Limit } from "@slicemachine/manager"; +import { PushChangesLimit } from "@slicemachine/manager"; const ConfirmationDialogue: React.FC<{ isConfirmed: boolean; @@ -40,7 +40,7 @@ const ConfirmationDialogue: React.FC<{ export const SoftDeleteDocumentsDrawer: React.FunctionComponent<{ pushChanges: (confirmDeleteDocuments: boolean) => void; - modalData?: Limit; + modalData?: PushChangesLimit; onClose: () => void; }> = ({ pushChanges, modalData, onClose }) => { const [confirmDeleteDocuments, setConfirmDeleteDocuments] = useState(false); diff --git a/packages/slice-machine/pages/changes.tsx b/packages/slice-machine/pages/changes.tsx index 704785ed41..b9798a2324 100644 --- a/packages/slice-machine/pages/changes.tsx +++ b/packages/slice-machine/pages/changes.tsx @@ -27,7 +27,7 @@ import { ChangedCustomType, ChangedSlice, } from "@lib/models/common/ModelStatus"; -import { Limit } from "@slicemachine/manager"; +import { PushChangesLimit } from "@slicemachine/manager"; import { pushChanges } from "@src/features/changes/actions/pushChanges"; import { getState } from "@src/apiClient"; @@ -60,9 +60,9 @@ const Changes: React.FunctionComponent = () => { const { pushChangesSuccess, refreshState } = useSliceMachineActions(); const [isSyncing, setIsSyncing] = useState(false); - const [openModalData, setOpenModalData] = useState( - undefined, - ); + const [openModalData, setOpenModalData] = useState< + PushChangesLimit | undefined + >(undefined); const numberOfChanges = unSyncedSlices.length + unSyncedCustomTypes.length; diff --git a/packages/slice-machine/src/features/changes/actions/pushChanges.ts b/packages/slice-machine/src/features/changes/actions/pushChanges.ts index e96036510d..384febc983 100644 --- a/packages/slice-machine/src/features/changes/actions/pushChanges.ts +++ b/packages/slice-machine/src/features/changes/actions/pushChanges.ts @@ -3,7 +3,7 @@ import { ChangedCustomType, ChangedSlice, } from "@lib/models/common/ModelStatus"; -import { Limit } from "@slicemachine/manager"; +import { PushChangesLimit } from "@slicemachine/manager"; import { trackPushChangesSuccess } from "./trackPushChangesSuccess"; @@ -15,7 +15,7 @@ type PushChangesArgs = { export async function pushChanges( args: PushChangesArgs, -): Promise { +): Promise { const { changedSlices, changedCustomTypes,