-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: adding functions and sessions apis #1159
Conversation
* fix: add sort properties to filter queries * fix: fix typo
- @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected]
* test(alerts): skip flaky test temporarily * chore(package): update yarn
- @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected]
* fix: release to override a bad release * chore: skip validateDocLinks due to a bad release
- @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected] - @cognite/[email protected]
* chore: re-enable temporary disabled ci check * chore: update yarn.lock
* fix: create 50 alerts for cursor pagination test * linting * use nextCursor * remove comment * linting * use int for limit * add client and cogniterrors in test file * linting * remove unnecessary expectation
* fix: remove deprecated labels properties * feat: add active property to integrations * fix: remove deprecated lastUpdatedTime property * fix: add missing versionNumber property * fix: make filter optional
AnnotationsCogmonoAnnotationTypesDiagramsAssetLink, | ||
AnnotationsCogmonoAnnotationTypesDiagramsInstanceLink, | ||
AnnotationsCogmonoAnnotationTypesImagesAssetLink, | ||
AnnotationsCogmonoAnnotationTypesImagesInstanceLink, | ||
AnnotationsCogmonoAnnotationTypesPrimitivesGeometry2DGeometry, | ||
AnnotationsCogmonoAnnotationTypesPrimitivesGeometry3DGeometry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a breaking change? any way possible to keep the old names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what annoys me the most, I don't have control over codegen and this is a change coming from the tool. How can I avoid this breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My advice is not to use it since you spend more time working around it than it requires writing a few type definitions.
but maybe @andersfylling or @BugGambit have a better idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a discussion about this specific breaking change here: #1120 (comment)
I suggest:
- Revert the breaking change.
- Change the base branch to
release-v10
where we, in a few days, will release a new SDK major version where breaking changes are allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@polomani how can I keep the old names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR. I left some comments.
In retro, I believe the PR should have been two PRs. One for Functions and one for Sessions.
/** | ||
* @hidden | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why hidden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snippets or samples, one of those tools was failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we should look into that. @hidden
will hide this endpoint from the documentation.
I can look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested and this works:
/**
* [List function calls](https://api-docs.cognite.com/20230101/tag/Function-calls/operation/postFunctionsCall)
*
* ```js
* client.functions.call(123, { nonce: 'abc' } )
* ```
*/
🤷
code: 400, | ||
message: 'Could not build function.', | ||
}, | ||
} as CogniteFunction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why as CogniteFunction
vs const mockFunction: CogniteFunction = {}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't doing the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, not completely. Both will result in mockFunction
being recognized as the type CogniteFunction
, but as CogniteFunction
will ignore type errors.
type Foo = {
bar: number;
}
const a: Foo = {} // this will fail as `bar` is missing
const b = {} as Foo; // this will NOT fail
/** | ||
* @hidden | ||
*/ | ||
public get calls() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this used for and why is it hidden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pointing to the function calls methods (API) example:
functionsApi.calls.list()
It is hidden because the snippets or samples tools were failing
/** | ||
* @hidden | ||
*/ | ||
async limits(): Promise<HttpResponse<FunctionsLimitsResponse>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it hidden?
export interface FunctionCallRequest { | ||
// biome-ignore lint/suspicious/noExplicitAny: couldn't find correct type definition. | ||
data?: any; | ||
// biome-ignore lint/suspicious/noExplicitAny: couldn't find correct type definition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments auto-generated 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. nonce
here should be a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, no, since I turned off the auto-generated types for this API I can update the types, thanks :)
Co-authored-by: Fredrik Anfinsen <[email protected]>
Closing this PR as priorities changed and I unfortunately I have to work on something else and don't have time to finish this PR |
This PR adds sessions API and partial support for functions API in the SDK.
I covered the APIs with unit tests and added code samples.
There were some problems (mostly, generated some types with
any
and later it failed on lint) with codegen when I tried to generate the types for functions so at the end I skipped codgen for this API.