-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add final method call to request context header (#478)
* Add final method call to all request-sending methods except asyncIter * Mark asyncIter-originated fetchPage calls * Fix asyncIter to actually fetch next pages * Add changeset * Fix runAssignEmployeeToVentureTest * Stop exposing calledByAsyncIter argument in fetchPage * Fix semantic merge conflict with queries PR * Add final method call to applyQuery * Make return type of augment fn a Partial<RequestContext> * Add rationale for augment fn in comment
- Loading branch information
1 parent
6a91177
commit dec005b
Showing
11 changed files
with
147 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@osdk/client.api": patch | ||
"@osdk/client": patch | ||
--- | ||
|
||
Add final method call to request context header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { MinimalClient, RequestContext } from "../MinimalClientContext.js"; | ||
|
||
/** | ||
Returns a client with its `requestContext` merged with the result of applying | ||
`augment` to its `requestContext`. | ||
The second argument is an `Partial<RequestContext>`-returning `augment` function | ||
instead of a `RequestContext` object to make referencing the current request | ||
context easier. For example, modifying the `fetchPage` function to add its name | ||
to the object set's called method chain could look like: | ||
``` | ||
augmentRequestContext( | ||
clientContext, | ||
ctx => ({ methodChain: [...ctx.methodChain, "fetchPage"] }) | ||
) | ||
``` | ||
or | ||
``` | ||
augmentRequestContext( | ||
clientContext, | ||
({ methodChain }) => ({ methodChain: [...methodChain, "fetchPage"] }) | ||
) | ||
``` | ||
instead of | ||
``` | ||
augmentRequestContext( | ||
clientContext, | ||
{ methodChain: [...clientContext.requestContext.methodChain, "fetchPage"] } | ||
) | ||
``` | ||
*/ | ||
export const augmentRequestContext = ( | ||
client: MinimalClient, | ||
augment: (ctx: RequestContext) => Partial<RequestContext>, | ||
): MinimalClient => ({ | ||
...client, | ||
requestContext: { | ||
...client.requestContext, | ||
...augment(client.requestContext), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters