@auxilium/datalynk-client 0.5.1 → 0.6.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 +52 -5
- package/dist/api.d.ts +52 -21
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts +27 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/files.d.ts +17 -5
- package/dist/files.d.ts.map +1 -1
- package/dist/index.cjs +135 -27
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +135 -27
- package/dist/login-prompt.d.ts +18 -5
- package/dist/login-prompt.d.ts.map +1 -1
- package/dist/pdf.d.ts +43 -0
- package/dist/pdf.d.ts.map +1 -0
- package/dist/serializer.d.ts +5 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/slice.d.ts +19 -2
- package/dist/slice.d.ts.map +1 -1
- package/dist/socket.d.ts +14 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/superuser.d.ts +4 -2
- package/dist/superuser.d.ts.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Datalynk Client Library
|
|
2
2
|
|
|
3
|
-
[](https://gitlab.auxiliumgroup.com/ztimson/datalynk-client/pipelines)
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -45,6 +45,8 @@ const resp = await api.request({'$/auth/current':{}});
|
|
|
45
45
|
|
|
46
46
|
## Documentation
|
|
47
47
|
|
|
48
|
+
The full documentation can be found [here](./docs/Home.md).
|
|
49
|
+
|
|
48
50
|
<details>
|
|
49
51
|
<summary>
|
|
50
52
|
<h3 id="integration" style="display: inline">Integration</h3>
|
|
@@ -74,10 +76,12 @@ export class DatalynkApi extends Api {
|
|
|
74
76
|
contacts!: Slice<Contact>;
|
|
75
77
|
|
|
76
78
|
constructor() {
|
|
79
|
+
// Create API object & expose to window
|
|
77
80
|
super(environment.api, {/* options */});
|
|
78
81
|
window.api = this;
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
// Handle logging in
|
|
84
|
+
this.auth.handleLogin('spoke', {/* login UI options */});
|
|
81
85
|
|
|
82
86
|
// Create store to cache slice data
|
|
83
87
|
this.contacts = this.slice<Contact>(Slices.Contact);
|
|
@@ -95,7 +99,12 @@ import {environment} from '../environment/environment';
|
|
|
95
99
|
import {Contact} from '../models/contact';
|
|
96
100
|
import {Slices} from '../models/slices';
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
// Create API object & expose to window
|
|
103
|
+
export const api = window.api = new Api(environment.api, {/* options */});
|
|
104
|
+
|
|
105
|
+
// Handle logging in
|
|
106
|
+
api.auth.handleLogin('spoke', {/* login UI options */});
|
|
107
|
+
|
|
99
108
|
// Create store to cache slice data
|
|
100
109
|
export const contacts = api.slice<Contact>(Slices.Contact);
|
|
101
110
|
```
|
|
@@ -108,7 +117,12 @@ export const contacts = api.slice<Contact>(Slices.Contact);
|
|
|
108
117
|
<script type="module">
|
|
109
118
|
import {Api} from '@auxilium/datlaynk-client/dist/index.mjs';
|
|
110
119
|
|
|
120
|
+
// Create API object & expose to window
|
|
111
121
|
var api = new Api('https://spoke.auxiliumgroup.com', /* options */);
|
|
122
|
+
|
|
123
|
+
// Handle logging in
|
|
124
|
+
api.auth.handleLogin('spoke', {/* login UI options */});
|
|
125
|
+
|
|
112
126
|
// Create store to cache slice data
|
|
113
127
|
var contacts = api.slice(12345);
|
|
114
128
|
</script>
|
|
@@ -191,7 +205,7 @@ const user = await api.auth.login('spoke', 'username', 'password', '2faCode');
|
|
|
191
205
|
|
|
192
206
|
<details>
|
|
193
207
|
<summary>
|
|
194
|
-
<h3 id="" style="display: inline">Slice Engine</h3>
|
|
208
|
+
<h3 id="slices" style="display: inline">Slice Engine</h3>
|
|
195
209
|
</summary>
|
|
196
210
|
|
|
197
211
|
This library comes with LINQ style query language to help make interacting with Slices easier by providing types & intelisense.
|
|
@@ -270,7 +284,7 @@ await api.slice(12345)
|
|
|
270
284
|
|
|
271
285
|
<details>
|
|
272
286
|
<summary>
|
|
273
|
-
<h3 id="" style="display: inline">Sockets</h3>
|
|
287
|
+
<h3 id="sockets" style="display: inline">Sockets</h3>
|
|
274
288
|
</summary>
|
|
275
289
|
|
|
276
290
|
|
|
@@ -313,4 +327,37 @@ api.socket.sliceEvents(123, callbackFn(event)); // Listen to a specific slice
|
|
|
313
327
|
api.socket.addListener(callbackFn(event)); // listen to all socket events
|
|
314
328
|
```
|
|
315
329
|
|
|
330
|
+
</details>
|
|
331
|
+
|
|
332
|
+
</details>
|
|
333
|
+
|
|
334
|
+
<details>
|
|
335
|
+
<summary>
|
|
336
|
+
<h3 id="uploads" style="display: inline">Uploads</h3>
|
|
337
|
+
</summary>
|
|
338
|
+
|
|
339
|
+
A file URL can be created from the file ID
|
|
340
|
+
```js
|
|
341
|
+
const url = api.files.get(12345);
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Uploading files to datalynk is done by first uploading the file as form-data &
|
|
345
|
+
then creating a reference to the upload ID in a slice.
|
|
346
|
+
|
|
347
|
+
```js
|
|
348
|
+
// Get files from file input
|
|
349
|
+
const files = document.querySelector('#upload').files;
|
|
350
|
+
|
|
351
|
+
// Upload file
|
|
352
|
+
api.files.upload(files).then(uploaded => {
|
|
353
|
+
// Associate with record
|
|
354
|
+
const slice = 12345, row: 123;
|
|
355
|
+
api.files.associate(uploaded.map(r => r.id), slice, row, 'field');
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// OR do it all at once
|
|
359
|
+
api.files.upload(files, {slice: 12345, row: 1234, field: 'abc'});
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
|
|
316
363
|
</details>
|
package/dist/api.d.ts
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
2
|
import { Auth } from './auth';
|
|
3
3
|
import { Files } from './files';
|
|
4
|
+
import { Pdf } from './pdf';
|
|
4
5
|
import { Slice, SliceMeta } from './slice';
|
|
5
6
|
import { Socket } from './socket';
|
|
6
7
|
import { Superuser } from './superuser';
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
* Function definition for API callbacks
|
|
10
|
-
*/
|
|
11
|
-
export type ApiCallback = (code: number, data: any) => void;
|
|
12
9
|
/**
|
|
13
10
|
* Api connection options
|
|
14
11
|
*/
|
|
15
12
|
export type ApiOptions = {
|
|
16
|
-
/** Bundle requests that happen
|
|
13
|
+
/** Bundle requests together that happen in quick succession */
|
|
17
14
|
bundleTime?: number;
|
|
18
15
|
/** Name of client for logging */
|
|
19
16
|
origin?: string;
|
|
20
17
|
/** Save session token to localStorage to persist logins */
|
|
21
18
|
saveSession?: boolean;
|
|
22
|
-
/** Disable sockets or override socket URL */
|
|
19
|
+
/** Disable sockets with false or override socket URL */
|
|
23
20
|
socket?: false | string;
|
|
24
21
|
};
|
|
25
22
|
/**
|
|
26
|
-
*
|
|
23
|
+
* Possible options for API calls
|
|
27
24
|
*/
|
|
28
25
|
export interface ApiRequestOptions {
|
|
29
26
|
/** Skip optimizations like bundling & caching */
|
|
@@ -33,15 +30,19 @@ export interface ApiRequestOptions {
|
|
|
33
30
|
/** Skip wrapping IDs in an array */
|
|
34
31
|
rawUpload?: boolean;
|
|
35
32
|
}
|
|
36
|
-
/**
|
|
37
|
-
export interface
|
|
33
|
+
/** API error response */
|
|
34
|
+
export interface ApiError {
|
|
35
|
+
/** Error message */
|
|
38
36
|
message: string;
|
|
37
|
+
/** Source of error */
|
|
39
38
|
request: any;
|
|
39
|
+
/** Extra debugging information */
|
|
40
40
|
debug?: any;
|
|
41
|
+
/** Stack trace */
|
|
41
42
|
trace?: any;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Connect to Datalynk & send requests
|
|
45
46
|
*/
|
|
46
47
|
export declare class Api {
|
|
47
48
|
readonly options: ApiOptions;
|
|
@@ -57,6 +58,8 @@ export declare class Api {
|
|
|
57
58
|
readonly auth: Auth;
|
|
58
59
|
/** File helpers */
|
|
59
60
|
readonly files: Files;
|
|
61
|
+
/** PDF helpers */
|
|
62
|
+
readonly pdf: Pdf;
|
|
60
63
|
/** Socket object */
|
|
61
64
|
readonly socket: Socket;
|
|
62
65
|
/** Superuser helpers */
|
|
@@ -68,31 +71,59 @@ export declare class Api {
|
|
|
68
71
|
get token(): string | null;
|
|
69
72
|
set token(token: string | null);
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* Connect to Datalynk & send requests
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const api = new Api('https://spoke.auxiliumgroup.com');
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
72
81
|
* @param {string} url API URL
|
|
73
82
|
* @param {ApiOptions} options
|
|
74
83
|
*/
|
|
75
84
|
constructor(url: string, options?: ApiOptions);
|
|
76
85
|
private _request;
|
|
86
|
+
/**
|
|
87
|
+
* Parses API request/response object for special Datalynk tokens & converts them to native JS objects
|
|
88
|
+
*
|
|
89
|
+
* @param obj An API request or response
|
|
90
|
+
* @return {Object} Api request or response with translated tokens
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
77
93
|
private static translateTokens;
|
|
78
94
|
/**
|
|
79
95
|
* Send a request to Datalynk
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
82
|
-
*
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const response = await api.request('$/auth/current');
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @param {object} data Request using Datalynk API syntax. Strings will be converted: '$/auth/current' -> {'$/auth/current': {}}
|
|
103
|
+
* @param {ApiRequestOptions} options
|
|
104
|
+
* @returns {Promise<any>} Datalynk response or error
|
|
83
105
|
*/
|
|
84
106
|
request<T = any>(data: any, options?: ApiRequestOptions): Promise<T>;
|
|
85
107
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @
|
|
108
|
+
* Create a slice object using the API
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const contactsSlice = api.slice<Contacts>(12345);
|
|
113
|
+
* const allContacts = await contactsSlice.select().exec().rows();
|
|
114
|
+
* const unsubscribe = contactsSlice.sync().subscribe(rows => console.log(rows));
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @param {number} slice Slice number the object will target
|
|
118
|
+
* @returns {Slice<T extends SliceMeta>} Object for making requests & caching rows
|
|
89
119
|
*/
|
|
90
120
|
slice<T extends SliceMeta>(slice: number | string): Slice<T>;
|
|
91
121
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @param {
|
|
95
|
-
* @
|
|
122
|
+
* Exact same as `request` method, but logs the response in the console automatically
|
|
123
|
+
*
|
|
124
|
+
* @param {object | string} data Datalynk request as object or string
|
|
125
|
+
* @param {ApiRequestOptions} options
|
|
126
|
+
* @returns {Promise<any>} Datalynk response
|
|
96
127
|
*/
|
|
97
128
|
test<T = any>(data: any, options?: ApiRequestOptions): Promise<T>;
|
|
98
129
|
}
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,O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AAQ,CAAC,GAAG,MAAiB;IAC7B,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IACzB,wBAAwB;IACxB,QAAQ,CAAC,SAAS,YAAuB;IACzC,mBAAmB;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,wBAAwB;IACxB,MAAM,iCAA4C;IAClD,IAAI,KAAK,IACQ,MAAM,GAAG,IAAI,CADgB;IAC9C,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAA8B;IAE5D;;;;;;;;;;OAUG;gBACS,GAAG,EAAE,MAAM,EAAkB,OAAO,GAAE,UAAe;IAyBjE,OAAO,CAAC,QAAQ;IAqBhB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAsB9B;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;IAmC/E;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAIxD;;;;;;OAMG;IACI,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;CAS5E"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -2,19 +2,29 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
2
2
|
import { Api } from './api';
|
|
3
3
|
import { LoginPromptOptions } from './login-prompt';
|
|
4
4
|
|
|
5
|
-
/** User */
|
|
5
|
+
/** User Account */
|
|
6
6
|
export type User = {
|
|
7
|
+
/** User ID */
|
|
7
8
|
id: Number;
|
|
9
|
+
/** Current session token */
|
|
8
10
|
token: string;
|
|
11
|
+
/** Whether account is considered a guest */
|
|
9
12
|
guest: boolean;
|
|
13
|
+
/** Whether account is an admin */
|
|
10
14
|
sysadmin: boolean;
|
|
15
|
+
/** Account holders firstname */
|
|
11
16
|
first_name: string;
|
|
17
|
+
/** Account holders lastname */
|
|
12
18
|
last_name: string;
|
|
19
|
+
/** Contact email address */
|
|
13
20
|
email: string;
|
|
21
|
+
/** Username for logging in */
|
|
14
22
|
login: string;
|
|
15
23
|
"2FA"?: string;
|
|
16
24
|
"2FA_code"?: string;
|
|
25
|
+
/** Contact phone number */
|
|
17
26
|
mobile_phone?: string;
|
|
27
|
+
/** Spoke user comes from */
|
|
18
28
|
spoke: string;
|
|
19
29
|
};
|
|
20
30
|
/**
|
|
@@ -22,18 +32,23 @@ export type User = {
|
|
|
22
32
|
*/
|
|
23
33
|
export declare class Auth {
|
|
24
34
|
private readonly api;
|
|
35
|
+
/** Current user as an observable */
|
|
25
36
|
user$: BehaviorSubject<User | null>;
|
|
37
|
+
/** Current user */
|
|
26
38
|
get user(): User | null;
|
|
39
|
+
/** Set current user info */
|
|
27
40
|
set user(user: User | null);
|
|
28
41
|
constructor(api: Api);
|
|
29
42
|
/**
|
|
30
43
|
* Get current user associated with API token
|
|
44
|
+
*
|
|
31
45
|
* @return {Promise<User | null>}
|
|
32
46
|
*/
|
|
33
47
|
current(): Promise<null | User>;
|
|
34
48
|
/**
|
|
35
49
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
36
50
|
* user with a login screen if required
|
|
51
|
+
*
|
|
37
52
|
* @param {string} spoke Desired spoke
|
|
38
53
|
* @param {LoginPromptOptions} options Aesthetic options
|
|
39
54
|
* @return {Promise<void>} Login complete
|
|
@@ -41,31 +56,37 @@ export declare class Auth {
|
|
|
41
56
|
handleLogin(spoke: string, options?: LoginPromptOptions): Promise<void>;
|
|
42
57
|
/**
|
|
43
58
|
* Check whether user has a token
|
|
59
|
+
*
|
|
44
60
|
* @return {boolean} True if session token authenticated
|
|
45
61
|
*/
|
|
46
62
|
isAuthenticated(): boolean;
|
|
47
63
|
/**
|
|
48
64
|
* Check if the current user is a guest
|
|
65
|
+
*
|
|
49
66
|
* @return {boolean} True if guest
|
|
50
67
|
*/
|
|
51
68
|
isGuest(): boolean;
|
|
52
69
|
/**
|
|
53
70
|
* Check if user is a system administrator
|
|
71
|
+
*
|
|
54
72
|
* @return {Promise<boolean>} True if system administrator
|
|
55
73
|
*/
|
|
56
74
|
isSysAdmin(): Promise<boolean>;
|
|
57
75
|
/**
|
|
58
76
|
* Check if user is a table administrator
|
|
77
|
+
*
|
|
59
78
|
* @return {Promise<boolean>} True if table administrator
|
|
60
79
|
*/
|
|
61
80
|
isTableAdmin(): Promise<boolean>;
|
|
62
81
|
/**
|
|
63
82
|
* Check if user is a user administrator
|
|
83
|
+
*
|
|
64
84
|
* @return {Promise<boolean>} True if user administrator
|
|
65
85
|
*/
|
|
66
86
|
isUserAdmin(): Promise<boolean>;
|
|
67
87
|
/**
|
|
68
88
|
* Perform login and save the session token
|
|
89
|
+
*
|
|
69
90
|
* @param {string} login Login username or email
|
|
70
91
|
* @param {string} password Password for account
|
|
71
92
|
* @param {string} spoke Override login spoke
|
|
@@ -75,11 +96,13 @@ export declare class Auth {
|
|
|
75
96
|
login(spoke: string, login: string, password: string, twoFactor?: string): Promise<any>;
|
|
76
97
|
/**
|
|
77
98
|
* Login as guest user
|
|
99
|
+
*
|
|
78
100
|
* @return {Promise<any>}
|
|
79
101
|
*/
|
|
80
102
|
loginGuest(): Promise<any>;
|
|
81
103
|
/**
|
|
82
104
|
* Create Login UI
|
|
105
|
+
*
|
|
83
106
|
* @param {string} spoke Desired spoke
|
|
84
107
|
* @param {LoginPromptOptions} options Aesthetic options
|
|
85
108
|
* @return {Promise<void>} Login complete
|
|
@@ -87,6 +110,7 @@ export declare class Auth {
|
|
|
87
110
|
loginPrompt(spoke: string, options?: LoginPromptOptions): Promise<void>;
|
|
88
111
|
/**
|
|
89
112
|
* Logout current user
|
|
113
|
+
*
|
|
90
114
|
* @return {Promise<{closed: string, new: string}>}
|
|
91
115
|
*/
|
|
92
116
|
logout(): Promise<{
|
|
@@ -95,6 +119,7 @@ export declare class Auth {
|
|
|
95
119
|
}>;
|
|
96
120
|
/**
|
|
97
121
|
* Reset user account password
|
|
122
|
+
*
|
|
98
123
|
* @param {string} login User login
|
|
99
124
|
* @param {string} newPassword New password
|
|
100
125
|
* @param {string} code Reset code sent with `resetRequest`
|
|
@@ -103,6 +128,7 @@ export declare class Auth {
|
|
|
103
128
|
reset(login: string, newPassword: string, code?: string): Promise<any>;
|
|
104
129
|
/**
|
|
105
130
|
* Request reset code for user
|
|
131
|
+
*
|
|
106
132
|
* @param {string} login User to reset
|
|
107
133
|
* @param {"email" | "sms" | "voice"} mode Method of sending reset code
|
|
108
134
|
* @return {Promise<any>} Unknown
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE/D,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE/D,mBAAmB;AACnB,MAAM,MAAM,IAAI,GAAG;IAClB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,+BA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MG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;;;OAIG;IACH,MAAM;gBAC6B,MAAM;aAAO,MAAM;;IAOtD;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAWvD;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO;CAI3D"}
|
package/dist/files.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { Api } from './api';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Metadata for an uploaded file in Datalynk
|
|
5
|
+
*/
|
|
3
6
|
export interface UploadedFile {
|
|
7
|
+
/** File ID used to reference file in Datalynk */
|
|
4
8
|
id: number;
|
|
9
|
+
/** Filename */
|
|
5
10
|
name: string;
|
|
11
|
+
/** Size of file on disk */
|
|
6
12
|
size: number;
|
|
13
|
+
/** Filename extension */
|
|
7
14
|
extension: string;
|
|
15
|
+
/** Mimetype */
|
|
8
16
|
mime: string;
|
|
17
|
+
/** URL to open file */
|
|
9
18
|
url?: string;
|
|
10
19
|
}
|
|
11
20
|
/**
|
|
@@ -17,19 +26,21 @@ export declare class Files {
|
|
|
17
26
|
constructor(api: Api);
|
|
18
27
|
/**
|
|
19
28
|
* Associate an existing file with an existing row
|
|
29
|
+
*
|
|
20
30
|
* @param {number | number[]} fileIds Existing files to associate
|
|
21
31
|
* @param {number} slice Target slice
|
|
22
|
-
* @param {number}
|
|
32
|
+
* @param {number} row Target slice record
|
|
23
33
|
* @param {string} field Record filed file should be added to
|
|
24
|
-
* @param {
|
|
25
|
-
* @return {any}
|
|
34
|
+
* @param {boolean} execute Will run request by default, passing false will return the API request instead
|
|
35
|
+
* @return {any} The API response by default, or the raw API request if execute is false
|
|
26
36
|
*/
|
|
27
|
-
associate(fileIds: number | number[], slice: number,
|
|
37
|
+
associate(fileIds: number | number[], slice: number, row: number, field: string, execute: true): {
|
|
28
38
|
[key: string]: any;
|
|
29
39
|
};
|
|
30
|
-
associate(fileIds: number | number[], slice: number,
|
|
40
|
+
associate(fileIds: number | number[], slice: number, row: number, field: string): Promise<any>;
|
|
31
41
|
/**
|
|
32
42
|
* Get an authenticated URL to fetch files from
|
|
43
|
+
*
|
|
33
44
|
* @param {number} id File ID
|
|
34
45
|
* @param {boolean} ignoreToken Ignore authentication
|
|
35
46
|
* @return {string} URL file can be viewed at
|
|
@@ -37,6 +48,7 @@ export declare class Files {
|
|
|
37
48
|
get(id: number, ignoreToken?: boolean): string;
|
|
38
49
|
/**
|
|
39
50
|
* Upload file(s) to the API & optionally associate them with a row
|
|
51
|
+
*
|
|
40
52
|
* @param {FileList | File | File[]} files Files to be uploaded
|
|
41
53
|
* @param {{slice: number, row: any, field: string, pk?: string}} associate Row to associate with
|
|
42
54
|
*/
|
package/dist/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,KAAK;IAGL,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,QAAQ,CAAC,GAAG,EAAG,MAAM,CAAA;gBAEQ,GAAG,EAAE,GAAG;IAIrC
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings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