@graphql-box/worker-client 4.1.6 → 5.0.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/README.md +1 -5
- package/dist/cjs/index.cjs +410 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +401 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/cjs/constants.d.cts +6 -0
- package/dist/types/cjs/constants.d.cts.map +1 -0
- package/dist/types/cjs/debug/logRequest.d.cts +6 -0
- package/dist/types/cjs/debug/logRequest.d.cts.map +1 -0
- package/dist/types/cjs/debug/logSubscription.d.cts +6 -0
- package/dist/types/cjs/debug/logSubscription.d.cts.map +1 -0
- package/dist/types/cjs/helpers/isGraphqlBoxMessageRequestPayload.d.cts +4 -0
- package/dist/types/cjs/helpers/isGraphqlBoxMessageRequestPayload.d.cts.map +1 -0
- package/dist/types/cjs/helpers/operationNameRegex.d.cts +2 -0
- package/dist/types/cjs/helpers/operationNameRegex.d.cts.map +1 -0
- package/dist/types/cjs/index.d.cts +5 -0
- package/dist/types/cjs/index.d.cts.map +1 -0
- package/dist/types/cjs/main.d.cts +24 -0
- package/dist/types/cjs/main.d.cts.map +1 -0
- package/dist/types/cjs/registerWorker.d.cts +5 -0
- package/dist/types/cjs/registerWorker.d.cts.map +1 -0
- package/dist/types/cjs/types.d.cts +49 -0
- package/dist/types/cjs/types.d.cts.map +1 -0
- package/dist/types/esm/constants.d.ts +6 -0
- package/dist/types/esm/constants.d.ts.map +1 -0
- package/dist/types/esm/debug/logRequest.d.ts +6 -0
- package/dist/types/esm/debug/logRequest.d.ts.map +1 -0
- package/dist/types/esm/debug/logSubscription.d.ts +6 -0
- package/dist/types/esm/debug/logSubscription.d.ts.map +1 -0
- package/dist/types/esm/helpers/isGraphqlBoxMessageRequestPayload.d.ts +4 -0
- package/dist/types/esm/helpers/isGraphqlBoxMessageRequestPayload.d.ts.map +1 -0
- package/dist/types/esm/helpers/operationNameRegex.d.ts +2 -0
- package/dist/types/esm/helpers/operationNameRegex.d.ts.map +1 -0
- package/dist/types/esm/index.d.ts +5 -0
- package/dist/types/esm/index.d.ts.map +1 -0
- package/dist/types/esm/main.d.ts +24 -0
- package/dist/types/esm/main.d.ts.map +1 -0
- package/dist/types/esm/registerWorker.d.ts +5 -0
- package/dist/types/esm/registerWorker.d.ts.map +1 -0
- package/{lib/types/defs/index.d.ts → dist/types/esm/types.d.ts} +11 -11
- package/dist/types/esm/types.d.ts.map +1 -0
- package/dist/types/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +57 -45
- package/src/constants.ts +5 -0
- package/src/debug/{log-request/index.ts → logRequest.ts} +30 -20
- package/src/debug/logSubscription.ts +50 -0
- package/src/helpers/isGraphqlBoxMessageRequestPayload.ts +7 -0
- package/src/helpers/operationNameRegex.test.ts +26 -14
- package/src/helpers/operationNameRegex.ts +2 -2
- package/src/index.ts +4 -3
- package/src/{main/index.ts → main.ts} +135 -108
- package/src/registerWorker.ts +107 -0
- package/src/{defs/index.ts → types.ts} +14 -9
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +17 -0
- package/lib/browser/index.js +0 -2
- package/lib/browser/index.js.map +0 -1
- package/lib/browser/production.analysis.txt +0 -81
- package/lib/main/consts/index.js +0 -17
- package/lib/main/consts/index.js.map +0 -1
- package/lib/main/debug/log-request/index.js +0 -77
- package/lib/main/debug/log-request/index.js.map +0 -1
- package/lib/main/debug/log-subscription/index.js +0 -55
- package/lib/main/debug/log-subscription/index.js.map +0 -1
- package/lib/main/defs/index.js +0 -2
- package/lib/main/defs/index.js.map +0 -1
- package/lib/main/helpers/operationNameRegex.js +0 -14
- package/lib/main/helpers/operationNameRegex.js.map +0 -1
- package/lib/main/index.js +0 -41
- package/lib/main/index.js.map +0 -1
- package/lib/main/main/index.js +0 -249
- package/lib/main/main/index.js.map +0 -1
- package/lib/main/register-worker/index.js +0 -143
- package/lib/main/register-worker/index.js.map +0 -1
- package/lib/module/consts/index.mjs +0 -6
- package/lib/module/consts/index.mjs.map +0 -1
- package/lib/module/debug/log-request/index.mjs +0 -64
- package/lib/module/debug/log-request/index.mjs.map +0 -1
- package/lib/module/debug/log-subscription/index.mjs +0 -43
- package/lib/module/debug/log-subscription/index.mjs.map +0 -1
- package/lib/module/defs/index.mjs +0 -2
- package/lib/module/defs/index.mjs.map +0 -1
- package/lib/module/helpers/operationNameRegex.mjs +0 -5
- package/lib/module/helpers/operationNameRegex.mjs.map +0 -1
- package/lib/module/index.mjs +0 -4
- package/lib/module/index.mjs.map +0 -1
- package/lib/module/main/index.mjs +0 -236
- package/lib/module/main/index.mjs.map +0 -1
- package/lib/module/register-worker/index.mjs +0 -126
- package/lib/module/register-worker/index.mjs.map +0 -1
- package/lib/types/consts/index.d.ts +0 -6
- package/lib/types/consts/index.d.ts.map +0 -1
- package/lib/types/debug/log-request/index.d.ts +0 -2
- package/lib/types/debug/log-request/index.d.ts.map +0 -1
- package/lib/types/debug/log-subscription/index.d.ts +0 -2
- package/lib/types/debug/log-subscription/index.d.ts.map +0 -1
- package/lib/types/defs/index.d.ts.map +0 -1
- package/lib/types/helpers/operationNameRegex.d.ts +0 -3
- package/lib/types/helpers/operationNameRegex.d.ts.map +0 -1
- package/lib/types/helpers/operationNameRegex.test.d.ts +0 -2
- package/lib/types/helpers/operationNameRegex.test.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -4
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/main/index.d.ts +0 -32
- package/lib/types/main/index.d.ts.map +0 -1
- package/lib/types/register-worker/index.d.ts +0 -5
- package/lib/types/register-worker/index.d.ts.map +0 -1
- package/src/consts/index.ts +0 -7
- package/src/debug/log-subscription/index.ts +0 -41
- package/src/register-worker/index.ts +0 -95
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PartialRequestResult, type RequestContext, type RequestOptions } from '@graphql-box/core';
|
|
2
|
+
import { type WorkerClient } from '../main.ts';
|
|
3
|
+
type Descriptor = (request: string, options: RequestOptions, context: RequestContext) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
|
|
4
|
+
export declare const logSubscription: () => (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>) => void;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=logSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSubscription.d.ts","sourceRoot":"","sources":["../../../../src/debug/logSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,KAAK,UAAU,GAAG,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,oBAAoB,GAAG,qBAAqB,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC,CAAC;AAE7F,eAAO,MAAM,eAAe,kBACT,YAAY,iBAAiB,MAAM,cAAc,wBAAwB,UAAU,CAAC,KAAG,IAiCzG,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';
|
|
2
|
+
import type { MessageRequestPayload } from '../types.ts';
|
|
3
|
+
export declare const isGraphqlBoxMessageRequestPayload: (payload: MessageRequestPayload | CachemapMessageRequestPayload) => payload is MessageRequestPayload;
|
|
4
|
+
//# sourceMappingURL=isGraphqlBoxMessageRequestPayload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isGraphqlBoxMessageRequestPayload.d.ts","sourceRoot":"","sources":["../../../../src/helpers/isGraphqlBoxMessageRequestPayload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,IAAI,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAE1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,eAAO,MAAM,iCAAiC,YACnC,qBAAqB,GAAG,6BAA6B,qCACG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operationNameRegex.d.ts","sourceRoot":"","sources":["../../../../src/helpers/operationNameRegex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa,MAAM,uBAGjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CoreWorker } from '@cachemap/core-worker';
|
|
2
|
+
import { type PartialRequestContext, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';
|
|
3
|
+
import { type UserOptions } from './types.ts';
|
|
4
|
+
export declare class WorkerClient {
|
|
5
|
+
private static _getMessageContext;
|
|
6
|
+
private _onMessage;
|
|
7
|
+
private _cache;
|
|
8
|
+
private _debugManager;
|
|
9
|
+
private _eventEmitter;
|
|
10
|
+
private _experimentalDeferStreamSupport;
|
|
11
|
+
private _pending;
|
|
12
|
+
private _worker;
|
|
13
|
+
constructor(options: UserOptions);
|
|
14
|
+
get cache(): CoreWorker;
|
|
15
|
+
mutate(request: string, options?: RequestOptions, context?: PartialRequestContext): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
|
|
16
|
+
query(request: string, options?: RequestOptions, context?: PartialRequestContext): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
|
|
17
|
+
request(request: string, options?: RequestOptions, context?: PartialRequestContext): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
|
|
18
|
+
subscribe(request: string, options?: RequestOptions): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
|
|
19
|
+
private _addEventListener;
|
|
20
|
+
private _getRequestContext;
|
|
21
|
+
private _request;
|
|
22
|
+
private _subscribe;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAGzB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAiB3B,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,OAAO,CAAC,UAAU,CAwDhB;IAEF,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,+BAA+B,CAAU;IACjD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,WAAW;IA2BhC,IAAI,KAAK,IAAI,UAAU,CAEtB;IAEY,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,EAAE,OAAO,GAAE,qBAA0B;IAIzF,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,EAAE,OAAO,GAAE,qBAA0B;IAIxF,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,EAAE,OAAO,GAAE,qBAA0B;IAI1F,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAIpE,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,kBAAkB;YAwBZ,QAAQ;IA2BtB,OAAO,CAAC,UAAU;CAwBnB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Client } from '@graphql-box/client';
|
|
2
|
+
import { type MessageRequestPayload, type RegisterWorkerOptions } from './types.ts';
|
|
3
|
+
export declare const handleMessage: (data: MessageRequestPayload, client: Client) => void;
|
|
4
|
+
export declare const registerWorker: ({ client }: RegisterWorkerOptions) => void;
|
|
5
|
+
//# sourceMappingURL=registerWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWorker.d.ts","sourceRoot":"","sources":["../../../src/registerWorker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAUlD,OAAO,EAEL,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAmEpB,eAAO,MAAM,aAAa,SAAU,qBAAqB,UAAU,MAAM,KAAG,IAQ3E,CAAC;AAEF,eAAO,MAAM,cAAc,eAAgB,qBAAqB,KAAG,IAUlE,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Client from
|
|
3
|
-
import { DebugManagerDef,
|
|
1
|
+
import { type CoreWorker } from '@cachemap/core-worker';
|
|
2
|
+
import { type Client } from '@graphql-box/client';
|
|
3
|
+
import { type DebugManagerDef, type PartialRawFetchData, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';
|
|
4
4
|
export interface UserOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The cache.
|
|
7
7
|
*/
|
|
8
|
-
cache:
|
|
8
|
+
cache: CoreWorker;
|
|
9
9
|
/**
|
|
10
10
|
* The debug manager.
|
|
11
11
|
*/
|
|
@@ -20,24 +20,24 @@ export interface UserOptions {
|
|
|
20
20
|
*/
|
|
21
21
|
worker: Worker;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
24
|
-
export
|
|
23
|
+
export type MethodNames = 'request' | 'subscribe';
|
|
24
|
+
export type PendingResolver = (value: PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>) => void;
|
|
25
25
|
export interface PendingData {
|
|
26
26
|
resolve: PendingResolver;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export type PendingTracker = Map<string, PendingData>;
|
|
29
29
|
export interface MessageRequestPayload {
|
|
30
30
|
context: MessageContext;
|
|
31
31
|
method: MethodNames;
|
|
32
32
|
options: RequestOptions;
|
|
33
33
|
request: string;
|
|
34
|
-
type:
|
|
34
|
+
type: 'graphqlBox' | 'cachemap';
|
|
35
35
|
}
|
|
36
36
|
export interface MessageResponsePayload {
|
|
37
37
|
context: MessageContext;
|
|
38
38
|
method: MethodNames;
|
|
39
|
-
result:
|
|
40
|
-
type:
|
|
39
|
+
result: PartialRawFetchData;
|
|
40
|
+
type: 'graphqlBox' | 'cachemap';
|
|
41
41
|
}
|
|
42
42
|
export interface MessageContext {
|
|
43
43
|
hasDeferOrStream: boolean;
|
|
@@ -46,4 +46,4 @@ export interface MessageContext {
|
|
|
46
46
|
export interface RegisterWorkerOptions {
|
|
47
47
|
client: Client;
|
|
48
48
|
}
|
|
49
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,eAAe,CAAC;IAE/B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IAEzC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAAC,oBAAoB,GAAG,SAAS,CAAC,KAClF,IAAI,CAAC;AAEV,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB"}
|