@makerx/graphql-core 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/subscriptions/subscription-iterator.d.cts +3 -1
- package/subscriptions/subscription-iterator.d.mts +3 -1
- package/subscriptions/subscription-iterator.d.ts +3 -1
- package/subscriptions/subscription-iterator.js +7 -1
- package/subscriptions/subscription-iterator.js.map +1 -1
- package/subscriptions/subscription-iterator.mjs +7 -1
- package/subscriptions/subscription-iterator.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* @param iterator The async iterator to wrap.
|
|
12
12
|
* @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.
|
|
13
13
|
* @param eventIsFinal An optional function to determine if an event is final (and iteration should end).
|
|
14
|
-
*
|
|
14
|
+
* The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which
|
|
15
|
+
* the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event
|
|
16
|
+
* is checked.
|
|
15
17
|
* @returns An async iterator for the event data.
|
|
16
18
|
*/
|
|
17
19
|
export declare function wrapSubscriptionIterator<TEventData>({ iterator: wrapped, initialPayload, eventIsFinal, }: {
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* @param iterator The async iterator to wrap.
|
|
12
12
|
* @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.
|
|
13
13
|
* @param eventIsFinal An optional function to determine if an event is final (and iteration should end).
|
|
14
|
-
*
|
|
14
|
+
* The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which
|
|
15
|
+
* the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event
|
|
16
|
+
* is checked.
|
|
15
17
|
* @returns An async iterator for the event data.
|
|
16
18
|
*/
|
|
17
19
|
export declare function wrapSubscriptionIterator<TEventData>({ iterator: wrapped, initialPayload, eventIsFinal, }: {
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* @param iterator The async iterator to wrap.
|
|
12
12
|
* @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.
|
|
13
13
|
* @param eventIsFinal An optional function to determine if an event is final (and iteration should end).
|
|
14
|
-
*
|
|
14
|
+
* The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which
|
|
15
|
+
* the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event
|
|
16
|
+
* is checked.
|
|
15
17
|
* @returns An async iterator for the event data.
|
|
16
18
|
*/
|
|
17
19
|
export declare function wrapSubscriptionIterator<TEventData>({ iterator: wrapped, initialPayload, eventIsFinal, }: {
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* @param iterator The async iterator to wrap.
|
|
14
14
|
* @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.
|
|
15
15
|
* @param eventIsFinal An optional function to determine if an event is final (and iteration should end).
|
|
16
|
-
*
|
|
16
|
+
* The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which
|
|
17
|
+
* the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event
|
|
18
|
+
* is checked.
|
|
17
19
|
* @returns An async iterator for the event data.
|
|
18
20
|
*/
|
|
19
21
|
function wrapSubscriptionIterator({ iterator: wrapped, initialPayload, eventIsFinal, }) {
|
|
@@ -25,6 +27,10 @@ function wrapSubscriptionIterator({ iterator: wrapped, initialPayload, eventIsFi
|
|
|
25
27
|
return { done: true, value: undefined };
|
|
26
28
|
if (initialQueue.length > 0) {
|
|
27
29
|
const value = initialQueue.shift();
|
|
30
|
+
if (initialQueue.length === 0 && eventIsFinal && eventIsFinal(value)) {
|
|
31
|
+
done = true;
|
|
32
|
+
await wrapped.return?.();
|
|
33
|
+
}
|
|
28
34
|
return { done: false, value };
|
|
29
35
|
}
|
|
30
36
|
const next = await wrapped.next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-iterator.js","sources":["../../src/subscriptions/subscription-iterator.ts"],"sourcesContent":["/**\n * Wraps an async iterator with options for:\n * - returning an initial payload (e.g. current state)\n * - eagerly ending iteration when a final event is received\n *\n * Providing an initial payload helps avoid race conditions when clients subscribe to events but miss recent state changes,\n * by providing an initial payload to be immediately returned, before subsequent events stream in.\n *\n * Eagerly ending iteration when a final event ensures subscriptions do not continue unnecessarily.\n *\n * @param iterator The async iterator to wrap.\n * @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.\n * @param eventIsFinal An optional function to determine if an event is final (and iteration should end).\n *
|
|
1
|
+
{"version":3,"file":"subscription-iterator.js","sources":["../../src/subscriptions/subscription-iterator.ts"],"sourcesContent":["/**\n * Wraps an async iterator with options for:\n * - returning an initial payload (e.g. current state)\n * - eagerly ending iteration when a final event is received\n *\n * Providing an initial payload helps avoid race conditions when clients subscribe to events but miss recent state changes,\n * by providing an initial payload to be immediately returned, before subsequent events stream in.\n *\n * Eagerly ending iteration when a final event ensures subscriptions do not continue unnecessarily.\n *\n * @param iterator The async iterator to wrap.\n * @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.\n * @param eventIsFinal An optional function to determine if an event is final (and iteration should end).\n * The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which\n * the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event\n * is checked.\n * @returns An async iterator for the event data.\n */\nexport function wrapSubscriptionIterator<TEventData>({\n iterator: wrapped,\n initialPayload,\n eventIsFinal,\n}: {\n iterator: AsyncIterableIterator<TEventData>\n initialPayload?: TEventData | TEventData[]\n eventIsFinal?: (event: TEventData) => boolean\n}): AsyncIterator<TEventData> & AsyncIterable<TEventData> {\n let done = false\n const initialQueue: TEventData[] =\n initialPayload === undefined ? [] : Array.isArray(initialPayload) ? [...initialPayload] : [initialPayload]\n\n const iterator: AsyncIterator<TEventData> = {\n next: async () => {\n if (done) return { done: true, value: undefined }\n\n if (initialQueue.length > 0) {\n const value = initialQueue.shift() as TEventData\n if (initialQueue.length === 0 && eventIsFinal && eventIsFinal(value)) {\n done = true\n await wrapped.return?.()\n }\n return { done: false, value }\n }\n\n const next = await wrapped.next()\n if (!next.done && eventIsFinal && eventIsFinal(next.value)) {\n done = true\n await wrapped.return?.()\n }\n return next\n },\n return: async (value) => {\n done = true\n initialQueue.length = 0\n if (wrapped.return) return wrapped.return(value)\n return { done: true, value: value as TEventData }\n },\n throw: async (err) => {\n done = true\n initialQueue.length = 0\n if (wrapped.throw) return wrapped.throw(err)\n throw err\n },\n }\n\n return { ...iterator, [Symbol.asyncIterator]: () => iterator }\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,wBAAwB,CAAa,EACnD,QAAQ,EAAE,OAAO,EACjB,cAAc,EACd,YAAY,GAKb,EAAA;IACC,IAAI,IAAI,GAAG,KAAK;AAChB,IAAA,MAAM,YAAY,GAChB,cAAc,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;AAE5G,IAAA,MAAM,QAAQ,GAA8B;QAC1C,IAAI,EAAE,YAAW;AACf,YAAA,IAAI,IAAI;gBAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;AAEjD,YAAA,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,gBAAA,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAgB;AAChD,gBAAA,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;oBACpE,IAAI,GAAG,IAAI;AACX,oBAAA,MAAM,OAAO,CAAC,MAAM,IAAI;gBAC1B;AACA,gBAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;YAC/B;AAEA,YAAA,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,YAAY,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAC1D,IAAI,GAAG,IAAI;AACX,gBAAA,MAAM,OAAO,CAAC,MAAM,IAAI;YAC1B;AACA,YAAA,OAAO,IAAI;QACb,CAAC;AACD,QAAA,MAAM,EAAE,OAAO,KAAK,KAAI;YACtB,IAAI,GAAG,IAAI;AACX,YAAA,YAAY,CAAC,MAAM,GAAG,CAAC;YACvB,IAAI,OAAO,CAAC,MAAM;AAAE,gBAAA,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAmB,EAAE;QACnD,CAAC;AACD,QAAA,KAAK,EAAE,OAAO,GAAG,KAAI;YACnB,IAAI,GAAG,IAAI;AACX,YAAA,YAAY,CAAC,MAAM,GAAG,CAAC;YACvB,IAAI,OAAO,CAAC,KAAK;AAAE,gBAAA,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,YAAA,MAAM,GAAG;QACX,CAAC;KACF;AAED,IAAA,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC,MAAM,CAAC,aAAa,GAAG,MAAM,QAAQ,EAAE;AAChE;;;;"}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* @param iterator The async iterator to wrap.
|
|
12
12
|
* @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.
|
|
13
13
|
* @param eventIsFinal An optional function to determine if an event is final (and iteration should end).
|
|
14
|
-
*
|
|
14
|
+
* The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which
|
|
15
|
+
* the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event
|
|
16
|
+
* is checked.
|
|
15
17
|
* @returns An async iterator for the event data.
|
|
16
18
|
*/
|
|
17
19
|
function wrapSubscriptionIterator({ iterator: wrapped, initialPayload, eventIsFinal, }) {
|
|
@@ -23,6 +25,10 @@ function wrapSubscriptionIterator({ iterator: wrapped, initialPayload, eventIsFi
|
|
|
23
25
|
return { done: true, value: undefined };
|
|
24
26
|
if (initialQueue.length > 0) {
|
|
25
27
|
const value = initialQueue.shift();
|
|
28
|
+
if (initialQueue.length === 0 && eventIsFinal && eventIsFinal(value)) {
|
|
29
|
+
done = true;
|
|
30
|
+
await wrapped.return?.();
|
|
31
|
+
}
|
|
26
32
|
return { done: false, value };
|
|
27
33
|
}
|
|
28
34
|
const next = await wrapped.next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-iterator.mjs","sources":["../../src/subscriptions/subscription-iterator.ts"],"sourcesContent":["/**\n * Wraps an async iterator with options for:\n * - returning an initial payload (e.g. current state)\n * - eagerly ending iteration when a final event is received\n *\n * Providing an initial payload helps avoid race conditions when clients subscribe to events but miss recent state changes,\n * by providing an initial payload to be immediately returned, before subsequent events stream in.\n *\n * Eagerly ending iteration when a final event ensures subscriptions do not continue unnecessarily.\n *\n * @param iterator The async iterator to wrap.\n * @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.\n * @param eventIsFinal An optional function to determine if an event is final (and iteration should end).\n *
|
|
1
|
+
{"version":3,"file":"subscription-iterator.mjs","sources":["../../src/subscriptions/subscription-iterator.ts"],"sourcesContent":["/**\n * Wraps an async iterator with options for:\n * - returning an initial payload (e.g. current state)\n * - eagerly ending iteration when a final event is received\n *\n * Providing an initial payload helps avoid race conditions when clients subscribe to events but miss recent state changes,\n * by providing an initial payload to be immediately returned, before subsequent events stream in.\n *\n * Eagerly ending iteration when a final event ensures subscriptions do not continue unnecessarily.\n *\n * @param iterator The async iterator to wrap.\n * @param initialPayload An optional initial payload to return on the first iteration. May be a single event or an array.\n * @param eventIsFinal An optional function to determine if an event is final (and iteration should end).\n * The full `initialPayload` is always yielded; `eventIsFinal` is only checked against its final entry, after which\n * the wrapped iterator is closed without ever being pulled from. For events from the wrapped iterator, every event\n * is checked.\n * @returns An async iterator for the event data.\n */\nexport function wrapSubscriptionIterator<TEventData>({\n iterator: wrapped,\n initialPayload,\n eventIsFinal,\n}: {\n iterator: AsyncIterableIterator<TEventData>\n initialPayload?: TEventData | TEventData[]\n eventIsFinal?: (event: TEventData) => boolean\n}): AsyncIterator<TEventData> & AsyncIterable<TEventData> {\n let done = false\n const initialQueue: TEventData[] =\n initialPayload === undefined ? [] : Array.isArray(initialPayload) ? [...initialPayload] : [initialPayload]\n\n const iterator: AsyncIterator<TEventData> = {\n next: async () => {\n if (done) return { done: true, value: undefined }\n\n if (initialQueue.length > 0) {\n const value = initialQueue.shift() as TEventData\n if (initialQueue.length === 0 && eventIsFinal && eventIsFinal(value)) {\n done = true\n await wrapped.return?.()\n }\n return { done: false, value }\n }\n\n const next = await wrapped.next()\n if (!next.done && eventIsFinal && eventIsFinal(next.value)) {\n done = true\n await wrapped.return?.()\n }\n return next\n },\n return: async (value) => {\n done = true\n initialQueue.length = 0\n if (wrapped.return) return wrapped.return(value)\n return { done: true, value: value as TEventData }\n },\n throw: async (err) => {\n done = true\n initialQueue.length = 0\n if (wrapped.throw) return wrapped.throw(err)\n throw err\n },\n }\n\n return { ...iterator, [Symbol.asyncIterator]: () => iterator }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,wBAAwB,CAAa,EACnD,QAAQ,EAAE,OAAO,EACjB,cAAc,EACd,YAAY,GAKb,EAAA;IACC,IAAI,IAAI,GAAG,KAAK;AAChB,IAAA,MAAM,YAAY,GAChB,cAAc,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;AAE5G,IAAA,MAAM,QAAQ,GAA8B;QAC1C,IAAI,EAAE,YAAW;AACf,YAAA,IAAI,IAAI;gBAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,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