@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.
Files changed (110) hide show
  1. package/README.md +1 -5
  2. package/dist/cjs/index.cjs +410 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/esm/index.mjs +401 -0
  5. package/dist/esm/index.mjs.map +1 -0
  6. package/dist/types/cjs/constants.d.cts +6 -0
  7. package/dist/types/cjs/constants.d.cts.map +1 -0
  8. package/dist/types/cjs/debug/logRequest.d.cts +6 -0
  9. package/dist/types/cjs/debug/logRequest.d.cts.map +1 -0
  10. package/dist/types/cjs/debug/logSubscription.d.cts +6 -0
  11. package/dist/types/cjs/debug/logSubscription.d.cts.map +1 -0
  12. package/dist/types/cjs/helpers/isGraphqlBoxMessageRequestPayload.d.cts +4 -0
  13. package/dist/types/cjs/helpers/isGraphqlBoxMessageRequestPayload.d.cts.map +1 -0
  14. package/dist/types/cjs/helpers/operationNameRegex.d.cts +2 -0
  15. package/dist/types/cjs/helpers/operationNameRegex.d.cts.map +1 -0
  16. package/dist/types/cjs/index.d.cts +5 -0
  17. package/dist/types/cjs/index.d.cts.map +1 -0
  18. package/dist/types/cjs/main.d.cts +24 -0
  19. package/dist/types/cjs/main.d.cts.map +1 -0
  20. package/dist/types/cjs/registerWorker.d.cts +5 -0
  21. package/dist/types/cjs/registerWorker.d.cts.map +1 -0
  22. package/dist/types/cjs/types.d.cts +49 -0
  23. package/dist/types/cjs/types.d.cts.map +1 -0
  24. package/dist/types/esm/constants.d.ts +6 -0
  25. package/dist/types/esm/constants.d.ts.map +1 -0
  26. package/dist/types/esm/debug/logRequest.d.ts +6 -0
  27. package/dist/types/esm/debug/logRequest.d.ts.map +1 -0
  28. package/dist/types/esm/debug/logSubscription.d.ts +6 -0
  29. package/dist/types/esm/debug/logSubscription.d.ts.map +1 -0
  30. package/dist/types/esm/helpers/isGraphqlBoxMessageRequestPayload.d.ts +4 -0
  31. package/dist/types/esm/helpers/isGraphqlBoxMessageRequestPayload.d.ts.map +1 -0
  32. package/dist/types/esm/helpers/operationNameRegex.d.ts +2 -0
  33. package/dist/types/esm/helpers/operationNameRegex.d.ts.map +1 -0
  34. package/dist/types/esm/index.d.ts +5 -0
  35. package/dist/types/esm/index.d.ts.map +1 -0
  36. package/dist/types/esm/main.d.ts +24 -0
  37. package/dist/types/esm/main.d.ts.map +1 -0
  38. package/dist/types/esm/registerWorker.d.ts +5 -0
  39. package/dist/types/esm/registerWorker.d.ts.map +1 -0
  40. package/{lib/types/defs/index.d.ts → dist/types/esm/types.d.ts} +11 -11
  41. package/dist/types/esm/types.d.ts.map +1 -0
  42. package/dist/types/tsconfig.build.tsbuildinfo +1 -0
  43. package/package.json +57 -45
  44. package/src/constants.ts +5 -0
  45. package/src/debug/{log-request/index.ts → logRequest.ts} +30 -20
  46. package/src/debug/logSubscription.ts +50 -0
  47. package/src/helpers/isGraphqlBoxMessageRequestPayload.ts +7 -0
  48. package/src/helpers/operationNameRegex.test.ts +26 -14
  49. package/src/helpers/operationNameRegex.ts +2 -2
  50. package/src/index.ts +4 -3
  51. package/src/{main/index.ts → main.ts} +135 -108
  52. package/src/registerWorker.ts +107 -0
  53. package/src/{defs/index.ts → types.ts} +14 -9
  54. package/tsconfig.build.json +10 -0
  55. package/tsconfig.json +17 -0
  56. package/lib/browser/index.js +0 -2
  57. package/lib/browser/index.js.map +0 -1
  58. package/lib/browser/production.analysis.txt +0 -81
  59. package/lib/main/consts/index.js +0 -17
  60. package/lib/main/consts/index.js.map +0 -1
  61. package/lib/main/debug/log-request/index.js +0 -77
  62. package/lib/main/debug/log-request/index.js.map +0 -1
  63. package/lib/main/debug/log-subscription/index.js +0 -55
  64. package/lib/main/debug/log-subscription/index.js.map +0 -1
  65. package/lib/main/defs/index.js +0 -2
  66. package/lib/main/defs/index.js.map +0 -1
  67. package/lib/main/helpers/operationNameRegex.js +0 -14
  68. package/lib/main/helpers/operationNameRegex.js.map +0 -1
  69. package/lib/main/index.js +0 -41
  70. package/lib/main/index.js.map +0 -1
  71. package/lib/main/main/index.js +0 -249
  72. package/lib/main/main/index.js.map +0 -1
  73. package/lib/main/register-worker/index.js +0 -143
  74. package/lib/main/register-worker/index.js.map +0 -1
  75. package/lib/module/consts/index.mjs +0 -6
  76. package/lib/module/consts/index.mjs.map +0 -1
  77. package/lib/module/debug/log-request/index.mjs +0 -64
  78. package/lib/module/debug/log-request/index.mjs.map +0 -1
  79. package/lib/module/debug/log-subscription/index.mjs +0 -43
  80. package/lib/module/debug/log-subscription/index.mjs.map +0 -1
  81. package/lib/module/defs/index.mjs +0 -2
  82. package/lib/module/defs/index.mjs.map +0 -1
  83. package/lib/module/helpers/operationNameRegex.mjs +0 -5
  84. package/lib/module/helpers/operationNameRegex.mjs.map +0 -1
  85. package/lib/module/index.mjs +0 -4
  86. package/lib/module/index.mjs.map +0 -1
  87. package/lib/module/main/index.mjs +0 -236
  88. package/lib/module/main/index.mjs.map +0 -1
  89. package/lib/module/register-worker/index.mjs +0 -126
  90. package/lib/module/register-worker/index.mjs.map +0 -1
  91. package/lib/types/consts/index.d.ts +0 -6
  92. package/lib/types/consts/index.d.ts.map +0 -1
  93. package/lib/types/debug/log-request/index.d.ts +0 -2
  94. package/lib/types/debug/log-request/index.d.ts.map +0 -1
  95. package/lib/types/debug/log-subscription/index.d.ts +0 -2
  96. package/lib/types/debug/log-subscription/index.d.ts.map +0 -1
  97. package/lib/types/defs/index.d.ts.map +0 -1
  98. package/lib/types/helpers/operationNameRegex.d.ts +0 -3
  99. package/lib/types/helpers/operationNameRegex.d.ts.map +0 -1
  100. package/lib/types/helpers/operationNameRegex.test.d.ts +0 -2
  101. package/lib/types/helpers/operationNameRegex.test.d.ts.map +0 -1
  102. package/lib/types/index.d.ts +0 -4
  103. package/lib/types/index.d.ts.map +0 -1
  104. package/lib/types/main/index.d.ts +0 -32
  105. package/lib/types/main/index.d.ts.map +0 -1
  106. package/lib/types/register-worker/index.d.ts +0 -5
  107. package/lib/types/register-worker/index.d.ts.map +0 -1
  108. package/src/consts/index.ts +0 -7
  109. package/src/debug/log-subscription/index.ts +0 -41
  110. package/src/register-worker/index.ts +0 -95
@@ -0,0 +1,401 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _applyDecoratedDescriptor from '@babel/runtime/helpers/applyDecoratedDescriptor';
3
+ import 'core-js/modules/es.array.push.js';
4
+ import { REQUEST_EXECUTED, REQUEST_RESOLVED, SUBSCRIPTION_EXECUTED, SUBSCRIPTION_RESOLVED } from '@graphql-box/core';
5
+ import { isPlainObject, deserializeErrors, rehydrateCacheMetadata, EventAsyncIterator, ArgsError, GroupedError, hashRequest, dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';
6
+ import { EventEmitter } from 'eventemitter3';
7
+ import { OperationTypeNode } from 'graphql';
8
+ import { isError } from 'lodash-es';
9
+ import { v4 } from 'uuid';
10
+ import { isAsyncIterable, forAwaitEach } from 'iterall';
11
+ import 'core-js/modules/web.self.js';
12
+ import { handleMessage as handleMessage$1 } from '@cachemap/core-worker';
13
+
14
+ const CACHEMAP = 'cachemap';
15
+ const GRAPHQL_BOX = 'graphqlBox';
16
+ const MESSAGE = 'message';
17
+ const REQUEST = 'request';
18
+ const SUBSCRIBE = 'subscribe';
19
+
20
+ const operationNameRegex = request => {
21
+ const output = /(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(request);
22
+ return output ? output[2] : '';
23
+ };
24
+
25
+ const logRequest = () => {
26
+ return (_target, _propertyName, descriptor) => {
27
+ const method = descriptor.value;
28
+ if (!method) {
29
+ return;
30
+ }
31
+ descriptor.value = async function descriptorValue(...args) {
32
+ return new Promise(resolve => {
33
+ void (async () => {
34
+ const {
35
+ debugManager,
36
+ ...otherContext
37
+ } = args[2];
38
+ if (!debugManager) {
39
+ resolve(await method.apply(this, args));
40
+ return;
41
+ }
42
+ const derivedOperationName = operationNameRegex(args[0]);
43
+ const startTime = debugManager.now();
44
+ debugManager.log(REQUEST_EXECUTED, {
45
+ context: {
46
+ ...otherContext,
47
+ operationName: derivedOperationName
48
+ },
49
+ options: args[1],
50
+ request: args[0],
51
+ stats: {
52
+ startTime
53
+ }
54
+ });
55
+ const result = await method.apply(this, args);
56
+ const endTime = debugManager.now();
57
+ const duration = endTime - startTime;
58
+ resolve(result);
59
+ if (isAsyncIterable(result)) {
60
+ return;
61
+ }
62
+ debugManager.log(REQUEST_RESOLVED, {
63
+ context: {
64
+ ...otherContext,
65
+ operationName: derivedOperationName
66
+ },
67
+ options: args[1],
68
+ request: args[0],
69
+ result,
70
+ stats: {
71
+ duration,
72
+ endTime,
73
+ startTime
74
+ }
75
+ });
76
+ })();
77
+ });
78
+ };
79
+ };
80
+ };
81
+
82
+ const logSubscription = () => {
83
+ return (_target, _propertyName, descriptor) => {
84
+ const method = descriptor.value;
85
+ if (!method) {
86
+ return;
87
+ }
88
+ descriptor.value = async function descriptorValue(...args) {
89
+ return new Promise(resolve => {
90
+ void (async () => {
91
+ const {
92
+ debugManager,
93
+ ...otherContext
94
+ } = args[2];
95
+ if (!debugManager) {
96
+ resolve(await method.apply(this, args));
97
+ return;
98
+ }
99
+ const derivedOperationName = operationNameRegex(args[0]);
100
+ const startTime = debugManager.now();
101
+ debugManager.log(SUBSCRIPTION_EXECUTED, {
102
+ context: {
103
+ ...otherContext,
104
+ operationName: derivedOperationName
105
+ },
106
+ options: args[1],
107
+ request: args[0],
108
+ stats: {
109
+ startTime
110
+ }
111
+ });
112
+ const result = await method.apply(this, args);
113
+ resolve(result);
114
+ })();
115
+ });
116
+ };
117
+ };
118
+ };
119
+
120
+ var _dec, _dec2, _class;
121
+ let WorkerClient = (_dec = logRequest(), _dec2 = logSubscription(), (_class = class WorkerClient {
122
+ static _getMessageContext({
123
+ hasDeferOrStream = false,
124
+ requestID
125
+ }) {
126
+ return {
127
+ hasDeferOrStream,
128
+ requestID
129
+ };
130
+ }
131
+ constructor(options) {
132
+ _defineProperty(this, "_onMessage", ({
133
+ data
134
+ }) => {
135
+ if (!isPlainObject(data)) {
136
+ return;
137
+ }
138
+ const {
139
+ context,
140
+ method,
141
+ result,
142
+ type
143
+ } = data;
144
+ if (type !== GRAPHQL_BOX) {
145
+ return;
146
+ }
147
+ const {
148
+ _cacheMetadata,
149
+ ...otherProps
150
+ } = result;
151
+ const response = {
152
+ ...deserializeErrors(otherProps),
153
+ requestID: context.requestID
154
+ };
155
+ if (_cacheMetadata) {
156
+ response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);
157
+ }
158
+ if (method === SUBSCRIBE) {
159
+ this._debugManager?.log(SUBSCRIPTION_RESOLVED, {
160
+ context,
161
+ result: response,
162
+ stats: {
163
+ endTime: this._debugManager.now()
164
+ }
165
+ });
166
+ this._eventEmitter.emit(context.requestID, response);
167
+ } else if (context.hasDeferOrStream) {
168
+ const pending = this._pending.get(context.requestID);
169
+ if (pending) {
170
+ const eventAsyncIterator = new EventAsyncIterator(this._eventEmitter, context.requestID);
171
+ pending.resolve(eventAsyncIterator.getIterator());
172
+ }
173
+ this._debugManager?.log(REQUEST_RESOLVED, {
174
+ context,
175
+ result: response,
176
+ stats: {
177
+ endTime: this._debugManager.now()
178
+ }
179
+ });
180
+ this._eventEmitter.emit(context.requestID, response);
181
+ } else {
182
+ const pending = this._pending.get(context.requestID);
183
+ if (!pending) {
184
+ return;
185
+ }
186
+ this._debugManager?.log(REQUEST_RESOLVED, {
187
+ context,
188
+ result: response,
189
+ stats: {
190
+ endTime: this._debugManager.now()
191
+ }
192
+ });
193
+ pending.resolve(response);
194
+ }
195
+ });
196
+ _defineProperty(this, "_cache", void 0);
197
+ _defineProperty(this, "_debugManager", void 0);
198
+ _defineProperty(this, "_eventEmitter", void 0);
199
+ _defineProperty(this, "_experimentalDeferStreamSupport", void 0);
200
+ _defineProperty(this, "_pending", new Map());
201
+ _defineProperty(this, "_worker", void 0);
202
+ const errors = [];
203
+ if (!isPlainObject(options)) {
204
+ errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));
205
+ }
206
+ if (!('cache' in options)) {
207
+ errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));
208
+ }
209
+ if (!('worker' in options)) {
210
+ errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));
211
+ }
212
+ if (errors.length > 0) {
213
+ throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);
214
+ }
215
+ this._cache = options.cache;
216
+ this._debugManager = options.debugManager ?? null;
217
+ this._eventEmitter = new EventEmitter();
218
+ this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;
219
+ this._worker = options.worker;
220
+ this._addEventListener();
221
+ }
222
+ get cache() {
223
+ return this._cache;
224
+ }
225
+ async mutate(request, options = {}, context = {}) {
226
+ return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));
227
+ }
228
+ async query(request, options = {}, context = {}) {
229
+ return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));
230
+ }
231
+ async request(request, options = {}, context = {}) {
232
+ return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));
233
+ }
234
+ async subscribe(request, options = {}) {
235
+ return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));
236
+ }
237
+ _addEventListener() {
238
+ this._worker.addEventListener(MESSAGE, this._onMessage);
239
+ }
240
+ _getRequestContext(operation, request, context = {}) {
241
+ return {
242
+ debugManager: this._debugManager,
243
+ experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,
244
+ fieldTypeMap: new Map(),
245
+ filteredRequest: '',
246
+ operation,
247
+ operationName: '',
248
+ originalRequestHash: hashRequest(request),
249
+ parsedRequest: '',
250
+ queryFiltered: false,
251
+ request,
252
+ requestComplexity: null,
253
+ requestDepth: null,
254
+ requestID: v4(),
255
+ ...context
256
+ };
257
+ }
258
+ async _request(request, options, context) {
259
+ try {
260
+ return await new Promise(resolve => {
261
+ this._worker.postMessage({
262
+ context: WorkerClient._getMessageContext(context),
263
+ method: REQUEST,
264
+ options,
265
+ request,
266
+ type: GRAPHQL_BOX
267
+ });
268
+ this._pending.set(context.requestID, {
269
+ resolve
270
+ });
271
+ });
272
+ } catch (error) {
273
+ const confirmedError = isError(error) ? error : new Error('@graphql-box/worker-client request had an unexpected error.');
274
+ return {
275
+ errors: [confirmedError],
276
+ requestID: context.requestID
277
+ };
278
+ }
279
+ }
280
+ _subscribe(request, options, context) {
281
+ try {
282
+ this._worker.postMessage({
283
+ context: WorkerClient._getMessageContext(context),
284
+ method: SUBSCRIBE,
285
+ options,
286
+ request,
287
+ type: GRAPHQL_BOX
288
+ });
289
+ const eventAsyncIterator = new EventAsyncIterator(this._eventEmitter, context.requestID);
290
+ return Promise.resolve(eventAsyncIterator.getIterator());
291
+ } catch (error) {
292
+ const confirmedError = isError(error) ? error : new Error('@graphql-box/worker-client subscribe had an unexpected error.');
293
+ return Promise.resolve({
294
+ errors: [confirmedError],
295
+ requestID: context.requestID
296
+ });
297
+ }
298
+ }
299
+ }, (_applyDecoratedDescriptor(_class.prototype, "_request", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "_request"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_subscribe", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "_subscribe"), _class.prototype)), _class));
300
+
301
+ const isGraphqlBoxMessageRequestPayload = payload => payload.type === GRAPHQL_BOX;
302
+
303
+ const globalScope = self;
304
+ const handleRequest = async (request, method, options, context, client) => {
305
+ const requestResult = await client.request(request, options, context);
306
+ if (!isAsyncIterable(requestResult)) {
307
+ const {
308
+ _cacheMetadata,
309
+ ...otherProps
310
+ } = requestResult;
311
+ const result = {
312
+ ...otherProps
313
+ };
314
+ if (_cacheMetadata) {
315
+ result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
316
+ }
317
+ globalScope.postMessage({
318
+ context,
319
+ method,
320
+ result: serializeErrors(result),
321
+ type: GRAPHQL_BOX
322
+ });
323
+ return;
324
+ }
325
+ void forAwaitEach(requestResult, ({
326
+ _cacheMetadata,
327
+ ...otherProps
328
+ }) => {
329
+ const result = {
330
+ ...otherProps
331
+ };
332
+ if (_cacheMetadata) {
333
+ result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
334
+ }
335
+ globalScope.postMessage({
336
+ context,
337
+ method,
338
+ result: serializeErrors(result),
339
+ type: GRAPHQL_BOX
340
+ });
341
+ });
342
+ };
343
+ const handleSubscription = async (request, method, options, context, client) => {
344
+ const subscribeResult = await client.subscribe(request, options, context);
345
+ if (!isAsyncIterable(subscribeResult)) {
346
+ globalScope.postMessage({
347
+ context,
348
+ method,
349
+ result: serializeErrors(subscribeResult),
350
+ type: GRAPHQL_BOX
351
+ });
352
+ return;
353
+ }
354
+ void forAwaitEach(subscribeResult, ({
355
+ _cacheMetadata,
356
+ ...otherProps
357
+ }) => {
358
+ const result = {
359
+ ...otherProps
360
+ };
361
+ if (_cacheMetadata) {
362
+ result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
363
+ }
364
+ globalScope.postMessage({
365
+ context,
366
+ method,
367
+ result: serializeErrors(result),
368
+ type: GRAPHQL_BOX
369
+ });
370
+ });
371
+ };
372
+ const handleMessage = (data, client) => {
373
+ const {
374
+ context,
375
+ method,
376
+ options,
377
+ request
378
+ } = data;
379
+ if (method === REQUEST) {
380
+ void handleRequest(request, method, options, context, client);
381
+ } else {
382
+ void handleSubscription(request, method, options, context, client);
383
+ }
384
+ };
385
+ const registerWorker = ({
386
+ client
387
+ }) => {
388
+ const onMessage = ({
389
+ data
390
+ }) => {
391
+ if (isGraphqlBoxMessageRequestPayload(data)) {
392
+ handleMessage(data, client);
393
+ } else {
394
+ void handleMessage$1(data, client.cache);
395
+ }
396
+ };
397
+ globalScope.addEventListener(MESSAGE, onMessage);
398
+ };
399
+
400
+ export { CACHEMAP, GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE, WorkerClient, handleMessage, registerWorker };
401
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../worker-client/src//constants.ts","../worker-client/src//helpers/operationNameRegex.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.ts","../worker-client/src//main.ts","../worker-client/src//helpers/isGraphqlBoxMessageRequestPayload.ts","../worker-client/src//registerWorker.ts"],"sourcesContent":["export const CACHEMAP = 'cachemap' as const;\nexport const GRAPHQL_BOX = 'graphqlBox' as const;\nexport const MESSAGE = 'message' as const;\nexport const REQUEST = 'request' as const;\nexport const SUBSCRIBE = 'subscribe' as const;\n","export const operationNameRegex = (request: string) => {\n const output = /(query|mutation|subscription) ([A-Za-z]+)(\\(| {)/.exec(request);\n return output ? output[2] : '';\n};\n","import {\n type PartialRequestResult,\n REQUEST_EXECUTED,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { isAsyncIterable } from 'iterall';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logRequest = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(REQUEST_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n const endTime = debugManager.now();\n const duration = endTime - startTime;\n resolve(result);\n\n if (isAsyncIterable(result)) {\n return;\n }\n\n debugManager.log(REQUEST_RESOLVED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n result,\n stats: { duration, endTime, startTime },\n });\n })();\n });\n };\n };\n};\n","import {\n type PartialRequestResult,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_EXECUTED,\n} from '@graphql-box/core';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logSubscription = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(SUBSCRIPTION_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n resolve(result);\n })();\n });\n };\n };\n};\n","import { type CoreWorker } from '@cachemap/core-worker';\nimport {\n type DebugManagerDef,\n type PartialRequestContext,\n type PartialRequestResult,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_RESOLVED,\n} from '@graphql-box/core';\nimport {\n ArgsError,\n EventAsyncIterator,\n GroupedError,\n deserializeErrors,\n hashRequest,\n isPlainObject,\n rehydrateCacheMetadata,\n} from '@graphql-box/helpers';\nimport { EventEmitter } from 'eventemitter3';\nimport { OperationTypeNode } from 'graphql';\nimport { isError } from 'lodash-es';\nimport { v4 as uuidv4 } from 'uuid';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE } from './constants.ts';\nimport { logRequest } from './debug/logRequest.ts';\nimport { logSubscription } from './debug/logSubscription.ts';\nimport {\n type MessageContext,\n type MessageResponsePayload,\n type PendingResolver,\n type PendingTracker,\n type UserOptions,\n} from './types.ts';\n\nexport class WorkerClient {\n private static _getMessageContext({ hasDeferOrStream = false, requestID }: RequestContext): MessageContext {\n return { hasDeferOrStream, requestID };\n }\n\n private _onMessage = ({ data }: MessageEvent<MessageResponsePayload>): void => {\n if (!isPlainObject(data)) {\n return;\n }\n\n const { context, method, result, type } = data;\n\n if (type !== GRAPHQL_BOX) {\n return;\n }\n\n const { _cacheMetadata, ...otherProps } = result;\n const response: PartialRequestResult = { ...deserializeErrors(otherProps), requestID: context.requestID };\n\n if (_cacheMetadata) {\n response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);\n }\n\n if (method === SUBSCRIBE) {\n this._debugManager?.log(SUBSCRIPTION_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else if (context.hasDeferOrStream) {\n const pending = this._pending.get(context.requestID);\n\n if (pending) {\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n pending.resolve(eventAsyncIterator.getIterator());\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else {\n const pending = this._pending.get(context.requestID);\n\n if (!pending) {\n return;\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n pending.resolve(response);\n }\n };\n\n private _cache: CoreWorker;\n private _debugManager: DebugManagerDef | null;\n private _eventEmitter: EventEmitter;\n private _experimentalDeferStreamSupport: boolean;\n private _pending: PendingTracker = new Map();\n private _worker: Worker;\n\n constructor(options: UserOptions) {\n const errors: ArgsError[] = [];\n\n if (!isPlainObject(options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));\n }\n\n if (!('cache' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));\n }\n\n if (!('worker' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));\n }\n\n if (errors.length > 0) {\n throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);\n }\n\n this._cache = options.cache;\n this._debugManager = options.debugManager ?? null;\n this._eventEmitter = new EventEmitter();\n this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;\n this._worker = options.worker;\n this._addEventListener();\n }\n\n get cache(): CoreWorker {\n return this._cache;\n }\n\n public async mutate(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));\n }\n\n public async query(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async request(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async subscribe(request: string, options: RequestOptions = {}) {\n return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));\n }\n\n private _addEventListener(): void {\n this._worker.addEventListener(MESSAGE, this._onMessage);\n }\n\n private _getRequestContext(\n operation: OperationTypeNode,\n request: string,\n context: PartialRequestContext = {}\n ): RequestContext {\n return {\n debugManager: this._debugManager,\n experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,\n fieldTypeMap: new Map(),\n filteredRequest: '',\n operation,\n operationName: '',\n originalRequestHash: hashRequest(request),\n parsedRequest: '',\n queryFiltered: false,\n request,\n requestComplexity: null,\n requestDepth: null,\n requestID: uuidv4(),\n ...context,\n };\n }\n\n @logRequest()\n private async _request(\n request: string,\n options: RequestOptions,\n context: RequestContext\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n return await new Promise((resolve: PendingResolver) => {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n\n this._pending.set(context.requestID, { resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n @logSubscription()\n private _subscribe(\n request: string,\n options: RequestOptions,\n context: RequestContext\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n return Promise.resolve(eventAsyncIterator.getIterator());\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client subscribe had an unexpected error.');\n\n return Promise.resolve({ errors: [confirmedError], requestID: context.requestID });\n }\n }\n}\n","import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';\nimport { GRAPHQL_BOX } from '../constants.ts';\nimport type { MessageRequestPayload } from '../types.ts';\n\nexport const isGraphqlBoxMessageRequestPayload = (\n payload: MessageRequestPayload | CachemapMessageRequestPayload\n): payload is MessageRequestPayload => payload.type === GRAPHQL_BOX;\n","import {\n type PostMessage as CachemapMessageRequestPayload,\n handleMessage as handleCachemapMessage,\n} from '@cachemap/core-worker';\nimport { type Client } from '@graphql-box/client';\nimport {\n type PartialRequestResult,\n type PartialRequestResultWithDehydratedCacheMetadata,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';\nimport { forAwaitEach, isAsyncIterable } from 'iterall';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST } from './constants.ts';\nimport { isGraphqlBoxMessageRequestPayload } from './helpers/isGraphqlBoxMessageRequestPayload.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MethodNames,\n type RegisterWorkerOptions,\n} from './types.ts';\n\nconst globalScope = self as unknown as DedicatedWorkerGlobalScope;\n\nconst handleRequest = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client\n): Promise<void> => {\n const requestResult = await client.request(request, options, context);\n\n if (!isAsyncIterable(requestResult)) {\n const { _cacheMetadata, ...otherProps } = requestResult as PartialRequestResult;\n const result: PartialRequestResultWithDehydratedCacheMetadata = { ...otherProps };\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalScope.postMessage({ context, method, result: serializeErrors(result), type: GRAPHQL_BOX });\n return;\n }\n\n void forAwaitEach(requestResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialRequestResultWithDehydratedCacheMetadata = { ...otherProps };\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalScope.postMessage({ context, method, result: serializeErrors(result), type: GRAPHQL_BOX });\n });\n};\n\nconst handleSubscription = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client\n): Promise<void> => {\n const subscribeResult = await client.subscribe(request, options, context);\n\n if (!isAsyncIterable(subscribeResult)) {\n globalScope.postMessage({\n context,\n method,\n result: serializeErrors(subscribeResult as PartialRequestResult),\n type: GRAPHQL_BOX,\n });\n\n return;\n }\n\n void forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialRequestResultWithDehydratedCacheMetadata = { ...otherProps };\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalScope.postMessage({ context, method, result: serializeErrors(result), type: GRAPHQL_BOX });\n });\n};\n\nexport const handleMessage = (data: MessageRequestPayload, client: Client): void => {\n const { context, method, options, request } = data;\n\n if (method === REQUEST) {\n void handleRequest(request, method, options, context, client);\n } else {\n void handleSubscription(request, method, options, context, client);\n }\n};\n\nexport const registerWorker = ({ client }: RegisterWorkerOptions): void => {\n const onMessage = ({ data }: MessageEvent<MessageRequestPayload | CachemapMessageRequestPayload>): void => {\n if (isGraphqlBoxMessageRequestPayload(data)) {\n handleMessage(data, client);\n } else {\n void handleCachemapMessage(data, client.cache);\n }\n };\n\n globalScope.addEventListener(MESSAGE, onMessage);\n};\n"],"names":["CACHEMAP","GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","logRequest","_target","_propertyName","descriptor","method","value","descriptorValue","args","Promise","resolve","debugManager","otherContext","apply","derivedOperationName","startTime","now","log","REQUEST_EXECUTED","context","operationName","options","stats","result","endTime","duration","isAsyncIterable","REQUEST_RESOLVED","logSubscription","SUBSCRIPTION_EXECUTED","WorkerClient","_dec","_dec2","_class","_getMessageContext","hasDeferOrStream","requestID","constructor","_defineProperty","data","isPlainObject","type","_cacheMetadata","otherProps","response","deserializeErrors","rehydrateCacheMetadata","_debugManager","SUBSCRIPTION_RESOLVED","_eventEmitter","emit","pending","_pending","get","eventAsyncIterator","EventAsyncIterator","getIterator","Map","errors","push","ArgsError","length","GroupedError","_cache","cache","EventEmitter","_experimentalDeferStreamSupport","experimentalDeferStreamSupport","_worker","worker","_addEventListener","mutate","_request","_getRequestContext","OperationTypeNode","MUTATION","query","QUERY","subscribe","_subscribe","SUBSCRIPTION","addEventListener","_onMessage","operation","fieldTypeMap","filteredRequest","originalRequestHash","hashRequest","parsedRequest","queryFiltered","requestComplexity","requestDepth","uuidv4","postMessage","set","error","confirmedError","isError","Error","_applyDecoratedDescriptor","prototype","Object","getOwnPropertyDescriptor","isGraphqlBoxMessageRequestPayload","payload","globalScope","self","handleRequest","client","requestResult","dehydrateCacheMetadata","serializeErrors","forAwaitEach","handleSubscription","subscribeResult","handleMessage","registerWorker","onMessage","handleCachemapMessage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AgB,CAACvF,OAAO,EAAE2H,SAAS,CAAC,CAAA;AAClD;;;;"}
@@ -0,0 +1,6 @@
1
+ export declare const CACHEMAP: "cachemap";
2
+ export declare const GRAPHQL_BOX: "graphqlBox";
3
+ export declare const MESSAGE: "message";
4
+ export declare const REQUEST: "request";
5
+ export declare const SUBSCRIBE: "subscribe";
6
+ //# sourceMappingURL=constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/constants.cts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,YAAsB,CAAC;AAC5C,eAAO,MAAM,WAAW,cAAwB,CAAC;AACjD,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,SAAS,aAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type PartialRequestResult, type RequestContext, type RequestOptions } from '@graphql-box/core';
2
+ import { type WorkerClient } from '../main.cts';
3
+ type Descriptor = (request: string, options: RequestOptions, context: RequestContext) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;
4
+ export declare const logRequest: () => (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>) => void;
5
+ export {};
6
+ //# sourceMappingURL=logRequest.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logRequest.d.cts","sourceRoot":"","sources":["../../../../src/debug/logRequest.cts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAG3B,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,UAAU,kBACJ,YAAY,iBAAiB,MAAM,cAAc,wBAAwB,UAAU,CAAC,KAAG,IA+CzG,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type PartialRequestResult, type RequestContext, type RequestOptions } from '@graphql-box/core';
2
+ import { type WorkerClient } from '../main.cts';
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.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSubscription.d.cts","sourceRoot":"","sources":["../../../../src/debug/logSubscription.cts"],"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.cts';
3
+ export declare const isGraphqlBoxMessageRequestPayload: (payload: MessageRequestPayload | CachemapMessageRequestPayload) => payload is MessageRequestPayload;
4
+ //# sourceMappingURL=isGraphqlBoxMessageRequestPayload.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGraphqlBoxMessageRequestPayload.d.cts","sourceRoot":"","sources":["../../../../src/helpers/isGraphqlBoxMessageRequestPayload.cts"],"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,2 @@
1
+ export declare const operationNameRegex: (request: string) => string | undefined;
2
+ //# sourceMappingURL=operationNameRegex.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationNameRegex.d.cts","sourceRoot":"","sources":["../../../../src/helpers/operationNameRegex.cts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa,MAAM,uBAGjD,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './constants.cts';
2
+ export * from './main.cts';
3
+ export * from './registerWorker.cts';
4
+ export * from './types.cts';
5
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/index.cts"],"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.cts';
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.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"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.cts';
3
+ export declare const handleMessage: (data: MessageRequestPayload, client: Client) => void;
4
+ export declare const registerWorker: ({ client }: RegisterWorkerOptions) => void;
5
+ //# sourceMappingURL=registerWorker.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerWorker.d.cts","sourceRoot":"","sources":["../../../src/registerWorker.cts"],"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"}
@@ -0,0 +1,49 @@
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
+ export interface UserOptions {
5
+ /**
6
+ * The cache.
7
+ */
8
+ cache: CoreWorker;
9
+ /**
10
+ * The debug manager.
11
+ */
12
+ debugManager?: DebugManagerDef;
13
+ /**
14
+ * Enable support for defer and stream directives. Based on version
15
+ * of spec in 16.1.0-experimental-stream-defer.6
16
+ */
17
+ experimentalDeferStreamSupport?: boolean;
18
+ /**
19
+ * The web worker instance.
20
+ */
21
+ worker: Worker;
22
+ }
23
+ export type MethodNames = 'request' | 'subscribe';
24
+ export type PendingResolver = (value: PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>) => void;
25
+ export interface PendingData {
26
+ resolve: PendingResolver;
27
+ }
28
+ export type PendingTracker = Map<string, PendingData>;
29
+ export interface MessageRequestPayload {
30
+ context: MessageContext;
31
+ method: MethodNames;
32
+ options: RequestOptions;
33
+ request: string;
34
+ type: 'graphqlBox' | 'cachemap';
35
+ }
36
+ export interface MessageResponsePayload {
37
+ context: MessageContext;
38
+ method: MethodNames;
39
+ result: PartialRawFetchData;
40
+ type: 'graphqlBox' | 'cachemap';
41
+ }
42
+ export interface MessageContext {
43
+ hasDeferOrStream: boolean;
44
+ requestID: string;
45
+ }
46
+ export interface RegisterWorkerOptions {
47
+ client: Client;
48
+ }
49
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/types.cts"],"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"}
@@ -0,0 +1,6 @@
1
+ export declare const CACHEMAP: "cachemap";
2
+ export declare const GRAPHQL_BOX: "graphqlBox";
3
+ export declare const MESSAGE: "message";
4
+ export declare const REQUEST: "request";
5
+ export declare const SUBSCRIBE: "subscribe";
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,YAAsB,CAAC;AAC5C,eAAO,MAAM,WAAW,cAAwB,CAAC;AACjD,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,SAAS,aAAuB,CAAC"}
@@ -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 logRequest: () => (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>) => void;
5
+ export {};
6
+ //# sourceMappingURL=logRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logRequest.d.ts","sourceRoot":"","sources":["../../../../src/debug/logRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAG3B,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,UAAU,kBACJ,YAAY,iBAAiB,MAAM,cAAc,wBAAwB,UAAU,CAAC,KAAG,IA+CzG,CAAC"}