8000 Enforce action params do not allow more parameters than in the specified type by nihalbhatnagar · Pull Request #1095 · palantir/osdk-ts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enforce action params do not allow more parameters than in the specified type #1095

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

Merged
merged 5 commits into from
May 6, 2025

Conversation

nihalbhatnagar
Copy link
Contributor
@nihalbhatnagar nihalbhatnagar commented Jan 14, 2025

Fixes #104
Before:
image
Generic expands type def only when fully complete:
image

After:
image

image

@@ -83,7 +83,7 @@ export async function generatePackage(
beta: options.beta,
});

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this intentional?

@@ -35,6 +35,18 @@ export type OsdkBase<
readonly $objectSpecifier: ObjectSpecifier<Q>;
};

export type OsdkWithPrimaryKey<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe should be OsdkBaseWithPrimaryKey

return o && typeof o === "object" && typeof o.$apiName === "string"
export function isActionOrQueryObjectParameter(
o: any,
): o is { $primaryKey: any } {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you intentionally didn't use OsdkBaseWithPrimaryKey here because you didn't want to add it to our contract yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, i don't want to export this from API yet if ever

const objectArray = await client(OsdkTestObject).fetchPage();

// Testing Object action with OSDK instance
await client($Actions.editOsdkTestObject).applyAction({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add type tests in actions.test.ts to make sure our actions accept osdkInstance+primaryKey+osdkBase+osdkBaseWithPrimaryKey?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will add them there as well. I should have commented this but I added the tests in our e2e so they'll be run during our backcompat tests as well. I think for the future its probably best we have coverage in both places as well

@nihalbhatnagar nihalbhatnagar force-pushed the nihalb/fix-action-params branch from f13e8af to 2b2f39f Compare April 14, 2025 18:52 8000
@nihalbhatnagar nihalbhatnagar added this to the 2.2.x milestone Apr 25, 2025
ssanjay1
ssanjay1 previously approved these changes May 2, 2025
@policy-bot policy-bot bot dismissed ssanjay1’s stale review May 2, 2025 15:02

Invalidated by push of c0e0707

@nihalbhatnagar nihalbhatnagar merged commit 67e772e into main May 6, 2025
8 checks passed
@nihalbhatnagar nihalbhatnagar deleted the nihalb/fix-action-params branch May 6, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0