
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@cognite/fdm-client
Advanced tools
This library, plus the generate-js-sdk functionality of the beta CDF CLI.
Cognite FDM Client is an auto-generated query builder that enables type-safe CDF data querying and ingestion against your data models. This tool reduces boilerplate. And you can easily use it along side React Query (demo coming soon).
To get started, make sure you have the beta CDF CLI installed.
Then, in the project you would like to generate the SDK, run cdf data-models generate-js-sdk.
From then, you can run the below code to get a instantiated FDMQueryClient.
import { FDMQueryClientBuilder } from '@cognite/fdm-client';
const client = FDMQueryClientBuilder.fromClient(/**Your CogniteClient Here**/);
Hint: Feel free to checkout the generated/sample.ts for how to use the SDK!
With FDM, you get access to list, search, and aggregate queries for every type you define.
To run these queries, use the runQuery command and it will autocomplete all of the fields.
import { everything } from '@cognite/fdm-client';
client
.runQuery({
searchMovie: {
items: {
...everything, // use everything to get all the scalars back.
name: true, // or just type the property name as key and `true` as value to get the data back
},
},
})
.then((response) => {
// do something with `response.data`
});
You'll notice that the response you get back is according to the field selection in the runQuery command.
For most queries, you would like to specify some parameters (i.e. query for search commands, or limit for page size).
You can do that via giving the query an array with the 1st item being the parameters, 2nd being the query like the first example.
client
.runQuery({
searchMovie: [
{ query: 'some string', limit: 1000 }, // you can specify the parameters right in here
{
items: {
name: true,
},
},
],
})
.then((response) => {
// do something with `response.data`
});
To upsert (update or insert) data into your data model's types, you can use upsertNodes.
When you upsert, you must specify the externalId and any other required fields.
Loading basic nodes is very easy, simply pass in an array of JSON object after specifying the type that you would like to load to.
await client.upsertNodes('Actor', [
{
name: 'Brad Pitt',
externalId: 'bp',
},
]);
await client.upsertNodes('Movie', [
{
name: "Ocean's 11",
externalId: 'o11',
},
]);
We have a special NodeRef class defined to make it easy for ingesting 1:1 (direct) relationships. Just specify the target node's externalId.
import { NodeRef } from '@cognite/fdm-client';
client.upsertNodes('Actor', [
{
name: 'Brad Pitt',
externalId: 'bp',
favMovie: new NodeRef('o11'),
},
]);
For loading relationships - 1:m (one to many) or m:n (many to many), specify first the property that the data should be loaded to to upsertRelationships. Then, we have a special NodeRef class to make it easy for ingesting these relationships. Just specify the start and end node's externalIds.
import { NodeRef } from '@cognite/fdm-client';
client.upsertRelationships('Movie', 'actors', [
{
startNode: new NodeRef('o11'),
endNode: new NodeRef('bp'),
},
]);
For deleting nodes data just use the deleteNodes and pass in the externalIds to be deleted for the specified type.
For deleting relationships - 1:m (one to many) or m:n (many to many), use the special NodeRef class and specify the start and end node's externalIds. Pass the array of relationships to be deleted to deleteRelationships.
import { NodeRef } from '@cognite/fdm-client';
// deleting nodes
client.deleteNodes('Movie', ['bp']);
// deleting relationships
client.deleteRelationships('Movie', 'actors', [
{
startNode: new NodeRef('o11'),
endNode: new NodeRef('bp'),
},
]);
For querying, we take inspiration from genql.
@cognite/fdm-client npm packageThe @cognite/fdm-client npm package consists of two key parts:
@cognite/fdm-client module itself, which only changes when you re-install the package.cognite/fdm-client folder, which is the default location for the generate-js-sdk command of the beta CDF CLI.When you update your data model, simply rerun generate-js-sdk and you will get the latest autogenerated SDK in your code for use. You do not need to reinstall @cognite/fdm-client on each data model change.
By generating CDF FDM Client into node_modules, the SDK is usually kept out of version control by default since node_modules is typically ignored for version control. This is by design. When using a custom output path for the generated client (using --output-directory), it is advised to exclude it from your version control because it should be generated based on the specified data model + version from Cognite.
FAQs
A CLI for Cognite Data Fusion
The npm package @cognite/fdm-client receives a total of 1 weekly downloads. As such, @cognite/fdm-client popularity was classified as not popular.
We found that @cognite/fdm-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 229 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.