@cognite/sdk
Advanced tools
Comparing version 7.19.0 to 7.19.1
@@ -15,6 +15,6 @@ import { BaseResourceAPI, CursorAndAsyncIterator } from '@cognite/sdk-core'; | ||
* // automatic upload: | ||
* const file = await client.files.upload({name: 'examplefile.jpg', mimeType: 'image/jpg'}, fileContent); | ||
* const file = await client.files.upload({name: 'examplefile.jpg', mimeType: 'image/jpeg'}, fileContent); | ||
* | ||
* // manual with uploadUrl: | ||
* const file2 = await client.files.upload({name: 'examplefile.jpg', mimeType: 'image/jpg'}); | ||
* const file2 = await client.files.upload({name: 'examplefile.jpg', mimeType: 'image/jpeg'}); | ||
* // then upload using the file.uploadUrl | ||
@@ -70,3 +70,3 @@ * ``` | ||
* filter: { | ||
* mimeType: 'image/jpg', | ||
* mimeType: 'image/jpeg', | ||
* }, | ||
@@ -73,0 +73,0 @@ * search: { |
@@ -9,3 +9,3 @@ { | ||
"types": "dist/src/index.d.js", | ||
"version": "7.19.0", | ||
"version": "7.19.1", | ||
"scripts": { | ||
@@ -38,3 +38,3 @@ "clean": "rm -rf dist/ docs/ codeSnippets/", | ||
}, | ||
"gitHead": "52becd5ce0851cf2b23c62c920600635303158e5" | ||
"gitHead": "b851e1a85df579f02eb3e019a1c62163e1e646e5" | ||
} |
@@ -1,3 +0,3 @@ | ||
Cognite Javascript SDK | ||
====================== | ||
# Cognite Javascript SDK | ||
The package `@cognite/sdk` provides convenient access to the stable [Cognite API](https://doc.cognitedata.com/dev/) | ||
@@ -19,9 +19,13 @@ from applications written in client- or server-side javascript. | ||
Install the package with yarn: | ||
``` | ||
$ yarn add @cognite/sdk | ||
``` | ||
or npm | ||
``` | ||
$ npm install @cognite/sdk --save | ||
``` | ||
## Usage | ||
@@ -46,2 +50,3 @@ | ||
### Web | ||
```js | ||
@@ -51,31 +56,27 @@ import { CogniteClient, CogniteAuthentication } from '@cognite/sdk'; | ||
async function quickstart() { | ||
const project = 'publicdata'; | ||
const legacyInstance = new CogniteAuthentication({ | ||
project, | ||
}); | ||
const project = "publicdata"; | ||
const legacyInstance = new CogniteAuthentication({ | ||
project, | ||
}); | ||
const getToken = async () => { | ||
await legacyInstance.handleLoginRedirect(); | ||
let token = await legacyInstance.getCDFToken(); | ||
if (token) { | ||
return token.accessToken; | ||
} | ||
token = await legacyInstance.login({ onAuthenticate: 'REDIRECT' }); | ||
if (token) { | ||
return token.accessToken; | ||
} | ||
throw new Error('error'); | ||
}; | ||
const getToken = async () => { | ||
await legacyInstance.handleLoginRedirect(); | ||
let token = await legacyInstance.getCDFToken(); | ||
if (token) { | ||
return token.accessToken; | ||
} | ||
token = await legacyInstance.login({ onAuthenticate: "REDIRECT" }); | ||
if (token) { | ||
return token.accessToken; | ||
} | ||
throw new Error("error"); | ||
}; | ||
const client = new CogniteClient({ | ||
appId: 'YOUR APPLICATION NAME', | ||
project, | ||
getToken | ||
getToken, | ||
}); | ||
const assets = await client.assets | ||
.list() | ||
.autoPagingToArray({ limit: 100 }); | ||
const assets = await client.assets.list().autoPagingToArray({ limit: 100 }); | ||
} | ||
@@ -86,5 +87,6 @@ quickstart(); | ||
> For more details about SDK authentication see this [document](https://github.com/cognitedata/cognite-sdk-js/blob/master/guides/authentication.md). | ||
> Also, more comprehensive intro guide with a demo app can be found [here](https://github.com/cognitedata/javascript-getting-started/tree/master/sdk-auth-and-fetch-data) | ||
> Also, more comprehensive intro guide can be found [here](https://docs.cognite.com/dev/guides/sdk/js/) | ||
### Backend | ||
```js | ||
@@ -97,8 +99,6 @@ const { CogniteClient } = require('@cognite/sdk'); | ||
apiKeyMode: true, | ||
getToken: () => Promise.resolve('YOUR_SECRET_API_KEY') | ||
getToken: () => Promise.resolve('YOUR_SECRET_API_KEY'), | ||
}); | ||
const assets = await client.assets | ||
.list() | ||
.autoPagingToArray({ limit: 100 }); | ||
const assets = await client.assets.list().autoPagingToArray({ limit: 100 }); | ||
} | ||
@@ -110,4 +110,4 @@ quickstart(); | ||
- [API reference documentation](https://doc.cognitedata.com/api/v1) | ||
- [JS SDK reference documentation](https://cognitedata.github.io/cognite-sdk-js/classes/cogniteclient.html) | ||
- [API reference documentation](https://doc.cognitedata.com/api/v1) | ||
- [JS SDK reference documentation](https://cognitedata.github.io/cognite-sdk-js/classes/cogniteclient.html) | ||
@@ -123,2 +123,3 @@ ## Best practices | ||
**Bad:** | ||
``` | ||
@@ -132,2 +133,3 @@ import { CogniteAsyncIterator } from '@cognite/sdk/dist/src/autoPagination'; // ❌ | ||
**Good:** | ||
``` | ||
@@ -152,7 +154,6 @@ import { CogniteAsyncIterator } from '@cognite/sdk'; // ✅ | ||
## Guides | ||
- [Migration guide](https://github.com/cognitedata/cognite-sdk-js/blob/master/guides/MIGRATION_GUIDE_1xx_2xx.md) | ||
on how to migrate from version `1.x.x` to version `2.x.x`. | ||
- [Migration guide](https://github.com/cognitedata/cognite-sdk-js/blob/master/guides/MIGRATION_GUIDE_2xx_3xx.md) from version `2.x.x` to version `3.x.x`. | ||
- [Migration guide](https://github.com/cognitedata/cognite-sdk-js/blob/master/guides/MIGRATION_GUIDE_1xx_2xx.md) | ||
on how to migrate from version `1.x.x` to version `2.x.x`. | ||
- [Migration guide](https://github.com/cognitedata/cognite-sdk-js/blob/master/guides/MIGRATION_GUIDE_2xx_3xx.md) from version `2.x.x` to version `3.x.x`. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151
514909
63