@aneuhold/core-ts-api-lib 2.0.2 → 2.0.3
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/lib/services/DOFunctionService/DOFunction.d.ts +3 -3
- package/lib/services/DOFunctionService/DOFunction.d.ts.map +1 -1
- package/lib/services/DOFunctionService/DOFunction.js +8 -16
- package/lib/services/DOFunctionService/DOFunction.js.map +1 -1
- package/lib/services/DOFunctionService/DOFunction.ts +10 -15
- package/package.json +1 -1
|
@@ -82,11 +82,11 @@ export default abstract class DOFunction<TInput extends DOFunctionInput, TOutput
|
|
|
82
82
|
*/
|
|
83
83
|
call(input: TInput): Promise<DOFunctionCallOutput<TOutput>>;
|
|
84
84
|
/**
|
|
85
|
-
* Decodes an {@link
|
|
85
|
+
* Decodes an {@link ArrayBuffer} into a {@link DOFunctionCallOutput}.
|
|
86
86
|
*
|
|
87
|
-
* @param
|
|
87
|
+
* @param buffer - The buffer to decode.
|
|
88
88
|
* @returns The decoded output.
|
|
89
89
|
*/
|
|
90
|
-
private
|
|
90
|
+
private decodeArrayBuffer;
|
|
91
91
|
}
|
|
92
92
|
//# sourceMappingURL=DOFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOFunction.d.ts","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,EAAE;QACJ;;;WAGG;QACH,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,cAAc,EAAE,0BAA0B,CAAC;KAC5C,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,gBAAgB;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,UAAU,CACtC,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB;IAEhC;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,SAAS;IAIT;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB;;;;;;;;OAQG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"DOFunction.d.ts","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,EAAE;QACJ;;;WAGG;QACH,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,cAAc,EAAE,0BAA0B,CAAC;KAC5C,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,gBAAgB;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,UAAU,CACtC,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB;IAEhC;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,SAAS;IAIT;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB;;;;;;;;OAQG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAgBjE;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -39,34 +39,26 @@ export default class DOFunction {
|
|
|
39
39
|
if (!this.url) {
|
|
40
40
|
throw new Error(`${this.functionName} URL is not set`);
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
const base64Input = Buffer.from(serializedInput).toString('base64');
|
|
44
|
-
const response = await fetch(this.url, {
|
|
42
|
+
const result = await fetch(this.url, {
|
|
45
43
|
method: 'POST',
|
|
46
44
|
headers: {
|
|
47
45
|
'Content-Type': 'application/octet-stream'
|
|
48
46
|
},
|
|
49
47
|
// It isn't clear why this works by itself. It comes in to the function
|
|
50
48
|
// as a base64 string.
|
|
51
|
-
body:
|
|
49
|
+
body: BSON.serialize(input)
|
|
52
50
|
});
|
|
53
|
-
return this.
|
|
51
|
+
return this.decodeArrayBuffer(await result.arrayBuffer());
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
56
|
-
* Decodes an {@link
|
|
54
|
+
* Decodes an {@link ArrayBuffer} into a {@link DOFunctionCallOutput}.
|
|
57
55
|
*
|
|
58
|
-
* @param
|
|
56
|
+
* @param buffer - The buffer to decode.
|
|
59
57
|
* @returns The decoded output.
|
|
60
58
|
*/
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
return BSON.deserialize(buffer);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
console.error('Deserialization error:', error);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
59
|
+
decodeArrayBuffer(buffer) {
|
|
60
|
+
const bytes = new Uint8Array(buffer);
|
|
61
|
+
return BSON.deserialize(bytes);
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
64
|
//# sourceMappingURL=DOFunction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOFunction.js","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAyD5B;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAgB,UAAU;IAItC;;OAEG;IACO,GAAG,CAAU;IAEb,YAAY,CAAS;IAE/B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,iBAAiB,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,
|
|
1
|
+
{"version":3,"file":"DOFunction.js","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAyD5B;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAgB,UAAU;IAItC;;OAEG;IACO,GAAG,CAAU;IAEb,YAAY,CAAS;IAE/B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,iBAAiB,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,0BAA0B;aAC3C;YACD,uEAAuE;YACvE,sBAAsB;YACtB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CACvB,MAAmB;QAEnB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAkC,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -102,33 +102,28 @@ export default abstract class DOFunction<
|
|
|
102
102
|
if (!this.url) {
|
|
103
103
|
throw new Error(`${this.functionName} URL is not set`);
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
const base64Input = Buffer.from(serializedInput).toString('base64');
|
|
107
|
-
const response = await fetch(this.url, {
|
|
105
|
+
const result = await fetch(this.url, {
|
|
108
106
|
method: 'POST',
|
|
109
107
|
headers: {
|
|
110
108
|
'Content-Type': 'application/octet-stream'
|
|
111
109
|
},
|
|
112
110
|
// It isn't clear why this works by itself. It comes in to the function
|
|
113
111
|
// as a base64 string.
|
|
114
|
-
body:
|
|
112
|
+
body: BSON.serialize(input)
|
|
115
113
|
});
|
|
116
|
-
return this.
|
|
114
|
+
return this.decodeArrayBuffer(await result.arrayBuffer());
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
/**
|
|
120
|
-
* Decodes an {@link
|
|
118
|
+
* Decodes an {@link ArrayBuffer} into a {@link DOFunctionCallOutput}.
|
|
121
119
|
*
|
|
122
|
-
* @param
|
|
120
|
+
* @param buffer - The buffer to decode.
|
|
123
121
|
* @returns The decoded output.
|
|
124
122
|
*/
|
|
125
|
-
private
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
console.error('Deserialization error:', error);
|
|
131
|
-
throw error;
|
|
132
|
-
}
|
|
123
|
+
private decodeArrayBuffer(
|
|
124
|
+
buffer: ArrayBuffer
|
|
125
|
+
): DOFunctionCallOutput<TOutput> {
|
|
126
|
+
const bytes = new Uint8Array(buffer);
|
|
127
|
+
return BSON.deserialize(bytes) as DOFunctionCallOutput<TOutput>;
|
|
133
128
|
}
|
|
134
129
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@aneuhold/core-ts-api-lib",
|
|
3
3
|
"author": "Anton G. Neuhold Jr.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.3",
|
|
6
6
|
"description": "A library for interacting with the backend and defining the backend API for personal projects.",
|
|
7
7
|
"packageManager": "yarn@4.5.1",
|
|
8
8
|
"type": "module",
|