@osdk/client 2.2.0-beta.8 → 2.2.0-beta.9
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 +18 -0
- package/build/browser/createMinimalClient.js +2 -2
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/object/SimpleOsdkProperties.js +2 -0
- package/build/browser/object/SimpleOsdkProperties.js.map +1 -0
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +10 -3
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +4 -2
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/fetchPage.js +13 -1
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +56 -2
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/InterfaceObjectSet.test.js +18 -2
- package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +92 -102
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +18 -14
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ListPayload.js.map +1 -1
- package/build/browser/observable/ObjectPayload.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/ActionApplication.js +29 -29
- package/build/browser/observable/internal/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/CacheKey.js +1 -1
- package/build/browser/observable/internal/CacheKey.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +2 -2
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
- package/build/browser/observable/internal/Changes.js.map +1 -0
- package/build/browser/observable/internal/Layer.js +3 -0
- package/build/browser/observable/internal/Layer.js.map +1 -1
- package/build/browser/observable/internal/ListQuery.js +411 -170
- package/build/browser/observable/internal/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/ObjectQuery.js +32 -16
- package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +4 -12
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/OrderByCanonicalizer.js +73 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.test.js +78 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
- package/build/browser/observable/internal/Query.js +64 -31
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/RefCounts.js +7 -2
- package/build/browser/observable/internal/RefCounts.js.map +1 -1
- package/build/browser/observable/internal/SimpleWhereClause.js +2 -0
- package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -0
- package/build/browser/observable/internal/Store.js +84 -267
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +264 -247
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js +11 -3
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +82 -18
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/cjs/{chunk-JPENHIJB.cjs → chunk-EY52J5Z4.cjs} +25 -15
- package/build/cjs/chunk-EY52J5Z4.cjs.map +1 -0
- package/build/cjs/{chunk-IU47QMYO.cjs → chunk-MCQVHD2F.cjs} +32 -28
- package/build/cjs/chunk-MCQVHD2F.cjs.map +1 -0
- package/build/cjs/chunk-T4NIFYZS.cjs +14 -0
- package/build/cjs/chunk-T4NIFYZS.cjs.map +1 -0
- package/build/cjs/index.cjs +69 -72
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/internal.cjs +6 -6
- package/build/cjs/public/unstable-do-not-use.cjs +683 -539
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +27 -26
- package/build/esm/createMinimalClient.js +2 -2
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/object/SimpleOsdkProperties.js +2 -0
- package/build/esm/object/SimpleOsdkProperties.js.map +1 -0
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +10 -3
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +4 -2
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/fetchPage.js +13 -1
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +56 -2
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/InterfaceObjectSet.test.js +18 -2
- package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +92 -102
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +18 -14
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ListPayload.js.map +1 -1
- package/build/esm/observable/ObjectPayload.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/ActionApplication.js +29 -29
- package/build/esm/observable/internal/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/CacheKey.js +1 -1
- package/build/esm/observable/internal/CacheKey.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +2 -2
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
- package/build/esm/observable/internal/Changes.js.map +1 -0
- package/build/esm/observable/internal/Layer.js +3 -0
- package/build/esm/observable/internal/Layer.js.map +1 -1
- package/build/esm/observable/internal/ListQuery.js +411 -170
- package/build/esm/observable/internal/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/ObjectQuery.js +32 -16
- package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +4 -12
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/OrderByCanonicalizer.js +73 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.test.js +78 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
- package/build/esm/observable/internal/Query.js +64 -31
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/RefCounts.js +7 -2
- package/build/esm/observable/internal/RefCounts.js.map +1 -1
- package/build/esm/observable/internal/SimpleWhereClause.js +2 -0
- package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -0
- package/build/esm/observable/internal/Store.js +84 -267
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +264 -247
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js +11 -3
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +82 -18
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/types/object/SimpleOsdkProperties.d.ts +1 -0
- package/build/types/object/SimpleOsdkProperties.d.ts.map +1 -0
- package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts +1 -0
- package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts.map +1 -0
- package/build/types/object/convertWireToOsdkObjects.d.ts +8 -1
- package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/types/observable/ListPayload.d.ts +5 -9
- package/build/types/observable/ListPayload.d.ts.map +1 -1
- package/build/types/observable/ObjectPayload.d.ts +4 -7
- package/build/types/observable/ObjectPayload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +27 -11
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +15 -0
- package/build/types/observable/internal/Changes.d.ts.map +1 -0
- package/build/types/observable/internal/Layer.d.ts +1 -0
- package/build/types/observable/internal/Layer.d.ts.map +1 -1
- package/build/types/observable/internal/ListQuery.d.ts +59 -14
- package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectQuery.d.ts +5 -6
- package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts +12 -0
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts.map +1 -0
- package/build/types/observable/internal/Query.d.ts +39 -4
- package/build/types/observable/internal/Query.d.ts.map +1 -1
- package/build/types/observable/internal/RefCounts.d.ts.map +1 -1
- package/build/types/observable/internal/SimpleWhereClause.d.ts +2 -0
- package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -0
- package/build/types/observable/internal/Store.d.ts +19 -43
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +2 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts +4 -2
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +39 -9
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +1 -4
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/package.json +12 -10
- package/build/browser/observable/internal/ChangedObjects.js.map +0 -1
- package/build/cjs/chunk-IU47QMYO.cjs.map +0 -1
- package/build/cjs/chunk-JPENHIJB.cjs.map +0 -1
- package/build/esm/observable/internal/ChangedObjects.js.map +0 -1
- package/build/types/observable/internal/ChangedObjects.d.ts +0 -11
- package/build/types/observable/internal/ChangedObjects.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKey.js","names":["DEBUG_ONLY__cacheKeyToString","x","process","env","NODE_ENV","type","otherKeys","map","xx","JSON","stringify","join","replaceAll","Error","DEBUG_ONLY__cacheKeysToString"],"sources":["CacheKey.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 { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeyToString(x: CacheKey) {\n if (process.env.NODE_ENV !== \"production\") {\n return `${x.type}CacheKey<${\n x.otherKeys.map(xx => JSON.stringify(xx)).join(\", \")\n }>`.replaceAll(\"\\\"\", \"'\");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeysToString(x: CacheKey[]) {\n if (process.env.NODE_ENV !== \"production\") {\n return
|
|
1
|
+
{"version":3,"file":"CacheKey.js","names":["DEBUG_ONLY__cacheKeyToString","x","process","env","NODE_ENV","type","otherKeys","map","xx","JSON","stringify","join","replaceAll","Error","DEBUG_ONLY__cacheKeysToString"],"sources":["CacheKey.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 { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeyToString(x: CacheKey) {\n if (process.env.NODE_ENV !== \"production\") {\n return `${x.type}CacheKey<${\n x.otherKeys.map(xx => JSON.stringify(xx)).join(\", \")\n }>`.replaceAll(\"\\\"\", \"'\");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeysToString(x: CacheKey[]) {\n if (process.env.NODE_ENV !== \"production\") {\n return \"\\n - \" + x.map(DEBUG_ONLY__cacheKeyToString).join(\"\\n - \");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAACC,CAAW,EAAE;EACxD,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAO,GAAGH,CAAC,CAACI,IAAI,YACdJ,CAAC,CAACK,SAAS,CAACC,GAAG,CAACC,EAAE,IAAIC,IAAI,CAACC,SAAS,CAACF,EAAE,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC,GACnD,CAACC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;EAC3B,CAAC,MAAM;IACL,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAACb,CAAa,EAAE;EAC3D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAO,QAAQ,GAAGH,CAAC,CAACM,GAAG,CAACP,4BAA4B,CAAC,CAACW,IAAI,CAAC,QAAQ,CAAC;EACtE,CAAC,MAAM;IACL,MAAM,IAAIE,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF","ignoreList":[]}
|
|
@@ -37,12 +37,12 @@ export class CacheKeys {
|
|
|
37
37
|
}
|
|
38
38
|
return this.#cacheKeys.lookupArray(["object", apiName, pk]);
|
|
39
39
|
});
|
|
40
|
-
this.#registerCacheKeyFactory("list", (apiName, where, orderBy) => {
|
|
40
|
+
this.#registerCacheKeyFactory("list", (type, apiName, where, orderBy) => {
|
|
41
41
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
42
42
|
// eslint-disable-next-line no-console
|
|
43
43
|
console.debug(`CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${JSON.stringify(orderBy)}]) -- already exists? `, this.#cacheKeys.peekArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]) != null);
|
|
44
44
|
}
|
|
45
|
-
return this.#cacheKeys.lookupArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
|
|
45
|
+
return this.#cacheKeys.lookupArray(["list", type, apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
#registerCacheKeyFactory(type, factory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.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 { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./
|
|
1
|
+
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.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 { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./OrderByCanonicalizer.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\ntype CacheKeyArgs<K extends CacheKey> = [K[\"type\"], ...K[\"otherKeys\"]];\n\nexport class CacheKeys {\n #cacheKeys = new Trie<CacheKey<string, any, any>>(false, (keys) => {\n const ret = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as CacheKey<\n string,\n any,\n any\n >;\n this.#onCreate(ret);\n return ret;\n });\n #cacheKeyFactories = new Map<string, (...args: any[]) => CacheKey>();\n #onCreate: (cacheKey: CacheKey) => void;\n\n constructor(\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n onCreate: (cacheKey: CacheKey) => void,\n ) {\n this.#onCreate = onCreate;\n this.#registerCacheKeyFactory<ObjectCacheKey>(\n \"object\",\n (apiName, pk) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([object, ${apiName}, ${pk}]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"object\",\n apiName,\n pk,\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray([\n \"object\",\n apiName,\n pk,\n ]) as ObjectCacheKey;\n },\n );\n this.#registerCacheKeyFactory<ListCacheKey>(\n \"list\",\n (type, apiName, where, orderBy) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${\n JSON.stringify(orderBy)\n }]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"list\",\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray<\n CacheKeyArgs<ListCacheKey>\n >([\n \"list\",\n type,\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) as ListCacheKey;\n },\n );\n }\n\n #registerCacheKeyFactory<K extends CacheKey>(\n type: K[\"type\"],\n factory: (...args: K[\"__cacheKey\"][\"args\"]) => K,\n ): void {\n this.#cacheKeyFactories.set(type, factory);\n }\n\n get<K extends CacheKey<string, any, any>>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n const factory = this.#cacheKeyFactories.get(type);\n invariant(factory, `no cache key factory for type \"${type}\"`);\n return factory(...args) as K;\n }\n\n remove<K extends CacheKey<string, any, any>>(\n cacheKey: K,\n ): void {\n this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A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+16,32 @@
|
|
|
16
16
|
|
|
17
17
|
import { MultiMap } from "mnemonist";
|
|
18
18
|
import { DEBUG_ONLY__cacheKeyToString } from "./CacheKey.js";
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export class Changes {
|
|
20
|
+
modifiedObjects = new MultiMap();
|
|
21
|
+
addedObjects = new MultiMap();
|
|
22
|
+
added = new Set();
|
|
23
|
+
modified = new Set();
|
|
24
|
+
registerObject = (cacheKey, data, isNew) => {
|
|
25
|
+
this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
|
|
26
|
+
this[isNew ? "added" : "modified"].add(cacheKey);
|
|
27
|
+
};
|
|
28
|
+
registerList = key => {
|
|
29
|
+
this.modified.add(key);
|
|
25
30
|
};
|
|
31
|
+
isEmpty() {
|
|
32
|
+
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function createChangedObjects() {
|
|
36
|
+
return new Changes();
|
|
26
37
|
}
|
|
27
38
|
export function DEBUG_ONLY__changesToString(changes) {
|
|
28
39
|
if (process.env.NODE_ENV !== "production") {
|
|
29
40
|
return JSON.stringify({
|
|
30
41
|
modifiedObjects: multimapHelper(changes.modifiedObjects),
|
|
31
42
|
addedObjects: multimapHelper(changes.addedObjects),
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
added: listHelper(changes.added),
|
|
44
|
+
modified: listHelper(changes.modified)
|
|
34
45
|
}, null, 2);
|
|
35
46
|
} else {
|
|
36
47
|
throw new Error("not implemented");
|
|
@@ -44,4 +55,4 @@ function multimapHelper(multimap) {
|
|
|
44
55
|
return [type, objects.map(o => o.$primaryKey)];
|
|
45
56
|
}));
|
|
46
57
|
}
|
|
47
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=Changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","registerObject","cacheKey","data","isNew","set","$apiName","add","registerList","key","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.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 { MultiMap } from \"mnemonist\";\nimport type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<ListCacheKey | ObjectCacheKey> = new Set();\n modified: Set<ListCacheKey | ObjectCacheKey> = new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(data.$apiName, data);\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,WAAW;AAGpC,SAASC,4BAA4B,QAAQ,eAAe;AAI5D,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIH,QAAQ,CAAC,CAAC;EAChEI,YAAY,GAAmC,IAAIJ,QAAQ,CAAC,CAAC;EAE7DK,KAAK,GAAuC,IAAIC,GAAG,CAAC,CAAC;EACrDC,QAAQ,GAAuC,IAAID,GAAG,CAAC,CAAC;EAExDE,cAAc,GAAGA,CACfC,QAAwB,EACxBC,IAAkB,EAClBC,KAAc,KACL;IACT,IAAI,CAACA,KAAK,GAAG,cAAc,GAAG,iBAAiB,CAAC,CAACC,GAAG,CAACF,IAAI,CAACG,QAAQ,EAAEH,IAAI,CAAC;IACzE,IAAI,CAACC,KAAK,GAAG,OAAO,GAAG,UAAU,CAAC,CAACG,GAAG,CAACL,QAAQ,CAAC;EAClD,CAAC;EAEDM,YAAY,GAAIC,GAAiB,IAAW;IAC1C,IA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IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.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 { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent.removeLayer(layerId);\n }\n\n entries(): IterableIterator<[CacheKey<string, any, any>, Entry<any>]> {\n return this.#cache.entries();\n }\n\n public get<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n ): Entry<K> | undefined {\n return this.#cache.get(cacheKey) as Entry<K> | undefined\n ?? this.#parent?.get(cacheKey) as Entry<K> | undefined;\n }\n\n public set<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n value: Entry<K>,\n ): void {\n this.#cache.set(cacheKey, value);\n }\n}\n\nexport class Entry<K extends CacheKey<any, any, any>> {\n readonly cacheKey: K;\n value: K[\"__cacheKey\"][\"value\"] | undefined;\n lastUpdated: number;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n constructor(\n cacheKey: K,\n value: K[\"__cacheKey\"][\"value\"],\n lastUpdated: number,\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" = \"init\",\n ) {\n this.cacheKey = cacheKey;\n this.value = value;\n this.lastUpdated = lastUpdated;\n this.status = status;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,kBAAkB,QAAQ,yBAAyB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,KAAK,CAAC;EACjB,CAACC,MAAM;EACP,CAACC,KAAK,GAAG,IAAIH,kBAAkB,CAAyC,CAAC;EACzE,CAACI,OAAO;EAERC,WAAWA,CAACH,MAAyB,EAAEE,OAAgB,EAAE;IACvD,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACE,OAAO,GAAGA,OAAO;EACzB;EAEA,IAAIE,WAAWA,CAAA,EAAsB;IACnC,OAAO,IAAI,CAAC,CAACJ,MAAM;EACrB;EAEA,IAAIE,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAAC,CAACA,OAAO;EACtB;EAEAG,QAAQA,CAACH,OAAgB,EAAS;IAChC,OAAO,IAAIH,KAAK,CAAC,IAAI,EAAEG,OAAO,CAAC;EACjC;EAEAI,WAAWA,CAACJ,OAAgB,EAAS;IACnC,IAAIA,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,CAACF,MAAM,IAAI,IAAI,EAAE;MAC3C;MACA,OAAO,IAAI;IACb;IAEA,IAAI,IAAI,CAAC,CAACE,OAAO,KAAKA,OAAO,EAAE;MAC7B,IAAI,CAAC,CAACF,MAAM,GAAG,IAAI,CAAC,CAACA,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;MAChD,OAAO,IAAI;IACb;IAEA,OAAO,IAAI,CAAC,CAACF,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;EAC1C;EAEAK,OAAOA,CAAA,EAA+D;IACpE,OAAO,IAAI,CAAC,CAACN,KAAK,CAACM,OAAO,CAAC,CAAC;EAC9B;EAEOC,GAAGA,CACRC,QAAW,EACW;IACtB,OAAO,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","keys","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.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 { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent.removeLayer(layerId);\n }\n\n entries(): IterableIterator<[CacheKey<string, any, any>, Entry<any>]> {\n return this.#cache.entries();\n }\n\n keys(): IterableIterator<CacheKey<string, any, any>> {\n return this.#cache.keys();\n }\n\n public get<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n ): Entry<K> | undefined {\n return this.#cache.get(cacheKey) as Entry<K> | undefined\n ?? this.#parent?.get(cacheKey) as Entry<K> | undefined;\n }\n\n public set<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n value: Entry<K>,\n ): void {\n this.#cache.set(cacheKey, value);\n }\n}\n\nexport class Entry<K extends CacheKey<any, any, any>> {\n readonly cacheKey: K;\n value: K[\"__cacheKey\"][\"value\"] | undefined;\n lastUpdated: number;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n constructor(\n cacheKey: K,\n value: K[\"__cacheKey\"][\"value\"],\n lastUpdated: number,\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" = \"init\",\n ) {\n this.cacheKey = cacheKey;\n this.value = value;\n this.last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