[eventhubs] - pass an interface to BlobCheckpointStore's constructor#20344
[eventhubs] - pass an interface to BlobCheckpointStore's constructor#20344maorleger merged 3 commits intoAzure:mainfrom
Conversation
|
API changes have been detected in |
Does |
Doesn't quite work, and the reason is that by returning But that gave me an idea! this seems to work: import { ContainerClient, BlobClient, BlockBlobClient } from "@azure/storage-blob";
export type BlobClientLike = {
[P in keyof Pick<BlobClient, "getBlockBlobClient">]: BlobClient[P] extends (
...args: Parameters<BlobClient[P]>
) => BlockBlobClient
? (...args: Parameters<BlobClient[P]>) => BlockBlobClientLike
: never;
};
export type ContainerClientLike = {
[P in keyof Pick<ContainerClient, "getBlobClient" | "listBlobsFlat">]: P extends "getBlobClient"
? (...args: Parameters<ContainerClient[P]>) => BlobClientLike
: ContainerClient[P];
};
export type BlockBlobClientLike = Pick<BlockBlobClient, "upload" | "setMetadata">;But I can't decide which I like better 😄 I do have to clean this up a bit |
xirzec
left a comment
There was a problem hiding this comment.
Even though there's no fancy type math, I like the approach shown in this PR for abstracting the interfaces. We did similar work in the past with PipelineLike and WebResourceLike so there is plenty of prior art.
|
/azp run js - eventhubs-checkpointstore-blob - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Packages impacted by this PR
@azure/eventhubs-checkpointstore-blob
Issues associated with this PR
Issue #13667
Describe the problem that is addressed by this PR
Because:
You cannot pass what would otherwise be a compatible ContainerClient instance to
BlobCheckpointStore unless it is successfully deduped by NPM, even across minor
versions.
This causes compatibility issues for anyone who upgrades storage-blob.
What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?
I tried to get clever with mapped types, but ran into a few situations (These examples probably have a lot of mistakes, it was hard to keep them all in-place):
At which point I gave up and just copied the minimal interface needed to support
our calls
Are there test cases added in this PR? (If not, why?)
No, the existing test cases already cover assignability
Provide a list of related PRs (if any)
Command used to generate this PR:**(Applicable only to SDK release request PRs)
Checklists