@auxilium/datalynk-client 0.9.12 → 1.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 +22 -15
- package/dist/api.d.ts +16 -18
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +106 -157
- package/dist/index.mjs +106 -157
- package/dist/slice.d.ts +56 -101
- package/dist/slice.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/slice.d.ts
CHANGED
|
@@ -1,104 +1,19 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { Api,
|
|
2
|
+
import { Api, ApiRequestOptions } from './api';
|
|
3
3
|
import { Unsubscribe } from './socket';
|
|
4
4
|
|
|
5
|
-
export interface SliceMeta {
|
|
6
|
-
id?: number;
|
|
7
|
-
created?: Date;
|
|
8
|
-
creatorRef?: number;
|
|
9
|
-
modified?: Date;
|
|
10
|
-
modifiedRef?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* An object to provide helpers for Datalynk results
|
|
14
|
-
*/
|
|
15
|
-
export declare class SlicePromise<T extends SliceMeta> {
|
|
16
|
-
readonly slice: Slice<T>;
|
|
17
|
-
readonly promise: Promise<SliceResponse<T>>;
|
|
18
|
-
/**
|
|
19
|
-
* An object to provide helpers for Datalynk results
|
|
20
|
-
*
|
|
21
|
-
* @param slice
|
|
22
|
-
* @param {SliceResponse<T>} promise Datalynk promise to handle
|
|
23
|
-
*/
|
|
24
|
-
constructor(slice: Slice<T>, promise: Promise<SliceResponse<T>>);
|
|
25
|
-
/**
|
|
26
|
-
* Catch promise errors
|
|
27
|
-
*/
|
|
28
|
-
catch(callback: (error: ApiError | any) => any): Promise<any>;
|
|
29
|
-
/**
|
|
30
|
-
* Count rows or fetch count alias result
|
|
31
|
-
*/
|
|
32
|
-
count(): Promise<number>;
|
|
33
|
-
/**
|
|
34
|
-
* Log the raw result to the console for inspection
|
|
35
|
-
*/
|
|
36
|
-
debug(): SlicePromise<T>;
|
|
37
|
-
/**
|
|
38
|
-
* Fields that failed
|
|
39
|
-
*/
|
|
40
|
-
failed(): Promise<number[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Catch promise errors
|
|
43
|
-
*/
|
|
44
|
-
finally(callback: () => any): Promise<SliceResponse<T>>;
|
|
45
|
-
/**
|
|
46
|
-
* Fields that were ignored (Perms or readonly)
|
|
47
|
-
*/
|
|
48
|
-
ignored(): Promise<object[]>;
|
|
49
|
-
/**
|
|
50
|
-
* ID of first affected row
|
|
51
|
-
*/
|
|
52
|
-
key(): Promise<number>;
|
|
53
|
-
/**
|
|
54
|
-
* IDs of all affected rows
|
|
55
|
-
*/
|
|
56
|
-
keys(): Promise<number[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Fields that were affected successfully
|
|
59
|
-
*/
|
|
60
|
-
granted(): Promise<object[]>;
|
|
61
|
-
/**
|
|
62
|
-
* First row of data
|
|
63
|
-
*/
|
|
64
|
-
row(): Promise<T>;
|
|
65
|
-
/**
|
|
66
|
-
* All rows of data
|
|
67
|
-
*/
|
|
68
|
-
rows(): Promise<T[]>;
|
|
69
|
-
/**
|
|
70
|
-
* Handle as normal request
|
|
71
|
-
*/
|
|
72
|
-
then(success: (response: SliceResponse<T>) => any, error?: (error: ApiError | any) => any): Promise<SliceResponse<T>>;
|
|
73
|
-
/**
|
|
74
|
-
* Get the raw promise
|
|
75
|
-
*/
|
|
76
|
-
toPromise(): Promise<SliceResponse<T>>;
|
|
77
|
-
/**
|
|
78
|
-
* Get the transaction ID
|
|
79
|
-
*/
|
|
80
|
-
transaction(): Promise<number>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Model for datalynk responses
|
|
84
|
-
*/
|
|
85
|
-
export interface SliceResponse<T extends SliceMeta> {
|
|
86
|
-
failed: number[];
|
|
87
|
-
granted: object[];
|
|
88
|
-
'ignored-fields': object[];
|
|
89
|
-
keys: number[];
|
|
90
|
-
rows: T[];
|
|
91
|
-
tx: number;
|
|
92
|
-
}
|
|
93
5
|
/**
|
|
94
6
|
* An object to aid in constructing Datalynk requests
|
|
95
7
|
*/
|
|
96
|
-
export declare class Slice<T
|
|
8
|
+
export declare class Slice<T = any> {
|
|
97
9
|
private slice;
|
|
98
10
|
private api;
|
|
99
11
|
static api: Api;
|
|
100
12
|
private operation;
|
|
13
|
+
private popField?;
|
|
101
14
|
private request;
|
|
15
|
+
/** Log response automatically */
|
|
16
|
+
debugging?: boolean;
|
|
102
17
|
/** Unsubscribe from changes, undefined if not subscribed */
|
|
103
18
|
unsubscribe?: Unsubscribe | null;
|
|
104
19
|
/** Cached slice data as an observable */
|
|
@@ -108,9 +23,10 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
108
23
|
/** Set cached data & alert subscribers */
|
|
109
24
|
private set cache(value);
|
|
110
25
|
/** Get raw API request */
|
|
111
|
-
get raw(): {
|
|
26
|
+
get raw(): Partial<{
|
|
112
27
|
[x: string]: any;
|
|
113
|
-
|
|
28
|
+
$pop: string | undefined;
|
|
29
|
+
}>;
|
|
114
30
|
/**
|
|
115
31
|
* An object to aid in constructing requests
|
|
116
32
|
*
|
|
@@ -119,17 +35,21 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
119
35
|
*/
|
|
120
36
|
constructor(slice: number | string, api: Api);
|
|
121
37
|
/**
|
|
122
|
-
* Whitelist and alias fields. Alias
|
|
38
|
+
* Whitelist and alias fields. Alias of `fields()`
|
|
123
39
|
* @example
|
|
124
40
|
* ```ts
|
|
125
41
|
* const id: {id: number, field2: any}[] = await new Slice<T>(12345)
|
|
126
42
|
* .select().alias({id: 'id', field1: 'field2'}).exec().keys();
|
|
127
43
|
* ```
|
|
128
44
|
* @param {object} aliasKeyVals List of properties to whitelist and what to rename them to
|
|
45
|
+
* @return {Slice<T>}
|
|
129
46
|
*/
|
|
130
|
-
alias
|
|
131
|
-
|
|
132
|
-
|
|
47
|
+
alias: {
|
|
48
|
+
(whitelist: string[]): Slice<T>;
|
|
49
|
+
(alias: {
|
|
50
|
+
[key: string]: string | object;
|
|
51
|
+
}): Slice<T>;
|
|
52
|
+
};
|
|
133
53
|
/**
|
|
134
54
|
* Add an 'AND' condition inside the where argument
|
|
135
55
|
* @example
|
|
@@ -140,6 +60,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
140
60
|
* .where({field2: 2, field3: 3})
|
|
141
61
|
* .exec().rows();
|
|
142
62
|
* ```
|
|
63
|
+
* @return {Slice<T>}
|
|
143
64
|
*/
|
|
144
65
|
and(): this;
|
|
145
66
|
/**
|
|
@@ -151,12 +72,15 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
151
72
|
* .exec().count();
|
|
152
73
|
* ```
|
|
153
74
|
* @param {object | string} arg Count argument
|
|
75
|
+
* @return {Slice<T>}
|
|
154
76
|
*/
|
|
155
|
-
count(arg?: object | string):
|
|
77
|
+
count(arg?: object | string): Slice<T>;
|
|
156
78
|
/**
|
|
157
79
|
* Output the formed request to the console for inspection
|
|
80
|
+
* @param {boolean} enabled Enable/Disable console logging
|
|
81
|
+
* @return {Slice<T>}
|
|
158
82
|
*/
|
|
159
|
-
debug(): this;
|
|
83
|
+
debug(enabled?: boolean): this;
|
|
160
84
|
/**
|
|
161
85
|
* Set the request type to delete
|
|
162
86
|
* @example
|
|
@@ -164,6 +88,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
164
88
|
* await new Slice(12345).delete(id).exec();
|
|
165
89
|
* ```
|
|
166
90
|
* @param {number | number[]} id ID(s) to delete
|
|
91
|
+
* @return {Slice<T>}
|
|
167
92
|
*/
|
|
168
93
|
delete(id?: number | number[]): Slice<T>;
|
|
169
94
|
/**
|
|
@@ -175,14 +100,15 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
175
100
|
* .exec().rows();
|
|
176
101
|
* ```
|
|
177
102
|
* @param formula Excel formula to use as where clause
|
|
103
|
+
* @return {Slice<T>}
|
|
178
104
|
*/
|
|
179
105
|
excel(formula: string): Slice<T>;
|
|
180
106
|
/**
|
|
181
107
|
* Compile the request and send it
|
|
182
108
|
* @param {ApiRequestOptions} options API Request options
|
|
183
|
-
* @return {
|
|
109
|
+
* @return {Promise<T = any>} API response
|
|
184
110
|
*/
|
|
185
|
-
exec(options?: ApiRequestOptions):
|
|
111
|
+
exec<T = any>(options?: ApiRequestOptions): Promise<T>;
|
|
186
112
|
/**
|
|
187
113
|
* Whitelist fields by passing an array of keys or alias fields by using a map
|
|
188
114
|
* @example
|
|
@@ -191,11 +117,17 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
191
117
|
* .select().fields(['id', 'field1']).exec().keys();
|
|
192
118
|
* ```
|
|
193
119
|
* @param {object} whitelist Either a list of keys to whitelist or a map of keys to rename
|
|
120
|
+
* @return {Slice<T>}
|
|
194
121
|
*/
|
|
195
122
|
fields(whitelist: string[]): Slice<T>;
|
|
196
123
|
fields(alias: {
|
|
197
124
|
[key: string]: string | object;
|
|
198
125
|
}): Slice<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Unwrap response returning the first ID
|
|
128
|
+
* @return {Slice<T>}
|
|
129
|
+
*/
|
|
130
|
+
id(): Slice<T>;
|
|
199
131
|
/**
|
|
200
132
|
* Set the request type to insert
|
|
201
133
|
* @example
|
|
@@ -206,6 +138,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
206
138
|
* ]).exec().keys();
|
|
207
139
|
* ```
|
|
208
140
|
* @param {T | T[]} rows Rows to be inserted into the slice
|
|
141
|
+
* @return {Slice<T>}
|
|
209
142
|
*/
|
|
210
143
|
insert(rows: T | T[]): Slice<T>;
|
|
211
144
|
/**
|
|
@@ -216,8 +149,9 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
216
149
|
* .exec().rows();
|
|
217
150
|
* ```
|
|
218
151
|
* @param {number} num Number of rows to return
|
|
152
|
+
* @return {Slice<T>}
|
|
219
153
|
*/
|
|
220
|
-
limit(num: number):
|
|
154
|
+
limit(num: number): this;
|
|
221
155
|
/**
|
|
222
156
|
* Add an 'OR' condition inside the where argument
|
|
223
157
|
* @example
|
|
@@ -230,6 +164,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
230
164
|
* .where(['$gt', ['$field', field4], 4)
|
|
231
165
|
* .exec().rows();
|
|
232
166
|
* ```
|
|
167
|
+
* @return {Slice<T>}
|
|
233
168
|
*/
|
|
234
169
|
or(): this;
|
|
235
170
|
/**
|
|
@@ -241,8 +176,25 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
241
176
|
* ```
|
|
242
177
|
* @param {string} field property name
|
|
243
178
|
* @param {boolean} ascending Sort in ascending or descending order
|
|
179
|
+
* @return {Slice<T>}
|
|
244
180
|
*/
|
|
245
181
|
order(field: string, ascending?: boolean): Slice<T>;
|
|
182
|
+
/**
|
|
183
|
+
* Unwrap response, returning the field
|
|
184
|
+
* @param {string} field Colon seperated path: `rows:0`
|
|
185
|
+
* @return {Slice<T>}
|
|
186
|
+
*/
|
|
187
|
+
pop(field: string | null): Slice<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Unwrap response returning the first row
|
|
190
|
+
* @return {Slice<T>}
|
|
191
|
+
*/
|
|
192
|
+
row(): Slice<T>;
|
|
193
|
+
/**
|
|
194
|
+
* Unwrap response returning the rows
|
|
195
|
+
* @return {Slice<T>}
|
|
196
|
+
*/
|
|
197
|
+
rows(): Slice<T>;
|
|
246
198
|
/**
|
|
247
199
|
* Set the request type to select
|
|
248
200
|
* @example
|
|
@@ -251,6 +203,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
251
203
|
* const row: T = new Slice<T>(12345).select(id).exec().row();
|
|
252
204
|
* ```
|
|
253
205
|
* @param {number | number[]} id ID(s) to select, leaving blank will return all rows
|
|
206
|
+
* @return {Slice<T>}
|
|
254
207
|
*/
|
|
255
208
|
select(id?: number | number[]): Slice<T>;
|
|
256
209
|
/**
|
|
@@ -274,6 +227,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
274
227
|
* ]).exec().keys();
|
|
275
228
|
* ```
|
|
276
229
|
* @param {T | T[]} rows Rows to be updated, each row must have an ID
|
|
230
|
+
* @return {Slice<T>}
|
|
277
231
|
*/
|
|
278
232
|
update(rows: T | T[]): this;
|
|
279
233
|
/**
|
|
@@ -290,6 +244,7 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
290
244
|
* @param {string | object} field property to compare or a map of equality comparisons
|
|
291
245
|
* @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
|
|
292
246
|
* @param {any} value value to compare against
|
|
247
|
+
* @return {Slice<T>}
|
|
293
248
|
*/
|
|
294
249
|
where(field: string | object, operator?: string, value?: any): Slice<T>;
|
|
295
250
|
}
|
package/dist/slice.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../src/slice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../src/slice.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAmB,WAAW,EAAC,MAAM,UAAU,CAAC;AAEvD;;GAEG;AACH,qBAAa,KAAK,CAAC,CAAC,GAAG,GAAG;IAoCb,OAAO,CAAC,KAAK;IAAmB,OAAO,CAAC,GAAG;IAnCvD,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;IAEhB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,OAAO,CAAW;IAE1B,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAEjC,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAAgC;IAC9C,wBAA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CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IAQ/B;;;;;;;;;OASG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM;IAKjB;;;;;;;;;;;;;OAaG;IACH,EAAE;IAUF;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAMhD;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;IAKnC;;;OAGG;IACH,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC;IAIf;;;OAGG;IACH,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC;IAIhB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IASxC;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,UAAO;IAoBd;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;IAQpB;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;CA+BvE"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@auxilium/datalynk-client",
|
|
3
3
|
"description": "Datalynk client library",
|
|
4
4
|
"repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "1.0.0",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|