@product-live/api-sdk 2.38.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/index.d.mts +8710 -0
- package/dist/index.d.ts +8710 -0
- package/dist/index.js +9038 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9038 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -4
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Product-live sdk
|
|
2
|
+
|
|
3
|
+
This sdk aims at simplifying access to the Product-Live public API.
|
|
4
|
+
|
|
5
|
+
## Installing
|
|
6
|
+
|
|
7
|
+
Install the library with the following command:
|
|
8
|
+
`npm i @product-live/sdk`
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Instantiation
|
|
13
|
+
|
|
14
|
+
For its creation, the apiClient must be provided with an AuthenticationProvider and a RequestAdapter
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import {ApiKeyAuthenticationProvider, ApiKeyLocation} from '@microsoft/kiota-abstractions';
|
|
18
|
+
import {FetchRequestAdapter} from '@microsoft/kiota-http-fetchlibrary';
|
|
19
|
+
import {createApiClient} from './index';
|
|
20
|
+
|
|
21
|
+
const authenticationProvider = new ApiKeyAuthenticationProvider(
|
|
22
|
+
key,
|
|
23
|
+
'X-Api-Key',
|
|
24
|
+
ApiKeyLocation.Header
|
|
25
|
+
);
|
|
26
|
+
const requestAdapter = new FetchRequestAdapter(authenticationProvider);
|
|
27
|
+
requestAdapter.baseUrl = url;
|
|
28
|
+
const apiClient = createApiClient(requestAdapter);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The library provides a simplified entry point for the most usual case
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {setup} from './index';
|
|
35
|
+
|
|
36
|
+
const apiClient = setup(key, url);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
It is currently recommended to use the latter method when the project is of `"type": "module"`
|
|
40
|
+
|
|
41
|
+
### Call
|
|
42
|
+
|
|
43
|
+
Once instantiated, the client may be called on any API available. The methods use will always reflect the targeted url and the http verb.
|
|
44
|
+
For instance, to obtain a list of audit logs, we need a GET request on url `/v1/audit_logs`. The corresponding call will be:
|
|
45
|
+
```typescript
|
|
46
|
+
const auditLogsList = await apiClient.v1.audit_logs.get();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Additional parameters
|
|
50
|
+
|
|
51
|
+
Additional parameters may be provided depending on the targeted API
|
|
52
|
+
|
|
53
|
+
- url parameters: a method byId(id: string) will be available in the functions chain
|
|
54
|
+
````typescript
|
|
55
|
+
const item = await apiClient.v1.items.byId(itemId).get();
|
|
56
|
+
````
|
|
57
|
+
|
|
58
|
+
- body: for API calls requiring it, a body will be expected as the call function first argument
|
|
59
|
+
````typescript
|
|
60
|
+
const newVariable = await apiClient.v1.data_factory.variables.post({
|
|
61
|
+
key: 'some-key',
|
|
62
|
+
name: 'explicit-name',
|
|
63
|
+
value: 'value'
|
|
64
|
+
});
|
|
65
|
+
````
|
|
66
|
+
|
|
67
|
+
- headers and query parameters: all calling methods accept a RequestConfiguration as a last argument. This object is a json containing a headers and/or queryParameters object, with the necessary values inside. Note that the autocomplete is not available for the content of `headers`
|
|
68
|
+
````typescript
|
|
69
|
+
const patitionsList = await apiClient.v1.partitions.get({
|
|
70
|
+
queryParameters: { tableId: tableId },
|
|
71
|
+
headers: { 'X-Context': contextAccountId }
|
|
72
|
+
});
|
|
73
|
+
````
|
|
74
|
+
|
|
75
|
+
## Compatibility
|
|
76
|
+
|
|
77
|
+
The library provides both cjs and esm version.
|