@coasys/ad4m 0.10.1-release-candidate-3 → 0.10.1-release-candidate-3-test-2
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/lib/index.cjs +44 -6
- package/lib/index.js +44 -6
- package/lib/src/model/Ad4mModel.d.ts +2 -0
- package/lib/src/model/Ad4mModel.js +18 -2
- package/lib/src/perspectives/PerspectiveClient.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.js +16 -3
- package/lib/src/perspectives/PerspectiveProxy.js +10 -1
- package/lib/src/subject/Ad4mModel.d.ts +550 -0
- package/lib/src/subject/Ad4mModel.js +956 -0
- package/lib/src/subject/SDNADecorators.d.ts +188 -0
- package/lib/src/subject/SDNADecorators.js +360 -0
- package/lib/src/subject/Subject.d.ts +25 -0
- package/lib/src/subject/Subject.js +188 -0
- package/lib/src/subject/SubjectEntity.d.ts +185 -0
- package/lib/src/subject/SubjectEntity.js +591 -0
- package/lib/src/subject/decorators.d.ts +496 -0
- package/lib/src/subject/decorators.js +683 -0
- package/lib/src/subject/util.d.ts +12 -0
- package/lib/src/subject/util.js +73 -0
- package/package.json +3 -3
- package/src/model/Ad4mModel.ts +22 -3
- package/src/perspectives/PerspectiveClient.ts +17 -4
- package/src/perspectives/PerspectiveProxy.ts +13 -2
- package/yarn-error.log +90 -0
package/lib/index.cjs
CHANGED
|
@@ -4671,6 +4671,7 @@ class QuerySubscriptionProxy {
|
|
|
4671
4671
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_query, query, "f");
|
|
4672
4672
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_client, client, "f");
|
|
4673
4673
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
|
|
4674
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, null, "f");
|
|
4674
4675
|
}
|
|
4675
4676
|
async subscribe() {
|
|
4676
4677
|
// initialize the query subscription
|
|
@@ -4680,7 +4681,8 @@ class QuerySubscriptionProxy {
|
|
|
4680
4681
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
|
|
4681
4682
|
// Add timeout to prevent hanging promises
|
|
4682
4683
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
|
|
4683
|
-
reject(new Error('Subscription initialization timed out after 30 seconds'));
|
|
4684
|
+
reject(new Error('Subscription initialization timed out after 30 seconds. Resubscribing...'));
|
|
4685
|
+
this.subscribe();
|
|
4684
4686
|
}, 30000), "f"); // 30 seconds timeout
|
|
4685
4687
|
// Subscribe to query updates
|
|
4686
4688
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"), (result) => {
|
|
@@ -4689,6 +4691,13 @@ class QuerySubscriptionProxy {
|
|
|
4689
4691
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
4690
4692
|
}
|
|
4691
4693
|
resolve(true);
|
|
4694
|
+
// if the result is one of those repeated initialization results
|
|
4695
|
+
// and we got a result before, we don't notify the callbacks
|
|
4696
|
+
// so they don't get confused (we could have gotten another
|
|
4697
|
+
// more recent result in between)
|
|
4698
|
+
if (result.isInit && __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_latestResult, "f")) {
|
|
4699
|
+
return;
|
|
4700
|
+
}
|
|
4692
4701
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, result, "f");
|
|
4693
4702
|
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, result);
|
|
4694
4703
|
}), "f");
|
|
@@ -5793,13 +5802,18 @@ class PerspectiveClient {
|
|
|
5793
5802
|
}));
|
|
5794
5803
|
const { subscriptionId, result } = perspectiveSubscribeQuery;
|
|
5795
5804
|
let finalResult = result;
|
|
5805
|
+
let isInit = false;
|
|
5806
|
+
if (finalResult.startsWith("#init#")) {
|
|
5807
|
+
finalResult = finalResult.substring(6);
|
|
5808
|
+
isInit = true;
|
|
5809
|
+
}
|
|
5796
5810
|
try {
|
|
5797
|
-
finalResult = JSON.parse(
|
|
5811
|
+
finalResult = JSON.parse(finalResult);
|
|
5798
5812
|
}
|
|
5799
5813
|
catch (e) {
|
|
5800
5814
|
console.error('Error parsing perspectiveSubscribeQuery result:', e);
|
|
5801
5815
|
}
|
|
5802
|
-
return { subscriptionId, result: finalResult };
|
|
5816
|
+
return { subscriptionId, result: finalResult, isInit };
|
|
5803
5817
|
}
|
|
5804
5818
|
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
5805
5819
|
const subscription = __classPrivateFieldGet$9(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
@@ -5815,8 +5829,16 @@ class PerspectiveClient {
|
|
|
5815
5829
|
next: (result) => {
|
|
5816
5830
|
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
5817
5831
|
let finalResult = result.data.perspectiveQuerySubscription;
|
|
5832
|
+
let isInit = false;
|
|
5833
|
+
if (finalResult.startsWith("#init#")) {
|
|
5834
|
+
finalResult = finalResult.substring(6);
|
|
5835
|
+
isInit = true;
|
|
5836
|
+
}
|
|
5818
5837
|
try {
|
|
5819
|
-
finalResult = JSON.parse(
|
|
5838
|
+
finalResult = JSON.parse(finalResult);
|
|
5839
|
+
if (isInit) {
|
|
5840
|
+
finalResult.isInit = true;
|
|
5841
|
+
}
|
|
5820
5842
|
}
|
|
5821
5843
|
catch (e) {
|
|
5822
5844
|
console.error('Error parsing perspectiveQuerySubscription:', e);
|
|
@@ -17681,6 +17703,12 @@ function buildLimitQuery(limit) {
|
|
|
17681
17703
|
*/
|
|
17682
17704
|
class Ad4mModel {
|
|
17683
17705
|
static async getClassName(perspective) {
|
|
17706
|
+
// Check if this is the Ad4mModel class itself or a subclass
|
|
17707
|
+
const isBaseClass = this === Ad4mModel;
|
|
17708
|
+
// For the base Ad4mModel class, we can't use the cache
|
|
17709
|
+
if (isBaseClass) {
|
|
17710
|
+
return await perspective.stringOrTemplateObjectToSubjectClassName(this);
|
|
17711
|
+
}
|
|
17684
17712
|
// Get or create the cache for this class
|
|
17685
17713
|
let classCache = this.classNamesByClass.get(this);
|
|
17686
17714
|
if (!classCache) {
|
|
@@ -18036,8 +18064,18 @@ class Ad4mModel {
|
|
|
18036
18064
|
}
|
|
18037
18065
|
await this.getData();
|
|
18038
18066
|
}
|
|
18067
|
+
cleanCopy() {
|
|
18068
|
+
const cleanCopy = {};
|
|
18069
|
+
const props = Object.entries(this);
|
|
18070
|
+
for (const [key, value] of props) {
|
|
18071
|
+
if (value !== undefined && value !== null && key !== "author" && key !== "timestamp") {
|
|
18072
|
+
cleanCopy[key] = value;
|
|
18073
|
+
}
|
|
18074
|
+
}
|
|
18075
|
+
return cleanCopy;
|
|
18076
|
+
}
|
|
18039
18077
|
async innerUpdate(setProperties = true, batchId) {
|
|
18040
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
18078
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
18041
18079
|
const entries = Object.entries(this);
|
|
18042
18080
|
for (const [key, value] of entries) {
|
|
18043
18081
|
if (value !== undefined && value !== null) {
|
|
@@ -18105,7 +18143,7 @@ class Ad4mModel {
|
|
|
18105
18143
|
* ```
|
|
18106
18144
|
*/
|
|
18107
18145
|
async get() {
|
|
18108
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
18146
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
18109
18147
|
return await this.getData();
|
|
18110
18148
|
}
|
|
18111
18149
|
/**
|
package/lib/index.js
CHANGED
|
@@ -4667,6 +4667,7 @@ class QuerySubscriptionProxy {
|
|
|
4667
4667
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_query, query, "f");
|
|
4668
4668
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_client, client, "f");
|
|
4669
4669
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
|
|
4670
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, null, "f");
|
|
4670
4671
|
}
|
|
4671
4672
|
async subscribe() {
|
|
4672
4673
|
// initialize the query subscription
|
|
@@ -4676,7 +4677,8 @@ class QuerySubscriptionProxy {
|
|
|
4676
4677
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
|
|
4677
4678
|
// Add timeout to prevent hanging promises
|
|
4678
4679
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
|
|
4679
|
-
reject(new Error('Subscription initialization timed out after 30 seconds'));
|
|
4680
|
+
reject(new Error('Subscription initialization timed out after 30 seconds. Resubscribing...'));
|
|
4681
|
+
this.subscribe();
|
|
4680
4682
|
}, 30000), "f"); // 30 seconds timeout
|
|
4681
4683
|
// Subscribe to query updates
|
|
4682
4684
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"), (result) => {
|
|
@@ -4685,6 +4687,13 @@ class QuerySubscriptionProxy {
|
|
|
4685
4687
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
4686
4688
|
}
|
|
4687
4689
|
resolve(true);
|
|
4690
|
+
// if the result is one of those repeated initialization results
|
|
4691
|
+
// and we got a result before, we don't notify the callbacks
|
|
4692
|
+
// so they don't get confused (we could have gotten another
|
|
4693
|
+
// more recent result in between)
|
|
4694
|
+
if (result.isInit && __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_latestResult, "f")) {
|
|
4695
|
+
return;
|
|
4696
|
+
}
|
|
4688
4697
|
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, result, "f");
|
|
4689
4698
|
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, result);
|
|
4690
4699
|
}), "f");
|
|
@@ -5789,13 +5798,18 @@ class PerspectiveClient {
|
|
|
5789
5798
|
}));
|
|
5790
5799
|
const { subscriptionId, result } = perspectiveSubscribeQuery;
|
|
5791
5800
|
let finalResult = result;
|
|
5801
|
+
let isInit = false;
|
|
5802
|
+
if (finalResult.startsWith("#init#")) {
|
|
5803
|
+
finalResult = finalResult.substring(6);
|
|
5804
|
+
isInit = true;
|
|
5805
|
+
}
|
|
5792
5806
|
try {
|
|
5793
|
-
finalResult = JSON.parse(
|
|
5807
|
+
finalResult = JSON.parse(finalResult);
|
|
5794
5808
|
}
|
|
5795
5809
|
catch (e) {
|
|
5796
5810
|
console.error('Error parsing perspectiveSubscribeQuery result:', e);
|
|
5797
5811
|
}
|
|
5798
|
-
return { subscriptionId, result: finalResult };
|
|
5812
|
+
return { subscriptionId, result: finalResult, isInit };
|
|
5799
5813
|
}
|
|
5800
5814
|
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
5801
5815
|
const subscription = __classPrivateFieldGet$9(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
@@ -5811,8 +5825,16 @@ class PerspectiveClient {
|
|
|
5811
5825
|
next: (result) => {
|
|
5812
5826
|
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
5813
5827
|
let finalResult = result.data.perspectiveQuerySubscription;
|
|
5828
|
+
let isInit = false;
|
|
5829
|
+
if (finalResult.startsWith("#init#")) {
|
|
5830
|
+
finalResult = finalResult.substring(6);
|
|
5831
|
+
isInit = true;
|
|
5832
|
+
}
|
|
5814
5833
|
try {
|
|
5815
|
-
finalResult = JSON.parse(
|
|
5834
|
+
finalResult = JSON.parse(finalResult);
|
|
5835
|
+
if (isInit) {
|
|
5836
|
+
finalResult.isInit = true;
|
|
5837
|
+
}
|
|
5816
5838
|
}
|
|
5817
5839
|
catch (e) {
|
|
5818
5840
|
console.error('Error parsing perspectiveQuerySubscription:', e);
|
|
@@ -17677,6 +17699,12 @@ function buildLimitQuery(limit) {
|
|
|
17677
17699
|
*/
|
|
17678
17700
|
class Ad4mModel {
|
|
17679
17701
|
static async getClassName(perspective) {
|
|
17702
|
+
// Check if this is the Ad4mModel class itself or a subclass
|
|
17703
|
+
const isBaseClass = this === Ad4mModel;
|
|
17704
|
+
// For the base Ad4mModel class, we can't use the cache
|
|
17705
|
+
if (isBaseClass) {
|
|
17706
|
+
return await perspective.stringOrTemplateObjectToSubjectClassName(this);
|
|
17707
|
+
}
|
|
17680
17708
|
// Get or create the cache for this class
|
|
17681
17709
|
let classCache = this.classNamesByClass.get(this);
|
|
17682
17710
|
if (!classCache) {
|
|
@@ -18032,8 +18060,18 @@ class Ad4mModel {
|
|
|
18032
18060
|
}
|
|
18033
18061
|
await this.getData();
|
|
18034
18062
|
}
|
|
18063
|
+
cleanCopy() {
|
|
18064
|
+
const cleanCopy = {};
|
|
18065
|
+
const props = Object.entries(this);
|
|
18066
|
+
for (const [key, value] of props) {
|
|
18067
|
+
if (value !== undefined && value !== null && key !== "author" && key !== "timestamp") {
|
|
18068
|
+
cleanCopy[key] = value;
|
|
18069
|
+
}
|
|
18070
|
+
}
|
|
18071
|
+
return cleanCopy;
|
|
18072
|
+
}
|
|
18035
18073
|
async innerUpdate(setProperties = true, batchId) {
|
|
18036
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
18074
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
18037
18075
|
const entries = Object.entries(this);
|
|
18038
18076
|
for (const [key, value] of entries) {
|
|
18039
18077
|
if (value !== undefined && value !== null) {
|
|
@@ -18101,7 +18139,7 @@ class Ad4mModel {
|
|
|
18101
18139
|
* ```
|
|
18102
18140
|
*/
|
|
18103
18141
|
async get() {
|
|
18104
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
18142
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
18105
18143
|
return await this.getData();
|
|
18106
18144
|
}
|
|
18107
18145
|
/**
|
|
@@ -30,6 +30,7 @@ export type Query = {
|
|
|
30
30
|
export type AllInstancesResult = {
|
|
31
31
|
AllInstances: Ad4mModel[];
|
|
32
32
|
TotalCount?: number;
|
|
33
|
+
isInit?: boolean;
|
|
33
34
|
};
|
|
34
35
|
export type ResultsWithTotalCount<T> = {
|
|
35
36
|
results: T[];
|
|
@@ -280,6 +281,7 @@ export declare class Ad4mModel {
|
|
|
280
281
|
* ```
|
|
281
282
|
*/
|
|
282
283
|
save(batchId?: string): Promise<void>;
|
|
284
|
+
private cleanCopy;
|
|
283
285
|
private innerUpdate;
|
|
284
286
|
/**
|
|
285
287
|
* Updates the model instance's properties and collections.
|
|
@@ -250,6 +250,12 @@ function buildLimitQuery(limit) {
|
|
|
250
250
|
*/
|
|
251
251
|
export class Ad4mModel {
|
|
252
252
|
static async getClassName(perspective) {
|
|
253
|
+
// Check if this is the Ad4mModel class itself or a subclass
|
|
254
|
+
const isBaseClass = this === Ad4mModel;
|
|
255
|
+
// For the base Ad4mModel class, we can't use the cache
|
|
256
|
+
if (isBaseClass) {
|
|
257
|
+
return await perspective.stringOrTemplateObjectToSubjectClassName(this);
|
|
258
|
+
}
|
|
253
259
|
// Get or create the cache for this class
|
|
254
260
|
let classCache = this.classNamesByClass.get(this);
|
|
255
261
|
if (!classCache) {
|
|
@@ -605,8 +611,18 @@ export class Ad4mModel {
|
|
|
605
611
|
}
|
|
606
612
|
await this.getData();
|
|
607
613
|
}
|
|
614
|
+
cleanCopy() {
|
|
615
|
+
const cleanCopy = {};
|
|
616
|
+
const props = Object.entries(this);
|
|
617
|
+
for (const [key, value] of props) {
|
|
618
|
+
if (value !== undefined && value !== null && key !== "author" && key !== "timestamp") {
|
|
619
|
+
cleanCopy[key] = value;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return cleanCopy;
|
|
623
|
+
}
|
|
608
624
|
async innerUpdate(setProperties = true, batchId) {
|
|
609
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
625
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
610
626
|
const entries = Object.entries(this);
|
|
611
627
|
for (const [key, value] of entries) {
|
|
612
628
|
if (value !== undefined && value !== null) {
|
|
@@ -674,7 +690,7 @@ export class Ad4mModel {
|
|
|
674
690
|
* ```
|
|
675
691
|
*/
|
|
676
692
|
async get() {
|
|
677
|
-
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this), "f");
|
|
693
|
+
__classPrivateFieldSet(this, _Ad4mModel_subjectClassName, await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").stringOrTemplateObjectToSubjectClassName(this.cleanCopy()), "f");
|
|
678
694
|
return await this.getData();
|
|
679
695
|
}
|
|
680
696
|
/**
|
|
@@ -30,6 +30,7 @@ export declare class PerspectiveClient {
|
|
|
30
30
|
subscribeQuery(uuid: string, query: string): Promise<{
|
|
31
31
|
subscriptionId: string;
|
|
32
32
|
result: AllInstancesResult;
|
|
33
|
+
isInit?: boolean;
|
|
33
34
|
}>;
|
|
34
35
|
subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void;
|
|
35
36
|
keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean>;
|
|
@@ -150,13 +150,18 @@ export class PerspectiveClient {
|
|
|
150
150
|
}));
|
|
151
151
|
const { subscriptionId, result } = perspectiveSubscribeQuery;
|
|
152
152
|
let finalResult = result;
|
|
153
|
+
let isInit = false;
|
|
154
|
+
if (finalResult.startsWith("#init#")) {
|
|
155
|
+
finalResult = finalResult.substring(6);
|
|
156
|
+
isInit = true;
|
|
157
|
+
}
|
|
153
158
|
try {
|
|
154
|
-
finalResult = JSON.parse(
|
|
159
|
+
finalResult = JSON.parse(finalResult);
|
|
155
160
|
}
|
|
156
161
|
catch (e) {
|
|
157
162
|
console.error('Error parsing perspectiveSubscribeQuery result:', e);
|
|
158
163
|
}
|
|
159
|
-
return { subscriptionId, result: finalResult };
|
|
164
|
+
return { subscriptionId, result: finalResult, isInit };
|
|
160
165
|
}
|
|
161
166
|
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
162
167
|
const subscription = __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
@@ -172,8 +177,16 @@ export class PerspectiveClient {
|
|
|
172
177
|
next: (result) => {
|
|
173
178
|
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
174
179
|
let finalResult = result.data.perspectiveQuerySubscription;
|
|
180
|
+
let isInit = false;
|
|
181
|
+
if (finalResult.startsWith("#init#")) {
|
|
182
|
+
finalResult = finalResult.substring(6);
|
|
183
|
+
isInit = true;
|
|
184
|
+
}
|
|
175
185
|
try {
|
|
176
|
-
finalResult = JSON.parse(
|
|
186
|
+
finalResult = JSON.parse(finalResult);
|
|
187
|
+
if (isInit) {
|
|
188
|
+
finalResult.isInit = true;
|
|
189
|
+
}
|
|
177
190
|
}
|
|
178
191
|
catch (e) {
|
|
179
192
|
console.error('Error parsing perspectiveQuerySubscription:', e);
|
|
@@ -70,6 +70,7 @@ export class QuerySubscriptionProxy {
|
|
|
70
70
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_query, query, "f");
|
|
71
71
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_client, client, "f");
|
|
72
72
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
|
|
73
|
+
__classPrivateFieldSet(this, _QuerySubscriptionProxy_latestResult, null, "f");
|
|
73
74
|
}
|
|
74
75
|
async subscribe() {
|
|
75
76
|
// initialize the query subscription
|
|
@@ -79,7 +80,8 @@ export class QuerySubscriptionProxy {
|
|
|
79
80
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
|
|
80
81
|
// Add timeout to prevent hanging promises
|
|
81
82
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
|
|
82
|
-
reject(new Error('Subscription initialization timed out after 30 seconds'));
|
|
83
|
+
reject(new Error('Subscription initialization timed out after 30 seconds. Resubscribing...'));
|
|
84
|
+
this.subscribe();
|
|
83
85
|
}, 30000), "f"); // 30 seconds timeout
|
|
84
86
|
// Subscribe to query updates
|
|
85
87
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet(this, _QuerySubscriptionProxy_subscriptionId, "f"), (result) => {
|
|
@@ -88,6 +90,13 @@ export class QuerySubscriptionProxy {
|
|
|
88
90
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
89
91
|
}
|
|
90
92
|
resolve(true);
|
|
93
|
+
// if the result is one of those repeated initialization results
|
|
94
|
+
// and we got a result before, we don't notify the callbacks
|
|
95
|
+
// so they don't get confused (we could have gotten another
|
|
96
|
+
// more recent result in between)
|
|
97
|
+
if (result.isInit && __classPrivateFieldGet(this, _QuerySubscriptionProxy_latestResult, "f")) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
91
100
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_latestResult, result, "f");
|
|
92
101
|
__classPrivateFieldGet(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, result);
|
|
93
102
|
}), "f");
|