Skip to content
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

chore(deps): update dependency @bjoerge/mutiny to ^0.7.0 #7274

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@bjoerge/mutiny": "^0.5.3",
"@bjoerge/mutiny": "^0.7.0",
"@google-cloud/storage": "^7.11.0",
"@jest/globals": "^29.7.0",
"@playwright/test": "1.44.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"watch": "pkg-utils watch"
},
"dependencies": {
"@bjoerge/mutiny": "^0.5.1",
"@bjoerge/mutiny": "^0.7.0",
"@sanity/client": "^6.21.1",
"@sanity/types": "3.52.4",
"@sanity/util": "3.52.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function normalizeMutation(
return change.flatMap((ch) => normalizeMutation(ch))
}
if (isRawMutation(change)) {
return SanityEncoder.decode([change] as any) as Mutation[]
return SanityEncoder.decodeAll([change] as any) as Mutation[]
}
return [change]
}
Expand Down Expand Up @@ -128,7 +128,7 @@ function normalizeDocumentMutation(
return change.flatMap((ch) => normalizeDocumentMutation(documentId, ch))
}
if (isRawMutation(change)) {
return SanityEncoder.decode([change] as any)[0] as Mutation
return SanityEncoder.decodeAll([change] as any)[0] as Mutation
}
if (isTransaction(change)) {
return change
Expand All @@ -149,7 +149,7 @@ function normalizeNodeMutation(
return change.flatMap((ch) => normalizeNodeMutation(path, ch))
}
if (isRawMutation(change)) {
return SanityEncoder.decode([change] as any)[0] as Mutation
return SanityEncoder.decodeAll([change] as any)[0] as Mutation
}

if (isNodePatch(change)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jest.mock('@bjoerge/mutiny', () => {
return {
...actual,
SanityEncoder: {
...actual.SanityEncoder.encode,
encode: jest
.fn<typeof actual.SanityEncoder.encode>()
.mockImplementation(actual.SanityEncoder.encode),
...actual.SanityEncoder,
encodeAll: jest
.fn<typeof actual.SanityEncoder.encodeAll>()
.mockImplementation(actual.SanityEncoder.encodeAll),
},
}
})
Expand Down Expand Up @@ -45,8 +45,8 @@ describe('#toSanityMutations', () => {
result.push(mutation)
}

expect(result.flat()).toEqual(SanityEncoder.encode([mockMutation] as any))
expect(SanityEncoder.encode).toHaveBeenCalledWith([mockMutation])
expect(result.flat()).toEqual(SanityEncoder.encodeAll([mockMutation] as any[]))
expect(SanityEncoder.encodeAll).toHaveBeenCalledWith([mockMutation])
})

it('should handle multiple mutations', async () => {
Expand Down Expand Up @@ -84,8 +84,8 @@ describe('#toSanityMutations', () => {
result.push(mutation)
}

expect(result.flat()).toEqual(SanityEncoder.encode(mockMutations as any))
expect(SanityEncoder.encode).toHaveBeenCalledWith(mockMutations)
expect(result.flat()).toEqual(SanityEncoder.encodeAll(mockMutations as any[]))
expect(SanityEncoder.encodeAll).toHaveBeenCalledWith(mockMutations)
})

it('should handle transaction', async () => {
Expand Down Expand Up @@ -114,10 +114,10 @@ describe('#toSanityMutations', () => {

const expected: TransactionPayload = {
transactionId: mockTransaction.id,
mutations: SanityEncoder.encode(mockTransaction.mutations as any),
mutations: SanityEncoder.encodeAll(mockTransaction.mutations as any[]),
}

expect(result).toEqual([expected])
expect(SanityEncoder.encode).toHaveBeenCalledWith(mockTransaction.mutations)
expect(SanityEncoder.encodeAll).toHaveBeenCalledWith(mockTransaction.mutations)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export async function* toSanityMutations(
if (isTransaction(mut)) {
yield {
transactionId: mut.id,
mutations: SanityEncoder.encode(mut.mutations as any) as SanityMutation[],
mutations: SanityEncoder.encodeAll(mut.mutations as any[]) as SanityMutation[],
}
continue
}

yield SanityEncoder.encode(arrify(mut) as any[]) as SanityMutation[]
yield SanityEncoder.encodeAll(arrify(mut) as any[]) as SanityMutation[]
}
}
}
26 changes: 13 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion scripts/doc-report/docReportCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ studioMetricsClient.datasets.list().then(async (datasets) => {
filter(({mutations}) => mutations.length > 0),
mergeMap(({pkg, mutations}) => {
console.log(`Submitting ${mutations.length} mutations for ${pkg.manifest.name}`)
return studioMetricsClient.observable.transaction(SanityEncoder.encode(mutations)).commit()
return studioMetricsClient.observable
.transaction(SanityEncoder.encodeAll(mutations))
.commit()
}, 2),
)
.subscribe()
Expand Down
Loading