Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ardoq/ardoq-sdk-js
A software development kit for integrating with Ardoq
https://github.com/ardoq/ardoq-sdk-js
Last synced: 7 days ago
JSON representation
A software development kit for integrating with Ardoq
- Host: GitHub
- URL: https://github.com/ardoq/ardoq-sdk-js
- Owner: ardoq
- License: mit
- Created: 2020-01-23T14:57:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:44:53.000Z (over 1 year ago)
- Last Synced: 2024-10-30T04:50:18.645Z (15 days ago)
- Language: TypeScript
- Homepage: https://npm.im/ardoq-sdk-js
- Size: 384 KB
- Stars: 6
- Watchers: 31
- Forks: 1
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ardoq SDK JS
This is an, as of yet, small SDK for developing against the Ardoq API.
It currently constist of two parts:1. The API - A set of functions corresponding to the API endpoints of Ardoq,
with correct typings
2. A graph syncer - A function that allows you to define a simple graph object
and update a set of workspaces in Ardoq to match this local graphPlease [open an issue](https://github.com/ardoq/ardoq-sdk-js/issues/new) if
there is any functionality you are missing, or if you find any bugs.## Usage
For complete usage examples, please see our [repo with examples](https://github.com/ardoq/ardoq-sync-examples).
### The API
The following example demonstrates how to create a component with the api.
```typescript
import { getAggregatedWorkspace, updateComponent } from 'ardoq-sdk-js';const apiProps = {
authToken: '',
org: '',
url: 'https://.ardoq.com/api/',
};const main = async () => {
const workspace = await getAggregatedWorkspace(apiProps, '');
for (const component of workspace.components) {
await updateComponent(apiProps, {
...component,
description: (component.description || '') + '\nVisited by script',
});
}
};main();
```### The Graph Syncer
The following example demonstrates most of the functionality of the graph
syncer. Notice that the `sync` function will take care of creating the used
types and fields. Fields can be changed locally, and will lead to the components
remotely being updated as long as the `customId`s stay the same.```typescript
import { sync, FieldType } from "ardoq-sdk-js";const apiProps = {
authToken: '',
org: '',
url: 'https://.ardoq.com/api/'
};const fields = [
{
name: "excerciseValue",
label: "Excercise value",
type: FieldType.NUMBER
}
];
const workspaces = {
activities: "",
equipment: "",
};
const graph = {
components: [
{
customId: "walking",
workspace: "activities",
name: "Walking",
type: "Simple Activity",
fields: {
excerciseValue: 10
}
},
{
customId: "running",
workspace: "activities",
name: "Running",
type: "Simple Activity",
parent: 'walking',
fields: {
excerciseValue: 50
}
},
{
customId: "sailing",
workspace: "activities",
name: "Sailing",
type: "Complex Activity",
fields: {
excerciseValue: 15
}
},
{
customId: "dinghy",
workspace: "equipment",
name: "Dinghy",
type: "Equipment"
}
],
references: [
{
customId: "sailing-uses-dinghy",
source: "sailing",
type: "Uses",
target: "dinghy",
},
]
};sync(apiProps, workspaces, graph, fields);
```## Contributing
There are a few things that could use some work:
- Verify the validity of the graph before attempting sync
- Add more of the api endpoints
- Write more tests for sync### Developing and testing
- `yarn start` will start continous building (very nice to combine with
`yarn link` for live testing in another repo)
- `yarn test --watch` will start continous testing### Cutting a new release
1. Make sure everything works: `yarn test`
2. Publish: `yarn publish`
- **NB**: Make sure to follow schemantic versioning. As long as we are in
`0.x.x`, make sure to bump the minor version on any change that could break
existing code.