@osdk/client 2.0.2-rc.3 → 2.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -46
- package/build/browser/Client.d.ts +1 -1
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/browser/createClient.d.ts.map +1 -1
- package/build/browser/createClient.js +11 -0
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/browser/object/fetchSingle.js +1 -1
- package/build/browser/object/fetchSingle.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
- package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +37 -156
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +2 -2
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/esm/Client.d.ts +1 -1
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/esm/createClient.d.ts.map +1 -1
- package/build/esm/createClient.js +11 -0
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/esm/object/fetchSingle.js +1 -1
- package/build/esm/object/fetchSingle.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
- package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +37 -156
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +2 -2
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,56 +1,27 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
-
## 2.0
|
|
3
|
+
## 2.1.0-beta.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- 4c5e0ae: Fix queries that have response types with nested values, like arrays.
|
|
8
|
-
- ba1c42a: Fixing proxy handlers.
|
|
9
|
-
- Updated dependencies [4c5e0ae]
|
|
10
|
-
- @osdk/api@2.0.2-rc.3
|
|
11
|
-
- @osdk/generator-converters@2.0.2-rc.3
|
|
12
|
-
- @osdk/client.unstable@2.0.2-rc.3
|
|
13
|
-
|
|
14
|
-
## 2.0.2-beta.2
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- 51354c5: Fixes where clauses when objects have an api namespace
|
|
19
|
-
- 51354c5: Locks dependency version of 3 internal libraries
|
|
20
|
-
- Updated dependencies [51354c5]
|
|
21
|
-
- @osdk/generator-converters@2.0.2-beta.2
|
|
22
|
-
- @osdk/client.unstable@2.0.2-beta.2
|
|
23
|
-
- @osdk/api@2.0.2-beta.2
|
|
24
|
-
|
|
25
|
-
## 2.0.2-beta.1
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- 135bddc: improves interface api name mapping with api namespaces
|
|
30
|
-
- @osdk/generator-converters@2.0.2-beta.1
|
|
31
|
-
- @osdk/client.unstable@2.0.2-beta.1
|
|
32
|
-
- @osdk/api@2.0.2-beta.1
|
|
33
|
-
|
|
34
|
-
## 2.0.2-rc.0
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- @osdk/generator-converters@2.0.2-rc.0
|
|
39
|
-
- @osdk/client.unstable@2.0.2-rc.0
|
|
40
|
-
- @osdk/api@2.0.2-rc.0
|
|
5
|
+
### Minor Changes
|
|
41
6
|
|
|
42
|
-
|
|
7
|
+
- 0dc40b0: Switch to OSDK.Instance
|
|
8
|
+
- d927a1d: Throws error in createClient when passed an invalid ontology RID
|
|
9
|
+
- d464009: improves interface api name mapping with api namespaces
|
|
10
|
+
- 8eb2378: Fixes where clauses when objects have an api namespace
|
|
11
|
+
- e548b9b: Updates subscribe to return object updates
|
|
12
|
+
- 5e78575: Fix queries that have response types with nested values, like arrays.
|
|
13
|
+
- 9af346e: Fixing proxy handlers.
|
|
14
|
+
- c682504: Locks dependency version of 3 internal libraries
|
|
43
15
|
|
|
44
16
|
### Patch Changes
|
|
45
17
|
|
|
46
|
-
- Updated dependencies [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- @osdk/
|
|
51
|
-
- @osdk/generator-converters@2.0.
|
|
52
|
-
- @osdk/
|
|
53
|
-
- @osdk/client.unstable@2.0.1
|
|
18
|
+
- Updated dependencies [0dc40b0]
|
|
19
|
+
- Updated dependencies [03e1941]
|
|
20
|
+
- Updated dependencies [e548b9b]
|
|
21
|
+
- Updated dependencies [c682504]
|
|
22
|
+
- @osdk/api@2.1.0-beta.0
|
|
23
|
+
- @osdk/generator-converters@2.1.0-beta.0
|
|
24
|
+
- @osdk/client.unstable@2.1.0-beta.0
|
|
54
25
|
|
|
55
26
|
## 2.0.0
|
|
56
27
|
|
|
@@ -32,7 +32,7 @@ export interface Client extends SharedClient<MinimalClient> {
|
|
|
32
32
|
*/
|
|
33
33
|
readonly [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: <T extends ObjectOrInterfaceDefinition>(objs: Osdk<T>[], links: string[]) => AsyncGenerator<BulkLinkResult, void, undefined>;
|
|
34
34
|
}
|
|
35
|
-
declare const MaxOsdkVersion = "2.0
|
|
35
|
+
declare const MaxOsdkVersion = "2.1.0";
|
|
36
36
|
export type MaxOsdkVersion = typeof MaxOsdkVersion;
|
|
37
37
|
declare const ErrorMessage: unique symbol;
|
|
38
38
|
export {};
|
package/build/browser/Client.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
17
|
-
const MaxOsdkVersion = "2.0
|
|
17
|
+
const MaxOsdkVersion = "2.1.0";
|
|
18
18
|
const ErrorMessage = Symbol("ErrorMessage");
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=Client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.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 */\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.0
|
|
1
|
+
{"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.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 */\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.1.0\";\nconst ErrorMessage = Symbol(\"ErrorMessage\");\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,OAAO;AAC9B,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OsdkBase } from "@osdk/api";
|
|
2
2
|
import type { MinimalClient } from "../MinimalClientContext.js";
|
|
3
3
|
export interface BulkLinkResult {
|
|
4
|
-
object:
|
|
4
|
+
object: OsdkBase<any>;
|
|
5
5
|
linkApiName: string;
|
|
6
6
|
otherObjectApiName: string | undefined;
|
|
7
7
|
otherObjectPk: unknown;
|
|
8
8
|
}
|
|
9
|
-
export declare function createBulkLinksAsyncIterFactory(ctx: MinimalClient): (objs: Array<
|
|
9
|
+
export declare function createBulkLinksAsyncIterFactory(ctx: MinimalClient): (objs: Array<OsdkBase<any>>, linkTypes: string[]) => AsyncGenerator<BulkLinkResult, void, unknown>;
|
|
10
10
|
//# sourceMappingURL=createBulkLinksAsyncIterFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBulkLinksAsyncIterFactory.d.ts","sourceRoot":"","sources":["../../../src/__unstable/createBulkLinksAsyncIterFactory.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"createBulkLinksAsyncIterFactory.d.ts","sourceRoot":"","sources":["../../../src/__unstable/createBulkLinksAsyncIterFactory.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAS1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAUhE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,aAAa,UAExD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,aACf,MAAM,EAAE,KAClB,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CA8GjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../src/createClient.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../src/createClient.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqJ1C,eAAO,MAAM,YAAY,gFAzGF,OAAO,CAAC,MAAM,CAAC;aAChB,MAAM;4DA2G3B,CAAC"}
|
|
@@ -43,6 +43,17 @@ class QueryInvoker {
|
|
|
43
43
|
export function createClientInternal(objectSetFactory,
|
|
44
44
|
// first so i can bind
|
|
45
45
|
baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
|
|
46
|
+
if (typeof ontologyRid === "string") {
|
|
47
|
+
if (!ontologyRid.startsWith("ri.")) {
|
|
48
|
+
throw new Error("Invalid ontology RID");
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
ontologyRid.then(ontologyRid => {
|
|
52
|
+
if (!ontologyRid.startsWith("ri.")) {
|
|
53
|
+
throw new Error("Invalid ontology RID");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
46
57
|
const clientCtx = createMinimalClient({
|
|
47
58
|
ontologyRid
|
|
48
59
|
}, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet","symbolClientContext","createBulkLinksAsyncIterFactory","applyAction","createMinimalClient","fetchMetadataInternal","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","fetchMetadata","client","Object","defineProperties","o","type","
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet","symbolClientContext","createBulkLinksAsyncIterFactory","applyAction","createMinimalClient","fetchMetadataInternal","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","value","get","definition","rid","objectSets","objectType","apiName","reference","createClient"],"sources":["createClient.js"],"sourcesContent":["/*\n * Copyright 2024 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 { __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks, __EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet, } from \"@osdk/api/unstable\";\nimport { symbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nclass ActionInvoker {\n constructor(clientCtx, actionDef) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n applyAction;\n batchApplyAction;\n}\nclass QueryInvoker {\n constructor(clientCtx, queryDef) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n executeFunction;\n}\n/** @internal */\nexport function createClientInternal(objectSetFactory, // first so i can bind\nbaseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n }\n else {\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n const clientCtx = createMinimalClient({ ontologyRid }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);\n function clientFn(o) {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx);\n }\n else if (o.type === \"action\") {\n return new ActionInvoker(clientCtx, o); // then as any for dealing with the conditional return value\n }\n else if (o.type === \"query\") {\n return new QueryInvoker(clientCtx, o);\n }\n else {\n throw new Error(\"not implemented\");\n }\n }\n const fetchMetadata = fetchMetadataInternal.bind(undefined, clientCtx);\n const client = Object.defineProperties(clientFn, {\n [symbolClientContext]: {\n value: clientCtx,\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: {\n get: () => createBulkLinksAsyncIterFactory(clientCtx),\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet]: {\n get: () => (definition, rid) => {\n return createObjectSet(definition, client[symbolClientContext], {\n type: \"intersect\",\n objectSets: [\n {\n type: \"base\",\n objectType: definition.apiName,\n },\n {\n type: \"reference\",\n reference: rid,\n },\n ],\n });\n },\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n });\n return client;\n}\nexport const createClient = createClientInternal.bind(undefined, createObjectSet);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,+CAA+C,EAAEC,uDAAuD,QAAS,oBAAoB;AAC9I,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,+BAA+B,QAAQ,iDAAiD;AACjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,UAAU,QAAQ,yBAAyB;AACpD,MAAMC,aAAa,CAAC;EAChBC,WAAWA,CAACC,SAAS,EAAEC,SAAS,EAAE;IAC9B;IACA;IACA;IACA;IACA,IAAI,CAACR,WAAW,GAAGA,WAAW,CAACS,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGX,WAAW,CAACS,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;EAC7E;EACAR,WAAW;EACXW,gBAAgB;AACpB;AACA,MAAMC,YAAY,CAAC;EACfN,WAAWA,CAACC,SAAS,EAAEM,QAAQ,EAAE;IAC7B,IAAI,CAACC,eAAe,GAAGV,UAAU,CAACK,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEM,QAAQ,CAAC;EAC1E;EACAC,eAAe;AACnB;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,gBAAgB;AAAE;AACvDC,OAAO,EAAEC,WAAW,EAAEC,aAAa,EAAEC,OAAO,GAAGV,SAAS,EAAEW,OAAO,GAAGC,KAAK,EAAE;EACvE,IAAI,OAAOJ,WAAW,KAAK,QAAQ,EAAE;IACjC,IAAI,CAACA,WAAW,CAACK,UAAU,CAAC,KAAK,CAAC,EAAE;MAChC,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IAC3C;EACJ,CAAC,MACI;IACDN,WAAW,CAACO,IAAI,CAAEP,WAAW,IAAK;MAC9B,IAAI,CAACA,WAAW,CAACK,UAAU,CAAC,KAAK,CAAC,EAAE;QAChC,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;MAC3C;IACJ,CAAC,CAAC;EACN;EACA,MAAMjB,SAAS,GAAGN,mBAAmB,CAAC;IAAEiB;EAAY,CAAC,EAAED,OAAO,EAAEE,aAAa,EAAEC,OAAO,EAAEC,OAAO,EAAEL,gBAAgB,CAAC;EAelH,MAAMU,aAAa,GAAGxB,qBAAqB,CAACO,IAAI,CAACC,SAAS,EAAEH,SAAS,CAAC;EACtE,MAAMoB,MAAM,GAAGC,MAAM,CAACC,gBAAgB,CAftC,UAAkBC,CAAC,EAAE;IACjB,IAAIA,CAAC,CAACC,IAAI,KAAK,QAAQ,IAAID,CAAC,CAACC,IAAI,KAAK,WAAW,EAAE;MAC/C,OAAOf,gBAAgB,CAACc,CAAC,EAAEvB,SAAS,CAAC;IACzC,CAAC,MACI,IAAIuB,CAAC,CAACC,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO,IAAI1B,aAAa,CAACE,SAAS,EAAEuB,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC,MACI,IAAIA,CAAC,CAACC,IAAI,KAAK,OAAO,EAAE;MACzB,OAAO,IAAInB,YAAY,CAACL,SAAS,EAAEuB,CAAC,CAAC;IACzC,CAAC,MACI;MACD,MAAM,IAAIN,KAAK,CAAC,iBAAiB,CAAC;IACtC;EACJ,CAAC,EAEgD;IAC7C,CAAC1B,mBAAmB,GAAG;MACnBkC,KAAK,EAAEzB;IACX,CAAC;IACD,CAACX,+CAA+C,GAAG;MAC/CqC,GAAG,EAAEA,CAAA,KAAMlC,+BAA+B,CAACQ,SAAS;IACxD,CAAC;IACD,CAACV,uDAAuD,GAAG;MACvDoC,GAAG,EAAEA,CAAA,KAAM,CAACC,UAAU,EAAEC,GAAG,KAAK;QAC5B,OAAOhC,eAAe,CAAC+B,UAAU,EAAEP,MAAM,CAAC7B,mBAAmB,CAAC,EAAE;UAC5DiC,IAAI,EAAE,WAAW;UACjBK,UAAU,EAAE,CACR;YACIL,IAAI,EAAE,MAAM;YACZM,UAAU,EAAEH,UAAU,CAACI;UAC3B,CAAC,EACD;YACIP,IAAI,EAAE,WAAW;YACjBQ,SAAS,EAAEJ;UACf,CAAC;QAET,CAAC,CAAC;MACN;IACJ,CAAC;IACDT,aAAa,EAAE;MACXM,KAAK,EAAEN;IACX;EACJ,CAAC,CAAC;EACF,OAAOC,MAAM;AACjB;AACA,OAAO,MAAMa,YAAY,GAAGzB,oBAAoB,CAACN,IAAI,CAACC,SAAS,EAAEP,eAAe,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectOrInterfaceDefinition,
|
|
1
|
+
import type { ObjectOrInterfaceDefinition, OsdkBase } from "@osdk/api";
|
|
2
2
|
export declare const UnderlyingOsdkObject: unique symbol;
|
|
3
3
|
export declare const ObjectDefRef: unique symbol;
|
|
4
4
|
export declare const InterfaceDefRef: unique symbol;
|
|
@@ -6,7 +6,7 @@ export declare const InterfaceDefRef: unique symbol;
|
|
|
6
6
|
export declare const RawObject: unique symbol;
|
|
7
7
|
export declare const ClientRef: unique symbol;
|
|
8
8
|
export interface HolderBase<T extends ObjectOrInterfaceDefinition> {
|
|
9
|
-
[UnderlyingOsdkObject]:
|
|
9
|
+
[UnderlyingOsdkObject]: OsdkBase<any>;
|
|
10
10
|
[ObjectDefRef]?: T;
|
|
11
11
|
[InterfaceDefRef]?: T;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSymbols.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/InternalSymbols.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"InternalSymbols.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/InternalSymbols.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEvE,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,eAAO,MAAM,YAAY,eAExB,CAAC;AAEF,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,SAAS,eAErB,CAAC;AAEF,eAAO,MAAM,SAAS,eAErB,CAAC;AAEF,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,2BAA2B;IAC/D,CAAC,oBAAoB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;CACvB"}
|
|
@@ -19,7 +19,7 @@ import { fetchPage } from "./fetchPage.js";
|
|
|
19
19
|
export async function fetchSingle(client, objectType, args, objectSet) {
|
|
20
20
|
const result = await fetchPage(client, objectType, {
|
|
21
21
|
...args,
|
|
22
|
-
pageSize: 1
|
|
22
|
+
$pageSize: 1
|
|
23
23
|
}, objectSet);
|
|
24
24
|
if (result.data.length !== 1 || result.nextPageToken != null) {
|
|
25
25
|
throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSingle.js","names":["PalantirApiError","fetchPage","fetchSingle","client","objectType","args","objectSet","result","pageSize","data","length","nextPageToken","fetchSingleWithErrors","value","e","Error","error"],"sources":["fetchSingle.js"],"sourcesContent":["/*\n * Copyright 2024 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 { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { fetchPage } from \"./fetchPage.js\";\n/** @internal */\nexport async function fetchSingle(client, objectType, args, objectSet) {\n const result = await fetchPage(client, objectType, { ...args, pageSize: 1 }, objectSet);\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\n}\n/** @internal */\nexport async function fetchSingleWithErrors(client, objectType, args, objectSet) {\n try {\n const result = await fetchSingle(client, objectType, args, objectSet);\n return { value: result };\n }\n catch (e) {\n if (e instanceof Error) {\n return { error: e };\n }\n return { error: e };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAC1C;AACA,OAAO,eAAeC,WAAWA,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EACnE,MAAMC,MAAM,GAAG,MAAMN,SAAS,CAACE,MAAM,EAAEC,UAAU,EAAE;IAAE,GAAGC,IAAI;IAAEG,
|
|
1
|
+
{"version":3,"file":"fetchSingle.js","names":["PalantirApiError","fetchPage","fetchSingle","client","objectType","args","objectSet","result","$pageSize","data","length","nextPageToken","fetchSingleWithErrors","value","e","Error","error"],"sources":["fetchSingle.js"],"sourcesContent":["/*\n * Copyright 2024 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 { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { fetchPage } from \"./fetchPage.js\";\n/** @internal */\nexport async function fetchSingle(client, objectType, args, objectSet) {\n const result = await fetchPage(client, objectType, { ...args, $pageSize: 1 }, objectSet);\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\n}\n/** @internal */\nexport async function fetchSingleWithErrors(client, objectType, args, objectSet) {\n try {\n const result = await fetchSingle(client, objectType, args, objectSet);\n return { value: result };\n }\n catch (e) {\n if (e instanceof Error) {\n return { error: e };\n }\n return { error: e };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAC1C;AACA,OAAO,eAAeC,WAAWA,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EACnE,MAAMC,MAAM,GAAG,MAAMN,SAAS,CAACE,MAAM,EAAEC,UAAU,EAAE;IAAE,GAAGC,IAAI;IAAEG,SAAS,EAAE;EAAE,CAAC,EAAEF,SAAS,CAAC;EACxF,IAAIC,MAAM,CAACE,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIH,MAAM,CAACI,aAAa,IAAI,IAAI,EAAE;IAC1D,MAAM,IAAIX,gBAAgB,CAAC,oCAAoCO,MAAM,CAACE,IAAI,CAACC,MAAM,WAAWH,MAAM,CAACI,aAAa,IAAI,IAAI,GAAG,yBAAyB,GAAG,EAAE,EAAE,CAAC;EAChK;EACA,OAAOJ,MAAM,CAACE,IAAI,CAAC,CAAC,CAAC;AACzB;AACA;AACA,OAAO,eAAeG,qBAAqBA,CAACT,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EAC7E,IAAI;IACA,MAAMC,MAAM,GAAG,MAAML,WAAW,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,CAAC;IACrE,OAAO;MAAEO,KAAK,EAAEN;IAAO,CAAC;EAC5B,CAAC,CACD,OAAOO,CAAC,EAAE;IACN,IAAIA,CAAC,YAAYC,KAAK,EAAE;MACpB,OAAO;QAAEC,KAAK,EAAEF;MAAE,CAAC;IACvB;IACA,OAAO;MAAEE,KAAK,EAAEF;IAAE,CAAC;EACvB;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSetListenerWebsocket.d.ts","sourceRoot":"","sources":["../../../src/objectSet/ObjectSetListenerWebsocket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ObjectSetListenerWebsocket.d.ts","sourceRoot":"","sources":["../../../src/objectSet/ObjectSetListenerWebsocket.ts"],"names":[],"mappings":""}
|
|
@@ -13,14 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { bulkLoadOntologyEntities, createTemporaryObjectSet, loadAllOntologies } from "@osdk/client.unstable";
|
|
17
|
-
import { batchEnableWatcher } from "@osdk/client.unstable.osw";
|
|
18
|
-
import * as OntologiesV2 from "@osdk/internal.foundry.ontologiesv2";
|
|
19
16
|
import WebSocket from "isomorphic-ws";
|
|
20
17
|
import invariant from "tiny-invariant";
|
|
21
|
-
import { metadataCacheClient } from "../__unstable/ConjureSupport.js";
|
|
22
18
|
import { convertWireToOsdkObjects } from "../object/convertWireToOsdkObjects.js";
|
|
23
|
-
import { getObjectSetBaseType, toConjureObjectSet } from "./toConjureObjectSet.js";
|
|
24
19
|
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
25
20
|
const MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;
|
|
26
21
|
/** Noop function to reduce conditional checks */
|
|
@@ -40,7 +35,7 @@ function fillOutListener({
|
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
function isReady(sub) {
|
|
43
|
-
return sub.
|
|
38
|
+
return sub.isReady != null;
|
|
44
39
|
}
|
|
45
40
|
function subscriptionIsDone(sub) {
|
|
46
41
|
return sub.status === "done" || sub.status === "error";
|
|
@@ -72,9 +67,6 @@ export class ObjectSetListenerWebsocket {
|
|
|
72
67
|
* temporary and not the actual subscriptionId from the server.
|
|
73
68
|
*/
|
|
74
69
|
#subscriptions = new Map();
|
|
75
|
-
#oswContext;
|
|
76
|
-
#metadataContext;
|
|
77
|
-
#ossContext;
|
|
78
70
|
#maybeDisconnectTimeout;
|
|
79
71
|
// DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM
|
|
80
72
|
constructor(client, {
|
|
@@ -88,25 +80,12 @@ export class ObjectSetListenerWebsocket {
|
|
|
88
80
|
msgPrefix: "<OSW> "
|
|
89
81
|
});
|
|
90
82
|
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? invariant(false, "Stack must be a URL") : void 0;
|
|
91
|
-
this.#oswContext = {
|
|
92
|
-
baseUrl: client.baseUrl,
|
|
93
|
-
servicePath: "/object-set-watcher/api",
|
|
94
|
-
fetchFn: client.fetch,
|
|
95
|
-
tokenProvider: async () => await client.tokenProvider()
|
|
96
|
-
};
|
|
97
|
-
this.#ossContext = {
|
|
98
|
-
...this.#oswContext,
|
|
99
|
-
servicePath: "/object-set-service/api"
|
|
100
|
-
};
|
|
101
|
-
this.#metadataContext = {
|
|
102
|
-
...this.#oswContext,
|
|
103
|
-
servicePath: "/ontology-metadata/api"
|
|
104
|
-
};
|
|
105
83
|
}
|
|
106
|
-
async subscribe(objectSet, listener) {
|
|
84
|
+
async subscribe(objectSet, listener, properties) {
|
|
107
85
|
const sub = {
|
|
108
86
|
listener: fillOutListener(listener),
|
|
109
87
|
objectSet,
|
|
88
|
+
requestedProperties: properties,
|
|
110
89
|
status: "preparing",
|
|
111
90
|
// Since we don't have a real subscription id yet but we need to keep
|
|
112
91
|
// track of this reference, we can just use a random uuid.
|
|
@@ -139,28 +118,22 @@ export class ObjectSetListenerWebsocket {
|
|
|
139
118
|
// expiry is tied to the temporary object set, which is set to `timeToLive: "ONE_DAY"`
|
|
140
119
|
// in `#createTemporaryObjectSet`. They should be in sync
|
|
141
120
|
sub.expiry = setTimeout(() => this.#expire(sub), this.OBJECT_SET_EXPIRY_MS);
|
|
142
|
-
|
|
121
|
+
await this.#client.ontologyRid;
|
|
143
122
|
try {
|
|
144
|
-
|
|
145
|
-
// create a time-bounded object set representation for watching
|
|
146
|
-
this.#createTemporaryObjectSet(sub.objectSet), this.#ensureWebsocket(),
|
|
147
|
-
// look up the object type's rid and ensure that we have enabled object set watcher for that rid
|
|
148
|
-
// TODO ???
|
|
149
|
-
getObjectSetBaseType(sub.objectSet).then(baseType => OntologiesV2.ObjectTypesV2.get(this.#client, ontologyRid, baseType)).then(objectType => this.#enableObjectSetsWatcher([objectType.rid]))]);
|
|
123
|
+
await this.#ensureWebsocket();
|
|
150
124
|
// the consumer may have already unsubscribed before we are ready to request a subscription
|
|
151
125
|
// so we have to acquire the pendingSubscription after the await.
|
|
152
126
|
if (subscriptionIsDone(sub)) {
|
|
153
127
|
return;
|
|
154
128
|
}
|
|
155
|
-
|
|
156
|
-
sub.temporaryObjectSetId = temporaryObjectSet.objectSetRid;
|
|
129
|
+
sub.isReady = true;
|
|
157
130
|
// if we aren't open, then this happens after we #onConnect
|
|
158
131
|
if (this.#ws?.readyState === WebSocket.OPEN) {
|
|
159
132
|
this.#sendSubscribeMessage();
|
|
160
133
|
}
|
|
161
134
|
} catch (error) {
|
|
162
135
|
this.#logger?.error(error, "Error in #initiateSubscribe");
|
|
163
|
-
sub.listener.onError(error);
|
|
136
|
+
sub.listener.onError([error]);
|
|
164
137
|
}
|
|
165
138
|
}
|
|
166
139
|
#sendSubscribeMessage() {
|
|
@@ -186,15 +159,12 @@ export class ObjectSetListenerWebsocket {
|
|
|
186
159
|
const subscribe = {
|
|
187
160
|
id,
|
|
188
161
|
requests: readySubs.map(({
|
|
189
|
-
|
|
162
|
+
objectSet,
|
|
163
|
+
requestedProperties
|
|
190
164
|
}) => ({
|
|
191
|
-
objectSet:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
parameterOverrides: {}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
watchAllLinks: false
|
|
165
|
+
objectSet: objectSet,
|
|
166
|
+
propertySet: requestedProperties,
|
|
167
|
+
referenceSet: []
|
|
198
168
|
}))
|
|
199
169
|
};
|
|
200
170
|
if (process?.env?.NODE_ENV !== "production") {
|
|
@@ -258,8 +228,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
258
228
|
tokenProvider
|
|
259
229
|
} = this.#client;
|
|
260
230
|
const base = new URL(baseUrl);
|
|
261
|
-
|
|
262
|
-
const url = `wss://${base.host}/object-set-watcher/ws/subscriptions`;
|
|
231
|
+
const url = `wss://${base.host}/api/v2/ontologySubscriptions/ontologies/${this.#client.ontologyRid}/streamSubscriptions`;
|
|
263
232
|
const token = await tokenProvider();
|
|
264
233
|
// tokenProvider is async, there could potentially be a race to create the websocket.
|
|
265
234
|
// Only the first call to reach here will find a null this.#ws, the rest will bail out
|
|
@@ -322,15 +291,14 @@ export class ObjectSetListenerWebsocket {
|
|
|
322
291
|
}
|
|
323
292
|
switch (data.type) {
|
|
324
293
|
case "objectSetChanged":
|
|
325
|
-
return this.#handleMessage_objectSetChanged(data
|
|
294
|
+
return this.#handleMessage_objectSetChanged(data);
|
|
326
295
|
case "refreshObjectSet":
|
|
327
|
-
return this.#handleMessage_refreshObjectSet(data
|
|
296
|
+
return this.#handleMessage_refreshObjectSet(data);
|
|
328
297
|
case "subscribeResponses":
|
|
329
|
-
return this.#handleMessage_subscribeResponses(data
|
|
298
|
+
return this.#handleMessage_subscribeResponses(data);
|
|
330
299
|
case "subscriptionClosed":
|
|
331
300
|
{
|
|
332
|
-
|
|
333
|
-
return this.#handleMessage_subscriptionClosed(payload);
|
|
301
|
+
return this.#handleMessage_subscriptionClosed(data);
|
|
334
302
|
}
|
|
335
303
|
default:
|
|
336
304
|
invariant(false, "Unexpected message type");
|
|
@@ -339,15 +307,21 @@ export class ObjectSetListenerWebsocket {
|
|
|
339
307
|
#handleMessage_objectSetChanged = async payload => {
|
|
340
308
|
const sub = this.#subscriptions.get(payload.id);
|
|
341
309
|
!sub ? invariant(false, `Expected subscription id ${payload.id}`) : void 0;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
310
|
+
const objectUpdates = payload.updates.filter(update => update.type === "object");
|
|
311
|
+
payload.updates.filter(update => update.type === "reference");
|
|
312
|
+
const osdkObjects = await Promise.all(objectUpdates.map(async o => {
|
|
313
|
+
const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [o.object], undefined);
|
|
314
|
+
const singleOsdkObject = osdkObjectArray[0] ?? undefined;
|
|
315
|
+
return singleOsdkObject != null ? {
|
|
316
|
+
object: singleOsdkObject,
|
|
317
|
+
state: o.state
|
|
318
|
+
} : undefined;
|
|
319
|
+
}));
|
|
320
|
+
for (const osdkObject of osdkObjects) {
|
|
321
|
+
if (osdkObject != null) {
|
|
322
|
+
return sub.listener.onChange?.(osdkObject);
|
|
323
|
+
}
|
|
345
324
|
}
|
|
346
|
-
const objects = payload.updates.filter(function (a) {
|
|
347
|
-
return a.type === "object";
|
|
348
|
-
}).map(a => a.object);
|
|
349
|
-
!(objects.length === payload.updates.length) ? invariant(false, "currently only support full updates not reference updates") : void 0;
|
|
350
|
-
sub.listener.onChange(await convertFoundryToOsdkObjects(this.#client, this.#metadataContext, objects));
|
|
351
325
|
};
|
|
352
326
|
#handleMessage_refreshObjectSet = payload => {
|
|
353
327
|
const sub = this.#subscriptions.get(payload.id);
|
|
@@ -367,7 +341,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
367
341
|
const response = responses[i];
|
|
368
342
|
switch (response.type) {
|
|
369
343
|
case "error":
|
|
370
|
-
sub.listener.onError(response.
|
|
344
|
+
sub.listener.onError(response.errors);
|
|
371
345
|
this.#unsubscribe(sub, "error");
|
|
372
346
|
break;
|
|
373
347
|
case "qos":
|
|
@@ -383,10 +357,10 @@ export class ObjectSetListenerWebsocket {
|
|
|
383
357
|
}, "success");
|
|
384
358
|
}
|
|
385
359
|
sub.status = "subscribed";
|
|
386
|
-
if (sub.subscriptionId !== response.
|
|
360
|
+
if (sub.subscriptionId !== response.id) {
|
|
387
361
|
// might be the temporary one
|
|
388
362
|
this.#subscriptions.delete(sub.subscriptionId);
|
|
389
|
-
sub.subscriptionId = response.
|
|
363
|
+
sub.subscriptionId = response.id;
|
|
390
364
|
this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId
|
|
391
365
|
}
|
|
392
366
|
if (shouldFireOutOfDate) sub.listener.onOutOfDate();
|
|
@@ -399,7 +373,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
399
373
|
#handleMessage_subscriptionClosed(payload) {
|
|
400
374
|
const sub = this.#subscriptions.get(payload.id);
|
|
401
375
|
!sub ? invariant(false, `Expected subscription id ${payload.id}`) : void 0;
|
|
402
|
-
sub.listener.onError(payload.
|
|
376
|
+
sub.listener.onError([payload.cause]);
|
|
403
377
|
this.#unsubscribe(sub, "error");
|
|
404
378
|
}
|
|
405
379
|
#onClose = event => {
|
|
@@ -411,28 +385,8 @@ export class ObjectSetListenerWebsocket {
|
|
|
411
385
|
// TODO we should probably throttle this so we don't abuse the backend
|
|
412
386
|
this.#cycleWebsocket();
|
|
413
387
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
requests: objectTypeRids
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
async #createTemporaryObjectSet(objectSet) {
|
|
420
|
-
const objectSetBaseType = await getObjectSetBaseType(objectSet);
|
|
421
|
-
const mcc = await metadataCacheClient(this.#client);
|
|
422
|
-
const objectInfo = await mcc.forObjectByApiName(objectSetBaseType);
|
|
423
|
-
const propMapping = await objectInfo.getPropertyMapping();
|
|
424
|
-
const temporaryObjectSet = await createTemporaryObjectSet(this.#ossContext, {
|
|
425
|
-
objectSet: toConjureObjectSet(objectSet, propMapping),
|
|
426
|
-
timeToLive: "ONE_DAY",
|
|
427
|
-
// MUST keep in sync with the value for expiry in `#initiateSubscribe`.
|
|
428
|
-
objectSetFilterContext: {
|
|
429
|
-
parameterOverrides: {}
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
return {
|
|
433
|
-
objectSetRid: temporaryObjectSet.objectSetRid
|
|
434
|
-
};
|
|
435
|
-
}
|
|
388
|
+
// TODO: Validate if this is needed
|
|
389
|
+
async #enableObjectSetsWatcher() {}
|
|
436
390
|
#cycleWebsocket = () => {
|
|
437
391
|
if (this.#ws) {
|
|
438
392
|
this.#ws.removeEventListener("open", this.#onOpen);
|
|
@@ -457,77 +411,4 @@ export class ObjectSetListenerWebsocket {
|
|
|
457
411
|
}
|
|
458
412
|
};
|
|
459
413
|
}
|
|
460
|
-
async function convertFoundryToOsdkObjects(client, ctx, objects) {
|
|
461
|
-
const osdkObjects = await Promise.all(objects.map(async object => {
|
|
462
|
-
const propertyMapping = await (await (await metadataCacheClient(client)).forObjectByRid(object.type)).getPropertyMapping();
|
|
463
|
-
const convertedObject = Object.fromEntries([...Object.entries(object.properties).map(([key, value]) => {
|
|
464
|
-
return [propertyMapping?.propertyIdToApiNameMapping[key], value];
|
|
465
|
-
}), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName], ["$apiName", propertyMapping?.apiName]]);
|
|
466
|
-
return convertedObject;
|
|
467
|
-
}));
|
|
468
|
-
// doesn't care about interfaces
|
|
469
|
-
return await convertWireToOsdkObjects(client, osdkObjects, undefined);
|
|
470
|
-
}
|
|
471
|
-
// Mapping of ObjectRid to Properties
|
|
472
|
-
const objectTypeMapping = new WeakMap();
|
|
473
|
-
const objectApiNameToRid = new Map();
|
|
474
|
-
async function getOntologyPropertyMappingForApiName(client, ctx, objectApiName) {
|
|
475
|
-
if (objectApiNameToRid.has(objectApiName)) {
|
|
476
|
-
return objectTypeMapping.get(ctx)?.get(objectApiNameToRid.get(objectApiName));
|
|
477
|
-
}
|
|
478
|
-
const ontologyRid = await client.ontologyRid;
|
|
479
|
-
const wireObjectType = await OntologiesV2.ObjectTypesV2.get(client, ontologyRid, objectApiName);
|
|
480
|
-
return getOntologyPropertyMappingForRid(ctx, ontologyRid, wireObjectType.rid);
|
|
481
|
-
}
|
|
482
|
-
let cachedAllOntologies;
|
|
483
|
-
async function getOntologyVersionForRid(ctx, ontologyRid) {
|
|
484
|
-
cachedAllOntologies ??= await loadAllOntologies(ctx, {});
|
|
485
|
-
!cachedAllOntologies.ontologies[ontologyRid] ? invariant(false, "ontology should be loaded") : void 0;
|
|
486
|
-
return cachedAllOntologies.ontologies[ontologyRid].currentOntologyVersion;
|
|
487
|
-
}
|
|
488
|
-
async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
|
|
489
|
-
if (!objectTypeMapping.has(ctx)) {
|
|
490
|
-
objectTypeMapping.set(ctx, new Map());
|
|
491
|
-
}
|
|
492
|
-
if (!objectTypeMapping.get(ctx).has(objectRid)) {
|
|
493
|
-
const ontologyVersion = await getOntologyVersionForRid(ctx, ontologyRid);
|
|
494
|
-
const body = {
|
|
495
|
-
datasourceTypes: [],
|
|
496
|
-
objectTypes: [{
|
|
497
|
-
identifier: {
|
|
498
|
-
type: "objectTypeRid",
|
|
499
|
-
objectTypeRid: objectRid
|
|
500
|
-
},
|
|
501
|
-
versionReference: {
|
|
502
|
-
type: "ontologyVersion",
|
|
503
|
-
ontologyVersion: ontologyVersion
|
|
504
|
-
}
|
|
505
|
-
}],
|
|
506
|
-
linkTypes: [],
|
|
507
|
-
sharedPropertyTypes: [],
|
|
508
|
-
interfaceTypes: [],
|
|
509
|
-
typeGroups: [],
|
|
510
|
-
loadRedacted: false,
|
|
511
|
-
includeObjectTypeCount: undefined,
|
|
512
|
-
includeObjectTypesWithoutSearchableDatasources: true,
|
|
513
|
-
includeEntityMetadata: undefined
|
|
514
|
-
};
|
|
515
|
-
const entities = await bulkLoadOntologyEntities(ctx, undefined, body);
|
|
516
|
-
!entities.objectTypes[0]?.objectType ? invariant(false, "object type should be loaded") : void 0;
|
|
517
|
-
const propertyIdToApiNameMapping = Object.fromEntries(Object.values(entities.objectTypes[0].objectType.propertyTypes).map(property => {
|
|
518
|
-
return [property.id, property.apiName];
|
|
519
|
-
}));
|
|
520
|
-
const propertyApiNameToIdMapping = Object.fromEntries(Object.values(entities.objectTypes[0].objectType.propertyTypes).map(property => {
|
|
521
|
-
return [property.apiName, property.id];
|
|
522
|
-
}));
|
|
523
|
-
objectTypeMapping.get(ctx)?.set(objectRid, {
|
|
524
|
-
apiName: entities.objectTypes[0].objectType.apiName,
|
|
525
|
-
id: entities.objectTypes[0].objectType.id,
|
|
526
|
-
propertyIdToApiNameMapping,
|
|
527
|
-
propertyApiNameToIdMapping
|
|
528
|
-
});
|
|
529
|
-
objectApiNameToRid.set(entities.objectTypes[0].objectType.apiName, objectRid);
|
|
530
|
-
}
|
|
531
|
-
return objectTypeMapping.get(ctx)?.get(objectRid);
|
|
532
|
-
}
|
|
533
414
|
//# sourceMappingURL=ObjectSetListenerWebsocket.js.map
|