@midnight-ntwrk/wallet-sdk-indexer-client 1.2.1 → 1.2.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { Either } from 'effect';
14
+ import { describe, expect, it } from 'vitest';
15
+ import { createWebSocketUrl, deriveWebSocketUrl } from '../ConnectionHelper.js';
16
+ const right = (e) => (Either.isRight(e) ? e.right : undefined);
17
+ describe('deriveWebSocketUrl', () => {
18
+ it('flips http→ws and https→wss', () => {
19
+ expect(right(deriveWebSocketUrl('http://example.com/api'))).toBe('ws://example.com/api/ws');
20
+ expect(right(deriveWebSocketUrl('https://example.com/api'))).toBe('wss://example.com/api/ws');
21
+ });
22
+ it('appends /ws regardless of whether the input path ends with a slash', () => {
23
+ expect(right(deriveWebSocketUrl('http://example.com/api'))).toBe('ws://example.com/api/ws');
24
+ expect(right(deriveWebSocketUrl('http://example.com/api/'))).toBe('ws://example.com/api/ws');
25
+ });
26
+ });
27
+ describe('createWebSocketUrl', () => {
28
+ it('returns the provided wsUrl as-is, ignoring httpUrl', () => {
29
+ expect(right(createWebSocketUrl('http://example.com/api', 'ws://override.example/custom'))).toBe('ws://override.example/custom');
30
+ });
31
+ it('falls back to deriveWebSocketUrl when wsUrl is undefined', () => {
32
+ expect(right(createWebSocketUrl('https://example.com/api'))).toBe('wss://example.com/api/ws');
33
+ });
34
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midnight-ntwrk/wallet-sdk-indexer-client",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,17 +28,17 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@graphql-typed-document-node/core": "^3.2.0",
31
- "@midnight-ntwrk/wallet-sdk-utilities": "1.1.1",
31
+ "@midnight-ntwrk/wallet-sdk-utilities": "^1.2.0",
32
32
  "effect": "^3.19.19",
33
33
  "graphql": "^16.13.0",
34
34
  "graphql-http": "^1.22.4",
35
35
  "graphql-ws": "^6.0.7"
36
36
  },
37
37
  "devDependencies": {
38
- "@graphql-codegen/cli": "^6.3.0",
39
- "@graphql-codegen/client-preset": "^5.3.0",
40
- "@graphql-codegen/typescript": "^5.0.8",
41
- "@graphql-codegen/typescript-operations": "^5.1.0"
38
+ "@graphql-codegen/cli": "^7.0.0",
39
+ "@graphql-codegen/client-preset": "^6.0.0",
40
+ "@graphql-codegen/typescript": "^6.0.0",
41
+ "@graphql-codegen/typescript-operations": "^6.0.0"
42
42
  },
43
43
  "scripts": {
44
44
  "gql:codegen": "graphql-codegen --clean --config codegen.ts",