@memberjunction/server 2.26.0 → 2.27.0
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/dist/generated/generated.d.ts +1821 -1815
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +1373 -1330
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/ResolverBase.d.ts +2 -1
- package/dist/generic/ResolverBase.d.ts.map +1 -1
- package/dist/generic/ResolverBase.js +16 -4
- package/dist/generic/ResolverBase.js.map +1 -1
- package/package.json +22 -22
- package/src/generated/generated.ts +3041 -3015
- package/src/generic/ResolverBase.ts +19 -3
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
CompositeKey,
|
|
5
5
|
EntityFieldTSType,
|
|
6
6
|
EntityPermissionType,
|
|
7
|
+
LogDebug,
|
|
7
8
|
LogError,
|
|
8
9
|
LogStatus,
|
|
9
10
|
Metadata,
|
|
@@ -30,7 +31,18 @@ import { Subscription } from 'rxjs';
|
|
|
30
31
|
export class ResolverBase {
|
|
31
32
|
private static _emit = process.env.CLOUDEVENTS_HTTP_TRANSPORT ? emitterFor(httpTransport(process.env.CLOUDEVENTS_HTTP_TRANSPORT)) : null;
|
|
32
33
|
private static _cloudeventsHeaders = process.env.CLOUDEVENTS_HTTP_HEADERS ? JSON.parse(process.env.CLOUDEVENTS_HTTP_HEADERS) : {};
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
private static _eventSubscriptionKey: string = '___MJServer___ResolverBase___EventSubscriptions';
|
|
36
|
+
private get EventSubscriptions(): Map<string, Subscription> {
|
|
37
|
+
// here we use the global object store instead of a static member becuase in some cases based on import code paths/bundling/etc, the static member
|
|
38
|
+
// could actually be duplicated and we'd end up with multiple instances of the same map, which would be bad.
|
|
39
|
+
const g = MJGlobal.Instance.GetGlobalObjectStore();
|
|
40
|
+
if (!g[ResolverBase._eventSubscriptionKey]) {
|
|
41
|
+
LogDebug(`>>>>> MJServer.ResolverBase.EventSubscriptions: Creating new Map - this should only happen once per server instance <<<<<<`);
|
|
42
|
+
g[ResolverBase._eventSubscriptionKey] = new Map<string, Subscription>();
|
|
43
|
+
}
|
|
44
|
+
return g[ResolverBase._eventSubscriptionKey];
|
|
45
|
+
}
|
|
34
46
|
|
|
35
47
|
protected MapFieldNamesToCodeNames(entityName: string, dataObject: any) {
|
|
36
48
|
// for the given entity name provided, check to see if there are any fields
|
|
@@ -576,15 +588,19 @@ export class ResolverBase {
|
|
|
576
588
|
// cause issues with multiple messages for the same event.
|
|
577
589
|
const uniqueKey = entityObject.EntityInfo.Name;
|
|
578
590
|
|
|
579
|
-
if (!
|
|
591
|
+
if (!this.EventSubscriptions.has(uniqueKey)) {
|
|
580
592
|
// listen for events from the entityObject in case it is a long running task and we can push messages back to the client via pubSub
|
|
593
|
+
LogDebug(`ResolverBase.ListenForEntityMessages: About to call MJGlobal.Instance.GetEventListener() to get the event listener subscription for ${uniqueKey}`);
|
|
581
594
|
const theSub = MJGlobal.Instance.GetEventListener(false).subscribe(async (event: MJEvent) => {
|
|
582
595
|
if (event) {
|
|
596
|
+
LogDebug(`ResolverBase.ListenForEntityMessages: Received Event from within MJGlobal.Instance.GetEventListener() callback. Will call EmitCloudEvent() next\nEvent data:\n${JSON.stringify(event)}`);
|
|
583
597
|
await this.EmitCloudEvent(event);
|
|
598
|
+
LogDebug(`ResolverBase.ListenForEntityMessages: EmitCloudEvent() completed successfully`);
|
|
584
599
|
|
|
585
600
|
if (event.args && event.args instanceof BaseEntityEvent) {
|
|
586
601
|
const baseEntityEvent = event.args as BaseEntityEvent;
|
|
587
602
|
// message from our entity object, relay it to the client
|
|
603
|
+
LogDebug('ResolverBase.ListenForEntityMessages: About to publish PUSH_STATUS_UPDATES_TOPIC');
|
|
588
604
|
pubSub.publish(PUSH_STATUS_UPDATES_TOPIC, {
|
|
589
605
|
message: JSON.stringify({
|
|
590
606
|
status: 'OK',
|
|
@@ -598,7 +614,7 @@ export class ResolverBase {
|
|
|
598
614
|
}
|
|
599
615
|
}
|
|
600
616
|
});
|
|
601
|
-
|
|
617
|
+
this.EventSubscriptions.set(uniqueKey, theSub);
|
|
602
618
|
}
|
|
603
619
|
}
|
|
604
620
|
|