@osdk/client 2.1.0-beta.2 → 2.1.0-beta.21
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/CHANGELOG.md +297 -0
- package/build/browser/Client.d.ts +6 -22
- package/build/browser/Client.d.ts.map +1 -1
- package/build/browser/Client.js +3 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.d.ts +1 -1
- package/build/browser/MinimalClientContext.d.ts.map +1 -1
- package/build/browser/__unstable/ConjureSupport.js +5 -5
- package/build/browser/__unstable/ConjureSupport.js.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js +2 -2
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/browser/actions/actions.test.js +28 -0
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/actions/applyAction.js +1 -1
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.d.ts +1 -1
- package/build/browser/createClient.d.ts.map +1 -1
- package/build/browser/createClient.js +41 -19
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createClient.test.js +24 -0
- package/build/browser/createClient.test.js.map +1 -1
- package/build/browser/createGeotimeSeriesProperty.d.ts +1 -1
- package/build/browser/createGeotimeSeriesProperty.d.ts.map +1 -1
- package/build/browser/createGeotimeSeriesProperty.js +4 -1
- package/build/browser/createGeotimeSeriesProperty.js.map +1 -1
- package/build/browser/createMinimalClient.js +9 -4
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/createPlatformClient.d.ts +1 -1
- package/build/browser/createPlatformClient.d.ts.map +1 -1
- package/build/browser/createTimeseriesProperty.d.ts.map +1 -1
- package/build/browser/fetchMetadata.test.js +14 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.d.ts +2 -2
- package/build/browser/index.d.ts.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/intellisense.test.js +1 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
- package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +11 -3
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +208 -7
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/AttachmentUpload.d.ts.map +1 -1
- package/build/browser/object/AttachmentUpload.js +5 -7
- package/build/browser/object/AttachmentUpload.js.map +1 -1
- package/build/browser/object/aggregate.js +4 -5
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/aggregate.test.js +6 -9
- package/build/browser/object/aggregate.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js +4 -3
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +41 -85
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +0 -6
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +60 -89
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js +2 -2
- package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js +14 -38
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +42 -6
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +177 -45
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.d.ts.map +1 -1
- package/build/browser/object/fetchPage.js +34 -23
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +75 -1
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/object/object.test.d.ts.map +1 -1
- package/build/browser/object/object.test.js +25 -1
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/object/timeseries.test.js +10 -0
- package/build/browser/object/timeseries.test.js.map +1 -1
- package/build/browser/objectSet/InterfaceObjectSet.test.d.ts +2 -0
- package/build/browser/objectSet/InterfaceObjectSet.test.d.ts.map +1 -0
- package/build/browser/objectSet/InterfaceObjectSet.test.js +61 -0
- package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -0
- package/build/browser/objectSet/ObjectSet.test.js +162 -48
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +136 -74
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +150 -42
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +10 -8
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/objectSet/toConjureObjectSet.js +2 -0
- package/build/browser/objectSet/toConjureObjectSet.js.map +1 -1
- package/build/browser/ontology/makeConjureContext.d.ts +1 -1
- package/build/browser/ontology/makeConjureContext.d.ts.map +1 -1
- package/build/browser/public/internal.d.ts +4 -0
- package/build/browser/public/internal.d.ts.map +1 -0
- package/build/browser/public/internal.js +19 -0
- package/build/browser/public/internal.js.map +1 -0
- package/build/browser/public-utils/createAndFetchTempObjectSetRid.d.ts +11 -0
- package/build/browser/public-utils/createAndFetchTempObjectSetRid.d.ts.map +1 -0
- package/build/browser/public-utils/createAndFetchTempObjectSetRid.js +32 -0
- package/build/browser/public-utils/createAndFetchTempObjectSetRid.js.map +1 -0
- package/build/browser/public-utils/hydrateAttachmentFromRid.d.ts +10 -0
- package/build/browser/public-utils/hydrateAttachmentFromRid.d.ts.map +1 -0
- package/build/{esm/createAttachmentFromRid.js → browser/public-utils/hydrateAttachmentFromRid.js} +9 -4
- package/build/browser/public-utils/hydrateAttachmentFromRid.js.map +1 -0
- package/build/browser/public-utils/hydrateObjectSetFromRid.d.ts +11 -0
- package/build/browser/public-utils/hydrateObjectSetFromRid.d.ts.map +1 -0
- package/build/browser/public-utils/hydrateObjectSetFromRid.js +37 -0
- package/build/browser/public-utils/hydrateObjectSetFromRid.js.map +1 -0
- package/build/browser/queries/applyQuery.d.ts.map +1 -1
- package/build/browser/queries/applyQuery.js +3 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +30 -2
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/tsserver.js +1 -1
- package/build/browser/tsserver.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/datetimeConverters.d.ts +22 -0
- package/build/browser/util/datetimeConverters.d.ts.map +1 -0
- package/build/browser/util/datetimeConverters.js +55 -0
- package/build/browser/util/datetimeConverters.js.map +1 -0
- package/build/browser/util/datetimeConverters.test.d.ts +2 -0
- package/build/browser/util/datetimeConverters.test.d.ts.map +1 -0
- package/build/browser/util/datetimeConverters.test.js +75 -0
- package/build/browser/util/datetimeConverters.test.js.map +1 -0
- package/build/browser/util/objectSetUtils.d.ts +4 -0
- package/build/browser/util/objectSetUtils.d.ts.map +1 -0
- package/build/browser/util/objectSetUtils.js +25 -0
- package/build/browser/util/objectSetUtils.js.map +1 -0
- package/build/browser/util/timeseriesUtils.d.ts +1 -1
- package/build/browser/util/timeseriesUtils.d.ts.map +1 -1
- package/build/browser/util/timeseriesUtils.js +1 -1
- package/build/browser/util/timeseriesUtils.js.map +1 -1
- package/build/browser/util/toDataValue.js +6 -0
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +9 -1
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/browser/util/toDataValueQueries.js +6 -0
- package/build/browser/util/toDataValueQueries.js.map +1 -1
- package/build/esm/Client.d.ts +6 -22
- package/build/esm/Client.d.ts.map +1 -1
- package/build/esm/Client.js +3 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.d.ts +1 -1
- package/build/esm/MinimalClientContext.d.ts.map +1 -1
- package/build/esm/__unstable/ConjureSupport.js +5 -5
- package/build/esm/__unstable/ConjureSupport.js.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js +2 -2
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/esm/actions/actions.test.js +28 -0
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/actions/applyAction.js +1 -1
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.d.ts +1 -1
- package/build/esm/createClient.d.ts.map +1 -1
- package/build/esm/createClient.js +41 -19
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createClient.test.js +24 -0
- package/build/esm/createClient.test.js.map +1 -1
- package/build/esm/createGeotimeSeriesProperty.d.ts +1 -1
- package/build/esm/createGeotimeSeriesProperty.d.ts.map +1 -1
- package/build/esm/createGeotimeSeriesProperty.js +4 -1
- package/build/esm/createGeotimeSeriesProperty.js.map +1 -1
- package/build/esm/createMinimalClient.js +9 -4
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/createPlatformClient.d.ts +1 -1
- package/build/esm/createPlatformClient.d.ts.map +1 -1
- package/build/esm/createTimeseriesProperty.d.ts.map +1 -1
- package/build/esm/fetchMetadata.test.js +14 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.d.ts +2 -2
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/intellisense.test.js +1 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
- package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +11 -3
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +208 -7
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/AttachmentUpload.d.ts.map +1 -1
- package/build/esm/object/AttachmentUpload.js +5 -7
- package/build/esm/object/AttachmentUpload.js.map +1 -1
- package/build/esm/object/aggregate.js +4 -5
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/aggregate.test.js +6 -9
- package/build/esm/object/aggregate.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js +4 -3
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +41 -85
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +0 -6
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +60 -89
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js +2 -2
- package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js +14 -38
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +42 -6
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +177 -45
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.d.ts.map +1 -1
- package/build/esm/object/fetchPage.js +34 -23
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +75 -1
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/object/object.test.d.ts.map +1 -1
- package/build/esm/object/object.test.js +25 -1
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/object/timeseries.test.js +10 -0
- package/build/esm/object/timeseries.test.js.map +1 -1
- package/build/esm/objectSet/InterfaceObjectSet.test.d.ts +2 -0
- package/build/esm/objectSet/InterfaceObjectSet.test.d.ts.map +1 -0
- package/build/esm/objectSet/InterfaceObjectSet.test.js +61 -0
- package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -0
- package/build/esm/objectSet/ObjectSet.test.js +162 -48
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +136 -77
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +150 -42
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +10 -8
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/objectSet/toConjureObjectSet.js +2 -0
- package/build/esm/objectSet/toConjureObjectSet.js.map +1 -1
- package/build/esm/ontology/makeConjureContext.d.ts +1 -1
- package/build/esm/ontology/makeConjureContext.d.ts.map +1 -1
- package/build/esm/public/internal.d.ts +4 -0
- package/build/esm/public/internal.d.ts.map +1 -0
- package/build/esm/public/internal.js +19 -0
- package/build/esm/public/internal.js.map +1 -0
- package/build/esm/public-utils/createAndFetchTempObjectSetRid.d.ts +11 -0
- package/build/esm/public-utils/createAndFetchTempObjectSetRid.d.ts.map +1 -0
- package/build/esm/public-utils/createAndFetchTempObjectSetRid.js +32 -0
- package/build/esm/public-utils/createAndFetchTempObjectSetRid.js.map +1 -0
- package/build/esm/public-utils/hydrateAttachmentFromRid.d.ts +10 -0
- package/build/esm/public-utils/hydrateAttachmentFromRid.d.ts.map +1 -0
- package/build/{browser/createAttachmentFromRid.js → esm/public-utils/hydrateAttachmentFromRid.js} +9 -4
- package/build/esm/public-utils/hydrateAttachmentFromRid.js.map +1 -0
- package/build/esm/public-utils/hydrateObjectSetFromRid.d.ts +11 -0
- package/build/esm/public-utils/hydrateObjectSetFromRid.d.ts.map +1 -0
- package/build/esm/public-utils/hydrateObjectSetFromRid.js +37 -0
- package/build/esm/public-utils/hydrateObjectSetFromRid.js.map +1 -0
- package/build/esm/queries/applyQuery.d.ts.map +1 -1
- package/build/esm/queries/applyQuery.js +3 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +30 -2
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/tsserver.js +1 -1
- package/build/esm/tsserver.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/datetimeConverters.d.ts +22 -0
- package/build/esm/util/datetimeConverters.d.ts.map +1 -0
- package/build/esm/util/datetimeConverters.js +55 -0
- package/build/esm/util/datetimeConverters.js.map +1 -0
- package/build/esm/util/datetimeConverters.test.d.ts +2 -0
- package/build/esm/util/datetimeConverters.test.d.ts.map +1 -0
- package/build/esm/util/datetimeConverters.test.js +75 -0
- package/build/esm/util/datetimeConverters.test.js.map +1 -0
- package/build/esm/util/objectSetUtils.d.ts +4 -0
- package/build/esm/util/objectSetUtils.d.ts.map +1 -0
- package/build/esm/util/objectSetUtils.js +25 -0
- package/build/esm/util/objectSetUtils.js.map +1 -0
- package/build/esm/util/timeseriesUtils.d.ts +1 -1
- package/build/esm/util/timeseriesUtils.d.ts.map +1 -1
- package/build/esm/util/timeseriesUtils.js +1 -1
- package/build/esm/util/timeseriesUtils.js.map +1 -1
- package/build/esm/util/toDataValue.js +6 -0
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +9 -1
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/esm/util/toDataValueQueries.js +6 -0
- package/build/esm/util/toDataValueQueries.js.map +1 -1
- package/package.json +23 -19
- package/build/browser/createAttachmentFromRid.d.ts +0 -10
- package/build/browser/createAttachmentFromRid.d.ts.map +0 -1
- package/build/browser/createAttachmentFromRid.js.map +0 -1
- package/build/esm/createAttachmentFromRid.d.ts +0 -10
- package/build/esm/createAttachmentFromRid.d.ts.map +0 -1
- package/build/esm/createAttachmentFromRid.js.map +0 -1
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import WebSocket from "isomorphic-ws";
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
-
import { convertWireToOsdkObjects } from "../object/convertWireToOsdkObjects.js";
|
|
19
|
-
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
20
18
|
const MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;
|
|
21
19
|
/** Noop function to reduce conditional checks */
|
|
22
20
|
function doNothing() {}
|
|
@@ -26,12 +24,14 @@ function doNothing() {}
|
|
|
26
24
|
function fillOutListener({
|
|
27
25
|
onChange = doNothing,
|
|
28
26
|
onError = doNothing,
|
|
29
|
-
onOutOfDate = doNothing
|
|
27
|
+
onOutOfDate = doNothing,
|
|
28
|
+
onSuccessfulSubscription = doNothing
|
|
30
29
|
}) {
|
|
31
30
|
return {
|
|
32
31
|
onChange,
|
|
33
32
|
onError,
|
|
34
|
-
onOutOfDate
|
|
33
|
+
onOutOfDate,
|
|
34
|
+
onSuccessfulSubscription
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function isReady(sub) {
|
|
@@ -43,7 +43,6 @@ function subscriptionIsDone(sub) {
|
|
|
43
43
|
/** @internal */
|
|
44
44
|
export class ObjectSetListenerWebsocket {
|
|
45
45
|
static #instances = new WeakMap();
|
|
46
|
-
OBJECT_SET_EXPIRY_MS;
|
|
47
46
|
MINIMUM_RECONNECT_DELAY_MS;
|
|
48
47
|
// FIXME
|
|
49
48
|
static getInstance(client) {
|
|
@@ -67,32 +66,44 @@ export class ObjectSetListenerWebsocket {
|
|
|
67
66
|
* temporary and not the actual subscriptionId from the server.
|
|
68
67
|
*/
|
|
69
68
|
#subscriptions = new Map();
|
|
69
|
+
#endedSubscriptions = new Set();
|
|
70
70
|
#maybeDisconnectTimeout;
|
|
71
71
|
// DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM
|
|
72
72
|
constructor(client, {
|
|
73
|
-
objectSetExpiryMs = ONE_DAY_MS,
|
|
74
73
|
minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS
|
|
75
74
|
} = {}) {
|
|
76
|
-
this.OBJECT_SET_EXPIRY_MS = objectSetExpiryMs;
|
|
77
75
|
this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;
|
|
78
76
|
this.#client = client;
|
|
79
77
|
this.#logger = client.logger?.child({}, {
|
|
80
78
|
msgPrefix: "<OSW> "
|
|
81
79
|
});
|
|
82
|
-
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? invariant(false, "Stack must be a URL") : void 0;
|
|
80
|
+
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? process.env.NODE_ENV !== "production" ? invariant(false, "Stack must be a URL") : invariant(false) : void 0;
|
|
83
81
|
}
|
|
84
|
-
async subscribe(objectSet, listener, properties) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
async subscribe(objectType, objectSet, listener, properties = []) {
|
|
83
|
+
const objDef = objectType.type === "object" ? await this.#client.ontologyProvider.getObjectDefinition(objectType.apiName) : await this.#client.ontologyProvider.getInterfaceDefinition(objectType.apiName);
|
|
84
|
+
let objectProperties = [];
|
|
85
|
+
let referenceProperties = [];
|
|
86
|
+
if (objectType.type === "object") {
|
|
87
|
+
if (properties.length === 0) {
|
|
88
|
+
properties = Object.keys(objDef.properties);
|
|
89
|
+
}
|
|
90
|
+
objectProperties = properties.filter(p => objDef.properties[p].type !== "geotimeSeriesReference");
|
|
91
|
+
referenceProperties = properties.filter(p => objDef.properties[p].type === "geotimeSeriesReference");
|
|
92
|
+
} else {
|
|
93
|
+
objectProperties = [];
|
|
94
|
+
referenceProperties = properties;
|
|
95
|
+
}
|
|
88
96
|
const sub = {
|
|
89
97
|
listener: fillOutListener(listener),
|
|
90
98
|
objectSet,
|
|
91
|
-
|
|
99
|
+
primaryKeyPropertyName: objDef.type === "interface" ? undefined : objDef.primaryKeyApiName,
|
|
100
|
+
requestedProperties: objectProperties,
|
|
101
|
+
requestedReferenceProperties: referenceProperties,
|
|
92
102
|
status: "preparing",
|
|
93
103
|
// Since we don't have a real subscription id yet but we need to keep
|
|
94
104
|
// track of this reference, we can just use a random uuid.
|
|
95
|
-
subscriptionId: `TMP-${
|
|
105
|
+
subscriptionId: `TMP-${nextUuid()}}`,
|
|
106
|
+
interfaceApiName: objDef.type === "object" ? undefined : objDef.apiName
|
|
96
107
|
};
|
|
97
108
|
this.#subscriptions.set(sub.subscriptionId, sub);
|
|
98
109
|
// actually prepares the subscription, ensures the ws is ready, and sends
|
|
@@ -112,16 +123,9 @@ export class ObjectSetListenerWebsocket {
|
|
|
112
123
|
* @returns
|
|
113
124
|
*/
|
|
114
125
|
async #initiateSubscribe(sub) {
|
|
115
|
-
if (process
|
|
126
|
+
if (process.env.NODE_ENV !== "production") {
|
|
116
127
|
this.#logger?.trace("#initiateSubscribe()");
|
|
117
128
|
}
|
|
118
|
-
if (sub.expiry) {
|
|
119
|
-
clearTimeout(sub.expiry);
|
|
120
|
-
}
|
|
121
|
-
// expiry is tied to the temporary object set, which is set to `timeToLive: "ONE_DAY"`
|
|
122
|
-
// in `#createTemporaryObjectSet`. They should be in sync
|
|
123
|
-
sub.expiry = setTimeout(() => this.#expire(sub), this.OBJECT_SET_EXPIRY_MS);
|
|
124
|
-
await this.#client.ontologyRid;
|
|
125
129
|
try {
|
|
126
130
|
await this.#ensureWebsocket();
|
|
127
131
|
// the consumer may have already unsubscribed before we are ready to request a subscription
|
|
@@ -136,25 +140,18 @@ export class ObjectSetListenerWebsocket {
|
|
|
136
140
|
}
|
|
137
141
|
} catch (error) {
|
|
138
142
|
this.#logger?.error(error, "Error in #initiateSubscribe");
|
|
139
|
-
sub
|
|
143
|
+
this.#tryCatchOnError(sub, true, error);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
#sendSubscribeMessage() {
|
|
143
|
-
if (process
|
|
147
|
+
if (process.env.NODE_ENV !== "production") {
|
|
144
148
|
this.#logger?.trace("#sendSubscribeMessage()");
|
|
145
149
|
}
|
|
146
150
|
// If two calls to `.subscribe()` happen at once (or if the connection is reset),
|
|
147
151
|
// we may have multiple subscriptions that don't have a subscriptionId yet,
|
|
148
152
|
// so we filter those out.
|
|
149
153
|
const readySubs = [...this.#subscriptions.values()].filter(isReady);
|
|
150
|
-
|
|
151
|
-
if (process?.env?.NODE_ENV !== "production") {
|
|
152
|
-
this.#logger?.trace("#sendSubscribeMessage(): aborting due to no ready subscriptions");
|
|
153
|
-
}
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
// Assumes the node 18 crypto fallback to globalThis in `subscribe` has happened.
|
|
157
|
-
const id = crypto.randomUUID();
|
|
154
|
+
const id = nextUuid();
|
|
158
155
|
// responses come back as an array of subIds, so we need to know the sources
|
|
159
156
|
this.#pendingSubscriptions.set(id, readySubs);
|
|
160
157
|
// every subscribe message "overwrites" the previous ones that are not
|
|
@@ -163,31 +160,24 @@ export class ObjectSetListenerWebsocket {
|
|
|
163
160
|
id,
|
|
164
161
|
requests: readySubs.map(({
|
|
165
162
|
objectSet,
|
|
166
|
-
requestedProperties
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
requestedProperties,
|
|
164
|
+
requestedReferenceProperties,
|
|
165
|
+
interfaceApiName
|
|
166
|
+
}) => {
|
|
167
|
+
return {
|
|
168
|
+
objectSet: objectSet,
|
|
169
|
+
propertySet: requestedProperties,
|
|
170
|
+
referenceSet: requestedReferenceProperties
|
|
171
|
+
};
|
|
172
|
+
})
|
|
172
173
|
};
|
|
173
|
-
if (process
|
|
174
|
+
if (process.env.NODE_ENV !== "production") {
|
|
174
175
|
this.#logger?.trace({
|
|
175
176
|
payload: subscribe
|
|
176
177
|
}, "sending subscribe message");
|
|
177
178
|
}
|
|
178
179
|
this.#ws?.send(JSON.stringify(subscribe));
|
|
179
180
|
}
|
|
180
|
-
#expire(sub) {
|
|
181
|
-
if (process?.env?.NODE_ENV !== "production") {
|
|
182
|
-
this.#logger?.trace({
|
|
183
|
-
subscription: sub
|
|
184
|
-
}, "#expire()");
|
|
185
|
-
}
|
|
186
|
-
// the temporary ObjectSet has expired, we should re-subscribe which will cause the
|
|
187
|
-
// listener to get an onOutOfDate message when it becomes subscribed again
|
|
188
|
-
sub.status = "expired";
|
|
189
|
-
this.#initiateSubscribe(sub);
|
|
190
|
-
}
|
|
191
181
|
#unsubscribe(sub, newStatus = "done") {
|
|
192
182
|
if (subscriptionIsDone(sub)) {
|
|
193
183
|
// if we are already done, we don't need to do anything
|
|
@@ -196,11 +186,9 @@ export class ObjectSetListenerWebsocket {
|
|
|
196
186
|
sub.status = newStatus;
|
|
197
187
|
// make sure listeners do nothing now
|
|
198
188
|
sub.listener = fillOutListener({});
|
|
199
|
-
if (sub.expiry) {
|
|
200
|
-
clearTimeout(sub.expiry);
|
|
201
|
-
sub.expiry = undefined;
|
|
202
|
-
}
|
|
203
189
|
this.#subscriptions.delete(sub.subscriptionId);
|
|
190
|
+
this.#endedSubscriptions.add(sub.subscriptionId);
|
|
191
|
+
this.#sendSubscribeMessage();
|
|
204
192
|
// If we have no more subscriptions, we can disconnect the websocket
|
|
205
193
|
// however we should wait a bit to see if we get any more subscriptions.
|
|
206
194
|
// For example, when switching between react views, you may unsubscribe
|
|
@@ -230,8 +218,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
230
218
|
baseUrl,
|
|
231
219
|
tokenProvider
|
|
232
220
|
} = this.#client;
|
|
233
|
-
const
|
|
234
|
-
const url = `wss://${base.host}/api/v2/ontologySubscriptions/ontologies/${this.#client.ontologyRid}/streamSubscriptions`;
|
|
221
|
+
const url = constructWebsocketUrl(baseUrl, this.#client.ontologyRid);
|
|
235
222
|
const token = await tokenProvider();
|
|
236
223
|
// tokenProvider is async, there could potentially be a race to create the websocket.
|
|
237
224
|
// Only the first call to reach here will find a null this.#ws, the rest will bail out
|
|
@@ -247,7 +234,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
247
234
|
this.#lastWsConnect = Date.now();
|
|
248
235
|
// we again may have lost the race after our minimum backoff time
|
|
249
236
|
if (this.#ws == null) {
|
|
250
|
-
if (process
|
|
237
|
+
if (process.env.NODE_ENV !== "production") {
|
|
251
238
|
this.#logger?.trace("Creating websocket");
|
|
252
239
|
}
|
|
253
240
|
this.#ws = new WebSocket(url, [`Bearer-${token}`]);
|
|
@@ -287,7 +274,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
287
274
|
};
|
|
288
275
|
#onMessage = async message => {
|
|
289
276
|
const data = JSON.parse(message.data.toString());
|
|
290
|
-
if (process
|
|
277
|
+
if (process.env.NODE_ENV !== "production") {
|
|
291
278
|
this.#logger?.trace({
|
|
292
279
|
payload: data
|
|
293
280
|
}, "received message from ws");
|
|
@@ -304,16 +291,43 @@ export class ObjectSetListenerWebsocket {
|
|
|
304
291
|
return this.#handleMessage_subscriptionClosed(data);
|
|
305
292
|
}
|
|
306
293
|
default:
|
|
307
|
-
invariant(false, "Unexpected message type");
|
|
294
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "Unexpected message type") : invariant(false);
|
|
308
295
|
}
|
|
309
296
|
};
|
|
310
297
|
#handleMessage_objectSetChanged = async payload => {
|
|
311
298
|
const sub = this.#subscriptions.get(payload.id);
|
|
312
|
-
|
|
299
|
+
if (sub == null) return;
|
|
313
300
|
const objectUpdates = payload.updates.filter(update => update.type === "object");
|
|
314
|
-
payload.updates.filter(update => update.type === "reference");
|
|
301
|
+
const referenceUpdates = payload.updates.filter(update => update.type === "reference");
|
|
302
|
+
const osdkObjectsWithReferenceUpdates = await Promise.all(referenceUpdates.map(async o => {
|
|
303
|
+
const osdkObjectArray = await this.#client.objectFactory(this.#client, [{
|
|
304
|
+
__apiName: o.objectType,
|
|
305
|
+
__primaryKey: sub.primaryKeyPropertyName != null ? o.primaryKey[sub.primaryKeyPropertyName] : undefined,
|
|
306
|
+
...o.primaryKey,
|
|
307
|
+
[o.property]: o.value
|
|
308
|
+
}], sub.interfaceApiName);
|
|
309
|
+
const singleOsdkObject = osdkObjectArray[0] ?? undefined;
|
|
310
|
+
return singleOsdkObject != null ? {
|
|
311
|
+
object: singleOsdkObject,
|
|
312
|
+
state: "ADDED_OR_UPDATED"
|
|
313
|
+
} : undefined;
|
|
314
|
+
}));
|
|
315
|
+
for (const osdkObject of osdkObjectsWithReferenceUpdates) {
|
|
316
|
+
if (osdkObject != null) {
|
|
317
|
+
try {
|
|
318
|
+
sub.listener.onChange?.(osdkObject);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
this.#logger?.error(error, "Error in onChange callback");
|
|
321
|
+
this.#tryCatchOnError(sub, false, error);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
315
325
|
const osdkObjects = await Promise.all(objectUpdates.map(async o => {
|
|
316
|
-
const
|
|
326
|
+
const keysToDelete = Object.keys(o.object).filter(key => sub.requestedReferenceProperties.includes(key));
|
|
327
|
+
for (const key of keysToDelete) {
|
|
328
|
+
delete o.object[key];
|
|
329
|
+
}
|
|
330
|
+
const osdkObjectArray = await this.#client.objectFactory(this.#client, [o.object], sub.interfaceApiName);
|
|
317
331
|
const singleOsdkObject = osdkObjectArray[0] ?? undefined;
|
|
318
332
|
return singleOsdkObject != null ? {
|
|
319
333
|
object: singleOsdkObject,
|
|
@@ -322,14 +336,24 @@ export class ObjectSetListenerWebsocket {
|
|
|
322
336
|
}));
|
|
323
337
|
for (const osdkObject of osdkObjects) {
|
|
324
338
|
if (osdkObject != null) {
|
|
325
|
-
|
|
339
|
+
try {
|
|
340
|
+
sub.listener.onChange?.(osdkObject);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
this.#logger?.error(error, "Error in onChange callback");
|
|
343
|
+
this.#tryCatchOnError(sub, false, error);
|
|
344
|
+
}
|
|
326
345
|
}
|
|
327
346
|
}
|
|
328
347
|
};
|
|
329
348
|
#handleMessage_refreshObjectSet = payload => {
|
|
330
349
|
const sub = this.#subscriptions.get(payload.id);
|
|
331
|
-
!sub ? invariant(false, `Expected subscription id ${payload.id}`) : void 0;
|
|
332
|
-
|
|
350
|
+
!sub ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected subscription id ${payload.id}`) : invariant(false) : void 0;
|
|
351
|
+
try {
|
|
352
|
+
sub.listener.onOutOfDate();
|
|
353
|
+
} catch (error) {
|
|
354
|
+
this.#logger?.error(error, "Error in onOutOfDate callback");
|
|
355
|
+
this.#tryCatchOnError(sub, false, error);
|
|
356
|
+
}
|
|
333
357
|
};
|
|
334
358
|
#handleMessage_subscribeResponses = payload => {
|
|
335
359
|
const {
|
|
@@ -337,14 +361,14 @@ export class ObjectSetListenerWebsocket {
|
|
|
337
361
|
responses
|
|
338
362
|
} = payload;
|
|
339
363
|
const subs = this.#pendingSubscriptions.get(id);
|
|
340
|
-
!subs ? invariant(false, `should have a pending subscription for ${id}`) : void 0;
|
|
364
|
+
!subs ? process.env.NODE_ENV !== "production" ? invariant(false, `should have a pending subscription for ${id}`) : invariant(false) : void 0;
|
|
341
365
|
this.#pendingSubscriptions.delete(id);
|
|
342
366
|
for (let i = 0; i < responses.length; i++) {
|
|
343
367
|
const sub = subs[i];
|
|
344
368
|
const response = responses[i];
|
|
345
369
|
switch (response.type) {
|
|
346
370
|
case "error":
|
|
347
|
-
sub
|
|
371
|
+
this.#tryCatchOnError(sub, true, response.errors);
|
|
348
372
|
this.#unsubscribe(sub, "error");
|
|
349
373
|
break;
|
|
350
374
|
case "qos":
|
|
@@ -354,7 +378,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
354
378
|
case "success":
|
|
355
379
|
// `"preparing"` should only be the status on an initial subscribe.
|
|
356
380
|
const shouldFireOutOfDate = sub.status === "expired" || sub.status === "reconnecting";
|
|
357
|
-
if (process
|
|
381
|
+
if (process.env.NODE_ENV !== "production") {
|
|
358
382
|
this.#logger?.trace({
|
|
359
383
|
shouldFireOutOfDate
|
|
360
384
|
}, "success");
|
|
@@ -366,21 +390,27 @@ export class ObjectSetListenerWebsocket {
|
|
|
366
390
|
sub.subscriptionId = response.id;
|
|
367
391
|
this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId
|
|
368
392
|
}
|
|
369
|
-
|
|
393
|
+
try {
|
|
394
|
+
if (shouldFireOutOfDate) sub.listener.onOutOfDate();else sub.listener.onSuccessfulSubscription();
|
|
395
|
+
} catch (error) {
|
|
396
|
+
this.#logger?.error(error, "Error in onOutOfDate or onSuccessfulSubscription callback");
|
|
397
|
+
this.#tryCatchOnError(sub, false, error);
|
|
398
|
+
}
|
|
370
399
|
break;
|
|
371
400
|
default:
|
|
372
|
-
sub
|
|
401
|
+
this.#tryCatchOnError(sub, true, response);
|
|
373
402
|
}
|
|
374
403
|
}
|
|
375
404
|
};
|
|
376
405
|
#handleMessage_subscriptionClosed(payload) {
|
|
377
406
|
const sub = this.#subscriptions.get(payload.id);
|
|
378
|
-
|
|
379
|
-
sub.
|
|
407
|
+
if (sub == null && this.#endedSubscriptions.has(payload.id)) return;
|
|
408
|
+
!sub ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected subscription id ${payload.id}`) : invariant(false) : void 0;
|
|
409
|
+
this.#tryCatchOnError(sub, true, payload.cause);
|
|
380
410
|
this.#unsubscribe(sub, "error");
|
|
381
411
|
}
|
|
382
412
|
#onClose = event => {
|
|
383
|
-
if (process
|
|
413
|
+
if (process.env.NODE_ENV !== "production") {
|
|
384
414
|
this.#logger?.trace({
|
|
385
415
|
event
|
|
386
416
|
}, "Received close event from ws", event);
|
|
@@ -388,8 +418,6 @@ export class ObjectSetListenerWebsocket {
|
|
|
388
418
|
// TODO we should probably throttle this so we don't abuse the backend
|
|
389
419
|
this.#cycleWebsocket();
|
|
390
420
|
};
|
|
391
|
-
// TODO: Validate if this is needed
|
|
392
|
-
async #enableObjectSetsWatcher() {}
|
|
393
421
|
#cycleWebsocket = () => {
|
|
394
422
|
if (this.#ws) {
|
|
395
423
|
this.#ws.removeEventListener("open", this.#onOpen);
|
|
@@ -402,9 +430,9 @@ export class ObjectSetListenerWebsocket {
|
|
|
402
430
|
}
|
|
403
431
|
// if we have any listeners that are still depending on us, go ahead and reopen the websocket
|
|
404
432
|
if (this.#subscriptions.size > 0) {
|
|
405
|
-
if (process
|
|
433
|
+
if (process.env.NODE_ENV !== "production") {
|
|
406
434
|
for (const s of this.#subscriptions.values()) {
|
|
407
|
-
!(s.status !== "done" && s.status !== "error") ? invariant(false, "should not have done/error subscriptions still") : void 0;
|
|
435
|
+
!(s.status !== "done" && s.status !== "error") ? process.env.NODE_ENV !== "production" ? invariant(false, "should not have done/error subscriptions still") : invariant(false) : void 0;
|
|
408
436
|
}
|
|
409
437
|
}
|
|
410
438
|
for (const s of this.#subscriptions.values()) {
|
|
@@ -413,5 +441,36 @@ export class ObjectSetListenerWebsocket {
|
|
|
413
441
|
this.#ensureWebsocket();
|
|
414
442
|
}
|
|
415
443
|
};
|
|
444
|
+
#tryCatchOnError = (sub, subscriptionClosed, error) => {
|
|
445
|
+
try {
|
|
446
|
+
sub.listener.onError({
|
|
447
|
+
subscriptionClosed: subscriptionClosed,
|
|
448
|
+
error
|
|
449
|
+
});
|
|
450
|
+
} catch (onErrorError) {
|
|
451
|
+
// eslint-disable-next-line no-console
|
|
452
|
+
console.error(`Error encountered in an onError callback for an OSDK subscription`, onErrorError);
|
|
453
|
+
// eslint-disable-next-line no-console
|
|
454
|
+
console.error(`This onError call was triggered by an error in another callback`, error);
|
|
455
|
+
// eslint-disable-next-line no-console
|
|
456
|
+
console.error(`The subscription has been closed.`, error);
|
|
457
|
+
if (!subscriptionClosed) {
|
|
458
|
+
this.#logger?.error(error, "Error in onError callback");
|
|
459
|
+
this.#unsubscribe(sub, "error");
|
|
460
|
+
this.#tryCatchOnError(sub, true, onErrorError);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
/** @internal */
|
|
466
|
+
export function constructWebsocketUrl(baseUrl, ontologyRid) {
|
|
467
|
+
const base = new URL(baseUrl);
|
|
468
|
+
const url = new URL(`api/v2/ontologySubscriptions/ontologies/${ontologyRid}/streamSubscriptions`, base);
|
|
469
|
+
url.protocol = url.protocol.replace("https", "wss");
|
|
470
|
+
return url;
|
|
471
|
+
}
|
|
472
|
+
let uuidCounter = 0;
|
|
473
|
+
function nextUuid() {
|
|
474
|
+
return `00000000-0000-0000-0000-${(uuidCounter++).toString().padStart(12, "0")}`;
|
|
416
475
|
}
|
|
417
476
|
//# sourceMappingURL=ObjectSetListenerWebsocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSetListenerWebsocket.js","names":["WebSocket","invariant","convertWireToOsdkObjects","ONE_DAY_MS","MINIMUM_RECONNECT_DELAY_MS","doNothing","fillOutListener","onChange","onError","onOutOfDate","isReady","sub","subscriptionIsDone","status","ObjectSetListenerWebsocket","instances","WeakMap","OBJECT_SET_EXPIRY_MS","getInstance","client","instance","get","clientCacheKey","set","ws","lastWsConnect","logger","pendingSubscriptions","Map","subscriptions","maybeDisconnectTimeout","constructor","objectSetExpiryMs","minimumReconnectDelayMs","child","msgPrefix","baseUrl","startsWith","subscribe","objectSet","listener","properties","globalThis","crypto","webcrypto","requestedProperties","subscriptionId","randomUUID","initiateSubscribe","unsubscribe","#initiateSubscribe","process","env","NODE_ENV","trace","expiry","clearTimeout","setTimeout","expire","ontologyRid","ensureWebsocket","readyState","OPEN","sendSubscribeMessage","error","#sendSubscribeMessage","readySubs","values","filter","length","id","requests","map","propertySet","referenceSet","payload","send","JSON","stringify","#expire","subscription","#unsubscribe","newStatus","undefined","delete","size","cycleWebsocket","#ensureWebsocket","tokenProvider","base","URL","url","host","token","nextConnectTime","Date","now","Promise","resolve","addEventListener","onClose","onMessage","onOpen","CONNECTING","reject","cleanup","removeEventListener","open","evt","#onOpen","message","data","parse","toString","type","handleMessage_objectSetChanged","handleMessage_refreshObjectSet","handleMessage_subscribeResponses","handleMessage_subscriptionClosed","objectUpdates","updates","update","osdkObjects","all","o","osdkObjectArray","object","singleOsdkObject","state","osdkObject","responses","subs","i","response","errors","shouldFireOutOfDate","#handleMessage_subscriptionClosed","cause","event","enableObjectSetsWatcher","#enableObjectSetsWatcher","#cycleWebsocket","CLOSING","CLOSED","close","s"],"sources":["ObjectSetListenerWebsocket.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport WebSocket from \"isomorphic-ws\";\nimport invariant from \"tiny-invariant\";\nimport { convertWireToOsdkObjects } from \"../object/convertWireToOsdkObjects.js\";\nconst ONE_DAY_MS = 24 * 60 * 60 * 1000;\nconst MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;\n/** Noop function to reduce conditional checks */\nfunction doNothing() { }\n/**\n * Converts an ObjectSetListener to one where all the functions are defined.\n */\nfunction fillOutListener({ onChange = doNothing, onError = doNothing, onOutOfDate = doNothing, }) {\n return { onChange, onError, onOutOfDate };\n}\nfunction isReady(sub) {\n return sub.isReady != null;\n}\nfunction subscriptionIsDone(sub) {\n return sub.status === \"done\" || sub.status === \"error\";\n}\n/** @internal */\nexport class ObjectSetListenerWebsocket {\n static #instances = new WeakMap();\n OBJECT_SET_EXPIRY_MS;\n MINIMUM_RECONNECT_DELAY_MS;\n // FIXME\n static getInstance(client) {\n let instance = ObjectSetListenerWebsocket.#instances.get(client.clientCacheKey);\n if (instance == null) {\n instance = new ObjectSetListenerWebsocket(client);\n ObjectSetListenerWebsocket.#instances.set(client.clientCacheKey, instance);\n }\n return instance;\n }\n #ws;\n #lastWsConnect = 0;\n #client;\n #logger;\n /**\n * map of requestId to all active subscriptions at the time of the request\n */\n #pendingSubscriptions = new Map();\n /**\n * Map of subscriptionId to Subscription. Note: the subscriptionId may be\n * temporary and not the actual subscriptionId from the server.\n */\n #subscriptions = new Map();\n #maybeDisconnectTimeout;\n // DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM\n constructor(client, { objectSetExpiryMs = ONE_DAY_MS, minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS, } = {}) {\n this.OBJECT_SET_EXPIRY_MS = objectSetExpiryMs;\n this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;\n this.#client = client;\n this.#logger = client.logger?.child({}, {\n msgPrefix: \"<OSW> \",\n });\n invariant(client.baseUrl.startsWith(\"https://\")\n || client.baseUrl.startsWith(\"http://\"), \"Stack must be a URL\");\n }\n async subscribe(objectSet, listener, properties) {\n if (process.env.TARGET !== \"browser\") {\n // Node 18 does not expose 'crypto' on globalThis, so we need to do it ourselves. This\n // will not be needed after our minimum version is 19 or greater.\n globalThis.crypto ??= (await import(\"node:crypto\")).webcrypto;\n }\n const sub = {\n listener: fillOutListener(listener),\n objectSet,\n requestedProperties: properties,\n status: \"preparing\",\n // Since we don't have a real subscription id yet but we need to keep\n // track of this reference, we can just use a random uuid.\n subscriptionId: `TMP-${crypto.randomUUID()}`,\n };\n this.#subscriptions.set(sub.subscriptionId, sub);\n // actually prepares the subscription, ensures the ws is ready, and sends\n // a subscribe message. We don't want to block on this.\n this.#initiateSubscribe(sub);\n return () => {\n this.#unsubscribe(sub);\n };\n }\n /**\n * Called at least once for every subscription.\n *\n * - Resets pending expiry\n * - Recreates temporary object set\n * - Triggers a full subscribe message\n *\n * @returns\n */\n async #initiateSubscribe(sub) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#initiateSubscribe()\");\n }\n if (sub.expiry) {\n clearTimeout(sub.expiry);\n }\n // expiry is tied to the temporary object set, which is set to `timeToLive: \"ONE_DAY\"`\n // in `#createTemporaryObjectSet`. They should be in sync\n sub.expiry = setTimeout(() => this.#expire(sub), this.OBJECT_SET_EXPIRY_MS);\n const ontologyRid = await this.#client.ontologyRid;\n try {\n await this.#ensureWebsocket();\n // the consumer may have already unsubscribed before we are ready to request a subscription\n // so we have to acquire the pendingSubscription after the await.\n if (subscriptionIsDone(sub)) {\n return;\n }\n sub.isReady = true;\n // if we aren't open, then this happens after we #onConnect\n if (this.#ws?.readyState === WebSocket.OPEN) {\n this.#sendSubscribeMessage();\n }\n }\n catch (error) {\n this.#logger?.error(error, \"Error in #initiateSubscribe\");\n sub.listener.onError([error]);\n }\n }\n #sendSubscribeMessage() {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage()\");\n }\n // If two calls to `.subscribe()` happen at once (or if the connection is reset),\n // we may have multiple subscriptions that don't have a subscriptionId yet,\n // so we filter those out.\n const readySubs = [...this.#subscriptions.values()].filter(isReady);\n if (readySubs.length === 0) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage(): aborting due to no ready subscriptions\");\n }\n return;\n }\n // Assumes the node 18 crypto fallback to globalThis in `subscribe` has happened.\n const id = crypto.randomUUID();\n // responses come back as an array of subIds, so we need to know the sources\n this.#pendingSubscriptions.set(id, readySubs);\n // every subscribe message \"overwrites\" the previous ones that are not\n // re-included, so we have to reconstitute the entire list of subscriptions\n const subscribe = {\n id,\n requests: readySubs.map(({ objectSet, requestedProperties }) => ({\n objectSet: objectSet,\n propertySet: requestedProperties,\n referenceSet: [],\n })),\n };\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: subscribe }, \"sending subscribe message\");\n }\n this.#ws?.send(JSON.stringify(subscribe));\n }\n #expire(sub) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ subscription: sub }, \"#expire()\");\n }\n // the temporary ObjectSet has expired, we should re-subscribe which will cause the\n // listener to get an onOutOfDate message when it becomes subscribed again\n sub.status = \"expired\";\n this.#initiateSubscribe(sub);\n }\n #unsubscribe(sub, newStatus = \"done\") {\n if (subscriptionIsDone(sub)) {\n // if we are already done, we don't need to do anything\n return;\n }\n sub.status = newStatus;\n // make sure listeners do nothing now\n sub.listener = fillOutListener({});\n if (sub.expiry) {\n clearTimeout(sub.expiry);\n sub.expiry = undefined;\n }\n this.#subscriptions.delete(sub.subscriptionId);\n // If we have no more subscriptions, we can disconnect the websocket\n // however we should wait a bit to see if we get any more subscriptions.\n // For example, when switching between react views, you may unsubscribe\n // in the old view and subscribe in the new view. We don't need to re-establish\n // the websocket connection in that case.\n if (this.#maybeDisconnectTimeout) {\n // We reset the timeout on every unsubscribe so its always at least 15s from\n // the last time we are empty. E.g.:\n // - 0s: Subscribe(A)\n // - 10s: Unsubscribe(A)\n // - 11s: Subscribe(B)\n // - 20s: Unsubscribe(B)\n // If we do not clear out the timeout we would disconnect at 25s but that would only be\n // 5s after the last subscription was removed instead of at 35s for the desired 15s.\n clearTimeout(this.#maybeDisconnectTimeout);\n }\n this.#maybeDisconnectTimeout = setTimeout(() => {\n this.#maybeDisconnectTimeout = undefined;\n if (this.#subscriptions.size === 0) {\n this.#cycleWebsocket();\n }\n }, 15_000 /* ms */);\n }\n async #ensureWebsocket() {\n if (this.#ws == null) {\n const { baseUrl, tokenProvider } = this.#client;\n const base = new URL(baseUrl);\n const url = `wss://${base.host}/api/v2/ontologySubscriptions/ontologies/${this.#client.ontologyRid}/streamSubscriptions`;\n const token = await tokenProvider();\n // tokenProvider is async, there could potentially be a race to create the websocket.\n // Only the first call to reach here will find a null this.#ws, the rest will bail out\n if (this.#ws == null) {\n // TODO this can probably be exponential backoff with jitter\n // don't reconnect more quickly than MINIMUM_RECONNECT_DELAY\n const nextConnectTime = (this.#lastWsConnect ?? 0)\n + this.MINIMUM_RECONNECT_DELAY_MS;\n if (nextConnectTime > Date.now()) {\n await new Promise((resolve) => {\n setTimeout(resolve, nextConnectTime - Date.now());\n });\n }\n this.#lastWsConnect = Date.now();\n // we again may have lost the race after our minimum backoff time\n if (this.#ws == null) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"Creating websocket\");\n }\n this.#ws = new WebSocket(url, [`Bearer-${token}`]);\n this.#ws.addEventListener(\"close\", this.#onClose);\n this.#ws.addEventListener(\"message\", this.#onMessage);\n this.#ws.addEventListener(\"open\", this.#onOpen);\n }\n }\n // Allow await-ing the websocket open event if it isn't open already.\n // This needs to happen even for callers that didn't just create this.#ws\n if (this.#ws.readyState === WebSocket.CONNECTING) {\n const ws = this.#ws;\n return new Promise((resolve, reject) => {\n function cleanup() {\n ws.removeEventListener(\"open\", open);\n ws.removeEventListener(\"error\", error);\n ws.removeEventListener(\"close\", cleanup);\n }\n function open() {\n cleanup();\n resolve();\n }\n function error(evt) {\n cleanup();\n reject(evt);\n }\n ws.addEventListener(\"open\", open);\n ws.addEventListener(\"error\", error);\n ws.addEventListener(\"close\", cleanup);\n });\n }\n }\n }\n #onOpen = () => {\n // resubscribe all of the listeners\n this.#sendSubscribeMessage();\n };\n #onMessage = async (message) => {\n const data = JSON.parse(message.data.toString());\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: data }, \"received message from ws\");\n }\n switch (data.type) {\n case \"objectSetChanged\":\n return this.#handleMessage_objectSetChanged(data);\n case \"refreshObjectSet\":\n return this.#handleMessage_refreshObjectSet(data);\n case \"subscribeResponses\":\n return this.#handleMessage_subscribeResponses(data);\n case \"subscriptionClosed\": {\n return this.#handleMessage_subscriptionClosed(data);\n }\n default:\n const _ = data;\n invariant(false, \"Unexpected message type\");\n }\n };\n #handleMessage_objectSetChanged = async (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n const objectUpdates = payload.updates.filter((update) => update.type === \"object\");\n const referenceUpdates = payload.updates.filter((update) => update.type === \"reference\");\n const osdkObjects = await Promise.all(objectUpdates.map(async (o) => {\n const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [o.object], undefined);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: o.state,\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjects) {\n if (osdkObject != null) {\n return sub.listener.onChange?.(osdkObject);\n }\n }\n };\n #handleMessage_refreshObjectSet = (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onOutOfDate();\n };\n #handleMessage_subscribeResponses = (payload) => {\n const { id, responses } = payload;\n const subs = this.#pendingSubscriptions.get(id);\n invariant(subs, `should have a pending subscription for ${id}`);\n this.#pendingSubscriptions.delete(id);\n for (let i = 0; i < responses.length; i++) {\n const sub = subs[i];\n const response = responses[i];\n switch (response.type) {\n case \"error\":\n sub.listener.onError(response.errors);\n this.#unsubscribe(sub, \"error\");\n break;\n case \"qos\":\n // the server has requested that we tear down our websocket and reconnect to help load balance\n this.#cycleWebsocket();\n break;\n case \"success\":\n // `\"preparing\"` should only be the status on an initial subscribe.\n const shouldFireOutOfDate = sub.status === \"expired\"\n || sub.status === \"reconnecting\";\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ shouldFireOutOfDate }, \"success\");\n }\n sub.status = \"subscribed\";\n if (sub.subscriptionId !== response.id) {\n // might be the temporary one\n this.#subscriptions.delete(sub.subscriptionId);\n sub.subscriptionId = response.id;\n this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId\n }\n if (shouldFireOutOfDate)\n sub.listener.onOutOfDate();\n break;\n default:\n const _ = response;\n sub.listener.onError(response);\n }\n }\n };\n #handleMessage_subscriptionClosed(payload) {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onError([payload.cause]);\n this.#unsubscribe(sub, \"error\");\n }\n #onClose = (event) => {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ event }, \"Received close event from ws\", event);\n }\n // TODO we should probably throttle this so we don't abuse the backend\n this.#cycleWebsocket();\n };\n // TODO: Validate if this is needed\n async #enableObjectSetsWatcher(objectTypeRids) {\n // return batchEnableWatcher(this.#oswContext, {\n // requests: objectTypeRids,\n // });\n return;\n }\n #cycleWebsocket = () => {\n if (this.#ws) {\n this.#ws.removeEventListener(\"open\", this.#onOpen);\n this.#ws.removeEventListener(\"message\", this.#onMessage);\n this.#ws.removeEventListener(\"close\", this.#onClose);\n if (this.#ws.readyState !== WebSocket.CLOSING\n && this.#ws.readyState !== WebSocket.CLOSED) {\n this.#ws.close();\n }\n this.#ws = undefined;\n }\n // if we have any listeners that are still depending on us, go ahead and reopen the websocket\n if (this.#subscriptions.size > 0) {\n if (process?.env?.NODE_ENV !== \"production\") {\n for (const s of this.#subscriptions.values()) {\n invariant(s.status !== \"done\" && s.status !== \"error\", \"should not have done/error subscriptions still\");\n }\n }\n for (const s of this.#subscriptions.values()) {\n if (s.status === \"subscribed\")\n s.status = \"reconnecting\";\n }\n this.#ensureWebsocket();\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,eAAe;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,wBAAwB,QAAQ,uCAAuC;AAChF,MAAMC,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;AACtC,MAAMC,0BAA0B,GAAG,CAAC,GAAG,IAAI;AAC3C;AACA,SAASC,SAASA,CAAA,EAAG,CAAE;AACvB;AACA;AACA;AACA,SAASC,eAAeA,CAAC;EAAEC,QAAQ,GAAGF,SAAS;EAAEG,OAAO,GAAGH,SAAS;EAAEI,WAAW,GAAGJ;AAAW,CAAC,EAAE;EAC9F,OAAO;IAAEE,QAAQ;IAAEC,OAAO;IAAEC;EAAY,CAAC;AAC7C;AACA,SAASC,OAAOA,CAACC,GAAG,EAAE;EAClB,OAAOA,GAAG,CAACD,OAAO,IAAI,IAAI;AAC9B;AACA,SAASE,kBAAkBA,CAACD,GAAG,EAAE;EAC7B,OAAOA,GAAG,CAACE,MAAM,KAAK,MAAM,IAAIF,GAAG,CAACE,MAAM,KAAK,OAAO;AAC1D;AACA;AACA,OAAO,MAAMC,0BAA0B,CAAC;EACpC,OAAO,CAAC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AAS,EAAE,IAAI,CAAC,CAACL,SAAS,CAAC;MACxD,IAAI,CAAC,CAAC7E,EAAE,CAACkF,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAACN,OAAO,CAAC;MACpD,IAAI,IAAI,CAAC,CAAC5E,EAAE,CAACqC,UAAU,KAAK7D,SAAS,CAAC8I,OAAO,IACtC,IAAI,CAAC,CAACtH,EAAE,CAACqC,UAAU,KAAK7D,SAAS,CAAC+I,MAAM,EAAE;QAC7C,IAAI,CAAC,CAACvH,EAAE,CAACwH,KAAK,CAAC,CAAC;MACpB;MACA,IAAI,CAAC,CAACxH,EAAE,GAAG2D,SAAS;IACxB;IACA;IACA,IAAI,IAAI,CAAC,CAACtD,aAAa,CAACwD,IAAI,GAAG,CAAC,EAAE;MAC9B,IAAIlC,OAAO,EAAEC,GAAG,EAAEC,QAAQ,KAAK,YAAY,EAAE;QACzC,KAAK,MAAM4F,CAAC,IAAI,IAAI,CAAC,CAACpH,aAAa,CAACsC,MAAM,CAAC,CAAC,EAAE;UAC1C,EAAU8E,CAAC,CAACpI,MAAM,KAAK,MAAM,IAAIoI,CAAC,CAACpI,MAAM,KAAK,OAAO,IAArDZ,SAAS,QAA8C,gDAAgD;QAC3G;MACJ;MACA,KAAK,MAAMgJ,CAAC,IAAI,IAAI,CAAC,CAACpH,aAAa,CAACsC,MAAM,CAAC,CAAC,EAAE;QAC1C,IAAI8E,CAAC,CAACpI,MAAM,KAAK,YAAY,EACzBoI,CAAC,CAACpI,MAAM,GAAG,cAAc;MACjC;MACA,IAAI,CAAC,CAAC+C,eAAe,CAAC,CAAC;IAC3B;EACJ,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectSetListenerWebsocket.js","names":["WebSocket","invariant","MINIMUM_RECONNECT_DELAY_MS","doNothing","fillOutListener","onChange","onError","onOutOfDate","onSuccessfulSubscription","isReady","sub","subscriptionIsDone","status","ObjectSetListenerWebsocket","instances","WeakMap","getInstance","client","instance","get","clientCacheKey","set","ws","lastWsConnect","logger","pendingSubscriptions","Map","subscriptions","endedSubscriptions","Set","maybeDisconnectTimeout","constructor","minimumReconnectDelayMs","child","msgPrefix","baseUrl","startsWith","process","env","NODE_ENV","subscribe","objectType","objectSet","listener","properties","objDef","type","ontologyProvider","getObjectDefinition","apiName","getInterfaceDefinition","objectProperties","referenceProperties","length","Object","keys","filter","p","primaryKeyPropertyName","undefined","primaryKeyApiName","requestedProperties","requestedReferenceProperties","subscriptionId","nextUuid","interfaceApiName","initiateSubscribe","unsubscribe","#initiateSubscribe","trace","ensureWebsocket","readyState","OPEN","sendSubscribeMessage","error","tryCatchOnError","#sendSubscribeMessage","readySubs","values","id","requests","map","propertySet","referenceSet","payload","send","JSON","stringify","#unsubscribe","newStatus","delete","add","clearTimeout","setTimeout","size","cycleWebsocket","#ensureWebsocket","tokenProvider","url","constructWebsocketUrl","ontologyRid","token","nextConnectTime","Date","now","Promise","resolve","addEventListener","onClose","onMessage","onOpen","CONNECTING","reject","cleanup","removeEventListener","open","evt","#onOpen","message","data","parse","toString","handleMessage_objectSetChanged","handleMessage_refreshObjectSet","handleMessage_subscribeResponses","handleMessage_subscriptionClosed","objectUpdates","updates","update","referenceUpdates","osdkObjectsWithReferenceUpdates","all","o","osdkObjectArray","objectFactory","__apiName","__primaryKey","primaryKey","property","value","singleOsdkObject","object","state","osdkObject","osdkObjects","keysToDelete","key","includes","responses","subs","i","response","errors","shouldFireOutOfDate","#handleMessage_subscriptionClosed","has","cause","event","#cycleWebsocket","CLOSING","CLOSED","close","s","#tryCatchOnError","subscriptionClosed","onErrorError","console","base","URL","protocol","replace","uuidCounter","padStart"],"sources":["ObjectSetListenerWebsocket.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport WebSocket from \"isomorphic-ws\";\nimport invariant from \"tiny-invariant\";\nconst MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;\n/** Noop function to reduce conditional checks */\nfunction doNothing() { }\n/**\n * Converts an ObjectSetListener to one where all the functions are defined.\n */\nfunction fillOutListener({ onChange = doNothing, onError = doNothing, onOutOfDate = doNothing, onSuccessfulSubscription = doNothing, }) {\n return { onChange, onError, onOutOfDate, onSuccessfulSubscription };\n}\nfunction isReady(sub) {\n return sub.isReady != null;\n}\nfunction subscriptionIsDone(sub) {\n return sub.status === \"done\" || sub.status === \"error\";\n}\n/** @internal */\nexport class ObjectSetListenerWebsocket {\n static #instances = new WeakMap();\n MINIMUM_RECONNECT_DELAY_MS;\n // FIXME\n static getInstance(client) {\n let instance = ObjectSetListenerWebsocket.#instances.get(client.clientCacheKey);\n if (instance == null) {\n instance = new ObjectSetListenerWebsocket(client);\n ObjectSetListenerWebsocket.#instances.set(client.clientCacheKey, instance);\n }\n return instance;\n }\n #ws;\n #lastWsConnect = 0;\n #client;\n #logger;\n /**\n * map of requestId to all active subscriptions at the time of the request\n */\n #pendingSubscriptions = new Map();\n /**\n * Map of subscriptionId to Subscription. Note: the subscriptionId may be\n * temporary and not the actual subscriptionId from the server.\n */\n #subscriptions = new Map();\n #endedSubscriptions = new Set();\n #maybeDisconnectTimeout;\n // DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM\n constructor(client, { minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS, } = {}) {\n this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;\n this.#client = client;\n this.#logger = client.logger?.child({}, {\n msgPrefix: \"<OSW> \",\n });\n invariant(client.baseUrl.startsWith(\"https://\")\n || client.baseUrl.startsWith(\"http://\"), \"Stack must be a URL\");\n }\n async subscribe(objectType, objectSet, listener, properties = []) {\n const objDef = objectType.type === \"object\"\n ? await this.#client.ontologyProvider.getObjectDefinition(objectType.apiName)\n : await this.#client.ontologyProvider.getInterfaceDefinition(objectType.apiName);\n let objectProperties = [];\n let referenceProperties = [];\n if (objectType.type === \"object\") {\n if (properties.length === 0) {\n properties = Object.keys(objDef.properties);\n }\n objectProperties = properties.filter((p) => objDef.properties[p].type !== \"geotimeSeriesReference\");\n referenceProperties = properties.filter((p) => objDef.properties[p].type === \"geotimeSeriesReference\");\n }\n else {\n objectProperties = [];\n referenceProperties = properties;\n }\n const sub = {\n listener: fillOutListener(listener),\n objectSet,\n primaryKeyPropertyName: objDef.type === \"interface\"\n ? undefined\n : objDef.primaryKeyApiName,\n requestedProperties: objectProperties,\n requestedReferenceProperties: referenceProperties,\n status: \"preparing\",\n // Since we don't have a real subscription id yet but we need to keep\n // track of this reference, we can just use a random uuid.\n subscriptionId: `TMP-${nextUuid()}}`,\n interfaceApiName: objDef.type === \"object\"\n ? undefined\n : objDef.apiName,\n };\n this.#subscriptions.set(sub.subscriptionId, sub);\n // actually prepares the subscription, ensures the ws is ready, and sends\n // a subscribe message. We don't want to block on this.\n this.#initiateSubscribe(sub);\n return () => {\n this.#unsubscribe(sub);\n };\n }\n /**\n * Called at least once for every subscription.\n *\n * - Resets pending expiry\n * - Recreates temporary object set\n * - Triggers a full subscribe message\n *\n * @returns\n */\n async #initiateSubscribe(sub) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#initiateSubscribe()\");\n }\n try {\n await this.#ensureWebsocket();\n // the consumer may have already unsubscribed before we are ready to request a subscription\n // so we have to acquire the pendingSubscription after the await.\n if (subscriptionIsDone(sub)) {\n return;\n }\n sub.isReady = true;\n // if we aren't open, then this happens after we #onConnect\n if (this.#ws?.readyState === WebSocket.OPEN) {\n this.#sendSubscribeMessage();\n }\n }\n catch (error) {\n this.#logger?.error(error, \"Error in #initiateSubscribe\");\n this.#tryCatchOnError(sub, true, error);\n }\n }\n #sendSubscribeMessage() {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage()\");\n }\n // If two calls to `.subscribe()` happen at once (or if the connection is reset),\n // we may have multiple subscriptions that don't have a subscriptionId yet,\n // so we filter those out.\n const readySubs = [...this.#subscriptions.values()].filter(isReady);\n const id = nextUuid();\n // responses come back as an array of subIds, so we need to know the sources\n this.#pendingSubscriptions.set(id, readySubs);\n // every subscribe message \"overwrites\" the previous ones that are not\n // re-included, so we have to reconstitute the entire list of subscriptions\n const subscribe = {\n id,\n requests: readySubs.map(({ objectSet, requestedProperties, requestedReferenceProperties, interfaceApiName, }) => {\n return {\n objectSet: objectSet,\n propertySet: requestedProperties,\n referenceSet: requestedReferenceProperties,\n };\n }),\n };\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: subscribe }, \"sending subscribe message\");\n }\n this.#ws?.send(JSON.stringify(subscribe));\n }\n #unsubscribe(sub, newStatus = \"done\") {\n if (subscriptionIsDone(sub)) {\n // if we are already done, we don't need to do anything\n return;\n }\n sub.status = newStatus;\n // make sure listeners do nothing now\n sub.listener = fillOutListener({});\n this.#subscriptions.delete(sub.subscriptionId);\n this.#endedSubscriptions.add(sub.subscriptionId);\n this.#sendSubscribeMessage();\n // If we have no more subscriptions, we can disconnect the websocket\n // however we should wait a bit to see if we get any more subscriptions.\n // For example, when switching between react views, you may unsubscribe\n // in the old view and subscribe in the new view. We don't need to re-establish\n // the websocket connection in that case.\n if (this.#maybeDisconnectTimeout) {\n // We reset the timeout on every unsubscribe so its always at least 15s from\n // the last time we are empty. E.g.:\n // - 0s: Subscribe(A)\n // - 10s: Unsubscribe(A)\n // - 11s: Subscribe(B)\n // - 20s: Unsubscribe(B)\n // If we do not clear out the timeout we would disconnect at 25s but that would only be\n // 5s after the last subscription was removed instead of at 35s for the desired 15s.\n clearTimeout(this.#maybeDisconnectTimeout);\n }\n this.#maybeDisconnectTimeout = setTimeout(() => {\n this.#maybeDisconnectTimeout = undefined;\n if (this.#subscriptions.size === 0) {\n this.#cycleWebsocket();\n }\n }, 15_000 /* ms */);\n }\n async #ensureWebsocket() {\n if (this.#ws == null) {\n const { baseUrl, tokenProvider } = this.#client;\n const url = constructWebsocketUrl(baseUrl, this.#client.ontologyRid);\n const token = await tokenProvider();\n // tokenProvider is async, there could potentially be a race to create the websocket.\n // Only the first call to reach here will find a null this.#ws, the rest will bail out\n if (this.#ws == null) {\n // TODO this can probably be exponential backoff with jitter\n // don't reconnect more quickly than MINIMUM_RECONNECT_DELAY\n const nextConnectTime = (this.#lastWsConnect ?? 0)\n + this.MINIMUM_RECONNECT_DELAY_MS;\n if (nextConnectTime > Date.now()) {\n await new Promise((resolve) => {\n setTimeout(resolve, nextConnectTime - Date.now());\n });\n }\n this.#lastWsConnect = Date.now();\n // we again may have lost the race after our minimum backoff time\n if (this.#ws == null) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"Creating websocket\");\n }\n this.#ws = new WebSocket(url, [`Bearer-${token}`]);\n this.#ws.addEventListener(\"close\", this.#onClose);\n this.#ws.addEventListener(\"message\", this.#onMessage);\n this.#ws.addEventListener(\"open\", this.#onOpen);\n }\n }\n // Allow await-ing the websocket open event if it isn't open already.\n // This needs to happen even for callers that didn't just create this.#ws\n if (this.#ws.readyState === WebSocket.CONNECTING) {\n const ws = this.#ws;\n return new Promise((resolve, reject) => {\n function cleanup() {\n ws.removeEventListener(\"open\", open);\n ws.removeEventListener(\"error\", error);\n ws.removeEventListener(\"close\", cleanup);\n }\n function open() {\n cleanup();\n resolve();\n }\n function error(evt) {\n cleanup();\n reject(evt);\n }\n ws.addEventListener(\"open\", open);\n ws.addEventListener(\"error\", error);\n ws.addEventListener(\"close\", cleanup);\n });\n }\n }\n }\n #onOpen = () => {\n // resubscribe all of the listeners\n this.#sendSubscribeMessage();\n };\n #onMessage = async (message) => {\n const data = JSON.parse(message.data.toString());\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: data }, \"received message from ws\");\n }\n switch (data.type) {\n case \"objectSetChanged\":\n return this.#handleMessage_objectSetChanged(data);\n case \"refreshObjectSet\":\n return this.#handleMessage_refreshObjectSet(data);\n case \"subscribeResponses\":\n return this.#handleMessage_subscribeResponses(data);\n case \"subscriptionClosed\": {\n return this.#handleMessage_subscriptionClosed(data);\n }\n default:\n const _ = data;\n invariant(false, \"Unexpected message type\");\n }\n };\n #handleMessage_objectSetChanged = async (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n if (sub == null)\n return;\n const objectUpdates = payload.updates.filter((update) => update.type === \"object\");\n const referenceUpdates = payload.updates.filter((update) => update.type === \"reference\");\n const osdkObjectsWithReferenceUpdates = await Promise.all(referenceUpdates.map(async (o) => {\n const osdkObjectArray = await this.#client.objectFactory(this.#client, [{\n __apiName: o.objectType,\n __primaryKey: sub.primaryKeyPropertyName != null\n ? o.primaryKey[sub.primaryKeyPropertyName]\n : undefined,\n ...o.primaryKey,\n [o.property]: o.value,\n }], sub.interfaceApiName);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: \"ADDED_OR_UPDATED\",\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjectsWithReferenceUpdates) {\n if (osdkObject != null) {\n try {\n sub.listener.onChange?.(osdkObject);\n }\n catch (error) {\n this.#logger?.error(error, \"Error in onChange callback\");\n this.#tryCatchOnError(sub, false, error);\n }\n }\n }\n const osdkObjects = await Promise.all(objectUpdates.map(async (o) => {\n const keysToDelete = Object.keys(o.object).filter((key) => sub.requestedReferenceProperties.includes(key));\n for (const key of keysToDelete) {\n delete o.object[key];\n }\n const osdkObjectArray = await this.#client.objectFactory(this.#client, [o.object], sub.interfaceApiName);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: o.state,\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjects) {\n if (osdkObject != null) {\n try {\n sub.listener.onChange?.(osdkObject);\n }\n catch (error) {\n this.#logger?.error(error, \"Error in onChange callback\");\n this.#tryCatchOnError(sub, false, error);\n }\n }\n }\n };\n #handleMessage_refreshObjectSet = (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n try {\n sub.listener.onOutOfDate();\n }\n catch (error) {\n this.#logger?.error(error, \"Error in onOutOfDate callback\");\n this.#tryCatchOnError(sub, false, error);\n }\n };\n #handleMessage_subscribeResponses = (payload) => {\n const { id, responses } = payload;\n const subs = this.#pendingSubscriptions.get(id);\n invariant(subs, `should have a pending subscription for ${id}`);\n this.#pendingSubscriptions.delete(id);\n for (let i = 0; i < responses.length; i++) {\n const sub = subs[i];\n const response = responses[i];\n switch (response.type) {\n case \"error\":\n this.#tryCatchOnError(sub, true, response.errors);\n this.#unsubscribe(sub, \"error\");\n break;\n case \"qos\":\n // the server has requested that we tear down our websocket and reconnect to help load balance\n this.#cycleWebsocket();\n break;\n case \"success\":\n // `\"preparing\"` should only be the status on an initial subscribe.\n const shouldFireOutOfDate = sub.status === \"expired\"\n || sub.status === \"reconnecting\";\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ shouldFireOutOfDate }, \"success\");\n }\n sub.status = \"subscribed\";\n if (sub.subscriptionId !== response.id) {\n // might be the temporary one\n this.#subscriptions.delete(sub.subscriptionId);\n sub.subscriptionId = response.id;\n this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId\n }\n try {\n if (shouldFireOutOfDate)\n sub.listener.onOutOfDate();\n else\n sub.listener.onSuccessfulSubscription();\n }\n catch (error) {\n this.#logger?.error(error, \"Error in onOutOfDate or onSuccessfulSubscription callback\");\n this.#tryCatchOnError(sub, false, error);\n }\n break;\n default:\n this.#tryCatchOnError(sub, true, response);\n }\n }\n };\n #handleMessage_subscriptionClosed(payload) {\n const sub = this.#subscriptions.get(payload.id);\n if (sub == null && this.#endedSubscriptions.has(payload.id))\n return;\n invariant(sub, `Expected subscription id ${payload.id}`);\n this.#tryCatchOnError(sub, true, payload.cause);\n this.#unsubscribe(sub, \"error\");\n }\n #onClose = (event) => {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ event }, \"Received close event from ws\", event);\n }\n // TODO we should probably throttle this so we don't abuse the backend\n this.#cycleWebsocket();\n };\n #cycleWebsocket = () => {\n if (this.#ws) {\n this.#ws.removeEventListener(\"open\", this.#onOpen);\n this.#ws.removeEventListener(\"message\", this.#onMessage);\n this.#ws.removeEventListener(\"close\", this.#onClose);\n if (this.#ws.readyState !== WebSocket.CLOSING\n && this.#ws.readyState !== WebSocket.CLOSED) {\n this.#ws.close();\n }\n this.#ws = undefined;\n }\n // if we have any listeners that are still depending on us, go ahead and reopen the websocket\n if (this.#subscriptions.size > 0) {\n if (process.env.NODE_ENV !== \"production\") {\n for (const s of this.#subscriptions.values()) {\n invariant(s.status !== \"done\" && s.status !== \"error\", \"should not have done/error subscriptions still\");\n }\n }\n for (const s of this.#subscriptions.values()) {\n if (s.status === \"subscribed\")\n s.status = \"reconnecting\";\n }\n this.#ensureWebsocket();\n }\n };\n #tryCatchOnError = (sub, subscriptionClosed, error) => {\n try {\n sub.listener.onError({ subscriptionClosed: subscriptionClosed, error });\n }\n catch (onErrorError) {\n // eslint-disable-next-line no-console\n console.error(`Error encountered in an onError callback for an OSDK subscription`, onErrorError);\n // eslint-disable-next-line no-console\n console.error(`This onError call was triggered by an error in another callback`, error);\n // eslint-disable-next-line no-console\n console.error(`The subscription has been closed.`, error);\n if (!subscriptionClosed) {\n this.#logger?.error(error, \"Error in onError callback\");\n this.#unsubscribe(sub, \"error\");\n this.#tryCatchOnError(sub, true, onErrorError);\n }\n }\n };\n}\n/** @internal */\nexport function constructWebsocketUrl(baseUrl, ontologyRid) {\n const base = new URL(baseUrl);\n const url = new URL(`api/v2/ontologySubscriptions/ontologies/${ontologyRid}/streamSubscriptions`, base);\n url.protocol = url.protocol.replace(\"https\", \"wss\");\n return url;\n}\nlet uuidCounter = 0;\nfunction nextUuid() {\n return `00000000-0000-0000-0000-${(uuidCounter++).toString().padStart(12, \"0\")}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,eAAe;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,MAAMC,0BAA0B,GAAG,CAAC,GAAG,IAAI;AAC3C;AACA,SAASC,SAASA,CAAA,EAAG,CAAE;AACvB;AACA;AACA;AACA,SAASC,eAAeA,CAAC;EAAEC,QAAQ,GAAGF,SAAS;EAAEG,OAAO,GAAGH,SAAS;EAAEI,WAAW,GAAGJ,SAAS;EAAEK,wBAAwB,GAAGL;AAAW,CAAC,EAAE;EACpI,OAAO;IAAEE,QAAQ;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAyB,CAAC;AACvE;AACA,SAASC,OAAOA,CAACC,GAAG,EAAE;EAClB,OAAOA,GAAG,CAACD,OAAO,IAAI,IAAI;AAC9B;AACA,SAASE,kBAAkBA,CAACD,GAAG,EAAE;EAC7B,OAAOA,GAAG,CAACE,MAAM,KAAK,MAAM,IAAIF,GAAG,CAACE,MAAM,KAAK,OAAO;AAC1D;AACA;AACA,OAAO,MAAMC,0BAA0B,CAAC;EACpC,OAAO,CAACC,SAAS,GAAG,IAAIC,OAAO,CAAC,CAAC;EACjCb,0BAA0B;EAC1B;EACA,OAAOc,WAAWA,CAACC,MAAM,EAAE;IACvB,IAAIC,QAAQ,GAAGL,0BAA0B,CAAC,CAACC,SAAS,CAACK,GAAG,CAACF,MAAM,CAACG,cAAc,CAAC;IAC/E,IAAIF,QAAQ,IAAI,IAAI,EAAE;MAClBA,QAAQ,GAAG,IAAIL,0BAA0B,CAACI,MAAM,CAAC;MACjDJ,0BAA0B,CAAC,CAACC,SAAS,CAACO,GAAG,CAACJ,MAAM,CAACG,c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