Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
23c03fd623 | |||
cab2d8aa2e | |||
1f57f1397c | |||
8a9c2c1505 | |||
b003da7f59 | |||
735890bc3d | |||
69035f49c8 | |||
5ec20ee526 | |||
8b811ffd6b | |||
35df3697c7 | |||
8b4befc828 | |||
77dddd9157 | |||
737f413324 | |||
e613937c43 | |||
9c66752f8b | |||
5c6922c710 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@api.global/typedrequest",
|
||||
"version": "3.0.11",
|
||||
"version": "3.0.19",
|
||||
"private": false,
|
||||
"description": "make typed requests towards apis",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -14,7 +14,7 @@
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@api.global/typedserver": "^3.0.25",
|
||||
"@api.global/typedserver": "^3.0.27",
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
@ -30,7 +30,7 @@
|
||||
"@push.rocks/smartbuffer": "^1.0.7",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/webrequest": "^3.0.34",
|
||||
"@push.rocks/webrequest": "^3.0.35",
|
||||
"@push.rocks/webstream": "^1.0.8"
|
||||
},
|
||||
"files": [
|
||||
|
81
pnpm-lock.yaml
generated
81
pnpm-lock.yaml
generated
@ -24,16 +24,16 @@ dependencies:
|
||||
specifier: ^4.0.3
|
||||
version: 4.0.3
|
||||
'@push.rocks/webrequest':
|
||||
specifier: ^3.0.34
|
||||
version: 3.0.34
|
||||
specifier: ^3.0.35
|
||||
version: 3.0.35
|
||||
'@push.rocks/webstream':
|
||||
specifier: ^1.0.8
|
||||
version: 1.0.8
|
||||
|
||||
devDependencies:
|
||||
'@api.global/typedserver':
|
||||
specifier: ^3.0.25
|
||||
version: 3.0.25
|
||||
specifier: ^3.0.27
|
||||
version: 3.0.27
|
||||
'@git.zone/tsbuild':
|
||||
specifier: ^2.1.72
|
||||
version: 2.1.72
|
||||
@ -61,8 +61,8 @@ packages:
|
||||
/@api.global/typedrequest-interfaces@3.0.18:
|
||||
resolution: {integrity: sha512-O/AdHnk9NDcBfb/Qcpi3Bq/7I6uAJHXfIT5peeKODvLUYysmuxG/c3t9NWQvfSOXQUKnVKb0WrCGjraOL7Pyww==}
|
||||
|
||||
/@api.global/typedrequest@3.0.9:
|
||||
resolution: {integrity: sha512-EFjapitckBbEk0UoGwE1UAY3D9nOIdmFEJIJurzFkNlaXGRgSGL23MhuPHhnG7JgBm+IhokE1gKj3N5XD1UZIg==}
|
||||
/@api.global/typedrequest@3.0.18:
|
||||
resolution: {integrity: sha512-zeiX8+CgX7RZ/oGfTMStFrWIg/VkxFR1M1FVaMvysfXNngLPDxFrkJkY+mT/686ViEoWCMy0NSdT4cyLzoQLuA==}
|
||||
dependencies:
|
||||
'@api.global/typedrequest-interfaces': 3.0.18
|
||||
'@push.rocks/isounique': 1.0.5
|
||||
@ -70,14 +70,14 @@ packages:
|
||||
'@push.rocks/smartbuffer': 1.0.7
|
||||
'@push.rocks/smartdelay': 3.0.5
|
||||
'@push.rocks/smartpromise': 4.0.3
|
||||
'@push.rocks/webrequest': 3.0.34
|
||||
'@push.rocks/webrequest': 3.0.35
|
||||
'@push.rocks/webstream': 1.0.8
|
||||
dev: true
|
||||
|
||||
/@api.global/typedserver@3.0.25:
|
||||
resolution: {integrity: sha512-3cci307/AtM2GqPzIJ1SqU1oi9Kj1WhpUNFPjPwvG0nbXK4HSp1nFBk5P6z+bqBj19grhzQRiMl9YbvtWwJVQQ==}
|
||||
/@api.global/typedserver@3.0.27:
|
||||
resolution: {integrity: sha512-iDQcoVy3CL5NkJa6xHb+EXNxxGtOscl7U163ARHasMHcrab4Nx5Px576G1ZlG6faeRpA1UKlxaT/QepfomLIbw==}
|
||||
dependencies:
|
||||
'@api.global/typedrequest': 3.0.9
|
||||
'@api.global/typedrequest': 3.0.18
|
||||
'@api.global/typedrequest-interfaces': 3.0.18
|
||||
'@api.global/typedsocket': 3.0.0
|
||||
'@push.rocks/lik': 6.0.14
|
||||
@ -86,7 +86,7 @@ packages:
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@push.rocks/smartfeed': 1.0.11
|
||||
'@push.rocks/smartfile': 11.0.4
|
||||
'@push.rocks/smartjson': 5.0.11
|
||||
'@push.rocks/smartjson': 5.0.14
|
||||
'@push.rocks/smartlog': 3.0.3
|
||||
'@push.rocks/smartlog-destination-devtools': 1.0.10
|
||||
'@push.rocks/smartmanifest': 2.0.2
|
||||
@ -116,13 +116,13 @@ packages:
|
||||
/@api.global/typedsocket@3.0.0:
|
||||
resolution: {integrity: sha512-ui+6MLd99iTN/lC+iC/FKPRjzVyiZ4PrmlU6ptbCtbBj3cSOXHx+RRGF54+be2xHodf4FOgwFv/GZdW8LtO3vg==}
|
||||
dependencies:
|
||||
'@api.global/typedrequest': 3.0.9
|
||||
'@api.global/typedrequest': 3.0.18
|
||||
'@api.global/typedrequest-interfaces': 3.0.18
|
||||
'@push.rocks/isohash': 2.0.1
|
||||
'@push.rocks/smartjson': 5.0.11
|
||||
'@push.rocks/smartjson': 5.0.14
|
||||
'@push.rocks/smartrx': 3.0.7
|
||||
'@push.rocks/smartsocket': 2.0.24
|
||||
'@push.rocks/smartstring': 4.0.13
|
||||
'@push.rocks/smartstring': 4.0.14
|
||||
'@push.rocks/smarturl': 3.0.7
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
@ -426,7 +426,7 @@ packages:
|
||||
resolution: {integrity: sha512-ec95MNeA21L+ob+lvLVCmwPTTC1BY+v/JHLYZ9DOZ9+9buLgx+cJ7VkwGBJCnlWJtqEtJosUrFKTih36iNuT3g==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@api.global/typedserver': 3.0.25
|
||||
'@api.global/typedserver': 3.0.27
|
||||
'@git.zone/tsbundle': 2.0.15
|
||||
'@git.zone/tsrun': 1.2.46(@types/node@20.11.24)
|
||||
'@push.rocks/consolecolor': 2.0.1
|
||||
@ -755,6 +755,16 @@ packages:
|
||||
buffer-json: 2.0.0
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
lodash.clonedeep: 4.5.0
|
||||
dev: true
|
||||
|
||||
/@push.rocks/smartjson@5.0.14:
|
||||
resolution: {integrity: sha512-xS74shCYvTDvn25DWHU5VbXUtsTtbLvQmgHroN0xG4RcQfgsdoR2EYrnXmt6aY0IPubONtJ0OxABE3LDI5Yviw==}
|
||||
dependencies:
|
||||
'@push.rocks/smartbuffer': 1.0.7
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@push.rocks/smartstring': 4.0.14
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
lodash.clonedeep: 4.5.0
|
||||
|
||||
/@push.rocks/smartlog-destination-devtools@1.0.10:
|
||||
resolution: {integrity: sha512-E6xRx5vhR7gh9peXjUyBwNj0H0MeaBjh+PY++PbOhUF4NDMaEuswRLRs+UN9bfbLXZQl2i4hYD1MNCesHGTVgA==}
|
||||
@ -901,7 +911,7 @@ packages:
|
||||
'@push.rocks/smartfeed': 1.0.11
|
||||
'@push.rocks/smartxml': 1.0.8
|
||||
'@push.rocks/smartyaml': 2.0.5
|
||||
'@push.rocks/webrequest': 3.0.34
|
||||
'@push.rocks/webrequest': 3.0.35
|
||||
'@tsclass/tsclass': 4.0.52
|
||||
dev: true
|
||||
|
||||
@ -909,13 +919,13 @@ packages:
|
||||
resolution: {integrity: sha512-Glqv1Zi5TXgD+04P8OvTpiytyfrQxTPv67qAwZizAVVQ2zWJJgKqnIuoHT1zKP8QiKRNer+D58LCxX0ZE2XfzQ==}
|
||||
dependencies:
|
||||
'@api.global/typedrequest-interfaces': 3.0.18
|
||||
'@api.global/typedserver': 3.0.25
|
||||
'@api.global/typedserver': 3.0.27
|
||||
'@push.rocks/isohash': 2.0.1
|
||||
'@push.rocks/isounique': 1.0.5
|
||||
'@push.rocks/lik': 6.0.14
|
||||
'@push.rocks/smartdelay': 3.0.5
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@push.rocks/smartjson': 5.0.11
|
||||
'@push.rocks/smartjson': 5.0.14
|
||||
'@push.rocks/smartlog': 3.0.3
|
||||
'@push.rocks/smartpromise': 4.0.3
|
||||
'@push.rocks/smartrx': 3.0.7
|
||||
@ -972,6 +982,19 @@ packages:
|
||||
randomatic: 3.1.1
|
||||
strip-indent: 4.0.0
|
||||
url: 0.11.3
|
||||
dev: true
|
||||
|
||||
/@push.rocks/smartstring@4.0.14:
|
||||
resolution: {integrity: sha512-0zwtB+3yT1rFOtZY6+H6c8DIpKPrqQH/zx+P667nykvLgopH1t/kjGWNvaLC2mJOT3l+GjUd58DUO7DlTZzOSA==}
|
||||
dependencies:
|
||||
'@push.rocks/isounique': 1.0.5
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@types/randomatic': 3.1.5
|
||||
crypto-random-string: 5.0.0
|
||||
js-base64: 3.7.7
|
||||
randomatic: 3.1.1
|
||||
strip-indent: 4.0.0
|
||||
url: 0.11.3
|
||||
|
||||
/@push.rocks/smarttime@4.0.6:
|
||||
resolution: {integrity: sha512-1whOow0YJw/TbN758TedRRxApoZbsvyxCVpoGjXh7DE/fEEgs7RCr4vVF5jYpyXNQuNMLpKJcTsSfyQ6RvH4Aw==}
|
||||
@ -1025,12 +1048,12 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/@push.rocks/webrequest@3.0.34:
|
||||
resolution: {integrity: sha512-3gqJb58ZukPsOcS26ya2M/nAEOP7lMYyc2Syh45ljgwdM3X8PwHquk5pdc1MMdDWAo1aiYrxReEw6BgMCJUlNQ==}
|
||||
/@push.rocks/webrequest@3.0.35:
|
||||
resolution: {integrity: sha512-8RZJ1lznDGo/94kQDvNCKAcOPfMLFzYkcU/5gnIwpKeN7uBs2gAiKxRr71HWL2VoR5XUP1XtODIB0rnb7f/pdQ==}
|
||||
dependencies:
|
||||
'@push.rocks/smartdelay': 3.0.5
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@push.rocks/smartjson': 5.0.11
|
||||
'@push.rocks/smartjson': 5.0.14
|
||||
'@push.rocks/smartpromise': 4.0.3
|
||||
'@push.rocks/webstore': 2.0.13
|
||||
|
||||
@ -1040,7 +1063,7 @@ packages:
|
||||
'@apiglobal/typedrequest-interfaces': 2.0.1
|
||||
'@push.rocks/lik': 6.0.14
|
||||
'@push.rocks/smartenv': 5.0.12
|
||||
'@push.rocks/smartjson': 5.0.11
|
||||
'@push.rocks/smartjson': 5.0.14
|
||||
'@push.rocks/smartpromise': 4.0.3
|
||||
'@push.rocks/smartrx': 3.0.7
|
||||
fake-indexeddb: 4.0.2
|
||||
@ -1382,6 +1405,7 @@ packages:
|
||||
|
||||
/@types/buffer-json@2.0.3:
|
||||
resolution: {integrity: sha512-ItD4UfF3Q5jA+PEV6ZUWEHvlWaXJbd0rpuBKOIrEebM053FHaJddKsgUf0vy7nLSTs44nqFj3Mh8J3TiT0xv4g==}
|
||||
dev: true
|
||||
|
||||
/@types/chai-dom@0.0.9:
|
||||
resolution: {integrity: sha512-jj4F2NJog2/GBYsyJ8+NvhnWUBbPY4MUAKLdPJE6+568rw12GGXvj0ycUuP5nndVrnJgozmJAoMTvxvjJATXWw==}
|
||||
@ -1785,6 +1809,11 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/@xmldom/xmldom@0.8.10:
|
||||
resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
dev: true
|
||||
|
||||
/accepts@1.3.8:
|
||||
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@ -1983,6 +2012,7 @@ packages:
|
||||
|
||||
/base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
dev: true
|
||||
|
||||
/base64id@2.0.0:
|
||||
resolution: {integrity: sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==}
|
||||
@ -2052,6 +2082,7 @@ packages:
|
||||
|
||||
/buffer-json@2.0.0:
|
||||
resolution: {integrity: sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==}
|
||||
dev: true
|
||||
|
||||
/buffer@5.7.1:
|
||||
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
||||
@ -2065,6 +2096,7 @@ packages:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
dev: true
|
||||
|
||||
/bytes@3.1.2:
|
||||
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
|
||||
@ -3297,6 +3329,7 @@ packages:
|
||||
|
||||
/ieee754@1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
dev: true
|
||||
|
||||
/ignore@5.3.1:
|
||||
resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==}
|
||||
@ -4138,6 +4171,7 @@ packages:
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
replace-buffer: 1.2.1
|
||||
dev: true
|
||||
|
||||
/normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
@ -4356,6 +4390,8 @@ packages:
|
||||
resolution: {integrity: sha512-mXF9AIgnvq1DP/ZM2R28tAfxP2wKZHYa2DjV0R1KCwcqSzm5Iqh1XQq9rdfAt6dp2DuPP0VHZIaCALc2v1cL5A==}
|
||||
engines: {node: '>=14.18.0', npm: '>=6.14.15'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@xmldom/xmldom': 0.8.10
|
||||
dev: true
|
||||
bundledDependencies:
|
||||
- '@xmldom/xmldom'
|
||||
@ -4578,6 +4614,7 @@ packages:
|
||||
/replace-buffer@1.2.1:
|
||||
resolution: {integrity: sha512-ly3OKwKu+3T55DjP5PjIMzxgz9lFx6dQnBmAIxryZyRKl8f22juy12ShOyuq8WrQE5UlFOseZgQZDua0iF9DHw==}
|
||||
engines: {node: '>=4'}
|
||||
dev: true
|
||||
|
||||
/require-directory@2.1.1:
|
||||
resolution: {integrity: sha1-jGStX9MNqxyXbiNE/+f3kqam30I=}
|
||||
|
@ -29,17 +29,19 @@ tap.test('should define a testHandler', async () => {
|
||||
testTypedRouter.addTypedHandler(testTypedHandler);
|
||||
});
|
||||
|
||||
tap.test('should fire a request', async () => {
|
||||
const typedRequest = new typedrequest.TypedRequest<ITestReqRes>(
|
||||
'http://localhost:3000/typedrequest',
|
||||
'hi'
|
||||
);
|
||||
const result = await typedRequest.fire({
|
||||
name: 'yes',
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(result);
|
||||
tap.skip.test('should fire a request', async () => {
|
||||
let response = await fetch('http://localhost:3000/typedrequest', {
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": "{\"correlation\":{\"id\":\"uni_aefe56c1a0f61a3e91082209\",\"phase\":\"request\"},\"method\":\"hi\",\"request\":{\"name\":\"yes\"},\"response\":null}"
|
||||
})
|
||||
console.log(await response.text());
|
||||
});
|
||||
|
||||
tap.skip.test('test', async (tools) => {
|
||||
await tools.delayFor(5000);
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -96,13 +96,14 @@ tap.test('should allow VirtualStreams', async () => {
|
||||
|
||||
newRequestingVS.sendData(Buffer.from('hello'));
|
||||
const data = await generatedRequestingVS.fetchData();
|
||||
const decodedData = data.toString();
|
||||
expect(data.toString()).toEqual('hello');
|
||||
const decodedData = new TextDecoder().decode(data);
|
||||
expect(decodedData).toEqual('hello');
|
||||
});
|
||||
|
||||
tap.test('should end the server', async (toolsArg) => {
|
||||
await toolsArg.delayFor(5000);
|
||||
await toolsArg.delayFor(1000);
|
||||
await testServer.stop();
|
||||
setTimeout(() => process.exit(0), 100);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@api.global/typedrequest',
|
||||
version: '3.0.11',
|
||||
version: '3.0.19',
|
||||
description: 'make typed requests towards apis'
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ import * as smartbuffer from '@push.rocks/smartbuffer';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as webrequest from '@push.rocks/webrequest';
|
||||
import * as webstream from '@push.rocks/webstream';
|
||||
|
||||
export { isounique, lik, smartbuffer, smartdelay, smartpromise, webrequest, webstream };
|
||||
|
||||
export { isounique, lik, smartbuffer, smartdelay, smartpromise, webrequest };
|
||||
|
@ -120,6 +120,7 @@ export class TypedRouter {
|
||||
typedRequestArg.correlation.phase = 'response';
|
||||
|
||||
// encode again before handing back
|
||||
typedRequestArg.localData = null;
|
||||
typedRequestArg = VirtualStream.encodePayloadForNetwork(typedRequestArg, {
|
||||
typedrouter: this,
|
||||
});
|
||||
|
@ -52,26 +52,24 @@ export class VirtualStream<T = ArrayBufferLike> implements plugins.typedRequestI
|
||||
};
|
||||
}
|
||||
} else if (Array.isArray(objectPayload)) {
|
||||
const returnArray = [];
|
||||
for (const item of objectPayload) {
|
||||
returnArray.push(
|
||||
VirtualStream.encodePayloadForNetwork(
|
||||
item,
|
||||
commFunctions,
|
||||
originalPayload || objectPayload,
|
||||
path
|
||||
)
|
||||
);
|
||||
}
|
||||
return returnArray;
|
||||
} else if (objectPayload !== null && typeof objectPayload === 'object') {
|
||||
return Object.keys(objectPayload).reduce((acc, key) => {
|
||||
path.push(key);
|
||||
acc[key] = VirtualStream.encodePayloadForNetwork(
|
||||
objectPayload[key],
|
||||
// For arrays, we recurse over each item.
|
||||
return objectPayload.map((item, index) =>
|
||||
VirtualStream.encodePayloadForNetwork(
|
||||
item,
|
||||
commFunctions,
|
||||
originalPayload || objectPayload,
|
||||
path
|
||||
path.concat(String(index)) // Convert index to string and concatenate to path
|
||||
)
|
||||
);
|
||||
} else if (objectPayload !== null && typeof objectPayload === 'object') {
|
||||
// For objects, we recurse over each key-value pair.
|
||||
return Object.entries(objectPayload).reduce((acc, [key, value]) => {
|
||||
const newPath = path.concat(key); // Concatenate the new key to the path
|
||||
acc[key] = VirtualStream.encodePayloadForNetwork(
|
||||
value,
|
||||
commFunctions,
|
||||
originalPayload || objectPayload,
|
||||
newPath
|
||||
);
|
||||
return acc;
|
||||
}, {});
|
||||
|
Reference in New Issue
Block a user