@auxilium/datalynk-client 1.0.18 → 1.0.20
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 +4 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/files.d.ts +0 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/index.cjs +17 -14
- package/dist/index.mjs +17 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -389,16 +389,15 @@ Uploading files to datalynk is done by first uploading the file as form-data & t
|
|
|
389
389
|
// Get files from file input
|
|
390
390
|
const files = document.querySelector('#upload').files;
|
|
391
391
|
|
|
392
|
-
// Upload file
|
|
392
|
+
// Upload a file & associate it with a record in one call
|
|
393
|
+
api.files.upload(files, {slice: 12345, row: 1234, field: 'abc'});
|
|
394
|
+
// OR upload a file on its own
|
|
393
395
|
api.files.upload(files).then(uploaded => {
|
|
394
|
-
// Associate with record
|
|
396
|
+
// Associate file with a record manually
|
|
395
397
|
const slice = 12345, row: 123;
|
|
396
398
|
api.files.associate(uploaded.map(r => r.id), slice, row, 'field');
|
|
397
399
|
});
|
|
398
400
|
|
|
399
|
-
// OR do it all at once
|
|
400
|
-
api.files.upload(files, {slice: 12345, row: 1234, field: 'abc'});
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
-
|
|
404
403
|
</details>
|
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,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,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
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,KAAK;IACL,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,GAAG;IAErC;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9G,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG;QAAC,qBAAqB,EAAE;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,EAAE,CAAA;SAAC,CAAA;KAAC;IAOrL;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM;IAI9C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,EAAE,EAAE,SAAS,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAuB5I"}
|
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
36
36
|
return value;
|
|
37
37
|
}, space);
|
|
38
38
|
}
|
|
39
|
+
function makeArray(value) {
|
|
40
|
+
return Array.isArray(value) ? value : [value];
|
|
41
|
+
}
|
|
39
42
|
function contrast(background) {
|
|
40
43
|
const exploded = background == null ? void 0 : background.match(background.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
|
|
41
44
|
if (!exploded || (exploded == null ? void 0 : exploded.length) < 3) return "black";
|
|
@@ -1994,9 +1997,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1994
1997
|
}
|
|
1995
1998
|
class Files {
|
|
1996
1999
|
constructor(api) {
|
|
1997
|
-
__publicField(this, "url");
|
|
1998
2000
|
this.api = api;
|
|
1999
|
-
this.url = `${this.api.url}file`;
|
|
2000
2001
|
}
|
|
2001
2002
|
associate(fileIds, slice, row, field, execute = true) {
|
|
2002
2003
|
const req = { [`${execute ? "!" : "$"}/tools/file/update`]: { slice, row, field, ids: fileIds } };
|
|
@@ -2011,7 +2012,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2011
2012
|
* @return {string} URL file can be viewed at
|
|
2012
2013
|
*/
|
|
2013
2014
|
get(id, ignoreToken) {
|
|
2014
|
-
return `${this.url}?id=${id}${ignoreToken ? "" : `&token=${this.api.token}`}`;
|
|
2015
|
+
return `${this.api.url}file?id=${id}${ignoreToken ? "" : `&token=${this.api.token}`}`;
|
|
2015
2016
|
}
|
|
2016
2017
|
/**
|
|
2017
2018
|
* Upload file(s) to the API & optionally associate them with a row
|
|
@@ -2020,20 +2021,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2020
2021
|
* @param {{slice: number, row: any, field: string, pk?: string}} associate Row to associate with
|
|
2021
2022
|
*/
|
|
2022
2023
|
upload(files, associate) {
|
|
2023
|
-
let f =
|
|
2024
|
-
if (files instanceof FileList) f = Array.from(files);
|
|
2025
|
-
else f = Array.isArray(files) ? files : [files];
|
|
2024
|
+
let f = files instanceof FileList ? Array.from(files) : makeArray(files);
|
|
2026
2025
|
return Promise.all(f.map((file) => {
|
|
2027
2026
|
const data = new FormData();
|
|
2028
|
-
data.append("", file, file.name);
|
|
2029
|
-
return fetch(this.url
|
|
2027
|
+
data.append("uploadedfiles[]", file, file.name);
|
|
2028
|
+
return fetch(`${this.api.url}upload.php`, {
|
|
2030
2029
|
method: "POST",
|
|
2031
2030
|
headers: clean({ "Authorization": this.api.token ? `Bearer ${this.api.token}` : "" }),
|
|
2032
2031
|
body: data
|
|
2033
2032
|
}).then(async (resp) => {
|
|
2034
2033
|
const data2 = await resp.json().catch(() => ({}));
|
|
2035
2034
|
if (!resp.ok || data2["error"]) throw Object.assign(errorFromCode(resp.status, data2.error) || {}, data2);
|
|
2036
|
-
return
|
|
2035
|
+
return data2.files.uploadedfiles[0];
|
|
2037
2036
|
});
|
|
2038
2037
|
})).then(async (files2) => {
|
|
2039
2038
|
if (associate) {
|
|
@@ -2696,7 +2695,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2696
2695
|
} });
|
|
2697
2696
|
}
|
|
2698
2697
|
}
|
|
2699
|
-
const version = "1.0.
|
|
2698
|
+
const version = "1.0.20";
|
|
2700
2699
|
class Api {
|
|
2701
2700
|
/**
|
|
2702
2701
|
* Connect to Datalynk & send requests
|
|
@@ -2726,15 +2725,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2726
2725
|
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2727
2726
|
/** Helpers */
|
|
2728
2727
|
/** Authentication */
|
|
2729
|
-
__publicField(this, "auth"
|
|
2728
|
+
__publicField(this, "auth");
|
|
2730
2729
|
/** File */
|
|
2731
|
-
__publicField(this, "files"
|
|
2730
|
+
__publicField(this, "files");
|
|
2732
2731
|
/** PDF */
|
|
2733
|
-
__publicField(this, "pdf"
|
|
2732
|
+
__publicField(this, "pdf");
|
|
2734
2733
|
/** Socket */
|
|
2735
2734
|
__publicField(this, "socket");
|
|
2736
2735
|
/** Superuser */
|
|
2737
|
-
__publicField(this, "superuser"
|
|
2736
|
+
__publicField(this, "superuser");
|
|
2738
2737
|
this.options = options;
|
|
2739
2738
|
this.url = `${new URL(url).origin}/api/`;
|
|
2740
2739
|
this.options = {
|
|
@@ -2752,6 +2751,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2752
2751
|
});
|
|
2753
2752
|
}
|
|
2754
2753
|
Slice.api = this;
|
|
2754
|
+
this.auth = new Auth(this);
|
|
2755
|
+
this.files = new Files(this);
|
|
2756
|
+
this.pdf = new Pdf(this);
|
|
2757
|
+
this.superuser = new Superuser(this);
|
|
2755
2758
|
this.socket = new Socket(this, { url: options.socket });
|
|
2756
2759
|
}
|
|
2757
2760
|
get token() {
|
package/dist/index.mjs
CHANGED
|
@@ -32,6 +32,9 @@ function JSONSanitize(obj, space) {
|
|
|
32
32
|
return value;
|
|
33
33
|
}, space);
|
|
34
34
|
}
|
|
35
|
+
function makeArray(value) {
|
|
36
|
+
return Array.isArray(value) ? value : [value];
|
|
37
|
+
}
|
|
35
38
|
function contrast(background) {
|
|
36
39
|
const exploded = background == null ? void 0 : background.match(background.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
|
|
37
40
|
if (!exploded || (exploded == null ? void 0 : exploded.length) < 3) return "black";
|
|
@@ -1990,9 +1993,7 @@ class Auth {
|
|
|
1990
1993
|
}
|
|
1991
1994
|
class Files {
|
|
1992
1995
|
constructor(api) {
|
|
1993
|
-
__publicField(this, "url");
|
|
1994
1996
|
this.api = api;
|
|
1995
|
-
this.url = `${this.api.url}file`;
|
|
1996
1997
|
}
|
|
1997
1998
|
associate(fileIds, slice, row, field, execute = true) {
|
|
1998
1999
|
const req = { [`${execute ? "!" : "$"}/tools/file/update`]: { slice, row, field, ids: fileIds } };
|
|
@@ -2007,7 +2008,7 @@ class Files {
|
|
|
2007
2008
|
* @return {string} URL file can be viewed at
|
|
2008
2009
|
*/
|
|
2009
2010
|
get(id, ignoreToken) {
|
|
2010
|
-
return `${this.url}?id=${id}${ignoreToken ? "" : `&token=${this.api.token}`}`;
|
|
2011
|
+
return `${this.api.url}file?id=${id}${ignoreToken ? "" : `&token=${this.api.token}`}`;
|
|
2011
2012
|
}
|
|
2012
2013
|
/**
|
|
2013
2014
|
* Upload file(s) to the API & optionally associate them with a row
|
|
@@ -2016,20 +2017,18 @@ class Files {
|
|
|
2016
2017
|
* @param {{slice: number, row: any, field: string, pk?: string}} associate Row to associate with
|
|
2017
2018
|
*/
|
|
2018
2019
|
upload(files, associate) {
|
|
2019
|
-
let f =
|
|
2020
|
-
if (files instanceof FileList) f = Array.from(files);
|
|
2021
|
-
else f = Array.isArray(files) ? files : [files];
|
|
2020
|
+
let f = files instanceof FileList ? Array.from(files) : makeArray(files);
|
|
2022
2021
|
return Promise.all(f.map((file) => {
|
|
2023
2022
|
const data = new FormData();
|
|
2024
|
-
data.append("", file, file.name);
|
|
2025
|
-
return fetch(this.url
|
|
2023
|
+
data.append("uploadedfiles[]", file, file.name);
|
|
2024
|
+
return fetch(`${this.api.url}upload.php`, {
|
|
2026
2025
|
method: "POST",
|
|
2027
2026
|
headers: clean({ "Authorization": this.api.token ? `Bearer ${this.api.token}` : "" }),
|
|
2028
2027
|
body: data
|
|
2029
2028
|
}).then(async (resp) => {
|
|
2030
2029
|
const data2 = await resp.json().catch(() => ({}));
|
|
2031
2030
|
if (!resp.ok || data2["error"]) throw Object.assign(errorFromCode(resp.status, data2.error) || {}, data2);
|
|
2032
|
-
return
|
|
2031
|
+
return data2.files.uploadedfiles[0];
|
|
2033
2032
|
});
|
|
2034
2033
|
})).then(async (files2) => {
|
|
2035
2034
|
if (associate) {
|
|
@@ -2692,7 +2691,7 @@ class Superuser {
|
|
|
2692
2691
|
} });
|
|
2693
2692
|
}
|
|
2694
2693
|
}
|
|
2695
|
-
const version = "1.0.
|
|
2694
|
+
const version = "1.0.20";
|
|
2696
2695
|
class Api {
|
|
2697
2696
|
/**
|
|
2698
2697
|
* Connect to Datalynk & send requests
|
|
@@ -2722,15 +2721,15 @@ class Api {
|
|
|
2722
2721
|
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2723
2722
|
/** Helpers */
|
|
2724
2723
|
/** Authentication */
|
|
2725
|
-
__publicField(this, "auth"
|
|
2724
|
+
__publicField(this, "auth");
|
|
2726
2725
|
/** File */
|
|
2727
|
-
__publicField(this, "files"
|
|
2726
|
+
__publicField(this, "files");
|
|
2728
2727
|
/** PDF */
|
|
2729
|
-
__publicField(this, "pdf"
|
|
2728
|
+
__publicField(this, "pdf");
|
|
2730
2729
|
/** Socket */
|
|
2731
2730
|
__publicField(this, "socket");
|
|
2732
2731
|
/** Superuser */
|
|
2733
|
-
__publicField(this, "superuser"
|
|
2732
|
+
__publicField(this, "superuser");
|
|
2734
2733
|
this.options = options;
|
|
2735
2734
|
this.url = `${new URL(url).origin}/api/`;
|
|
2736
2735
|
this.options = {
|
|
@@ -2748,6 +2747,10 @@ class Api {
|
|
|
2748
2747
|
});
|
|
2749
2748
|
}
|
|
2750
2749
|
Slice.api = this;
|
|
2750
|
+
this.auth = new Auth(this);
|
|
2751
|
+
this.files = new Files(this);
|
|
2752
|
+
this.pdf = new Pdf(this);
|
|
2753
|
+
this.superuser = new Superuser(this);
|
|
2751
2754
|
this.socket = new Socket(this, { url: options.socket });
|
|
2752
2755
|
}
|
|
2753
2756
|
get token() {
|
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": "1.0.
|
|
5
|
+
"version": "1.0.20",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"watch": "vite build --watch"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ztimson/node-utils": "1.0.
|
|
28
|
+
"@ztimson/node-utils": "1.0.2",
|
|
29
29
|
"@ztimson/utils": "0.25.7",
|
|
30
30
|
"rxjs": "^7.8.2"
|
|
31
31
|
},
|