@osdk/client 2.5.2 → 2.6.0-beta.10
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 +118 -73
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/actions/applyAction.js +4 -0
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +2 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createClient.test.js +19 -1
- package/build/browser/createClient.test.js.map +1 -1
- package/build/browser/createMinimalClient.js +4 -2
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +19 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +2 -2
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/extractNamespace.js +22 -0
- package/build/browser/internal/conversions/extractNamespace.js.map +1 -0
- package/build/browser/internal/conversions/fullyQualifyPropName.js +26 -0
- package/build/browser/internal/conversions/fullyQualifyPropName.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterBbox.js +41 -0
- package/build/browser/internal/conversions/makeGeoFilterBbox.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterIntersects.js +29 -0
- package/build/browser/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterPolygon.js +30 -0
- package/build/browser/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterWithin.js +48 -0
- package/build/browser/internal/conversions/makeGeoFilterWithin.js.map +1 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +59 -105
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +309 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/aggregate.js +3 -0
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +5 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +13 -6
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/browser/object/formatting/formatBoolean.js +23 -0
- package/build/browser/object/formatting/formatBoolean.js.map +1 -0
- package/build/browser/object/formatting/formatDateTime.js +158 -0
- package/build/browser/object/formatting/formatDateTime.js.map +1 -0
- package/build/browser/object/formatting/formatNumber.js +242 -0
- package/build/browser/object/formatting/formatNumber.js.map +1 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/browser/object/mediaUpload.js +3 -0
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +17 -0
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +11 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.js +12 -4
- package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.test.js +48 -0
- package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +9 -3
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/Canonicalizer.js +51 -0
- package/build/browser/observable/internal/Canonicalizer.js.map +1 -0
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/IntersectCanonicalizer.js +35 -0
- package/build/browser/observable/internal/IntersectCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +3 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OrderByCanonicalizer.js +1 -4
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/PivotCanonicalizer.js +33 -0
- package/build/browser/observable/internal/PivotCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/RdpCanonicalizer.js +66 -0
- package/build/browser/observable/internal/RdpCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/RdpCanonicalizer.test.js +68 -0
- package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -0
- package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -1
- package/build/browser/observable/internal/Store.js +172 -6
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/actions/ActionApplication.js +1 -1
- package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/actions/OptimisticJob.js +3 -3
- package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/aggregation/AggregationCacheKey.js +22 -0
- package/build/browser/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
- package/build/browser/observable/internal/aggregation/AggregationQuery.js +77 -0
- package/build/browser/observable/internal/aggregation/AggregationQuery.js.map +1 -0
- package/build/browser/observable/internal/aggregation/AggregationsHelper.js +54 -0
- package/build/browser/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
- package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
- package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
- package/build/browser/observable/internal/base-list/BaseListQuery.js +145 -5
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js +0 -5
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
- package/build/browser/observable/internal/evaluateFilter.js +61 -0
- package/build/browser/observable/internal/evaluateFilter.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +33 -1
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/InterfaceListQuery.js +8 -3
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListCacheKey.js +24 -1
- package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +35 -62
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListQueryOptions.js.map +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js +18 -8
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js +51 -3
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectCacheKey.js +20 -1
- package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectQuery.js +10 -58
- package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectsHelper.js +65 -5
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.js +3 -37
- package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js +5 -1
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +3 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
- package/build/browser/observable/internal/testUtils/invalidateList.js +6 -1
- package/build/browser/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +5 -3
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/observable/internal/types/ObjectUpdate.js +2 -0
- package/build/browser/observable/internal/types/ObjectUpdate.js.map +1 -0
- package/build/browser/observable/internal/utils/rdpFieldOperations.js +83 -0
- package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -0
- package/build/browser/ontology/loadActionMetadata.js +3 -1
- package/build/browser/ontology/loadActionMetadata.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
- package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/browser/public/internal-node.js +18 -0
- package/build/browser/public/internal-node.js.map +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/queries/applyQuery.js +5 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.js +5 -1
- package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/browser/util/toDataValue.js +16 -1
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +42 -2
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/chunk-6SCDLAU2.cjs +57 -0
- package/build/cjs/chunk-6SCDLAU2.cjs.map +1 -0
- package/build/cjs/{chunk-SDFKR62Z.cjs → chunk-HJX4D4KL.cjs} +627 -63
- package/build/cjs/chunk-HJX4D4KL.cjs.map +1 -0
- package/build/cjs/{chunk-MEL46GIF.cjs → chunk-RO7XAQOS.cjs} +454 -242
- package/build/cjs/chunk-RO7XAQOS.cjs.map +1 -0
- package/build/cjs/{createClient-BJo8T7Js.d.cts → createClient-mOlFts15.d.cts} +1 -0
- package/build/cjs/{delay-QK4T7RVX.cjs → delay-KIUUJ5NJ.cjs} +4 -3
- package/build/cjs/delay-KIUUJ5NJ.cjs.map +1 -0
- package/build/cjs/index.cjs +24 -8
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +10 -3
- package/build/cjs/public/internal-node.cjs +193767 -0
- package/build/cjs/public/internal-node.cjs.map +1 -0
- package/build/cjs/public/internal-node.d.cts +29 -0
- package/build/cjs/public/internal.cjs +16 -9
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +1736 -868
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +43 -7
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/actions/applyAction.js +4 -0
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +2 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createClient.test.js +19 -1
- package/build/esm/createClient.test.js.map +1 -1
- package/build/esm/createMinimalClient.js +4 -2
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +19 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/extractNamespace.js +22 -0
- package/build/esm/internal/conversions/extractNamespace.js.map +1 -0
- package/build/esm/internal/conversions/fullyQualifyPropName.js +26 -0
- package/build/esm/internal/conversions/fullyQualifyPropName.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterBbox.js +41 -0
- package/build/esm/internal/conversions/makeGeoFilterBbox.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterIntersects.js +29 -0
- package/build/esm/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterPolygon.js +30 -0
- package/build/esm/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterWithin.js +48 -0
- package/build/esm/internal/conversions/makeGeoFilterWithin.js.map +1 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +59 -105
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +309 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/aggregate.js +3 -0
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +5 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +13 -6
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/esm/object/formatting/formatBoolean.js +23 -0
- package/build/esm/object/formatting/formatBoolean.js.map +1 -0
- package/build/esm/object/formatting/formatDateTime.js +158 -0
- package/build/esm/object/formatting/formatDateTime.js.map +1 -0
- package/build/esm/object/formatting/formatNumber.js +242 -0
- package/build/esm/object/formatting/formatNumber.js.map +1 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/esm/object/mediaUpload.js +3 -0
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +17 -0
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +11 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.js +12 -4
- package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.test.js +48 -0
- package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +9 -3
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/Canonicalizer.js +51 -0
- package/build/esm/observable/internal/Canonicalizer.js.map +1 -0
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/IntersectCanonicalizer.js +35 -0
- package/build/esm/observable/internal/IntersectCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +3 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OrderByCanonicalizer.js +1 -4
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/PivotCanonicalizer.js +33 -0
- package/build/esm/observable/internal/PivotCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/RdpCanonicalizer.js +66 -0
- package/build/esm/observable/internal/RdpCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/RdpCanonicalizer.test.js +68 -0
- package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -0
- package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -1
- package/build/esm/observable/internal/Store.js +172 -6
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/actions/ActionApplication.js +1 -1
- package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/actions/OptimisticJob.js +3 -3
- package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/aggregation/AggregationCacheKey.js +22 -0
- package/build/esm/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
- package/build/esm/observable/internal/aggregation/AggregationQuery.js +77 -0
- package/build/esm/observable/internal/aggregation/AggregationQuery.js.map +1 -0
- package/build/esm/observable/internal/aggregation/AggregationsHelper.js +54 -0
- package/build/esm/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
- package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
- package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
- package/build/esm/observable/internal/base-list/BaseListQuery.js +145 -5
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js +0 -5
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
- package/build/esm/observable/internal/evaluateFilter.js +61 -0
- package/build/esm/observable/internal/evaluateFilter.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +33 -1
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/InterfaceListQuery.js +8 -3
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListCacheKey.js +24 -1
- package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +35 -62
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListQueryOptions.js.map +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js +18 -8
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js +51 -3
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectCacheKey.js +20 -1
- package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectQuery.js +10 -58
- package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectsHelper.js +65 -5
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.js +3 -37
- package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js +5 -1
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +3 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
- package/build/esm/observable/internal/testUtils/invalidateList.js +6 -1
- package/build/esm/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +5 -3
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/observable/internal/types/ObjectUpdate.js +2 -0
- package/build/esm/observable/internal/types/ObjectUpdate.js.map +1 -0
- package/build/esm/observable/internal/utils/rdpFieldOperations.js +83 -0
- package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -0
- package/build/esm/ontology/loadActionMetadata.js +3 -1
- package/build/esm/ontology/loadActionMetadata.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
- package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/esm/public/internal-node.js +18 -0
- package/build/esm/public/internal-node.js.map +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.js +5 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.js +5 -1
- package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/esm/util/toDataValue.js +16 -1
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +42 -2
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/MinimalClientContext.d.ts +3 -1
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +1 -0
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/internal/conversions/extractNamespace.d.ts +1 -0
- package/build/types/internal/conversions/extractNamespace.d.ts.map +1 -0
- package/build/types/internal/conversions/fullyQualifyPropName.d.ts +2 -0
- package/build/types/internal/conversions/fullyQualifyPropName.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterBbox.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterBbox.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterWithin.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterWithin.d.ts.map +1 -0
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
- package/build/types/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/formatting/applyPropertyFormatter.d.ts +18 -0
- package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts.map +1 -0
- package/build/types/object/formatting/formatBoolean.d.ts +5 -0
- package/build/types/object/formatting/formatBoolean.d.ts.map +1 -0
- package/build/types/object/formatting/formatDateTime.d.ts +6 -0
- package/build/types/object/formatting/formatDateTime.d.ts.map +1 -0
- package/build/types/object/formatting/formatNumber.d.ts +15 -0
- package/build/types/object/formatting/formatNumber.d.ts.map +1 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts +10 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts.map +1 -0
- package/build/types/object/mediaUpload.d.ts +2 -1
- package/build/types/object/mediaUpload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +60 -5
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Canonicalizer.d.ts +37 -0
- package/build/types/observable/internal/Canonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/Changes.d.ts +4 -3
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/IntersectCanonicalizer.d.ts +18 -0
- package/build/types/observable/internal/IntersectCanonicalizer.d.ts.map +1 -0
- 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/OrderByCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/PivotCanonicalizer.d.ts +10 -0
- package/build/types/observable/internal/PivotCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/RdpCanonicalizer.d.ts +8 -0
- package/build/types/observable/internal/RdpCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/RdpCanonicalizer.test.d.ts +1 -0
- package/build/types/observable/internal/RdpCanonicalizer.test.d.ts.map +1 -0
- package/build/types/observable/internal/SimpleWhereClause.d.ts +6 -2
- package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +10 -0
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +5 -2
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts +12 -0
- package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/AggregationQuery.d.ts +49 -0
- package/build/types/observable/internal/aggregation/AggregationQuery.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts +37 -0
- package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts +5 -0
- package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts +48 -2
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts +1 -23
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -1
- package/build/types/observable/internal/evaluateFilter.d.ts +6 -0
- package/build/types/observable/internal/evaluateFilter.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +5 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts +10 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts +12 -15
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQueryOptions.d.ts +9 -1
- package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts +7 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts +6 -1
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts +60 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts +1 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectQuery.d.ts +1 -1
- package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts +15 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/observable/internal/types/ObjectUpdate.d.ts +11 -0
- package/build/types/observable/internal/types/ObjectUpdate.d.ts.map +1 -0
- package/build/types/observable/internal/utils/rdpFieldOperations.d.ts +5 -0
- package/build/types/observable/internal/utils/rdpFieldOperations.d.ts.map +1 -0
- package/build/types/public/internal-node.d.ts +2 -0
- package/build/types/public/internal-node.d.ts.map +1 -0
- package/build/types/public/unstable-do-not-use.d.ts +1 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/internal-node.d.ts +17 -0
- package/package.json +23 -13
- package/build/cjs/chunk-MEL46GIF.cjs.map +0 -1
- package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
- package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
- package/build/cjs/chunk-SDFKR62Z.cjs.map +0 -1
- package/build/cjs/delay-QK4T7RVX.cjs.map +0 -1
|
@@ -108,5 +108,53 @@ describe(BulkObjectLoader, () => {
|
|
|
108
108
|
expect(mockThen).toHaveBeenCalled();
|
|
109
109
|
vi.useRealTimers();
|
|
110
110
|
});
|
|
111
|
+
it("uses $eq for single object and $in for multiple objects", async () => {
|
|
112
|
+
const loader = new BulkObjectLoader(client, 25, 100);
|
|
113
|
+
vi.useFakeTimers();
|
|
114
|
+
const whereClauses = [];
|
|
115
|
+
const mockObjectSet = {
|
|
116
|
+
where: clause => {
|
|
117
|
+
whereClauses.push(clause);
|
|
118
|
+
return mockObjectSet;
|
|
119
|
+
},
|
|
120
|
+
fetchPage: vi.fn().mockResolvedValue({
|
|
121
|
+
data: [employees[0]],
|
|
122
|
+
nextPageToken: undefined,
|
|
123
|
+
totalCount: "1"
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
client.mockReturnValueOnce(mockObjectSet);
|
|
127
|
+
const load0 = loader.fetch("Employee", 0);
|
|
128
|
+
vi.advanceTimersByTime(26);
|
|
129
|
+
await load0;
|
|
130
|
+
expect(whereClauses[0]).toEqual({
|
|
131
|
+
id: {
|
|
132
|
+
$eq: 0
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
whereClauses.length = 0;
|
|
136
|
+
const mockObjectSet2 = {
|
|
137
|
+
where: clause => {
|
|
138
|
+
whereClauses.push(clause);
|
|
139
|
+
return mockObjectSet2;
|
|
140
|
+
},
|
|
141
|
+
fetchPage: vi.fn().mockResolvedValue({
|
|
142
|
+
data: [employees[1], employees[2]],
|
|
143
|
+
nextPageToken: undefined,
|
|
144
|
+
totalCount: "2"
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
client.mockReturnValueOnce(mockObjectSet2);
|
|
148
|
+
const load1 = loader.fetch("Employee", 1);
|
|
149
|
+
const load2 = loader.fetch("Employee", 2);
|
|
150
|
+
vi.advanceTimersByTime(26);
|
|
151
|
+
await Promise.all([load1, load2]);
|
|
152
|
+
expect(whereClauses[0]).toEqual({
|
|
153
|
+
id: {
|
|
154
|
+
$in: [1, 2]
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
vi.useRealTimers();
|
|
158
|
+
});
|
|
111
159
|
});
|
|
112
160
|
//# sourceMappingURL=BulkObjectLoader.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkObjectLoader.test.js","names":["beforeEach","describe","expect","it","vi","BulkObjectLoader","createClientMockHelper","client","mockClient","mocked","fetchMetadata","mockReturnValue","Promise","resolve","primaryKeyApiName","employees","$apiName","$objectType","$primaryKey","loader","firstRequest","mockFetchPageOnce","secondRequest","load0","fetch","load1","load2","data","nextPageToken","undefined","totalCount","resolves","toMatchObject","mock","fn","then","not","toHaveBeenCalled","useFakeTimers","advanceTimersByTime","runOnlyPendingTimers","mockThen","useRealTimers"],"sources":["BulkObjectLoader.test.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 { ObjectMetadata } from \"@osdk/api\";\nimport type { Mock } from \"vitest\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../../Client.js\";\nimport { BulkObjectLoader } from \"./BulkObjectLoader.js\";\nimport { createClientMockHelper, type MockClientHelper } from \"./testUtils.js\";\n\ndescribe(BulkObjectLoader, () => {\n let client: Mock<Client> & Client;\n let mockClient: MockClientHelper;\n\n beforeEach(async () => {\n mockClient = createClientMockHelper();\n client = mockClient.client;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n vi.mocked(client.fetchMetadata).mockReturnValue(\n Promise.resolve(\n {\n primaryKeyApiName: \"id\",\n } satisfies Pick<ObjectMetadata, \"primaryKeyApiName\"> as ObjectMetadata,\n ),\n );\n });\n\n const employees = [\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 0,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 1,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 2,\n },\n ];\n\n it(\"splits up work by count\", async () => {\n const loader = new BulkObjectLoader(client, 25, /*ms*/ 2 /*entries*/);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n const load0 = loader.fetch(\"Employee\", 0);\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0], employees[1]],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n const mock = vi.fn();\n void load2.then(mock);\n expect(mock).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [employees[2]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mock).toHaveBeenCalled();\n });\n\n it(\"splits up work by time\", async () => {\n const loader = new BulkObjectLoader(client, /*ms*/ 25, /*entries*/ 100);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n vi.useFakeTimers();\n\n const load0 = loader.fetch(\"Employee\", 0);\n\n vi.advanceTimersByTime(26);\n\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n vi.runOnlyPendingTimers();\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n const mockThen = vi.fn();\n void load2.then(mockThen);\n\n expect(mockThen).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [\n employees[1],\n employees[2],\n ],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mockThen).toHaveBeenCalled();\n\n vi.useRealTimers();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAE7D,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,sBAAsB,QAA+B,gBAAgB;AAE9EL,QAAQ,CAACI,gBAAgB,EAAE,MAAM;EAC/B,IAAIE,MAA6B;EACjC,IAAIC,UAA4B;EAEhCR,UAAU,CAAC,YAAY;IACrBQ,UAAU,GAAGF,sBAAsB,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E,CAAC,CAAC;IAEzCJ,YAAY,CAACP,OAAO,CAAC;MACnBc,IAAI,EAAE,CAACZ,SAAS,CAAC,CAAC,CAAC,CAAC;MACpBa,aAAa,EAAEC,SAAS;MACxBC,UAAU,EAAE;IACd,CAAC,CAAC;IAEF1B,EAAE,CAACoC,oBAAoB,CAAC,CAAC;IAEzB,MAAMtC,MAAM,CAACqB,KAAK,CAAC,CAACQ,QAAQ,CAACC,aAAa,CAAC;MACzCd,WAAW,EAAE;IACf,CAAC,CAAC;IAEF,MAAMuB,QAAQ,GAAGrC,EAAE,CAAC8B,EAAE,CAAC,CAAC;IACxB,KAAKR,KAAK,CAACS,IAAI,CAACM,QAAQ,CAAC;IAEzBvC,MAAM,CAACuC,QAAQ,CAAC,CAACL,GAAG,CAACC,gBAAgB,CAAC,CAAC;IAEvCf,aAAa,CAACT,OAAO,CAAC;MACpBc,IAAI,EAAE,CACJZ,SAAS,CAAC,CAAC,CAAC,EACZA,SAAS,CAAC,CAAC,CAAC,CACb;MACDa,aAAa,EAAEC,SAAS;MACxBC,UAAU,EAAE;IACd,CAAC,CAAC;IAEF,MAAM5B,MAAM,CAACuB,KAAK,CAAC,CAACM,QAAQ,CAACC,aAAa,CAAC;MACzCd,WAAW,EAAE;IACf,CAAC,CAAC;IAEF,MAAMhB,MAAM,CAACwB,KAAK,CAAC,CAACK,QAAQ,CAACC,aAAa,CAAC;MACzCd,WAAW,EAAE;IACf,CAAC,CAAC;IAEFhB,MAAM,CAACuC,QAAQ,CAAC,CAACJ,gBAAgB,CAAC,CAAC;IAEnCjC,EAAE,CAACsC,aAAa,CAAC,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BulkObjectLoader.test.js","names":["beforeEach","describe","expect","it","vi","BulkObjectLoader","createClientMockHelper","client","mockClient","mocked","fetchMetadata","mockReturnValue","Promise","resolve","primaryKeyApiName","employees","$apiName","$objectType","$primaryKey","loader","firstRequest","mockFetchPageOnce","secondRequest","load0","fetch","load1","load2","data","nextPageToken","undefined","totalCount","resolves","toMatchObject","mock","fn","then","not","toHaveBeenCalled","useFakeTimers","advanceTimersByTime","runOnlyPendingTimers","mockThen","useRealTimers","whereClauses","mockObjectSet","where","clause","push","fetchPage","mockResolvedValue","mockReturnValueOnce","toEqual","id","$eq","length","mockObjectSet2","all","$in"],"sources":["BulkObjectLoader.test.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 ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Mock } from \"vitest\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../../Client.js\";\nimport { BulkObjectLoader } from \"./BulkObjectLoader.js\";\nimport { createClientMockHelper, type MockClientHelper } from \"./testUtils.js\";\n\ndescribe(BulkObjectLoader, () => {\n let client: Mock<Client> & Client;\n let mockClient: MockClientHelper;\n\n beforeEach(async () => {\n mockClient = createClientMockHelper();\n client = mockClient.client;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n vi.mocked(client.fetchMetadata).mockReturnValue(\n Promise.resolve(\n {\n primaryKeyApiName: \"id\",\n } satisfies Pick<ObjectMetadata, \"primaryKeyApiName\"> as ObjectMetadata,\n ),\n );\n });\n\n const employees = [\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 0,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 1,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 2,\n },\n ];\n\n it(\"splits up work by count\", async () => {\n const loader = new BulkObjectLoader(client, 25, /*ms*/ 2 /*entries*/);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n const load0 = loader.fetch(\"Employee\", 0);\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0], employees[1]],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n const mock = vi.fn();\n void load2.then(mock);\n expect(mock).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [employees[2]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mock).toHaveBeenCalled();\n });\n\n it(\"splits up work by time\", async () => {\n const loader = new BulkObjectLoader(client, /*ms*/ 25, /*entries*/ 100);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n vi.useFakeTimers();\n\n const load0 = loader.fetch(\"Employee\", 0);\n\n vi.advanceTimersByTime(26);\n\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n vi.runOnlyPendingTimers();\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n const mockThen = vi.fn();\n void load2.then(mockThen);\n\n expect(mockThen).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [\n employees[1],\n employees[2],\n ],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mockThen).toHaveBeenCalled();\n\n vi.useRealTimers();\n });\n\n it(\"uses $eq for single object and $in for multiple objects\", async () => {\n const loader = new BulkObjectLoader(client, 25, 100);\n\n vi.useFakeTimers();\n\n const whereClauses: WhereClause<ObjectTypeDefinition>[] = [];\n\n const mockObjectSet: ObjectSet<ObjectTypeDefinition> = {\n where: (clause) => {\n whereClauses.push(clause);\n return mockObjectSet;\n },\n fetchPage: vi.fn().mockResolvedValue({\n data: [employees[0]],\n nextPageToken: undefined,\n totalCount: \"1\",\n }),\n } as Pick<\n ObjectSet<ObjectTypeDefinition>,\n \"fetchPage\" | \"where\"\n > as ObjectSet<ObjectTypeDefinition>;\n\n client.mockReturnValueOnce(mockObjectSet);\n const load0 = loader.fetch(\"Employee\", 0);\n\n vi.advanceTimersByTime(26);\n\n await load0;\n\n expect(whereClauses[0]).toEqual({\n id: { $eq: 0 },\n });\n\n whereClauses.length = 0;\n\n const mockObjectSet2: ObjectSet<ObjectTypeDefinition> = {\n where: (clause) => {\n whereClauses.push(clause);\n return mockObjectSet2;\n },\n fetchPage: vi.fn().mockResolvedValue({\n data: [employees[1], employees[2]],\n nextPageToken: undefined,\n totalCount: \"2\",\n }),\n } as Pick<\n ObjectSet<ObjectTypeDefinition>,\n \"fetchPage\" | \"where\"\n > as ObjectSet<ObjectTypeDefinition>;\n\n client.mockReturnValueOnce(mockObjectSet2);\n\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n vi.advanceTimersByTime(26);\n\n await Promise.all([load1, load2]);\n\n expect(whereClauses[0]).toEqual({\n id: { $in: [1, 2] },\n });\n\n vi.useRealTimers();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAE7D,SAASC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E;MACd,CAAC;IACH,CAGoC;IAEpCvB,MAAM,CAAC2C,mBAAmB,CAACK,cAAc,CAAC;IAE1C,MAAM9B,KAAK,GAAGN,MAAM,CAACK,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IACzC,MAAME,KAAK,GAAGP,MAAM,CAACK,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAEzCpB,EAAE,CAACmC,mBAAmB,CAAC,EAAE,CAAC;IAE1B,MAAM3B,OAAO,CAAC4C,GAAG,CAAC,CAAC/B,KAAK,EAAEC,KAAK,CAAC,CAAC;IAEjCxB,MAAM,CAACyC,YAAY,CAAC,CAAC,CAAC,CAAC,CAACQ,OAAO,CAAC;MAC9BC,EAAE,EAAE;QAAEK,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;MAAE;IACpB,CAAC,CAAC;IAEFrD,EAAE,CAACsC,aAAa,CAAC,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -65,11 +65,17 @@ export class CacheKeys {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
get(type, ...args) {
|
|
68
|
-
|
|
68
|
+
// Normalize trailing undefined values to ensure consistent cache key creation
|
|
69
|
+
// This makes get("object", "Foo", 1, undefined) === get("object", "Foo", 1)
|
|
70
|
+
const normalizedArgs = [...args];
|
|
71
|
+
while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === undefined) {
|
|
72
|
+
normalizedArgs.pop();
|
|
73
|
+
}
|
|
74
|
+
const cacheKeyArgs = [type, ...normalizedArgs];
|
|
69
75
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
70
76
|
// eslint-disable-next-line no-console
|
|
71
|
-
console.debug(`CacheKeys.get([${type},
|
|
72
|
-
${
|
|
77
|
+
console.debug(`CacheKeys.get([${type},
|
|
78
|
+
${normalizedArgs.map(x => JSON.stringify(x)).join(", ")}]) - already exists? `, this.#cacheKeys.peekArray(cacheKeyArgs) != null);
|
|
73
79
|
}
|
|
74
80
|
const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
75
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKeys.js","names":["Trie","DEBUG_CACHE_KEYS","DEBUG_REFCOUNTS","RefCounts","CacheKeys","cacheKeys","keys","cacheKey","type","otherKeys","slice","onCreate","console","log","JSON","stringify","finalizationRegistry","register","refCounts","k","cleanupCacheKey","onDestroy","constructor","setInterval","gc","FinalizationRegistry","cleanupCallback","e","error","get","args","cacheKeyArgs","process","env","NODE_ENV","debug","map","x","join","peekArray","lookupArray","retain","release","remove","#remove","key"],"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 { DEBUG_CACHE_KEYS, DEBUG_REFCOUNTS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { RefCounts } from \"./RefCounts.js\";\n\n/**\n * Cache key management with canonicalization.\n * - Uses Trie structure for efficient storage and lookup\n */\nexport class CacheKeys<TCacheKey extends CacheKey> {\n #cacheKeys = new Trie<TCacheKey>(false, (keys) => {\n const cacheKey = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as TCacheKey;\n this.#onCreate?.(cacheKey);\n\n if (DEBUG_REFCOUNTS) {\n // eslint-disable-next-line no-console\n console.log(\n `CacheKeys.onCreate(${cacheKey.type}, ${\n JSON.stringify(cacheKey.otherKeys)\n })`,\n );\n\n this.#finalizationRegistry.register(cacheKey, () => {\n // eslint-disable-next-line no-console\n console.log(\n `CacheKey Finalization(${cacheKey.type}, ${\n JSON.stringify(cacheKey.otherKeys)\n })`,\n );\n });\n }\n return cacheKey;\n });\n\n #refCounts = new RefCounts<TCacheKey>(\n DEBUG_REFCOUNTS ? 15_000 : 60_000,\n (k) => this.#cleanupCacheKey(k),\n );\n\n // we are currently only using this for debug logging and should just remove it in the future if that\n // continues to be true\n #finalizationRegistry: FinalizationRegistry<() => void>;\n\n #onCreate?: (cacheKey: TCacheKey) => void;\n #onDestroy?: (cacheKey: TCacheKey) => void;\n\n constructor(\n { onCreate, onDestroy }: {\n onCreate?: (cacheKey: TCacheKey) => void;\n onDestroy?: (cacheKey: TCacheKey) => void;\n },\n ) {\n this.#onCreate = onCreate;\n this.#onDestroy = onDestroy;\n\n setInterval(() => {\n this.#refCounts.gc();\n }, 1000);\n\n this.#finalizationRegistry = new FinalizationRegistry<() => void>(\n (cleanupCallback) => {\n try {\n cleanupCallback();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Caught an error while running a finalization callback\",\n e,\n );\n }\n },\n );\n }\n\n get<K extends TCacheKey>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n const cacheKeyArgs = [type, ...
|
|
1
|
+
{"version":3,"file":"CacheKeys.js","names":["Trie","DEBUG_CACHE_KEYS","DEBUG_REFCOUNTS","RefCounts","CacheKeys","cacheKeys","keys","cacheKey","type","otherKeys","slice","onCreate","console","log","JSON","stringify","finalizationRegistry","register","refCounts","k","cleanupCacheKey","onDestroy","constructor","setInterval","gc","FinalizationRegistry","cleanupCallback","e","error","get","args","normalizedArgs","length","undefined","pop","cacheKeyArgs","process","env","NODE_ENV","debug","map","x","join","peekArray","lookupArray","retain","release","remove","#remove","key"],"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 { DEBUG_CACHE_KEYS, DEBUG_REFCOUNTS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { RefCounts } from \"./RefCounts.js\";\n\n/**\n * Cache key management with canonicalization.\n * - Uses Trie structure for efficient storage and lookup\n */\nexport class CacheKeys<TCacheKey extends CacheKey> {\n #cacheKeys = new Trie<TCacheKey>(false, (keys) => {\n const cacheKey = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as TCacheKey;\n this.#onCreate?.(cacheKey);\n\n if (DEBUG_REFCOUNTS) {\n // eslint-disable-next-line no-console\n console.log(\n `CacheKeys.onCreate(${cacheKey.type}, ${\n JSON.stringify(cacheKey.otherKeys)\n })`,\n );\n\n this.#finalizationRegistry.register(cacheKey, () => {\n // eslint-disable-next-line no-console\n console.log(\n `CacheKey Finalization(${cacheKey.type}, ${\n JSON.stringify(cacheKey.otherKeys)\n })`,\n );\n });\n }\n return cacheKey;\n });\n\n #refCounts = new RefCounts<TCacheKey>(\n DEBUG_REFCOUNTS ? 15_000 : 60_000,\n (k) => this.#cleanupCacheKey(k),\n );\n\n // we are currently only using this for debug logging and should just remove it in the future if that\n // continues to be true\n #finalizationRegistry: FinalizationRegistry<() => void>;\n\n #onCreate?: (cacheKey: TCacheKey) => void;\n #onDestroy?: (cacheKey: TCacheKey) => void;\n\n constructor(\n { onCreate, onDestroy }: {\n onCreate?: (cacheKey: TCacheKey) => void;\n onDestroy?: (cacheKey: TCacheKey) => void;\n },\n ) {\n this.#onCreate = onCreate;\n this.#onDestroy = onDestroy;\n\n setInterval(() => {\n this.#refCounts.gc();\n }, 1000);\n\n this.#finalizationRegistry = new FinalizationRegistry<() => void>(\n (cleanupCallback) => {\n try {\n cleanupCallback();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Caught an error while running a finalization callback\",\n e,\n );\n }\n },\n );\n }\n\n get<K extends TCacheKey>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n // Normalize trailing undefined values to ensure consistent cache key creation\n // This makes get(\"object\", \"Foo\", 1, undefined) === get(\"object\", \"Foo\", 1)\n const normalizedArgs = [...args];\n while (\n normalizedArgs.length > 0\n && normalizedArgs[normalizedArgs.length - 1] === undefined\n ) {\n normalizedArgs.pop();\n }\n\n const cacheKeyArgs = [type, ...normalizedArgs];\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([${type},\n ${\n normalizedArgs.map(x => JSON.stringify(x)).join(\", \")\n }]) - already exists? `,\n this.#cacheKeys.peekArray(cacheKeyArgs) != null,\n );\n }\n\n const cacheKey = this.#cacheKeys.lookupArray(\n cacheKeyArgs,\n ) as K;\n\n // This is an idempotent call that ensures the cache key is registered for\n // cleanup. If already registered, this does nothing.\n this.#refCounts.register(cacheKey);\n\n return cacheKey;\n }\n\n retain(cacheKey: TCacheKey): void {\n this.#refCounts.retain(cacheKey);\n }\n\n release(cacheKey: TCacheKey): void {\n this.#refCounts.release(cacheKey);\n }\n\n #remove<K extends TCacheKey>(cacheKey: K): void {\n this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);\n }\n\n /**\n * Called after a key is no longer retained and the timeout has elapsed\n * @param key\n */\n #cleanupCacheKey = (key: TCacheKey) => {\n this.#onDestroy?.(key);\n this.#remove(key);\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,WAAW;AAChC,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2B,MAAM,CAACtC,QAAQ,CAAC;EAClC;EAEAuC,OAAOA,CAACvC,QAAmB,EAAQ;IACjC,IAAI,CAAC,CAACW,SAAS,CAAC4B,OAAO,CAACvC,QAAQ,CAAC;EACnC;EAEA,CAACwC,MAAMC,CAAsBzC,QAAW,EAAQ;IAC9C,IAAI,CAAC,CAACF,SAAS,CAAC0C,MAAM,CAACxC,QAAQ,CAACC,IAAI,EAAE,GAAGD,QAAQ,CAACE,SAAS,CAAC;EAC9D;;EAEA;AACF;AACA;AACA;EACE,CAACW,eAAe,GAAI6B,GAAc,IAAK;IACrC,IAAI,CAAC,CAAC5B,SAAS,GAAG4B,GAAG,CAAC;IACtB,IAAI,CAAC,CAACF,MAAM,CAACE,GAAG,CAAC;EACnB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Interface for canonicalizing objects.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base class for canonicalizers that provides common caching infrastructure.
|
|
23
|
+
* Subclasses control how structural deduplication is performed.
|
|
24
|
+
*/
|
|
25
|
+
export class CachingCanonicalizer {
|
|
26
|
+
/**
|
|
27
|
+
* Cache for input object identity.
|
|
28
|
+
*/
|
|
29
|
+
inputCache = new WeakMap();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Look up or create a canonical form for the given input.
|
|
33
|
+
* This method handles the structural deduplication logic.
|
|
34
|
+
*
|
|
35
|
+
* @param input The input to canonicalize
|
|
36
|
+
* @returns The canonical form
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
canonicalize(input) {
|
|
40
|
+
if (!input) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (this.inputCache.has(input)) {
|
|
44
|
+
return this.inputCache.get(input);
|
|
45
|
+
}
|
|
46
|
+
const canonical = this.lookupOrCreate(input);
|
|
47
|
+
this.inputCache.set(input, canonical);
|
|
48
|
+
return canonical;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=Canonicalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canonicalizer.js","names":["CachingCanonicalizer","inputCache","WeakMap","canonicalize","input","undefined","has","get","canonical","lookupOrCreate","set"],"sources":["Canonicalizer.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 { Canonical } from \"./Canonical.js\";\n\n/**\n * Interface for canonicalizing objects.\n */\nexport interface Canonicalizer<TInput, TCanonical> {\n /**\n * Canonicalizes the input object. Returns the same reference for\n * structurally identical inputs.\n */\n canonicalize(input: TInput | undefined): Canonical<TCanonical> | undefined;\n}\n\n/**\n * Base class for canonicalizers that provides common caching infrastructure.\n * Subclasses control how structural deduplication is performed.\n */\nexport abstract class CachingCanonicalizer<TInput extends object, TCanonical>\n implements Canonicalizer<TInput, TCanonical>\n{\n /**\n * Cache for input object identity.\n */\n protected inputCache: WeakMap<TInput, Canonical<TCanonical>> = new WeakMap<\n TInput,\n Canonical<TCanonical>\n >();\n\n /**\n * Look up or create a canonical form for the given input.\n * This method handles the structural deduplication logic.\n *\n * @param input The input to canonicalize\n * @returns The canonical form\n */\n protected abstract lookupOrCreate(input: TInput): Canonical<TCanonical>;\n\n canonicalize(input: TInput): Canonical<TCanonical>;\n canonicalize(input: TInput | undefined): Canonical<TCanonical> | undefined;\n canonicalize(input: TInput | undefined): Canonical<TCanonical> | undefined {\n if (!input) {\n return undefined;\n }\n if (this.inputCache.has(input)) {\n return this.inputCache.get(input)!;\n }\n\n const canonical = this.lookupOrCreate(input);\n this.inputCache.set(input, canonical);\n\n return canonical;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA,OAAO,MAAeA,oBAAoB,CAE1C;EACE;AACF;AACA;EACYC,UAAU,GAA2C,IAAIC,OAAO,CAGxE,CAAC;;EAEH;AACF;AACA;AACA;AACA;AACA;AACA;;EAKEC,YAAYA,CAACC,KAAyB,EAAqC;IACzE,IAAI,CAACA,KAAK,EAAE;MACV,OAAOC,SAAS;IAClB;IACA,IAAI,IAAI,CAACJ,UAAU,CAACK,GAAG,CAACF,KAAK,CAAC,EAAE;MAC9B,OAAO,IAAI,CAACH,UAAU,CAACM,GAAG,CAACH,KAAK,CAAC;IACnC;IAEA,MAAMI,SAAS,GAAG,IAAI,CAACC,cAAc,CAACL,KAAK,CAAC;IAC5C,IAAI,CAACH,UAAU,CAACS,GAAG,CAACN,KAAK,EAAEI,SAAS,CAAC;IAErC,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","registerObjectSet","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 { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<\n
|
|
1
|
+
{"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","registerObjectSet","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 { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<\n | AggregationCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n modified: Set<\n | AggregationCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n deleted: Set<\n | AggregationCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = 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 deleteObject = (cacheKey: ObjectCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n registerLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.modified.add(cacheKey);\n };\n\n deleteLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerObjectSet = (key: ObjectSetCacheKey): 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 && this.deleted.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;AAIpC,SAASC,4BAA4B,QAAQ,eAAe;AAM5D,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,I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
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { CachingCanonicalizer } from "./Canonicalizer.js";
|
|
18
|
+
export class IntersectCanonicalizer extends CachingCanonicalizer {
|
|
19
|
+
structuralCache = new Map();
|
|
20
|
+
constructor(whereCanonicalizer) {
|
|
21
|
+
super();
|
|
22
|
+
this.whereCanonicalizer = whereCanonicalizer;
|
|
23
|
+
}
|
|
24
|
+
lookupOrCreate(intersectWith) {
|
|
25
|
+
const canonicalClauses = intersectWith.map(item => this.whereCanonicalizer.canonicalize(item.where ?? {}));
|
|
26
|
+
const structuralKey = canonicalClauses.map(clause => JSON.stringify(clause)).join("||");
|
|
27
|
+
let canonical = this.structuralCache.get(structuralKey);
|
|
28
|
+
if (!canonical) {
|
|
29
|
+
canonical = canonicalClauses;
|
|
30
|
+
this.structuralCache.set(structuralKey, canonical);
|
|
31
|
+
}
|
|
32
|
+
return canonical;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=IntersectCanonicalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntersectCanonicalizer.js","names":["CachingCanonicalizer","IntersectCanonicalizer","structuralCache","Map","constructor","whereCanonicalizer","lookupOrCreate","intersectWith","canonicalClauses","map","item","canonicalize","where","structuralKey","clause","JSON","stringify","join","canonical","get","set"],"sources":["IntersectCanonicalizer.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 ObjectOrInterfaceDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Canonical } from \"./Canonical.js\";\nimport { CachingCanonicalizer } from \"./Canonicalizer.js\";\nimport type { SimpleWhereClause } from \"./SimpleWhereClause.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\ntype IntersectWithInput<\n T extends ObjectOrInterfaceDefinition = ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n SimplePropertyDef\n >,\n> = Array<{ where: WhereClause<T, RDPs> }>;\n\nexport class IntersectCanonicalizer extends CachingCanonicalizer<\n IntersectWithInput,\n Array<Canonical<SimpleWhereClause>>\n> {\n private structuralCache = new Map<\n string,\n Canonical<Array<Canonical<SimpleWhereClause>>>\n >();\n\n constructor(private whereCanonicalizer: WhereClauseCanonicalizer) {\n super();\n }\n\n protected lookupOrCreate(\n intersectWith: IntersectWithInput,\n ): Canonical<Array<Canonical<SimpleWhereClause>>> {\n const canonicalClauses = intersectWith.map((item) =>\n this.whereCanonicalizer.canonicalize(item.where ?? {})\n );\n\n const structuralKey = canonicalClauses\n .map((clause) => JSON.stringify(clause))\n .join(\"||\");\n\n let canonical = this.structuralCache.get(structuralKey);\n\n if (!canonical) {\n canonical = canonicalClauses as Canonical<\n Array<Canonical<SimpleWhereClause>>\n >;\n this.structuralCache.set(structuralKey, canonical);\n }\n\n return canonical;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,oBAAoB,QAAQ,oBAAoB;AAYzD,OAAO,MAAMC,sBAAsB,SAASD,oBAAoB,CAG9D;EACQE,eAAe,GAAG,IAAIC,GAAG,CAG/B,CAAC;EAEHC,WAAWA,CAASC,kBAA4C,EAAE;IAChE,KAAK,CAAC,CAAC;IAAC,KADUA,kBAA4C,GAA5CA,kBAA4C;EAEhE;EAEUC,cAAcA,CACtBC,aAAiC,EACe;IAChD,MAAMC,gBAAgB,GAAGD,aAAa,CAACE,GAAG,CAAEC,IAAI,IAC9C,IAAI,CAACL,kBAAkB,CAACM,YAAY,CAACD,IAAI,CAACE,KAAK,IAAI,CAAC,CAAC,CACvD,CAAC;IAED,MAAMC,aAAa,GAAGL,gBAAgB,CACnCC,GAAG,CAAEK,MAAM,IAAKC,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC,CAAC,CACvCG,IAAI,CAAC,IAAI,CAAC;IAEb,IAAIC,SAAS,GAAG,IAAI,CAAChB,eAAe,CAACiB,GAAG,CAACN,aAAa,CAAC;IAEvD,IAAI,CAACK,SAAS,EAAE;MACdA,SAAS,GAAGV,gBAEX;MACD,IAAI,CAACN,eAAe,CAACkB,GAAG,CAACP,aAAa,EAAEK,SAAS,CAAC;IACpD;IAEA,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.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 { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport type KnownCacheKey =\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey\n | ObjectSetCacheKey;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.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 { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport type KnownCacheKey =\n | AggregationCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey\n | ObjectSetCacheKey;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -45,6 +45,9 @@ export class ObservableClientImpl {
|
|
|
45
45
|
// cast to cross typed to untyped barrier
|
|
46
46
|
subFn);
|
|
47
47
|
};
|
|
48
|
+
observeAggregation = (options, subFn) => {
|
|
49
|
+
return this.__experimentalStore.aggregations.observe(options, subFn);
|
|
50
|
+
};
|
|
48
51
|
observeLinks = (objects, linkName, options, subFn) => {
|
|
49
52
|
// Convert to array if single object provided
|
|
50
53
|
const objectsArray = Array.isArray(objects) ? objects : [objects];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableClientImpl.js","names":["Subscription","UnsubscribableWrapper","ObservableClientImpl","constructor","store","__experimentalStore","applyAction","bind","validateAction","observeObject","apiName","pk","options","subFn","objects","observe","observeList","lists","observeLinks","linkName","objectsArray","Array","isArray","parentSub","obj","querySubscription","links","srcType","type","$apiName","$primaryKey","add","observeObjectSet","baseObjectSet","objectSets","invalidateAll","invalidateObjects","invalidateObjectType","undefined","canonicalizeWhereClause","where","whereCanonicalizer","canonicalize"],"sources":["ObservableClientImpl.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 ActionDefinition,\n ActionValidationResponse,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { Subscription } from \"rxjs\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\nimport type { SpecificLinkPayload } from \"../LinkPayload.js\";\nimport type { ListPayload } from \"../ListPayload.js\";\nimport type { ObjectPayload } from \"../ObjectPayload.js\";\nimport type { ObjectSetPayload } from \"../ObjectSetPayload.js\";\nimport type {\n ObservableClient,\n ObserveListOptions,\n ObserveObjectArgs,\n ObserveObjectOptions,\n ObserveObjectsArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../ObservableClient.js\";\nimport type { Observer } from \"../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../ObservableClient/ObserveLink.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./objectset/ObjectSetQueryOptions.js\";\nimport type { Store } from \"./Store.js\";\nimport { UnsubscribableWrapper } from \"./UnsubscribableWrapper.js\";\n\n/**\n * Implementation of the public ObservableClient interface.\n * - Delegates all operations to the Store for consistency\n * - Serves as the entry point for reactive data management\n * - Ensures proper method binding and API exposure\n *\n * @internal\n */\nexport class ObservableClientImpl implements ObservableClient {\n __experimentalStore: Store;\n\n constructor(store: Store) {\n this.__experimentalStore = store;\n\n this.applyAction = store.applyAction.bind(store);\n this.validateAction = store.validateAction.bind(store);\n }\n\n public observeObject: <T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: Omit<ObserveObjectOptions<T>, \"apiName\" | \"pk\">,\n subFn: Observer<ObserveObjectArgs<T>>,\n ) => Unsubscribable = (apiName, pk, options, subFn) => {\n return this.__experimentalStore.objects.observe(\n {\n ...options,\n apiName,\n pk,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectPayload>,\n );\n };\n\n public observeList: <T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ) => Unsubscribable = (options, subFn) => {\n return this.__experimentalStore.lists.observe(\n options,\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ListPayload>,\n );\n };\n\n public observeLinks: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<T>[\"links\"] & string,\n >(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>>,\n linkName: L,\n options: ObserveLinks.Options<T, L>,\n subFn: Observer<\n ObserveLinks.CallbackArgs<\n CompileTimeMetadata<T>[\"links\"][L][\"targetType\"]\n >\n >,\n ) => Unsubscribable = (objects, linkName, options, subFn) => {\n // Convert to array if single object provided\n const objectsArray = Array.isArray(objects) ? objects : [objects];\n\n const parentSub = new Subscription();\n\n for (const obj of objectsArray) {\n const querySubscription = this.__experimentalStore.links\n .observe(\n {\n ...options,\n srcType: {\n type: \"object\",\n apiName: obj.$apiName,\n },\n linkName,\n pk: obj.$primaryKey,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<SpecificLinkPayload>,\n );\n\n parentSub.add(querySubscription);\n }\n\n return new UnsubscribableWrapper(parentSub);\n };\n\n public applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n public validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n public observeObjectSet<\n T extends ObjectTypeDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable {\n return this.__experimentalStore.objectSets.observe(\n { baseObjectSet, ...options },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectSetPayload>,\n );\n }\n\n public invalidateAll(): Promise<void> {\n return this.__experimentalStore.invalidateAll();\n }\n\n public invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjects(objects);\n }\n\n public invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjectType(type, undefined);\n }\n\n public canonicalizeWhereClause<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(where: WhereClause<T>): Canonical<WhereClause<T>> {\n return this.__experimentalStore.whereCanonicalizer\n .canonicalize(where) as Canonical<WhereClause<T>>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,YAAY,QAAQ,MAAM;AAoBnC,SAASC,qBAAqB,QAAQ,4BAA4B;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAA6B;EAG5DC,WAAWA,CAACC,KAAY,EAAE;IACxB,IAAI,CAACC,mBAAmB,GAAGD,KAAK;IAEhC,IAAI,CAACE,WAAW,GAAGF,KAAK,CAACE,WAAW,CAACC,IAAI,CAACH,KAAK,CAAC;IAChD,IAAI,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACD,IAAI,CAACH,KAAK,CAAC;EACxD;EAEOK,aAAa,GAKEA,CAACC,OAAO,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,KAAK;IACrD,OAAO,IAAI,CAACR,mBAAmB,CAACS,OAAO,CAACC,OAAO,CAC7C;MACE,GAAGH,OAAO;MACVF,OAAO;MACPC;IACF,CAAC;IACD;IACAE,KACF,CAAC;EACH,CAAC;EAEMG,WAAW,GAGIA,CAACJ,OAAO,EAAEC,KAAK,KAAK;IACxC,OAAO,IAAI,CAACR,mBAAmB,CAACY,KAAK,CAACF,OAAO,CAC3CH,OAAO;IACP;IACAC,KACF,CAAC;EACH,CAAC;EAEMK,YAAY,GAYGA,CAACJ,OAAO,EAAEK,QAAQ,EAAEP,OAAO,EAAEC,KAAK,KAAK;IAC3D;IACA,MAAMO,YAAY,GAAGC,KAAK,CAACC,OAAO,CAACR,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC;IAEjE,MAAMS,SAAS,GAAG,IAAIvB,YAAY,CAAC,CAAC;IAEpC,KAAK,MAAMwB,GAAG,IAAIJ,YAAY,EAAE;MAC9B,MAAMK,iBAAiB,GAAG,IAAI,CAACpB,mBAAmB,CAACqB,KAAK,CACrDX,OAAO,CACN;QACE,GAAGH,OAAO;QACVe,OAAO,EAAE;UACPC,IAAI,EAAE,QAAQ;UACdlB,OAAO,EAAEc,GAAG,CAACK;QACf,CAAC;QACDV,QAAQ;QACRR,EAAE,EAAEa,GAAG,CAACM;MACV,CAAC;MACD;MACAjB,KACF,CAAC;MAEHU,SAAS,CAACQ,GAAG,CAACN,iBAAiB,CAAC;IAClC;IAEA,OAAO,IAAIxB,qBAAqB,CAACsB,SAAS,CAAC;EAC7C,CAAC;EAaMS,gBAAgBA,CAOrBC,aAA2B,EAC3BrB,OAAyC,EACzCC,KAA8C,EAC9B;IAChB,OAAO,IAAI,CAACR,mBAAmB,CAAC6B,UAAU,CAACnB,OAAO,CAChD;MAAEkB,aAAa;MAAE,GAAGrB;IAAQ,CAAC;IAC7B;IACAC,KACF,CAAC;EACH;EAEOsB,aAAaA,CAAA,EAAkB;IACpC,OAAO,IAAI,CAAC9B,mBAAmB,CAAC8B,aAAa,CAAC,CAAC;EACjD;EAEOC,iBAAiBA,CACtBtB,OAEsD,EACvC;IACf,OAAO,IAAI,CAACT,mBAAmB,CAAC+B,iBAAiB,CAACtB,OAAO,CAAC;EAC5D;EAEOuB,oBAAoBA,CACzBT,IAAsB,EACP;IACf,OAAO,IAAI,CAACvB,mBAAmB,CAACgC,oBAAoB,CAACT,IAAI,EAAEU,SAAS,CAAC;EACvE;EAEOC,uBAAuBA,CAE5BC,KAAqB,EAA6B;IAClD,OAAO,IAAI,CAACnC,mBAAmB,CAACoC,kBAAkB,CAC/CC,YAAY,CAACF,KAAK,CAAC;EACxB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObservableClientImpl.js","names":["Subscription","UnsubscribableWrapper","ObservableClientImpl","constructor","store","__experimentalStore","applyAction","bind","validateAction","observeObject","apiName","pk","options","subFn","objects","observe","observeList","lists","observeAggregation","aggregations","observeLinks","linkName","objectsArray","Array","isArray","parentSub","obj","querySubscription","links","srcType","type","$apiName","$primaryKey","add","observeObjectSet","baseObjectSet","objectSets","invalidateAll","invalidateObjects","invalidateObjectType","undefined","canonicalizeWhereClause","where","whereCanonicalizer","canonicalize"],"sources":["ObservableClientImpl.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 ActionDefinition,\n ActionValidationResponse,\n AggregateOpts,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n SimplePropertyDef,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { Subscription } from \"rxjs\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\nimport type { SpecificLinkPayload } from \"../LinkPayload.js\";\nimport type { ListPayload } from \"../ListPayload.js\";\nimport type { ObjectPayload } from \"../ObjectPayload.js\";\nimport type { ObjectSetPayload } from \"../ObjectSetPayload.js\";\nimport type {\n ObservableClient,\n ObserveAggregationArgs,\n ObserveAggregationOptions,\n ObserveListOptions,\n ObserveObjectArgs,\n ObserveObjectOptions,\n ObserveObjectsArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../ObservableClient.js\";\nimport type { Observer } from \"../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../ObservableClient/ObserveLink.js\";\nimport type { AggregationPayloadBase } from \"./aggregation/AggregationQuery.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./objectset/ObjectSetQueryOptions.js\";\nimport type { Store } from \"./Store.js\";\nimport { UnsubscribableWrapper } from \"./UnsubscribableWrapper.js\";\n\n/**\n * Implementation of the public ObservableClient interface.\n * - Delegates all operations to the Store for consistency\n * - Serves as the entry point for reactive data management\n * - Ensures proper method binding and API exposure\n *\n * @internal\n */\nexport class ObservableClientImpl implements ObservableClient {\n __experimentalStore: Store;\n\n constructor(store: Store) {\n this.__experimentalStore = store;\n\n this.applyAction = store.applyAction.bind(store);\n this.validateAction = store.validateAction.bind(store);\n }\n\n public observeObject: <T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: Omit<ObserveObjectOptions<T>, \"apiName\" | \"pk\">,\n subFn: Observer<ObserveObjectArgs<T>>,\n ) => Unsubscribable = (apiName, pk, options, subFn) => {\n return this.__experimentalStore.objects.observe(\n {\n ...options,\n apiName,\n pk,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectPayload>,\n );\n };\n\n public observeList: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveListOptions<T, RDPs>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ) => Unsubscribable = (options, subFn) => {\n return this.__experimentalStore.lists.observe(\n options,\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ListPayload>,\n );\n };\n\n public observeAggregation: <\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ) => Unsubscribable = <\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ) => {\n return this.__experimentalStore.aggregations.observe(\n options,\n subFn as Observer<AggregationPayloadBase>,\n );\n };\n\n public observeLinks: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<T>[\"links\"] & string,\n >(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>>,\n linkName: L,\n options: ObserveLinks.Options<T, L>,\n subFn: Observer<\n ObserveLinks.CallbackArgs<\n CompileTimeMetadata<T>[\"links\"][L][\"targetType\"]\n >\n >,\n ) => Unsubscribable = (objects, linkName, options, subFn) => {\n // Convert to array if single object provided\n const objectsArray = Array.isArray(objects) ? objects : [objects];\n\n const parentSub = new Subscription();\n\n for (const obj of objectsArray) {\n const querySubscription = this.__experimentalStore.links\n .observe(\n {\n ...options,\n srcType: {\n type: \"object\",\n apiName: obj.$apiName,\n },\n linkName,\n pk: obj.$primaryKey,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<SpecificLinkPayload>,\n );\n\n parentSub.add(querySubscription);\n }\n\n return new UnsubscribableWrapper(parentSub);\n };\n\n public applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n public validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n public observeObjectSet<\n T extends ObjectTypeDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable {\n return this.__experimentalStore.objectSets.observe(\n { baseObjectSet, ...options },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectSetPayload>,\n );\n }\n\n public invalidateAll(): Promise<void> {\n return this.__experimentalStore.invalidateAll();\n }\n\n public invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjects(objects);\n }\n\n public invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjectType(type, undefined);\n }\n\n public canonicalizeWhereClause<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(where: WhereClause<T, RDPs>): Canonical<WhereClause<T, RDPs>> {\n return this.__experimentalStore.whereCanonicalizer\n .canonicalize(where) as Canonical<WhereClause<T, RDPs>>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA,SAASA,YAAY,QAAQ,MAAM;AAuBnC,SAASC,qBAAqB,QAAQ,4BAA4B;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAA6B;EAG5DC,WAAWA,CAACC,KAAY,EAAE;IACxB,IAAI,CAACC,mBAAmB,GAAGD,KAAK;IAEhC,IAAI,CAACE,WAAW,GAAGF,KAAK,CAACE,WAAW,CAACC,IAAI,CAACH,KAAK,CAAC;IAChD,IAAI,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACD,IAAI,CAACH,KAAK,CAAC;EACxD;EAEOK,aAAa,GAKEA,CAACC,OAAO,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,KAAK;IACrD,OAAO,IAAI,CAACR,mBAAmB,CAACS,OAAO,CAACC,OAAO,CAC7C;MACE,GAAGH,OAAO;MACVF,OAAO;MACPC;IACF,CAAC;IACD;IACAE,KACF,CAAC;EACH,CAAC;EAEMG,WAAW,GAMIA,CAACJ,OAAO,EAAEC,KAAK,KAAK;IACxC,OAAO,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A,CACtBxB,OAEsD,EACvC;IACf,OAAO,IAAI,CAACT,mBAAmB,CAACiC,iBAAiB,CAACxB,OAAO,CAAC;EAC5D;EAEOyB,oBAAoBA,CACzBT,IAAsB,EACP;IACf,OAAO,IAAI,CAACzB,mBAAmB,CAACkC,oBAAoB,CAACT,IAAI,EAAEU,SAAS,CAAC;EACvE;EAEOC,uBAAuBA,CAG5BC,KAA2B,EAAmC;IAC9D,OAAO,IAAI,CAACrC,mBAAmB,CAACsC,kBAAkB,CAC/CC,YAAY,CAACF,KAAK,CAAC;EACxB;AACF","ignoreList":[]}
|
|
@@ -23,10 +23,7 @@ export class OrderByCanonicalizer {
|
|
|
23
23
|
}
|
|
24
24
|
return result;
|
|
25
25
|
}, []);
|
|
26
|
-
|
|
27
|
-
if (process.env.NODE_ENV !== "production") {
|
|
28
|
-
data = Object.freeze(data);
|
|
29
|
-
}
|
|
26
|
+
const data = Object.fromEntries(pairs);
|
|
30
27
|
return data;
|
|
31
28
|
});
|
|
32
29
|
canonicalize = orderBy => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderByCanonicalizer.js","names":["WeakRefTrie","OrderByCanonicalizer","trie","array","pairs","reduce","result","_","index","push","slice","data","Object","fromEntries","
|
|
1
|
+
{"version":3,"file":"OrderByCanonicalizer.js","names":["WeakRefTrie","OrderByCanonicalizer","trie","array","pairs","reduce","result","_","index","push","slice","data","Object","fromEntries","canonicalize","orderBy","strings","entries","flat","lookupArray"],"sources":["OrderByCanonicalizer.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 { ObjectTypeDefinition } from \"@osdk/api\";\nimport type { OrderBy } from \"../ObservableClient.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport { WeakRefTrie } from \"./WeakRefTrie.js\";\n\nexport class OrderByCanonicalizer {\n #trie = new WeakRefTrie(\n (array: Array<string>) => {\n const pairs = array.reduce<Array<[string, \"asc\" | \"desc\"]>>(\n function(result, _, index, array) {\n if (index % 2 === 0 && array[index] != null) {\n result.push(\n array.slice(index, index + 2) as [string, \"asc\" | \"desc\"],\n );\n }\n return result;\n },\n [],\n );\n const data = Object.fromEntries(pairs) satisfies Record<\n string,\n \"asc\" | \"desc\"\n > as Canonical<OrderBy<ObjectTypeDefinition>>;\n return data;\n },\n );\n\n canonicalize: (\n orderBy: Record<string, \"asc\" | \"desc\" | undefined>,\n ) => Canonical<Record<string, \"asc\" | \"desc\" | undefined>> = (\n orderBy,\n ) => {\n const strings = Object.entries(orderBy).flat();\n return this.#trie.lookupArray(strings);\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,WAAW,QAAQ,kBAAkB;AAE9C,OAAO,MAAMC,oBAAoB,CAAC;EAChC,CAACC,IAAI,GAAG,IAAIF,WAAW,CACpBG,KAAoB,IAAK;IACxB,MAAMC,KAAK,GAAGD,KAAK,CAACE,MAAM,CACxB,UAASC,MAAM,EAAEC,CAAC,EAAEC,KAAK,EAAEL,KAAK,EAAE;MAChC,IAAIK,KAAK,GAAG,CAAC,KAAK,CAAC,IAAIL,KAAK,CAACK,KAAK,CAAC,IAAI,IAAI,EAAE;QAC3CF,MAAM,CAACG,IAAI,CACTN,KAAK,CAACO,KAAK,CAACF,KAAK,EAAEA,KAAK,GAAG,CAAC,CAC9B,CAAC;MACH;MACA,OAAOF,MAAM;IACf,CAAC,EACD,EACF,CAAC;IACD,MAAMK,IAAI,GAAGC,MAAM,CAACC,WAAW,CAACT,KAAK,CAGQ;IAC7C,OAAOO,IAAI;EACb,CACF,CAAC;EAEDG,YAAY,GAGVC,OAAO,IACJ;IACH,MAAMC,OAAO,GAAGJ,MAAM,CAACK,OAAO,CAACF,OAAO,CAAC,CAACG,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,CAAChB,IAAI,CAACiB,WAAW,CAACH,OAAO,CAAC;EACxC,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export class PivotCanonicalizer {
|
|
18
|
+
#cache = new Map();
|
|
19
|
+
canonicalize(sourceType, linkName) {
|
|
20
|
+
const key = `${sourceType}::${linkName}`;
|
|
21
|
+
let canonical = this.#cache.get(key);
|
|
22
|
+
if (!canonical) {
|
|
23
|
+
canonical = {
|
|
24
|
+
sourceType,
|
|
25
|
+
linkName,
|
|
26
|
+
targetType: "<targetType>"
|
|
27
|
+
};
|
|
28
|
+
this.#cache.set(key, canonical);
|
|
29
|
+
}
|
|
30
|
+
return canonical;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=PivotCanonicalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PivotCanonicalizer.js","names":["PivotCanonicalizer","cache","Map","canonicalize","sourceType","linkName","key","canonical","get","targetType","set"],"sources":["PivotCanonicalizer.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 { Canonical } from \"./Canonical.js\";\n\nexport interface PivotInfo {\n sourceType: string;\n linkName: string;\n targetType: string;\n}\n\nexport class PivotCanonicalizer {\n #cache = new Map<string, Canonical<PivotInfo>>();\n\n canonicalize(sourceType: string, linkName: string): Canonical<PivotInfo> {\n const key = `${sourceType}::${linkName}`;\n\n let canonical = this.#cache.get(key);\n\n if (!canonical) {\n canonical = {\n sourceType,\n linkName,\n targetType: \"<targetType>\",\n } as Canonical<PivotInfo>;\n this.#cache.set(key, canonical);\n }\n\n return canonical;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,MAAMA,kBAAkB,CAAC;EAC9B,CAACC,KAAK,GAAG,IAAIC,GAAG,CAA+B,CAAC;EAEhDC,YAAYA,CAACC,UAAkB,EAAEC,QAAgB,EAAwB;IACvE,MAAMC,GAAG,GAAG,GAAGF,UAAU,KAAKC,QAAQ,EAAE;IAExC,IAAIE,SAAS,GAAG,IAAI,CAAC,CAACN,KAAK,CAACO,GAAG,CAACF,GAAG,CAAC;IAEpC,IAAI,CAACC,SAAS,EAAE;MACdA,SAAS,GAAG;QACVH,UAAU;QACVC,QAAQ;QACRI,UAAU,EAAE;MACd,CAAyB;MACzB,IAAI,CAAC,CAACR,KAAK,CAACS,GAAG,CAACJ,GAAG,EAAEC,SAAS,CAAC;IACjC;IAEA,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createWithPropertiesObjectSet } from "../../derivedProperties/createWithPropertiesObjectSet.js";
|
|
18
|
+
import { CachingCanonicalizer } from "./Canonicalizer.js";
|
|
19
|
+
export class RdpCanonicalizer extends CachingCanonicalizer {
|
|
20
|
+
structuralCache = new Map();
|
|
21
|
+
lookupOrCreate(rdp) {
|
|
22
|
+
// Map from builder result symbols to their definitions
|
|
23
|
+
const definitionMap = new Map();
|
|
24
|
+
const computedProperties = {};
|
|
25
|
+
|
|
26
|
+
// Create a wrapper holding object type for the builder to let us extract the definition structure
|
|
27
|
+
const objectTypeHolder = {
|
|
28
|
+
type: "object",
|
|
29
|
+
apiName: "__rdp_canonicalizer_holder__"
|
|
30
|
+
};
|
|
31
|
+
for (const [key, rdpFunction] of Object.entries(rdp)) {
|
|
32
|
+
const builder = createWithPropertiesObjectSet(objectTypeHolder, {
|
|
33
|
+
type: "methodInput"
|
|
34
|
+
}, definitionMap, /* fromBaseObjectSet */true);
|
|
35
|
+
const result = rdpFunction(builder);
|
|
36
|
+
const definition = definitionMap.get(result);
|
|
37
|
+
if (definition) {
|
|
38
|
+
computedProperties[key] = definition;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Sort entries by key for consistent ordering
|
|
43
|
+
const sortedKeys = Object.keys(computedProperties).sort();
|
|
44
|
+
|
|
45
|
+
// Create a serialized key for the computed definitions
|
|
46
|
+
const sortedDefinitions = {};
|
|
47
|
+
for (const key of sortedKeys) {
|
|
48
|
+
sortedDefinitions[key] = computedProperties[key];
|
|
49
|
+
}
|
|
50
|
+
const definitionsKey = JSON.stringify(sortedDefinitions);
|
|
51
|
+
|
|
52
|
+
// Check if we already have a canonical RDP for these definitions
|
|
53
|
+
let canonical = this.structuralCache.get(definitionsKey);
|
|
54
|
+
if (!canonical) {
|
|
55
|
+
// Create a canonical RDP object with sorted keys
|
|
56
|
+
const sortedRdp = {};
|
|
57
|
+
for (const key of Object.keys(rdp).sort()) {
|
|
58
|
+
sortedRdp[key] = rdp[key];
|
|
59
|
+
}
|
|
60
|
+
canonical = sortedRdp;
|
|
61
|
+
this.structuralCache.set(definitionsKey, canonical);
|
|
62
|
+
}
|
|
63
|
+
return canonical;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=RdpCanonicalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RdpCanonicalizer.js","names":["createWithPropertiesObjectSet","CachingCanonicalizer","RdpCanonicalizer","structuralCache","Map","lookupOrCreate","rdp","definitionMap","computedProperties","objectTypeHolder","type","apiName","key","rdpFunction","Object","entries","builder","result","definition","get","sortedKeys","keys","sort","sortedDefinitions","definitionsKey","JSON","stringify","canonical","sortedRdp","set"],"sources":["RdpCanonicalizer.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 DerivedProperty,\n ObjectOrInterfaceDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { createWithPropertiesObjectSet } from \"../../derivedProperties/createWithPropertiesObjectSet.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport { CachingCanonicalizer } from \"./Canonicalizer.js\";\n\nexport type Rdp = DerivedProperty.Clause<ObjectOrInterfaceDefinition>;\n\nexport class RdpCanonicalizer extends CachingCanonicalizer<Rdp, Rdp> {\n private structuralCache = new Map<string, Canonical<Rdp>>();\n\n protected lookupOrCreate(rdp: Rdp): Canonical<Rdp> {\n // Map from builder result symbols to their definitions\n const definitionMap = new Map<\n DerivedProperty.Definition<\n SimplePropertyDef,\n ObjectOrInterfaceDefinition\n >,\n DerivedPropertyDefinition\n >();\n const computedProperties: Record<string, DerivedPropertyDefinition> = {};\n\n // Create a wrapper holding object type for the builder to let us extract the definition structure\n const objectTypeHolder = {\n type: \"object\" as const,\n apiName: \"__rdp_canonicalizer_holder__\",\n } as ObjectOrInterfaceDefinition;\n\n for (const [key, rdpFunction] of Object.entries(rdp)) {\n const builder = createWithPropertiesObjectSet(\n objectTypeHolder,\n { type: \"methodInput\" },\n definitionMap,\n /* fromBaseObjectSet */ true,\n );\n\n const result = rdpFunction(builder);\n const definition = definitionMap.get(result);\n\n if (definition) {\n computedProperties[key] = definition;\n }\n }\n\n // Sort entries by key for consistent ordering\n const sortedKeys = Object.keys(computedProperties).sort();\n\n // Create a serialized key for the computed definitions\n const sortedDefinitions: Record<string, DerivedPropertyDefinition> = {};\n for (const key of sortedKeys) {\n sortedDefinitions[key] = computedProperties[key];\n }\n const definitionsKey = JSON.stringify(sortedDefinitions);\n\n // Check if we already have a canonical RDP for these definitions\n let canonical = this.structuralCache.get(definitionsKey);\n\n if (!canonical) {\n // Create a canonical RDP object with sorted keys\n const sortedRdp: Rdp = {};\n for (const key of Object.keys(rdp).sort()) {\n sortedRdp[key] = rdp[key];\n }\n canonical = sortedRdp as Canonical<Rdp>;\n this.structuralCache.set(definitionsKey, canonical);\n }\n\n return canonical;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,6BAA6B,QAAQ,0DAA0D;AAExG,SAASC,oBAAoB,QAAQ,oBAAoB;AAIzD,OAAO,MAAMC,gBAAgB,SAASD,oBAAoB,CAAW;EAC3DE,eAAe,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAEjDC,cAAcA,CAACC,GAAQ,EAAkB;IACjD;IACA,MAAMC,aAAa,GAAG,IAAIH,GAAG,CAM3B,CAAC;IACH,MAAMI,kBAA6D,GAAG,CAAC,CAAC;;IAExE;IACA,MAAMC,gBAAgB,GAAG;MACvBC,IAAI,EAAE,QAAiB;MACvBC,OAAO,EAAE;IACX,CAAgC;IAEhC,KAAK,MAAM,CAACC,GAAG,EAAEC,WAAW,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,GAAG,CAAC,EAAE;MACpD,MAAMU,OAAO,GAAGhB,6BAA6B,CAC3CS,gBAAgB,EAChB;QAAEC,IAAI,EAAE;MAAc,CAAC,EACvBH,aAAa,EACb,uBAAwB,IAC1B,CAAC;MAED,MAAMU,MAAM,GAAGJ,WAAW,CAACG,OAAO,CAAC;MACnC,MAAME,UAAU,GAAGX,aAAa,CAACY,GAAG,CAACF,MAAM,CAAC;MAE5C,IAAIC,UAAU,EAAE;QACdV,kBAAkB,CAACI,GAAG,CAAC,GAAGM,UAAU;MACtC;IACF;;IAEA;IACA,MAAME,UAAU,GAAGN,MAAM,CAACO,IAAI,CAACb,kBAAkB,CAAC,CAACc,IAAI,CAAC,CAAC;;IAEzD;IACA,MAAMC,iBAA4D,GAAG,CAAC,CAAC;IACvE,KAAK,MAAMX,GAAG,IAAIQ,UAAU,EAAE;MAC5BG,iBAAiB,CAACX,GAAG,CAAC,GAAGJ,kBAAkB,CAACI,GAAG,CAAC;IAClD;IACA,MAAMY,cAAc,GAAGC,IAAI,CAACC,SAAS,CAACH,iBAAiB,CAAC;;IAExD;IACA,IAAII,SAAS,GAAG,IAAI,CAACxB,eAAe,CAACgB,GAAG,CAACK,cAAc,CAAC;IAExD,IAAI,CAACG,SAAS,EAAE;MACd;MACA,MAAMC,SAAc,GAAG,CAAC,CAAC;MACzB,KAAK,MAAMhB,GAAG,IAAIE,MAAM,CAACO,IAAI,CAACf,GAAG,CAAC,CAACgB,IAAI,CAAC,CAAC,EAAE;QACzCM,SAAS,CAAChB,GAAG,CAAC,GAAGN,GAAG,CAACM,GAAG,CAAC;MAC3B;MACAe,SAAS,GAAGC,SAA2B;MACvC,IAAI,CAACzB,eAAe,CAAC0B,GAAG,CAACL,cAAc,EAAEG,SAAS,CAAC;IACrD;IAEA,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expect, it } from "vitest";
|
|
18
|
+
import { RdpCanonicalizer } from "./RdpCanonicalizer.js";
|
|
19
|
+
describe("RdpCanonicalizer", () => {
|
|
20
|
+
it("returns same canonical object for functionally identical RDPs with different function references", () => {
|
|
21
|
+
const canonicalizer = new RdpCanonicalizer();
|
|
22
|
+
|
|
23
|
+
// Create first RDP with a function
|
|
24
|
+
const rdp1 = {
|
|
25
|
+
derivedAddress: base => base.pivotTo("lead").selectProperty("employeeId"),
|
|
26
|
+
derivedName: base => base.pivotTo("lead").selectProperty("fullName")
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Create second RDP with new function references but same logic
|
|
30
|
+
const rdp2 = {
|
|
31
|
+
derivedAddress: base => base.pivotTo("lead").selectProperty("employeeId"),
|
|
32
|
+
derivedName: base => base.pivotTo("lead").selectProperty("fullName")
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// The functions should have different references
|
|
36
|
+
expect(rdp1.derivedAddress).not.toBe(rdp2.derivedAddress);
|
|
37
|
+
expect(rdp1.derivedName).not.toBe(rdp2.derivedName);
|
|
38
|
+
|
|
39
|
+
// But canonicalization should return the same object
|
|
40
|
+
const canonical1 = canonicalizer.canonicalize(rdp1);
|
|
41
|
+
const canonical2 = canonicalizer.canonicalize(rdp2);
|
|
42
|
+
expect(canonical1).toBe(canonical2);
|
|
43
|
+
});
|
|
44
|
+
it("handles complex RDP with aggregations", () => {
|
|
45
|
+
const canonicalizer = new RdpCanonicalizer();
|
|
46
|
+
const canonical1 = canonicalizer.canonicalize({
|
|
47
|
+
peepsCount: base => base.pivotTo("peeps").aggregate("$count"),
|
|
48
|
+
leadName: base => base.pivotTo("lead").selectProperty("fullName")
|
|
49
|
+
});
|
|
50
|
+
const canonical2 = canonicalizer.canonicalize({
|
|
51
|
+
peepsCount: base => base.pivotTo("peeps").aggregate("$count"),
|
|
52
|
+
leadName: base => base.pivotTo("lead").selectProperty("fullName")
|
|
53
|
+
});
|
|
54
|
+
expect(canonical1).toBe(canonical2);
|
|
55
|
+
});
|
|
56
|
+
it("caches results for the same input object", () => {
|
|
57
|
+
const canonicalizer = new RdpCanonicalizer();
|
|
58
|
+
const rdp = {
|
|
59
|
+
derivedProp: base => base.pivotTo("lead").selectProperty("employeeId")
|
|
60
|
+
};
|
|
61
|
+
const canonical1 = canonicalizer.canonicalize(rdp);
|
|
62
|
+
const canonical2 = canonicalizer.canonicalize(rdp);
|
|
63
|
+
|
|
64
|
+
// Same input object should return cached result
|
|
65
|
+
expect(canonical1).toBe(canonical2);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=RdpCanonicalizer.test.js.map
|