@osdk/client 2.7.0-beta.10 → 2.7.0-beta.12
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 +30 -0
- package/build/browser/actions/actions.test.js +0 -8
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +13 -4
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +46 -2
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +1 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/FunctionPayload.js +2 -0
- package/build/browser/observable/FunctionPayload.js.map +1 -0
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/Changes.js +4 -1
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +21 -1
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/Store.js +8 -0
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +48 -1
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/actions/ActionApplication.js +11 -7
- package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/browser/observable/internal/function/FunctionCacheKey.js +26 -0
- package/build/browser/observable/internal/function/FunctionCacheKey.js.map +1 -0
- package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.js +151 -0
- package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.test.js +186 -0
- package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.test.js.map +1 -0
- package/build/browser/observable/internal/function/FunctionQuery.js +137 -0
- package/build/browser/observable/internal/function/FunctionQuery.js.map +1 -0
- package/build/browser/observable/internal/function/FunctionQuery.test.js +278 -0
- package/build/browser/observable/internal/function/FunctionQuery.test.js.map +1 -0
- package/build/browser/observable/internal/function/FunctionsHelper.js +92 -0
- package/build/browser/observable/internal/function/FunctionsHelper.js.map +1 -0
- package/build/browser/observable/internal/list/InterfaceListQuery.js +24 -9
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectsHelper.js +1 -3
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/isObjectSpecifiersObject.js.map +1 -1
- package/build/cjs/{Client-DaUJl7jZ.d.cts → Client-Cmx6x_V1.d.cts} +1 -1
- package/build/cjs/{chunk-RDZ5NKAI.cjs → chunk-4HXJEKQT.cjs} +16 -7
- package/build/cjs/chunk-4HXJEKQT.cjs.map +1 -0
- package/build/cjs/{chunk-MZZAHBN6.cjs → chunk-62RUUOW2.cjs} +67 -65
- package/build/cjs/{chunk-MZZAHBN6.cjs.map → chunk-62RUUOW2.cjs.map} +1 -1
- package/build/cjs/{createClient-D5G3qzAO.d.cts → createClient-BPK4om7e.d.cts} +1 -1
- package/build/cjs/index.cjs +8 -8
- package/build/cjs/index.d.cts +2 -2
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/internal.d.cts +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +432 -62
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +55 -4
- package/build/esm/actions/actions.test.js +0 -8
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +13 -4
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +46 -2
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +1 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/FunctionPayload.js +2 -0
- package/build/esm/observable/FunctionPayload.js.map +1 -0
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/Changes.js +4 -1
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +21 -1
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/Store.js +8 -0
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +48 -1
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/actions/ActionApplication.js +11 -7
- package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/esm/observable/internal/function/FunctionCacheKey.js +26 -0
- package/build/esm/observable/internal/function/FunctionCacheKey.js.map +1 -0
- package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.js +151 -0
- package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.test.js +186 -0
- package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.test.js.map +1 -0
- package/build/esm/observable/internal/function/FunctionQuery.js +137 -0
- package/build/esm/observable/internal/function/FunctionQuery.js.map +1 -0
- package/build/esm/observable/internal/function/FunctionQuery.test.js +278 -0
- package/build/esm/observable/internal/function/FunctionQuery.test.js.map +1 -0
- package/build/esm/observable/internal/function/FunctionsHelper.js +92 -0
- package/build/esm/observable/internal/function/FunctionsHelper.js.map +1 -0
- package/build/esm/observable/internal/list/InterfaceListQuery.js +24 -9
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectsHelper.js +1 -3
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/isObjectSpecifiersObject.js.map +1 -1
- package/build/types/observable/FunctionPayload.d.ts +10 -0
- package/build/types/observable/FunctionPayload.d.ts.map +1 -0
- package/build/types/observable/ObservableClient.d.ts +52 -1
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +5 -3
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +5 -1
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/Store.test.d.ts.map +1 -1
- package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/function/FunctionCacheKey.d.ts +17 -0
- package/build/types/observable/internal/function/FunctionCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/function/FunctionParamsCanonicalizer.d.ts +16 -0
- package/build/types/observable/internal/function/FunctionParamsCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/function/FunctionParamsCanonicalizer.test.d.ts +1 -0
- package/build/types/observable/internal/function/FunctionParamsCanonicalizer.test.d.ts.map +1 -0
- package/build/types/observable/internal/function/FunctionQuery.d.ts +40 -0
- package/build/types/observable/internal/function/FunctionQuery.d.ts.map +1 -0
- package/build/types/observable/internal/function/FunctionQuery.test.d.ts +1 -0
- package/build/types/observable/internal/function/FunctionQuery.test.d.ts.map +1 -0
- package/build/types/observable/internal/function/FunctionsHelper.d.ts +25 -0
- package/build/types/observable/internal/function/FunctionsHelper.d.ts.map +1 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts +3 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +2 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/util/isObjectSpecifiersObject.d.ts +1 -0
- package/build/types/util/isObjectSpecifiersObject.d.ts.map +1 -1
- package/package.json +7 -7
- package/build/cjs/chunk-RDZ5NKAI.cjs.map +0 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import groupBy from "object.groupby";
|
|
18
18
|
import invariant from "tiny-invariant";
|
|
19
|
-
import { ObjectDefRef
|
|
19
|
+
import { ObjectDefRef } from "../../../object/convertWireToOsdkObjects/InternalSymbols.js";
|
|
20
20
|
import { ListQuery, RDP_IDX } from "./ListQuery.js";
|
|
21
21
|
export class InterfaceListQuery extends ListQuery {
|
|
22
22
|
createObjectSet(store) {
|
|
@@ -42,6 +42,17 @@ export class InterfaceListQuery extends ListQuery {
|
|
|
42
42
|
async postProcessFetchedData(data) {
|
|
43
43
|
return reloadDataAsFullObjects(this.store.client, data);
|
|
44
44
|
}
|
|
45
|
+
createPayload(params) {
|
|
46
|
+
const resolvedList = params.resolvedData.map(obj => obj.$as(this.apiName));
|
|
47
|
+
return {
|
|
48
|
+
resolvedList,
|
|
49
|
+
isOptimistic: params.isOptimistic,
|
|
50
|
+
fetchMore: this.fetchMore,
|
|
51
|
+
hasMore: this.nextPageToken != null,
|
|
52
|
+
status: params.status,
|
|
53
|
+
lastUpdated: params.lastUpdated
|
|
54
|
+
};
|
|
55
|
+
}
|
|
45
56
|
extractRelevantObjects(changes) {
|
|
46
57
|
const matchesApiName = ([, object]) => {
|
|
47
58
|
return this.apiName in object[ObjectDefRef].interfaceMap;
|
|
@@ -65,12 +76,16 @@ export class InterfaceListQuery extends ListQuery {
|
|
|
65
76
|
|
|
66
77
|
// Hopefully this can go away when we can just request the full object properties on first load
|
|
67
78
|
async function reloadDataAsFullObjects(client, data) {
|
|
79
|
+
if (data.length === 0) {
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
68
82
|
const groups = groupBy(data, x => x.$objectType);
|
|
69
83
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
// Interface query results don't have ObjectDefRef, so we fetch metadata to get primaryKeyApiName
|
|
85
|
+
const objectDef = await client.fetchMetadata({
|
|
86
|
+
type: "object",
|
|
87
|
+
apiName
|
|
88
|
+
});
|
|
74
89
|
const where = {
|
|
75
90
|
[objectDef.primaryKeyApiName]: {
|
|
76
91
|
$in: objects.map(x => x.$primaryKey)
|
|
@@ -79,10 +94,10 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
79
94
|
const result = await client(objectDef).where(where).fetchPage();
|
|
80
95
|
return [apiName, Object.fromEntries(result.data.map(x => [x.$primaryKey, x]))];
|
|
81
96
|
})));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
return data.map(obj => {
|
|
98
|
+
const fullObject = objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
|
|
99
|
+
!fullObject ? process.env.NODE_ENV !== "production" ? invariant(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant(false) : void 0;
|
|
100
|
+
return fullObject;
|
|
85
101
|
});
|
|
86
|
-
return data;
|
|
87
102
|
}
|
|
88
103
|
//# sourceMappingURL=InterfaceListQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceListQuery.js","names":["groupBy","invariant","ObjectDefRef","UnderlyingOsdkObject","ListQuery","RDP_IDX","InterfaceListQuery","createObjectSet","store","rdpConfig","cacheKey","otherKeys","objectTypeDef","type","apiName","client","withProperties","where","canonicalWhere","revalidateObjectType","objectMetadata","fetchMetadata","interfaceMap","revalidate","postProcessFetchedData","data","reloadDataAsFullObjects","extractRelevantObjects","changes","matchesApiName","object","added","Array","from","addedObjects","filter","map","$as","modified","modifiedObjects","all","strictMatches","Set","sortaMatches","groups","x","$objectType","objectTypeToPrimaryKeyToObject","Object","fromEntries","Promise","entries","objects","objectDef","primaryKeyApiName","$in","$primaryKey","result","fetchPage","obj","process","env","NODE_ENV"],"sources":["InterfaceListQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 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\nimport type { ObjectSet, ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport groupBy from \"object.groupby\";\nimport invariant from \"tiny-invariant\";\nimport type { Client } from \"../../../Client.js\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport {\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"../../../object/convertWireToOsdkObjects/InternalSymbols.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { Store } from \"../Store.js\";\nimport { ListQuery, RDP_IDX } from \"./ListQuery.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\nexport class InterfaceListQuery extends ListQuery {\n protected createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition> {\n const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];\n const type: string = \"interface\" as const;\n const objectTypeDef = {\n type,\n apiName: this.apiName,\n } as ObjectTypeDefinition;\n\n if (rdpConfig != null) {\n return store.client(objectTypeDef)\n .withProperties(rdpConfig as Rdp)\n .where(this.canonicalWhere);\n }\n\n return store.client(objectTypeDef)\n .where(this.canonicalWhere);\n }\n\n async revalidateObjectType(apiName: string): Promise<void> {\n const objectMetadata = await this.store.client.fetchMetadata({\n type: \"object\",\n apiName,\n });\n\n if (this.apiName in objectMetadata.interfaceMap) {\n await this.revalidate(/* force */ true);\n }\n }\n\n protected async postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]> {\n return reloadDataAsFullObjects(this.store.client, data);\n }\n\n protected extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n const matchesApiName = ([, object]: [unknown, ObjectHolder]) => {\n return this.apiName in object[ObjectDefRef].interfaceMap;\n };\n\n const added = Array.from(changes.addedObjects).filter(matchesApiName).map((\n [, object],\n ) => object.$as(this.apiName));\n\n const modified = Array.from(changes.modifiedObjects).filter(matchesApiName)\n .map((\n [, object],\n ) => object.$as(this.apiName));\n\n return {\n added: {\n all: added,\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n modified: {\n all: modified,\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n };\n }\n}\n\n// Hopefully this can go away when we can just request the full object properties on first load\nasync function reloadDataAsFullObjects(\n client: Client,\n data: Osdk.Instance<any>[],\n) {\n const groups = groupBy(data, (x) => x.$objectType);\n const objectTypeToPrimaryKeyToObject = Object.fromEntries(\n await Promise.all(\n Object.entries(groups).map<\n Promise<\n [\n /** objectType **/ string,\n Record<string | number, Osdk.Instance<ObjectTypeDefinition>>,\n ]\n >\n >(async ([apiName, objects]) => {\n // to keep InternalSimpleOsdkInstance simple, we make both the `ObjectDefRef` and\n // the `InterfaceDefRef` optional but we know that the right one is on there\n // thus we can `!`\n const objectDef = (objects[0] as ObjectHolder)[UnderlyingOsdkObject][\n ObjectDefRef\n ]!;\n const where: SimpleWhereClause = {\n [objectDef.primaryKeyApiName]: {\n $in: objects.map(x => x.$primaryKey),\n },\n };\n\n const result = await client(\n objectDef as ObjectTypeDefinition,\n ).where(\n where as Parameters<ObjectSet<ObjectTypeDefinition>[\"where\"]>[0],\n ).fetchPage();\n return [\n apiName,\n Object.fromEntries(result.data.map(\n x => [x.$primaryKey, x],\n )),\n ];\n }),\n ),\n );\n\n data = data.map((obj) => {\n invariant(\n objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey],\n `Could not find object ${obj.$objectType} ${obj.$primaryKey}`,\n );\n return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];\n });\n\n return data;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,OAAOC,SAAS,MAAM,gBAAgB;AAGtC,SACEC,YAAY,EACZC,oBAAoB,QACf,6DAA6D;AAMpE,SAASC,SAAS,EAAEC,OAAO,QAAQ,gBAAgB;AAQnD,OAAO,MAAMC,kBAAkB,SAASF,SAAS,CAAC;EACtCG,eAAeA,CAACC,KAAY,EAAmC;IACvE,MAAMC,SAAS,GAAG,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACN,OAAO,CAAC;IAElD,MAAMO,aAAa,GAAG;MACpBC,IAAI,EAFe,WAEf;MACJC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAyB;IAEzB,IAAIL,SAAS,IAAI,IAAI,EAAE;MACrB,OAAOD,KAAK,CAACO,MAAM,CAACH,aAAa,CAAC,CAC/BI,cAAc,CAACP,SAAgB,CAAC,CAChCQ,KAAK,CAAC,IAAI,CAACC,cA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AACY,GAAG,CAACb,WAAW,CAAC,CAACa,GAAG,CAACH,WAAW,CAAC,GAAAI,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADlE7D,SAAS,QAEP,yBAAyB0D,GAAG,CAACb,WAAW,IAAIa,GAAG,CAACH,WAAW,EAAE,IAF/DvD,SAAS;IAIT,OAAO8C,8BAA8B,CAACY,GAAG,CAACb,WAAW,CAAC,CAACa,GAAG,CAACH,WAAW,CAAC;EACzE,CAAC,CAAC;EAEF,OAAO/B,IAAI;AACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InterfaceListQuery.js","names":["groupBy","invariant","ObjectDefRef","ListQuery","RDP_IDX","InterfaceListQuery","createObjectSet","store","rdpConfig","cacheKey","otherKeys","objectTypeDef","type","apiName","client","withProperties","where","canonicalWhere","revalidateObjectType","objectMetadata","fetchMetadata","interfaceMap","revalidate","postProcessFetchedData","data","reloadDataAsFullObjects","createPayload","params","resolvedList","resolvedData","map","obj","$as","isOptimistic","fetchMore","hasMore","nextPageToken","status","lastUpdated","extractRelevantObjects","changes","matchesApiName","object","added","Array","from","addedObjects","filter","modified","modifiedObjects","all","strictMatches","Set","sortaMatches","length","groups","x","$objectType","objectTypeToPrimaryKeyToObject","Object","fromEntries","Promise","entries","objects","objectDef","primaryKeyApiName","$in","$primaryKey","result","fetchPage","fullObject","process","env","NODE_ENV"],"sources":["InterfaceListQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 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\nimport type { ObjectSet, ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport groupBy from \"object.groupby\";\nimport invariant from \"tiny-invariant\";\nimport type { Client } from \"../../../Client.js\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport { ObjectDefRef } from \"../../../object/convertWireToOsdkObjects/InternalSymbols.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { CollectionConnectableParams } from \"../base-list/BaseCollectionQuery.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { Store } from \"../Store.js\";\nimport { ListQuery, RDP_IDX } from \"./ListQuery.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\nexport class InterfaceListQuery extends ListQuery {\n protected createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition> {\n const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];\n const type: string = \"interface\" as const;\n const objectTypeDef = {\n type,\n apiName: this.apiName,\n } as ObjectTypeDefinition;\n\n if (rdpConfig != null) {\n return store.client(objectTypeDef)\n .withProperties(rdpConfig as Rdp)\n .where(this.canonicalWhere);\n }\n\n return store.client(objectTypeDef)\n .where(this.canonicalWhere);\n }\n\n async revalidateObjectType(apiName: string): Promise<void> {\n const objectMetadata = await this.store.client.fetchMetadata({\n type: \"object\",\n apiName,\n });\n\n if (this.apiName in objectMetadata.interfaceMap) {\n await this.revalidate(/* force */ true);\n }\n }\n\n protected async postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]> {\n return reloadDataAsFullObjects(this.store.client, data);\n }\n\n protected createPayload(\n params: CollectionConnectableParams,\n ): ListPayload {\n const resolvedList = params.resolvedData.map((obj: ObjectHolder) =>\n obj.$as(this.apiName)\n );\n\n return {\n resolvedList,\n isOptimistic: params.isOptimistic,\n fetchMore: this.fetchMore,\n hasMore: this.nextPageToken != null,\n status: params.status,\n lastUpdated: params.lastUpdated,\n };\n }\n\n protected extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n const matchesApiName = ([, object]: [unknown, ObjectHolder]) => {\n return this.apiName in object[ObjectDefRef].interfaceMap;\n };\n\n const added = Array.from(changes.addedObjects).filter(matchesApiName).map((\n [, object],\n ) => object.$as(this.apiName));\n\n const modified = Array.from(changes.modifiedObjects).filter(matchesApiName)\n .map((\n [, object],\n ) => object.$as(this.apiName));\n\n return {\n added: {\n all: added,\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n modified: {\n all: modified,\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n };\n }\n}\n\n// Hopefully this can go away when we can just request the full object properties on first load\nasync function reloadDataAsFullObjects(\n client: Client,\n data: Osdk.Instance<any>[],\n) {\n if (data.length === 0) {\n return data;\n }\n\n const groups = groupBy(data, (x) => x.$objectType);\n const objectTypeToPrimaryKeyToObject = Object.fromEntries(\n await Promise.all(\n Object.entries(groups).map<\n Promise<\n [\n /** objectType **/ string,\n Record<string | number, Osdk.Instance<ObjectTypeDefinition>>,\n ]\n >\n >(async ([apiName, objects]) => {\n // Interface query results don't have ObjectDefRef, so we fetch metadata to get primaryKeyApiName\n const objectDef = await client.fetchMetadata({\n type: \"object\",\n apiName,\n });\n const where: SimpleWhereClause = {\n [objectDef.primaryKeyApiName]: {\n $in: objects.map(x => x.$primaryKey),\n },\n };\n\n const result = await client(\n objectDef as ObjectTypeDefinition,\n ).where(\n where as Parameters<ObjectSet<ObjectTypeDefinition>[\"where\"]>[0],\n ).fetchPage();\n return [\n apiName,\n Object.fromEntries(result.data.map(\n x => [x.$primaryKey, x],\n )),\n ];\n }),\n ),\n );\n\n return data.map((obj) => {\n const fullObject =\n objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];\n invariant(\n fullObject,\n `Could not find object ${obj.$objectType} ${obj.$primaryKey}`,\n );\n return fullObject;\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,OAAOC,SAAS,MAAM,gBAAgB;AAGtC,SAASC,YAAY,QAAQ,6DAA6D;AAQ1F,SAASC,SAAS,EAAEC,OAAO,QAAQ,gBAAgB;AAQnD,OAAO,MAAMC,kBAAkB,SAASF,SAAS,CAAC;EACtCG,eAAeA,CAACC,KAAY,EAAmC;IACvE,MAAMC,SAAS,GAAG,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACN,OAAO,CAAC;IAElD,MAAMO,aAAa,GAAG;MACpBC,IAAI,EAFe,WAEf;MACJC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAyB;IAEzB,IAAIL,SAAS,IAAI,IAAI,EAAE;MACrB,OAAOD,KAAK,CAACO,MAAM,CAACH,aAAa,CAAC,CAC/BI,cAAc,CAACP,SAAgB,CAAC,CAChCQ,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;IAC/B;IAEA,OAAOV,KAAK,CAACO,MAAM,CAACH,aAAa,CAAC,CAC/BK,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;EAC/B;EAEA,MAAMC,oBAAoBA,CAACL,OAAe,EAAiB;IACzD,MAAMM,cAAc,GAAG,MAAM,IAAI,CAACZ,KAAK,CAACO,MAAM,CAACM,aAAa,CAAC;MAC3DR,IAAI,EAAE,QAAQ;MACdC;IACF,CAAC,CAAC;IAEF,IAAI,IAAI,CAACA,OAAO,IAAIM,cAAc,CAACE,YAAY,EAAE;MAC/C,MAAM,IAAI,CAACC,UAAU,CAAC,WAAY,IAAI,CAAC;IACzC;EACF;EAEA,MAAgBC,sBAAsBA,CACpCC,IAA0B,EACK;IAC/B,OAAO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MuC,UAAU,GACdZ,8BAA8B,CAAC3B,GAAG,CAAC0B,WAAW,CAAC,CAAC1B,GAAG,CAACoC,WAAW,CAAC;IAClE,CACEG,UAAU,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADZxE,SAAS,QAEP,yBAAyB8B,GAAG,CAAC0B,WAAW,IAAI1B,GAAG,CAACoC,WAAW,EAAE,IAF/DlE,SAAS;IAIT,OAAOqE,UAAU;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -41,10 +41,8 @@ export class ObjectsHelper extends AbstractHelper {
|
|
|
41
41
|
* @internal
|
|
42
42
|
*/
|
|
43
43
|
storeOsdkInstances(values, batch, rdpConfig) {
|
|
44
|
-
// update the cache for any object that has changed
|
|
45
|
-
// and save the mapped values to return
|
|
46
44
|
return values.map(v => this.getQuery({
|
|
47
|
-
apiName: v.$apiName,
|
|
45
|
+
apiName: v.$objectType ?? v.$apiName,
|
|
48
46
|
pk: v.$primaryKey
|
|
49
47
|
}, rdpConfig).writeToStore(v, "loaded", batch).cacheKey);
|
|
50
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectsHelper.js","names":["deepEqual","AbstractHelper","tombstone","mergeObjectFields","ObjectQuery","ObjectsHelper","observe","options","subFn","getQuery","rdpConfig","apiName","pk","objectCacheKey","cacheKeys","get","undefined","store","queries","subjects","dedupeInterval","storeOsdkInstances","values","batch","map","v","$apiName","$primaryKey","writeToStore","cacheKey","propagateWrite","sourceCacheKey","value","status","existing","read","dataChanged","statusChanged","valueToWrite","write","changes","registerObject","metadata","objectCacheKeyRegistry","getMetadata","relatedKeys","getVariants","primaryKey","Set","targetKey","isKeyActive","targetCurrentValue","merged","mergeForTarget","isObjectHolder","key","subject","peek","observed","sourceValue","targetCacheKey","sourceRdpFields","getRdpFieldSet","targetRdpFields"],"sources":["ObjectsHelper.ts"],"sourcesContent":["/*\n * Copyright 2025 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\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport deepEqual from \"fast-deep-equal\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ObjectPayload } from \"../../ObjectPayload.js\";\nimport type { ObserveObjectOptions } from \"../../ObservableClient.js\";\nimport type { Observer, Status } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport { tombstone } from \"../tombstone.js\";\nimport { mergeObjectFields } from \"../utils/rdpFieldOperations.js\";\nimport { type ObjectCacheKey } from \"./ObjectCacheKey.js\";\nimport { ObjectQuery } from \"./ObjectQuery.js\";\n\nexport class ObjectsHelper extends AbstractHelper<\n ObjectQuery,\n ObserveObjectOptions<any>\n> {\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n subFn: Observer<ObjectPayload>,\n ): QuerySubscription<ObjectQuery> {\n return super.observe(options, subFn);\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n rdpConfig?: Canonical<Rdp> | null,\n ): ObjectQuery {\n const apiName = typeof options.apiName === \"string\"\n ? options.apiName\n : options.apiName.apiName;\n const { pk } = options;\n\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n apiName,\n pk,\n rdpConfig ?? undefined,\n );\n\n return this.store.queries.get(objectCacheKey, () =>\n new ObjectQuery(\n this.store,\n this.store.subjects.get(objectCacheKey),\n apiName,\n pk,\n objectCacheKey,\n { dedupeInterval: 0 },\n ));\n }\n\n /**\n * Internal helper method for writing objects to the store and returning their\n * object keys. For list queries with RDPs, the rdpConfig is included in the\n * cache key to ensure proper data isolation.\n * @internal\n */\n public storeOsdkInstances(\n values: Array<ObjectHolder> | Array<Osdk.Instance<any, any, any>>,\n batch: BatchContext,\n rdpConfig?: Canonical<Rdp> | null,\n ): ObjectCacheKey[] {\n // update the cache for any object that has changed\n // and save the mapped values to return\n return values.map(v =>\n this.getQuery({\n apiName: v.$apiName,\n pk: v.$primaryKey as string | number,\n }, rdpConfig).writeToStore(\n v as ObjectHolder,\n \"loaded\",\n batch,\n ).cacheKey\n );\n }\n\n /**\n * Write an object to cache and propagate to all related cache keys\n * @internal\n */\n public propagateWrite(\n sourceCacheKey: ObjectCacheKey,\n value: ObjectHolder | typeof tombstone,\n status: Status,\n batch: BatchContext,\n ): void {\n const existing = batch.read(sourceCacheKey);\n const dataChanged = !existing\n || existing.value === undefined\n || value === tombstone\n || !deepEqual(existing.value, value);\n const statusChanged = !existing || existing.status !== status;\n\n if (!dataChanged && !statusChanged) {\n return;\n }\n\n const valueToWrite = !dataChanged && existing ? existing.value : value;\n batch.write(sourceCacheKey, valueToWrite, status);\n\n if (value !== tombstone) {\n batch.changes.registerObject(sourceCacheKey, value, !existing);\n }\n\n const metadata = this.store.objectCacheKeyRegistry.getMetadata(\n sourceCacheKey,\n );\n\n const relatedKeys = metadata\n ? this.store.objectCacheKeyRegistry.getVariants(\n metadata.apiName,\n metadata.primaryKey,\n )\n : new Set([sourceCacheKey]);\n\n for (const targetKey of relatedKeys) {\n if (targetKey === sourceCacheKey || !this.isKeyActive(targetKey)) {\n continue;\n }\n\n if (value === tombstone) {\n batch.write(targetKey, tombstone, status);\n continue;\n }\n\n const targetCurrentValue = batch.read(targetKey)?.value;\n const merged = this.mergeForTarget(\n value,\n targetCurrentValue && this.isObjectHolder(targetCurrentValue)\n ? targetCurrentValue\n : undefined,\n sourceCacheKey,\n targetKey,\n );\n\n batch.write(targetKey, merged, status);\n }\n }\n\n /**\n * Check if a cache key is actively observed\n */\n private isKeyActive(key: ObjectCacheKey): boolean {\n const subject = this.store.subjects.peek(key);\n return subject?.observed === true;\n }\n\n /**\n * Type guard to check if a value is an ObjectHolder\n */\n private isObjectHolder(\n value: ObjectHolder | undefined,\n ): value is ObjectHolder {\n return value != null\n && typeof value === \"object\"\n && \"$apiName\" in value\n && \"$primaryKey\" in value;\n }\n\n /**\n * Merge object data for a specific target cache key, preserving RDP fields\n */\n private mergeForTarget(\n sourceValue: ObjectHolder,\n targetCurrentValue: ObjectHolder | undefined,\n sourceCacheKey: ObjectCacheKey,\n targetCacheKey: ObjectCacheKey,\n ): ObjectHolder {\n const sourceRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(\n sourceCacheKey,\n );\n const targetRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(\n targetCacheKey,\n );\n\n return mergeObjectFields(\n sourceValue,\n sourceRdpFields,\n targetRdpFields,\n targetCurrentValue,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,OAAOA,SAAS,MAAM,iBAAiB;AAKvC,SAASC,cAAc,QAAQ,sBAAsB;AAKrD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,OAAO,MAAMC,aAAa,SAASJ,cAAc,CAG/C;EACAK,OAAOA,CACLC,OAAgC,EAChCC,KAA8B,EACE;IAChC,OAAO,KAAK,CAACF,OAAO,CAACC,OAAO,EAAEC,KAAK,CAAC;EACtC;EAEAC,QAAQA,CACNF,OAAgC,EAChCG,SAAiC,EACpB;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,CAAC,GACzDA,kBAAkB,GAClBnC,SAAS,EACbe,cAAc,EACdkB,SACF,CAAC;MAED1B,KAAK,CAACgB,KAAK,CAACU,SAAS,EAAEG,MAAM,EAAEnB,MAAM,CAAC;IACxC;EACF;;EAEA;AACF;AACA;EACUiB,WAAWA,CAACK,GAAmB,EAAW;IAChD,MAAMC,OAAO,GAAG,IAAI,CAACvC,KAAK,CAACE,QAAQ,CAACsC,IAAI,CAACF,GAAG,CAAC;IAC7C,OAAOC,OAAO,EAAEE,QAAQ,KAAK,IAAI;EACnC;;EAEA;AACF;AACA;EACUJ,cAAcA,CACpBtB,KAA+B,EACR;IACvB,OAAOA,KAAK,IAAI,IAAI,IACf,OAAOA,KAAK,KAAK,QAAQ,IACzB,UAAU,IAAIA,KAAK,IACnB,aAAa,IAAIA,KAAK;EAC7B;;EAEA;AACF;AACA;EACUqB,cAAcA,CACpBM,WAAyB,EACzBR,kBAA4C,EAC5CpB,cAA8B,EAC9B6B,cAA8B,EAChB;IACd,MAAMC,eAAe,GAAG,IAAI,CAAC5C,KAAK,CAAC0B,sBAAsB,CAACmB,cAAc,CACtE/B,cACF,CAAC;IACD,MAAMgC,eAAe,GAAG,IAAI,CAAC9C,KAAK,CAAC0B,sBAAsB,CAACmB,cAAc,CACtEF,cACF,CAAC;IAED,OAAOzD,iBAAiB,CACtBwD,WAAW,EACXE,eAAe,EACfE,eAAe,EACfZ,kBACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectsHelper.js","names":["deepEqual","AbstractHelper","tombstone","mergeObjectFields","ObjectQuery","ObjectsHelper","observe","options","subFn","getQuery","rdpConfig","apiName","pk","objectCacheKey","cacheKeys","get","undefined","store","queries","subjects","dedupeInterval","storeOsdkInstances","values","batch","map","v","$objectType","$apiName","$primaryKey","writeToStore","cacheKey","propagateWrite","sourceCacheKey","value","status","existing","read","dataChanged","statusChanged","valueToWrite","write","changes","registerObject","metadata","objectCacheKeyRegistry","getMetadata","relatedKeys","getVariants","primaryKey","Set","targetKey","isKeyActive","targetCurrentValue","merged","mergeForTarget","isObjectHolder","key","subject","peek","observed","sourceValue","targetCacheKey","sourceRdpFields","getRdpFieldSet","targetRdpFields"],"sources":["ObjectsHelper.ts"],"sourcesContent":["/*\n * Copyright 2025 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\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport deepEqual from \"fast-deep-equal\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ObjectPayload } from \"../../ObjectPayload.js\";\nimport type { ObserveObjectOptions } from \"../../ObservableClient.js\";\nimport type { Observer, Status } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport { tombstone } from \"../tombstone.js\";\nimport { mergeObjectFields } from \"../utils/rdpFieldOperations.js\";\nimport { type ObjectCacheKey } from \"./ObjectCacheKey.js\";\nimport { ObjectQuery } from \"./ObjectQuery.js\";\n\nexport class ObjectsHelper extends AbstractHelper<\n ObjectQuery,\n ObserveObjectOptions<any>\n> {\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n subFn: Observer<ObjectPayload>,\n ): QuerySubscription<ObjectQuery> {\n return super.observe(options, subFn);\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n rdpConfig?: Canonical<Rdp> | null,\n ): ObjectQuery {\n const apiName = typeof options.apiName === \"string\"\n ? options.apiName\n : options.apiName.apiName;\n const { pk } = options;\n\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n apiName,\n pk,\n rdpConfig ?? undefined,\n );\n\n return this.store.queries.get(objectCacheKey, () =>\n new ObjectQuery(\n this.store,\n this.store.subjects.get(objectCacheKey),\n apiName,\n pk,\n objectCacheKey,\n { dedupeInterval: 0 },\n ));\n }\n\n /**\n * Internal helper method for writing objects to the store and returning their\n * object keys. For list queries with RDPs, the rdpConfig is included in the\n * cache key to ensure proper data isolation.\n * @internal\n */\n public storeOsdkInstances(\n values: Array<ObjectHolder> | Array<Osdk.Instance<any, any, any>>,\n batch: BatchContext,\n rdpConfig?: Canonical<Rdp> | null,\n ): ObjectCacheKey[] {\n return values.map(v =>\n this.getQuery({\n apiName: v.$objectType ?? v.$apiName,\n pk: v.$primaryKey as string | number,\n }, rdpConfig).writeToStore(\n v as ObjectHolder,\n \"loaded\",\n batch,\n ).cacheKey\n );\n }\n\n /**\n * Write an object to cache and propagate to all related cache keys\n * @internal\n */\n public propagateWrite(\n sourceCacheKey: ObjectCacheKey,\n value: ObjectHolder | typeof tombstone,\n status: Status,\n batch: BatchContext,\n ): void {\n const existing = batch.read(sourceCacheKey);\n const dataChanged = !existing\n || existing.value === undefined\n || value === tombstone\n || !deepEqual(existing.value, value);\n const statusChanged = !existing || existing.status !== status;\n\n if (!dataChanged && !statusChanged) {\n return;\n }\n\n const valueToWrite = !dataChanged && existing ? existing.value : value;\n batch.write(sourceCacheKey, valueToWrite, status);\n\n if (value !== tombstone) {\n batch.changes.registerObject(sourceCacheKey, value, !existing);\n }\n\n const metadata = this.store.objectCacheKeyRegistry.getMetadata(\n sourceCacheKey,\n );\n\n const relatedKeys = metadata\n ? this.store.objectCacheKeyRegistry.getVariants(\n metadata.apiName,\n metadata.primaryKey,\n )\n : new Set([sourceCacheKey]);\n\n for (const targetKey of relatedKeys) {\n if (targetKey === sourceCacheKey || !this.isKeyActive(targetKey)) {\n continue;\n }\n\n if (value === tombstone) {\n batch.write(targetKey, tombstone, status);\n continue;\n }\n\n const targetCurrentValue = batch.read(targetKey)?.value;\n const merged = this.mergeForTarget(\n value,\n targetCurrentValue && this.isObjectHolder(targetCurrentValue)\n ? targetCurrentValue\n : undefined,\n sourceCacheKey,\n targetKey,\n );\n\n batch.write(targetKey, merged, status);\n }\n }\n\n /**\n * Check if a cache key is actively observed\n */\n private isKeyActive(key: ObjectCacheKey): boolean {\n const subject = this.store.subjects.peek(key);\n return subject?.observed === true;\n }\n\n /**\n * Type guard to check if a value is an ObjectHolder\n */\n private isObjectHolder(\n value: ObjectHolder | undefined,\n ): value is ObjectHolder {\n return value != null\n && typeof value === \"object\"\n && \"$apiName\" in value\n && \"$primaryKey\" in value;\n }\n\n /**\n * Merge object data for a specific target cache key, preserving RDP fields\n */\n private mergeForTarget(\n sourceValue: ObjectHolder,\n targetCurrentValue: ObjectHolder | undefined,\n sourceCacheKey: ObjectCacheKey,\n targetCacheKey: ObjectCacheKey,\n ): ObjectHolder {\n const sourceRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(\n sourceCacheKey,\n );\n const targetRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(\n targetCacheKey,\n );\n\n return mergeObjectFields(\n sourceValue,\n sourceRdpFields,\n targetRdpFields,\n targetCurrentValue,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,OAAOA,SAAS,MAAM,iBAAiB;AAKvC,SAASC,cAAc,QAAQ,sBAAsB;AAKrD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,OAAO,M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,CAAC;QACzC;MACF;MAEA,MAAMkB,kBAAkB,GAAG7B,KAAK,CAACa,IAAI,CAACc,SAAS,CAAC,EAAEjB,KAAK;MACvD,MAAMoB,MAAM,GAAG,IAAI,CAACC,cAAc,CAChCrB,KAAK,EACLmB,kBAAkB,IAAI,IAAI,CAACG,cAAc,CAACH,kBAAkB,CAAC,GACzDA,kBAAkB,GAClBpC,SAAS,EACbgB,cAAc,EACdkB,SACF,CAAC;MAED3B,KAAK,CAACiB,KAAK,CAACU,SAAS,EAAEG,MAAM,EAAEnB,MAAM,CAAC;IACxC;EACF;;EAEA;AACF;AACA;EACUiB,WAAWA,CAACK,GAAmB,EAAW;IAChD,MAAMC,OAAO,GAAG,IAAI,CAACxC,KAAK,CAACE,QAAQ,CAACuC,IAAI,CAACF,GAAG,CAAC;IAC7C,OAAOC,OAAO,EAAEE,QAAQ,KAAK,IAAI;EACnC;;EAEA;AACF;AACA;EACUJ,cAAcA,CACpBtB,KAA+B,EACR;IACvB,OAAOA,KAAK,IAAI,IAAI,IACf,OAAOA,KAAK,KAAK,QAAQ,IACzB,UAAU,IAAIA,KAAK,IACnB,aAAa,IAAIA,KAAK;EAC7B;;EAEA;AACF;AACA;EACUqB,cAAcA,CACpBM,WAAyB,EACzBR,kBAA4C,EAC5CpB,cAA8B,EAC9B6B,cAA8B,EAChB;IACd,MAAMC,eAAe,GAAG,IAAI,CAAC7C,KAAK,CAAC2B,sBAAsB,CAACmB,cAAc,CACtE/B,cACF,CAAC;IACD,MAAMgC,eAAe,GAAG,IAAI,CAAC/C,KAAK,CAAC2B,sBAAsB,CAACmB,cAAc,CACtEF,cACF,CAAC;IAED,OAAO1D,iBAAiB,CACtByD,WAAW,EACXE,eAAe,EACfE,eAAe,EACfZ,kBACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-do-not-use.js","names":["augment","computeObjectSetCacheKey","createObservableClient","getMetaTagContent","getOsdkConfig","createClientWithTransaction"],"sources":["unstable-do-not-use.ts"],"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\nexport { augment } from \"../object/fetchPage.js\";\n\n// THIS IS NOT THE FINAL NAME DO NOT SHIP LIKE THIS\nexport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nexport { computeObjectSetCacheKey } from \"../observable/computeObjectSetCacheKey.js\";\nexport { createObservableClient } from \"../observable/ObservableClient.js\";\nexport type {\n ObservableClient,\n ObserveAggregationArgs,\n ObserveObjectCallbackArgs,\n ObserveObjectsCallbackArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../observable/ObservableClient.js\";\nexport type { Observer } from \"../observable/ObservableClient/common.js\";\nexport type { ObserveLinks } from \"../observable/ObservableClient/ObserveLink.js\";\nexport {\n getMetaTagContent,\n getOsdkConfig,\n} from \"../public-utils/osdkConfig.js\";\nexport type { OsdkConfig } from \"../public-utils/osdkConfig.js\";\n\nexport { createClientWithTransaction } from \"../createClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,wBAAwB;;AAEhD;;AAEA,SAASC,wBAAwB,QAAQ,2CAA2C;AACpF,SAASC,sBAAsB,QAAQ,mCAAmC;
|
|
1
|
+
{"version":3,"file":"unstable-do-not-use.js","names":["augment","computeObjectSetCacheKey","createObservableClient","getMetaTagContent","getOsdkConfig","createClientWithTransaction"],"sources":["unstable-do-not-use.ts"],"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\nexport { augment } from \"../object/fetchPage.js\";\n\n// THIS IS NOT THE FINAL NAME DO NOT SHIP LIKE THIS\nexport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nexport { computeObjectSetCacheKey } from \"../observable/computeObjectSetCacheKey.js\";\nexport { createObservableClient } from \"../observable/ObservableClient.js\";\nexport type {\n ObservableClient,\n ObserveAggregationArgs,\n ObserveFunctionCallbackArgs,\n ObserveFunctionOptions,\n ObserveObjectCallbackArgs,\n ObserveObjectsCallbackArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../observable/ObservableClient.js\";\nexport type { Observer } from \"../observable/ObservableClient/common.js\";\nexport type { ObserveLinks } from \"../observable/ObservableClient/ObserveLink.js\";\nexport {\n getMetaTagContent,\n getOsdkConfig,\n} from \"../public-utils/osdkConfig.js\";\nexport type { OsdkConfig } from \"../public-utils/osdkConfig.js\";\n\nexport { createClientWithTransaction } from \"../createClient.js\";\nexport type { QueryParameterType, QueryReturnType } from \"../queries/types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,wBAAwB;;AAEhD;;AAEA,SAASC,wBAAwB,QAAQ,2CAA2C;AACpF,SAASC,sBAAsB,QAAQ,mCAAmC;AAa1E,SACEC,iBAAiB,EACjBC,aAAa,QACR,+BAA+B;AAGtC,SAASC,2BAA2B,QAAQ,oBAAoB","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.7.0-beta.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.7.0-beta.12"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.12"}`;
|
|
19
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isObjectSpecifiersObject.js","names":["isObjectSpecifiersObject","o","$apiName","$primaryKey"],"sources":["isObjectSpecifiersObject.ts"],"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 */\n\nimport type { PrimaryKeyTypes } from \"@osdk/api\";\n\nexport function isObjectSpecifiersObject(\n o: any,\n): o is {
|
|
1
|
+
{"version":3,"file":"isObjectSpecifiersObject.js","names":["isObjectSpecifiersObject","o","$apiName","$primaryKey"],"sources":["isObjectSpecifiersObject.ts"],"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 */\n\nimport type { PrimaryKeyTypes } from \"@osdk/api\";\n\nexport function isObjectSpecifiersObject(\n o: any,\n): o is {\n $apiName: string;\n $objectType?: string;\n $primaryKey: PrimaryKeyTypes;\n} {\n return o && typeof o === \"object\" && typeof o.$apiName === \"string\"\n && o.$primaryKey != null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,wBAAwBA,CACtCC,CAAM,EAKN;EACA,OAAOA,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAI,OAAOA,CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9DD,CAAC,CAACE,WAAW,IAAI,IAAI;AAC5B","ignoreList":[]}
|
|
@@ -63,4 +63,4 @@ interface Client extends SharedClient, OldSharedClient {
|
|
|
63
63
|
fetchMetadata<Q extends (ObjectTypeDefinition | InterfaceDefinition | ActionDefinition<any> | QueryDefinition<any>)>(o: Q): Promise<Q extends ObjectTypeDefinition ? ObjectMetadata : Q extends InterfaceDefinition ? InterfaceMetadata : Q extends ActionDefinition<any> ? ActionMetadata : Q extends QueryDefinition<any> ? QueryMetadata : never>;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export type { ActionSignatureFromDef as A, Client as C };
|
|
66
|
+
export type { ActionSignatureFromDef as A, Client as C, QueryReturnType as Q, QueryParameterType as a };
|
|
@@ -1757,7 +1757,7 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1757
1757
|
});
|
|
1758
1758
|
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "Stack must be a URL") : invariant4__default.default(false) : void 0;
|
|
1759
1759
|
}
|
|
1760
|
-
async subscribe(objectType, objectSet, listener, properties = []) {
|
|
1760
|
+
async subscribe(objectType, objectSet, listener, properties = [], shouldLoadRids = false) {
|
|
1761
1761
|
const objOrInterfaceDef = objectType.type === "object" ? await this.#client.ontologyProvider.getObjectDefinition(objectType.apiName) : await this.#client.ontologyProvider.getInterfaceDefinition(objectType.apiName);
|
|
1762
1762
|
let objectProperties = [];
|
|
1763
1763
|
let referenceProperties = [];
|
|
@@ -1776,7 +1776,8 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1776
1776
|
// Since we don't have a real subscription id yet but we need to keep
|
|
1777
1777
|
// track of this reference, we can just use a random uuid.
|
|
1778
1778
|
subscriptionId: `TMP-${nextUuid()}}`,
|
|
1779
|
-
interfaceApiName: objOrInterfaceDef.type === "object" ? void 0 : objOrInterfaceDef.apiName
|
|
1779
|
+
interfaceApiName: objOrInterfaceDef.type === "object" ? void 0 : objOrInterfaceDef.apiName,
|
|
1780
|
+
loadRids: shouldLoadRids
|
|
1780
1781
|
};
|
|
1781
1782
|
this.#subscriptions.set(sub.subscriptionId, sub);
|
|
1782
1783
|
void this.#initiateSubscribe(sub);
|
|
@@ -1829,7 +1830,10 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1829
1830
|
return {
|
|
1830
1831
|
objectSet,
|
|
1831
1832
|
propertySet: requestedProperties,
|
|
1832
|
-
referenceSet: requestedReferenceProperties
|
|
1833
|
+
referenceSet: requestedReferenceProperties,
|
|
1834
|
+
objectLoadingResponseOptions: {
|
|
1835
|
+
shouldLoadObjectRids: true
|
|
1836
|
+
}
|
|
1833
1837
|
};
|
|
1834
1838
|
})
|
|
1835
1839
|
};
|
|
@@ -1987,9 +1991,14 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1987
1991
|
}
|
|
1988
1992
|
const osdkObjectArray = await this.#client.objectFactory2(this.#client, [o.object], sub.interfaceApiName, {}, void 0, false, void 0, false, await this.#fetchInterfaceMapping(o.object.__apiName, sub.interfaceApiName));
|
|
1989
1993
|
const singleOsdkObject = osdkObjectArray[0] ?? void 0;
|
|
1990
|
-
|
|
1994
|
+
const rid = singleOsdkObject["$rid"];
|
|
1995
|
+
return singleOsdkObject != null ? rid === void 0 ? {
|
|
1991
1996
|
object: singleOsdkObject,
|
|
1992
1997
|
state: o.state
|
|
1998
|
+
} : {
|
|
1999
|
+
object: singleOsdkObject,
|
|
2000
|
+
state: o.state,
|
|
2001
|
+
rid
|
|
1993
2002
|
} : void 0;
|
|
1994
2003
|
}));
|
|
1995
2004
|
for (const osdkObject of osdkObjects) {
|
|
@@ -2233,7 +2242,7 @@ function createObjectSet(objectType, clientCtx, objectSet = resolveBaseObjectSet
|
|
|
2233
2242
|
})), objectType, options, await createWithPk(clientCtx, objectType, objectSet, primaryKey));
|
|
2234
2243
|
} : void 0,
|
|
2235
2244
|
subscribe: (listener, opts) => {
|
|
2236
|
-
const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(clientCtx).subscribe(objectType, objectSet, listener, opts?.properties);
|
|
2245
|
+
const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(clientCtx).subscribe(objectType, objectSet, listener, opts?.properties, opts?.includeRid);
|
|
2237
2246
|
return {
|
|
2238
2247
|
unsubscribe: async () => (await pendingSubscribe)()
|
|
2239
2248
|
};
|
|
@@ -2343,5 +2352,5 @@ exports.hydrateAttachmentFromRidInternal = hydrateAttachmentFromRidInternal;
|
|
|
2343
2352
|
exports.isObjectSet = isObjectSet;
|
|
2344
2353
|
exports.isWireObjectSet = isWireObjectSet;
|
|
2345
2354
|
exports.symbolClientContext = symbolClientContext;
|
|
2346
|
-
//# sourceMappingURL=chunk-
|
|
2347
|
-
//# sourceMappingURL=chunk-
|
|
2355
|
+
//# sourceMappingURL=chunk-4HXJEKQT.cjs.map
|
|
2356
|
+
//# sourceMappingURL=chunk-4HXJEKQT.cjs.map
|