@osdk/faux 0.2.0-rc.19 → 0.2.1

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.
@@ -33,7 +33,8 @@ export class FauxOntology {
33
33
  objectTypes: {},
34
34
  ontology,
35
35
  queryTypes: {},
36
- sharedPropertyTypes: {}
36
+ sharedPropertyTypes: {},
37
+ valueTypes: {}
37
38
  };
38
39
  }
39
40
  get apiName() {
@@ -52,7 +53,8 @@ export class FauxOntology {
52
53
  actionTypes: filterRecord(this.#ontology.actionTypes, request.actionTypes),
53
54
  queryTypes: this.#getFilteredQueryTypes(request),
54
55
  interfaceTypes: filterRecord(this.#ontology.interfaceTypes, request.interfaceTypes),
55
- sharedPropertyTypes: {}
56
+ sharedPropertyTypes: {},
57
+ valueTypes: {}
56
58
  };
57
59
  }
58
60
  getAllInterfaceTypes() {
@@ -1 +1 @@
1
- {"version":3,"file":"FauxOntology.js","names":["semver","valid","invariant","ActionNotFoundError","LinkTypeNotFound","ObjectNotFoundError","ObjectTypeDoesNotExistError","QueryNotFoundError","OpenApiCallError","FauxOntology","ontology","actionImpl","Map","queryImpl","constructor","actionTypes","interfaceTypes","objectTypes","queryTypes","sharedPropertyTypes","apiName","getOntologyFullMetadata","getFilteredOntologyMetadata","request","Object","fromEntries","entries","filter","objectType","includes","map","objectTypeApiName","objectTypeDefinition","linkTypes","linkType","filterRecord","getFilteredQueryTypes","getAllInterfaceTypes","values","getAllObjectTypes","getAllActionTypes","getAllQueryTypes","getInterfaceType","interfaceType","ret","undefined","getObjectTypeFullMetadata","getObjectTypeFullMetadataOrThrow","getActionDef","actionTypeApiName","actionType","getActionImpl","impl","get","process","env","NODE_ENV","getQueryDef","queryTypeApiNameAndVersion","queryType","convertToVersionedApiName","getQueryImpl","queryTypeApiName","version","versionMap","rsort","Array","from","keys","getInterfaceToObjectTypeMappings","objectApiNames","objectDefs","ifaceToObjMap","objDef","ifaceApiName","properties","implementsInterfaces2","getLinkTypeSideV2","linkTypeName","find","a","getOtherLinkTypeSideV2OrThrow","thisSideLink","otherObj","candidates","l","linkTypeRid","length","candidate","getBothLinkTypeSides","leftObjectType","leftLinkName","rightObjectType","leftTypeSideV2","rightTypeSideV2","registerObjectType","def","Error","registerActionType","implementation","set","registerQueryType","has","registerInterfaceType","registerSharedPropertyType","#getFilteredQueryTypes","remappedQueryTypes","x","queryTypeDefinition","indexOf","#convertToVersionedApiName","extractVersion","split","record","key"],"sources":["FauxOntology.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 ObjectTypeDefinition } from \"@osdk/api\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type {\n LoadOntologyMetadataRequest,\n VersionedQueryTypeApiName,\n} from \"@osdk/internal.foundry.ontologies\";\nimport semver, { valid } from \"semver\";\nimport invariant from \"tiny-invariant\";\nimport type { ReadonlyDeep } from \"type-fest\";\nimport {\n ActionNotFoundError,\n LinkTypeNotFound,\n ObjectNotFoundError,\n ObjectTypeDoesNotExistError,\n QueryNotFoundError,\n} from \"../errors.js\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { FauxActionImpl } from \"./FauxActionImpl.js\";\nimport type { FauxQueryImpl } from \"./FauxQueryImpl.js\";\nimport type { TH_ObjectTypeFullMetadata } from \"./typeHelpers/TH_ObjectTypeFullMetadata.js\";\n\n/**\n * Currently Unsupported Concepts:\n * - many:many links.\n */\nexport class FauxOntology {\n #ontology: OntologiesV2.OntologyFullMetadata;\n #actionImpl: Map<OntologiesV2.ActionTypeApiName, FauxActionImpl> = new Map();\n #queryImpl: Map<\n OntologiesV2.QueryApiName,\n Map<OntologiesV2.FunctionVersion, FauxQueryImpl>\n > = new Map();\n\n constructor(ontology: OntologiesV2.OntologyV2) {\n this.#ontology = {\n actionTypes: {},\n interfaceTypes: {},\n objectTypes: {},\n ontology,\n queryTypes: {},\n sharedPropertyTypes: {},\n };\n }\n\n get apiName(): OntologiesV2.OntologyApiName {\n return this.#ontology.ontology.apiName;\n }\n\n getOntologyFullMetadata(): OntologiesV2.OntologyFullMetadata {\n return this.#ontology;\n }\n\n getFilteredOntologyMetadata(\n request: OntologiesV2.LoadOntologyMetadataRequest,\n ): OntologiesV2.OntologyFullMetadata {\n return {\n ontology: this.#ontology.ontology,\n objectTypes: Object.fromEntries(\n Object.entries(this.#ontology.objectTypes).filter(([objectType]) =>\n request.objectTypes.includes(objectType)\n ).map(([objectTypeApiName, objectTypeDefinition]) => [\n objectTypeApiName,\n {\n ...objectTypeDefinition,\n linkTypes: objectTypeDefinition.linkTypes.filter(linkType =>\n request.linkTypes.includes(linkType.apiName)\n ),\n },\n ]),\n ),\n actionTypes: filterRecord(\n this.#ontology.actionTypes,\n request.actionTypes,\n ),\n queryTypes: this.#getFilteredQueryTypes(request),\n\n interfaceTypes: filterRecord(\n this.#ontology.interfaceTypes,\n request.interfaceTypes,\n ),\n sharedPropertyTypes: {},\n };\n }\n\n getAllInterfaceTypes(): OntologiesV2.InterfaceType[] {\n return Object.values(this.#ontology.interfaceTypes);\n }\n\n getAllObjectTypes(): OntologiesV2.ObjectTypeFullMetadata[] {\n return Object.values(this.#ontology.objectTypes);\n }\n\n getAllActionTypes(): OntologiesV2.ActionTypeV2[] {\n return Object.values(this.#ontology.actionTypes);\n }\n\n getAllQueryTypes(): OntologiesV2.QueryTypeV2[] {\n return Object.values(this.#ontology.queryTypes);\n }\n\n getInterfaceType(interfaceType: string): OntologiesV2.InterfaceType {\n const ret = this.#ontology.interfaceTypes[interfaceType];\n\n if (ret === undefined) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(interfaceType, \"\"),\n );\n }\n\n return (\n this.#ontology.interfaceTypes[interfaceType]\n );\n }\n\n public getObjectTypeFullMetadata(\n objectTypeApiName: string,\n ): OntologiesV2.ObjectTypeFullMetadata | undefined {\n return this.#ontology.objectTypes[objectTypeApiName];\n }\n\n public getObjectTypeFullMetadataOrThrow(\n objectTypeApiName: string,\n ): OntologiesV2.ObjectTypeFullMetadata {\n const objectType = this.#ontology.objectTypes[objectTypeApiName];\n if (objectType === undefined) {\n throw new OpenApiCallError(\n 404,\n ObjectTypeDoesNotExistError(objectTypeApiName),\n );\n }\n return objectType;\n }\n\n public getActionDef(actionTypeApiName: string): OntologiesV2.ActionTypeV2 {\n const actionType = this.#ontology.actionTypes[actionTypeApiName];\n if (actionType === undefined) {\n throw new OpenApiCallError(\n 404,\n ActionNotFoundError(),\n );\n }\n return actionType;\n }\n\n public getActionImpl(actionTypeApiName: string): FauxActionImpl {\n const impl = this.#actionImpl.get(actionTypeApiName);\n invariant(impl, \"Action implementation not found for \" + actionTypeApiName);\n return impl;\n }\n\n public getQueryDef(\n queryTypeApiNameAndVersion: string,\n ): OntologiesV2.QueryTypeV2 {\n const queryType = this.#ontology\n .queryTypes[this.#convertToVersionedApiName(queryTypeApiNameAndVersion)];\n if (queryType === undefined) {\n throw new OpenApiCallError(\n 404,\n QueryNotFoundError(queryTypeApiNameAndVersion),\n );\n }\n return queryType;\n }\n\n public getQueryImpl(\n queryTypeApiName: string,\n version?: string,\n ): FauxQueryImpl {\n const versionMap = this.#queryImpl.get(queryTypeApiName);\n\n const impl = version !== undefined\n ? versionMap?.get(version)\n : versionMap?.get(semver.rsort(Array.from(versionMap.keys() ?? []))[0]);\n\n if (!impl) {\n throw new OpenApiCallError(\n 404,\n QueryNotFoundError(queryTypeApiName),\n );\n }\n invariant(impl, \"Query implementation not found for \" + queryTypeApiName);\n return impl;\n }\n\n public getInterfaceToObjectTypeMappings(\n objectApiNames: Iterable<OntologiesV2.ObjectTypeApiName>,\n ): Record<\n OntologiesV2.InterfaceTypeApiName,\n OntologiesV2.InterfaceToObjectTypeMappings\n > {\n const objectDefs = Array.from(objectApiNames).map(apiName =>\n this.getObjectTypeFullMetadataOrThrow(apiName)\n );\n\n const ifaceToObjMap: Record<\n OntologiesV2.InterfaceTypeApiName,\n OntologiesV2.InterfaceToObjectTypeMappings\n > = {};\n\n for (const objDef of objectDefs) {\n for (\n const [ifaceApiName, { properties }] of Object.entries(\n objDef.implementsInterfaces2,\n )\n ) {\n if (ifaceToObjMap[ifaceApiName] === undefined) {\n ifaceToObjMap[ifaceApiName] = {};\n }\n\n ifaceToObjMap[ifaceApiName][objDef.objectType.apiName] = properties;\n }\n }\n\n return ifaceToObjMap;\n }\n\n public getLinkTypeSideV2(\n objectTypeApiName: string,\n linkTypeName: string,\n ): OntologiesV2.LinkTypeSideV2 {\n const objectType = this.getObjectTypeFullMetadataOrThrow(objectTypeApiName);\n const linkType = objectType.linkTypes.find((a) =>\n a.apiName === linkTypeName\n );\n if (linkType === undefined) {\n throw new OpenApiCallError(\n 404,\n LinkTypeNotFound(objectTypeApiName, linkTypeName),\n );\n }\n return linkType;\n }\n\n public getOtherLinkTypeSideV2OrThrow(\n objectTypeApiName: string,\n linkTypeName: string,\n ): OntologiesV2.LinkTypeSideV2 {\n const thisSideLink = this.getLinkTypeSideV2(\n objectTypeApiName,\n linkTypeName,\n );\n const otherObj = this.getObjectTypeFullMetadataOrThrow(\n thisSideLink.objectTypeApiName,\n );\n const candidates = otherObj.linkTypes.filter(l =>\n l.linkTypeRid === thisSideLink.linkTypeRid\n );\n if (otherObj.objectType.apiName !== objectTypeApiName) {\n // if its not the same object type then there should only be one\n invariant(\n candidates.length === 1,\n \"Expected only one candidate link type\",\n );\n return candidates[0];\n }\n // if its the same object type, then this could be a link that points to itself that\n // is 1:1, many:1 or many:many. In the 1:1 case, the link could have the same name\n // and there would only be 1 entry in that case. Otherwise there should be 2 entries\n // and we want the one that doesn't match the one passed in.\n if (candidates.length === 1) {\n return candidates[0];\n }\n invariant(\n candidates.length === 2,\n \"Expected only two candidate link types\",\n );\n const candidate = candidates.find(l => l.apiName !== thisSideLink.apiName);\n invariant(\n candidate,\n \"Expected to find a candidate link type that is not the same as the one passed in\",\n );\n return candidate;\n }\n\n getBothLinkTypeSides(\n leftObjectType: string,\n leftLinkName: string,\n rightObjectType: string,\n ): [OntologiesV2.LinkTypeSideV2, OntologiesV2.LinkTypeSideV2] {\n const leftTypeSideV2 = this.getLinkTypeSideV2(\n leftObjectType,\n leftLinkName,\n );\n\n // the rhs passed in should match the target of the lhs\n invariant(rightObjectType === leftTypeSideV2.objectTypeApiName);\n\n const rightTypeSideV2 = this.getOtherLinkTypeSideV2OrThrow(\n leftObjectType,\n leftLinkName,\n );\n\n return [leftTypeSideV2, rightTypeSideV2];\n }\n\n registerObjectType<Q extends ObjectTypeDefinition>(\n def: TH_ObjectTypeFullMetadata<Q>,\n ): void;\n registerObjectType(\n def: ReadonlyDeep<OntologiesV2.ObjectTypeFullMetadata>,\n ): void;\n registerObjectType<Q extends ObjectTypeDefinition>(\n def:\n | TH_ObjectTypeFullMetadata<Q>\n | OntologiesV2.ObjectTypeFullMetadata,\n ): void {\n if (def.objectType.apiName in this.#ontology.objectTypes) {\n throw new Error(\n `ObjectType ${def.objectType.apiName} already registered`,\n );\n }\n this.#ontology.objectTypes[def.objectType.apiName] = def;\n }\n\n registerActionType<Q extends OntologiesV2.ActionTypeV2>(\n def: Q,\n implementation?: FauxActionImpl<Q>,\n ): void;\n registerActionType(\n def: OntologiesV2.ActionTypeV2,\n implementation?: FauxActionImpl,\n ): void;\n registerActionType(\n def: OntologiesV2.ActionTypeV2,\n implementation?: FauxActionImpl,\n ): void {\n if (def.apiName in this.#ontology.actionTypes) {\n throw new Error(\n `ActionType ${def.apiName} already registered`,\n );\n }\n this.#ontology.actionTypes[def.apiName] = def;\n if (implementation) {\n this.#actionImpl.set(def.apiName, implementation);\n }\n }\n\n registerQueryType(\n def: OntologiesV2.QueryTypeV2,\n implementation?: FauxQueryImpl,\n ): void {\n if (`${def.apiName}:${def.version}` in this.#ontology.queryTypes) {\n throw new Error(\n `QueryType ${def.apiName} already registered`,\n );\n }\n this.#ontology\n .queryTypes[\n `${def.apiName}:${def.version}` as VersionedQueryTypeApiName\n ] = def;\n if (implementation) {\n if (!this.#queryImpl.has(def.apiName)) {\n this.#queryImpl.set(def.apiName, new Map());\n }\n if (!valid(def.version)) {\n throw new Error(\n `QueryType ${def.apiName} version ${def.version} is not semver valid`,\n );\n }\n this.#queryImpl.get(def.apiName)?.set(\n def.version,\n implementation,\n );\n }\n }\n\n registerInterfaceType(def: OntologiesV2.InterfaceType): void {\n if (def.apiName in this.#ontology.interfaceTypes) {\n throw new Error(\n `InterfaceType ${def.apiName} already registered`,\n );\n }\n this.#ontology.interfaceTypes[def.apiName] = def;\n }\n\n registerSharedPropertyType(def: OntologiesV2.SharedPropertyType): void {\n if (def.apiName in this.#ontology.sharedPropertyTypes) {\n throw new Error(\n `SharedPropertyType ${def.apiName} already registered`,\n );\n }\n this.#ontology.sharedPropertyTypes[def.apiName] = def;\n }\n\n #getFilteredQueryTypes(request: LoadOntologyMetadataRequest): Record<\n OntologiesV2.QueryApiName,\n OntologiesV2.QueryTypeV2\n > {\n const remappedQueryTypes = request.queryTypes.map(x =>\n this.#convertToVersionedApiName(x)\n );\n return Object.fromEntries(\n Object.entries(this.#ontology.queryTypes).filter((\n [queryTypeApiName],\n ) => remappedQueryTypes.includes(queryTypeApiName)).map((\n [queryTypeApiName, queryTypeDefinition],\n ) => [\n request.queryTypes[remappedQueryTypes.indexOf(queryTypeApiName)],\n queryTypeDefinition,\n ]),\n );\n }\n\n #convertToVersionedApiName(\n apiName: string,\n ): VersionedQueryTypeApiName {\n // If a query is requested without a version, we remap it to include a versioned api name with the latest version\n if (extractVersion(apiName) !== undefined) {\n return apiName as VersionedQueryTypeApiName;\n }\n const version = semver.rsort(\n Object.keys(this.#ontology.queryTypes).filter(\n queryTypeApiName => queryTypeApiName.split(\":\")[0] === apiName,\n ).map(x => extractVersion(x)),\n )[0];\n return `${apiName}:${version}`;\n }\n}\n\nfunction filterRecord<T>(\n record: Record<string, T>,\n keys: string[],\n): Record<string, T> {\n return Object.fromEntries(\n Object.entries(record).filter(([key]) => keys.includes(key)),\n );\n}\n\nfunction extractVersion(\n apiName: string,\n): string {\n return apiName.split(\":\")[1];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,MAAM,IAAIC,KAAK,QAAQ,QAAQ;AACtC,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SACEC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,kBAAkB,QACb,cAAc;AACrB,SAASC,gBAAgB,QAAQ,uCAAuC;AAKxE;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,CAAC;EACxB,CAACC,QAAQ;EACT,CAACC,UAAU,GAAwD,IAAIC,GAAG,CAAC,CAAC;EAC5E,CAACC,SAAS,GAGN,IAAID,GAAG,CAAC,CAAC;EAEbE,WAAWA,CAACJ,QAAiC,EAAE;IAC7C,IAAI,CAAC,CAACA,QAAQ,GAAG;MACfK,WAAW,EAAE,CAAC,CAAC;MACfC,cAAc,EAAE,CAAC,CAAC;MAClBC,WAAW,EAAE,CAAC,CAAC;MACfP,QAAQ;MACRQ,UAAU,EAAE,CAAC,CAAC;MACdC,mBAAmB,EAAE,CAAC;IACxB,CAAC;EACH;EAEA,IAAIC,OAAOA,CAAA,EAAiC;IAC1C,OAAO,IAAI,CAAC,CAACV,QAAQ,CAACA,QAAQ,CAACU,OAAO;EACxC;EAEAC,uBAAuBA,CAAA,EAAsC;IAC3D,OAAO,IAAI,CAAC,CAACX,QAAQ;EACvB;EAEAY,2BAA2BA,CACzBC,OAAiD,EACd;IACnC,O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CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC9B","ignoreList":[]}
1
+ {"version":3,"file":"FauxOntology.js","names":["semver","valid","invariant","ActionNotFoundError","LinkTypeNotFound","ObjectNotFoundError","ObjectTypeDoesNotExistError","QueryNotFoundError","OpenApiCallError","FauxOntology","ontology","actionImpl","Map","queryImpl","constructor","actionTypes","interfaceTypes","objectTypes","queryTypes","sharedPropertyTypes","valueTypes","apiName","getOntologyFullMetadata","getFilteredOntologyMetadata","request","Object","fromEntries","entries","filter","objectType","includes","map","objectTypeApiName","objectTypeDefinition","linkTypes","linkType","filterRecord","getFilteredQueryTypes","getAllInterfaceTypes","values","getAllObjectTypes","getAllActionTypes","getAllQueryTypes","getInterfaceType","interfaceType","ret","undefined","getObjectTypeFullMetadata","getObjectTypeFullMetadataOrThrow","getActionDef","actionTypeApiName","actionType","getActionImpl","impl","get","process","env","NODE_ENV","getQueryDef","queryTypeApiNameAndVersion","queryType","convertToVersionedApiName","getQueryImpl","queryTypeApiName","version","versionMap","rsort","Array","from","keys","getInterfaceToObjectTypeMappings","objectApiNames","objectDefs","ifaceToObjMap","objDef","ifaceApiName","properties","implementsInterfaces2","getLinkTypeSideV2","linkTypeName","find","a","getOtherLinkTypeSideV2OrThrow","thisSideLink","otherObj","candidates","l","linkTypeRid","length","candidate","getBothLinkTypeSides","leftObjectType","leftLinkName","rightObjectType","leftTypeSideV2","rightTypeSideV2","registerObjectType","def","Error","registerActionType","implementation","set","registerQueryType","has","registerInterfaceType","registerSharedPropertyType","#getFilteredQueryTypes","remappedQueryTypes","x","queryTypeDefinition","indexOf","#convertToVersionedApiName","extractVersion","split","record","key"],"sources":["FauxOntology.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 ObjectTypeDefinition } from \"@osdk/api\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type {\n LoadOntologyMetadataRequest,\n VersionedQueryTypeApiName,\n} from \"@osdk/internal.foundry.ontologies\";\nimport semver, { valid } from \"semver\";\nimport invariant from \"tiny-invariant\";\nimport type { ReadonlyDeep } from \"type-fest\";\nimport {\n ActionNotFoundError,\n LinkTypeNotFound,\n ObjectNotFoundError,\n ObjectTypeDoesNotExistError,\n QueryNotFoundError,\n} from \"../errors.js\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { FauxActionImpl } from \"./FauxActionImpl.js\";\nimport type { FauxQueryImpl } from \"./FauxQueryImpl.js\";\nimport type { TH_ObjectTypeFullMetadata } from \"./typeHelpers/TH_ObjectTypeFullMetadata.js\";\n\n/**\n * Currently Unsupported Concepts:\n * - many:many links.\n */\nexport class FauxOntology {\n #ontology: OntologiesV2.OntologyFullMetadata;\n #actionImpl: Map<OntologiesV2.ActionTypeApiName, FauxActionImpl> = new Map();\n #queryImpl: Map<\n OntologiesV2.QueryApiName,\n Map<OntologiesV2.FunctionVersion, FauxQueryImpl>\n > = new Map();\n\n constructor(ontology: OntologiesV2.OntologyV2) {\n this.#ontology = {\n actionTypes: {},\n interfaceTypes: {},\n objectTypes: {},\n ontology,\n queryTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n };\n }\n\n get apiName(): OntologiesV2.OntologyApiName {\n return this.#ontology.ontology.apiName;\n }\n\n getOntologyFullMetadata(): OntologiesV2.OntologyFullMetadata {\n return this.#ontology;\n }\n\n getFilteredOntologyMetadata(\n request: OntologiesV2.LoadOntologyMetadataRequest,\n ): OntologiesV2.OntologyFullMetadata {\n return {\n ontology: this.#ontology.ontology,\n objectTypes: Object.fromEntries(\n Object.entries(this.#ontology.objectTypes).filter(([objectType]) =>\n request.objectTypes.includes(objectType)\n ).map(([objectTypeApiName, objectTypeDefinition]) => [\n objectTypeApiName,\n {\n ...objectTypeDefinition,\n linkTypes: objectTypeDefinition.linkTypes.filter(linkType =>\n request.linkTypes.includes(linkType.apiName)\n ),\n },\n ]),\n ),\n actionTypes: filterRecord(\n this.#ontology.actionTypes,\n request.actionTypes,\n ),\n queryTypes: this.#getFilteredQueryTypes(request),\n\n interfaceTypes: filterRecord(\n this.#ontology.interfaceTypes,\n request.interfaceTypes,\n ),\n sharedPropertyTypes: {},\n valueTypes: {},\n };\n }\n\n getAllInterfaceTypes(): OntologiesV2.InterfaceType[] {\n return Object.values(this.#ontology.interfaceTypes);\n }\n\n getAllObjectTypes(): OntologiesV2.ObjectTypeFullMetadata[] {\n return Object.values(this.#ontology.objectTypes);\n }\n\n getAllActionTypes(): OntologiesV2.ActionTypeV2[] {\n return Object.values(this.#ontology.actionTypes);\n }\n\n getAllQueryTypes(): OntologiesV2.QueryTypeV2[] {\n return Object.values(this.#ontology.queryTypes);\n }\n\n getInterfaceType(interfaceType: string): OntologiesV2.InterfaceType {\n const ret = this.#ontology.interfaceTypes[interfaceType];\n\n if (ret === undefined) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(interfaceType, \"\"),\n );\n }\n\n return (\n this.#ontology.interfaceTypes[interfaceType]\n );\n }\n\n public getObjectTypeFullMetadata(\n objectTypeApiName: string,\n ): OntologiesV2.ObjectTypeFullMetadata | undefined {\n return this.#ontology.objectTypes[objectTypeApiName];\n }\n\n public getObjectTypeFullMetadataOrThrow(\n objectTypeApiName: string,\n ): OntologiesV2.ObjectTypeFullMetadata {\n const objectType = this.#ontology.objectTypes[objectTypeApiName];\n if (objectType === undefined) {\n throw new OpenApiCallError(\n 404,\n ObjectTypeDoesNotExistError(objectTypeApiName),\n );\n }\n return objectType;\n }\n\n public getActionDef(actionTypeApiName: string): OntologiesV2.ActionTypeV2 {\n const actionType = this.#ontology.actionTypes[actionTypeApiName];\n if (actionType === undefined) {\n throw new OpenApiCallError(\n 404,\n ActionNotFoundError(),\n );\n }\n return actionType;\n }\n\n public getActionImpl(actionTypeApiName: string): FauxActionImpl {\n const impl = this.#actionImpl.get(actionTypeApiName);\n invariant(impl, \"Action implementation not found for \" + actionTypeApiName);\n return impl;\n }\n\n public getQueryDef(\n queryTypeApiNameAndVersion: string,\n ): OntologiesV2.QueryTypeV2 {\n const queryType = this.#ontology\n .queryTypes[this.#convertToVersionedApiName(queryTypeApiNameAndVersion)];\n if (queryType === undefined) {\n throw new OpenApiCallError(\n 404,\n QueryNotFoundError(queryTypeApiNameAndVersion),\n );\n }\n return queryType;\n }\n\n public getQueryImpl(\n queryTypeApiName: string,\n version?: string,\n ): FauxQueryImpl {\n const versionMap = this.#queryImpl.get(queryTypeApiName);\n\n const impl = version !== undefined\n ? versionMap?.get(version)\n : versionMap?.get(semver.rsort(Array.from(versionMap.keys() ?? []))[0]);\n\n if (!impl) {\n throw new OpenApiCallError(\n 404,\n QueryNotFoundError(queryTypeApiName),\n );\n }\n invariant(impl, \"Query implementation not found for \" + queryTypeApiName);\n return impl;\n }\n\n public getInterfaceToObjectTypeMappings(\n objectApiNames: Iterable<OntologiesV2.ObjectTypeApiName>,\n ): Record<\n OntologiesV2.InterfaceTypeApiName,\n OntologiesV2.InterfaceToObjectTypeMappings\n > {\n const objectDefs = Array.from(objectApiNames).map(apiName =>\n this.getObjectTypeFullMetadataOrThrow(apiName)\n );\n\n const ifaceToObjMap: Record<\n OntologiesV2.InterfaceTypeApiName,\n OntologiesV2.InterfaceToObjectTypeMappings\n > = {};\n\n for (const objDef of objectDefs) {\n for (\n const [ifaceApiName, { properties }] of Object.entries(\n objDef.implementsInterfaces2,\n )\n ) {\n if (ifaceToObjMap[ifaceApiName] === undefined) {\n ifaceToObjMap[ifaceApiName] = {};\n }\n\n ifaceToObjMap[ifaceApiName][objDef.objectType.apiName] = properties;\n }\n }\n\n return ifaceToObjMap;\n }\n\n public getLinkTypeSideV2(\n objectTypeApiName: string,\n linkTypeName: string,\n ): OntologiesV2.LinkTypeSideV2 {\n const objectType = this.getObjectTypeFullMetadataOrThrow(objectTypeApiName);\n const linkType = objectType.linkTypes.find((a) =>\n a.apiName === linkTypeName\n );\n if (linkType === undefined) {\n throw new OpenApiCallError(\n 404,\n LinkTypeNotFound(objectTypeApiName, linkTypeName),\n );\n }\n return linkType;\n }\n\n public getOtherLinkTypeSideV2OrThrow(\n objectTypeApiName: string,\n linkTypeName: string,\n ): OntologiesV2.LinkTypeSideV2 {\n const thisSideLink = this.getLinkTypeSideV2(\n objectTypeApiName,\n linkTypeName,\n );\n const otherObj = this.getObjectTypeFullMetadataOrThrow(\n thisSideLink.objectTypeApiName,\n );\n const candidates = otherObj.linkTypes.filter(l =>\n l.linkTypeRid === thisSideLink.linkTypeRid\n );\n if (otherObj.objectType.apiName !== objectTypeApiName) {\n // if its not the same object type then there should only be one\n invariant(\n candidates.length === 1,\n \"Expected only one candidate link type\",\n );\n return candidates[0];\n }\n // if its the same object type, then this could be a link that points to itself that\n // is 1:1, many:1 or many:many. In the 1:1 case, the link could have the same name\n // and there would only be 1 entry in that case. Otherwise there should be 2 entries\n // and we want the one that doesn't match the one passed in.\n if (candidates.length === 1) {\n return candidates[0];\n }\n invariant(\n candidates.length === 2,\n \"Expected only two candidate link types\",\n );\n const candidate = candidates.find(l => l.apiName !== thisSideLink.apiName);\n invariant(\n candidate,\n \"Expected to find a candidate link type that is not the same as the one passed in\",\n );\n return candidate;\n }\n\n getBothLinkTypeSides(\n leftObjectType: string,\n leftLinkName: string,\n rightObjectType: string,\n ): [OntologiesV2.LinkTypeSideV2, OntologiesV2.LinkTypeSideV2] {\n const leftTypeSideV2 = this.getLinkTypeSideV2(\n leftObjectType,\n leftLinkName,\n );\n\n // the rhs passed in should match the target of the lhs\n invariant(rightObjectType === leftTypeSideV2.objectTypeApiName);\n\n const rightTypeSideV2 = this.getOtherLinkTypeSideV2OrThrow(\n leftObjectType,\n leftLinkName,\n );\n\n return [leftTypeSideV2, rightTypeSideV2];\n }\n\n registerObjectType<Q extends ObjectTypeDefinition>(\n def: TH_ObjectTypeFullMetadata<Q>,\n ): void;\n registerObjectType(\n def: ReadonlyDeep<OntologiesV2.ObjectTypeFullMetadata>,\n ): void;\n registerObjectType<Q extends ObjectTypeDefinition>(\n def:\n | TH_ObjectTypeFullMetadata<Q>\n | OntologiesV2.ObjectTypeFullMetadata,\n ): void {\n if (def.objectType.apiName in this.#ontology.objectTypes) {\n throw new Error(\n `ObjectType ${def.objectType.apiName} already registered`,\n );\n }\n this.#ontology.objectTypes[def.objectType.apiName] = def;\n }\n\n registerActionType<Q extends OntologiesV2.ActionTypeV2>(\n def: Q,\n implementation?: FauxActionImpl<Q>,\n ): void;\n registerActionType(\n def: OntologiesV2.ActionTypeV2,\n implementation?: FauxActionImpl,\n ): void;\n registerActionType(\n def: OntologiesV2.ActionTypeV2,\n implementation?: FauxActionImpl,\n ): void {\n if (def.apiName in this.#ontology.actionTypes) {\n throw new Error(\n `ActionType ${def.apiName} already registered`,\n );\n }\n this.#ontology.actionTypes[def.apiName] = def;\n if (implementation) {\n this.#actionImpl.set(def.apiName, implementation);\n }\n }\n\n registerQueryType(\n def: OntologiesV2.QueryTypeV2,\n implementation?: FauxQueryImpl,\n ): void {\n if (`${def.apiName}:${def.version}` in this.#ontology.queryTypes) {\n throw new Error(\n `QueryType ${def.apiName} already registered`,\n );\n }\n this.#ontology\n .queryTypes[\n `${def.apiName}:${def.version}` as VersionedQueryTypeApiName\n ] = def;\n if (implementation) {\n if (!this.#queryImpl.has(def.apiName)) {\n this.#queryImpl.set(def.apiName, new Map());\n }\n if (!valid(def.version)) {\n throw new Error(\n `QueryType ${def.apiName} version ${def.version} is not semver valid`,\n );\n }\n this.#queryImpl.get(def.apiName)?.set(\n def.version,\n implementation,\n );\n }\n }\n\n registerInterfaceType(def: OntologiesV2.InterfaceType): void {\n if (def.apiName in this.#ontology.interfaceTypes) {\n throw new Error(\n `InterfaceType ${def.apiName} already registered`,\n );\n }\n this.#ontology.interfaceTypes[def.apiName] = def;\n }\n\n registerSharedPropertyType(def: OntologiesV2.SharedPropertyType): void {\n if (def.apiName in this.#ontology.sharedPropertyTypes) {\n throw new Error(\n `SharedPropertyType ${def.apiName} already registered`,\n );\n }\n this.#ontology.sharedPropertyTypes[def.apiName] = def;\n }\n\n #getFilteredQueryTypes(request: LoadOntologyMetadataRequest): Record<\n OntologiesV2.QueryApiName,\n OntologiesV2.QueryTypeV2\n > {\n const remappedQueryTypes = request.queryTypes.map(x =>\n this.#convertToVersionedApiName(x)\n );\n return Object.fromEntries(\n Object.entries(this.#ontology.queryTypes).filter((\n [queryTypeApiName],\n ) => remappedQueryTypes.includes(queryTypeApiName)).map((\n [queryTypeApiName, queryTypeDefinition],\n ) => [\n request.queryTypes[remappedQueryTypes.indexOf(queryTypeApiName)],\n queryTypeDefinition,\n ]),\n );\n }\n\n #convertToVersionedApiName(\n apiName: string,\n ): VersionedQueryTypeApiName {\n // If a query is requested without a version, we remap it to include a versioned api name with the latest version\n if (extractVersion(apiName) !== undefined) {\n return apiName as VersionedQueryTypeApiName;\n }\n const version = semver.rsort(\n Object.keys(this.#ontology.queryTypes).filter(\n queryTypeApiName => queryTypeApiName.split(\":\")[0] === apiName,\n ).map(x => extractVersion(x)),\n )[0];\n return `${apiName}:${version}`;\n }\n}\n\nfunction filterRecord<T>(\n record: Record<string, T>,\n keys: string[],\n): Record<string, T> {\n return Object.fromEntries(\n Object.entries(record).filter(([key]) => keys.includes(key)),\n );\n}\n\nfunction extractVersion(\n apiName: string,\n): string {\n return apiName.split(\":\")[1];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,MAAM,IAAIC,KAAK,QAAQ,QAAQ;AACtC,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SACEC,mBA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ACxB1F,OAAe,EACY;IAC3B;IACA,IAAI2F,cAAc,CAAC3F,OAAO,CAAC,KAAKyB,SAAS,EAAE;MACzC,OAAOzB,OAAO;IAChB;IACA,MAAM2C,OAAO,GAAGhE,MAAM,CAACkE,KAAK,CAC1BzC,MAAM,CAAC4C,IAAI,CAAC,IAAI,CAAC,CAAC3D,QAAQ,CAACQ,UAAU,CAAC,CAACU,MAAM,CAC3CmC,gBAAgB,IAAIA,gBAAgB,CAACkD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK5F,OACzD,CAAC,CAACU,GAAG,CAAC6E,CAAC,IAAII,cAAc,CAACJ,CAAC,CAAC,CAC9B,CAAC,CAAC,CAAC,CAAC;IACJ,OAAO,GAAGvF,OAAO,IAAI2C,OAAO,EAAE;EAChC;AACF;AAEA,SAAS5B,YAAYA,CACnB8E,MAAyB,EACzB7C,IAAc,EACK;EACnB,OAAO5C,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACuF,MAAM,CAAC,CAACtF,MAAM,CAAC,CAAC,CAACuF,GAAG,CAAC,KAAK9C,IAAI,CAACvC,QAAQ,CAACqF,GAAG,CAAC,CAC7D,CAAC;AACH;AAEA,SAASH,cAAcA,CACrB3F,OAAe,EACP;EACR,OAAOA,OAAO,CAAC4F,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC9B","ignoreList":[]}
@@ -29,7 +29,7 @@ OntologiesV2.Queries.execute(baseUrl, async ({
29
29
  }) => {
30
30
  const queryParams = Object.fromEntries(new URL(request.url).searchParams.entries());
31
31
  const version = queryParams["version"];
32
- if (!valid(version)) {
32
+ if (version != null && !valid(version)) {
33
33
  throw new Error(`Invalid version "${version}" for query "${queryApiName}" in ontology "${ontologyApiName}: not semver compatible".`);
34
34
  }
35
35
  const queryImpl = fauxFoundry.getOntology(ontologyApiName).getQueryImpl(queryApiName, version);
@@ -1 +1 @@
1
- {"version":3,"file":"createQueryHandlers.js","names":["valid","OntologiesV2","createQueryHandlers","baseUrl","fauxFoundry","Queries","execute","request","params","ontologyApiName","queryApiName","queryParams","Object","fromEntries","URL","url","searchParams","entries","version","Error","queryImpl","getOntology","getQueryImpl","json","getDataStore"],"sources":["createQueryHandlers.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 { valid } from \"semver\";\nimport { OntologiesV2 } from \"../mock/index.js\";\nimport type { FauxFoundryHandlersFactory } from \"./createFauxFoundryHandlers.js\";\n\nexport const createQueryHandlers: FauxFoundryHandlersFactory = (\n baseUrl,\n fauxFoundry,\n) => [\n /**\n * Execute Queries\n */\n OntologiesV2.Queries.execute(\n baseUrl,\n async ({ request, params: { ontologyApiName, queryApiName } }) => {\n const queryParams = Object.fromEntries(\n new URL(request.url).searchParams.entries(),\n );\n\n const version = queryParams[\"version\"];\n if (!valid(version)) {\n throw new Error(\n `Invalid version \"${version}\" for query \"${queryApiName}\" in ontology \"${ontologyApiName}: not semver compatible\".`,\n );\n }\n\n const queryImpl = fauxFoundry\n .getOntology(ontologyApiName)\n .getQueryImpl(queryApiName, version);\n\n return queryImpl(\n await request.json(),\n fauxFoundry.getDataStore(ontologyApiName),\n );\n },\n ),\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,QAAQ;AAC9B,SAASC,YAAY,QAAQ,kBAAkB;AAG/C,OAAO,MAAMC,mBAA+C,GAAGA,CAC7DC,OAAO,EACPC,WAAW,KACR;AACH;AACF;AACA;AACEH,YAAY,CAACI,OAAO,CAACC,OAAO,CAC1BH,OAAO,EACP,OAAO;EAAEI,OAAO;EAAEC,MAAM,EAAE;IAAEC,eAAe;IAAEC;EAAa;AAAE,CAAC,KAAK;EAChE,MAAMC,WAAW,GAAGC,MAAM,CAACC,WAAW,CACpC,IAAIC,GAAG,CAACP,OAAO,CAACQ,GAAG,CAAC,CAACC,YAAY,CAACC,OAAO,CAAC,CAC5C,CAAC;EAED,MAAMC,OAAO,GAAGP,WAAW,CAAC,SAAS,CAAC;EACtC,IAAI,CAACX,KAAK,CAACkB,OAAO,CAAC,EAAE;IACnB,MAAM,IAAIC,KAAK,CACb,oBAAoBD,OAAO,gBAAgBR,YAAY,kBAAkBD,eAAe,2BAC1F,CAAC;EACH;EAEA,MAAMW,SAAS,GAAGhB,WAAW,CAC1BiB,WAAW,CAACZ,eAAe,CAAC,CAC5Ba,YAAY,CAACZ,YAAY,EAAEQ,OAAO,CAAC;EAEtC,OAAOE,SAAS,CACd,MAAMb,OAAO,CAACgB,IAAI,CAAC,CAAC,EACpBnB,WAAW,CAACoB,YAAY,CAACf,eAAe,CAC1C,CAAC;AACH,CACF,CAAC,CACF","ignoreList":[]}
1
+ {"version":3,"file":"createQueryHandlers.js","names":["valid","OntologiesV2","createQueryHandlers","baseUrl","fauxFoundry","Queries","execute","request","params","ontologyApiName","queryApiName","queryParams","Object","fromEntries","URL","url","searchParams","entries","version","Error","queryImpl","getOntology","getQueryImpl","json","getDataStore"],"sources":["createQueryHandlers.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 { valid } from \"semver\";\nimport { OntologiesV2 } from \"../mock/index.js\";\nimport type { FauxFoundryHandlersFactory } from \"./createFauxFoundryHandlers.js\";\n\nexport const createQueryHandlers: FauxFoundryHandlersFactory = (\n baseUrl,\n fauxFoundry,\n) => [\n /**\n * Execute Queries\n */\n OntologiesV2.Queries.execute(\n baseUrl,\n async ({ request, params: { ontologyApiName, queryApiName } }) => {\n const queryParams = Object.fromEntries(\n new URL(request.url).searchParams.entries(),\n );\n\n const version = queryParams[\"version\"];\n if (version != null && !valid(version)) {\n throw new Error(\n `Invalid version \"${version}\" for query \"${queryApiName}\" in ontology \"${ontologyApiName}: not semver compatible\".`,\n );\n }\n\n const queryImpl = fauxFoundry\n .getOntology(ontologyApiName)\n .getQueryImpl(queryApiName, version);\n\n return queryImpl(\n await request.json(),\n fauxFoundry.getDataStore(ontologyApiName),\n );\n },\n ),\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,QAAQ;AAC9B,SAASC,YAAY,QAAQ,kBAAkB;AAG/C,OAAO,MAAMC,mBAA+C,GAAGA,CAC7DC,OAAO,EACPC,WAAW,KACR;AACH;AACF;AACA;AACEH,YAAY,CAACI,OAAO,CAACC,OAAO,CAC1BH,OAAO,EACP,OAAO;EAAEI,OAAO;EAAEC,MAAM,EAAE;IAAEC,eAAe;IAAEC;EAAa;AAAE,CAAC,KAAK;EAChE,MAAMC,WAAW,GAAGC,MAAM,CAACC,WAAW,CACpC,IAAIC,GAAG,CAACP,OAAO,CAACQ,GAAG,CAAC,CAACC,YAAY,CAACC,OAAO,CAAC,CAC5C,CAAC;EAED,MAAMC,OAAO,GAAGP,WAAW,CAAC,SAAS,CAAC;EACtC,IAAIO,OAAO,IAAI,IAAI,IAAI,CAAClB,KAAK,CAACkB,OAAO,CAAC,EAAE;IACtC,MA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B,UAAU,sBAC3BC,KAAK,0BAA0B;CAEjC,mBACEC,KAAK,aAAa,aAAa;CAejC,mBAAmB,UAAU,aAAa,cACxCC,KAAK,GACLC,iBAAiB,eAAe;CAElC,mBACEC,KAAK,aAAa,cAClBC,iBAAiB;CAiBnB,kBACEC,KAAK,aAAa,aAClBC,iBAAiB;CA2BnB,sBAAsBC,KAAK,aAAa;CASxC,2BAA2BC,KAAK,aAAa;AA0C9C","names":["ontology: OntologiesV2.OntologyV2","request: OntologiesV2.LoadOntologyMetadataRequest","interfaceType: string","objectTypeApiName: string","actionTypeApiName: string","queryTypeApiNameAndVersion: string","queryTypeApiName: string","version?: string","objectApiNames: Iterable<OntologiesV2.ObjectTypeApiName>","linkTypeName: string","leftObjectType: string","leftLinkName: string","rightObjectType: string","def: TH_ObjectTypeFullMetadata<Q>","def: ReadonlyDeep<OntologiesV2.ObjectTypeFullMetadata>","def: Q","implementation?: FauxActionImpl<Q>","def: OntologiesV2.ActionTypeV2","implementation?: FauxActionImpl","def: OntologiesV2.QueryTypeV2","implementation?: FauxQueryImpl","def: OntologiesV2.InterfaceType","def: OntologiesV2.SharedPropertyType"],"sources":["../../../src/FauxFoundry/FauxOntology.ts"],"version":3,"file":"FauxOntology.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,4BAA4B,WAAY;AACtD,iBAAiB,kBAAkB,0BAA2B;AAO9D,cAAc,oBAAoB,WAAY;AAS9C,cAAc,sBAAsB,qBAAsB;AAC1D,cAAc,qBAAqB,oBAAqB;AACxD,cAAc,iCAAiC,4CAA6C;;;;;AAM5F,OAAO,cAAM,aAAa;;CAQxB,YAAYA,UAAU,aAAa;CAYnC,IAAI,WAAW,aAAa;CAI5B,2BAA2B,aAAa;CAIxC,4BACEC,SAAS,aAAa,8BACrB,aAAa;CA+BhB,wBAAwB,aAAa;CAIrC,qBAAqB,aAAa;CAIlC,qBAAqB,aAAa;CAIlC,oBAAoB,aAAa;CAIjC,iBAAiBC,wBAAwB,aAAa;CAetD,AAAO,0BACLC,4BACC,aAAa;CAIhB,AAAO,iCACLA,4BACC,aAAa;CAWhB,AAAO,aAAaC,4BAA4B,aAAa;CAW7D,AAAO,cAAcA,4BAA4B;CAMjD,AAAO,YACLC,qCACC,aAAa;CAYhB,AAAO,aACLC,0BACAC,mBACC;CAiBH,AAAO,iCACLC,gBAAgB,SAAS,aAAa,qBACrC,OACD,aAAa,sBACb,aAAa;CA4Bf,AAAO,kBACLL,2BACAM,uBACC,aAAa;CAchB,AAAO,8BACLN,2BACAM,uBACC,aAAa;CAsChB,qBACEC,wBACAC,sBACAC,2BACE,aAAa,gBAAgB,aAAa;CAiB9C,mBAAmB,UAAU,sBAC3BC,KAAK,0BAA0B;CAEjC,mBACEC,KAAK,aAAa,aAAa;CAejC,mBAAmB,UAAU,aAAa,cACxCC,KAAK,GACLC,iBAAiB,eAAe;CAElC,mBACEC,KAAK,aAAa,cAClBC,iBAAiB;CAiBnB,kBACEC,KAAK,aAAa,aAClBC,iBAAiB;CA2BnB,sBAAsBC,KAAK,aAAa;CASxC,2BAA2BC,KAAK,aAAa;AA0C9C","names":["ontology: OntologiesV2.OntologyV2","request: OntologiesV2.LoadOntologyMetadataRequest","interfaceType: string","objectTypeApiName: string","actionTypeApiName: string","queryTypeApiNameAndVersion: string","queryTypeApiName: string","version?: string","objectApiNames: Iterable<OntologiesV2.ObjectTypeApiName>","linkTypeName: string","leftObjectType: string","leftLinkName: string","rightObjectType: string","def: TH_ObjectTypeFullMetadata<Q>","def: ReadonlyDeep<OntologiesV2.ObjectTypeFullMetadata>","def: Q","implementation?: FauxActionImpl<Q>","def: OntologiesV2.ActionTypeV2","implementation?: FauxActionImpl","def: OntologiesV2.QueryTypeV2","implementation?: FauxQueryImpl","def: OntologiesV2.InterfaceType","def: OntologiesV2.SharedPropertyType"],"sources":["../../../src/FauxFoundry/FauxOntology.ts"],"version":3,"file":"FauxOntology.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/faux",
3
- "version": "0.2.0-rc.19",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "access": "private",
6
6
  "license": "Apache-2.0",
@@ -29,10 +29,10 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@osdk/foundry.core": "2.25.0",
33
- "@osdk/foundry.geo": "2.25.0",
34
- "@osdk/foundry.ontologies": "2.25.0",
35
- "@osdk/internal.foundry.ontologies": "2.25.0",
32
+ "@osdk/foundry.core": "2.28.0",
33
+ "@osdk/foundry.geo": "2.28.0",
34
+ "@osdk/foundry.ontologies": "2.28.0",
35
+ "@osdk/internal.foundry.ontologies": "2.28.0",
36
36
  "date-fns": "^4.1.0",
37
37
  "fast-deep-equal": "^3.1.3",
38
38
  "fetch-retry": "^6.0.0",
@@ -42,8 +42,8 @@
42
42
  "semver": "^7.5.1",
43
43
  "tiny-invariant": "^1.3.3",
44
44
  "type-fest": "^4.37.0",
45
- "@osdk/api": "~2.4.0-rc.19",
46
- "@osdk/generator-converters": "~2.4.0-rc.19"
45
+ "@osdk/api": "~2.4.1",
46
+ "@osdk/generator-converters": "~2.4.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/json-stable-stringify": "^1.0.36",
@@ -51,8 +51,8 @@
51
51
  "@types/semver": "^7.3.12",
52
52
  "ts-expect": "^1.3.0",
53
53
  "typescript": "~5.5.4",
54
- "@osdk/monorepo.api-extractor": "~0.3.0-beta.1",
55
- "@osdk/monorepo.tsconfig": "~0.3.0-beta.1"
54
+ "@osdk/monorepo.tsconfig": "~0.3.0",
55
+ "@osdk/monorepo.api-extractor": "~0.3.0"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"