@contello/sdk-client 8.22.2 → 8.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 entwico GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -1,193 +1,146 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- ContelloSdkClient: () => ContelloSdkClient
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
-
27
- // src/client.ts
28
- var import_graphql_ws = require("graphql-ws");
29
- var import_rxjs2 = require("rxjs");
30
-
31
- // src/pool.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let graphql_ws = require("graphql-ws");
3
+ let rxjs = require("rxjs");
4
+ //#region src/pool.ts
32
5
  var ConnectionPool = class {
33
- constructor(createClient2, poolSize) {
34
- this.createClient = createClient2;
35
- this.poolSize = poolSize;
36
- }
37
- clients = [];
38
- currentIndex = 0;
39
- async connect() {
40
- const connected = [];
41
- for (let i = 0; i < this.poolSize; i++) {
42
- const client = this.createClient(`${i + 1}`);
43
- this.clients.push(client);
44
- connected.push(
45
- new Promise((resolve) => {
46
- const unsubscribe = client.on("connected", () => {
47
- unsubscribe();
48
- resolve();
49
- });
50
- })
51
- );
52
- }
53
- await Promise.all(connected);
54
- }
55
- get() {
56
- if (this.clients.length === 0) {
57
- throw new Error("Connection pool is empty. Please call connect() first.");
58
- }
59
- const client = this.clients[this.currentIndex];
60
- this.currentIndex = (this.currentIndex + 1) % this.poolSize;
61
- if (!client) {
62
- throw new Error("No available WebSocket client");
63
- }
64
- return client;
65
- }
66
- async disconnect() {
67
- const closed = this.clients.map(
68
- (client) => new Promise((resolve) => {
69
- const unsubscribe = client.on("closed", () => {
70
- unsubscribe();
71
- resolve();
72
- });
73
- client.dispose();
74
- })
75
- );
76
- this.clients = [];
77
- await Promise.all(closed);
78
- }
6
+ createClient;
7
+ poolSize;
8
+ clients = [];
9
+ currentIndex = 0;
10
+ constructor(createClient, poolSize) {
11
+ this.createClient = createClient;
12
+ this.poolSize = poolSize;
13
+ }
14
+ async connect() {
15
+ const connected = [];
16
+ for (let i = 0; i < this.poolSize; i++) {
17
+ const client = this.createClient(String(i + 1));
18
+ this.clients.push(client);
19
+ connected.push(new Promise((resolve) => {
20
+ const unsubscribe = client.on("connected", () => {
21
+ unsubscribe();
22
+ resolve();
23
+ });
24
+ }));
25
+ }
26
+ await Promise.all(connected);
27
+ }
28
+ get() {
29
+ if (this.clients.length === 0) throw new Error("Connection pool is empty. Please call connect() first.");
30
+ const client = this.clients[this.currentIndex];
31
+ this.currentIndex = (this.currentIndex + 1) % this.poolSize;
32
+ if (!client) throw new Error("No available WebSocket client");
33
+ return client;
34
+ }
35
+ async disconnect() {
36
+ const closed = this.clients.map((client) => new Promise((resolve) => {
37
+ const unsubscribe = client.on("closed", () => {
38
+ unsubscribe();
39
+ resolve();
40
+ });
41
+ client.dispose();
42
+ }));
43
+ this.clients = [];
44
+ await Promise.all(closed);
45
+ }
79
46
  };
80
-
81
- // src/sdk.ts
82
- var import_rxjs = require("rxjs");
83
- var createSdk = (client, middlewares, getSdk) => {
84
- return getSdk((doc, vars, options) => {
85
- if (options) {
86
- console.warn("options are not supported yet");
87
- }
88
- const query = doc.loc?.source.body;
89
- if (!query) {
90
- throw new Error("No query provided");
91
- }
92
- if (vars && typeof vars !== "object") {
93
- throw new Error("Variables must be an object");
94
- }
95
- const operationDef = doc.definitions.find((def) => def.kind === "OperationDefinition");
96
- if (!operationDef) {
97
- throw new Error("No operation definition found");
98
- }
99
- const kind = operationDef.operation;
100
- const executeRequest = () => {
101
- const wsClient = client();
102
- return new import_rxjs.Observable((obs) => wsClient.subscribe({ query, variables: vars }, obs));
103
- };
104
- const request = {
105
- kind,
106
- operationName: operationDef.name?.value ?? "",
107
- query,
108
- variables: vars || {}
109
- };
110
- const executeWithMiddlewares = (mws, index) => {
111
- if (index >= mws.length) {
112
- return executeRequest();
113
- }
114
- const middleware = mws[index];
115
- if (middleware?.onRequest) {
116
- return middleware.onRequest(request, () => executeWithMiddlewares(mws, index + 1));
117
- }
118
- return executeWithMiddlewares(mws, index + 1);
119
- };
120
- const res = executeWithMiddlewares(middlewares, 0);
121
- return kind !== "subscription" ? (0, import_rxjs.firstValueFrom)(res) : res;
122
- });
47
+ //#endregion
48
+ //#region src/sdk.ts
49
+ const createSdk = (client, middlewares, getSdk) => {
50
+ return getSdk((doc, vars, options) => {
51
+ if (options) console.warn("options are not supported yet");
52
+ const query = doc.loc?.source.body;
53
+ if (!query) throw new Error("No query provided");
54
+ if (vars && typeof vars !== "object") throw new Error("Variables must be an object");
55
+ const operationDef = doc.definitions.find((def) => def.kind === "OperationDefinition");
56
+ if (!operationDef) throw new Error("No operation definition found");
57
+ const kind = operationDef.operation;
58
+ const executeRequest = () => {
59
+ const wsClient = client();
60
+ return new rxjs.Observable((obs) => wsClient.subscribe({
61
+ query,
62
+ variables: vars
63
+ }, obs));
64
+ };
65
+ const request = {
66
+ kind,
67
+ operationName: operationDef.name?.value ?? "",
68
+ query,
69
+ variables: vars || {}
70
+ };
71
+ const executeWithMiddlewares = (mws, index) => {
72
+ if (index >= mws.length) return executeRequest();
73
+ const middleware = mws[index];
74
+ if (middleware?.onRequest) return middleware.onRequest(request, () => executeWithMiddlewares(mws, index + 1));
75
+ return executeWithMiddlewares(mws, index + 1);
76
+ };
77
+ const res = executeWithMiddlewares(middlewares, 0);
78
+ return kind === "subscription" ? res : (0, rxjs.firstValueFrom)(res);
79
+ });
123
80
  };
124
-
125
- // src/client.ts
81
+ //#endregion
82
+ //#region src/client.ts
126
83
  var ContelloSdkClient = class {
127
- _pool;
128
- _sdk;
129
- constructor(getSdk, params) {
130
- const { url, project, token, client, pooling } = params;
131
- const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, "ws");
132
- this._pool = new ConnectionPool(
133
- (id) => {
134
- const context = Object.freeze({ connectionId: id, websocketUrl });
135
- return (0, import_graphql_ws.createClient)({
136
- url: websocketUrl,
137
- connectionParams: { authorization: `Bearer ${token}` },
138
- lazy: false,
139
- keepAlive: 3e4,
140
- retryAttempts: client?.retryAttempts ?? 3,
141
- shouldRetry: () => true,
142
- jsonMessageReplacer: (key, value) => {
143
- if (!key) {
144
- let message = value;
145
- for (const middleware of params.middlewares ?? []) {
146
- if (middleware.onOutgoingMessage) {
147
- message = middleware.onOutgoingMessage(message);
148
- }
149
- }
150
- return message;
151
- }
152
- return value;
153
- },
154
- ...client?.onError ? { onNonLazyError: (e) => client.onError(context, e) } : {},
155
- on: {
156
- ...client?.onError ? { error: (e) => client.onError(context, e) } : {},
157
- ...client?.onConnected ? { connected: () => client.onConnected(context) } : {},
158
- ...client?.onClosed ? { closed: () => client.onClosed(context) } : {},
159
- ...client?.onConnecting ? { connecting: () => client.onConnecting(context) } : {},
160
- ...client?.onOpened ? { opened: () => client.onOpened(context) } : {},
161
- ...client?.onMessage ? { message: (m) => client.onMessage(context, m) } : {},
162
- ...client?.onPing ? { ping: () => client.onPing(context) } : {},
163
- ...client?.onPong ? { pong: () => client.onPong(context) } : {}
164
- }
165
- });
166
- },
167
- pooling?.enabled === false ? 1 : pooling?.size ?? 5
168
- );
169
- this._sdk = { sdk: createSdk(() => this._pool.get(), params.middlewares ?? [], getSdk) };
170
- }
171
- get sdk() {
172
- return this._sdk.sdk;
173
- }
174
- async connect() {
175
- await this._pool.connect();
176
- }
177
- async disconnect() {
178
- await this._pool.disconnect();
179
- }
180
- subscribe(query, variables) {
181
- const wsClient = this._pool.get();
182
- return new import_rxjs2.Observable((obs) => wsClient.subscribe({ query, variables }, obs)).pipe(
183
- (0, import_rxjs2.map)((r) => r.data)
184
- );
185
- }
186
- execute(query, variables) {
187
- return (0, import_rxjs2.firstValueFrom)(this.subscribe(query, variables));
188
- }
84
+ _pool;
85
+ _sdk;
86
+ constructor(getSdk, params) {
87
+ const { url, project, token, client, pooling } = params;
88
+ const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, "ws");
89
+ this._pool = new ConnectionPool((id) => {
90
+ const context = Object.freeze({
91
+ connectionId: id,
92
+ websocketUrl
93
+ });
94
+ return (0, graphql_ws.createClient)({
95
+ url: websocketUrl,
96
+ connectionParams: { authorization: `Bearer ${token}` },
97
+ lazy: false,
98
+ keepAlive: 3e4,
99
+ retryAttempts: client?.retryAttempts ?? 3,
100
+ shouldRetry: () => true,
101
+ jsonMessageReplacer: (key, value) => {
102
+ if (!key) {
103
+ let message = value;
104
+ const middlewares = params.middlewares ?? [];
105
+ for (const middleware of middlewares) if (middleware.onOutgoingMessage) message = middleware.onOutgoingMessage(message);
106
+ return message;
107
+ }
108
+ return value;
109
+ },
110
+ ...client?.onError && { onNonLazyError: (e) => client.onError(context, e) },
111
+ on: {
112
+ ...client?.onError && { error: (e) => client.onError(context, e) },
113
+ ...client?.onConnected && { connected: () => client.onConnected(context) },
114
+ ...client?.onClosed && { closed: () => client.onClosed(context) },
115
+ ...client?.onConnecting && { connecting: () => client.onConnecting(context) },
116
+ ...client?.onOpened && { opened: () => client.onOpened(context) },
117
+ ...client?.onMessage && { message: (m) => client.onMessage(context, m) },
118
+ ...client?.onPing && { ping: () => client.onPing(context) },
119
+ ...client?.onPong && { pong: () => client.onPong(context) }
120
+ }
121
+ });
122
+ }, pooling?.enabled === false ? 1 : pooling?.size ?? 5);
123
+ this._sdk = { sdk: createSdk(() => this._pool.get(), params.middlewares ?? [], getSdk) };
124
+ }
125
+ get sdk() {
126
+ return this._sdk.sdk;
127
+ }
128
+ async connect() {
129
+ await this._pool.connect();
130
+ }
131
+ async disconnect() {
132
+ await this._pool.disconnect();
133
+ }
134
+ subscribe(query, variables) {
135
+ const wsClient = this._pool.get();
136
+ return new rxjs.Observable((obs) => wsClient.subscribe({
137
+ query,
138
+ variables
139
+ }, obs)).pipe((0, rxjs.map)((r) => r.data));
140
+ }
141
+ execute(query, variables) {
142
+ return (0, rxjs.firstValueFrom)(this.subscribe(query, variables));
143
+ }
189
144
  };
190
- // Annotate the CommonJS export names for ESM import in node:
191
- 0 && (module.exports = {
192
- ContelloSdkClient
193
- });
145
+ //#endregion
146
+ exports.ContelloSdkClient = ContelloSdkClient;
package/dist/index.d.cts CHANGED
@@ -1,52 +1,55 @@
1
- import { Observable } from 'rxjs';
2
- import { DocumentNode, ExecutionResult } from 'graphql';
3
-
1
+ import { Observable } from "rxjs";
2
+ import { DocumentNode, ExecutionResult } from "graphql";
3
+ //#region src/middleware.d.ts
4
4
  type ContelloSdkClientMiddleware = {
5
- onRequest?: (request: {
6
- kind: 'query' | 'mutation' | 'subscription';
7
- operationName: string;
8
- query: string;
9
- variables: Record<string, any>;
10
- }, next: () => Observable<any>) => Observable<any>;
11
- onOutgoingMessage?: (message: any) => any;
5
+ onRequest?: (request: {
6
+ kind: 'query' | 'mutation' | 'subscription';
7
+ operationName: string;
8
+ query: string;
9
+ variables: Record<string, any>;
10
+ }, next: () => Observable<any>) => Observable<any>;
11
+ onOutgoingMessage?: (message: any) => any;
12
12
  };
13
-
13
+ //#endregion
14
+ //#region src/sdk.d.ts
14
15
  type Requester<C = any, E = unknown> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<ExecutionResult<R, E>> | Observable<ExecutionResult<R, E>>;
15
-
16
+ //#endregion
17
+ //#region src/client.d.ts
16
18
  type ClientEventContext = {
17
- connectionId: string;
18
- websocketUrl: string;
19
+ connectionId: string;
20
+ websocketUrl: string;
19
21
  };
20
22
  type ContelloSdkClientParams = {
21
- url: string;
22
- project: string;
23
- token: string;
24
- middlewares?: ContelloSdkClientMiddleware[] | undefined;
25
- pooling?: {
26
- enabled?: boolean | undefined;
27
- size?: number | undefined;
28
- } | undefined;
29
- client?: {
30
- retryAttempts?: number | undefined;
31
- onError?: (context: ClientEventContext, error: unknown) => void;
32
- onConnected?: (context: ClientEventContext) => void;
33
- onClosed?: (context: ClientEventContext) => void;
34
- onConnecting?: (context: ClientEventContext) => void;
35
- onOpened?: (context: ClientEventContext) => void;
36
- onMessage?: (context: ClientEventContext, message: any) => void;
37
- onPing?: (context: ClientEventContext) => void;
38
- onPong?: (context: ClientEventContext) => void;
39
- } | undefined;
23
+ url: string;
24
+ project: string;
25
+ token: string;
26
+ middlewares?: ContelloSdkClientMiddleware[] | undefined;
27
+ pooling?: {
28
+ enabled?: boolean | undefined;
29
+ size?: number | undefined;
30
+ } | undefined;
31
+ client?: {
32
+ retryAttempts?: number | undefined;
33
+ onError?: (context: ClientEventContext, error: unknown) => void;
34
+ onConnected?: (context: ClientEventContext) => void;
35
+ onClosed?: (context: ClientEventContext) => void;
36
+ onConnecting?: (context: ClientEventContext) => void;
37
+ onOpened?: (context: ClientEventContext) => void;
38
+ onMessage?: (context: ClientEventContext, message: any) => void;
39
+ onPing?: (context: ClientEventContext) => void;
40
+ onPong?: (context: ClientEventContext) => void;
41
+ } | undefined;
40
42
  };
41
43
  declare class ContelloSdkClient<T> {
42
- private _pool;
43
- private _sdk;
44
- constructor(getSdk: <C, E>(requester: Requester<C, E>) => T, params: ContelloSdkClientParams);
45
- get sdk(): T;
46
- connect(): Promise<void>;
47
- disconnect(): Promise<void>;
48
- subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): Observable<TData>;
49
- execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
44
+ private _pool;
45
+ private _sdk;
46
+ constructor(getSdk: <C, E>(requester: Requester<C, E>) => T, params: ContelloSdkClientParams);
47
+ get sdk(): T;
48
+ connect(): Promise<void>;
49
+ disconnect(): Promise<void>;
50
+ subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): Observable<TData>;
51
+ execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
50
52
  }
51
-
53
+ //#endregion
52
54
  export { ContelloSdkClient, type ContelloSdkClientMiddleware, type ContelloSdkClientParams };
55
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/middleware.ts","../src/sdk.ts","../src/client.ts"],"mappings":";;;KAEY,2BAAA;EACV,SAAA,IACE,OAAA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package/dist/index.d.ts CHANGED
@@ -1,52 +1,56 @@
1
- import { Observable } from 'rxjs';
2
- import { DocumentNode, ExecutionResult } from 'graphql';
1
+ import { Observable } from "rxjs";
2
+ import { DocumentNode, ExecutionResult } from "graphql";
3
3
 
4
+ //#region src/middleware.d.ts
4
5
  type ContelloSdkClientMiddleware = {
5
- onRequest?: (request: {
6
- kind: 'query' | 'mutation' | 'subscription';
7
- operationName: string;
8
- query: string;
9
- variables: Record<string, any>;
10
- }, next: () => Observable<any>) => Observable<any>;
11
- onOutgoingMessage?: (message: any) => any;
6
+ onRequest?: (request: {
7
+ kind: 'query' | 'mutation' | 'subscription';
8
+ operationName: string;
9
+ query: string;
10
+ variables: Record<string, any>;
11
+ }, next: () => Observable<any>) => Observable<any>;
12
+ onOutgoingMessage?: (message: any) => any;
12
13
  };
13
-
14
+ //#endregion
15
+ //#region src/sdk.d.ts
14
16
  type Requester<C = any, E = unknown> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<ExecutionResult<R, E>> | Observable<ExecutionResult<R, E>>;
15
-
17
+ //#endregion
18
+ //#region src/client.d.ts
16
19
  type ClientEventContext = {
17
- connectionId: string;
18
- websocketUrl: string;
20
+ connectionId: string;
21
+ websocketUrl: string;
19
22
  };
20
23
  type ContelloSdkClientParams = {
21
- url: string;
22
- project: string;
23
- token: string;
24
- middlewares?: ContelloSdkClientMiddleware[] | undefined;
25
- pooling?: {
26
- enabled?: boolean | undefined;
27
- size?: number | undefined;
28
- } | undefined;
29
- client?: {
30
- retryAttempts?: number | undefined;
31
- onError?: (context: ClientEventContext, error: unknown) => void;
32
- onConnected?: (context: ClientEventContext) => void;
33
- onClosed?: (context: ClientEventContext) => void;
34
- onConnecting?: (context: ClientEventContext) => void;
35
- onOpened?: (context: ClientEventContext) => void;
36
- onMessage?: (context: ClientEventContext, message: any) => void;
37
- onPing?: (context: ClientEventContext) => void;
38
- onPong?: (context: ClientEventContext) => void;
39
- } | undefined;
24
+ url: string;
25
+ project: string;
26
+ token: string;
27
+ middlewares?: ContelloSdkClientMiddleware[] | undefined;
28
+ pooling?: {
29
+ enabled?: boolean | undefined;
30
+ size?: number | undefined;
31
+ } | undefined;
32
+ client?: {
33
+ retryAttempts?: number | undefined;
34
+ onError?: (context: ClientEventContext, error: unknown) => void;
35
+ onConnected?: (context: ClientEventContext) => void;
36
+ onClosed?: (context: ClientEventContext) => void;
37
+ onConnecting?: (context: ClientEventContext) => void;
38
+ onOpened?: (context: ClientEventContext) => void;
39
+ onMessage?: (context: ClientEventContext, message: any) => void;
40
+ onPing?: (context: ClientEventContext) => void;
41
+ onPong?: (context: ClientEventContext) => void;
42
+ } | undefined;
40
43
  };
41
44
  declare class ContelloSdkClient<T> {
42
- private _pool;
43
- private _sdk;
44
- constructor(getSdk: <C, E>(requester: Requester<C, E>) => T, params: ContelloSdkClientParams);
45
- get sdk(): T;
46
- connect(): Promise<void>;
47
- disconnect(): Promise<void>;
48
- subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): Observable<TData>;
49
- execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
45
+ private _pool;
46
+ private _sdk;
47
+ constructor(getSdk: <C, E>(requester: Requester<C, E>) => T, params: ContelloSdkClientParams);
48
+ get sdk(): T;
49
+ connect(): Promise<void>;
50
+ disconnect(): Promise<void>;
51
+ subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): Observable<TData>;
52
+ execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
50
53
  }
51
-
54
+ //#endregion
52
55
  export { ContelloSdkClient, type ContelloSdkClientMiddleware, type ContelloSdkClientParams };
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/middleware.ts","../src/sdk.ts","../src/client.ts"],"mappings":";;;;KAEY,2BAAA;EACV,SAAA,IACE,OAAA;IACE,IAAA;IACA,aAAA;IACA,KAAA;IACA,SAAA,EAAW,MAAA;EAAA,G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"graphql-ws";
3
- import { Observable as Observable2, firstValueFrom as firstValueFrom2, map } from "rxjs";
4
-
5
- // src/pool.ts
2
+ import { Observable, firstValueFrom, map } from "rxjs";
3
+ //#region src/pool.ts
6
4
  var ConnectionPool = class {
7
- constructor(createClient2, poolSize) {
8
- this.createClient = createClient2;
9
- this.poolSize = poolSize;
10
- }
11
- clients = [];
12
- currentIndex = 0;
13
- async connect() {
14
- const connected = [];
15
- for (let i = 0; i < this.poolSize; i++) {
16
- const client = this.createClient(`${i + 1}`);
17
- this.clients.push(client);
18
- connected.push(
19
- new Promise((resolve) => {
20
- const unsubscribe = client.on("connected", () => {
21
- unsubscribe();
22
- resolve();
23
- });
24
- })
25
- );
26
- }
27
- await Promise.all(connected);
28
- }
29
- get() {
30
- if (this.clients.length === 0) {
31
- throw new Error("Connection pool is empty. Please call connect() first.");
32
- }
33
- const client = this.clients[this.currentIndex];
34
- this.currentIndex = (this.currentIndex + 1) % this.poolSize;
35
- if (!client) {
36
- throw new Error("No available WebSocket client");
37
- }
38
- return client;
39
- }
40
- async disconnect() {
41
- const closed = this.clients.map(
42
- (client) => new Promise((resolve) => {
43
- const unsubscribe = client.on("closed", () => {
44
- unsubscribe();
45
- resolve();
46
- });
47
- client.dispose();
48
- })
49
- );
50
- this.clients = [];
51
- await Promise.all(closed);
52
- }
5
+ createClient;
6
+ poolSize;
7
+ clients = [];
8
+ currentIndex = 0;
9
+ constructor(createClient, poolSize) {
10
+ this.createClient = createClient;
11
+ this.poolSize = poolSize;
12
+ }
13
+ async connect() {
14
+ const connected = [];
15
+ for (let i = 0; i < this.poolSize; i++) {
16
+ const client = this.createClient(String(i + 1));
17
+ this.clients.push(client);
18
+ connected.push(new Promise((resolve) => {
19
+ const unsubscribe = client.on("connected", () => {
20
+ unsubscribe();
21
+ resolve();
22
+ });
23
+ }));
24
+ }
25
+ await Promise.all(connected);
26
+ }
27
+ get() {
28
+ if (this.clients.length === 0) throw new Error("Connection pool is empty. Please call connect() first.");
29
+ const client = this.clients[this.currentIndex];
30
+ this.currentIndex = (this.currentIndex + 1) % this.poolSize;
31
+ if (!client) throw new Error("No available WebSocket client");
32
+ return client;
33
+ }
34
+ async disconnect() {
35
+ const closed = this.clients.map((client) => new Promise((resolve) => {
36
+ const unsubscribe = client.on("closed", () => {
37
+ unsubscribe();
38
+ resolve();
39
+ });
40
+ client.dispose();
41
+ }));
42
+ this.clients = [];
43
+ await Promise.all(closed);
44
+ }
53
45
  };
54
-
55
- // src/sdk.ts
56
- import { Observable, firstValueFrom } from "rxjs";
57
- var createSdk = (client, middlewares, getSdk) => {
58
- return getSdk((doc, vars, options) => {
59
- if (options) {
60
- console.warn("options are not supported yet");
61
- }
62
- const query = doc.loc?.source.body;
63
- if (!query) {
64
- throw new Error("No query provided");
65
- }
66
- if (vars && typeof vars !== "object") {
67
- throw new Error("Variables must be an object");
68
- }
69
- const operationDef = doc.definitions.find((def) => def.kind === "OperationDefinition");
70
- if (!operationDef) {
71
- throw new Error("No operation definition found");
72
- }
73
- const kind = operationDef.operation;
74
- const executeRequest = () => {
75
- const wsClient = client();
76
- return new Observable((obs) => wsClient.subscribe({ query, variables: vars }, obs));
77
- };
78
- const request = {
79
- kind,
80
- operationName: operationDef.name?.value ?? "",
81
- query,
82
- variables: vars || {}
83
- };
84
- const executeWithMiddlewares = (mws, index) => {
85
- if (index >= mws.length) {
86
- return executeRequest();
87
- }
88
- const middleware = mws[index];
89
- if (middleware?.onRequest) {
90
- return middleware.onRequest(request, () => executeWithMiddlewares(mws, index + 1));
91
- }
92
- return executeWithMiddlewares(mws, index + 1);
93
- };
94
- const res = executeWithMiddlewares(middlewares, 0);
95
- return kind !== "subscription" ? firstValueFrom(res) : res;
96
- });
46
+ //#endregion
47
+ //#region src/sdk.ts
48
+ const createSdk = (client, middlewares, getSdk) => {
49
+ return getSdk((doc, vars, options) => {
50
+ if (options) console.warn("options are not supported yet");
51
+ const query = doc.loc?.source.body;
52
+ if (!query) throw new Error("No query provided");
53
+ if (vars && typeof vars !== "object") throw new Error("Variables must be an object");
54
+ const operationDef = doc.definitions.find((def) => def.kind === "OperationDefinition");
55
+ if (!operationDef) throw new Error("No operation definition found");
56
+ const kind = operationDef.operation;
57
+ const executeRequest = () => {
58
+ const wsClient = client();
59
+ return new Observable((obs) => wsClient.subscribe({
60
+ query,
61
+ variables: vars
62
+ }, obs));
63
+ };
64
+ const request = {
65
+ kind,
66
+ operationName: operationDef.name?.value ?? "",
67
+ query,
68
+ variables: vars || {}
69
+ };
70
+ const executeWithMiddlewares = (mws, index) => {
71
+ if (index >= mws.length) return executeRequest();
72
+ const middleware = mws[index];
73
+ if (middleware?.onRequest) return middleware.onRequest(request, () => executeWithMiddlewares(mws, index + 1));
74
+ return executeWithMiddlewares(mws, index + 1);
75
+ };
76
+ const res = executeWithMiddlewares(middlewares, 0);
77
+ return kind === "subscription" ? res : firstValueFrom(res);
78
+ });
97
79
  };
98
-
99
- // src/client.ts
80
+ //#endregion
81
+ //#region src/client.ts
100
82
  var ContelloSdkClient = class {
101
- _pool;
102
- _sdk;
103
- constructor(getSdk, params) {
104
- const { url, project, token, client, pooling } = params;
105
- const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, "ws");
106
- this._pool = new ConnectionPool(
107
- (id) => {
108
- const context = Object.freeze({ connectionId: id, websocketUrl });
109
- return createClient({
110
- url: websocketUrl,
111
- connectionParams: { authorization: `Bearer ${token}` },
112
- lazy: false,
113
- keepAlive: 3e4,
114
- retryAttempts: client?.retryAttempts ?? 3,
115
- shouldRetry: () => true,
116
- jsonMessageReplacer: (key, value) => {
117
- if (!key) {
118
- let message = value;
119
- for (const middleware of params.middlewares ?? []) {
120
- if (middleware.onOutgoingMessage) {
121
- message = middleware.onOutgoingMessage(message);
122
- }
123
- }
124
- return message;
125
- }
126
- return value;
127
- },
128
- ...client?.onError ? { onNonLazyError: (e) => client.onError(context, e) } : {},
129
- on: {
130
- ...client?.onError ? { error: (e) => client.onError(context, e) } : {},
131
- ...client?.onConnected ? { connected: () => client.onConnected(context) } : {},
132
- ...client?.onClosed ? { closed: () => client.onClosed(context) } : {},
133
- ...client?.onConnecting ? { connecting: () => client.onConnecting(context) } : {},
134
- ...client?.onOpened ? { opened: () => client.onOpened(context) } : {},
135
- ...client?.onMessage ? { message: (m) => client.onMessage(context, m) } : {},
136
- ...client?.onPing ? { ping: () => client.onPing(context) } : {},
137
- ...client?.onPong ? { pong: () => client.onPong(context) } : {}
138
- }
139
- });
140
- },
141
- pooling?.enabled === false ? 1 : pooling?.size ?? 5
142
- );
143
- this._sdk = { sdk: createSdk(() => this._pool.get(), params.middlewares ?? [], getSdk) };
144
- }
145
- get sdk() {
146
- return this._sdk.sdk;
147
- }
148
- async connect() {
149
- await this._pool.connect();
150
- }
151
- async disconnect() {
152
- await this._pool.disconnect();
153
- }
154
- subscribe(query, variables) {
155
- const wsClient = this._pool.get();
156
- return new Observable2((obs) => wsClient.subscribe({ query, variables }, obs)).pipe(
157
- map((r) => r.data)
158
- );
159
- }
160
- execute(query, variables) {
161
- return firstValueFrom2(this.subscribe(query, variables));
162
- }
163
- };
164
- export {
165
- ContelloSdkClient
83
+ _pool;
84
+ _sdk;
85
+ constructor(getSdk, params) {
86
+ const { url, project, token, client, pooling } = params;
87
+ const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, "ws");
88
+ this._pool = new ConnectionPool((id) => {
89
+ const context = Object.freeze({
90
+ connectionId: id,
91
+ websocketUrl
92
+ });
93
+ return createClient({
94
+ url: websocketUrl,
95
+ connectionParams: { authorization: `Bearer ${token}` },
96
+ lazy: false,
97
+ keepAlive: 3e4,
98
+ retryAttempts: client?.retryAttempts ?? 3,
99
+ shouldRetry: () => true,
100
+ jsonMessageReplacer: (key, value) => {
101
+ if (!key) {
102
+ let message = value;
103
+ const middlewares = params.middlewares ?? [];
104
+ for (const middleware of middlewares) if (middleware.onOutgoingMessage) message = middleware.onOutgoingMessage(message);
105
+ return message;
106
+ }
107
+ return value;
108
+ },
109
+ ...client?.onError && { onNonLazyError: (e) => client.onError(context, e) },
110
+ on: {
111
+ ...client?.onError && { error: (e) => client.onError(context, e) },
112
+ ...client?.onConnected && { connected: () => client.onConnected(context) },
113
+ ...client?.onClosed && { closed: () => client.onClosed(context) },
114
+ ...client?.onConnecting && { connecting: () => client.onConnecting(context) },
115
+ ...client?.onOpened && { opened: () => client.onOpened(context) },
116
+ ...client?.onMessage && { message: (m) => client.onMessage(context, m) },
117
+ ...client?.onPing && { ping: () => client.onPing(context) },
118
+ ...client?.onPong && { pong: () => client.onPong(context) }
119
+ }
120
+ });
121
+ }, pooling?.enabled === false ? 1 : pooling?.size ?? 5);
122
+ this._sdk = { sdk: createSdk(() => this._pool.get(), params.middlewares ?? [], getSdk) };
123
+ }
124
+ get sdk() {
125
+ return this._sdk.sdk;
126
+ }
127
+ async connect() {
128
+ await this._pool.connect();
129
+ }
130
+ async disconnect() {
131
+ await this._pool.disconnect();
132
+ }
133
+ subscribe(query, variables) {
134
+ const wsClient = this._pool.get();
135
+ return new Observable((obs) => wsClient.subscribe({
136
+ query,
137
+ variables
138
+ }, obs)).pipe(map((r) => r.data));
139
+ }
140
+ execute(query, variables) {
141
+ return firstValueFrom(this.subscribe(query, variables));
142
+ }
166
143
  };
144
+ //#endregion
145
+ export { ContelloSdkClient };
146
+
147
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/pool.ts","../src/sdk.ts","../src/client.ts"],"sourcesContent":["import type { Client } from 'graphql-ws';\n\nexport class ConnectionPool {\n private clients: Array<Client> = [];\n private currentIndex = 0;\n\n constructor(\n private createClient: (id: string) => Client,\n private poolSize: number,\n ) {}\n\n async connect() {\n const connected: Promise<void>[] = [];\n\n for (let i = 0; i < this.poolSize; i++) {\n const client = this.createClient(String(i + 1));\n this.clients.push(client);\n\n connected.push(\n new Promise<void>((resolve) => {\n const unsubscribe = client.on('connected', () => {\n unsubscribe();\n resolve();\n });\n }),\n );\n }\n\n await Promise.all(connected);\n }\n\n get() {\n if (this.clients.length === 0) {\n throw new Error('Connection pool is empty. Please call connect() first.');\n }\n\n const client = this.clients[this.currentIndex];\n\n this.currentIndex = (this.currentIndex + 1) % this.poolSize;\n\n if (!client) {\n throw new Error('No available WebSocket client');\n }\n\n return client;\n }\n\n async disconnect() {\n const closed = this.clients.map(\n (client) =>\n new Promise<void>((resolve) => {\n const unsubscribe = client.on('closed', () => {\n unsubscribe();\n resolve();\n });\n\n client.dispose();\n }),\n );\n\n this.clients = [];\n\n await Promise.all(closed);\n }\n}\n","import type { DocumentNode, ExecutionResult, OperationDefinitionNode } from 'graphql';\nimport type { Client } from 'graphql-ws';\nimport { Observable, firstValueFrom } from 'rxjs';\n\nimport type { ContelloSdkClientMiddleware } from './middleware';\n\nexport type Requester<C = any, E = unknown> = <R, V>(\n doc: DocumentNode,\n vars?: V,\n options?: C,\n) => Promise<ExecutionResult<R, E>> | Observable<ExecutionResult<R, E>>;\n\nexport type GetSdk<T, C = any, E = unknown> = (requester: Requester<C, E>) => T;\n\nexport const createSdk = <T>(client: () => Client, middlewares: ContelloSdkClientMiddleware[], getSdk: GetSdk<T>) => {\n return getSdk((doc: DocumentNode, vars?: any, options?: any) => {\n if (options) {\n console.warn('options are not supported yet');\n }\n\n const query = doc.loc?.source.body;\n\n if (!query) {\n throw new Error('No query provided');\n }\n\n if (vars && typeof vars !== 'object') {\n throw new Error('Variables must be an object');\n }\n\n const operationDef = doc.definitions.find((def) => def.kind === 'OperationDefinition') as\n | OperationDefinitionNode\n | undefined;\n\n if (!operationDef) {\n throw new Error('No operation definition found');\n }\n\n const kind = operationDef.operation;\n\n const executeRequest = () => {\n const wsClient = client();\n\n return new Observable<any>((obs) => wsClient.subscribe({ query, variables: vars as any }, obs));\n };\n\n const request = {\n kind,\n operationName: operationDef.name?.value ?? '',\n query,\n variables: vars || {},\n };\n\n const executeWithMiddlewares = (mws: ContelloSdkClientMiddleware[], index: number): Observable<any> => {\n if (index >= mws.length) {\n return executeRequest();\n }\n\n const middleware = mws[index];\n\n if (middleware?.onRequest) {\n return middleware.onRequest(request, () => executeWithMiddlewares(mws, index + 1));\n }\n\n return executeWithMiddlewares(mws, index + 1);\n };\n\n const res = executeWithMiddlewares(middlewares, 0);\n\n return kind === 'subscription' ? res : firstValueFrom(res);\n }) as T;\n};\n","import { createClient } from 'graphql-ws';\nimport { Observable, firstValueFrom, map } from 'rxjs';\n\nimport type { ContelloSdkClientMiddleware } from './middleware';\nimport { ConnectionPool } from './pool';\nimport { type Requester, createSdk } from './sdk';\n\nexport type ClientEventContext = {\n connectionId: string;\n websocketUrl: string;\n};\n\nexport type ContelloSdkClientParams = {\n url: string;\n project: string;\n token: string;\n middlewares?: ContelloSdkClientMiddleware[] | undefined;\n pooling?:\n | {\n enabled?: boolean | undefined;\n size?: number | undefined;\n }\n | undefined;\n client?:\n | {\n retryAttempts?: number | undefined;\n onError?: (context: ClientEventContext, error: unknown) => void;\n onConnected?: (context: ClientEventContext) => void;\n onClosed?: (context: ClientEventContext) => void;\n onConnecting?: (context: ClientEventContext) => void;\n onOpened?: (context: ClientEventContext) => void;\n onMessage?: (context: ClientEventContext, message: any) => void;\n onPing?: (context: ClientEventContext) => void;\n onPong?: (context: ClientEventContext) => void;\n }\n | undefined;\n};\n\nexport class ContelloSdkClient<T> {\n private _pool: ConnectionPool;\n private _sdk: { sdk: T };\n\n constructor(getSdk: <C, E>(requester: Requester<C, E>) => T, params: ContelloSdkClientParams) {\n const { url, project, token, client, pooling } = params;\n\n const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, 'ws');\n\n this._pool = new ConnectionPool(\n (id: string) => {\n const context: ClientEventContext = Object.freeze({ connectionId: id, websocketUrl });\n\n return createClient({\n url: websocketUrl,\n connectionParams: { authorization: `Bearer ${token}` },\n lazy: false,\n keepAlive: 30_000,\n retryAttempts: client?.retryAttempts ?? 3,\n shouldRetry: () => true,\n jsonMessageReplacer: (key, value) => {\n if (!key) {\n let message = value;\n\n const middlewares = params.middlewares ?? [];\n\n for (const middleware of middlewares) {\n if (middleware.onOutgoingMessage) {\n message = middleware.onOutgoingMessage(message);\n }\n }\n\n return message;\n }\n\n return value;\n },\n ...(client?.onError && { onNonLazyError: (e) => client!.onError!(context, e) }),\n on: {\n ...(client?.onError && { error: (e) => client!.onError!(context, e) }),\n ...(client?.onConnected && { connected: () => client!.onConnected!(context) }),\n ...(client?.onClosed && { closed: () => client!.onClosed!(context) }),\n ...(client?.onConnecting && { connecting: () => client!.onConnecting!(context) }),\n ...(client?.onOpened && { opened: () => client!.onOpened!(context) }),\n ...(client?.onMessage && { message: (m) => client!.onMessage!(context, m) }),\n ...(client?.onPing && { ping: () => client!.onPing!(context) }),\n ...(client?.onPong && { pong: () => client!.onPong!(context) }),\n },\n });\n },\n pooling?.enabled === false ? 1 : (pooling?.size ?? 5),\n );\n\n this._sdk = { sdk: createSdk(() => this._pool.get(), params.middlewares ?? [], getSdk) };\n }\n\n public get sdk() {\n return this._sdk.sdk;\n }\n\n public async connect() {\n await this._pool.connect();\n }\n\n public async disconnect() {\n await this._pool.disconnect();\n }\n\n public subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): Observable<TData> {\n const wsClient = this._pool.get();\n\n return new Observable<{ data: TData }>((obs) => wsClient.subscribe({ query, variables }, obs)).pipe(\n map((r) => r.data),\n );\n }\n\n public execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData> {\n return firstValueFrom(this.subscribe<TData>(query, variables));\n }\n}\n"],"mappings":";;;AAEA,IAAa,iBAAb,MAA4B;CAKhB;CACA;CALV,UAAiC,CAAC;CAClC,eAAuB;CAEvB,YACE,cACA,UACA;EAFQ,KAAA,eAAA;EACA,KAAA,WAAA;CACP;CAEH,MAAM,UAAU;EACd,MAAM,YAA6B,CAAC;EAEpC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,UAAU,KAAK;GACtC,MAAM,SAAS,KAAK,aAAa,OAAO,IAAI,CAAC,CAAC;GAC9C,KAAK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,QAAQ,eAAe,EAAE,iBAAiB,OAAQ,YAAa,OAAO,EAAE;KAC5E,GAAI,QAAQ,YAAY,EAAE,cAAc,OAAQ,SAAU,OAAO,EAAE;KACnE,GAAI,QAAQ,gBAAgB,EAAE,kBAAkB,OAAQ,aAAc,OAAO,EAAE;KAC/E,GAAI,QAAQ,YAAY,EAAE,cAAc,OAAQ,SAAU,OAAO,EAAE;KACnE,GAAI,QAAQ,aAAa,EAAE,UAAU,MAAM,OAAQ,UAAW,SAAS,CAAC,EAAE;KAC1E,GAAI,QAAQ,UAAU,EAAE,YAAY,OAAQ,OAAQ,OAAO,EAAE;KAC7D,GAAI,QAAQ,UAAU,EAAE,YAAY,OAAQ,OAAQ,OAAO,EAAE;IAC/D;GACF,CAAC;EACH,GACA,SAAS,YAAY,QAAQ,IAAK,SAAS,QAAQ,CACrD;EAEA,KAAK,OAAO,EAAE,KAAK,gBAAgB,KAAK,MAAM,IAAI,GAAG,OAAO,eAAe,CAAC,GAAG,MAAM,EAAE;CACzF;CAEA,IAAW,MAAM;EACf,OAAO,KAAK,KAAK;CACnB;CAEA,MAAa,UAAU;EACrB,MAAM,KAAK,MAAM,QAAQ;CAC3B;CAEA,MAAa,aAAa;EACxB,MAAM,KAAK,MAAM,WAAW;CAC9B;CAEA,UAAwB,OAAe,WAAoE;EACzG,MAAM,WAAW,KAAK,MAAM,IAAI;EAEhC,OAAO,IAAI,YAA6B,QAAQ,SAAS,UAAU;GAAE;GAAO;EAAU,GAAG,GAAG,CAAC,CAAC,CAAC,KAC7F,KAAK,MAAM,EAAE,IAAI,CACnB;CACF;CAEA,QAAsB,OAAe,WAAiE;EACpG,OAAO,eAAe,KAAK,UAAiB,OAAO,SAAS,CAAC;CAC/D;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contello/sdk-client",
3
- "version": "8.22.2",
3
+ "version": "8.22.3",
4
4
  "description": "GraphQL SDK client for Contello CMS with WebSocket transport and connection pooling",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,12 +10,6 @@
10
10
  "url": "https://github.com/entwico/contello-js",
11
11
  "directory": "packages/sdk-client"
12
12
  },
13
- "scripts": {
14
- "build": "tsup",
15
- "lint": "eslint .",
16
- "lint:fix": "eslint . --fix",
17
- "typecheck": "tsc --noEmit"
18
- },
19
13
  "peerDependencies": {
20
14
  "rxjs": "^7.0.0",
21
15
  "graphql": ">=16.0.0",
@@ -23,8 +17,8 @@
23
17
  },
24
18
  "devDependencies": {
25
19
  "rxjs": "^7.8.2",
26
- "graphql": "^16.13.1",
27
- "graphql-ws": "^6.0.7"
20
+ "graphql": "^16.13.2",
21
+ "graphql-ws": "^6.0.8"
28
22
  },
29
23
  "files": [
30
24
  "dist"
@@ -39,5 +33,11 @@
39
33
  "publishConfig": {
40
34
  "access": "public",
41
35
  "registry": "https://registry.npmjs.org"
36
+ },
37
+ "scripts": {
38
+ "build": "tsdown",
39
+ "lint": "eslint . --cache",
40
+ "lint:fix": "eslint . --fix",
41
+ "typecheck": "tsc --noEmit"
42
42
  }
43
- }
43
+ }