@streamlayer/sdk-web-api 0.11.4 → 0.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-api",
3
- "version": "0.11.4",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -22,7 +22,8 @@
22
22
  "@nanostores/query": "^0.2.4",
23
23
  "@streamlayer/sdk-web-interfaces": "workspace:^",
24
24
  "@streamlayer/sl-eslib": "^5.29.0",
25
- "nanostores": "^0.9.3"
25
+ "nanostores": "^0.9.3",
26
+ "tslib": "^2.6.2"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@swc/helpers": "^0.5.2"
@@ -1,5 +1,4 @@
1
1
  import { ReadableAtom } from 'nanostores';
2
2
  import { Transport } from '../transport';
3
- export { $user } from './user';
4
3
  export declare const $retrieveEventId: ($providerStreamId: ReadableAtom<string | undefined>, transport: Transport) => import("@nanostores/query").FetcherStore<string, any>;
5
4
  export declare const $streamSettings: (slStreamId: ReadableAtom<string | undefined>, transport: Transport) => import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").StreamSettings | undefined, any>;
@@ -1,40 +1,39 @@
1
1
  import { Events } from '@streamlayer/sl-eslib/sports/events/events_connect';
2
2
  import { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect';
3
- export { $user } from './user';
4
- export const $retrieveEventId = ($providerStreamId, transport)=>{
3
+ export const $retrieveEventId = ($providerStreamId, transport) => {
5
4
  const { client, queryKey } = transport.createPromiseClient(Events, {
6
5
  method: 'retrieveEventId',
7
- params: [
8
- $providerStreamId
9
- ]
6
+ params: [$providerStreamId],
10
7
  });
11
8
  return transport.nanoquery.createFetcherStore(queryKey, {
12
- fetcher: async (_, __, id)=>{
9
+ fetcher: async (_, __, id) => {
13
10
  if (!id || typeof id !== 'string') {
14
11
  return '';
15
12
  }
16
- const res = await client.retrieveEventId({
17
- id
18
- });
19
- return (res.data?.id) || '';
20
- }
13
+ try {
14
+ const res = await client.retrieveEventId({
15
+ id,
16
+ });
17
+ return res.data?.id || '';
18
+ }
19
+ catch (err) {
20
+ return '';
21
+ }
22
+ },
21
23
  });
22
24
  };
23
- export const $streamSettings = (slStreamId, transport)=>{
24
- const { client, queryKey } = transport.createPromiseClient(Client, {
25
- method: 'getStream',
26
- params: [
27
- slStreamId
28
- ]
29
- });
25
+ export const $streamSettings = (slStreamId, transport) => {
26
+ const { client, queryKey } = transport.createPromiseClient(Client, { method: 'getStream', params: [slStreamId] });
30
27
  return transport.nanoquery.createFetcherStore(queryKey, {
31
- fetcher: async (_, __, id)=>{
28
+ fetcher: async (_, __, id) => {
29
+ if (!id) {
30
+ return undefined;
31
+ }
32
32
  const res = await client.getStream({
33
- id: id
33
+ id: id, // we are sure that id is a string
34
34
  });
35
35
  return res.data?.attributes;
36
- }
36
+ },
37
37
  });
38
38
  };
39
-
40
39
  //# sourceMappingURL=event.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/event.ts"],"sourcesContent":["import { ReadableAtom } from 'nanostores'\nimport { Events } from '@streamlayer/sl-eslib/sports/events/events_connect'\nimport { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect'\n\nimport { Transport } from '../transport'\n\nexport { $user } from './user'\n\nexport const $retrieveEventId = ($providerStreamId: ReadableAtom<string | undefined>, transport: Transport) => {\n const { client, queryKey } = transport.createPromiseClient(Events, {\n method: 'retrieveEventId',\n params: [$providerStreamId],\n })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: async (_, __, id) => {\n if (!id || typeof id !== 'string') {\n return ''\n }\n\n const res = await client.retrieveEventId({\n id,\n })\n\n return (res.data?.id as unknown as string) || ''\n },\n })\n}\n\nexport const $streamSettings = (slStreamId: ReadableAtom<string | undefined>, transport: Transport) => {\n const { client, queryKey } = transport.createPromiseClient(Client, { method: 'getStream', params: [slStreamId] })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: async (_, __, id) => {\n const res = await client.getStream({\n id: id as string, // we are sure that id is a string\n })\n\n return res.data?.attributes\n },\n })\n}\n"],"names":["Events","Client","$user","$retrieveEventId","$providerStreamId","transport","client","queryKey","createPromiseClient","method","params","nanoquery","createFetcherStore","fetcher","_","__","id","res","retrieveEventId","data","$streamSettings","slStreamId","getStream","attributes"],"mappings":"AACA,SAASA,MAAM,QAAQ,qDAAoD;AAC3E,SAASC,MAAM,QAAQ,0DAAyD;AAIhF,SAASC,KAAK,QAAQ,SAAQ;AAE9B,OAAO,MAAMC,mBAAmB,CAACC,mBAAqDC;IACpF,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,UAAUG,mBAAmB,CAACR,QAAQ;QACjES,QAAQ;QACRC,QAAQ;YAACN;SAAkB;IAC7B;IAEA,OAAOC,UAAUM,SAAS,CAACC,kBAAkB,CAACL,UAAU;QACtDM,SAAS,OAAOC,GAAGC,IAAIC;YACrB,IAAI,CAACA,MAAM,OAAOA,OAAO,UAAU;gBACjC,OAAO;YACT;YAEA,MAAMC,MAAM,MAAMX,OAAOY,eAAe,CAAC;gBACvCF;YACF;YAEA,OAAO,CAACC,IAAIE,IAAI,EAAEH,EAAuB,KAAK;QAChD;IACF;AACF,EAAC;AAED,OAAO,MAAMI,kBAAkB,CAACC,YAA8ChB;IAC5E,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,UAAUG,mBAAmB,CAACP,QAAQ;QAAEQ,QAAQ;QAAaC,QAAQ;YAACW;SAAW;IAAC;IAE/G,OAAOhB,UAAUM,SAAS,CAACC,kBAAkB,CAACL,UAAU;QACtDM,SAAS,OAAOC,GAAGC,IAAIC;YACrB,MAAMC,MAAM,MAAMX,OAAOgB,SAAS,CAAC;gBACjCN,IAAIA;YACN;YAEA,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jH,OAAO,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE;QACtD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YAC3B,IAAI,CAAC,EAAE,EAAE;gBACP,OAAO,SAAS,CAAA;aACjB;YAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC;gBACjC,EAAE,EAAE,EAAY,EAAE,kCAAkC;aACrD,CAAC,CAAA;YAEF,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,CAAA;QAC7B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,5 +1,4 @@
1
1
  export * from './event';
2
2
  export * from './organization';
3
3
  export * from './user';
4
-
5
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/index.ts"],"sourcesContent":["export * from './event'\nexport * from './organization'\nexport * from './user'\n"],"names":[],"mappings":"AAAA,cAAc,UAAS;AACvB,cAAc,iBAAgB;AAC9B,cAAc,SAAQ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA"}
@@ -17,5 +17,5 @@ export declare const $organizationSettings: ($enabled: ReadableAtom<'on' | undef
17
17
  brandDefaults?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").BrandDefaults | undefined;
18
18
  pub?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").JWK | undefined;
19
19
  getstream?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").GetStreamSettingsClient | undefined;
20
- } | null, any>;
20
+ } | undefined, any>;
21
21
  export declare const $organizationAdvertising: ($enabled: ReadableAtom<string | undefined>, transport: Transport) => import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").Advertising | undefined, any>;
@@ -1,35 +1,29 @@
1
1
  import { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect';
2
2
  export { $user } from './user';
3
- export const $organizationSettings = ($enabled, transport)=>{
4
- const { client, queryKey } = transport.createPromiseClient(Client, {
5
- method: 'getOrganization',
6
- params: [
7
- $enabled
8
- ]
9
- });
3
+ export const $organizationSettings = ($enabled, transport) => {
4
+ const { client, queryKey } = transport.createPromiseClient(Client, { method: 'getOrganization', params: [$enabled] });
10
5
  return transport.nanoquery.createFetcherStore(queryKey, {
11
- fetcher: async ()=>{
6
+ fetcher: async () => {
12
7
  const res = await client.getOrganization({});
13
- return res.data ? {
14
- ...res.data.attributes,
15
- id: res.data.id
16
- } : null;
17
- }
8
+ return res.data
9
+ ? {
10
+ ...res.data.attributes,
11
+ id: res.data.id,
12
+ }
13
+ : undefined;
14
+ },
18
15
  });
19
16
  };
20
- export const $organizationAdvertising = ($enabled, transport)=>{
17
+ export const $organizationAdvertising = ($enabled, transport) => {
21
18
  const { client, queryKey } = transport.createPromiseClient(Client, {
22
19
  method: 'getOrganizationAdvertising',
23
- params: [
24
- $enabled
25
- ]
20
+ params: [$enabled],
26
21
  });
27
22
  return transport.nanoquery.createFetcherStore(queryKey, {
28
- fetcher: async ()=>{
23
+ fetcher: async () => {
29
24
  const res = await client.getOrganizationAdvertising({});
30
25
  return res.data?.attributes;
31
- }
26
+ },
32
27
  });
33
28
  };
34
-
35
29
  //# sourceMappingURL=organization.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/organization.ts"],"sourcesContent":["import { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect'\nimport { ReadableAtom } from 'nanostores'\n\nimport { Transport } from '../transport'\n\nexport { $user } from './user'\n\nexport const $organizationSettings = ($enabled: ReadableAtom<'on' | undefined>, transport: Transport) => {\n const { client, queryKey } = transport.createPromiseClient(Client, { method: 'getOrganization', params: [$enabled] })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: async () => {\n const res = await client.getOrganization({})\n\n return res.data\n ? {\n ...res.data.attributes,\n id: res.data.id,\n }\n : null\n },\n })\n}\n\nexport const $organizationAdvertising = ($enabled: ReadableAtom<string | undefined>, transport: Transport) => {\n const { client, queryKey } = transport.createPromiseClient(Client, {\n method: 'getOrganizationAdvertising',\n params: [$enabled],\n })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: async () => {\n const res = await client.getOrganizationAdvertising({})\n\n return res.data?.attributes\n },\n })\n}\n"],"names":["Client","$user","$organizationSettings","$enabled","transport","client","queryKey","createPromiseClient","method","params","nanoquery","createFetcherStore","fetcher","res","getOrganization","data","attributes","id","$organizationAdvertising","getOrganizationAdvertising"],"mappings":"AAAA,SAASA,MAAM,QAAQ,0DAAyD;AAKhF,SAASC,KAAK,QAAQ,SAAQ;AAE9B,OAAO,MAAMC,wBAAwB,CAACC,UAA0CC;IAC9E,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,UAAUG,mBAAmB,CAACP,QAAQ;QAAEQ,QAAQ;QAAmBC,QAAQ;YAACN;SAAS;IAAC;IAEnH,OAAOC,UAAUM,SAAS,CAACC,kBAAkB,CAACL,UAAU;QACtDM,SAAS;YACP,MAAMC,MAAM,MAAMR,OAAOS,eAAe,CAAC,CAAC;YAE1C,OAAOD,IAAIE,IAAI,GACX;gBACE,GAAGF,IAAIE,IAAI,CAACC,UAAU;gBACtBC,IAAIJ,IAAIE,IAAI,CAACE,EAAE;YACjB,IACA;QACN;IACF;AACF,EAAC;AAED,OAAO,MAAMC,2BAA2B,CAACf,UAA4CC;IACnF,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,UAAUG,mBAAmB,CAACP,QAAQ;QACjEQ,QAAQ;QACRC,QAAQ;YAACN;SAAS;IACpB;IAEA,OAAOC,UAAUM,SAAS,CAACC,kBAAkB,CAACL,UAAU;QACtDM,SAAS;YACP,MAAMC,MAAM,MAAMR,OAAOc,0BAA0B,CAAC,CAAC;YAErD,OAAON,IAAIE,IAAI,EAAEC;QACnB;IACF;AACF,EAAC"}
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yDAAyD,CAAA;AAKhF,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAwC,EAAE,SAAoB,EAAE,EAAE;IACtG,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAErH,OAAO,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE;QACtD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA;YAE5C,OAAO,GAAG,CAAC,IAAI;gBACb,CAAC,CAAC;oBACE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU;oBACtB,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE;iBAChB;gBACH,CAAC,CAAC,SAAS,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAA0C,EAAE,SAAoB,EAAE,EAAE;IAC3G,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE;QACjE,MAAM,EAAE,4BAA4B;QACpC,MAAM,EAAE,CAAC,QAAQ,CAAC;KACnB,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE;QACtD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAA;YAEvD,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,CAAA;QAC7B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -6,59 +6,37 @@ import { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect'
6
6
  // login
7
7
  // save token
8
8
  // called on update user key
9
- export const $user = ($userToken, transport)=>{
10
- const { queryKey, client } = transport.createPromiseClient(Users, {
11
- method: 'me',
12
- params: [
13
- $userToken
14
- ]
15
- });
9
+ export const $user = ($userToken, transport) => {
10
+ const { queryKey, client } = transport.createPromiseClient(Users, { method: 'me', params: [$userToken] });
16
11
  return transport.nanoquery.createFetcherStore(queryKey, {
17
- fetcher: ()=>client.me({})
12
+ fetcher: () => client.me({}),
18
13
  });
19
14
  };
20
- export const $bypassLogin = (transport)=>{
21
- const { client, queryKeyStr } = transport.createPromiseClient(Users, {
22
- method: 'bypassAuth'
23
- });
24
- return transport.nanoquery.createMutatorStore(async ({ data: { userKey, schema, init }, getCacheUpdater })=>{
15
+ export const $bypassLogin = (transport) => {
16
+ const { client, queryKeyStr } = transport.createPromiseClient(Users, { method: 'bypassAuth' });
17
+ return transport.nanoquery.createMutatorStore(async ({ data: { userKey, schema, init }, getCacheUpdater }) => {
25
18
  const [updateCache] = getCacheUpdater(queryKeyStr);
26
- const user = await client.bypassAuth({
27
- userKey,
28
- schema,
29
- init
30
- });
19
+ const user = await client.bypassAuth({ userKey, schema, init });
31
20
  updateCache(user);
32
21
  return user;
33
22
  });
34
23
  };
35
- export const bypassAuth = (transport, params)=>{
36
- const { client } = transport.createPromiseClient(Users, {
37
- method: 'bypassAuth'
38
- });
24
+ export const bypassAuth = (transport, params) => {
25
+ const { client } = transport.createPromiseClient(Users, { method: 'bypassAuth' });
39
26
  return client.bypassAuth(params);
40
27
  };
41
- export const $userSettings = ($userToken, transport)=>{
42
- const { client, queryKey } = transport.createPromiseClient(Client, {
43
- method: 'get',
44
- params: [
45
- $userToken
46
- ]
47
- });
28
+ export const $userSettings = ($userToken, // sl user token
29
+ transport) => {
30
+ const { client, queryKey } = transport.createPromiseClient(Client, { method: 'get', params: [$userToken] });
48
31
  return transport.nanoquery.createFetcherStore(queryKey, {
49
- fetcher: async ()=>{
32
+ fetcher: async () => {
50
33
  const data = await client.get({});
51
34
  return data.data?.attributes;
52
- }
35
+ },
53
36
  });
54
37
  };
55
- export const register = (transport, phone)=>{
56
- const { client } = transport.createPromiseClient(Users, {
57
- method: 'register'
58
- });
59
- return client.register({
60
- id: phone
61
- });
38
+ export const register = (transport, phone) => {
39
+ const { client } = transport.createPromiseClient(Users, { method: 'register' });
40
+ return client.register({ id: phone });
62
41
  };
63
-
64
42
  //# sourceMappingURL=user.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/user.ts"],"sourcesContent":["import { ReadableAtom } from 'nanostores'\nimport { Users } from '@streamlayer/sl-eslib/users/users_connect'\nimport type { BypassAuthRequest, BypassAuthResponse } from '@streamlayer/sl-eslib/users/users_pb'\nimport { Client } from '@streamlayer/sl-eslib/sdkSettings/client/client_connect'\nimport { PlainMessage } from '@bufbuild/protobuf'\n\nimport { Transport } from '../transport'\n\n// user query\n// cache user\n// invalidate token\n// login\n// save token\n// called on update user key\nexport const $user = ($userToken: ReadableAtom<string | undefined>, transport: Transport) => {\n const { queryKey, client } = transport.createPromiseClient(Users, { method: 'me', params: [$userToken] })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: () => client.me({}),\n })\n}\n\nexport const $bypassLogin = (transport: Transport) => {\n const { client, queryKeyStr } = transport.createPromiseClient(Users, { method: 'bypassAuth' })\n\n return transport.nanoquery.createMutatorStore<PlainMessage<BypassAuthRequest>, PlainMessage<BypassAuthResponse>>(\n async ({ data: { userKey, schema, init }, getCacheUpdater }) => {\n const [updateCache] = getCacheUpdater(queryKeyStr)\n const user = await client.bypassAuth({ userKey, schema, init })\n\n updateCache(user)\n\n return user\n },\n )\n}\n\nexport const bypassAuth = (transport: Transport, params: { userKey?: string; schema?: string; init?: boolean }) => {\n const { client } = transport.createPromiseClient(Users, { method: 'bypassAuth' })\n\n return client.bypassAuth(params)\n}\n\nexport const $userSettings = (\n $userToken: ReadableAtom<string | undefined>, // sl user token\n transport: Transport,\n) => {\n const { client, queryKey } = transport.createPromiseClient(Client, { method: 'get', params: [$userToken] })\n\n return transport.nanoquery.createFetcherStore(queryKey, {\n fetcher: async () => {\n const data = await client.get({})\n\n return data.data?.attributes\n },\n })\n}\n\nexport const register = (transport: Transport, phone: string) => {\n const { client } = transport.createPromiseClient(Users, { method: 'register' })\n\n return client.register({ id: phone })\n}\n"],"names":["Users","Client","$user","$userToken","transport","queryKey","client","createPromiseClient","method","params","nanoquery","createFetcherStore","fetcher","me","$bypassLogin","queryKeyStr","createMutatorStore","data","userKey","schema","init","getCacheUpdater","updateCache","user","bypassAuth","$userSettings","get","attributes","register","phone","id"],"mappings":"AACA,SAASA,KAAK,QAAQ,4CAA2C;AAEjE,SAASC,MAAM,QAAQ,0DAAyD;AAKhF,aAAa;AACb,aAAa;AACb,mBAAmB;AACnB,QAAQ;AACR,aAAa;AACb,4BAA4B;AAC5B,OAAO,MAAMC,QAAQ,CAACC,YAA8CC;IAClE,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGF,UAAUG,mBAAmB,CAACP,OAAO;QAAEQ,QAAQ;QAAMC,QAAQ;YAACN;SAAW;IAAC;IAEvG,OAAOC,UAAUM,SAAS,CAACC,kBAAkB,CAACN,UAAU;QACtDO,SAAS,IAAMN,OAAOO,EAAE,CAAC,CAAC;IAC5B;AACF,EAAC;AAED,OAAO,MAAMC,eAAe,CAACV;IAC3B,MAAM,EAAEE,MAAM,EAAES,W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E;IAChH,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;IAEjF,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,UAA4C,EAAE,gBAAgB;AAC9D,SAAoB,EACpB,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAE3G,OAAO,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE;QACtD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAEjC,OAAO,IAAI,CAAC,IAAI,EAAE,UAAU,CAAA;QAC9B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAE,KAAa,EAAE,EAAE;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IAE/E,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { CallbackClient } from '@connectrpc/connect';
2
+ import { Atom } from 'nanostores';
3
+ import type { ServiceType, Message, PlainMessage, MethodInfoServerStreaming } from '@bufbuild/protobuf';
4
+ import { Transport } from './transport';
5
+ type StreamMethods<T extends ServiceType> = {
6
+ [P in keyof CallbackClient<T> as T['methods'][P] extends MethodInfoServerStreaming<any, any> ? P : never]: P;
7
+ };
8
+ export type StreamMethod<T extends ServiceType> = StreamMethods<T>[keyof StreamMethods<T>] extends keyof CallbackClient<T> ? StreamMethods<T>[keyof StreamMethods<T>] : never;
9
+ declare enum ServerStreamSubscriptionStatus {
10
+ Init = "init",
11
+ Ready = "ready",
12
+ Connecting = "connecting",
13
+ Connected = "connected",
14
+ Disconnected = "disconnected",
15
+ Failed = "failed",
16
+ Reconnecting = "reconnecting"
17
+ }
18
+ export type ServerStreamSubscriptionOptions = {
19
+ name: string;
20
+ withStore?: boolean;
21
+ };
22
+ export declare class ServerStreamSubscription<T extends ServiceType, Request extends Message<Request>, Response extends Message<Response>, M extends StreamMethod<T> = StreamMethod<T>, Method extends CallbackClient<T>[M] = CallbackClient<T>[M]> {
23
+ params: Atom<PlainMessage<Request>> | PlainMessage<Request>;
24
+ private stream?;
25
+ private method;
26
+ private name;
27
+ private headers;
28
+ private listeners;
29
+ private state;
30
+ private store?;
31
+ constructor(headers: Transport['$headers'], method: Method, params: Atom<PlainMessage<Request>> | PlainMessage<Request>, options: ServerStreamSubscriptionOptions);
32
+ updateState: (status: ServerStreamSubscriptionStatus) => void;
33
+ addStateLog: (msg: string) => void;
34
+ addListener: (name: string, listener: (response: Response) => void) => boolean;
35
+ removeListener: (name: string) => void;
36
+ connect: () => void;
37
+ disconnect: () => void;
38
+ reconnect: () => void;
39
+ getStore: () => import("nanostores").WritableAtom<Response | null | undefined> | undefined;
40
+ private onData;
41
+ private onStreamError;
42
+ }
43
+ export {};
@@ -0,0 +1,107 @@
1
+ import { MapStore, SingleStore, createMapStore, createSingleStore } from '@streamlayer/sdk-web-interfaces';
2
+ var ServerStreamSubscriptionStatus;
3
+ (function (ServerStreamSubscriptionStatus) {
4
+ ServerStreamSubscriptionStatus["Init"] = "init";
5
+ ServerStreamSubscriptionStatus["Ready"] = "ready";
6
+ ServerStreamSubscriptionStatus["Connecting"] = "connecting";
7
+ ServerStreamSubscriptionStatus["Connected"] = "connected";
8
+ ServerStreamSubscriptionStatus["Disconnected"] = "disconnected";
9
+ ServerStreamSubscriptionStatus["Failed"] = "failed";
10
+ ServerStreamSubscriptionStatus["Reconnecting"] = "reconnecting";
11
+ })(ServerStreamSubscriptionStatus || (ServerStreamSubscriptionStatus = {}));
12
+ export class ServerStreamSubscription {
13
+ params;
14
+ stream;
15
+ method;
16
+ name;
17
+ headers;
18
+ listeners;
19
+ state;
20
+ store;
21
+ constructor(headers, method, params, options) {
22
+ const initState = {
23
+ status: ServerStreamSubscriptionStatus.Init,
24
+ ts: new Date(),
25
+ log: [],
26
+ };
27
+ this.state = new MapStore(createMapStore(initState), `subscription:${options.name}:state`);
28
+ this.name = options.name;
29
+ this.headers = headers;
30
+ this.listeners = new Map();
31
+ this.params = params;
32
+ this.method = method;
33
+ if (options.withStore) {
34
+ this.store = new SingleStore(createSingleStore(null), `subscription:${options.name}:store`);
35
+ }
36
+ if ('subscribe' in params && typeof params.subscribe === 'function') {
37
+ params.subscribe(() => {
38
+ this.reconnect();
39
+ });
40
+ }
41
+ this.updateState(ServerStreamSubscriptionStatus.Ready);
42
+ }
43
+ updateState = (status) => {
44
+ this.state.setValue('status', status);
45
+ this.state.setValue('ts', new Date());
46
+ this.addStateLog(`status => ${status}`);
47
+ };
48
+ addStateLog = (msg) => {
49
+ const log = this.state.getStore().get()['log'];
50
+ this.state.setValue('log', [...log, `${new Date().toLocaleString()}: ${msg}`]);
51
+ };
52
+ addListener = (name, listener) => {
53
+ if (this.listeners.has(name)) {
54
+ this.addStateLog(`listener '${name}' not added`);
55
+ return false;
56
+ }
57
+ this.listeners.set(name, listener);
58
+ this.addStateLog(`listener '${name}' added`);
59
+ return true;
60
+ };
61
+ removeListener = (name) => {
62
+ this.listeners.delete(name);
63
+ this.addStateLog(`listener '${name}' removed`);
64
+ };
65
+ connect = () => {
66
+ this.updateState(ServerStreamSubscriptionStatus.Connecting);
67
+ if (this.stream) {
68
+ this.addStateLog(`disconnect prev connection`);
69
+ this.stream();
70
+ }
71
+ const params = 'get' in this.params && typeof this.params.get === 'function' ? this.params.get() : this.params;
72
+ this.stream = this.method(params,
73
+ // ToDo: fix types
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
+ // @ts-ignore
76
+ this.onData, this.onStreamError, { headers: this.headers.getValues() });
77
+ this.updateState(ServerStreamSubscriptionStatus.Connected);
78
+ };
79
+ disconnect = () => {
80
+ if (this.stream) {
81
+ this.stream();
82
+ }
83
+ this.listeners.clear();
84
+ this.updateState(ServerStreamSubscriptionStatus.Disconnected);
85
+ };
86
+ reconnect = () => {
87
+ this.updateState(ServerStreamSubscriptionStatus.Reconnecting);
88
+ this.connect();
89
+ };
90
+ getStore = () => this.store?.getStore();
91
+ onData = (response) => {
92
+ this.addStateLog(`received data => ${JSON.stringify(response)}`);
93
+ if (this.store) {
94
+ this.store.setValue(response);
95
+ }
96
+ for (const [, listener] of this.listeners) {
97
+ listener(response);
98
+ }
99
+ this.addStateLog(`data routed to ${this.listeners.size} listeners`);
100
+ };
101
+ onStreamError = (error) => {
102
+ console.error(error);
103
+ this.updateState(ServerStreamSubscriptionStatus.Failed);
104
+ this.state.setValue('error', error);
105
+ };
106
+ }
107
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../../../packages/sdk-web-api/src/grpc/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAsB1G,IAAK,8BAQJ;AARD,WAAK,8BAA8B;IACjC,+CAAa,CAAA;IACb,iDAAe,CAAA;IACf,2DAAyB,CAAA;IACzB,yDAAuB,CAAA;IACvB,+DAA6B,CAAA;IAC7B,mDAAiB,CAAA;IACjB,+DAA6B,CAAA;AAC/B,CAAC,EARI,8BAA8B,KAA9B,8BAA8B,QAQlC;AAcD,MAAM,OAAO,wBAAwB;IAO5B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,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;SAC9B;QAED,KAAK,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YACzC,QAAQ,CAAC,QAAQ,CAAC,CAAA;SACnB;QAED,IAAI,CAAC,WAAW,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,CAAA;IACrE,CAAC,CAAA;IAEO,aAAa,GAAG,CAAC,KAAmB,EAAE,EAAE;QAC9C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAA;QACvD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC,CAAA;CACF"}
@@ -1,11 +1,14 @@
1
- import { createRouterTransport, ConnectRouter, Interceptor, PromiseClient, UnaryRequest, StreamRequest } from '@connectrpc/connect';
2
- import type { ServiceType } from '@bufbuild/protobuf';
1
+ import { createRouterTransport, ConnectRouter, Interceptor, PromiseClient, CallbackClient, UnaryRequest, StreamRequest } from '@connectrpc/connect';
2
+ import type { ServiceType, Message, PlainMessage } from '@bufbuild/protobuf';
3
3
  import { createGrpcWebTransport } from '@bufbuild/connect-web';
4
4
  import type { KeyInput } from '@nanostores/query';
5
5
  import { nanoquery } from '@nanostores/query';
6
+ import { Atom } from 'nanostores';
7
+ import { ServerStreamSubscription, type ServerStreamSubscriptionOptions } from './subscription';
6
8
  type KnownHeaders = {
7
9
  authorization?: string;
8
10
  sdk?: string;
11
+ 'sl-device-id': string;
9
12
  } & Record<string, string>;
10
13
  export type GrpcTransport = Transport['transport'];
11
14
  type ReservedHeaders = 'sdk' | 'authorization';
@@ -25,15 +28,26 @@ type NanoqueryObjectType = {
25
28
  * transport wrapper, initialize grpc transport, store headers and connect interceptors
26
29
  */
27
30
  export declare class Transport {
31
+ toJsonOptions: {
32
+ emitDefaultValues: boolean;
33
+ enumAsInteger: boolean;
34
+ useProtoFieldName: boolean;
35
+ };
28
36
  readonly transport: ReturnType<typeof createGrpcWebTransport>;
29
37
  readonly nanoquery: NanoqueryObjectType;
30
38
  protected interceptors: Interceptor[];
31
39
  private readonly $headers;
32
40
  private clients;
41
+ private callbackClients;
42
+ private subscriptions;
33
43
  constructor();
44
+ addSubscription: <T extends ServiceType, Req extends Message<Req>, Res extends Message<Res>>(method: CallbackClient<T>[import("./subscription").StreamMethod<T>], params: PlainMessage<Req> | Atom<PlainMessage<Req>>, options: ServerStreamSubscriptionOptions) => ServerStreamSubscription<ServiceType, Message<import("@bufbuild/protobuf").AnyMessage>, Message<import("@bufbuild/protobuf").AnyMessage>, never, never> | ServerStreamSubscription<T, Req, Res, import("./subscription").StreamMethod<T>, CallbackClient<T>[import("./subscription").StreamMethod<T>]>;
45
+ removeSubscription: (subscription: ServerStreamSubscription<ServiceType, Message, Message>) => void;
46
+ disconnect: () => void;
34
47
  registerInterceptor: (interceptor: Interceptor) => void;
35
48
  removeInterceptor: (interceptor: Interceptor) => void;
36
49
  getClient: <T extends ServiceType>(service: T) => PromiseClient<T>;
50
+ getCallbackClient: <T extends ServiceType>(service: T) => CallbackClient<T>;
37
51
  createPromiseClient: <T extends ServiceType>(service: T, { params, method }: {
38
52
  params?: KeyInput | undefined;
39
53
  method: keyof T["methods"];
@@ -42,6 +56,9 @@ export declare class Transport {
42
56
  queryKey: ((string | number) | import("nanostores").ReadableAtom<(string | number) | (void | null | undefined)>)[];
43
57
  queryKeyStr: string;
44
58
  };
59
+ createCallbackClient: <T extends ServiceType>(service: T) => {
60
+ client: CallbackClient<T>;
61
+ };
45
62
  setSdkKey: (sdkKey: string) => void;
46
63
  setAuth: (token?: string) => void;
47
64
  setHeader: <T extends string = string>(name: ExcludeReservedHeaders<T>, value: string) => void;
@@ -1,113 +1,164 @@
1
1
  import { MapStore, createMapStore } from '@streamlayer/sdk-web-interfaces';
2
- import { createRouterTransport, createPromiseClient } from '@connectrpc/connect';
2
+ import { createRouterTransport, createPromiseClient, createCallbackClient, } from '@connectrpc/connect';
3
3
  import { createGrpcWebTransport } from '@bufbuild/connect-web';
4
4
  import { nanoquery } from '@nanostores/query';
5
+ import { __GRPC_DEVTOOLS_EXTENSION__ } from '../utils/devtools';
6
+ import { ServerStreamSubscription } from './subscription';
5
7
  /**
6
8
  * transport wrapper, initialize grpc transport, store headers and connect interceptors
7
- */ export class Transport {
8
- constructor(){
9
- this.interceptors = [];
10
- this.registerInterceptor = (interceptor)=>{
11
- this.interceptors.push(interceptor);
12
- };
13
- this.removeInterceptor = (interceptor)=>{
14
- this.interceptors = this.interceptors.filter((i)=>i !== interceptor);
15
- };
16
- this.getClient = (service)=>{
17
- const serviceName = service.typeName;
18
- if (this.clients.has(serviceName)) {
19
- return this.clients.get(serviceName);
20
- }
21
- const client = createPromiseClient(service, this.transport);
22
- this.clients.set(serviceName, client);
23
- return client;
24
- };
25
- this.createPromiseClient = (service, { params = [], method })=>{
26
- const client = this.getClient(service);
27
- const methodName = service.methods[method].name;
28
- const queryKey = [
29
- service.typeName,
30
- methodName.charAt(0).toLowerCase() + methodName.slice(1),
31
- ...Array.isArray(params) ? params : [
32
- params
33
- ]
34
- ];
35
- return {
36
- client,
37
- queryKey,
38
- queryKeyStr: queryKey.toString()
39
- };
40
- };
41
- this.setSdkKey = (sdkKey)=>{
42
- this.$headers.setValue('sdk', sdkKey);
43
- };
44
- this.setAuth = (token)=>{
45
- this.$headers.setValue('authorization', token);
46
- };
47
- this.setHeader = (name, value)=>this.$headers.setValue(name, value);
48
- this.getHeader = (name)=>this.$headers.getValue(name);
49
- this.getHeaders = ()=>this.$headers.getValues();
50
- this.initInterceptors = ()=>{
51
- if (this.interceptors.length !== 0) {
52
- return;
53
- }
54
- const auth = (next)=>async (req)=>{
55
- const headers = this.$headers.getValues();
56
- for(const header in headers){
57
- req.header.set(header, headers[header]);
58
- }
59
- try {
60
- return await next(req);
61
- } catch (err) {
62
- // eslint-disable-next-line no-console
63
- console.log({
64
- err
65
- }, 'catch err') // logout and something like this
66
- ;
67
- throw err;
68
- }
69
- };
70
- this.interceptors.push(auth);
71
- if (window.__GRPC_DEVTOOLS_EXTENSION__) {
72
- this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__());
73
- } else {
74
- window.addEventListener('grpc_devtools_loaded', ()=>{
75
- if (window.__GRPC_DEVTOOLS_EXTENSION__) {
76
- this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__());
77
- }
78
- });
79
- }
80
- };
81
- this.$headers = new MapStore(createMapStore({}));
9
+ */
10
+ export class Transport {
11
+ toJsonOptions = {
12
+ emitDefaultValues: false,
13
+ enumAsInteger: true,
14
+ useProtoFieldName: false,
15
+ };
16
+ transport;
17
+ nanoquery;
18
+ interceptors = [];
19
+ $headers;
20
+ clients;
21
+ callbackClients;
22
+ subscriptions;
23
+ constructor() {
24
+ this.$headers = new MapStore(createMapStore({
25
+ ['sl-device-id']: process.env.NX_DEVICE_ID || 'sdk-web-dev',
26
+ }), 'transport:headers');
82
27
  this.initInterceptors();
83
28
  this.clients = new Map();
29
+ this.callbackClients = new Map();
30
+ this.subscriptions = new Map();
84
31
  const [createFetcherStore, createMutatorStore, utils] = nanoquery();
85
- this.nanoquery = {
86
- createFetcherStore,
87
- createMutatorStore,
88
- utils
89
- };
32
+ this.nanoquery = { createFetcherStore, createMutatorStore, utils };
90
33
  this.transport = createGrpcWebTransport({
91
34
  baseUrl: process.env.NX_GRPC_HOST || 'https://grpc-web.next.streamlayer.io:443',
35
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
+ // @ts-ignore
92
37
  interceptors: this.interceptors,
93
- useBinaryFormat: true
38
+ useBinaryFormat: true,
94
39
  });
95
40
  }
41
+ // use shared request params, based on Atom, each new Atom will create new subscription
42
+ // mutate Atom, subscription automatically reconnect with new params
43
+ // if headers changed, reconnect subscription with new headers automatically
44
+ addSubscription = (method, params, options) => {
45
+ const currentSubscription = this.subscriptions.get(params);
46
+ if (currentSubscription) {
47
+ return currentSubscription;
48
+ }
49
+ const subscription = new ServerStreamSubscription(this.$headers, method, params, options);
50
+ // ToDo: fix types
51
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ // @ts-ignore
53
+ this.subscriptions.set(params, subscription);
54
+ return subscription;
55
+ };
56
+ removeSubscription = (subscription) => {
57
+ subscription.disconnect();
58
+ this.subscriptions.delete(subscription.params);
59
+ };
60
+ // cleanup subscriptions
61
+ disconnect = () => {
62
+ for (const [name, subscription] of this.subscriptions) {
63
+ subscription.disconnect();
64
+ this.subscriptions.delete(name);
65
+ }
66
+ };
67
+ registerInterceptor = (interceptor) => {
68
+ this.interceptors.push(interceptor);
69
+ };
70
+ removeInterceptor = (interceptor) => {
71
+ this.interceptors = this.interceptors.filter((i) => i !== interceptor);
72
+ };
73
+ getClient = (service) => {
74
+ const serviceName = service.typeName;
75
+ if (this.clients.has(serviceName)) {
76
+ return this.clients.get(serviceName);
77
+ }
78
+ const client = createPromiseClient(service, this.transport);
79
+ this.clients.set(serviceName, client);
80
+ return client;
81
+ };
82
+ getCallbackClient = (service) => {
83
+ const serviceName = service.typeName;
84
+ if (this.callbackClients.has(serviceName)) {
85
+ return this.callbackClients.get(serviceName);
86
+ }
87
+ const client = createCallbackClient(service, this.transport);
88
+ this.callbackClients.set(serviceName, client);
89
+ return client;
90
+ };
91
+ // create unary client, used for query request
92
+ createPromiseClient = (service, { params = [], method }) => {
93
+ const client = this.getClient(service);
94
+ const methodName = service.methods[method].name;
95
+ const queryKey = [
96
+ service.typeName,
97
+ methodName.charAt(0).toLowerCase() + methodName.slice(1),
98
+ ...(Array.isArray(params) ? params : [params]),
99
+ ];
100
+ const queryKeyWithoutParams = [service.typeName, methodName.charAt(0).toLowerCase() + methodName.slice(1)];
101
+ return { client, queryKey, queryKeyStr: queryKeyWithoutParams.join('') };
102
+ };
103
+ // create callback client, used for server stream subscriptions
104
+ createCallbackClient = (service) => {
105
+ const client = this.getCallbackClient(service);
106
+ return { client };
107
+ };
108
+ setSdkKey = (sdkKey) => {
109
+ this.$headers.setValue('sdk', sdkKey);
110
+ };
111
+ setAuth = (token) => {
112
+ this.$headers.setValue('authorization', token);
113
+ };
114
+ setHeader = (name, value) => this.$headers.setValue(name, value);
115
+ getHeader = (name) => this.$headers.getValue(name);
116
+ getHeaders = () => this.$headers.getValues();
117
+ initInterceptors = () => {
118
+ if (this.interceptors.length !== 0) {
119
+ return;
120
+ }
121
+ const auth = (next) => async (req) => {
122
+ const headers = this.$headers.getValues();
123
+ for (const header in headers) {
124
+ req.header.set(header, headers[header]);
125
+ }
126
+ try {
127
+ return await next(req);
128
+ }
129
+ catch (err) {
130
+ // eslint-disable-next-line no-console
131
+ console.log({ err, req }, 'catch err'); // logout and something like this
132
+ throw err;
133
+ }
134
+ };
135
+ this.interceptors.push(auth);
136
+ this.interceptors.push(__GRPC_DEVTOOLS_EXTENSION__());
137
+ // if (window.__GRPC_DEVTOOLS_EXTENSION__) {
138
+ // this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__())
139
+ // } else {
140
+ // window.addEventListener('grpc_devtools_loaded', () => {
141
+ // if (window.__GRPC_DEVTOOLS_EXTENSION__) {
142
+ // this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__())
143
+ // }
144
+ // })
145
+ // }
146
+ };
96
147
  }
97
148
  export class MockTransport extends Transport {
98
- constructor(transport){
149
+ calls;
150
+ constructor(transport) {
99
151
  super();
100
152
  this.calls = [];
101
- this.interceptors.push((next)=>(req)=>{
102
- this.calls.push(req);
103
- return next(req);
104
- });
153
+ this.interceptors.push((next) => (req) => {
154
+ this.calls.push(req);
155
+ return next(req);
156
+ });
105
157
  this.transport = createRouterTransport(transport, {
106
158
  transport: {
107
- interceptors: this.interceptors
108
- }
159
+ interceptors: this.interceptors,
160
+ },
109
161
  });
110
162
  }
111
163
  }
112
-
113
164
  //# sourceMappingURL=transport.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web-api/src/grpc/transport.ts"],"sourcesContent":["import { MapStore, createMapStore } from '@streamlayer/sdk-web-interfaces'\n\nimport {\n createRouterTransport,\n ConnectRouter,\n Interceptor,\n createPromiseClient,\n PromiseClient,\n UnaryRequest,\n StreamRequest,\n} from '@connectrpc/connect'\nimport type { ServiceType } from '@bufbuild/protobuf'\nimport { createGrpcWebTransport } from '@bufbuild/connect-web'\nimport type { KeyInput } from '@nanostores/query'\nimport { nanoquery } from '@nanostores/query'\n\ntype KnownHeaders = {\n authorization?: string\n sdk?: string\n} & Record<string, string>\n\nexport type GrpcTransport = Transport['transport']\n\ntype ReservedHeaders = 'sdk' | 'authorization'\ntype ExcludeReservedHeaders<T> = ReservedHeaders extends T ? never : T extends ReservedHeaders ? never : T\n\ndeclare global {\n interface Window {\n __GRPC_DEVTOOLS_EXTENSION__?: () => import('@connectrpc/connect').Interceptor\n }\n}\ntype NanoqueryReturnType = ReturnType<typeof nanoquery>\ntype NanoqueryObjectType = {\n createFetcherStore: NanoqueryReturnType[0]\n createMutatorStore: NanoqueryReturnType[1]\n utils: NanoqueryReturnType[2]\n}\n\n/**\n * transport wrapper, initialize grpc transport, store headers and connect interceptors\n */\nexport class Transport {\n public readonly transport: ReturnType<typeof createGrpcWebTransport>\n public readonly nanoquery: NanoqueryObjectType\n\n protected interceptors: Interceptor[] = []\n private readonly $headers: MapStore<KnownHeaders>\n private clients: Map<keyof ServiceType['methods'], PromiseClient<ServiceType>>\n\n constructor() {\n this.$headers = new MapStore<KnownHeaders>(createMapStore({}))\n this.initInterceptors()\n this.clients = new Map()\n const [createFetcherStore, createMutatorStore, utils] = nanoquery()\n\n this.nanoquery = { createFetcherStore, createMutatorStore, utils }\n\n this.transport = createGrpcWebTransport({\n baseUrl: process.env.NX_GRPC_HOST || 'https://grpc-web.next.streamlayer.io:443',\n interceptors: this.interceptors,\n useBinaryFormat: true,\n })\n }\n\n registerInterceptor = (interceptor: Interceptor) => {\n this.interceptors.push(interceptor)\n }\n\n removeInterceptor = (interceptor: Interceptor) => {\n this.interceptors = this.interceptors.filter((i) => i !== interceptor)\n }\n\n getClient = <T extends ServiceType>(service: T): PromiseClient<T> => {\n const serviceName = service.typeName\n\n if (this.clients.has(serviceName)) {\n return this.clients.get(serviceName) as PromiseClient<T>\n }\n\n const client = createPromiseClient(service, this.transport)\n\n this.clients.set(serviceName, client)\n\n return client\n }\n\n createPromiseClient = <T extends ServiceType>(\n service: T,\n { params = [], method }: { params?: KeyInput; method: keyof T['methods'] },\n ) => {\n const client = this.getClient(service)\n\n const methodName = service.methods[method].name\n const queryKey = [\n service.typeName,\n methodName.charAt(0).toLowerCase() + methodName.slice(1),\n ...(Array.isArray(params) ? params : [params]),\n ]\n\n return { client, queryKey, queryKeyStr: queryKey.toString() }\n }\n\n setSdkKey = (sdkKey: string) => {\n this.$headers.setValue('sdk', sdkKey)\n }\n\n setAuth = (token?: string) => {\n this.$headers.setValue('authorization', token)\n }\n\n setHeader = <T extends keyof KnownHeaders = string>(name: ExcludeReservedHeaders<T>, value: string) =>\n this.$headers.setValue<string>(name, value)\n\n getHeader = (name: keyof KnownHeaders) => this.$headers.getValue(name)\n\n getHeaders = () => this.$headers.getValues()\n\n initInterceptors = () => {\n if (this.interceptors.length !== 0) {\n return\n }\n\n const auth: Interceptor = (next) => async (req) => {\n const headers = this.$headers.getValues()\n\n for (const header in headers) {\n req.header.set(header, headers[header])\n }\n try {\n return await next(req)\n } catch (err: unknown) {\n // eslint-disable-next-line no-console\n console.log({ err }, 'catch err') // logout and something like this\n\n throw err\n }\n }\n\n this.interceptors.push(auth)\n\n if (window.__GRPC_DEVTOOLS_EXTENSION__) {\n this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__())\n } else {\n window.addEventListener('grpc_devtools_loaded', () => {\n if (window.__GRPC_DEVTOOLS_EXTENSION__) {\n this.interceptors.push(window.__GRPC_DEVTOOLS_EXTENSION__())\n }\n })\n }\n }\n}\n\nexport class MockTransport extends Transport {\n public declare transport: ReturnType<typeof createRouterTransport>\n public calls: Array<UnaryRequest | StreamRequest>\n\n constructor(transport: (router: ConnectRouter) => void) {\n super()\n\n this.calls = []\n this.interceptors.push((next) => (req) => {\n this.calls.push(req)\n\n return next(req)\n })\n this.transport = createRouterTransport(transport, {\n transport: {\n interceptors: this.interceptors,\n },\n })\n }\n}\n"],"names":["MapStore","createMapStore","createRouterTransport","createPromiseClient","createGrpcWebTransport","nanoquery","Transport","constructor","interceptors","registerInterceptor","interceptor","push","removeInterceptor","filter","i","getClient","service","serviceName","typeName","clients","has","get","client","transport","set","params","method","methodName","methods","name","queryKey","charAt","toLowerCase","slice","Array","isArray","queryKeyStr","toString","setSdkKey","sdkKey","$headers","setValue","setAuth","token","setHeader","value","getHeader","getValue","getHeaders","getValues","initInterceptors","length","auth","next","req","headers","header","err","console","log","window","__GRPC_DEVTOOLS_EXTENSION__","addEventListener","Map","createFetcherStore","createMutatorStore","utils","baseUrl","process","env","NX_GRPC_HOST","useBinaryFormat","MockTransport","calls"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,cAAc,QAAQ,kCAAiC;AAE1E,SACEC,qBAAqB,EAGrBC,mBAAmB,QAId,sBAAqB;AAE5B,SAASC,sBAAsB,QAAQ,wBAAuB;AAE9D,SAASC,SAAS,QAAQ,oBAAmB;AAwB7C;;CAEC,GACD,OAAO,MAAMC;IAQXC,aAAc;aAJJC,eAA8B,EAAE;aAmB1CC,sBAAsB,CAACC;YACrB,IAAI,CAACF,YAAY,CAACG,IAAI,CAACD;QACzB;aAEAE,oBAAoB,CAACF;YACnB,IAAI,CAACF,YAAY,GAAG,IAAI,CAACA,YAAY,CAACK,MAAM,CAAC,CAACC,IAAMA,MAAMJ;QAC5D;aAEAK,YAAY,CAAwBC;YAClC,MAAMC,cAAcD,QAAQE,QAAQ;YAEpC,IAAI,IAAI,CAACC,OAAO,CAACC,GAAG,CAACH,cAAc;gBACjC,OAAO,IAAI,CAACE,OAAO,CAACE,GAAG,CA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AAM,OAAO,aAAc,SAAQ,SAAS;IAEnC,KAAK,CAAqC;IAEjD,YAAY,SAA0C;QACpD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAEpB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,SAAS,EAAE;YAChD,SAAS,EAAE;gBACT,YAAY,EAAE,IAAI,CAAC,YAAY;aAChC;SACF,CAAC,CAAA;IACJ,CAAC;CACF"}
package/src/index.d.ts CHANGED
@@ -1,5 +1,16 @@
1
+ import { StreamLayerContext } from '@streamlayer/sdk-web-interfaces';
1
2
  import { FetcherStore } from '@nanostores/query';
3
+ export type { ServerStreamSubscriptionOptions } from './grpc/subscription';
2
4
  export { Transport } from './grpc/transport';
5
+ import { Transport } from './grpc/transport';
3
6
  export type { GrpcTransport } from './grpc/transport';
4
7
  export * as queries from './grpc/queries';
5
8
  export type GetApiResponseType<T extends (...args: any[]) => FetcherStore> = ReturnType<ReturnType<T>['get']>['data'];
9
+ declare module '@streamlayer/sdk-web-interfaces' {
10
+ interface StreamLayerContext {
11
+ transport: Transport;
12
+ }
13
+ }
14
+ export declare const transport: (instance: StreamLayerContext, opts: {
15
+ sdkKey: string;
16
+ }, done: () => void) => void;
package/src/index.js CHANGED
@@ -1,4 +1,9 @@
1
1
  export { Transport } from './grpc/transport';
2
+ import { Transport } from './grpc/transport';
2
3
  export * as queries from './grpc/queries';
3
-
4
+ export const transport = (instance, opts, done) => {
5
+ instance.transport = new Transport();
6
+ instance.transport.setSdkKey(opts.sdkKey);
7
+ done();
8
+ };
4
9
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/sdk-web-api/src/index.ts"],"sourcesContent":["import { FetcherStore } from '@nanostores/query'\n\nexport { Transport } from './grpc/transport'\nexport type { GrpcTransport } from './grpc/transport'\nexport * as queries from './grpc/queries'\nexport type GetApiResponseType<T extends (...args: any[]) => FetcherStore> = ReturnType<ReturnType<T>['get']>['data']\n"],"names":["Transport","queries"],"mappings":"AAEA,SAASA,SAAS,QAAQ,mBAAkB;AAE5C,OAAO,KAAKC,OAAO,MAAM,iBAAgB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/sdk-web-api/src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AASzC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAA4B,EAAE,IAAwB,EAAE,IAAgB,EAAE,EAAE;IACpG,QAAQ,CAAC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAA;IACpC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzC,IAAI,EAAE,CAAA;AACR,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const __GRPC_DEVTOOLS_EXTENSION__: any;
@@ -0,0 +1,66 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+ async function* logEach(store, stream) {
4
+ for await (const m of stream) {
5
+ store.response.message = m;
6
+ store.received_at = Date.now();
7
+ const msg = {
8
+ type: '__GRPC_DEVTOOLS_EXTENSION__',
9
+ data: store,
10
+ };
11
+ window.postMessage(msg);
12
+ yield m;
13
+ }
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ export const __GRPC_DEVTOOLS_EXTENSION__ = () => (next) => async (request) => {
17
+ const store = {
18
+ name: request.url,
19
+ request: {},
20
+ response: {},
21
+ };
22
+ store.request.header = Object.fromEntries(request.header.entries());
23
+ store.sent_at = Date.now();
24
+ try {
25
+ const response = await next(request);
26
+ store.received_at = Date.now();
27
+ store.stream = response.stream;
28
+ store.response.header = Object.fromEntries(response.header.entries());
29
+ store.response.trailer = Object.fromEntries(response.trailer.entries());
30
+ if (!response.stream) {
31
+ store.request.message = request.message;
32
+ store.response.message = response.message;
33
+ store.latency = store.received_at - store.sent_at;
34
+ const msg = {
35
+ type: '__GRPC_DEVTOOLS_EXTENSION__',
36
+ data: store,
37
+ };
38
+ window.postMessage(msg);
39
+ }
40
+ else {
41
+ return {
42
+ ...response,
43
+ message: logEach(store, response.message),
44
+ };
45
+ }
46
+ return response;
47
+ }
48
+ catch (e) {
49
+ store.received_at = Date.now();
50
+ store.request.message = request.message;
51
+ store.response.trailer = {
52
+ ['grpc-status']: e.code,
53
+ ['grpc-message']: e.rawMessage,
54
+ };
55
+ store.response.message = e.rawMessage;
56
+ store.latency = store.received_at - store.sent_at;
57
+ const msg = {
58
+ type: '__GRPC_DEVTOOLS_EXTENSION__',
59
+ data: store,
60
+ };
61
+ window.postMessage(msg);
62
+ throw e;
63
+ }
64
+ };
65
+ window.dispatchEvent(new CustomEvent('grpc_devtools_loaded'));
66
+ //# sourceMappingURL=devtools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.js","sourceRoot":"","sources":["../../../../../packages/sdk-web-api/src/utils/devtools.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc;AACd,KAAK,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM;IACnC,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,EAAE;QAC5B,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAA;QAC1B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC9B,MAAM,GAA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AAW,GAAG,KAAK,CAAC,OAAO,CAAA;YACjD,MAAM,GAAG,GAAG;gBACV,IAAI,EAAE,6BAA6B;gBACnC,IAAI,EAAE,KAAK;aACZ,CAAA;YAED,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;SACxB;aAAM;YACL,OAAO;gBACL,GAAG,QAAQ;gBACX,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;aAC1C,CAAA;SACF;QAED,OAAO,QAAQ,CAAA;KAChB;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC9B,KAAK,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QACvC,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG;YACvB,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,IAAI;YACvB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,UAAU;SAC/B,CAAA;QACD,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC,UAAU,CAAA;QACrC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAA;QACjD,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,6BAA6B;YACnC,IAAI,EAAE,KAAK;SACZ,CAAA;QAED,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAEvB,MAAM,CAAC,CAAA;KACR;AACH,CAAC,CAAA;AAED,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,sBAAsB,CAAC,CAAC,CAAA"}
@@ -1,36 +1,24 @@
1
1
  import { Transport } from '..';
2
2
  export class GrpcStub {
3
- constructor(){
4
- this.stub = (method, response)=>{
5
- this.stubs.set(method.toLowerCase(), response);
6
- };
3
+ transport;
4
+ stubs;
5
+ constructor() {
7
6
  this.transport = new Transport();
8
7
  this.stubs = new Map();
9
- const stubbedUnary = (service, method, signal, timeoutMs, header, input)=>{
8
+ const stubbedUnary = (service, method, signal, timeoutMs, header, input) => {
10
9
  const key = `${service.typeName}${method.name}`.toLowerCase();
11
- console.log('grpc unary', {
12
- key,
13
- input
14
- });
15
- for (const [stubKey, stubValue] of this.stubs){
10
+ console.log('grpc unary', { key, input });
11
+ for (const [stubKey, stubValue] of this.stubs) {
16
12
  if (stubKey === key) {
17
- return {
18
- message: stubValue
19
- };
13
+ return { message: stubValue };
20
14
  }
21
15
  }
22
- throw new Error(JSON.stringify({
23
- message: 'not stubbed correctly',
24
- service,
25
- method,
26
- signal,
27
- timeoutMs,
28
- header,
29
- input
30
- }));
16
+ throw new Error(JSON.stringify({ message: 'not stubbed correctly', service, method, signal, timeoutMs, header, input }));
31
17
  };
32
18
  this.transport.transport.unary = stubbedUnary;
33
19
  }
20
+ stub = (method, response) => {
21
+ this.stubs.set(method.toLowerCase(), response);
22
+ };
34
23
  }
35
-
36
24
  //# sourceMappingURL=grpc-stub.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web-api/src/utils/grpc-stub.ts"],"sourcesContent":["import { Transport as BufTransport, UnaryResponse } from '@connectrpc/connect'\nimport type { AnyMessage, Message } from '@bufbuild/protobuf'\n\nimport { Transport } from '..'\n\ntype Unary = BufTransport['unary']\n\nexport class GrpcStub {\n public readonly transport: Transport\n private stubs: Map<string, Record<string, unknown>>\n\n constructor() {\n this.transport = new Transport()\n this.stubs = new Map()\n\n const stubbedUnary: Unary = <I extends Message<I> = AnyMessage, O extends Message<O> = AnyMessage>(\n service: Parameters<Unary>[0],\n method: Parameters<Unary>[1],\n signal: Parameters<Unary>[2],\n timeoutMs: Parameters<Unary>[3],\n header: Parameters<Unary>[4],\n input: Parameters<Unary>[5],\n ) => {\n const key = `${service.typeName}${method.name}`.toLowerCase()\n\n console.log('grpc unary', { key, input })\n\n for (const [stubKey, stubValue] of this.stubs) {\n if (stubKey === key) {\n return { message: stubValue } as unknown as Promise<UnaryResponse<I, O>>\n }\n }\n\n throw new Error(\n JSON.stringify({ message: 'not stubbed correctly', service, method, signal, timeoutMs, header, input }),\n )\n }\n\n this.transport.transport.unary = stubbedUnary\n }\n\n stub = (method: string, response: Record<string, unknown>) => {\n this.stubs.set(method.toLowerCase(), response)\n }\n}\n"],"names":["Transport","GrpcStub","constructor","stub","method","response","stubs","set","toLowerCase","transport","Map","stubbedUnary","service","signal","timeoutMs","header","input","key","typeName","name","console","log","stubKey","stubValue","message","Error","JSON","stringify","unary"],"mappings":"AAGA,SAASA,SAAS,QAAQ,KAAI;AAI9B,OAAO,MAAMC;IAIXC,aAAc;aA8BdC,OAAO,CAACC,QAAgBC;YACtB,IAAI,CAACC,KAAK,CAACC,GAAG,CAACH,OAAOI,WAAW,IAAIH;QACvC;QA/BE,IAAI,CAACI,SAAS,GAAG,IAAIT;QACrB,IAAI,CAACM,KAAK,GAAG,IAAII;QAEjB,MAAMC,eAAsB,CAC1BC,SACAR,QACAS,QACAC,WACAC,QACAC;YAEA,MAAMC,MAAM,CAAC,EAAEL,QAAQM,QAAQ,CAAC,EAAEd,OAAOe,IAAI,CAAC,CAAC,CAACX,WAAW;YAE3DY,QAAQC,GAAG,CAAC,cAAc;gBAAEJ;gBAAKD;YAAM;YAEvC,KAAK,MAAM,CAACM,SAASC,UAAU,IAAI,IAAI,CAACjB,KAAK,CAAE;gBAC7C,IAAIgB,YAAYL,KAAK;oBACnB,OAAO;wBAAEO,SAASD;oBAAU;gBAC9B;YACF;YAEA,MAAM,IAAIE,MACRC,KAAKC,SAAS,CAAC;gBAAEH,SAAS;gBAAyBZ;gBAASR;gBAAQS;gBAAQC;gBAAWC;gBAAQC;YAAM;QAEzG;QAEA,IAAI,CAACP,SAAS,CAACA,SAAS,CAACmB,KAAK,GAAGjB;IACnC;AAKF"}
1
+ {"version":3,"file":"grpc-stub.js","sourceRoot":"","sources":["../../../../../packages/sdk-web-api/src/utils/grpc-stub.ts"],"names":[],"mappings":"AAGA,OA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streamlayer/sl-eslib/streamlayer/sports/events/events_connect';
3
- import { MockTransport } from '../transport';
4
- import { $retrieveEventId } from './event';
5
- describe('Simple requests test', ()=>{
6
- const ctx = {
7
- providerStreamId: createSingleStore('')
8
- };
9
- beforeAll(()=>{
10
- const mock = ({ service })=>{
11
- service(Events, {
12
- retrieveEventId: ()=>({
13
- data: {
14
- id: 123
15
- }
16
- })
17
- });
18
- };
19
- ctx.transport = new MockTransport(mock);
20
- ctx.api = new ApiStore($retrieveEventId(ctx.providerStreamId, ctx.transport));
21
- ctx.api.listen(()=>{});
22
- });
23
- afterAll(()=>{
24
- ctx.api.off();
25
- });
26
- it('returns empty sl event id if provider id not defined', async ()=>{
27
- const emptyEvent = await ctx.api.getValue();
28
- expect(emptyEvent).toEqual('');
29
- });
30
- it('returns sl event id if provider id defined', async ()=>{
31
- ctx.providerStreamId.set('demo:event');
32
- const resolvedEvent = await ctx.api.getValue();
33
- expect(resolvedEvent).toEqual('123');
34
- });
35
- });
36
-
37
- //# sourceMappingURL=queries.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web-api/src/grpc/queries/queries.test.ts"],"sourcesContent":["import { ApiStore, createSingleStore } from '@streamlayer/sdk-web-interfaces'\n\nimport { Events } from '@streamlayer/sl-eslib/streamlayer/sports/events/events_connect'\n\nimport { MockTransport } from '../transport'\n\nimport { $retrieveEventId } from './event'\n\ndescribe('Simple requests test', () => {\n const ctx: {\n providerStreamId: ReturnType<typeof createSingleStore<string>>\n api?: ApiStore<ReturnType<typeof $retrieveEventId>>\n transport?: MockTransport\n } = {\n providerStreamId: createSingleStore(''),\n }\n\n beforeAll(() => {\n const mock = ({ service }) => {\n service(Events, {\n retrieveEventId: () => ({ data: { id: 123 } }),\n })\n }\n\n ctx.transport = new MockTransport(mock)\n\n ctx.api = new ApiStore($retrieveEventId(ctx.providerStreamId, ctx.transport))\n ctx.api.listen(() => {})\n })\n\n afterAll(() => {\n ctx.api.off()\n })\n\n it('returns empty sl event id if provider id not defined', async () => {\n const emptyEvent = await ctx.api.getValue()\n\n expect(emptyEvent).toEqual('')\n })\n\n it('returns sl event id if provider id defined', async () => {\n ctx.providerStreamId.set('demo:event')\n const resolvedEvent = await ctx.api.getValue()\n\n expect(resolvedEvent).toEqual('123')\n })\n})\n"],"names":["ApiStore","createSingleStore","Events","MockTransport","$retrieveEventId","describe","ctx","providerStreamId","beforeAll","mock","service","retrieveEventId","data","id","transport","api","listen","afterAll","off","it","emptyEvent","getValue","expect","toEqual","set","resolvedEvent"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,iBAAiB,QAAQ,kCAAiC;AAE7E,SAASC,MAAM,QAAQ,iEAAgE;AAEvF,SAASC,aAAa,QAAQ,eAAc;AAE5C,SAASC,gBAAgB,QAAQ,UAAS;AAE1CC,SAAS,wBAAwB;IAC/B,MAAMC,MAIF;QACFC,kBAAkBN,kBAAkB;IACtC;IAEAO,UAAU;QACR,MAAMC,OAAO,CAAC,EAAEC,OAAO,EAAE;YACvBA,QAAQR,QAAQ;gBACdS,iBAAiB,IAAO,CAAA;wBAAEC,MAAM;4BAAEC,IAAI;wBAAI;oBAAE,CAAA;YAC9C;QACF;QAEAP,IAAIQ,SAAS,GAAG,IAAIX,cAAcM;QAElCH,IAAIS,GAAG,GAAG,IAAIf,SAASI,iBAAiBE,IAAIC,gBAAgB,EAAED,IAAIQ,SAAS;QAC3ER,IAAIS,GAAG,CAACC,MAAM,CAAC,KAAO;IACxB;IAEAC,SAAS;QACPX,IAAIS,GAAG,CAACG,GAAG;IACb;IAEAC,GAAG,wDAAwD;QACzD,MAAMC,aAAa,MAAMd,IAAIS,GAAG,CAACM,QAAQ;QAEzCC,OAAOF,YAAYG,OAAO,CAAC;IAC7B;IAEAJ,GAAG,8CAA8C;QAC/Cb,IAAIC,gBAAgB,CAACiB,GAAG,CAAC;QACzB,MAAMC,gBAAgB,MAAMnB,IAAIS,GAAG,CAACM,QAAQ;QAE5CC,OAAOG,eAAeF,OAAO,CAAC;IAChC;AACF"}
@@ -1,81 +0,0 @@
1
- import { Health } from '@streamlayer/sl-eslib/grpc/health/v1/health_connect';
2
- import { MockTransport } from './transport';
3
- describe('Transport', ()=>{
4
- let transport;
5
- beforeAll(()=>{
6
- const mock = ({ service })=>{
7
- service(Health, {
8
- check: ()=>({
9
- status: 1
10
- })
11
- });
12
- };
13
- transport = new MockTransport(mock);
14
- });
15
- it('should initialize with default values', ()=>{
16
- expect(transport).toBeDefined();
17
- expect(transport.transport).toBeDefined();
18
- });
19
- it('should set SDK key', ()=>{
20
- const sdkKey = 'new-sdk-key';
21
- transport.setSdkKey(sdkKey);
22
- const headers = transport.getHeaders();
23
- expect(headers.sdk).toEqual(sdkKey);
24
- });
25
- it('should set authorization token', ()=>{
26
- const authToken = 'my-auth-token';
27
- transport.setAuth(authToken);
28
- const headers = transport.getHeaders();
29
- expect(headers.authorization).toEqual(authToken);
30
- });
31
- it('should set custom header', ()=>{
32
- const headerName = 'custom-header';
33
- const headerValue = 'custom-value';
34
- transport.setHeader(headerName, headerValue);
35
- const headers = transport.getHeaders();
36
- expect(headers[headerName]).toEqual(headerValue);
37
- });
38
- it('should get a specific header', ()=>{
39
- const headerName = 'custom-header';
40
- const headerValue = 'custom-value';
41
- transport.setHeader(headerName, headerValue);
42
- const retrievedValue = transport.getHeader(headerName);
43
- expect(retrievedValue).toEqual(headerValue);
44
- });
45
- it('should add/remove an interceptor', ()=>{
46
- const interceptor = (req)=>req;
47
- transport.registerInterceptor(interceptor);
48
- expect(transport['interceptors']).toContain(interceptor);
49
- transport.removeInterceptor(interceptor);
50
- expect(transport['interceptors']).not.toContain(interceptor);
51
- });
52
- it('should create and cache promise client', ()=>{
53
- const { client, queryKey } = transport.createPromiseClient(Health, {
54
- method: 'check'
55
- });
56
- expect(client).toBeDefined();
57
- expect(client.check).toBeDefined();
58
- expect(queryKey).toBeDefined();
59
- const { client: newClient, queryKey: newQueryKey } = transport.createPromiseClient(Health, {
60
- method: 'check'
61
- });
62
- expect(client === newClient);
63
- expect(queryKey !== newQueryKey);
64
- });
65
- it('should use all headers from store', async ()=>{
66
- const { client } = transport.createPromiseClient(Health, {
67
- method: 'check'
68
- });
69
- const res = await client.check({});
70
- expect(res?.status);
71
- expect(res.status).toEqual(1);
72
- const lastCall = transport.calls.pop();
73
- const headers = transport.getHeaders();
74
- expect(lastCall).toBeDefined();
75
- for(const header in headers){
76
- expect(lastCall?.header.get(header)).toEqual(headers[header]);
77
- }
78
- });
79
- });
80
-
81
- //# sourceMappingURL=transport.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web-api/src/grpc/transport.test.ts"],"sourcesContent":["import { Health } from '@streamlayer/sl-eslib/grpc/health/v1/health_connect'\n\nimport { MockTransport } from './transport'\n\ndescribe('Transport', () => {\n let transport: MockTransport\n\n beforeAll(() => {\n const mock = ({ service }) => {\n service(Health, {\n check: () => ({ status: 1 }),\n })\n }\n\n transport = new MockTransport(mock)\n })\n\n it('should initialize with default values', () => {\n expect(transport).toBeDefined()\n expect(transport.transport).toBeDefined()\n })\n\n it('should set SDK key', () => {\n const sdkKey = 'new-sdk-key'\n\n transport.setSdkKey(sdkKey)\n const headers = transport.getHeaders()\n\n expect(headers.sdk).toEqual(sdkKey)\n })\n\n it('should set authorization token', () => {\n const authToken = 'my-auth-token'\n\n transport.setAuth(authToken)\n const headers = transport.getHeaders()\n\n expect(headers.authorization).toEqual(authToken)\n })\n\n it('should set custom header', () => {\n const headerName = 'custom-header'\n const headerValue = 'custom-value'\n\n transport.setHeader(headerName, headerValue)\n const headers = transport.getHeaders()\n\n expect(headers[headerName]).toEqual(headerValue)\n })\n\n it('should get a specific header', () => {\n const headerName = 'custom-header'\n const headerValue = 'custom-value'\n\n transport.setHeader(headerName, headerValue)\n const retrievedValue = transport.getHeader(headerName)\n\n expect(retrievedValue).toEqual(headerValue)\n })\n\n it('should add/remove an interceptor', () => {\n const interceptor = (req) => req\n\n transport.registerInterceptor(interceptor)\n expect(transport['interceptors']).toContain(interceptor)\n\n transport.removeInterceptor(interceptor)\n expect(transport['interceptors']).not.toContain(interceptor)\n })\n\n it('should create and cache promise client', () => {\n const { client, queryKey } = transport.createPromiseClient(Health, { method: 'check' })\n\n expect(client).toBeDefined()\n expect(client.check).toBeDefined()\n expect(queryKey).toBeDefined()\n\n const { client: newClient, queryKey: newQueryKey } = transport.createPromiseClient(Health, { method: 'check' })\n\n expect(client === newClient)\n expect(queryKey !== newQueryKey)\n })\n\n it('should use all headers from store', async () => {\n const { client } = transport.createPromiseClient(Health, { method: 'check' })\n\n const res = await client.check({})\n\n expect(res?.status)\n expect(res.status).toEqual(1)\n\n const lastCall = transport.calls.pop()\n const headers = transport.getHeaders()\n\n expect(lastCall).toBeDefined()\n\n for (const header in headers) {\n expect(lastCall?.header.get(header)).toEqual(headers[header])\n }\n })\n})\n"],"names":["Health","MockTransport","describe","transport","beforeAll","mock","service","check","status","it","expect","toBeDefined","sdkKey","setSdkKey","headers","getHeaders","sdk","toEqual","authToken","setAuth","authorization","headerName","headerValue","setHeader","retrievedValue","getHeader","interceptor","req","registerInterceptor","toContain","removeInterceptor","not","client","queryKey","createPromiseClient","method","newClient","newQueryKey","res","lastCall","calls","pop","header","get"],"mappings":"AAAA,SAASA,MAAM,QAAQ,sDAAqD;AAE5E,SAASC,aAAa,QAAQ,cAAa;AAE3CC,SAAS,aAAa;IACpB,IAAIC;IAEJC,UAAU;QACR,MAAMC,OAAO,CAAC,EAAEC,OAAO,EAAE;YACvBA,QAAQN,QAAQ;gBACdO,OAAO,IAAO,CAAA;wBAAEC,QAAQ;oBAAE,CAAA;YAC5B;QACF;QAEAL,YAAY,IAAIF,cAAcI;IAChC;IAEAI,GAAG,yCAAyC;QAC1CC,OAAOP,WAAWQ,WAAW;QAC7BD,OAAOP,UAAUA,SAAS,EAAEQ,WAAW;IACzC;IAEAF,GAAG,sBAAsB;QACvB,MAAMG,SAAS;QAEfT,UAAUU,SAAS,CAACD;QACpB,MAA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