@auxilium/datalynk-client 0.9.3 → 0.9.7
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/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +121 -25
- package/dist/index.mjs +121 -25
- package/dist/slice.d.ts +92 -17
- package/dist/slice.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type JwtPayload = {
|
|
|
24
24
|
export type ApiOptions = {
|
|
25
25
|
/** Bundle requests together that happen in quick succession */
|
|
26
26
|
bundleTime?: number;
|
|
27
|
+
/** Use legacy dates by default */
|
|
28
|
+
legacyDates?: boolean;
|
|
27
29
|
/** Name of client for logging */
|
|
28
30
|
origin?: string;
|
|
29
31
|
/** Save session token to localStorage to persist logins */
|
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;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,O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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,wCAAwC;IACxC,IAAI,UAAU,IAAI,UAAU,GAAG,IAAI,CAGlC;IAED;;;;;;;;;;OAUG;gBACS,GAAG,EAAE,MAAM,EAAkB,OAAO,GAAE,UAAe;IA4BjE,OAAO,CAAC,QAAQ;IAoBhB;;;;;;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;IAqC/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/index.cjs
CHANGED
|
@@ -2129,7 +2129,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2129
2129
|
}
|
|
2130
2130
|
/**
|
|
2131
2131
|
* Whitelist and alias fields. Alias for the fields functions
|
|
2132
|
-
*
|
|
2132
|
+
* @example
|
|
2133
|
+
* ```ts
|
|
2134
|
+
* const id: {id: number, field2: any}[] = await new Slice<T>(12345)
|
|
2135
|
+
* .select().alias({id: 'id', field1: 'field2'}).exec().keys();
|
|
2136
|
+
* ```
|
|
2133
2137
|
* @param {object} aliasKeyVals List of properties to whitelist and what to rename them to
|
|
2134
2138
|
*/
|
|
2135
2139
|
alias(aliasKeyVals) {
|
|
@@ -2137,6 +2141,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2137
2141
|
}
|
|
2138
2142
|
/**
|
|
2139
2143
|
* Add an 'AND' condition inside the where argument
|
|
2144
|
+
* @example
|
|
2145
|
+
* ```ts
|
|
2146
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2147
|
+
* .where('field1', '>', 1)
|
|
2148
|
+
* .and()
|
|
2149
|
+
* .where({field2: 2, field3: 3})
|
|
2150
|
+
* .exec().rows();
|
|
2151
|
+
* ```
|
|
2140
2152
|
*/
|
|
2141
2153
|
and() {
|
|
2142
2154
|
var _a;
|
|
@@ -2147,10 +2159,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2147
2159
|
}
|
|
2148
2160
|
/**
|
|
2149
2161
|
* Count the returned rows
|
|
2162
|
+
* @example
|
|
2163
|
+
* ```ts
|
|
2164
|
+
* const count = await new Slice(12345).count()
|
|
2165
|
+
* .where({field1: 1})
|
|
2166
|
+
* .exec().count();
|
|
2167
|
+
* ```
|
|
2168
|
+
* @param {object | string} arg Count argument
|
|
2150
2169
|
*/
|
|
2151
|
-
count(
|
|
2170
|
+
count(arg = "id") {
|
|
2152
2171
|
this.operation = "$/slice/report";
|
|
2153
|
-
this.request.fields = { count: ["$count", typeof
|
|
2172
|
+
this.request.fields = { count: ["$count", typeof arg == "object" ? arg : ["$field", arg]] };
|
|
2154
2173
|
return this;
|
|
2155
2174
|
}
|
|
2156
2175
|
/**
|
|
@@ -2162,7 +2181,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2162
2181
|
}
|
|
2163
2182
|
/**
|
|
2164
2183
|
* Set the request type to delete
|
|
2165
|
-
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* ```ts
|
|
2186
|
+
* await new Slice(12345).delete(id).exec();
|
|
2187
|
+
* ```
|
|
2166
2188
|
* @param {number | number[]} id ID(s) to delete
|
|
2167
2189
|
*/
|
|
2168
2190
|
delete(id) {
|
|
@@ -2175,16 +2197,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2175
2197
|
}
|
|
2176
2198
|
/**
|
|
2177
2199
|
* Filter rows from slice based on an excel expression
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2200
|
+
* @example
|
|
2201
|
+
* ```ts
|
|
2202
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2203
|
+
* .excel('')
|
|
2204
|
+
* .exec().rows();
|
|
2205
|
+
* ```
|
|
2206
|
+
* @param formula Excel formula to use as where clause
|
|
2180
2207
|
*/
|
|
2181
|
-
excel(
|
|
2182
|
-
this.request.where
|
|
2208
|
+
excel(formula) {
|
|
2209
|
+
if (this.request.where && this.request.where[0] != "$or") this.and();
|
|
2210
|
+
if (!this.request.where) this.request.where = { "$excel": formula };
|
|
2211
|
+
else {
|
|
2212
|
+
if (this.request.where[0] == "$or") {
|
|
2213
|
+
const i = this.request.where.length - 1;
|
|
2214
|
+
if (this.request.where[i] == null) this.request.where[i] = { "$excel": formula };
|
|
2215
|
+
else {
|
|
2216
|
+
if (this.request.where[i][0] == "$and") this.request.where[i].push({ "$excel": formula });
|
|
2217
|
+
else this.request.where[i] = ["$and", this.request.where[i], { "$excel": formula }];
|
|
2218
|
+
}
|
|
2219
|
+
} else this.request.where.push({ "$excel": formula });
|
|
2220
|
+
}
|
|
2183
2221
|
return this;
|
|
2184
2222
|
}
|
|
2185
2223
|
/**
|
|
2186
2224
|
* Compile the request and send it
|
|
2187
|
-
*
|
|
2188
2225
|
* @param {ApiRequestOptions} options API Request options
|
|
2189
2226
|
* @return {SlicePromise<T>}
|
|
2190
2227
|
*/
|
|
@@ -2199,7 +2236,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2199
2236
|
}
|
|
2200
2237
|
/**
|
|
2201
2238
|
* Set the request type to insert
|
|
2202
|
-
*
|
|
2239
|
+
* @example
|
|
2240
|
+
* ```ts
|
|
2241
|
+
* const id: number = await new Slice<T>(12345).insert([
|
|
2242
|
+
* {field1: 1},
|
|
2243
|
+
* {field1: 2}
|
|
2244
|
+
* ]).exec().keys();
|
|
2245
|
+
* ```
|
|
2203
2246
|
* @param {T | T[]} rows Rows to be inserted into the slice
|
|
2204
2247
|
*/
|
|
2205
2248
|
insert(rows) {
|
|
@@ -2211,7 +2254,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2211
2254
|
}
|
|
2212
2255
|
/**
|
|
2213
2256
|
* Limit number of rows returned
|
|
2214
|
-
*
|
|
2257
|
+
* @example
|
|
2258
|
+
* ```ts
|
|
2259
|
+
* const rows: T[] = await new Slice<T>(12345).select().limit(10)
|
|
2260
|
+
* .exec().rows();
|
|
2261
|
+
* ```
|
|
2215
2262
|
* @param {number} num Number of rows to return
|
|
2216
2263
|
*/
|
|
2217
2264
|
limit(num) {
|
|
@@ -2219,17 +2266,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2219
2266
|
}
|
|
2220
2267
|
/**
|
|
2221
2268
|
* Add an 'OR' condition inside the where argument
|
|
2269
|
+
* @example
|
|
2270
|
+
* ```ts
|
|
2271
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2272
|
+
* .where('field1', '>', 1)
|
|
2273
|
+
* .or()
|
|
2274
|
+
* .where({field2: 2, field3: 3})
|
|
2275
|
+
* .or()
|
|
2276
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
2277
|
+
* .exec().rows();
|
|
2278
|
+
* ```
|
|
2222
2279
|
*/
|
|
2223
2280
|
or() {
|
|
2224
2281
|
var _a;
|
|
2225
|
-
if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or")
|
|
2226
|
-
|
|
2227
|
-
|
|
2282
|
+
if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") {
|
|
2283
|
+
this.request.where.push(null);
|
|
2284
|
+
return this;
|
|
2285
|
+
}
|
|
2286
|
+
if (this.request.where) this.request.where = ["$or", this.request.where, null];
|
|
2287
|
+
else this.request.where = ["$or", null];
|
|
2228
2288
|
return this;
|
|
2229
2289
|
}
|
|
2230
2290
|
/**
|
|
2231
2291
|
* Order rows by a field
|
|
2232
|
-
*
|
|
2292
|
+
* @example
|
|
2293
|
+
* ```ts
|
|
2294
|
+
* const rows: T[] = new Slice<T>(12345).select().order('field1', true) // true = ascending
|
|
2295
|
+
* .exec().rows();
|
|
2296
|
+
* ```
|
|
2233
2297
|
* @param {string} field property name
|
|
2234
2298
|
* @param {boolean} ascending Sort in ascending or descending order
|
|
2235
2299
|
*/
|
|
@@ -2240,7 +2304,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2240
2304
|
}
|
|
2241
2305
|
/**
|
|
2242
2306
|
* Set the request type to select
|
|
2243
|
-
*
|
|
2307
|
+
* @example
|
|
2308
|
+
* ```ts
|
|
2309
|
+
* const rows: T[] = new Slice<T>(12345).select().exec().rows();
|
|
2310
|
+
* const row: T = new Slice<T>(12345).select(id).exec().row();
|
|
2311
|
+
* ```
|
|
2244
2312
|
* @param {number | number[]} id ID(s) to select, leaving blank will return all rows
|
|
2245
2313
|
*/
|
|
2246
2314
|
select(id) {
|
|
@@ -2253,7 +2321,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2253
2321
|
}
|
|
2254
2322
|
/**
|
|
2255
2323
|
* Synchronize cache with server
|
|
2256
|
-
*
|
|
2324
|
+
* @example
|
|
2325
|
+
* ```ts
|
|
2326
|
+
* const slice: Slice = new Slice<T>(Slices.Contact);
|
|
2327
|
+
* slice.sync().subscribe((rows: T[]) => {});
|
|
2328
|
+
* ```
|
|
2257
2329
|
* @param {boolean} on Enable/disable events
|
|
2258
2330
|
* @return {BehaviorSubject<T[]>} Cache which can be subscribed to
|
|
2259
2331
|
*/
|
|
@@ -2273,7 +2345,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2273
2345
|
}
|
|
2274
2346
|
/**
|
|
2275
2347
|
* Set the request type to update
|
|
2276
|
-
*
|
|
2348
|
+
* @example
|
|
2349
|
+
* ```ts
|
|
2350
|
+
* const ids: number[] = await new Slice<Type>(12345).update([
|
|
2351
|
+
* {id: 1, field1: 1},
|
|
2352
|
+
* {id: 2, field1: 1}
|
|
2353
|
+
* ]).exec().keys();
|
|
2354
|
+
* ```
|
|
2277
2355
|
* @param {T | T[]} rows Rows to be updated, each row must have an ID
|
|
2278
2356
|
*/
|
|
2279
2357
|
update(rows) {
|
|
@@ -2284,17 +2362,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2284
2362
|
return this;
|
|
2285
2363
|
}
|
|
2286
2364
|
/**
|
|
2287
|
-
* Add where condition to request
|
|
2288
|
-
*
|
|
2289
|
-
*
|
|
2365
|
+
* Add where condition to request
|
|
2366
|
+
* @example
|
|
2367
|
+
* ```ts
|
|
2368
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2369
|
+
* .where('field1', '>', 1)
|
|
2370
|
+
* .where({field2: 2, field3: 3}) // Automatic AND
|
|
2371
|
+
* .or()
|
|
2372
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
2373
|
+
* .exec().rows();
|
|
2374
|
+
* ```
|
|
2290
2375
|
* @param {string | object} field property to compare or a map of equality comparisons
|
|
2291
2376
|
* @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
|
|
2292
2377
|
* @param {any} value value to compare against
|
|
2293
2378
|
*/
|
|
2294
2379
|
where(field, operator, value) {
|
|
2295
|
-
this.and();
|
|
2380
|
+
if (this.request.where && this.request.where[0] != "$or") this.and();
|
|
2296
2381
|
if (typeof field == "object") {
|
|
2297
|
-
Object.entries(field).forEach(([key, value2]) => this.
|
|
2382
|
+
Object.entries(field).forEach(([key, value2]) => this.where(key, "==", value2));
|
|
2298
2383
|
} else if (operator == null) {
|
|
2299
2384
|
throw new Error("Malformed where clause");
|
|
2300
2385
|
} else {
|
|
@@ -2324,7 +2409,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2324
2409
|
operator = "$mod";
|
|
2325
2410
|
break;
|
|
2326
2411
|
}
|
|
2327
|
-
this.request.where.
|
|
2412
|
+
if (!this.request.where) this.request.where = [operator, ["$field", field], value];
|
|
2413
|
+
else {
|
|
2414
|
+
if (this.request.where[0] == "$or") {
|
|
2415
|
+
const i = this.request.where.length - 1;
|
|
2416
|
+
if (this.request.where[i] == null) this.request.where[i] = [operator, ["$field", field], value];
|
|
2417
|
+
else {
|
|
2418
|
+
if (this.request.where[i][0] == "$and") this.request.where[i].push([operator, ["$field", field], value]);
|
|
2419
|
+
else this.request.where[i] = ["$and", this.request.where[i], [operator, ["$field", field], value]];
|
|
2420
|
+
}
|
|
2421
|
+
} else this.request.where.push([operator, ["$field", field], value]);
|
|
2422
|
+
}
|
|
2328
2423
|
}
|
|
2329
2424
|
return this;
|
|
2330
2425
|
}
|
|
@@ -2536,7 +2631,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2536
2631
|
method: "POST",
|
|
2537
2632
|
headers: clean({
|
|
2538
2633
|
Authorization: this.token ? `Bearer ${this.token}` : void 0,
|
|
2539
|
-
"Content-Type": "application/json"
|
|
2634
|
+
"Content-Type": "application/json",
|
|
2635
|
+
"X-Date-Return-Format": this.options.legacyDates ? void 0 : "ISO8601"
|
|
2540
2636
|
}),
|
|
2541
2637
|
body: JSON.stringify(Api.translateTokens(req))
|
|
2542
2638
|
}).then(async (resp) => {
|
package/dist/index.mjs
CHANGED
|
@@ -2125,7 +2125,11 @@ class Slice {
|
|
|
2125
2125
|
}
|
|
2126
2126
|
/**
|
|
2127
2127
|
* Whitelist and alias fields. Alias for the fields functions
|
|
2128
|
-
*
|
|
2128
|
+
* @example
|
|
2129
|
+
* ```ts
|
|
2130
|
+
* const id: {id: number, field2: any}[] = await new Slice<T>(12345)
|
|
2131
|
+
* .select().alias({id: 'id', field1: 'field2'}).exec().keys();
|
|
2132
|
+
* ```
|
|
2129
2133
|
* @param {object} aliasKeyVals List of properties to whitelist and what to rename them to
|
|
2130
2134
|
*/
|
|
2131
2135
|
alias(aliasKeyVals) {
|
|
@@ -2133,6 +2137,14 @@ class Slice {
|
|
|
2133
2137
|
}
|
|
2134
2138
|
/**
|
|
2135
2139
|
* Add an 'AND' condition inside the where argument
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```ts
|
|
2142
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2143
|
+
* .where('field1', '>', 1)
|
|
2144
|
+
* .and()
|
|
2145
|
+
* .where({field2: 2, field3: 3})
|
|
2146
|
+
* .exec().rows();
|
|
2147
|
+
* ```
|
|
2136
2148
|
*/
|
|
2137
2149
|
and() {
|
|
2138
2150
|
var _a;
|
|
@@ -2143,10 +2155,17 @@ class Slice {
|
|
|
2143
2155
|
}
|
|
2144
2156
|
/**
|
|
2145
2157
|
* Count the returned rows
|
|
2158
|
+
* @example
|
|
2159
|
+
* ```ts
|
|
2160
|
+
* const count = await new Slice(12345).count()
|
|
2161
|
+
* .where({field1: 1})
|
|
2162
|
+
* .exec().count();
|
|
2163
|
+
* ```
|
|
2164
|
+
* @param {object | string} arg Count argument
|
|
2146
2165
|
*/
|
|
2147
|
-
count(
|
|
2166
|
+
count(arg = "id") {
|
|
2148
2167
|
this.operation = "$/slice/report";
|
|
2149
|
-
this.request.fields = { count: ["$count", typeof
|
|
2168
|
+
this.request.fields = { count: ["$count", typeof arg == "object" ? arg : ["$field", arg]] };
|
|
2150
2169
|
return this;
|
|
2151
2170
|
}
|
|
2152
2171
|
/**
|
|
@@ -2158,7 +2177,10 @@ class Slice {
|
|
|
2158
2177
|
}
|
|
2159
2178
|
/**
|
|
2160
2179
|
* Set the request type to delete
|
|
2161
|
-
*
|
|
2180
|
+
* @example
|
|
2181
|
+
* ```ts
|
|
2182
|
+
* await new Slice(12345).delete(id).exec();
|
|
2183
|
+
* ```
|
|
2162
2184
|
* @param {number | number[]} id ID(s) to delete
|
|
2163
2185
|
*/
|
|
2164
2186
|
delete(id) {
|
|
@@ -2171,16 +2193,31 @@ class Slice {
|
|
|
2171
2193
|
}
|
|
2172
2194
|
/**
|
|
2173
2195
|
* Filter rows from slice based on an excel expression
|
|
2174
|
-
*
|
|
2175
|
-
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* ```ts
|
|
2198
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2199
|
+
* .excel('')
|
|
2200
|
+
* .exec().rows();
|
|
2201
|
+
* ```
|
|
2202
|
+
* @param formula Excel formula to use as where clause
|
|
2176
2203
|
*/
|
|
2177
|
-
excel(
|
|
2178
|
-
this.request.where
|
|
2204
|
+
excel(formula) {
|
|
2205
|
+
if (this.request.where && this.request.where[0] != "$or") this.and();
|
|
2206
|
+
if (!this.request.where) this.request.where = { "$excel": formula };
|
|
2207
|
+
else {
|
|
2208
|
+
if (this.request.where[0] == "$or") {
|
|
2209
|
+
const i = this.request.where.length - 1;
|
|
2210
|
+
if (this.request.where[i] == null) this.request.where[i] = { "$excel": formula };
|
|
2211
|
+
else {
|
|
2212
|
+
if (this.request.where[i][0] == "$and") this.request.where[i].push({ "$excel": formula });
|
|
2213
|
+
else this.request.where[i] = ["$and", this.request.where[i], { "$excel": formula }];
|
|
2214
|
+
}
|
|
2215
|
+
} else this.request.where.push({ "$excel": formula });
|
|
2216
|
+
}
|
|
2179
2217
|
return this;
|
|
2180
2218
|
}
|
|
2181
2219
|
/**
|
|
2182
2220
|
* Compile the request and send it
|
|
2183
|
-
*
|
|
2184
2221
|
* @param {ApiRequestOptions} options API Request options
|
|
2185
2222
|
* @return {SlicePromise<T>}
|
|
2186
2223
|
*/
|
|
@@ -2195,7 +2232,13 @@ class Slice {
|
|
|
2195
2232
|
}
|
|
2196
2233
|
/**
|
|
2197
2234
|
* Set the request type to insert
|
|
2198
|
-
*
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```ts
|
|
2237
|
+
* const id: number = await new Slice<T>(12345).insert([
|
|
2238
|
+
* {field1: 1},
|
|
2239
|
+
* {field1: 2}
|
|
2240
|
+
* ]).exec().keys();
|
|
2241
|
+
* ```
|
|
2199
2242
|
* @param {T | T[]} rows Rows to be inserted into the slice
|
|
2200
2243
|
*/
|
|
2201
2244
|
insert(rows) {
|
|
@@ -2207,7 +2250,11 @@ class Slice {
|
|
|
2207
2250
|
}
|
|
2208
2251
|
/**
|
|
2209
2252
|
* Limit number of rows returned
|
|
2210
|
-
*
|
|
2253
|
+
* @example
|
|
2254
|
+
* ```ts
|
|
2255
|
+
* const rows: T[] = await new Slice<T>(12345).select().limit(10)
|
|
2256
|
+
* .exec().rows();
|
|
2257
|
+
* ```
|
|
2211
2258
|
* @param {number} num Number of rows to return
|
|
2212
2259
|
*/
|
|
2213
2260
|
limit(num) {
|
|
@@ -2215,17 +2262,34 @@ class Slice {
|
|
|
2215
2262
|
}
|
|
2216
2263
|
/**
|
|
2217
2264
|
* Add an 'OR' condition inside the where argument
|
|
2265
|
+
* @example
|
|
2266
|
+
* ```ts
|
|
2267
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2268
|
+
* .where('field1', '>', 1)
|
|
2269
|
+
* .or()
|
|
2270
|
+
* .where({field2: 2, field3: 3})
|
|
2271
|
+
* .or()
|
|
2272
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
2273
|
+
* .exec().rows();
|
|
2274
|
+
* ```
|
|
2218
2275
|
*/
|
|
2219
2276
|
or() {
|
|
2220
2277
|
var _a;
|
|
2221
|
-
if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or")
|
|
2222
|
-
|
|
2223
|
-
|
|
2278
|
+
if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") {
|
|
2279
|
+
this.request.where.push(null);
|
|
2280
|
+
return this;
|
|
2281
|
+
}
|
|
2282
|
+
if (this.request.where) this.request.where = ["$or", this.request.where, null];
|
|
2283
|
+
else this.request.where = ["$or", null];
|
|
2224
2284
|
return this;
|
|
2225
2285
|
}
|
|
2226
2286
|
/**
|
|
2227
2287
|
* Order rows by a field
|
|
2228
|
-
*
|
|
2288
|
+
* @example
|
|
2289
|
+
* ```ts
|
|
2290
|
+
* const rows: T[] = new Slice<T>(12345).select().order('field1', true) // true = ascending
|
|
2291
|
+
* .exec().rows();
|
|
2292
|
+
* ```
|
|
2229
2293
|
* @param {string} field property name
|
|
2230
2294
|
* @param {boolean} ascending Sort in ascending or descending order
|
|
2231
2295
|
*/
|
|
@@ -2236,7 +2300,11 @@ class Slice {
|
|
|
2236
2300
|
}
|
|
2237
2301
|
/**
|
|
2238
2302
|
* Set the request type to select
|
|
2239
|
-
*
|
|
2303
|
+
* @example
|
|
2304
|
+
* ```ts
|
|
2305
|
+
* const rows: T[] = new Slice<T>(12345).select().exec().rows();
|
|
2306
|
+
* const row: T = new Slice<T>(12345).select(id).exec().row();
|
|
2307
|
+
* ```
|
|
2240
2308
|
* @param {number | number[]} id ID(s) to select, leaving blank will return all rows
|
|
2241
2309
|
*/
|
|
2242
2310
|
select(id) {
|
|
@@ -2249,7 +2317,11 @@ class Slice {
|
|
|
2249
2317
|
}
|
|
2250
2318
|
/**
|
|
2251
2319
|
* Synchronize cache with server
|
|
2252
|
-
*
|
|
2320
|
+
* @example
|
|
2321
|
+
* ```ts
|
|
2322
|
+
* const slice: Slice = new Slice<T>(Slices.Contact);
|
|
2323
|
+
* slice.sync().subscribe((rows: T[]) => {});
|
|
2324
|
+
* ```
|
|
2253
2325
|
* @param {boolean} on Enable/disable events
|
|
2254
2326
|
* @return {BehaviorSubject<T[]>} Cache which can be subscribed to
|
|
2255
2327
|
*/
|
|
@@ -2269,7 +2341,13 @@ class Slice {
|
|
|
2269
2341
|
}
|
|
2270
2342
|
/**
|
|
2271
2343
|
* Set the request type to update
|
|
2272
|
-
*
|
|
2344
|
+
* @example
|
|
2345
|
+
* ```ts
|
|
2346
|
+
* const ids: number[] = await new Slice<Type>(12345).update([
|
|
2347
|
+
* {id: 1, field1: 1},
|
|
2348
|
+
* {id: 2, field1: 1}
|
|
2349
|
+
* ]).exec().keys();
|
|
2350
|
+
* ```
|
|
2273
2351
|
* @param {T | T[]} rows Rows to be updated, each row must have an ID
|
|
2274
2352
|
*/
|
|
2275
2353
|
update(rows) {
|
|
@@ -2280,17 +2358,24 @@ class Slice {
|
|
|
2280
2358
|
return this;
|
|
2281
2359
|
}
|
|
2282
2360
|
/**
|
|
2283
|
-
* Add where condition to request
|
|
2284
|
-
*
|
|
2285
|
-
*
|
|
2361
|
+
* Add where condition to request
|
|
2362
|
+
* @example
|
|
2363
|
+
* ```ts
|
|
2364
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
2365
|
+
* .where('field1', '>', 1)
|
|
2366
|
+
* .where({field2: 2, field3: 3}) // Automatic AND
|
|
2367
|
+
* .or()
|
|
2368
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
2369
|
+
* .exec().rows();
|
|
2370
|
+
* ```
|
|
2286
2371
|
* @param {string | object} field property to compare or a map of equality comparisons
|
|
2287
2372
|
* @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
|
|
2288
2373
|
* @param {any} value value to compare against
|
|
2289
2374
|
*/
|
|
2290
2375
|
where(field, operator, value) {
|
|
2291
|
-
this.and();
|
|
2376
|
+
if (this.request.where && this.request.where[0] != "$or") this.and();
|
|
2292
2377
|
if (typeof field == "object") {
|
|
2293
|
-
Object.entries(field).forEach(([key, value2]) => this.
|
|
2378
|
+
Object.entries(field).forEach(([key, value2]) => this.where(key, "==", value2));
|
|
2294
2379
|
} else if (operator == null) {
|
|
2295
2380
|
throw new Error("Malformed where clause");
|
|
2296
2381
|
} else {
|
|
@@ -2320,7 +2405,17 @@ class Slice {
|
|
|
2320
2405
|
operator = "$mod";
|
|
2321
2406
|
break;
|
|
2322
2407
|
}
|
|
2323
|
-
this.request.where.
|
|
2408
|
+
if (!this.request.where) this.request.where = [operator, ["$field", field], value];
|
|
2409
|
+
else {
|
|
2410
|
+
if (this.request.where[0] == "$or") {
|
|
2411
|
+
const i = this.request.where.length - 1;
|
|
2412
|
+
if (this.request.where[i] == null) this.request.where[i] = [operator, ["$field", field], value];
|
|
2413
|
+
else {
|
|
2414
|
+
if (this.request.where[i][0] == "$and") this.request.where[i].push([operator, ["$field", field], value]);
|
|
2415
|
+
else this.request.where[i] = ["$and", this.request.where[i], [operator, ["$field", field], value]];
|
|
2416
|
+
}
|
|
2417
|
+
} else this.request.where.push([operator, ["$field", field], value]);
|
|
2418
|
+
}
|
|
2324
2419
|
}
|
|
2325
2420
|
return this;
|
|
2326
2421
|
}
|
|
@@ -2532,7 +2627,8 @@ class Api {
|
|
|
2532
2627
|
method: "POST",
|
|
2533
2628
|
headers: clean({
|
|
2534
2629
|
Authorization: this.token ? `Bearer ${this.token}` : void 0,
|
|
2535
|
-
"Content-Type": "application/json"
|
|
2630
|
+
"Content-Type": "application/json",
|
|
2631
|
+
"X-Date-Return-Format": this.options.legacyDates ? void 0 : "ISO8601"
|
|
2536
2632
|
}),
|
|
2537
2633
|
body: JSON.stringify(Api.translateTokens(req))
|
|
2538
2634
|
}).then(async (resp) => {
|
package/dist/slice.d.ts
CHANGED
|
@@ -115,7 +115,11 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
115
115
|
constructor(slice: number | string, api: Api);
|
|
116
116
|
/**
|
|
117
117
|
* Whitelist and alias fields. Alias for the fields functions
|
|
118
|
-
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const id: {id: number, field2: any}[] = await new Slice<T>(12345)
|
|
121
|
+
* .select().alias({id: 'id', field1: 'field2'}).exec().keys();
|
|
122
|
+
* ```
|
|
119
123
|
* @param {object} aliasKeyVals List of properties to whitelist and what to rename them to
|
|
120
124
|
*/
|
|
121
125
|
alias(aliasKeyVals: {
|
|
@@ -123,38 +127,64 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
123
127
|
}): Slice<T>;
|
|
124
128
|
/**
|
|
125
129
|
* Add an 'AND' condition inside the where argument
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
133
|
+
* .where('field1', '>', 1)
|
|
134
|
+
* .and()
|
|
135
|
+
* .where({field2: 2, field3: 3})
|
|
136
|
+
* .exec().rows();
|
|
137
|
+
* ```
|
|
126
138
|
*/
|
|
127
139
|
and(): this;
|
|
128
140
|
/**
|
|
129
141
|
* Count the returned rows
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const count = await new Slice(12345).count()
|
|
145
|
+
* .where({field1: 1})
|
|
146
|
+
* .exec().count();
|
|
147
|
+
* ```
|
|
148
|
+
* @param {object | string} arg Count argument
|
|
130
149
|
*/
|
|
131
|
-
count(
|
|
150
|
+
count(arg?: object | string): this;
|
|
132
151
|
/**
|
|
133
152
|
* Output the formed request to the console for inspection
|
|
134
153
|
*/
|
|
135
154
|
debug(): this;
|
|
136
155
|
/**
|
|
137
156
|
* Set the request type to delete
|
|
138
|
-
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* await new Slice(12345).delete(id).exec();
|
|
160
|
+
* ```
|
|
139
161
|
* @param {number | number[]} id ID(s) to delete
|
|
140
162
|
*/
|
|
141
163
|
delete(id?: number | number[]): Slice<T>;
|
|
142
164
|
/**
|
|
143
165
|
* Filter rows from slice based on an excel expression
|
|
144
|
-
*
|
|
145
|
-
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
169
|
+
* .excel('')
|
|
170
|
+
* .exec().rows();
|
|
171
|
+
* ```
|
|
172
|
+
* @param formula Excel formula to use as where clause
|
|
146
173
|
*/
|
|
147
|
-
excel(
|
|
174
|
+
excel(formula: string): Slice<T>;
|
|
148
175
|
/**
|
|
149
176
|
* Compile the request and send it
|
|
150
|
-
*
|
|
151
177
|
* @param {ApiRequestOptions} options API Request options
|
|
152
178
|
* @return {SlicePromise<T>}
|
|
153
179
|
*/
|
|
154
180
|
exec(options?: ApiRequestOptions): SlicePromise<T>;
|
|
155
181
|
/**
|
|
156
182
|
* Whitelist fields by passing an array of keys or alias fields by using a map
|
|
157
|
-
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const id: {id: number, field1: any}[] = await new Slice<T>(12345)
|
|
186
|
+
* .select().fields(['id', 'field1']).exec().keys();
|
|
187
|
+
* ```
|
|
158
188
|
* @param {object} whitelist Either a list of keys to whitelist or a map of keys to rename
|
|
159
189
|
*/
|
|
160
190
|
fields(whitelist: string[]): Slice<T>;
|
|
@@ -163,50 +193,95 @@ export declare class Slice<T extends SliceMeta> {
|
|
|
163
193
|
}): Slice<T>;
|
|
164
194
|
/**
|
|
165
195
|
* Set the request type to insert
|
|
166
|
-
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* const id: number = await new Slice<T>(12345).insert([
|
|
199
|
+
* {field1: 1},
|
|
200
|
+
* {field1: 2}
|
|
201
|
+
* ]).exec().keys();
|
|
202
|
+
* ```
|
|
167
203
|
* @param {T | T[]} rows Rows to be inserted into the slice
|
|
168
204
|
*/
|
|
169
205
|
insert(rows: T | T[]): Slice<T>;
|
|
170
206
|
/**
|
|
171
207
|
* Limit number of rows returned
|
|
172
|
-
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const rows: T[] = await new Slice<T>(12345).select().limit(10)
|
|
211
|
+
* .exec().rows();
|
|
212
|
+
* ```
|
|
173
213
|
* @param {number} num Number of rows to return
|
|
174
214
|
*/
|
|
175
215
|
limit(num: number): void;
|
|
176
216
|
/**
|
|
177
217
|
* Add an 'OR' condition inside the where argument
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
221
|
+
* .where('field1', '>', 1)
|
|
222
|
+
* .or()
|
|
223
|
+
* .where({field2: 2, field3: 3})
|
|
224
|
+
* .or()
|
|
225
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
226
|
+
* .exec().rows();
|
|
227
|
+
* ```
|
|
178
228
|
*/
|
|
179
229
|
or(): this;
|
|
180
230
|
/**
|
|
181
231
|
* Order rows by a field
|
|
182
|
-
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* const rows: T[] = new Slice<T>(12345).select().order('field1', true) // true = ascending
|
|
235
|
+
* .exec().rows();
|
|
236
|
+
* ```
|
|
183
237
|
* @param {string} field property name
|
|
184
238
|
* @param {boolean} ascending Sort in ascending or descending order
|
|
185
239
|
*/
|
|
186
240
|
order(field: string, ascending?: boolean): Slice<T>;
|
|
187
241
|
/**
|
|
188
242
|
* Set the request type to select
|
|
189
|
-
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const rows: T[] = new Slice<T>(12345).select().exec().rows();
|
|
246
|
+
* const row: T = new Slice<T>(12345).select(id).exec().row();
|
|
247
|
+
* ```
|
|
190
248
|
* @param {number | number[]} id ID(s) to select, leaving blank will return all rows
|
|
191
249
|
*/
|
|
192
250
|
select(id?: number | number[]): Slice<T>;
|
|
193
251
|
/**
|
|
194
252
|
* Synchronize cache with server
|
|
195
|
-
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* const slice: Slice = new Slice<T>(Slices.Contact);
|
|
256
|
+
* slice.sync().subscribe((rows: T[]) => {});
|
|
257
|
+
* ```
|
|
196
258
|
* @param {boolean} on Enable/disable events
|
|
197
259
|
* @return {BehaviorSubject<T[]>} Cache which can be subscribed to
|
|
198
260
|
*/
|
|
199
261
|
sync(on?: boolean): BehaviorSubject<T[]> | undefined;
|
|
200
262
|
/**
|
|
201
263
|
* Set the request type to update
|
|
202
|
-
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* const ids: number[] = await new Slice<Type>(12345).update([
|
|
267
|
+
* {id: 1, field1: 1},
|
|
268
|
+
* {id: 2, field1: 1}
|
|
269
|
+
* ]).exec().keys();
|
|
270
|
+
* ```
|
|
203
271
|
* @param {T | T[]} rows Rows to be updated, each row must have an ID
|
|
204
272
|
*/
|
|
205
273
|
update(rows: T | T[]): this;
|
|
206
274
|
/**
|
|
207
|
-
* Add where condition to request
|
|
208
|
-
*
|
|
209
|
-
*
|
|
275
|
+
* Add where condition to request
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* const rows: T[] = await new Slice<T>(12345).select()
|
|
279
|
+
* .where('field1', '>', 1)
|
|
280
|
+
* .where({field2: 2, field3: 3}) // Automatic AND
|
|
281
|
+
* .or()
|
|
282
|
+
* .where(['$gt', ['$field', field4], 4)
|
|
283
|
+
* .exec().rows();
|
|
284
|
+
* ```
|
|
210
285
|
* @param {string | object} field property to compare or a map of equality comparisons
|
|
211
286
|
* @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
|
|
212
287
|
* @param {any} value value to compare against
|
package/dist/slice.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../src/slice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAmB,WAAW,EAAC,MAAM,UAAU,CAAC;AAEvD,MAAM,WAAW,SAAS;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,UAAU,CAAC,EAAE,M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AC,OAAO,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAC,CAAC;IAMlD;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAQzD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IAQ/B;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB;;;;;;;;;;;;OAYG;IACH,EAAE;IAUF;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAMhD;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IASxC;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,UAAO;IAoBd;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;IAQpB;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;CA+CvE"}
|
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.9.
|
|
5
|
+
"version": "0.9.7",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|