@conduit-client/command-streaming 3.6.1 → 3.6.2

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/v1/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * All rights reserved.
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
- import { ok, err, toError } from "@conduit-client/utils";
6
+ import { resolvedPromiseLike, err, toError, ok } from "@conduit-client/utils";
7
7
  import { BaseCommand } from "@conduit-client/command-base/v1";
8
8
  class StreamingCommand extends BaseCommand {
9
9
  constructor(services) {
@@ -11,7 +11,11 @@ class StreamingCommand extends BaseCommand {
11
11
  this.services = services;
12
12
  }
13
13
  execute() {
14
- return this.convertFetchStreamResponseToData(this.services.fetch(...this.fetchParams));
14
+ try {
15
+ return this.convertFetchStreamResponseToData(this.services.fetch(...this.fetchParams));
16
+ } catch (reason) {
17
+ return resolvedPromiseLike(err(toError(reason)));
18
+ }
15
19
  }
16
20
  convertFetchStreamResponseToData(response) {
17
21
  return response.then(
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/v1/streaming-command.ts","../../src/v1/index.ts"],"sourcesContent":["import { toError, ok, err } from '@conduit-client/utils';\nimport { BaseCommand } from '@conduit-client/command-base/v1';\nimport type { Result } from '@conduit-client/utils';\nimport type { NamedFetchService, FetchService } from '@conduit-client/service-fetch-network/v1';\n\n/**\n * An implementation of BaseCommand that supports streaming responses and does not use the store.\n */\nexport abstract class StreamingCommand<\n StreamedData = Uint8Array,\n ExtraServices extends object = object,\n> extends BaseCommand<PromiseLike<Result<ReadableStream<StreamedData>, Error>>> {\n constructor(protected services: NamedFetchService & ExtraServices) {\n super();\n }\n\n execute() {\n return this.convertFetchStreamResponseToData(this.services.fetch(...this.fetchParams));\n }\n\n protected abstract readonly fetchParams: Parameters<FetchService>;\n\n /**\n * Decodes the bytes returned by fetch into the correct shape.\n *\n * @param byteStream ReadableStream<Uint8Array> returned by fetch\n * @returns ReadableStream<StreamedData> that will be the result of the Command\n */\n abstract decodeByteStream(byteStream: ReadableStream<Uint8Array>): ReadableStream<StreamedData>;\n\n convertFetchStreamResponseToData(\n response: PromiseLike<Response>\n ): PromiseLike<Result<ReadableStream<StreamedData>, Error>> {\n return response.then(\n (response) => {\n if (response.ok && response.body) {\n return ok(this.decodeByteStream(response.body));\n } else {\n return err(\n toError(response.ok ? 'Response body not present' : response.statusText)\n );\n }\n },\n (reason: any) => err(toError(reason))\n );\n }\n}\n","import { type ServiceDescriptor } from '@conduit-client/utils';\nimport { StreamingCommand } from './streaming-command';\n\nexport { StreamingCommand } from './streaming-command';\n\nexport type StreamingCommandServiceDescriptor = ServiceDescriptor<\n typeof StreamingCommand,\n 'streamingCommandBaseClass',\n '1.0'\n>;\n\nexport function buildServiceDescriptor(): StreamingCommandServiceDescriptor {\n return {\n type: 'streamingCommandBaseClass',\n version: '1.0',\n service: StreamingCommand,\n };\n}\n"],"names":["response"],"mappings":";;;;;;;AAQO,MAAe,yBAGZ,YAAsE;AAAA,EAC5E,YAAsB,UAA6C;AAC/D,UAAA;AADkB,SAAA,WAAA;AAAA,EAEtB;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,iCAAiC,KAAK,SAAS,MAAM,GAAG,KAAK,WAAW,CAAC;AAAA,EACzF;AAAA,EAYA,iCACI,UACwD;AACxD,WAAO,SAAS;AAAA,MACZ,CAACA,cAAa;AACV,YAAIA,UAAS,MAAMA,UAAS,MAAM;AAC9B,iBAAO,GAAG,KAAK,iBAAiBA,UAAS,IAAI,CAAC;AAAA,QAClD,OAAO;AACH,iBAAO;AAAA,YACH,QAAQA,UAAS,KAAK,8BAA8BA,UAAS,UAAU;AAAA,UAAA;AAAA,QAE/E;AAAA,MACJ;AAAA,MACA,CAAC,WAAgB,IAAI,QAAQ,MAAM,CAAC;AAAA,IAAA;AAAA,EAE5C;AACJ;ACnCO,SAAS,yBAA4D;AACxE,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EAAA;AAEjB;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/streaming-command.ts","../../src/v1/index.ts"],"sourcesContent":["import { toError, ok, err, resolvedPromiseLike } from '@conduit-client/utils';\nimport { BaseCommand } from '@conduit-client/command-base/v1';\nimport type { Result } from '@conduit-client/utils';\nimport type { NamedFetchService, FetchService } from '@conduit-client/service-fetch-network/v1';\n\n/**\n * An implementation of BaseCommand that supports streaming responses and does not use the store.\n */\nexport abstract class StreamingCommand<\n StreamedData = Uint8Array,\n ExtraServices extends object = object,\n> extends BaseCommand<PromiseLike<Result<ReadableStream<StreamedData>, Error>>> {\n constructor(protected services: NamedFetchService & ExtraServices) {\n super();\n }\n\n execute() {\n try {\n return this.convertFetchStreamResponseToData(this.services.fetch(...this.fetchParams));\n } catch (reason) {\n return resolvedPromiseLike(err(toError(reason)));\n }\n }\n\n protected abstract readonly fetchParams: Parameters<FetchService>;\n\n /**\n * Decodes the bytes returned by fetch into the correct shape.\n *\n * @param byteStream ReadableStream<Uint8Array> returned by fetch\n * @returns ReadableStream<StreamedData> that will be the result of the Command\n */\n abstract decodeByteStream(byteStream: ReadableStream<Uint8Array>): ReadableStream<StreamedData>;\n\n convertFetchStreamResponseToData(\n response: PromiseLike<Response>\n ): PromiseLike<Result<ReadableStream<StreamedData>, Error>> {\n return response.then(\n (response) => {\n if (response.ok && response.body) {\n return ok(this.decodeByteStream(response.body));\n } else {\n return err(\n toError(response.ok ? 'Response body not present' : response.statusText)\n );\n }\n },\n (reason: any) => err(toError(reason))\n );\n }\n}\n","import { type ServiceDescriptor } from '@conduit-client/utils';\nimport { StreamingCommand } from './streaming-command';\n\nexport { StreamingCommand } from './streaming-command';\n\nexport type StreamingCommandServiceDescriptor = ServiceDescriptor<\n typeof StreamingCommand,\n 'streamingCommandBaseClass',\n '1.0'\n>;\n\nexport function buildServiceDescriptor(): StreamingCommandServiceDescriptor {\n return {\n type: 'streamingCommandBaseClass',\n version: '1.0',\n service: StreamingCommand,\n };\n}\n"],"names":["response"],"mappings":";;;;;;;AAQO,MAAe,yBAGZ,YAAsE;AAAA,EAC5E,YAAsB,UAA6C;AAC/D,UAAA;AADkB,SAAA,WAAA;AAAA,EAEtB;AAAA,EAEA,UAAU;AACN,QAAI;AACA,aAAO,KAAK,iCAAiC,KAAK,SAAS,MAAM,GAAG,KAAK,WAAW,CAAC;AAAA,IACzF,SAAS,QAAQ;AACb,aAAO,oBAAoB,IAAI,QAAQ,MAAM,CAAC,CAAC;AAAA,IACnD;AAAA,EACJ;AAAA,EAYA,iCACI,UACwD;AACxD,WAAO,SAAS;AAAA,MACZ,CAACA,cAAa;AACV,YAAIA,UAAS,MAAMA,UAAS,MAAM;AAC9B,iBAAO,GAAG,KAAK,iBAAiBA,UAAS,IAAI,CAAC;AAAA,QAClD,OAAO;AACH,iBAAO;AAAA,YACH,QAAQA,UAAS,KAAK,8BAA8BA,UAAS,UAAU;AAAA,UAAA;AAAA,QAE/E;AAAA,MACJ;AAAA,MACA,CAAC,WAAgB,IAAI,QAAQ,MAAM,CAAC;AAAA,IAAA;AAAA,EAE5C;AACJ;ACvCO,SAAS,yBAA4D;AACxE,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EAAA;AAEjB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduit-client/command-streaming",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "private": false,
5
5
  "description": "Luvio Streaming Command",
6
6
  "type": "module",
@@ -31,9 +31,9 @@
31
31
  "watch": "npm run build --watch"
32
32
  },
33
33
  "dependencies": {
34
- "@conduit-client/command-base": "3.6.1",
35
- "@conduit-client/service-fetch-network": "3.6.1",
36
- "@conduit-client/utils": "3.6.1"
34
+ "@conduit-client/command-base": "3.6.2",
35
+ "@conduit-client/service-fetch-network": "3.6.2",
36
+ "@conduit-client/utils": "3.6.2"
37
37
  },
38
38
  "volta": {
39
39
  "extends": "../../../../package.json"