@graphql-box/worker-client 5.0.1 → 5.0.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.
@@ -1,410 +1,2 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _applyDecoratedDescriptor = require('@babel/runtime/helpers/applyDecoratedDescriptor');
5
- require('core-js/modules/es.array.push.js');
6
- var core = require('@graphql-box/core');
7
- var helpers = require('@graphql-box/helpers');
8
- var eventemitter3 = require('eventemitter3');
9
- var graphql = require('graphql');
10
- var lodashEs = require('lodash-es');
11
- var uuid = require('uuid');
12
- var iterall = require('iterall');
13
- require('core-js/modules/web.self.js');
14
- var coreWorker = require('@cachemap/core-worker');
15
-
16
- const CACHEMAP = 'cachemap';
17
- const GRAPHQL_BOX = 'graphqlBox';
18
- const MESSAGE = 'message';
19
- const REQUEST = 'request';
20
- const SUBSCRIBE = 'subscribe';
21
-
22
- const operationNameRegex = request => {
23
- const output = /(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(request);
24
- return output ? output[2] : '';
25
- };
26
-
27
- const logRequest = () => {
28
- return (_target, _propertyName, descriptor) => {
29
- const method = descriptor.value;
30
- if (!method) {
31
- return;
32
- }
33
- descriptor.value = async function descriptorValue(...args) {
34
- return new Promise(resolve => {
35
- void (async () => {
36
- const {
37
- debugManager,
38
- ...otherContext
39
- } = args[2];
40
- if (!debugManager) {
41
- resolve(await method.apply(this, args));
42
- return;
43
- }
44
- const derivedOperationName = operationNameRegex(args[0]);
45
- const startTime = debugManager.now();
46
- debugManager.log(core.REQUEST_EXECUTED, {
47
- context: {
48
- ...otherContext,
49
- operationName: derivedOperationName
50
- },
51
- options: args[1],
52
- request: args[0],
53
- stats: {
54
- startTime
55
- }
56
- });
57
- const result = await method.apply(this, args);
58
- const endTime = debugManager.now();
59
- const duration = endTime - startTime;
60
- resolve(result);
61
- if (iterall.isAsyncIterable(result)) {
62
- return;
63
- }
64
- debugManager.log(core.REQUEST_RESOLVED, {
65
- context: {
66
- ...otherContext,
67
- operationName: derivedOperationName
68
- },
69
- options: args[1],
70
- request: args[0],
71
- result,
72
- stats: {
73
- duration,
74
- endTime,
75
- startTime
76
- }
77
- });
78
- })();
79
- });
80
- };
81
- };
82
- };
83
-
84
- const logSubscription = () => {
85
- return (_target, _propertyName, descriptor) => {
86
- const method = descriptor.value;
87
- if (!method) {
88
- return;
89
- }
90
- descriptor.value = async function descriptorValue(...args) {
91
- return new Promise(resolve => {
92
- void (async () => {
93
- const {
94
- debugManager,
95
- ...otherContext
96
- } = args[2];
97
- if (!debugManager) {
98
- resolve(await method.apply(this, args));
99
- return;
100
- }
101
- const derivedOperationName = operationNameRegex(args[0]);
102
- const startTime = debugManager.now();
103
- debugManager.log(core.SUBSCRIPTION_EXECUTED, {
104
- context: {
105
- ...otherContext,
106
- operationName: derivedOperationName
107
- },
108
- options: args[1],
109
- request: args[0],
110
- stats: {
111
- startTime
112
- }
113
- });
114
- const result = await method.apply(this, args);
115
- resolve(result);
116
- })();
117
- });
118
- };
119
- };
120
- };
121
-
122
- var _dec, _dec2, _class;
123
- let WorkerClient = (_dec = logRequest(), _dec2 = logSubscription(), (_class = class WorkerClient {
124
- static _getMessageContext({
125
- hasDeferOrStream = false,
126
- requestID
127
- }) {
128
- return {
129
- hasDeferOrStream,
130
- requestID
131
- };
132
- }
133
- constructor(options) {
134
- _defineProperty(this, "_onMessage", ({
135
- data
136
- }) => {
137
- if (!helpers.isPlainObject(data)) {
138
- return;
139
- }
140
- const {
141
- context,
142
- method,
143
- result,
144
- type
145
- } = data;
146
- if (type !== GRAPHQL_BOX) {
147
- return;
148
- }
149
- const {
150
- _cacheMetadata,
151
- ...otherProps
152
- } = result;
153
- const response = {
154
- ...helpers.deserializeErrors(otherProps),
155
- requestID: context.requestID
156
- };
157
- if (_cacheMetadata) {
158
- response._cacheMetadata = helpers.rehydrateCacheMetadata(_cacheMetadata);
159
- }
160
- if (method === SUBSCRIBE) {
161
- this._debugManager?.log(core.SUBSCRIPTION_RESOLVED, {
162
- context,
163
- result: response,
164
- stats: {
165
- endTime: this._debugManager.now()
166
- }
167
- });
168
- this._eventEmitter.emit(context.requestID, response);
169
- } else if (context.hasDeferOrStream) {
170
- const pending = this._pending.get(context.requestID);
171
- if (pending) {
172
- const eventAsyncIterator = new helpers.EventAsyncIterator(this._eventEmitter, context.requestID);
173
- pending.resolve(eventAsyncIterator.getIterator());
174
- }
175
- this._debugManager?.log(core.REQUEST_RESOLVED, {
176
- context,
177
- result: response,
178
- stats: {
179
- endTime: this._debugManager.now()
180
- }
181
- });
182
- this._eventEmitter.emit(context.requestID, response);
183
- } else {
184
- const pending = this._pending.get(context.requestID);
185
- if (!pending) {
186
- return;
187
- }
188
- this._debugManager?.log(core.REQUEST_RESOLVED, {
189
- context,
190
- result: response,
191
- stats: {
192
- endTime: this._debugManager.now()
193
- }
194
- });
195
- pending.resolve(response);
196
- }
197
- });
198
- _defineProperty(this, "_cache", void 0);
199
- _defineProperty(this, "_debugManager", void 0);
200
- _defineProperty(this, "_eventEmitter", void 0);
201
- _defineProperty(this, "_experimentalDeferStreamSupport", void 0);
202
- _defineProperty(this, "_pending", new Map());
203
- _defineProperty(this, "_worker", void 0);
204
- const errors = [];
205
- if (!helpers.isPlainObject(options)) {
206
- errors.push(new helpers.ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));
207
- }
208
- if (!('cache' in options)) {
209
- errors.push(new helpers.ArgsError('@graphql-box/worker-client expected options.cache.'));
210
- }
211
- if (!('worker' in options)) {
212
- errors.push(new helpers.ArgsError('@graphql-box/worker-client expected options.worker.'));
213
- }
214
- if (errors.length > 0) {
215
- throw new helpers.GroupedError('@graphql-box/worker-client argument validation errors.', errors);
216
- }
217
- this._cache = options.cache;
218
- this._debugManager = options.debugManager ?? null;
219
- this._eventEmitter = new eventemitter3.EventEmitter();
220
- this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;
221
- this._worker = options.worker;
222
- this._addEventListener();
223
- }
224
- get cache() {
225
- return this._cache;
226
- }
227
- async mutate(request, options = {}, context = {}) {
228
- return this._request(request, options, this._getRequestContext(graphql.OperationTypeNode.MUTATION, request, context));
229
- }
230
- async query(request, options = {}, context = {}) {
231
- return this._request(request, options, this._getRequestContext(graphql.OperationTypeNode.QUERY, request, context));
232
- }
233
- async request(request, options = {}, context = {}) {
234
- return this._request(request, options, this._getRequestContext(graphql.OperationTypeNode.QUERY, request, context));
235
- }
236
- async subscribe(request, options = {}) {
237
- return this._subscribe(request, options, this._getRequestContext(graphql.OperationTypeNode.SUBSCRIPTION, request));
238
- }
239
- _addEventListener() {
240
- this._worker.addEventListener(MESSAGE, this._onMessage);
241
- }
242
- _getRequestContext(operation, request, context = {}) {
243
- return {
244
- debugManager: this._debugManager,
245
- experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,
246
- fieldTypeMap: new Map(),
247
- filteredRequest: '',
248
- operation,
249
- operationName: '',
250
- originalRequestHash: helpers.hashRequest(request),
251
- parsedRequest: '',
252
- queryFiltered: false,
253
- request,
254
- requestComplexity: null,
255
- requestDepth: null,
256
- requestID: uuid.v4(),
257
- ...context
258
- };
259
- }
260
- async _request(request, options, context) {
261
- try {
262
- return await new Promise(resolve => {
263
- this._worker.postMessage({
264
- context: WorkerClient._getMessageContext(context),
265
- method: REQUEST,
266
- options,
267
- request,
268
- type: GRAPHQL_BOX
269
- });
270
- this._pending.set(context.requestID, {
271
- resolve
272
- });
273
- });
274
- } catch (error) {
275
- const confirmedError = lodashEs.isError(error) ? error : new Error('@graphql-box/worker-client request had an unexpected error.');
276
- return {
277
- errors: [confirmedError],
278
- requestID: context.requestID
279
- };
280
- }
281
- }
282
- _subscribe(request, options, context) {
283
- try {
284
- this._worker.postMessage({
285
- context: WorkerClient._getMessageContext(context),
286
- method: SUBSCRIBE,
287
- options,
288
- request,
289
- type: GRAPHQL_BOX
290
- });
291
- const eventAsyncIterator = new helpers.EventAsyncIterator(this._eventEmitter, context.requestID);
292
- return Promise.resolve(eventAsyncIterator.getIterator());
293
- } catch (error) {
294
- const confirmedError = lodashEs.isError(error) ? error : new Error('@graphql-box/worker-client subscribe had an unexpected error.');
295
- return Promise.resolve({
296
- errors: [confirmedError],
297
- requestID: context.requestID
298
- });
299
- }
300
- }
301
- }, (_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));
302
-
303
- const isGraphqlBoxMessageRequestPayload = payload => payload.type === GRAPHQL_BOX;
304
-
305
- const globalScope = self;
306
- const handleRequest = async (request, method, options, context, client) => {
307
- const requestResult = await client.request(request, options, context);
308
- if (!iterall.isAsyncIterable(requestResult)) {
309
- const {
310
- _cacheMetadata,
311
- ...otherProps
312
- } = requestResult;
313
- const result = {
314
- ...otherProps
315
- };
316
- if (_cacheMetadata) {
317
- result._cacheMetadata = helpers.dehydrateCacheMetadata(_cacheMetadata);
318
- }
319
- globalScope.postMessage({
320
- context,
321
- method,
322
- result: helpers.serializeErrors(result),
323
- type: GRAPHQL_BOX
324
- });
325
- return;
326
- }
327
- void iterall.forAwaitEach(requestResult, ({
328
- _cacheMetadata,
329
- ...otherProps
330
- }) => {
331
- const result = {
332
- ...otherProps
333
- };
334
- if (_cacheMetadata) {
335
- result._cacheMetadata = helpers.dehydrateCacheMetadata(_cacheMetadata);
336
- }
337
- globalScope.postMessage({
338
- context,
339
- method,
340
- result: helpers.serializeErrors(result),
341
- type: GRAPHQL_BOX
342
- });
343
- });
344
- };
345
- const handleSubscription = async (request, method, options, context, client) => {
346
- const subscribeResult = await client.subscribe(request, options, context);
347
- if (!iterall.isAsyncIterable(subscribeResult)) {
348
- globalScope.postMessage({
349
- context,
350
- method,
351
- result: helpers.serializeErrors(subscribeResult),
352
- type: GRAPHQL_BOX
353
- });
354
- return;
355
- }
356
- void iterall.forAwaitEach(subscribeResult, ({
357
- _cacheMetadata,
358
- ...otherProps
359
- }) => {
360
- const result = {
361
- ...otherProps
362
- };
363
- if (_cacheMetadata) {
364
- result._cacheMetadata = helpers.dehydrateCacheMetadata(_cacheMetadata);
365
- }
366
- globalScope.postMessage({
367
- context,
368
- method,
369
- result: helpers.serializeErrors(result),
370
- type: GRAPHQL_BOX
371
- });
372
- });
373
- };
374
- const handleMessage = (data, client) => {
375
- const {
376
- context,
377
- method,
378
- options,
379
- request
380
- } = data;
381
- if (method === REQUEST) {
382
- void handleRequest(request, method, options, context, client);
383
- } else {
384
- void handleSubscription(request, method, options, context, client);
385
- }
386
- };
387
- const registerWorker = ({
388
- client
389
- }) => {
390
- const onMessage = ({
391
- data
392
- }) => {
393
- if (isGraphqlBoxMessageRequestPayload(data)) {
394
- handleMessage(data, client);
395
- } else {
396
- void coreWorker.handleMessage(data, client.cache);
397
- }
398
- };
399
- globalScope.addEventListener(MESSAGE, onMessage);
400
- };
401
-
402
- exports.CACHEMAP = CACHEMAP;
403
- exports.GRAPHQL_BOX = GRAPHQL_BOX;
404
- exports.MESSAGE = MESSAGE;
405
- exports.REQUEST = REQUEST;
406
- exports.SUBSCRIBE = SUBSCRIBE;
407
- exports.WorkerClient = WorkerClient;
408
- exports.handleMessage = handleMessage;
409
- exports.registerWorker = registerWorker;
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/applyDecoratedDescriptor");require("core-js/modules/es.array.push.js");var r=require("@graphql-box/core"),s=require("@graphql-box/helpers"),a=require("eventemitter3"),o=require("graphql"),n=require("lodash-es"),i=require("uuid"),c=require("iterall");require("core-js/modules/web.self.js");var u=require("@cachemap/core-worker");const p="graphqlBox",h="message",l="request",d="subscribe",g=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};var q,_,E;let m=(q=(e,t,s)=>{const a=s.value;a&&(s.value=async function(...e){return new Promise((t=>{(async()=>{const{debugManager:s,...o}=e[2];if(!s)return void t(await a.apply(this,e));const n=g(e[0]),i=s.now();s.log(r.REQUEST_EXECUTED,{context:{...o,operationName:n},options:e[1],request:e[0],stats:{startTime:i}});const u=await a.apply(this,e),p=s.now(),h=p-i;t(u),c.isAsyncIterable(u)||s.log(r.REQUEST_RESOLVED,{context:{...o,operationName:n},options:e[1],request:e[0],result:u,stats:{duration:h,endTime:p,startTime:i}})})()}))})},_=(e,t,s)=>{const a=s.value;a&&(s.value=async function(...e){return new Promise((t=>{(async()=>{const{debugManager:s,...o}=e[2];if(!s)return void t(await a.apply(this,e));const n=g(e[0]),i=s.now();s.log(r.SUBSCRIPTION_EXECUTED,{context:{...o,operationName:n},options:e[1],request:e[0],stats:{startTime:i}});const c=await a.apply(this,e);t(c)})()}))})},E=class t{static _getMessageContext({hasDeferOrStream:e=!1,requestID:t}){return{hasDeferOrStream:e,requestID:t}}constructor(t){e(this,"_onMessage",(({data:e})=>{if(!s.isPlainObject(e))return;const{context:t,method:a,result:o,type:n}=e;if(n!==p)return;const{_cacheMetadata:i,...c}=o,u={...s.deserializeErrors(c),requestID:t.requestID};if(i&&(u._cacheMetadata=s.rehydrateCacheMetadata(i)),a===d)this._debugManager?.log(r.SUBSCRIPTION_RESOLVED,{context:t,result:u,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(t.requestID,u);else if(t.hasDeferOrStream){const e=this._pending.get(t.requestID);if(e){const r=new s.EventAsyncIterator(this._eventEmitter,t.requestID);e.resolve(r.getIterator())}this._debugManager?.log(r.REQUEST_RESOLVED,{context:t,result:u,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(t.requestID,u)}else{const e=this._pending.get(t.requestID);if(!e)return;this._debugManager?.log(r.REQUEST_RESOLVED,{context:t,result:u,stats:{endTime:this._debugManager.now()}}),e.resolve(u)}})),e(this,"_cache",void 0),e(this,"_debugManager",void 0),e(this,"_eventEmitter",void 0),e(this,"_experimentalDeferStreamSupport",void 0),e(this,"_pending",new Map),e(this,"_worker",void 0);const o=[];if(s.isPlainObject(t)||o.push(new s.ArgsError("@graphql-box/worker-client expected options to ba a plain object.")),"cache"in t||o.push(new s.ArgsError("@graphql-box/worker-client expected options.cache.")),"worker"in t||o.push(new s.ArgsError("@graphql-box/worker-client expected options.worker.")),o.length>0)throw new s.GroupedError("@graphql-box/worker-client argument validation errors.",o);this._cache=t.cache,this._debugManager=t.debugManager??null,this._eventEmitter=new a.EventEmitter,this._experimentalDeferStreamSupport=t.experimentalDeferStreamSupport??!1,this._worker=t.worker,this._addEventListener()}get cache(){return this._cache}async mutate(e,t={},r={}){return this._request(e,t,this._getRequestContext(o.OperationTypeNode.MUTATION,e,r))}async query(e,t={},r={}){return this._request(e,t,this._getRequestContext(o.OperationTypeNode.QUERY,e,r))}async request(e,t={},r={}){return this._request(e,t,this._getRequestContext(o.OperationTypeNode.QUERY,e,r))}async subscribe(e,t={}){return this._subscribe(e,t,this._getRequestContext(o.OperationTypeNode.SUBSCRIPTION,e))}_addEventListener(){this._worker.addEventListener(h,this._onMessage)}_getRequestContext(e,t,r={}){return{debugManager:this._debugManager,experimentalDeferStreamSupport:this._experimentalDeferStreamSupport,fieldTypeMap:new Map,filteredRequest:"",operation:e,operationName:"",originalRequestHash:s.hashRequest(t),parsedRequest:"",queryFiltered:!1,request:t,requestComplexity:null,requestDepth:null,requestID:i.v4(),...r}}async _request(e,r,s){try{return await new Promise((a=>{this._worker.postMessage({context:t._getMessageContext(s),method:l,options:r,request:e,type:p}),this._pending.set(s.requestID,{resolve:a})}))}catch(e){return{errors:[n.isError(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:s.requestID}}}_subscribe(e,r,a){try{this._worker.postMessage({context:t._getMessageContext(a),method:d,options:r,request:e,type:p});const o=new s.EventAsyncIterator(this._eventEmitter,a.requestID);return Promise.resolve(o.getIterator())}catch(e){const t=n.isError(e)?e:new Error("@graphql-box/worker-client subscribe had an unexpected error.");return Promise.resolve({errors:[t],requestID:a.requestID})}}},t(E.prototype,"_request",[q],Object.getOwnPropertyDescriptor(E.prototype,"_request"),E.prototype),t(E.prototype,"_subscribe",[_],Object.getOwnPropertyDescriptor(E.prototype,"_subscribe"),E.prototype),E);const y=self,b=(e,t)=>{const{context:r,method:a,options:o,request:n}=e;a===l?(async(e,t,r,a,o)=>{const n=await o.request(e,r,a);if(!c.isAsyncIterable(n)){const{_cacheMetadata:e,...r}=n,o={...r};return e&&(o._cacheMetadata=s.dehydrateCacheMetadata(e)),void y.postMessage({context:a,method:t,result:s.serializeErrors(o),type:p})}c.forAwaitEach(n,(({_cacheMetadata:e,...r})=>{const o={...r};e&&(o._cacheMetadata=s.dehydrateCacheMetadata(e)),y.postMessage({context:a,method:t,result:s.serializeErrors(o),type:p})}))})(n,a,o,r,t):(async(e,t,r,a,o)=>{const n=await o.subscribe(e,r,a);c.isAsyncIterable(n)?c.forAwaitEach(n,(({_cacheMetadata:e,...r})=>{const o={...r};e&&(o._cacheMetadata=s.dehydrateCacheMetadata(e)),y.postMessage({context:a,method:t,result:s.serializeErrors(o),type:p})})):y.postMessage({context:a,method:t,result:s.serializeErrors(n),type:p})})(n,a,o,r,t)};exports.CACHEMAP="cachemap",exports.GRAPHQL_BOX=p,exports.MESSAGE=h,exports.REQUEST=l,exports.SUBSCRIBE=d,exports.WorkerClient=m,exports.handleMessage=b,exports.registerWorker=({client:e})=>{y.addEventListener(h,(({data:t})=>{t.type===p?b(t,e):u.handleMessage(t,e.cache)}))};
410
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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"],"mappings":";;;;;;;;;;;;;;;AAAO,MAAMA,QAAQ,GAAG,WAAmB;AACpC,MAAMC,WAAW,GAAG,aAAqB;AACzC,MAAMC,OAAO,GAAG,UAAkB;AAClC,MAAMC,OAAO,GAAG,UAAkB;AAClC,MAAMC,SAAS,GAAG;;ACJlB,MAAMC,kBAAkB,GAAIC,OAAe,IAAK;AACrD,EAAA,MAAMC,MAAM,GAAG,kDAAkD,CAACC,IAAI,CAACF,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kB,MAAAA,IAAI,EAAEhD,WAAAA;AAAY,KAAC,CAAC,CAAA;AAClG,GAAC,CAAC,CAAA;AACJ,CAAC,CAAA;MAEY0H,aAAa,GAAGA,CAAC5E,IAA2B,EAAEqE,MAAc,KAAW;EAClF,MAAM;IAAEzF,OAAO;IAAEd,MAAM;IAAEgB,OAAO;AAAEvB,IAAAA,OAAAA;AAAQ,GAAC,GAAGyC,IAAI,CAAA;EAElD,IAAIlC,MAAM,KAAKV,OAAO,EAAE;IACtB,KAAKgH,aAAa,CAAC7G,OAAO,EAAEO,MAAM,EAAEgB,OAAO,EAAEF,OAAO,EAAEyF,MAAM,CAAC,CAAA;AAC/D,GAAC,MAAM;IACL,KAAKK,kBAAkB,CAACnH,OAAO,EAAEO,MAAM,EAAEgB,OAAO,EAAEF,OAAO,EAAEyF,MAAM,CAAC,CAAA;AACpE,GAAA;AACF,EAAC;AAEM,MAAMQ,cAAc,GAAGA,CAAC;AAAER,EAAAA,MAAAA;AAA8B,CAAC,KAAW;EACzE,MAAMS,SAAS,GAAGA,CAAC;AAAE9E,IAAAA,IAAAA;AAA0E,GAAC,KAAW;AACzG,IAAA,IAAIgE,iCAAiC,CAAChE,IAAI,CAAC,EAAE;AAC3C4E,MAAAA,aAAa,CAAC5E,IAAI,EAAEqE,MAAM,CAAC,CAAA;AAC7B,KAAC,MAAM;AACL,MAAA,KAAKU,wBAAqB,CAAC/E,IAAI,EAAEqE,MAAM,CAAC5C,KAAK,CAAC,CAAA;AAChD,KAAA;GACD,CAAA;AAEDyC,EAAAA,WAAW,CAACxB,gBAAgB,CAACvF,OAAO,EAAE2H,SAAS,CAAC,CAAA;AAClD;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../worker-client/src//constants.ts","../worker-client/src//helpers/operationNameRegex.ts","../worker-client/src//main.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.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 { 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 {\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 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":["GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","WorkerClient","_dec","_target","_propertyName","descriptor","method","value","async","args","Promise","resolve","debugManager","otherContext","apply","this","derivedOperationName","startTime","now","log","REQUEST_EXECUTED","context","operationName","options","stats","result","endTime","duration","isAsyncIterable","REQUEST_RESOLVED","_dec2","SUBSCRIPTION_EXECUTED","_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","isError","Error","confirmedError","_applyDecoratedDescriptor","prototype","Object","getOwnPropertyDescriptor","globalScope","self","handleMessage","client","requestResult","dehydrateCacheMetadata","serializeErrors","forAwaitEach","handleRequest","subscribeResult","handleSubscription","registerWorker","onMessage","handleCachemapMessage"],"mappings":"8aAAO,MACMA,EAAc,aACdC,EAAU,UACVC,EAAU,UACVC,EAAY,YCJZC,EAAsBC,IACjC,MAAMC,EAAS,mDAAmDC,KAAKF,GACvE,OAAOC,EAASA,EAAO,GAAK,EAAE,YCgChC,IAAaE,GAAYC,EChBhB,CAACC,EAAuBC,EAAuBC,KACpD,MAAMC,EAASD,EAAWE,MAErBD,IAILD,EAAWE,MAAQC,kB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