@osdk/client 2.8.0-beta.25 → 2.8.0-beta.27
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 +28 -0
- package/build/browser/actions/applyAction.js +4 -4
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/fetchMetadata.js +1 -1
- package/build/browser/fetchMetadata.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +11 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/toIntervalQuery.js +56 -0
- package/build/browser/internal/conversions/toIntervalQuery.js.map +1 -0
- package/build/browser/object/SimpleOsdkProperties.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.js +16 -11
- package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/browser/observable/internal/GenericCanonicalizer.js +72 -0
- package/build/browser/observable/internal/GenericCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/IntersectCanonicalizer.js +1 -1
- package/build/browser/observable/internal/IntersectCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/ObjectSetArrayCanonicalizer.js +34 -0
- package/build/browser/observable/internal/ObjectSetArrayCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/Store.js +21 -1
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/evaluateFilter.js +1 -0
- package/build/browser/observable/internal/evaluateFilter.js.map +1 -1
- package/build/browser/observable/internal/list/ListCacheKey.js +1 -0
- package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +3 -0
- 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 +3 -2
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectQuery.js +6 -3
- package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectsHelper.js +3 -2
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js +8 -4
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +183 -27
- 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/util/UserAgent.js +2 -2
- package/build/cjs/{chunk-R7OP6A6S.cjs → chunk-BWOPPEUP.cjs} +82 -34
- package/build/cjs/chunk-BWOPPEUP.cjs.map +1 -0
- package/build/cjs/{chunk-3RY4ECUB.cjs → chunk-ZPGIIKEZ.cjs} +44 -44
- package/build/cjs/chunk-ZPGIIKEZ.cjs.map +1 -0
- package/build/cjs/index.cjs +10 -10
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +371 -114
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +12 -0
- package/build/esm/actions/applyAction.js +4 -4
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/fetchMetadata.js +1 -1
- package/build/esm/fetchMetadata.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +11 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/toIntervalQuery.js +56 -0
- package/build/esm/internal/conversions/toIntervalQuery.js.map +1 -0
- package/build/esm/object/SimpleOsdkProperties.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.js +16 -11
- package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/esm/observable/internal/GenericCanonicalizer.js +72 -0
- package/build/esm/observable/internal/GenericCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/IntersectCanonicalizer.js +1 -1
- package/build/esm/observable/internal/IntersectCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/ObjectSetArrayCanonicalizer.js +34 -0
- package/build/esm/observable/internal/ObjectSetArrayCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/Store.js +21 -1
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/evaluateFilter.js +1 -0
- package/build/esm/observable/internal/evaluateFilter.js.map +1 -1
- package/build/esm/observable/internal/list/ListCacheKey.js +1 -0
- package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +3 -0
- 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 +3 -2
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectQuery.js +6 -3
- package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectsHelper.js +3 -2
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js +8 -4
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +183 -27
- 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/util/UserAgent.js +2 -2
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/internal/conversions/toIntervalQuery.d.ts +7 -0
- package/build/types/internal/conversions/toIntervalQuery.d.ts.map +1 -0
- package/build/types/observable/ObservableClient.d.ts +7 -0
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/BulkObjectLoader.d.ts +1 -1
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
- package/build/types/observable/internal/GenericCanonicalizer.d.ts +8 -0
- package/build/types/observable/internal/GenericCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/IntersectCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectSetArrayCanonicalizer.d.ts +7 -0
- package/build/types/observable/internal/ObjectSetArrayCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/Store.d.ts +4 -0
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts +2 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQueryOptions.d.ts +1 -0
- package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- 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.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +1 -0
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +3 -1
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +4 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +6 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -1
- package/package.json +8 -8
- package/build/cjs/chunk-3RY4ECUB.cjs.map +0 -1
- package/build/cjs/chunk-R7OP6A6S.cjs.map +0 -1
|
@@ -113,6 +113,12 @@ interface ObserveObjectSetOptions<Q extends ObjectOrInterfaceDefinition, RDPs ex
|
|
|
113
113
|
* @default false
|
|
114
114
|
*/
|
|
115
115
|
streamUpdates?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* When true, loads per-property security metadata (marking requirements)
|
|
118
|
+
* alongside each object. The returned objects will have `$propertySecurities`
|
|
119
|
+
* populated with conjunctive/disjunctive marking requirements per property.
|
|
120
|
+
*/
|
|
121
|
+
$loadPropertySecurityMetadata?: boolean;
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
/**
|
|
@@ -203,6 +209,12 @@ interface ObserveListOptions<Q extends ObjectOrInterfaceDefinition, RDPs extends
|
|
|
203
209
|
* reducing payload sizes for list views.
|
|
204
210
|
*/
|
|
205
211
|
select?: readonly PropertyKeys<Q>[];
|
|
212
|
+
/**
|
|
213
|
+
* When true, loads per-property security metadata (marking requirements)
|
|
214
|
+
* alongside each object. The returned objects will have `$propertySecurities`
|
|
215
|
+
* populated with conjunctive/disjunctive marking requirements per property.
|
|
216
|
+
*/
|
|
217
|
+
$loadPropertySecurityMetadata?: boolean;
|
|
206
218
|
/**
|
|
207
219
|
* Automatically fetch additional pages on initial load.
|
|
208
220
|
*
|
|
@@ -24,8 +24,8 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
24
24
|
finalMethodCall: "applyAction"
|
|
25
25
|
})), action);
|
|
26
26
|
if (Array.isArray(parameters)) {
|
|
27
|
-
const response = await Actions.applyBatch(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
28
|
-
requests: parameters ? await remapBatchActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.apiName)) : [],
|
|
27
|
+
const response = await Actions.applyBatch(clientWithHeaders, await client.ontologyRid, action.unsanitizedApiName ?? action.apiName, {
|
|
28
|
+
requests: parameters ? await remapBatchActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.unsanitizedApiName ?? action.apiName)) : [],
|
|
29
29
|
options: {
|
|
30
30
|
returnEdits: options?.$returnEdits ? "ALL" : "NONE"
|
|
31
31
|
}
|
|
@@ -35,8 +35,8 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
35
35
|
const edits = response.edits;
|
|
36
36
|
return options?.$returnEdits ? edits?.type === "edits" ? remapActionResponse(response) : edits : undefined;
|
|
37
37
|
} else {
|
|
38
|
-
const response = await Actions.apply(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
39
|
-
parameters: await remapActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.apiName)),
|
|
38
|
+
const response = await Actions.apply(clientWithHeaders, await client.ontologyRid, action.unsanitizedApiName ?? action.apiName, {
|
|
39
|
+
parameters: await remapActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.unsanitizedApiName ?? action.apiName)),
|
|
40
40
|
options: {
|
|
41
41
|
mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
|
|
42
42
|
returnEdits: options?.$returnEdits ? "ALL_V2_WITH_DELETIONS" : "NONE"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyAction.js","names":["Actions","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","response","applyBatch","ontologyRid","apiName","requests","remapBatchActionParams","ontologyProvider","getActionDefinition","returnEdits","$returnEdits","branch","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","transactionId","validation","result","params","actionMetadata","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","process","env","NODE_ENV","console","warn","JSON","stringify"],"sources":["applyAction.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as Actions from \"@osdk/foundry.ontologies/Action\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n const response = await Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(\n parameters,\n client,\n await client.ontologyProvider.getActionDefinition(action.apiName),\n )\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n { branch: client.branch },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n await client.ontologyProvider.getActionDefinition(action.apiName),\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n { branch: client.branch, transactionId: client.transactionId },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation && response.validation?.result === \"INVALID\") {\n const validation = response.validation;\n throw new ActionValidationError(validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client, actionMetadata);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return {\n parameters: await remapActionParams<AD>(param, client, actionMetadata),\n };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,KAAKA,OAAO,MAAM,iCAAiC;AAE1D,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAqElE,OAAO,eAAeC,WAAWA,CAU/BC,MAAqB,EACrBC,MAAU,EACVC,UAAc,EACdC,OAAW,GAAG,CAAC,CAAO,EAGtB;EACA,MAAMC,iBAAiB,GAAGT,oCAAoC,CAC5DC,qBAAqB,CAACI,MAAM,EAAE,OAAM;IAAEK,eAAe,EAAE;EAAc,CAAC,CAAC,CAAC,EACxEJ,MACF,CAAC;EACD,IAAIK,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;IAC7B,MAAMM,QAAQ,GAAG,MAAMd,OAAO,CAACe,UAAU,CACvCL,iBAAiB,EACjB,MAAMJ,MAAM,CAACU,WAAW,EACxBT,MAAM,CAACU,OAAO,EACd;MACEC,QAAQ,EAAEV,UAAU,GAChB,MAAMW,sBAAsB,CAC5BX,UAAU,EACVF,MAAM,EACN,MAAMA,MAAM,CAACc,gBAAgB,CAAC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AAID,IAAI,CAAClC,IAAI,KAAK,cAAc,EAAE;UACvCuB,sBAAsB,CAACM,cAAc,EAAEW,IAAI,CAACL,QAAQ,CAAC;QACvD,CAAC,MAAM,IAAID,IAAI,CAAClC,IAAI,KAAK,cAAc,EAAE;UACvCuB,sBAAsB,CAACO,eAAe,CAACU,IAAI,CAACL,QAAQ,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACAC,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAAChB,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"applyAction.js","names":["Actions","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","response","applyBatch","ontologyRid","unsanitizedApiName","apiName","requests","remapBatchActionParams","ontologyProvider","getActionDefinition","returnEdits","$returnEdits","branch","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","transactionId","validation","result","params","actionMetadata","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","process","env","NODE_ENV","console","warn","JSON","stringify"],"sources":["applyAction.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as Actions from \"@osdk/foundry.ontologies/Action\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n const response = await Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(\n parameters,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n )\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n { branch: client.branch },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n { branch: client.branch, transactionId: client.transactionId },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation && response.validation?.result === \"INVALID\") {\n const validation = response.validation;\n throw new ActionValidationError(validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client, actionMetadata);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return {\n parameters: await remapActionParams<AD>(param, client, actionMetadata),\n };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,KAAKA,OAAO,MAAM,iCAAiC;AAE1D,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAqElE,OAAO,eAAeC,WAAWA,CAU/BC,MAAqB,EACrBC,MAAU,EACVC,UAAc,EACdC,OAAW,GAAG,CAAC,CAAO,EAGtB;EACA,MAAMC,iBAAiB,GAAGT,oCAAoC,CAC5DC,qBAAqB,CAACI,MAAM,EAAE,OAAM;IAAEK,eAAe,EAAE;EAAc,CAAC,CAAC,CAAC,EACxEJ,MACF,CAAC;EACD,IAAIK,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;IAC7B,MAAMM,QAAQ,GAAG,MAAMd,OAAO,CAACe,UAAU,CACvCL,iBAAiB,EACjB,MAAMJ,MAAM,CAACU,WAAW,EACxBT,MAAM,CAACU,kBAAkB,IAAIV,MAAM,CAACW,OAAO,EAC3C;MACEC,QAAQ,EAAEX,UAAU,GAChB,MAAMY,sBAAsB,CAC5BZ,UAAU,EACVF,MAAM,EACN,MAAMA,MAAM,CAACe,gBAAgB,CAACC,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,WAAW,EAAE;UAC7BuB,sBAAsB,CAACK,YAAY,CAACY,IAAI,CAACL,QAAQ,CAAC;QACpD,CAAC,MAAM,IAAID,IAAI,CAAClC,IAAI,KAAK,cAAc,EAAE;UACvCuB,sBAAsB,CAACM,cAAc,EAAEW,IAAI,CAACL,QAAQ,CAAC;QACvD,CAAC,MAAM,IAAID,IAAI,CAAClC,IAAI,KAAK,cAAc,EAAE;UACvCuB,sBAAsB,CAACO,eAAe,CAACU,IAAI,CAACL,QAAQ,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACAC,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAAChB,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
|
|
@@ -27,7 +27,7 @@ export const fetchMetadataInternal = async (client, definition) => {
|
|
|
27
27
|
} else if (definition.type === "interface") {
|
|
28
28
|
return client.ontologyProvider.getInterfaceDefinition(definition.apiName);
|
|
29
29
|
} else if (definition.type === "action") {
|
|
30
|
-
return client.ontologyProvider.getActionDefinition(definition.apiName);
|
|
30
|
+
return client.ontologyProvider.getActionDefinition(definition.unsanitizedApiName ?? definition.apiName);
|
|
31
31
|
} else if (definition.type === "query") {
|
|
32
32
|
return client.ontologyProvider.getQueryDefinition(definition.apiName, definition.isFixedVersion ? definition.version : undefined);
|
|
33
33
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchMetadata.js","names":["InterfaceDefinitions","fetchMetadataInternal","client","definition","type","interfaceDefs","objectTypeDef","ontologyProvider","getObjectDefinition","apiName","getInterfaceDefinition","getActionDefinition","getQueryDefinition","isFixedVersion","version","undefined","Error"],"sources":["fetchMetadata.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n} from \"@osdk/api\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { InterfaceDefinitions } from \"./ontology/OntologyProvider.js\";\n\n/** @internal */\nexport const fetchMetadataInternal = async <\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n>(\n client: MinimalClient,\n definition: Q,\n): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n> => {\n if (definition.type === \"object\") {\n const { [InterfaceDefinitions]: interfaceDefs, ...objectTypeDef } =\n await client.ontologyProvider\n .getObjectDefinition(definition.apiName);\n return objectTypeDef as any;\n } else if (definition.type === \"interface\") {\n return client.ontologyProvider.getInterfaceDefinition(\n definition.apiName,\n ) as any;\n } else if (definition.type === \"action\") {\n return client.ontologyProvider.getActionDefinition(\n definition.apiName,\n ) as any;\n } else if (definition.type === \"query\") {\n return client.ontologyProvider.getQueryDefinition(\n definition.apiName,\n definition.isFixedVersion ? definition.version : undefined,\n ) as any;\n } else {\n throw new Error(\"Not implemented for given definition\");\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,oBAAoB,QAAQ,gCAAgC;;AAErE;AACA,OAAO,MAAMC,qBAAqB,GAAG,MAAAA,CAQnCC,MAAqB,EACrBC,UAAa,KAOV;EACH,IAAIA,UAAU,CAACC,IAAI,KAAK,QAAQ,EAAE;IAChC,MAAM;MAAE,CAACJ,oBAAoB,GAAGK,aAAa;MAAE,GAAGC;IAAc,CAAC,GAC/D,MAAMJ,MAAM,CAACK,gBAAgB,CAC1BC,mBAAmB,CAACL,UAAU,CAACM,OAAO,CAAC;IAC5C,OAAOH,aAAa;EACtB,CAAC,MAAM,IAAIH,UAAU,CAACC,IAAI,KAAK,WAAW,EAAE;IAC1C,OAAOF,MAAM,CAACK,gBAAgB,CAACG,sBAAsB,CACnDP,UAAU,CAACM,OACb,CAAC;EACH,CAAC,MAAM,IAAIN,UAAU,CAACC,IAAI,KAAK,QAAQ,EAAE;IACvC,OAAOF,MAAM,CAACK,gBAAgB,CAACI,mBAAmB,CAChDR,UAAU,CAACM,
|
|
1
|
+
{"version":3,"file":"fetchMetadata.js","names":["InterfaceDefinitions","fetchMetadataInternal","client","definition","type","interfaceDefs","objectTypeDef","ontologyProvider","getObjectDefinition","apiName","getInterfaceDefinition","getActionDefinition","unsanitizedApiName","getQueryDefinition","isFixedVersion","version","undefined","Error"],"sources":["fetchMetadata.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n} from \"@osdk/api\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { InterfaceDefinitions } from \"./ontology/OntologyProvider.js\";\n\n/** @internal */\nexport const fetchMetadataInternal = async <\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n>(\n client: MinimalClient,\n definition: Q,\n): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n> => {\n if (definition.type === \"object\") {\n const { [InterfaceDefinitions]: interfaceDefs, ...objectTypeDef } =\n await client.ontologyProvider\n .getObjectDefinition(definition.apiName);\n return objectTypeDef as any;\n } else if (definition.type === \"interface\") {\n return client.ontologyProvider.getInterfaceDefinition(\n definition.apiName,\n ) as any;\n } else if (definition.type === \"action\") {\n return client.ontologyProvider.getActionDefinition(\n definition.unsanitizedApiName ?? definition.apiName,\n ) as any;\n } else if (definition.type === \"query\") {\n return client.ontologyProvider.getQueryDefinition(\n definition.apiName,\n definition.isFixedVersion ? definition.version : undefined,\n ) as any;\n } else {\n throw new Error(\"Not implemented for given definition\");\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,oBAAoB,QAAQ,gCAAgC;;AAErE;AACA,OAAO,MAAMC,qBAAqB,GAAG,MAAAA,CAQnCC,MAAqB,EACrBC,UAAa,KAOV;EACH,IAAIA,UAAU,CAACC,IAAI,KAAK,QAAQ,EAAE;IAChC,MAAM;MAAE,CAACJ,oBAAoB,GAAGK,aAAa;MAAE,GAAGC;IAAc,CAAC,GAC/D,MAAMJ,MAAM,CAACK,gBAAgB,CAC1BC,mBAAmB,CAACL,UAAU,CAACM,OAAO,CAAC;IAC5C,OAAOH,aAAa;EACtB,CAAC,MAAM,IAAIH,UAAU,CAACC,IAAI,KAAK,WAAW,EAAE;IAC1C,OAAOF,MAAM,CAACK,gBAAgB,CAACG,sBAAsB,CACnDP,UAAU,CAACM,OACb,CAAC;EACH,CAAC,MAAM,IAAIN,UAAU,CAACC,IAAI,KAAK,QAAQ,EAAE;IACvC,OAAOF,MAAM,CAACK,gBAAgB,CAACI,mBAAmB,CAChDR,UAAU,CAACS,kBAAkB,IAAIT,UAAU,CAACM,OAC9C,CAAC;EACH,CAAC,MAAM,IAAIN,UAAU,CAACC,IAAI,KAAK,OAAO,EAAE;IACtC,OAAOF,MAAM,CAACK,gBAAgB,CAACM,kBAAkB,CAC/CV,UAAU,CAACM,OAAO,EAClBN,UAAU,CAACW,cAAc,GAAGX,UAAU,CAACY,OAAO,GAAGC,SACnD,CAAC;EACH,CAAC,MAAM;IACL,MAAM,IAAIC,KAAK,CAAC,sCAAsC,CAAC;EACzD;AACF,CAAC","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ import invariant from "tiny-invariant";
|
|
|
18
18
|
import { fullyQualifyPropName } from "./fullyQualifyPropName.js";
|
|
19
19
|
import { makeGeoFilterIntersects } from "./makeGeoFilterIntersects.js";
|
|
20
20
|
import { makeGeoFilterWithin } from "./makeGeoFilterWithin.js";
|
|
21
|
+
import { toIntervalQueryRule } from "./toIntervalQuery.js";
|
|
21
22
|
function isAndClause(whereClause) {
|
|
22
23
|
return "$and" in whereClause && whereClause.$and !== undefined;
|
|
23
24
|
}
|
|
@@ -152,6 +153,16 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
152
153
|
fuzzy: typeof filter[firstKey] === "string" ? false : filter[firstKey]["fuzzySearch"] ?? false
|
|
153
154
|
};
|
|
154
155
|
}
|
|
156
|
+
if (firstKey === "$interval") {
|
|
157
|
+
return {
|
|
158
|
+
type: "interval",
|
|
159
|
+
...(propertyIdentifier != null && {
|
|
160
|
+
propertyIdentifier
|
|
161
|
+
}),
|
|
162
|
+
field,
|
|
163
|
+
rule: toIntervalQueryRule(filter[firstKey])
|
|
164
|
+
};
|
|
165
|
+
}
|
|
155
166
|
return {
|
|
156
167
|
type: firstKey.substring(1),
|
|
157
168
|
...(propertyIdentifier != null && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.js","names":["invariant","fullyQualifyPropName","makeGeoFilterIntersects","makeGeoFilterWithin","isAndClause","whereClause","$and","undefined","isOrClause","$or","isNotClause","$not","modernToLegacyWhereClause","objectOrInterface","rdpNames","parts","Object","entries","map","key","value","length","modernToLegacyWhereClauseInner","type","v","process","env","NODE_ENV","clause","handleWherePair","fieldName","filter","structFieldSelector","isRdp","has","propertyIdentifier","apiName","propertyApiName","field","keysOfFilter","keys","hasDollarSign","some","startsWith","structFilter","structFieldApiName","firstKey","containsValue","containsKeys","isFilterObject","substring","fuzzy"],"sources":["modernToLegacyWhereClause.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AndWhereClause,\n NotWhereClause,\n ObjectOrInterfaceDefinition,\n OrWhereClause,\n PossibleWhereClauseFilters,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { fullyQualifyPropName } from \"./fullyQualifyPropName.js\";\nimport { makeGeoFilterIntersects } from \"./makeGeoFilterIntersects.js\";\nimport { makeGeoFilterWithin } from \"./makeGeoFilterWithin.js\";\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction isAndClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is AndWhereClause<T, RDPs> {\n return \"$and\" in whereClause && whereClause.$and !== undefined;\n}\n\nfunction isOrClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is OrWhereClause<T, RDPs> {\n return \"$or\" in whereClause && whereClause.$or !== undefined;\n}\n\nfunction isNotClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is NotWhereClause<T, RDPs> {\n return \"$not\" in whereClause && whereClause.$not !== undefined;\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause).map(([key, value]) => ({\n [key]: value,\n })) as WhereClause<T, RDPs>[];\n if (parts.length === 1) {\n return modernToLegacyWhereClauseInner(\n whereClause,\n objectOrInterface,\n rdpNames,\n );\n }\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => modernToLegacyWhereClauseInner(v, objectOrInterface, rdpNames),\n ),\n };\n}\n\n/** @internal */\nexport function modernToLegacyWhereClauseInner<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause);\n\n invariant(parts.length === 1, \"Invalid where clause provided.\");\n\n if (isAndClause(whereClause)) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isOrClause(whereClause)) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isNotClause(whereClause)) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T, RDPs>,\n objectOrInterface,\n rdpNames,\n ),\n };\n }\n\n return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n `Cannot filter on property \"${fieldName}\" with an undefined or null value. `\n + `If the value might be undefined, check it before adding to the where clause.`,\n );\n\n const isRdp = !structFieldSelector && rdpNames?.has(fieldName);\n\n const propertyIdentifier: PropertyIdentifier | undefined = isRdp\n ? {\n type: \"property\",\n apiName: fieldName,\n }\n : structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n\n const field = !isRdp && structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n invariant(\n field == null\n || propertyIdentifier == null && (field != null || isRdp != null),\n \"Encountered error constructing where clause: field and propertyIdentifier cannot both be defined\",\n );\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.\",\n );\n\n // Struct\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n }, rdpNames);\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n if (firstKey === \"$contains\" && filter[firstKey] instanceof Object) {\n const containsValue = filter[firstKey];\n const containsKeys = Object.keys(containsValue);\n\n const isFilterObject = containsKeys.some(key => key.startsWith(\"$\"));\n\n if (isFilterObject) {\n return handleWherePair(\n [fieldName, containsValue],\n objectOrInterface,\n structFieldSelector,\n rdpNames,\n );\n } else {\n const structFilter: [string, any][] = Object.entries(containsValue);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = structFilter[0][0];\n\n return handleWherePair(structFilter[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n });\n }\n }\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n return makeGeoFilterWithin(filter[firstKey], propertyIdentifier, field);\n }\n if (firstKey === \"$intersects\") {\n return makeGeoFilterIntersects(filter[firstKey], propertyIdentifier, field);\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,mBAAmB,QAAQ,0BAA0B;AAK9D,SAASC,WAAWA,CAIlBC,WAAiC,EACO;EACxC,OAAO,MAAM,IAAIA,WAAW,IAAIA,WAAW,CAACC,IAAI,KAAKC,SAAS;AAChE;AAEA,SAASC,UAAUA,CAIjBH,WAAiC,EACM;EACvC,OAAO,KAAK,IAAIA,WAAW,IAAIA,WAAW,CAACI,GAAG,KAAKF,SAAS;AAC9D;AAEA,SAASG,WAAWA,CAIlBL,WAAiC,EACO;EACxC,OAAO,MAAM,IAAIA,WAAW,IAAIA,WAAW,CAACM,IAAI,KAAKJ,SAAS;AAChE;;AAEA;AACA,OAAO,SAASK,yBAAyBA,CAIvCP,WAAiC,EACjCQ,iBAAoB,EACpBC,QAAsB,EACH;EACnB,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACZ,WAAW,CAAC,CAACa,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,MAAM;IAC/D,CAACD,GAAG,GAAGC;EACT,CAAC,CAAC,CAA2B;EAC7B,IAAIL,KAAK,CAACM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,QAAQ,KAAK,kBAAkB,EAAE;IACvE,OAAO;MACLvB,IAAI,EAAEuB,QAAQ,CAACI,SAAS,CAAC,CAAC,CAAoC;MAC9D,IAAIf,kBAAkB,IAAI,IAAI,IAAI;QAAEA;MAAmB,CAAC,CAAC;MACzDG,KAAK;MACLlB,KAAK,EAAE,OAAOW,MAAM,CAACe,QAAQ,CAAC,KAAK,QAAQ,GACvCf,MAAM,CAACe,QAAQ,CAAC,GAChBf,MAAM,CAACe,QAAQ,CAAC,CAAC,MAAM,CAAC;MAC5BK,KAAK,EAAE,OAAOpB,MAAM,CAACe,QAAQ,CAAC,KAAK,QAAQ,GACvC,KAAK,GACLf,MAAM,CAACe,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAI;IACzC,CAAC;EACH;EAEA,OAAO;IACLvB,IAAI,EAAEuB,QAAQ,CAACI,SAAS,CAAC,CAAC,CAAoC;IAC9D,IAAIf,kBAAkB,IAAI,IAAI,IAAI;MAAEA;IAAmB,CAAC,CAAC;IACzDG,KAAK;IACLlB,KAAK,EAAEW,MAAM,CAACe,QAAQ;EACxB,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.js","names":["invariant","fullyQualifyPropName","makeGeoFilterIntersects","makeGeoFilterWithin","toIntervalQueryRule","isAndClause","whereClause","$and","undefined","isOrClause","$or","isNotClause","$not","modernToLegacyWhereClause","objectOrInterface","rdpNames","parts","Object","entries","map","key","value","length","modernToLegacyWhereClauseInner","type","v","process","env","NODE_ENV","clause","handleWherePair","fieldName","filter","structFieldSelector","isRdp","has","propertyIdentifier","apiName","propertyApiName","field","keysOfFilter","keys","hasDollarSign","some","startsWith","structFilter","structFieldApiName","firstKey","containsValue","containsKeys","isFilterObject","substring","fuzzy","rule"],"sources":["modernToLegacyWhereClause.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AndWhereClause,\n NotWhereClause,\n ObjectOrInterfaceDefinition,\n OrWhereClause,\n PossibleWhereClauseFilters,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { fullyQualifyPropName } from \"./fullyQualifyPropName.js\";\nimport { makeGeoFilterIntersects } from \"./makeGeoFilterIntersects.js\";\nimport { makeGeoFilterWithin } from \"./makeGeoFilterWithin.js\";\nimport { toIntervalQueryRule } from \"./toIntervalQuery.js\";\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction isAndClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is AndWhereClause<T, RDPs> {\n return \"$and\" in whereClause && whereClause.$and !== undefined;\n}\n\nfunction isOrClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is OrWhereClause<T, RDPs> {\n return \"$or\" in whereClause && whereClause.$or !== undefined;\n}\n\nfunction isNotClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is NotWhereClause<T, RDPs> {\n return \"$not\" in whereClause && whereClause.$not !== undefined;\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause).map(([key, value]) => ({\n [key]: value,\n })) as WhereClause<T, RDPs>[];\n if (parts.length === 1) {\n return modernToLegacyWhereClauseInner(\n whereClause,\n objectOrInterface,\n rdpNames,\n );\n }\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => modernToLegacyWhereClauseInner(v, objectOrInterface, rdpNames),\n ),\n };\n}\n\n/** @internal */\nexport function modernToLegacyWhereClauseInner<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause);\n\n invariant(parts.length === 1, \"Invalid where clause provided.\");\n\n if (isAndClause(whereClause)) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isOrClause(whereClause)) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isNotClause(whereClause)) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T, RDPs>,\n objectOrInterface,\n rdpNames,\n ),\n };\n }\n\n return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n `Cannot filter on property \"${fieldName}\" with an undefined or null value. `\n + `If the value might be undefined, check it before adding to the where clause.`,\n );\n\n const isRdp = !structFieldSelector && rdpNames?.has(fieldName);\n\n const propertyIdentifier: PropertyIdentifier | undefined = isRdp\n ? {\n type: \"property\",\n apiName: fieldName,\n }\n : structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n\n const field = !isRdp && structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n invariant(\n field == null\n || propertyIdentifier == null && (field != null || isRdp != null),\n \"Encountered error constructing where clause: field and propertyIdentifier cannot both be defined\",\n );\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.\",\n );\n\n // Struct\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n }, rdpNames);\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n if (firstKey === \"$contains\" && filter[firstKey] instanceof Object) {\n const containsValue = filter[firstKey];\n const containsKeys = Object.keys(containsValue);\n\n const isFilterObject = containsKeys.some(key => key.startsWith(\"$\"));\n\n if (isFilterObject) {\n return handleWherePair(\n [fieldName, containsValue],\n objectOrInterface,\n structFieldSelector,\n rdpNames,\n );\n } else {\n const structFilter: [string, any][] = Object.entries(containsValue);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = structFilter[0][0];\n\n return handleWherePair(structFilter[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n });\n }\n }\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n return makeGeoFilterWithin(filter[firstKey], propertyIdentifier, field);\n }\n if (firstKey === \"$intersects\") {\n return makeGeoFilterIntersects(filter[firstKey], propertyIdentifier, field);\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n if (firstKey === \"$interval\") {\n return {\n type: \"interval\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n rule: toIntervalQueryRule(filter[firstKey]),\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,mBAAmB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B,IAAI,IAAI,IAAI;QAAEA;MAAmB,CAAC,CAAC;MACzDG,KAAK;MACLc,IAAI,EAAEjD,mBAAmB,CAAC4B,MAAM,CAACe,QAAQ,CAAC;IAC5C,CAAC;EACH;EAEA,OAAO;IACLvB,IAAI,EAAEuB,QAAQ,CAACI,SAAS,CAAC,CAAC,CAAoC;IAC9D,IAAIf,kBAAkB,IAAI,IAAI,IAAI;MAAEA;IAAmB,CAAC,CAAC;IACzDG,KAAK;IACLlB,KAAK,EAAEW,MAAM,CAACe,QAAQ;EACxB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 invariant from "tiny-invariant";
|
|
18
|
+
export function toIntervalQueryRule(rule) {
|
|
19
|
+
if (rule.$match != null) {
|
|
20
|
+
if (rule.$prefixOnLastTerm) {
|
|
21
|
+
return {
|
|
22
|
+
type: "prefixOnLastToken",
|
|
23
|
+
query: rule.$match
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
type: "match",
|
|
28
|
+
query: rule.$match,
|
|
29
|
+
ordered: rule.$ordered,
|
|
30
|
+
maxGaps: rule.$maxGaps
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (rule.$and != null) {
|
|
34
|
+
return {
|
|
35
|
+
type: "allOf",
|
|
36
|
+
rules: rule.$and.map(toIntervalQueryRule),
|
|
37
|
+
ordered: rule.$ordered,
|
|
38
|
+
maxGaps: rule.$maxGaps
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (rule.$or != null) {
|
|
42
|
+
return {
|
|
43
|
+
type: "anyOf",
|
|
44
|
+
rules: rule.$or.map(toIntervalQueryRule)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (rule.$fuzzy != null) {
|
|
48
|
+
return {
|
|
49
|
+
type: "fuzzy",
|
|
50
|
+
term: rule.$fuzzy,
|
|
51
|
+
fuzziness: rule.$fuzziness
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "Unknown interval rule type") : invariant(false);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=toIntervalQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIntervalQuery.js","names":["invariant","toIntervalQueryRule","rule","$match","$prefixOnLastTerm","type","query","ordered","$ordered","maxGaps","$maxGaps","$and","rules","map","$or","$fuzzy","term","fuzziness","$fuzziness","process","env","NODE_ENV"],"sources":["toIntervalQuery.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { IntervalRule } from \"@osdk/api\";\nimport type { SearchJsonQueryV2 } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\n\ntype IntervalQueryRule = Extract<\n SearchJsonQueryV2,\n { type: \"interval\" }\n>[\"rule\"];\n\nexport function toIntervalQueryRule(\n rule: IntervalRule,\n): IntervalQueryRule {\n if (rule.$match != null) {\n if (rule.$prefixOnLastTerm) {\n return {\n type: \"prefixOnLastToken\",\n query: rule.$match,\n };\n }\n return {\n type: \"match\",\n query: rule.$match,\n ordered: rule.$ordered,\n maxGaps: rule.$maxGaps,\n };\n }\n if (rule.$and != null) {\n return {\n type: \"allOf\",\n rules: rule.$and.map(toIntervalQueryRule),\n ordered: rule.$ordered,\n maxGaps: rule.$maxGaps,\n };\n }\n if (rule.$or != null) {\n return {\n type: \"anyOf\",\n rules: rule.$or.map(toIntervalQueryRule),\n };\n }\n if (rule.$fuzzy != null) {\n return {\n type: \"fuzzy\",\n term: rule.$fuzzy,\n fuzziness: rule.$fuzziness,\n };\n }\n\n const _: never = rule;\n invariant(false, \"Unknown interval rule type\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,SAAS,MAAM,gBAAgB;AAOtC,OAAO,SAASC,mBAAmBA,CACjCC,IAAkB,EACC;EACnB,IAAIA,IAAI,CAACC,MAAM,IAAI,IAAI,EAAE;IACvB,IAAID,IAAI,CAACE,iBAAiB,EAAE;MAC1B,OAAO;QACLC,IAAI,EAAE,mBAAmB;QACzBC,KAAK,EAAEJ,IAAI,CAACC;MACd,CAAC;IACH;IACA,OAAO;MACLE,IAAI,EAAE,OAAO;MACbC,KAAK,EAAEJ,IAAI,CAACC,MAAM;MAClBI,OAAO,EAAEL,IAAI,CAACM,QAAQ;MACtBC,OAAO,EAAEP,IAAI,CAACQ;IAChB,CAAC;EACH;EACA,IAAIR,IAAI,CAACS,IAAI,IAAI,IAAI,EAAE;IACrB,OAAO;MACLN,IAAI,EAAE,OAAO;MACbO,KAAK,EAAEV,IAAI,CAACS,IAAI,CAACE,GAAG,CAACZ,mBAAmB,CAAC;MACzCM,OAAO,EAAEL,IAAI,CAACM,QAAQ;MACtBC,OAAO,EAAEP,IAAI,CAACQ;IAChB,CAAC;EACH;EACA,IAAIR,IAAI,CAACY,GAAG,IAAI,IAAI,EAAE;IACpB,OAAO;MACLT,IAAI,EAAE,OAAO;MACbO,KAAK,EAAEV,IAAI,CAACY,GAAG,CAACD,GAAG,CAACZ,mBAAmB;IACzC,CAAC;EACH;EACA,IAAIC,IAAI,CAACa,MAAM,IAAI,IAAI,EAAE;IACvB,OAAO;MACLV,IAAI,EAAE,OAAO;MACbW,IAAI,EAAEd,IAAI,CAACa,MAAM;MACjBE,SAAS,EAAEf,IAAI,CAACgB;IAClB,CAAC;EACH;EAGAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,4BAA4B,IAA7CA,SAAS;AACX","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleOsdkProperties.js","names":[],"sources":["SimpleOsdkProperties.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a \"pure\" object from the wire that has its special properties with\n * $ prefix and is ready to be converted to an Osdk object.\n *\n * This object intentionally does not have any generics attached to keep it simple\n * to use.\n *\n * @internal\n */\nexport interface SimpleOsdkProperties {\n $apiName: string;\n $objectType: string;\n $primaryKey: string | number
|
|
1
|
+
{"version":3,"file":"SimpleOsdkProperties.js","names":[],"sources":["SimpleOsdkProperties.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a \"pure\" object from the wire that has its special properties with\n * $ prefix and is ready to be converted to an Osdk object.\n *\n * This object intentionally does not have any generics attached to keep it simple\n * to use.\n *\n * @internal\n */\nexport interface SimpleOsdkProperties {\n $apiName: string;\n $objectType: string;\n $primaryKey: string | number;\n $title: string | undefined;\n $rid?: string;\n\n [key: string]:\n | string\n | Array<string>\n | number\n | Array<number>\n | boolean\n | Array<boolean>\n | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.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 ActionEditResponse,\n ActionValidationResponse,\n AggregateOpts,\n AggregationsResults,\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport type { QueryReturnType } from \"../queries/types.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectOrInterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectOrInterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q, RDPs>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n withProperties?: DerivedProperty.Clause<Q>;\n\n /**\n * Fetch objects by their Resource Identifiers (RIDs).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * observeList({ type: Employee, rids: ['ri.foo.123', 'ri.foo.456'] }, observer)\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * observeList({\n * type: Employee,\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * }, observer)\n */\n rids?: readonly string[];\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n select?: readonly PropertyKeys<Q>[];\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * @example\n * // Fetch all todos at once\n * observeList({ type: Todo, autoFetchMore: true }, observer)\n *\n * @example\n * // Fetch at least 100 todos\n * observeList({ type: Todo, autoFetchMore: 100, pageSize: 25 }, observer)\n */\n autoFetchMore?: boolean | number;\n intersectWith?: Array<{\n where: WhereClause<Q, RDPs>;\n }>;\n pivotTo?: string;\n}\n\nexport interface ObserveObjectCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\nexport interface ObserveObjectsCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\nexport interface ObserveObjectSetArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n objectSet: ObjectSet<T, RDPs>;\n totalCount?: string;\n}\n\ninterface ObserveAggregationBaseOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: T;\n where?: WhereClause<T, RDPs>;\n withProperties?: DerivedProperty.Clause<T>;\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n aggregate: A;\n}\n\n/**\n * Options for observeAggregation without an ObjectSet (synchronous).\n */\nexport interface ObserveAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet?: undefined;\n}\n\n/**\n * Options for observeAggregation with an ObjectSet (asynchronous).\n *\n * When objectSet is provided, the aggregation is performed on that ObjectSet\n * instead of the base type, enabling aggregation on pivoted or filtered sets.\n */\nexport interface ObserveAggregationOptionsWithObjectSet<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet: ObjectSet<T>;\n}\n\nexport interface ObserveAggregationArgs<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n> {\n result: AggregationsResults<T, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface ObserveFunctionOptions extends CommonObserveOptions {\n /**\n * Object types this function depends on.\n * When actions modify these types, the function will refetch.\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When these objects change, the function will refetch.\n *\n * For ObjectSets, the object type is extracted asynchronously and added\n * to the dependency list. Changes to any object of that type will trigger\n * a refetch.\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n}\n\nexport interface ObserveFunctionCallbackArgs<\n Q extends QueryDefinition<unknown>,\n> {\n result: QueryReturnType<CompileTimeMetadata<Q>[\"output\"]> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[] | undefined;\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<T>>\n >;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object or interface instance with automatic updates when it changes.\n *\n * @param apiName - The object type or interface definition, or its API name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectOrInterfaceDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectCallbackArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveListOptions<T, RDPs>,\n subFn: Observer<ObserveObjectsCallbackArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * Observe an ObjectSet with automatic updates when matching objects change.\n *\n * @param baseObjectSet - The base ObjectSet to observe\n * @param options - Options for transforming and observing the ObjectSet\n * @param subFn - Observer that receives ObjectSet state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports all ObjectSet operations:\n * - Filtering with where clauses\n * - Derived properties with withProperties\n * - Set operations (union, intersect, subtract)\n * - Link traversal with pivotTo\n * - Sorting and pagination\n */\n observeObjectSet<\n T extends ObjectOrInterfaceDefinition,\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\n /**\n * @deprecated Use the async overload with `objectSet` parameter instead.\n * Pass `objectSet: client(YourType)` to get the base object set.\n */\n 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\n /**\n * Observe an aggregation query on a custom ObjectSet with automatic updates.\n *\n * This overload accepts an ObjectSet parameter, enabling aggregation on pivoted,\n * filtered, or composed ObjectSets. Returns a Promise because invalidation type\n * computation is async (requires lookups for link targets).\n *\n * @param options - Aggregation configuration including objectSet, where, aggregate spec\n * @param subFn - Observer that receives aggregation result updates\n * @returns Promise resolving to subscription that can be unsubscribed\n *\n * @example\n * ```typescript\n * const sub = await observableClient.observeAggregation(\n * {\n * type: Office,\n * objectSet: $(Employee).pivotTo(\"primaryOffice\"),\n * aggregate: { $select: { $count: \"unordered\" } }\n * },\n * observer\n * );\n * ```\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Promise<Unsubscribable>;\n\n /**\n * Observe a function execution with automatic updates.\n *\n * @param queryDef - The QueryDefinition to execute\n * @param params - Parameters to pass to the function (undefined if no params)\n * @param options - Observation options including invalidation configuration\n * @param subFn - Observer that receives function result updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Automatic caching and deduplication\n * - Dependency-based invalidation (dependsOn object types)\n * - Instance-based invalidation (dependsOnObjects)\n * - Manual refetch via invalidateFunction()\n */\n observeFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n params: Record<string, unknown> | undefined,\n options: ObserveFunctionOptions,\n subFn: Observer<ObserveFunctionCallbackArgs<Q>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<ActionEditResponse>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n /**\n * Invalidates the entire cache, forcing all queries to refetch.\n * Use sparingly as this can cause significant network traffic.\n */\n invalidateAll(): Promise<void>;\n\n /**\n * Invalidates specific objects in the cache.\n * @param objects - Single object or array of objects to invalidate\n */\n invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void>;\n\n /**\n * Invalidates all cached data for a specific object type.\n * This includes:\n * - All objects of the specified type\n * - All lists containing objects of this type\n * - All links where the source is of this type\n *\n * @param type - Object type definition or API name string\n * @returns Promise that resolves when invalidation is complete\n */\n invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void>;\n\n /**\n * Invalidate function queries.\n * - If params undefined, invalidates ALL queries for this function\n * - If params provided, invalidates only the query with exact params match\n *\n * @param apiName - Function API name string or QueryDefinition\n * @param params - Optional params for exact match\n */\n invalidateFunction(\n apiName: string | QueryDefinition<unknown>,\n params?: Record<string, unknown>,\n ): Promise<void>;\n\n /**\n * Invalidate functions that depend on a specific object instance.\n *\n * @param apiName - Object type API name\n * @param primaryKey - Object primary key\n */\n invalidateFunctionsByObject(\n apiName: string,\n primaryKey: string | number,\n ): Promise<void>;\n\n canonicalizeWhereClause: <\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n where: WhereClause<T, RDPs>,\n ) => Canonical<WhereClause<T, RDPs>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAE5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AA+IjC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgPA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.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 ActionEditResponse,\n ActionValidationResponse,\n AggregateOpts,\n AggregationsResults,\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport type { QueryReturnType } from \"../queries/types.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectOrInterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n $loadPropertySecurityMetadata?: boolean;\n}\n\nexport type OrderBy<Q extends ObjectOrInterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q, RDPs>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n withProperties?: DerivedProperty.Clause<Q>;\n\n /**\n * Fetch objects by their Resource Identifiers (RIDs).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * observeList({ type: Employee, rids: ['ri.foo.123', 'ri.foo.456'] }, observer)\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * observeList({\n * type: Employee,\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * }, observer)\n */\n rids?: readonly string[];\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n select?: readonly PropertyKeys<Q>[];\n\n /**\n * When true, loads per-property security metadata (marking requirements)\n * alongside each object. The returned objects will have `$propertySecurities`\n * populated with conjunctive/disjunctive marking requirements per property.\n */\n $loadPropertySecurityMetadata?: boolean;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * @example\n * // Fetch all todos at once\n * observeList({ type: Todo, autoFetchMore: true }, observer)\n *\n * @example\n * // Fetch at least 100 todos\n * observeList({ type: Todo, autoFetchMore: 100, pageSize: 25 }, observer)\n */\n autoFetchMore?: boolean | number;\n intersectWith?: Array<{\n where: WhereClause<Q, RDPs>;\n }>;\n pivotTo?: string;\n}\n\nexport interface ObserveObjectCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\nexport interface ObserveObjectsCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\nexport interface ObserveObjectSetArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n objectSet: ObjectSet<T, RDPs>;\n totalCount?: string;\n}\n\ninterface ObserveAggregationBaseOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: T;\n where?: WhereClause<T, RDPs>;\n withProperties?: DerivedProperty.Clause<T>;\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n aggregate: A;\n}\n\n/**\n * Options for observeAggregation without an ObjectSet (synchronous).\n */\nexport interface ObserveAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet?: undefined;\n}\n\n/**\n * Options for observeAggregation with an ObjectSet (asynchronous).\n *\n * When objectSet is provided, the aggregation is performed on that ObjectSet\n * instead of the base type, enabling aggregation on pivoted or filtered sets.\n */\nexport interface ObserveAggregationOptionsWithObjectSet<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet: ObjectSet<T>;\n}\n\nexport interface ObserveAggregationArgs<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n> {\n result: AggregationsResults<T, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface ObserveFunctionOptions extends CommonObserveOptions {\n /**\n * Object types this function depends on.\n * When actions modify these types, the function will refetch.\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When these objects change, the function will refetch.\n *\n * For ObjectSets, the object type is extracted asynchronously and added\n * to the dependency list. Changes to any object of that type will trigger\n * a refetch.\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n}\n\nexport interface ObserveFunctionCallbackArgs<\n Q extends QueryDefinition<unknown>,\n> {\n result: QueryReturnType<CompileTimeMetadata<Q>[\"output\"]> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[] | undefined;\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<T>>\n >;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object or interface instance with automatic updates when it changes.\n *\n * @param apiName - The object type or interface definition, or its API name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectOrInterfaceDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectCallbackArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveListOptions<T, RDPs>,\n subFn: Observer<ObserveObjectsCallbackArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * Observe an ObjectSet with automatic updates when matching objects change.\n *\n * @param baseObjectSet - The base ObjectSet to observe\n * @param options - Options for transforming and observing the ObjectSet\n * @param subFn - Observer that receives ObjectSet state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports all ObjectSet operations:\n * - Filtering with where clauses\n * - Derived properties with withProperties\n * - Set operations (union, intersect, subtract)\n * - Link traversal with pivotTo\n * - Sorting and pagination\n */\n observeObjectSet<\n T extends ObjectOrInterfaceDefinition,\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\n /**\n * @deprecated Use the async overload with `objectSet` parameter instead.\n * Pass `objectSet: client(YourType)` to get the base object set.\n */\n 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\n /**\n * Observe an aggregation query on a custom ObjectSet with automatic updates.\n *\n * This overload accepts an ObjectSet parameter, enabling aggregation on pivoted,\n * filtered, or composed ObjectSets. Returns a Promise because invalidation type\n * computation is async (requires lookups for link targets).\n *\n * @param options - Aggregation configuration including objectSet, where, aggregate spec\n * @param subFn - Observer that receives aggregation result updates\n * @returns Promise resolving to subscription that can be unsubscribed\n *\n * @example\n * ```typescript\n * const sub = await observableClient.observeAggregation(\n * {\n * type: Office,\n * objectSet: $(Employee).pivotTo(\"primaryOffice\"),\n * aggregate: { $select: { $count: \"unordered\" } }\n * },\n * observer\n * );\n * ```\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Promise<Unsubscribable>;\n\n /**\n * Observe a function execution with automatic updates.\n *\n * @param queryDef - The QueryDefinition to execute\n * @param params - Parameters to pass to the function (undefined if no params)\n * @param options - Observation options including invalidation configuration\n * @param subFn - Observer that receives function result updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Automatic caching and deduplication\n * - Dependency-based invalidation (dependsOn object types)\n * - Instance-based invalidation (dependsOnObjects)\n * - Manual refetch via invalidateFunction()\n */\n observeFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n params: Record<string, unknown> | undefined,\n options: ObserveFunctionOptions,\n subFn: Observer<ObserveFunctionCallbackArgs<Q>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<ActionEditResponse>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n /**\n * Invalidates the entire cache, forcing all queries to refetch.\n * Use sparingly as this can cause significant network traffic.\n */\n invalidateAll(): Promise<void>;\n\n /**\n * Invalidates specific objects in the cache.\n * @param objects - Single object or array of objects to invalidate\n */\n invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void>;\n\n /**\n * Invalidates all cached data for a specific object type.\n * This includes:\n * - All objects of the specified type\n * - All lists containing objects of this type\n * - All links where the source is of this type\n *\n * @param type - Object type definition or API name string\n * @returns Promise that resolves when invalidation is complete\n */\n invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void>;\n\n /**\n * Invalidate function queries.\n * - If params undefined, invalidates ALL queries for this function\n * - If params provided, invalidates only the query with exact params match\n *\n * @param apiName - Function API name string or QueryDefinition\n * @param params - Optional params for exact match\n */\n invalidateFunction(\n apiName: string | QueryDefinition<unknown>,\n params?: Record<string, unknown>,\n ): Promise<void>;\n\n /**\n * Invalidate functions that depend on a specific object instance.\n *\n * @param apiName - Object type API name\n * @param primaryKey - Object primary key\n */\n invalidateFunctionsByObject(\n apiName: string,\n primaryKey: string | number,\n ): Promise<void>;\n\n canonicalizeWhereClause: <\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n where: WhereClause<T, RDPs>,\n ) => Canonical<WhereClause<T, RDPs>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAE5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AAuJjC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgPA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -38,9 +38,10 @@ export class BulkObjectLoader {
|
|
|
38
38
|
this.#maxWait = maxWait;
|
|
39
39
|
this.#maxEntries = maxEntries;
|
|
40
40
|
}
|
|
41
|
-
async fetch(apiName, primaryKey, defType = "object", select) {
|
|
41
|
+
async fetch(apiName, primaryKey, defType = "object", select, loadPropertySecurityMetadata) {
|
|
42
42
|
const deferred = pDefer();
|
|
43
|
-
const
|
|
43
|
+
const securitySuffix = loadPropertySecurityMetadata ? "\0sec" : "";
|
|
44
|
+
const selectKey = select && select.length > 0 ? `${apiName}\0${[...select].sort().join(",")}${securitySuffix}` : `${apiName}${securitySuffix}`;
|
|
44
45
|
const entry = this.#m.get(selectKey);
|
|
45
46
|
entry.data.push({
|
|
46
47
|
primaryKey: primaryKey,
|
|
@@ -49,25 +50,27 @@ export class BulkObjectLoader {
|
|
|
49
50
|
if (entry.defType === undefined) {
|
|
50
51
|
entry.defType = defType;
|
|
51
52
|
entry.select = select;
|
|
53
|
+
entry.loadPropertySecurityMetadata = loadPropertySecurityMetadata;
|
|
52
54
|
} else if (entry.defType !== defType) {
|
|
53
55
|
deferred.reject(new PalantirApiError(`Conflicting defType for ${apiName}: existing=${entry.defType}, new=${defType}`));
|
|
54
56
|
return deferred.promise;
|
|
55
57
|
}
|
|
56
58
|
if (!entry.timer) {
|
|
57
59
|
entry.timer = setTimeout(() => {
|
|
58
|
-
this.#loadObjects(apiName, entry.data, entry.defType ?? "object", entry.select);
|
|
60
|
+
this.#loadObjects(apiName, entry.data, entry.defType ?? "object", entry.select, entry.loadPropertySecurityMetadata);
|
|
59
61
|
}, this.#maxWait);
|
|
60
62
|
}
|
|
61
63
|
if (entry.data.length >= this.#maxEntries) {
|
|
62
64
|
clearTimeout(entry.timer);
|
|
63
|
-
this.#loadObjects(apiName, entry.data, entry.defType ?? "object", entry.select);
|
|
65
|
+
this.#loadObjects(apiName, entry.data, entry.defType ?? "object", entry.select, entry.loadPropertySecurityMetadata);
|
|
64
66
|
}
|
|
65
67
|
return await deferred.promise;
|
|
66
68
|
}
|
|
67
|
-
#loadObjects(apiName, arr, defType, select) {
|
|
68
|
-
const
|
|
69
|
+
#loadObjects(apiName, arr, defType, select, loadPropertySecurityMetadata) {
|
|
70
|
+
const securitySuffix = loadPropertySecurityMetadata ? "\0sec" : "";
|
|
71
|
+
const selectKey = select && select.length > 0 ? `${apiName}\0${[...select].sort().join(",")}${securitySuffix}` : `${apiName}${securitySuffix}`;
|
|
69
72
|
this.#m.delete(selectKey);
|
|
70
|
-
const loadFn = defType === "interface" ? this.#loadInterfaceObjects(apiName, arr, select) : this.#loadObjectTypeObjects(apiName, arr, select);
|
|
73
|
+
const loadFn = defType === "interface" ? this.#loadInterfaceObjects(apiName, arr, select, loadPropertySecurityMetadata) : this.#loadObjectTypeObjects(apiName, arr, select, loadPropertySecurityMetadata);
|
|
71
74
|
loadFn.catch(e => {
|
|
72
75
|
this.#logger?.error("Unhandled exception", e);
|
|
73
76
|
for (const {
|
|
@@ -79,7 +82,7 @@ export class BulkObjectLoader {
|
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
|
-
async #loadObjectTypeObjects(apiName, arr, select) {
|
|
85
|
+
async #loadObjectTypeObjects(apiName, arr, select, loadPropertySecurityMetadata) {
|
|
83
86
|
const objectDef = {
|
|
84
87
|
type: "object",
|
|
85
88
|
apiName
|
|
@@ -105,7 +108,8 @@ export class BulkObjectLoader {
|
|
|
105
108
|
$includeRid: true,
|
|
106
109
|
...(select && select.length > 0 ? {
|
|
107
110
|
$select: select
|
|
108
|
-
} : {})
|
|
111
|
+
} : {}),
|
|
112
|
+
$loadPropertySecurityMetadata: loadPropertySecurityMetadata ?? false
|
|
109
113
|
});
|
|
110
114
|
for (const {
|
|
111
115
|
primaryKey,
|
|
@@ -119,7 +123,7 @@ export class BulkObjectLoader {
|
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
|
-
async #loadInterfaceObjects(apiName, arr, select) {
|
|
126
|
+
async #loadInterfaceObjects(apiName, arr, select, loadPropertySecurityMetadata) {
|
|
123
127
|
const pks = arr.map(x => x.primaryKey);
|
|
124
128
|
const interfaceMetadata = await this.#client.fetchMetadata({
|
|
125
129
|
type: "interface",
|
|
@@ -152,7 +156,8 @@ export class BulkObjectLoader {
|
|
|
152
156
|
$pageSize: remainingPks.length,
|
|
153
157
|
...(select && select.length > 0 ? {
|
|
154
158
|
$select: select
|
|
155
|
-
} : {})
|
|
159
|
+
} : {}),
|
|
160
|
+
$loadPropertySecurityMetadata: loadPropertySecurityMetadata ?? false
|
|
156
161
|
});
|
|
157
162
|
for (const obj of data) {
|
|
158
163
|
foundObjects.set(obj.$primaryKey, obj);
|