@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,401 +1,2 @@
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 };
1
+ import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/applyDecoratedDescriptor";import"core-js/modules/es.array.push.js";import{REQUEST_EXECUTED as r,REQUEST_RESOLVED as s,SUBSCRIPTION_EXECUTED as o,SUBSCRIPTION_RESOLVED as a}from"@graphql-box/core";import{isPlainObject as n,deserializeErrors as i,rehydrateCacheMetadata as c,EventAsyncIterator as u,ArgsError as p,GroupedError as h,hashRequest as l,dehydrateCacheMetadata as m,serializeErrors as g}from"@graphql-box/helpers";import{EventEmitter as d}from"eventemitter3";import{OperationTypeNode as _}from"graphql";import{isError as q}from"lodash-es";import{v4 as b}from"uuid";import{isAsyncIterable as w,forAwaitEach as x}from"iterall";import"core-js/modules/web.self.js";import{handleMessage as y}from"@cachemap/core-worker";const M="cachemap",f="graphqlBox",v="message",D="request",I="subscribe",k=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};var S,E,R;let T=(S=(e,t,o)=>{const a=o.value;a&&(o.value=async function(...e){return new Promise((t=>{(async()=>{const{debugManager:o,...n}=e[2];if(!o)return void t(await a.apply(this,e));const i=k(e[0]),c=o.now();o.log(r,{context:{...n,operationName:i},options:e[1],request:e[0],stats:{startTime:c}});const u=await a.apply(this,e),p=o.now(),h=p-c;t(u),w(u)||o.log(s,{context:{...n,operationName:i},options:e[1],request:e[0],result:u,stats:{duration:h,endTime:p,startTime:c}})})()}))})},E=(e,t,r)=>{const s=r.value;s&&(r.value=async function(...e){return new Promise((t=>{(async()=>{const{debugManager:r,...a}=e[2];if(!r)return void t(await s.apply(this,e));const n=k(e[0]),i=r.now();r.log(o,{context:{...a,operationName:n},options:e[1],request:e[0],stats:{startTime:i}});const c=await s.apply(this,e);t(c)})()}))})},R=class t{static _getMessageContext({hasDeferOrStream:e=!1,requestID:t}){return{hasDeferOrStream:e,requestID:t}}constructor(t){e(this,"_onMessage",(({data:e})=>{if(!n(e))return;const{context:t,method:r,result:o,type:p}=e;if(p!==f)return;const{_cacheMetadata:h,...l}=o,m={...i(l),requestID:t.requestID};if(h&&(m._cacheMetadata=c(h)),r===I)this._debugManager?.log(a,{context:t,result:m,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(t.requestID,m);else if(t.hasDeferOrStream){const e=this._pending.get(t.requestID);if(e){const r=new u(this._eventEmitter,t.requestID);e.resolve(r.getIterator())}this._debugManager?.log(s,{context:t,result:m,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(t.requestID,m)}else{const e=this._pending.get(t.requestID);if(!e)return;this._debugManager?.log(s,{context:t,result:m,stats:{endTime:this._debugManager.now()}}),e.resolve(m)}})),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 r=[];if(n(t)||r.push(new p("@graphql-box/worker-client expected options to ba a plain object.")),"cache"in t||r.push(new p("@graphql-box/worker-client expected options.cache.")),"worker"in t||r.push(new p("@graphql-box/worker-client expected options.worker.")),r.length>0)throw new h("@graphql-box/worker-client argument validation errors.",r);this._cache=t.cache,this._debugManager=t.debugManager??null,this._eventEmitter=new d,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(_.MUTATION,e,r))}async query(e,t={},r={}){return this._request(e,t,this._getRequestContext(_.QUERY,e,r))}async request(e,t={},r={}){return this._request(e,t,this._getRequestContext(_.QUERY,e,r))}async subscribe(e,t={}){return this._subscribe(e,t,this._getRequestContext(_.SUBSCRIPTION,e))}_addEventListener(){this._worker.addEventListener(v,this._onMessage)}_getRequestContext(e,t,r={}){return{debugManager:this._debugManager,experimentalDeferStreamSupport:this._experimentalDeferStreamSupport,fieldTypeMap:new Map,filteredRequest:"",operation:e,operationName:"",originalRequestHash:l(t),parsedRequest:"",queryFiltered:!1,request:t,requestComplexity:null,requestDepth:null,requestID:b(),...r}}async _request(e,r,s){try{return await new Promise((o=>{this._worker.postMessage({context:t._getMessageContext(s),method:D,options:r,request:e,type:f}),this._pending.set(s.requestID,{resolve:o})}))}catch(e){return{errors:[q(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:s.requestID}}}_subscribe(e,r,s){try{this._worker.postMessage({context:t._getMessageContext(s),method:I,options:r,request:e,type:f});const o=new u(this._eventEmitter,s.requestID);return Promise.resolve(o.getIterator())}catch(e){const t=q(e)?e:new Error("@graphql-box/worker-client subscribe had an unexpected error.");return Promise.resolve({errors:[t],requestID:s.requestID})}}},t(R.prototype,"_request",[S],Object.getOwnPropertyDescriptor(R.prototype,"_request"),R.prototype),t(R.prototype,"_subscribe",[E],Object.getOwnPropertyDescriptor(R.prototype,"_subscribe"),R.prototype),R);const C=self,O=(e,t)=>{const{context:r,method:s,options:o,request:a}=e;s===D?(async(e,t,r,s,o)=>{const a=await o.request(e,r,s);if(!w(a)){const{_cacheMetadata:e,...r}=a,o={...r};return e&&(o._cacheMetadata=m(e)),void C.postMessage({context:s,method:t,result:g(o),type:f})}x(a,(({_cacheMetadata:e,...r})=>{const o={...r};e&&(o._cacheMetadata=m(e)),C.postMessage({context:s,method:t,result:g(o),type:f})}))})(a,s,o,r,t):(async(e,t,r,s,o)=>{const a=await o.subscribe(e,r,s);w(a)?x(a,(({_cacheMetadata:e,...r})=>{const o={...r};e&&(o._cacheMetadata=m(e)),C.postMessage({context:s,method:t,result:g(o),type:f})})):C.postMessage({context:s,method:t,result:g(a),type:f})})(a,s,o,r,t)},P=({client:e})=>{C.addEventListener(v,(({data:t})=>{t.type===f?O(t,e):y(t,e.cache)}))};export{M as CACHEMAP,f as GRAPHQL_BOX,v as MESSAGE,D as REQUEST,I as SUBSCRIBE,T as WorkerClient,O as handleMessage,P as registerWorker};
401
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +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"],"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,OAAO,CAAC,CAAA;AAC/E,EAAA,OAAOC,MAAM,GAAGA,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;AAChC,CAAC;;ACcM,MAAME,UAAU,GAAGA,MAAM;AAC9B,EAAA,OAAO,CAACC,OAAqB,EAAEC,aAAqB,EAAEC,UAA+C,KAAW;AAC9G,IAAA,MAAMC,MAAM,GAAGD,UAAU,CAACE,KAAK,CAAA;IAE/B,IAAI,CAACD,MAAM,EAAE;AACX,MAAA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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,eAAqB,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.mjs","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":["CACHEMAP","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":"8yBAAO,MAAMA,EAAW,WACXC,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,kBAAkCC,GACnD,OAAO,IAAIC,SAAQC,IACZ,WACH,MAAMC,aAAEA,KAAiBC,GAAiBJ,EAAK,GAE/C,IAAKG,EAEH,YADAD,QAAcL,EAAOQ,MAAMC,KAAMN,IAInC,MAAMO,EAAuBnB,EAAmBY,EAAK,IAC/CQ,EAAYL,EAAaM,MAE/BN,EAAaO,IAAIC,EAAkB,CACjCC,QAAS,IAAKR,EAAcS,cAAeN,GAC3CO,QAASd,EAAK,GACdX,QAASW,EAAK,GACde,MAA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AiBkE,EAAuBlE,SAGjD6D,EAAYV,YAAY,CAAEvE,UAASf,SAAQmB,OAAQmF,EAAgBnF,GAASe,KAAM/C,GAEpF,CAEKoH,EAAaH,GAAe,EAAGjE,oBAAmBC,MACrD,MAAMjB,EAA0D,IAAKiB,GAEjED,IACFhB,EAAOgB,eAAiBkE,EAAuBlE,IAGjD6D,EAAYV,YAAY,CAAEvE,UAASf,SAAQmB,OAAQmF,EAAgBnF,GAASe,KAAM/C,GAAc,GAChG,EAsCKqH,CAAchH,EAASQ,EAAQiB,EAASF,EAASoF,GAnC/BjG,OACzBV,EACAQ,EACAiB,EACAF,EACAoF,KAEA,MAAMM,QAAwBN,EAAO5B,UAAU/E,EAASyB,EAASF,GAE5DO,EAAgBmF,GAWhBF,EAAaE,GAAiB,EAAGtE,oBAAmBC,MACvD,MAAMjB,EAA0D,IAAKiB,GAEjED,IACFhB,EAAOgB,eAAiBkE,EAAuBlE,IAGjD6D,EAAYV,YAAY,CAAEvE,UAASf,SAAQmB,OAAQmF,EAAgBnF,GAASe,KAAM/C,GAAc,IAjBhG6G,EAAYV,YAAY,CACtBvE,UACAf,SACAmB,OAAQmF,EAAgBG,GACxBvE,KAAM/C,GAcR,EASKuH,CAAmBlH,EAASQ,EAAQiB,EAASF,EAASoF,EAC7D,EAGWQ,EAAiBA,EAAGR,aAS/BH,EAAYtB,iBAAiBtF,GARXwH,EAAG5E,WACmBA,ED5FKE,OAAS/C,EC6FlD+G,EAAclE,EAAMmE,GAEfU,EAAsB7E,EAAMmE,EAAO1C,MAC1C,GAG8C"}
@@ -0,0 +1,83 @@
1
+ -----------------------------
2
+ Rollup File Analysis
3
+ -----------------------------
4
+ bundle size: 11.769 KB
5
+ original size: 15.177 KB
6
+ code reduction: 22.46 %
7
+ module count: 8
8
+
9
+ ███████████████████████████░░░░░░░░░░░░░░░░░░░░░░░
10
+ file: /src/main.ts
11
+ bundle space: 54.01 %
12
+ rendered size: 6.357 KB
13
+ original size: 7.224 KB
14
+ code reduction: 12 %
15
+ dependents: 1
16
+ - /src/index.ts
17
+
18
+ ██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
19
+ file: /src/registerWorker.ts
20
+ bundle space: 20.32 %
21
+ rendered size: 2.392 KB
22
+ original size: 3.522 KB
23
+ code reduction: 32.08 %
24
+ dependents: 1
25
+ - /src/index.ts
26
+
27
+ ██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
28
+ file: /src/debug/logRequest.ts
29
+ bundle space: 13.46 %
30
+ rendered size: 1.584 KB
31
+ original size: 2.005 KB
32
+ code reduction: 21 %
33
+ dependents: 1
34
+ - /src/main.ts
35
+
36
+ ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
37
+ file: /src/debug/logSubscription.ts
38
+ bundle space: 8.9 %
39
+ rendered size: 1.048 KB
40
+ original size: 1.515 KB
41
+ code reduction: 30.83 %
42
+ dependents: 1
43
+ - /src/main.ts
44
+
45
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
46
+ file: /src/helpers/operationNameRegex.ts
47
+ bundle space: 1.35 %
48
+ rendered size: 159 Bytes
49
+ original size: 177 Bytes
50
+ code reduction: 10.17 %
51
+ dependents: 2
52
+ - /src/debug/logRequest.ts
53
+ - /src/debug/logSubscription.ts
54
+
55
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
56
+ file: /src/constants.ts
57
+ bundle space: 1.25 %
58
+ rendered size: 147 Bytes
59
+ original size: 228 Bytes
60
+ code reduction: 35.53 %
61
+ dependents: 4
62
+ - /src/main.ts
63
+ - /src/helpers/isGraphqlBoxMessageRequestPayload.ts
64
+ - /src/registerWorker.ts
65
+ - /src/index.ts
66
+
67
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
68
+ file: /src/helpers/isGraphqlBoxMessageRequestPayload.ts
69
+ bundle space: 0.7 %
70
+ rendered size: 82 Bytes
71
+ original size: 382 Bytes
72
+ code reduction: 78.53 %
73
+ dependents: 1
74
+ - /src/registerWorker.ts
75
+
76
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
77
+ file: /src/index.ts
78
+ bundle space: 0 %
79
+ rendered size: 0 Byte
80
+ original size: 124 Bytes
81
+ code reduction: 100 %
82
+ dependents: 0
83
+