@osdk/maker 0.15.0 → 0.16.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -126
- package/README.md +18 -1
- package/build/browser/api/cloneDefinition.js +36 -0
- package/build/browser/api/cloneDefinition.js.map +1 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/browser/api/defineAction.js +9 -1
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateObjectAction.js +3 -1
- package/build/browser/api/defineCreateObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteObjectAction.js +3 -1
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -1
- package/build/browser/api/defineFunction.js +61 -0
- package/build/browser/api/defineFunction.js.map +1 -0
- package/build/browser/api/defineInterface.js +3 -1
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -1
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineModifyObjectAction.js +3 -1
- package/build/browser/api/defineModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +29 -10
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +29 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +3 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +3 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/object/ObjectPropertyType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/ReducerType.js +2 -0
- package/build/browser/api/properties/ReducerType.js.map +1 -0
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +17 -6
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/browser/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/browser/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/browser/index.js +5 -2
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +267 -105
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +214 -164
- package/build/esm/api/cloneDefinition.js +36 -0
- package/build/esm/api/cloneDefinition.js.map +1 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/esm/api/defineAction.js +9 -1
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateObjectAction.js +3 -1
- package/build/esm/api/defineCreateObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteObjectAction.js +3 -1
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -1
- package/build/esm/api/defineFunction.js +61 -0
- package/build/esm/api/defineFunction.js.map +1 -0
- package/build/esm/api/defineInterface.js +3 -1
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -1
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineModifyObjectAction.js +3 -1
- package/build/esm/api/defineModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +29 -10
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +29 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +3 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +3 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/object/ObjectPropertyType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/ReducerType.js +2 -0
- package/build/esm/api/properties/ReducerType.js.map +1 -0
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +17 -6
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/esm/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/esm/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/types/api/cloneDefinition.d.ts +9 -0
- package/build/types/api/cloneDefinition.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -1
- package/build/types/api/defineFunction.d.ts +19 -0
- package/build/types/api/defineFunction.d.ts.map +1 -0
- package/build/types/api/defineInterface.d.ts +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +5 -0
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +3 -1
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/defineValueType.d.ts +1 -1
- package/build/types/api/defineValueType.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +1 -1
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/object/ObjectPropertyType.d.ts +2 -0
- package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +10 -3
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +4 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/ReducerType.d.ts +4 -0
- package/build/types/api/properties/ReducerType.d.ts.map +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts +2 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertDatasourceDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertReducers.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertReducers.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertSpt.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts +2 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -1
- package/build/types/index.d.ts +14 -6
- package/build/types/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/build/browser/api/test/actions.test.js +0 -14397
- package/build/browser/api/test/actions.test.js.map +0 -1
- package/build/browser/api/test/interfaces.test.js +0 -1189
- package/build/browser/api/test/interfaces.test.js.map +0 -1
- package/build/browser/api/test/links.test.js +0 -2019
- package/build/browser/api/test/links.test.js.map +0 -1
- package/build/browser/api/test/markingconstraint.test.js +0 -134
- package/build/browser/api/test/markingconstraint.test.js.map +0 -1
- package/build/browser/api/test/misc.test.js +0 -1315
- package/build/browser/api/test/misc.test.js.map +0 -1
- package/build/browser/api/test/objectStatus.test.js +0 -160
- package/build/browser/api/test/objectStatus.test.js.map +0 -1
- package/build/browser/api/test/objects.test.js +0 -3856
- package/build/browser/api/test/objects.test.js.map +0 -1
- package/build/browser/api/test/spt.test.js +0 -722
- package/build/browser/api/test/spt.test.js.map +0 -1
- package/build/browser/api/test/valueTypes.test.js +0 -307
- package/build/browser/api/test/valueTypes.test.js.map +0 -1
- package/build/esm/api/test/actions.test.js +0 -14397
- package/build/esm/api/test/actions.test.js.map +0 -1
- package/build/esm/api/test/interfaces.test.js +0 -1189
- package/build/esm/api/test/interfaces.test.js.map +0 -1
- package/build/esm/api/test/links.test.js +0 -2019
- package/build/esm/api/test/links.test.js.map +0 -1
- package/build/esm/api/test/markingconstraint.test.js +0 -134
- package/build/esm/api/test/markingconstraint.test.js.map +0 -1
- package/build/esm/api/test/misc.test.js +0 -1315
- package/build/esm/api/test/misc.test.js.map +0 -1
- package/build/esm/api/test/objectStatus.test.js +0 -160
- package/build/esm/api/test/objectStatus.test.js.map +0 -1
- package/build/esm/api/test/objects.test.js +0 -3856
- package/build/esm/api/test/objects.test.js.map +0 -1
- package/build/esm/api/test/spt.test.js +0 -722
- package/build/esm/api/test/spt.test.js.map +0 -1
- package/build/esm/api/test/valueTypes.test.js +0 -307
- package/build/esm/api/test/valueTypes.test.js.map +0 -1
- package/build/types/api/test/actions.test.d.ts +0 -1
- package/build/types/api/test/actions.test.d.ts.map +0 -1
- package/build/types/api/test/interfaces.test.d.ts +0 -1
- package/build/types/api/test/interfaces.test.d.ts.map +0 -1
- package/build/types/api/test/links.test.d.ts +0 -1
- package/build/types/api/test/links.test.d.ts.map +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/test/misc.test.d.ts +0 -1
- package/build/types/api/test/misc.test.d.ts.map +0 -1
- package/build/types/api/test/objectStatus.test.d.ts +0 -1
- package/build/types/api/test/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/test/objects.test.d.ts +0 -1
- package/build/types/api/test/objects.test.d.ts.map +0 -1
- package/build/types/api/test/spt.test.d.ts +0 -1
- package/build/types/api/test/spt.test.d.ts.map +0 -1
- package/build/types/api/test/valueTypes.test.d.ts +0 -1
- package/build/types/api/test/valueTypes.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineValueType.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","convertValueTypeTypeToBaseType","valueType","type","array","elementType","structV2","fields","map","field","identifier","baseType","keyType","optional","wrappedType","Error","defineValueType","valueTypeDef","apiName","inputApiName","displayName","description","version","namespacePrefix","test","process","env","NODE_ENV","existingVersions","VALUE_TYPE","duplicateVersion","find","vt","undefined","typeName","constraints","constraint","output","failureMessage","packageNamespace","substring","length","displayMetadata","status","convertUserValueTypeStatusToValueTypeStatus","exampleValues","__type","deprecated","message","deadline","replacedBy","active"],"sources":["defineValueType.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 BaseType,\n DataConstraint,\n DataConstraintWrapper,\n FailureMessage,\n ValueTypeDataConstraint,\n ValueTypeRid,\n ValueTypeStatus,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { type ValueTypeDefinitionVersion } from \"./values/ValueTypeDefinitionVersion.js\";\nimport { type ValueTypeType } from \"./values/ValueTypeType.js\";\n\ntype ZipBaseAndConstraint<Base, Constraint> = {\n [PropertyType in (BaseType[\"type\"] & DataConstraint[\"type\"])]: Base extends\n { type: PropertyType } ? {\n baseType: Omit<Base, \"type\">;\n constraints?: Constraint extends { type: PropertyType } ? {\n constraint: Omit<Constraint, \"type\">;\n failureMessage?: FailureMessage;\n }[]\n : undefined;\n }\n : never;\n};\n\ntype MappedZip = ZipBaseAndConstraint<BaseType, DataConstraint>;\n\ntype TypeNames = ValueTypeType[\"type\"];\n\ntype ValueTypeDefinitionBacking = {\n [Type in ValueTypeType[\"type\"] & DataConstraint[\"type\"]]: {\n baseType: { \"type\": Extract<ValueTypeType, { type: Type }>[\"value\"] } & {\n constraints: {\n constraint: Extract<\n DataConstraint,\n { type: Type }\n >[keyof Omit<Extract<DataConstraint, { type: Type }>, \"type\">];\n failureMessage?: FailureMessage;\n }[];\n };\n };\n};\n\ntype NewValueTypeDefinitionBacking = {\n [Type in ValueTypeType as Type[\"type\"]]: {\n type: Type[\"value\"];\n constraints?: Type[\"constraints\"];\n };\n};\ntype NewValueTypeDefinition =\n NewValueTypeDefinitionBacking[keyof NewValueTypeDefinitionBacking];\n\nfunction convertValueTypeTypeToBaseType(\n valueType: ValueTypeType[\"value\"],\n): BaseType {\n if (typeof valueType === \"string\") {\n }\n switch (true) {\n case (typeof valueType === \"object\" && valueType.type === \"array\"):\n return {\n type: \"array\",\n array: {\n elementType: convertValueTypeTypeToBaseType(valueType.elementType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"struct\"):\n return {\n type: \"structV2\",\n structV2: {\n fields: valueType.fields.map(field => ({\n identifier: field.identifier,\n baseType: convertValueTypeTypeToBaseType(field.baseType),\n })),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"map\"):\n return {\n type: \"map\",\n map: {\n keyType: convertValueTypeTypeToBaseType(valueType.keyType),\n valueType: convertValueTypeTypeToBaseType(valueType.valueType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"optional\"):\n return {\n type: \"optional\",\n optional: {\n wrappedType: convertValueTypeTypeToBaseType(valueType.wrappedType),\n },\n };\n case (typeof valueType === \"string\"):\n return { type: valueType, [valueType]: {} } as any;\n default:\n throw new Error(\"Invalid ValueTypeType\");\n }\n}\n\nexport type ValueTypeDefinition = {\n apiName: string;\n displayName: string;\n description?: string;\n type: NewValueTypeDefinition;\n version: string;\n status?: UserValueTypeStatus;\n namespacePrefix?: boolean;\n};\n\nexport type UserValueTypeStatus = \"active\" | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: ValueTypeRid;\n};\n\nexport function defineValueType(\n valueTypeDef: ValueTypeDefinition,\n): ValueTypeDefinitionVersion {\n const {\n apiName: inputApiName,\n displayName,\n description,\n type,\n version,\n namespacePrefix,\n } = valueTypeDef;\n const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;\n const semverValidation =\n /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n\n const existingVersions =\n ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];\n const duplicateVersion = existingVersions.find(vt => vt.version === version);\n invariant(\n duplicateVersion === undefined,\n `Value type with apiName ${apiName} and version ${version} is already defined`,\n );\n\n const typeName: TypeNames = typeof type.type === \"string\"\n ? type.type\n : type.type.type === \"struct\"\n ? \"structV2\"\n : type.type.type;\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = type.constraints\n ? type.constraints.map<ValueTypeDataConstraint>(constraint => {\n const output: any = {\n constraint: { type: typeName, [typeName]: constraint.constraint },\n failureMessage: constraint.failureMessage,\n };\n return { constraint: output as DataConstraintWrapper };\n })\n : [];\n\n const baseType: BaseType = convertValueTypeTypeToBaseType(type.type);\n\n const vt: ValueTypeDefinitionVersion = {\n apiName,\n packageNamespace: namespace.substring(0, namespace.length - 1),\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: convertUserValueTypeStatusToValueTypeStatus(valueTypeDef.status),\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n __type: OntologyEntityTypeEnum.VALUE_TYPE,\n };\n updateOntology(vt);\n return vt;\n}\n\nexport function convertUserValueTypeStatusToValueTypeStatus(\n status: UserValueTypeStatus | undefined,\n): ValueTypeStatus {\n if (typeof status === \"object\" && status.type === \"deprecated\") {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: status.replacedBy,\n },\n };\n }\n return { type: \"active\", active: {} };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AA4C5B,SAASC,8BAA8BA,CACrCC,SAAiC,EACvB;EACV,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE,CACnC;EACA,QAAQ,IAAI;IACV,KAAM,OAAOA,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,OAAO;MAC/D,OAAO;QACLA,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;UACLC,WAAW,EAAEJ,8BAA8B,CAACC,SAAS,CAACG,WAAW;QACnE;MACF,CAAC;IACH,KAAM,OAAOH,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,QAAQ;MAChE,OAAO;QACLA,IAAI,EAAE,UAAU;QAChBG,QAAQ,EAAE;UACRC,MAAM,EAAEL,SAAS,CAACK,MAAM,CAACC,GAAG,CAACC,KAAK,KAAK;YACrCC,UAAU,EAAED,KAAK,CAACC,UAAU;YAC5BC,QAAQ,EAAEV,8BAA8B,CAACQ,KAAK,CAACE,QAAQ;UACzD,CAAC,CAAC;QACJ;MACF,CAAC;IACH,KAAM,OAAOT,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,KAAK;MAC7D,OAAO;QACLA,IAAI,EAAE,KAAK;QACXK,GAAG,EAAE;UACHI,OAAO,EAAEX,8BAA8B,CAACC,SA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,KAAK,YAAY,EAAE;IAC9D,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB4C,UAAU,EAAE;QACVC,OAAO,EAAEL,MAAM,CAACK,OAAO;QACvBC,QAAQ,EAAEN,MAAM,CAACM,QAAQ;QACzBC,UAAU,EAAEP,MAAM,CAACO;MACrB;IACF,CAAC;EACH;EACA,OAAO;IAAE/C,IAAI,EAAE,QAAQ;IAAEgD,MAAM,EAAE,CAAC;EAAE,CAAC;AACvC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineValueType.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","convertValueTypeTypeToBaseType","valueType","type","array","elementType","structV2","fields","map","field","identifier","baseType","keyType","optional","wrappedType","Error","defineValueType","valueTypeDefInput","valueTypeDef","apiName","inputApiName","displayName","description","version","namespacePrefix","test","process","env","NODE_ENV","existingVersions","VALUE_TYPE","duplicateVersion","find","vt","undefined","typeName","constraints","constraint","output","failureMessage","packageNamespace","substring","length","displayMetadata","status","convertUserValueTypeStatusToValueTypeStatus","exampleValues","__type","deprecated","message","deadline","replacedBy","active"],"sources":["defineValueType.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 BaseType,\n DataConstraint,\n DataConstraintWrapper,\n FailureMessage,\n ValueTypeDataConstraint,\n ValueTypeRid,\n ValueTypeStatus,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { type ValueTypeDefinitionVersion } from \"./values/ValueTypeDefinitionVersion.js\";\nimport { type ValueTypeType } from \"./values/ValueTypeType.js\";\n\ntype ZipBaseAndConstraint<Base, Constraint> = {\n [PropertyType in (BaseType[\"type\"] & DataConstraint[\"type\"])]: Base extends\n { type: PropertyType } ? {\n baseType: Omit<Base, \"type\">;\n constraints?: Constraint extends { type: PropertyType } ? {\n constraint: Omit<Constraint, \"type\">;\n failureMessage?: FailureMessage;\n }[]\n : undefined;\n }\n : never;\n};\n\ntype MappedZip = ZipBaseAndConstraint<BaseType, DataConstraint>;\n\ntype TypeNames = ValueTypeType[\"type\"];\n\ntype ValueTypeDefinitionBacking = {\n [Type in ValueTypeType[\"type\"] & DataConstraint[\"type\"]]: {\n baseType: { \"type\": Extract<ValueTypeType, { type: Type }>[\"value\"] } & {\n constraints: {\n constraint: Extract<\n DataConstraint,\n { type: Type }\n >[keyof Omit<Extract<DataConstraint, { type: Type }>, \"type\">];\n failureMessage?: FailureMessage;\n }[];\n };\n };\n};\n\ntype NewValueTypeDefinitionBacking = {\n [Type in ValueTypeType as Type[\"type\"]]: {\n type: Type[\"value\"];\n constraints?: Type[\"constraints\"];\n };\n};\ntype NewValueTypeDefinition =\n NewValueTypeDefinitionBacking[keyof NewValueTypeDefinitionBacking];\n\nfunction convertValueTypeTypeToBaseType(\n valueType: ValueTypeType[\"value\"],\n): BaseType {\n if (typeof valueType === \"string\") {\n }\n switch (true) {\n case (typeof valueType === \"object\" && valueType.type === \"array\"):\n return {\n type: \"array\",\n array: {\n elementType: convertValueTypeTypeToBaseType(valueType.elementType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"struct\"):\n return {\n type: \"structV2\",\n structV2: {\n fields: valueType.fields.map(field => ({\n identifier: field.identifier,\n baseType: convertValueTypeTypeToBaseType(field.baseType),\n })),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"map\"):\n return {\n type: \"map\",\n map: {\n keyType: convertValueTypeTypeToBaseType(valueType.keyType),\n valueType: convertValueTypeTypeToBaseType(valueType.valueType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"optional\"):\n return {\n type: \"optional\",\n optional: {\n wrappedType: convertValueTypeTypeToBaseType(valueType.wrappedType),\n },\n };\n case (typeof valueType === \"string\"):\n return { type: valueType, [valueType]: {} } as any;\n default:\n throw new Error(\"Invalid ValueTypeType\");\n }\n}\n\nexport type ValueTypeDefinition = {\n apiName: string;\n displayName: string;\n description?: string;\n type: NewValueTypeDefinition;\n version: string;\n status?: UserValueTypeStatus;\n namespacePrefix?: boolean;\n};\n\nexport type UserValueTypeStatus = \"active\" | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: ValueTypeRid;\n};\n\nexport function defineValueType(\n valueTypeDefInput: ValueTypeDefinition,\n): ValueTypeDefinitionVersion {\n const valueTypeDef = cloneDefinition(valueTypeDefInput);\n const {\n apiName: inputApiName,\n displayName,\n description,\n type,\n version,\n namespacePrefix,\n } = valueTypeDef;\n const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;\n const semverValidation =\n /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n\n const existingVersions =\n ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];\n const duplicateVersion = existingVersions.find(vt => vt.version === version);\n invariant(\n duplicateVersion === undefined,\n `Value type with apiName ${apiName} and version ${version} is already defined`,\n );\n\n const typeName: TypeNames = typeof type.type === \"string\"\n ? type.type\n : type.type.type === \"struct\"\n ? \"structV2\"\n : type.type.type;\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = type.constraints\n ? type.constraints.map<ValueTypeDataConstraint>(constraint => {\n const output: any = {\n constraint: { type: typeName, [typeName]: constraint.constraint },\n failureMessage: constraint.failureMessage,\n };\n return { constraint: output as DataConstraintWrapper };\n })\n : [];\n\n const baseType: BaseType = convertValueTypeTypeToBaseType(type.type);\n\n const vt: ValueTypeDefinitionVersion = {\n apiName,\n packageNamespace: namespace.substring(0, namespace.length - 1),\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: convertUserValueTypeStatusToValueTypeStatus(valueTypeDef.status),\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n __type: OntologyEntityTypeEnum.VALUE_TYPE,\n };\n updateOntology(vt);\n return vt;\n}\n\nexport function convertUserValueTypeStatusToValueTypeStatus(\n status: UserValueTypeStatus | undefined,\n): ValueTypeStatus {\n if (typeof status === \"object\" && status.type === \"deprecated\") {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: status.replacedBy,\n },\n };\n }\n return { type: \"active\", active: {} };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AA4C5B,SAASC,8BAA8BA,CACrCC,SAAiC,EACvB;EACV,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE,CACnC;EACA,QAAQ,IAAI;IACV,KAAM,OAAOA,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,OAAO;MAC/D,OAAO;QACLA,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;UACLC,WAAW,EAAEJ,8BAA8B,CAACC,SAAS,CAACG,WAAW;QACnE;MACF,CAAC;IACH,KAAM,OAAOH,SAAS,KAAK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3C,SAAS,CAAC4C,MAAM,GAAG,CAAC,CAAC;IAC9DC,eAAe,EAAE;MACftB,WAAW,EAAEA,WAAW;MACxBC,WAAW,EAAEA,WAAW,IAAI;IAC9B,CAAC;IACDsB,MAAM,EAAEC,2CAA2C,CAAC3B,YAAY,CAAC0B,MAAM,CAAC;IACxErB,OAAO,EAAEA,OAAO;IAChBZ,QAAQ,EAAEA,QAAQ;IAClByB,WAAW,EAAEA,WAAW;IACxBU,aAAa,EAAE,EAAE;IACjBC,MAAM,EAAElD,sBAAsB,CAACiC;EACjC,CAAC;EACD9B,cAAc,CAACiC,EAAE,CAAC;EAClB,OAAOA,EAAE;AACX;AAEA,OAAO,SAASY,2CAA2CA,CACzDD,MAAuC,EACtB;EACjB,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACzC,IAAI,KAAK,YAAY,EAAE;IAC9D,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB6C,UAAU,EAAE;QACVC,OAAO,EAAEL,MAAM,CAACK,OAAO;QACvBC,QAAQ,EAAEN,MAAM,CAACM,QAAQ;QACzBC,UAAU,EAAEP,MAAM,CAACO;MACrB;IACF,CAAC;EACH;EACA,OAAO;IAAEhD,IAAI,EAAE,QAAQ;IAAEiD,MAAM,EAAE,CAAC;EAAE,CAAC;AACvC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.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 InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {\n InterfacePropertyType,\n InterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\n\nexport interface InterfaceType extends\n OntologyEntityBase,\n Omit<\n OntologyIrMarketplaceInterfaceType,\n // we want our simplified representation\n | \"properties\"\n // these things don't need to exist as the system works fine without them (I'm told)\n | \"propertiesV2\"\n | \"propertiesV3\"\n | \"extendsInterfaces\"\n >\n{\n propertiesV2: Record<string, InterfaceSharedPropertyType>;\n propertiesV3: Record<string, InterfacePropertyType>;\n extendsInterfaces: Array<InterfaceType>;\n status: InterfaceTypeStatus;\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.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 InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {\n InterfacePropertyType,\n InterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\n\nexport interface InterfaceType extends\n OntologyEntityBase,\n Omit<\n OntologyIrMarketplaceInterfaceType,\n // we want our simplified representation\n | \"properties\"\n // these things don't need to exist as the system works fine without them (I'm told)\n | \"propertiesV2\"\n | \"propertiesV3\"\n | \"extendsInterfaces\"\n | \"extendsInterfacesMetadata\"\n >\n{\n propertiesV2: Record<string, InterfaceSharedPropertyType>;\n propertiesV3: Record<string, InterfacePropertyType>;\n extendsInterfaces: Array<InterfaceType>;\n status: InterfaceTypeStatus;\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectPropertyType.js","names":[],"sources":["ObjectPropertyType.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 OntologyIrBaseFormatter,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { Nullability } from \"../properties/Nullability.js\";\nimport type { PropertyTypeType } from \"../properties/PropertyTypeType.js\";\nimport type { SharedPropertyType } from \"../properties/SharedPropertyType.js\";\nimport type { ValueTypeDefinitionVersion } from \"../values/ValueTypeDefinitionVersion.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectPropertyType = RequiredFields<\n Partial<ObjectPropertyTypeInner>,\n \"apiName\" | \"type\" | \"displayName\"\n>;\n\nexport interface ObjectPropertyTypeInner {\n // <These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n apiName: string; // was: ObjectTypeFieldApiName;\n\n // FIXME: This still depends on conjure types\n baseFormatter?: OntologyIrBaseFormatter | null | undefined;\n indexedForSearch: boolean;\n typeClasses: Array<{\n kind: string;\n name: string;\n }>;\n // </These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n type: PropertyTypeType;\n array?: boolean;\n valueType: ValueTypeDefinitionVersion;\n sharedPropertyType: SharedPropertyType;\n description: string | undefined;\n displayName: string;\n visibility: Visibility;\n nullability?: Nullability;\n status?: ObjectTypeStatus;\n editOnly?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectPropertyType.js","names":[],"sources":["ObjectPropertyType.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 OntologyIrBaseFormatter,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { Nullability } from \"../properties/Nullability.js\";\nimport type { PropertyTypeType } from \"../properties/PropertyTypeType.js\";\nimport type { ReducerType } from \"../properties/ReducerType.js\";\nimport type { SharedPropertyType } from \"../properties/SharedPropertyType.js\";\nimport type { ValueTypeDefinitionVersion } from \"../values/ValueTypeDefinitionVersion.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectPropertyType = RequiredFields<\n Partial<ObjectPropertyTypeInner>,\n \"apiName\" | \"type\" | \"displayName\"\n>;\n\nexport interface ObjectPropertyTypeInner {\n // <These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n apiName: string; // was: ObjectTypeFieldApiName;\n\n // FIXME: This still depends on conjure types\n baseFormatter?: OntologyIrBaseFormatter | null | undefined;\n indexedForSearch: boolean;\n typeClasses: Array<{\n kind: string;\n name: string;\n }>;\n // </These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n type: PropertyTypeType;\n array?: boolean;\n reducers?: Array<ReducerType>;\n valueType: ValueTypeDefinitionVersion;\n sharedPropertyType: SharedPropertyType;\n description: string | undefined;\n displayName: string;\n visibility: Visibility;\n nullability?: Nullability;\n status?: ObjectTypeStatus;\n editOnly?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTypeDatasourceDefinition.js","names":[],"sources":["ObjectTypeDatasourceDefinition.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 DerivedPropertyLinkTypeSide,\n MarkingType,\n ObjectTypeFieldApiName,\n} from \"@osdk/client.unstable\";\nimport type { LinkType } from \"../links/LinkType.js\";\nimport type { SecurityConditionDefinition } from \"./SecurityCondition.js\";\n\nexport type ObjectTypeDatasourceDefinition =\n | ObjectTypeDatasourceDefinition_stream\n | ObjectTypeDatasourceDefinition_dataset\n | ObjectTypeDatasourceDefinition_restrictedView\n | ObjectTypeDatasourceDefinition_derived;\n\nexport interface ObjectTypeDatasourceDefinition_dataset {\n type: \"dataset\";\n objectSecurityPolicy?: ObjectSecurityPolicy;\n propertySecurityGroups?: Array<PropertySecurityGroup>;\n}\n\nexport interface ObjectSecurityPolicy {\n name: string;\n granularPolicy?: SecurityConditionDefinition;\n
|
|
1
|
+
{"version":3,"file":"ObjectTypeDatasourceDefinition.js","names":[],"sources":["ObjectTypeDatasourceDefinition.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 DerivedPropertyLinkTypeSide,\n MarkingType,\n ObjectTypeFieldApiName,\n} from \"@osdk/client.unstable\";\nimport type { LinkType } from \"../links/LinkType.js\";\nimport type { SecurityConditionDefinition } from \"./SecurityCondition.js\";\n\nexport type ObjectTypeDatasourceDefinition =\n | ObjectTypeDatasourceDefinition_stream\n | ObjectTypeDatasourceDefinition_dataset\n | ObjectTypeDatasourceDefinition_restrictedView\n | ObjectTypeDatasourceDefinition_derived\n | ObjectTypeDatasourceDefinition_direct;\n\nexport interface ObjectTypeDatasourceDefinition_dataset {\n type: \"dataset\";\n objectSecurityPolicy?: ObjectSecurityPolicy;\n propertySecurityGroups?: Array<PropertySecurityGroup>;\n}\n\nexport interface ObjectSecurityPolicy {\n name: string;\n granularPolicy?: SecurityConditionDefinition;\n appliedMarkings?: Record<string, MarkingType>;\n assumedMarkings?: Record<string, MarkingType>;\n}\n\nexport interface PropertySecurityGroup {\n name: string;\n properties: Array<string>;\n granularPolicy?: SecurityConditionDefinition;\n appliedMarkings?: Record<string, MarkingType>;\n assumedMarkings?: Record<string, MarkingType>;\n}\n\nexport interface ObjectTypeDatasourceDefinition_stream {\n type: \"stream\";\n // Retention period must be in ISO 8601 duration format\n retentionPeriod?: string;\n}\n\nexport interface ObjectTypeDatasourceDefinition_restrictedView {\n type: \"restrictedView\";\n}\n\nexport interface ObjectTypeDatasourceDefinition_derived {\n type: \"derived\";\n linkDefinition: Array<DerivedPropertiesLinkDefinition>;\n // property->property is linkedProperties, property->aggregation is aggregatedProperties\n propertyMapping:\n | Record<ObjectTypeFieldApiName, ObjectTypeFieldApiName>\n | Record<ObjectTypeFieldApiName, DerivedPropertyAggregation>;\n}\nexport interface DerivedPropertiesLinkDefinition {\n linkType: LinkType;\n side?: DerivedPropertyLinkTypeSide;\n}\n\n// if the property is null on the object, it is ignored in aggregations\nexport type DerivedPropertyAggregation =\n | { type: \"count\" } // total count of objects\n | { type: \"avg\"; property: ObjectTypeFieldApiName }\n | { type: \"sum\"; property: ObjectTypeFieldApiName }\n | { type: \"min\"; property: ObjectTypeFieldApiName }\n | { type: \"max\"; property: ObjectTypeFieldApiName }\n | { type: \"approximateCardinality\"; property: ObjectTypeFieldApiName }\n | { type: \"exactCardinality\"; property: ObjectTypeFieldApiName }\n | { type: \"collectList\"; property: ObjectTypeFieldApiName; limit: number } // max limit is 100\n | { type: \"collectSet\"; property: ObjectTypeFieldApiName; limit: number }; // max limit is 100\n\nexport interface ObjectTypeDatasourceDefinition_direct {\n type: \"direct\";\n objectSecurityPolicy?: ObjectSecurityPolicy;\n propertySecurityGroups?: Array<PropertySecurityGroup>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyTypeType.js","names":["isPropertyTypeType","v","type","isExotic","undefined","includes","isStruct"],"sources":["PropertyTypeType.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 { StructFieldType } from \"@osdk/client.unstable\";\n\nexport type PropertyTypeType =\n | PropertyTypeTypePrimitive\n | PropertyTypeTypeExotic;\n\nexport type PropertyTypeTypePrimitive =\n | \"boolean\"\n | \"byte\"\n | \"date\"\n | \"decimal\"\n | \"double\"\n | \"float\"\n | \"integer\"\n | \"long\"\n | \"short\"\n | \"string\"\n | \"timestamp\"\n | \"attachment\";\n\nexport type PropertyTypeTypeExotic =\n | \"geopoint\"\n | \"geoshape\"\n | \"mediaReference\"\n | \"geotimeSeries\"\n | PropertyTypeTypeMarking\n | PropertyTypeTypeStruct\n | PropertyTypeTypeString\n | PropertyTypeTypeDecimal;\n\ntype PropertyTypeTypeMarking = {\n type: \"marking\";\n markingType: \"MANDATORY\" | \"CBAC\";\n markingInputGroupName: string;\n};\n\nexport type PropertyTypeTypeStruct = {\n type: \"struct\";\n structDefinition: {\n [api_name: string]:\n | StructPropertyType\n | Exclude<PropertyTypeTypesWithoutStruct, PropertyTypeTypeMarking>;\n };\n};\n\ntype PropertyTypeTypeString = {\n type: \"string\";\n isLongText?: boolean;\n supportsEfficientLeadingWildcard?: boolean;\n supportsExactMatching?: boolean;\n supportsFullTextRegex?: boolean;\n enableAsciiFolding?: boolean;\n};\n\ntype PropertyTypeTypeDecimal = {\n type: \"decimal\";\n precision?: number;\n scale?: number;\n};\n\nexport type PropertyTypeTypesWithoutStruct = Exclude<\n PropertyTypeType,\n PropertyTypeTypeStruct\n>;\nexport function isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\nexport function isExotic(\n type: PropertyTypeType | undefined,\n): type is PropertyTypeTypeExotic {\n if (type === undefined) {\n return false;\n }\n if (typeof type === \"string\") {\n return [\"geopoint\", \"geoshape\", \"mediaReference\", \"geotimeSeries\"].includes(\n type,\n );\n } else if (typeof type === \"object\" && type != null) {\n return type.type === \"marking\" || type.type === \"struct\"\n || type.type === \"string\"\n || type.type === \"decimal\";\n }\n return false;\n}\nexport function isStruct(\n type: PropertyTypeType,\n): type is PropertyTypeTypeStruct {\n return typeof type === \"object\" && type.type === \"struct\";\n}\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport interface StructPropertyType extends\n Optional<\n Omit<\n StructFieldType,\n \"fieldType\" | \"structFieldRid\" | \"apiName\"\n >,\n \"typeClasses\" | \"aliases\"\n >\n{\n fieldType: PropertyTypeTypesWithoutStruct;\n requireImplementation?: boolean;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"PropertyTypeType.js","names":["isPropertyTypeType","v","type","isExotic","undefined","includes","isStruct"],"sources":["PropertyTypeType.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 { StructFieldType } from \"@osdk/client.unstable\";\n\nexport type PropertyTypeType =\n | PropertyTypeTypePrimitive\n | PropertyTypeTypeExotic;\n\nexport type PropertyTypeTypePrimitive =\n | \"boolean\"\n | \"byte\"\n | \"date\"\n | \"decimal\"\n | \"double\"\n | \"float\"\n | \"integer\"\n | \"long\"\n | \"short\"\n | \"string\"\n | \"timestamp\"\n | \"attachment\";\n\nexport type PropertyTypeTypeExotic =\n | \"geopoint\"\n | \"geoshape\"\n | \"mediaReference\"\n | \"geotimeSeries\"\n | PropertyTypeTypeMarking\n | PropertyTypeTypeStruct\n | PropertyTypeTypeString\n | PropertyTypeTypeDecimal;\n\ntype PropertyTypeTypeMarking = {\n type: \"marking\";\n markingType: \"MANDATORY\" | \"CBAC\";\n markingInputGroupName: string;\n};\n\nexport type PropertyTypeTypeStruct = {\n type: \"struct\";\n structDefinition: {\n [api_name: string]:\n | StructPropertyType\n | Exclude<PropertyTypeTypesWithoutStruct, PropertyTypeTypeMarking>;\n };\n mainValue?: {\n fields: string | Array<string>;\n // TODO(ethana): we can infer this type from fields\n type: PropertyTypeType;\n };\n};\n\ntype PropertyTypeTypeString = {\n type: \"string\";\n isLongText?: boolean;\n supportsEfficientLeadingWildcard?: boolean;\n supportsExactMatching?: boolean;\n supportsFullTextRegex?: boolean;\n enableAsciiFolding?: boolean;\n};\n\ntype PropertyTypeTypeDecimal = {\n type: \"decimal\";\n precision?: number;\n scale?: number;\n};\n\nexport type PropertyTypeTypesWithoutStruct = Exclude<\n PropertyTypeType,\n PropertyTypeTypeStruct\n>;\nexport function isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\nexport function isExotic(\n type: PropertyTypeType | undefined,\n): type is PropertyTypeTypeExotic {\n if (type === undefined) {\n return false;\n }\n if (typeof type === \"string\") {\n return [\"geopoint\", \"geoshape\", \"mediaReference\", \"geotimeSeries\"].includes(\n type,\n );\n } else if (typeof type === \"object\" && type != null) {\n return type.type === \"marking\" || type.type === \"struct\"\n || type.type === \"string\"\n || type.type === \"decimal\";\n }\n return false;\n}\nexport function isStruct(\n type: PropertyTypeType,\n): type is PropertyTypeTypeStruct {\n return typeof type === \"object\" && type.type === \"struct\";\n}\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport interface StructPropertyType extends\n Optional<\n Omit<\n StructFieldType,\n \"fieldType\" | \"structFieldRid\" | \"apiName\"\n >,\n \"typeClasses\" | \"aliases\"\n >\n{\n fieldType: PropertyTypeTypesWithoutStruct;\n requireImplementation?: boolean;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuEA,OAAO,SAASA,kBAAkBA,CAChCC,CAAmB,EACI;EACvB,OAAOA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IACjCA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,QAAQ,IACjDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,UAAU,IAAIA,CAAC,KAAK,UAAU,IACrDA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAC9B,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,CAACC,IAAI,KAAK,SAAU,IAC/CD,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AACxB;AACA,OAAO,SAASE,QAAQA,CACtBD,IAAkC,EACF;EAChC,IAAIA,IAAI,KAAKE,SAAS,EAAE;IACtB,OAAO,KAAK;EACd;EACA,IAAI,OAAOF,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAACG,QAAQ,CACzEH,IACF,CAAC;EACH,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,IAAI,IAAI,EAAE;IACnD,OAAOA,IAAI,CAACA,IAAI,KAAK,SAAS,IAAIA,IAAI,CAACA,IAAI,KAAK,QAAQ,IACnDA,IAAI,CAACA,IAAI,KAAK,QAAQ,IACtBA,IAAI,CAACA,IAAI,KAAK,SAAS;EAC9B;EACA,OAAO,KAAK;AACd;AACA,OAAO,SAASI,QAAQA,CACtBJ,IAAsB,EACU;EAChC,OAAO,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACA,IAAI,KAAK,QAAQ;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReducerType.js","names":[],"sources":["ReducerType.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\nexport type ReducerType = {\n direction:\n | \"ascending\" // first (A -> Z) value, least recent date, etc.\n | \"descending\"; // last (Z -> A) value, most recent date, etc.\n structField?: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedPropertyType.js","names":[],"sources":["SharedPropertyType.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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { TypeClass } from \"../common/TypeClass.js\";\nimport type { Nullability } from \"./Nullability.js\";\nimport type { PropertyTypeType } from \"./PropertyTypeType.js\";\n\nexport interface SharedPropertyType extends OntologyEntityBase, PropertyType {\n apiName: string;\n nonNameSpacedApiName: string;\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE;\n}\nexport interface PropertyType {\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n typeClasses?: TypeClass[];\n nullability?: Nullability;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SharedPropertyType.js","names":[],"sources":["SharedPropertyType.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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { TypeClass } from \"../common/TypeClass.js\";\nimport type { Nullability } from \"./Nullability.js\";\nimport type { PropertyTypeType } from \"./PropertyTypeType.js\";\nimport type { ReducerType } from \"./ReducerType.js\";\n\nexport interface SharedPropertyType extends OntologyEntityBase, PropertyType {\n apiName: string;\n nonNameSpacedApiName: string;\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE;\n}\nexport interface PropertyType {\n type: PropertyTypeType;\n array?: boolean;\n reducers?: Array<ReducerType>;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n typeClasses?: TypeClass[];\n nullability?: Nullability;\n}\n"],"mappings":"","ignoreList":[]}
|
package/build/esm/cli/main.js
CHANGED
|
@@ -24,7 +24,7 @@ import { defineOntology } from "../api/defineOntology.js";
|
|
|
24
24
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
25
25
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
26
26
|
export default async function main(args = process.argv) {
|
|
27
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.
|
|
27
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.16.0-beta.10" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
28
28
|
input: {
|
|
29
29
|
alias: "i",
|
|
30
30
|
describe: "Input file",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineOntology","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","snippetPackageName","q"],"sources":["main.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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets\n && (commandLineOpts.codeSnippetPackageName !== \"\"\n || commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eAYL,GAAG,MAAMT,KAAK,CAACC,OAA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AsB,EACtBC,aAAsB,EACtB;EACA,MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineOntology","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","snippetPackageName","q"],"sources":["main.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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets\n && (commandLineOpts.codeSnippetPackageName !== \"\"\n || commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessK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CAChBpC,eAAe,CAACgB,MAAM,EACtBqB,IAAI,CAACC,SAAS,CACZJ,UAAU,EACV,IAAI,EACJ,CACF,CACF,CAAC;EACD;EACA,IACEA,UAAU,CAACK,UAAU,CAACA,UAAU,CAACZ,MAAM,GAAG,CAAC,IACxCO,UAAU,CAACM,kBAAkB,CAACD,UAAU,CAACZ,MAAM,GAAG,CAAC,EACtD;IACA,MAAMvC,EAAE,CAACgD,SAAS,CAChBpC,eAAe,CAACoB,gBAAgB,EAChCiB,IAAI,CAACC,SAAS,CACZJ,UAAU,CAACK,UAAU,EACrB,IAAI,EACJ,CACF,CACF,CAAC;EACH;AACF;AAEA,eAAeJ,YAAYA,CACzB1B,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7BsB,cAAkC,EAClCnB,oBAA6B,EAC7BoB,kBAA0B,EAC1BlB,cAAsB,EACtBC,aAAsB,EACtB;EACA,MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
export function convertDatasourceDefinition(objectType, properties) {
|
|
19
|
-
const baseDatasource = objectType.datasources?.find(ds => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
19
|
+
const baseDatasource = objectType.datasources?.find(ds => ["dataset", "stream", "restrictedView", "direct"].includes(ds.type));
|
|
20
20
|
switch (baseDatasource?.type) {
|
|
21
21
|
case "stream":
|
|
22
22
|
const window = baseDatasource.retentionPeriod;
|
|
@@ -55,6 +55,15 @@ export function convertDatasourceDefinition(objectType, properties) {
|
|
|
55
55
|
propertyMapping: buildPropertyMapping(properties)
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
case "direct":
|
|
59
|
+
return {
|
|
60
|
+
type: "direct",
|
|
61
|
+
direct: {
|
|
62
|
+
directSourceRid: objectType.apiName,
|
|
63
|
+
propertyMapping: buildPropertyMapping(properties),
|
|
64
|
+
propertySecurityGroups: convertPropertySecurityGroups(baseDatasource, properties, objectType.primaryKeyPropertyApiName)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
58
67
|
case "dataset":
|
|
59
68
|
default:
|
|
60
69
|
if (objectType.properties?.some(prop => typeof prop.type === "object" && prop.type.type === "marking") || baseDatasource?.objectSecurityPolicy || baseDatasource?.propertySecurityGroups) {
|
|
@@ -95,6 +104,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
95
104
|
},
|
|
96
105
|
additionalMandatory: {
|
|
97
106
|
markings: {},
|
|
107
|
+
assumedMarkingsV2: {},
|
|
98
108
|
assumedMarkings: []
|
|
99
109
|
}
|
|
100
110
|
}
|
|
@@ -121,7 +131,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
121
131
|
rid: ds.objectSecurityPolicy?.name || "defaultObjectSecurityPolicy",
|
|
122
132
|
security: {
|
|
123
133
|
type: "granular",
|
|
124
|
-
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.
|
|
134
|
+
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.appliedMarkings, ds.objectSecurityPolicy?.assumedMarkings)
|
|
125
135
|
},
|
|
126
136
|
type: {
|
|
127
137
|
type: "primaryKey",
|
|
@@ -134,7 +144,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
134
144
|
rid: psg.name,
|
|
135
145
|
security: {
|
|
136
146
|
type: "granular",
|
|
137
|
-
granular: convertGranularPolicy(psg.granularPolicy, psg.
|
|
147
|
+
granular: convertGranularPolicy(psg.granularPolicy, psg.appliedMarkings, psg.assumedMarkings)
|
|
138
148
|
},
|
|
139
149
|
type: {
|
|
140
150
|
type: "property",
|
|
@@ -146,7 +156,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
146
156
|
})) ?? [])]
|
|
147
157
|
};
|
|
148
158
|
}
|
|
149
|
-
function convertGranularPolicy(granularPolicy,
|
|
159
|
+
function convertGranularPolicy(granularPolicy, appliedMarkings, assumedMarkings) {
|
|
150
160
|
return {
|
|
151
161
|
viewPolicy: {
|
|
152
162
|
granularPolicyCondition: granularPolicy ? convertSecurityCondition(granularPolicy) : {
|
|
@@ -156,8 +166,9 @@ function convertGranularPolicy(granularPolicy, additionalMandatoryMarkings) {
|
|
|
156
166
|
}
|
|
157
167
|
},
|
|
158
168
|
additionalMandatory: {
|
|
159
|
-
markings:
|
|
160
|
-
assumedMarkings: []
|
|
169
|
+
markings: appliedMarkings ?? {},
|
|
170
|
+
assumedMarkings: [],
|
|
171
|
+
assumedMarkingsV2: assumedMarkings ?? {}
|
|
161
172
|
}
|
|
162
173
|
}
|
|
163
174
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertDatasourceDefinition.js","names":["invariant","convertDatasourceDefinition","objectType","properties","baseDatasource","datasources","find","ds","includes","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","some","objectSecurityPolicy","datasetV3","branchId","convertPropertySecurityGroups","primaryKeyPropertyApiName","groups","rid","security","granular","viewPolicy","granularPolicyCondition","and","conditions","additionalMandatory","markings","assumedMarkings","primaryKey","validPropertyNames","Set","usedProperties","forEach","psg","propertyName","has","process","env","NODE_ENV","name","add","objectSecurityPolicyGroup","convertGranularPolicy","granularPolicy","additionalMandatoryMarkings","filter","property","convertSecurityCondition","condition","c","or","comparison","operator","left","userProperty","groupIds","right","constant","strings","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 MarkingType,\n OntologyIrObjectTypeDatasourceDefinition,\n OntologyIrPropertySecurityGroup,\n OntologyIrPropertySecurityGroups,\n OntologyIrSecurityGroupGranularCondition,\n OntologyIrSecurityGroupGranularSecurityDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type { ObjectTypeDatasourceDefinition_dataset } from \"../../api/object/ObjectTypeDatasourceDefinition.js\";\nimport type { SecurityConditionDefinition } from \"../../api/object/SecurityCondition.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n const baseDatasource = objectType.datasources?.find(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n switch (baseDatasource?.type) {\n case \"stream\":\n const window = baseDatasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"derived\":\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"dataset\":\n default:\n if (\n objectType.properties?.some(prop =>\n typeof prop.type === \"object\" && prop.type.type === \"marking\"\n )\n || baseDatasource?.objectSecurityPolicy\n || baseDatasource?.propertySecurityGroups\n ) {\n return {\n type: \"datasetV3\",\n datasetV3: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n branchId: \"master\",\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n }\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction convertPropertySecurityGroups(\n ds: ObjectTypeDatasourceDefinition_dataset | undefined,\n properties: ObjectPropertyType[],\n primaryKeyPropertyApiName: string,\n): OntologyIrPropertySecurityGroups {\n if (\n !ds\n || (!(\"objectSecurityPolicy\" in ds) && !(\"propertySecurityGroups\" in ds))\n ) {\n return {\n groups: [\n {\n properties: properties.map(prop => prop.apiName),\n rid: \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: {\n viewPolicy: {\n granularPolicyCondition: {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: {},\n assumedMarkings: [],\n },\n },\n },\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n },\n ],\n };\n }\n\n const validPropertyNames = new Set(properties.map(prop => prop.apiName));\n const usedProperties = new Set();\n\n ds.propertySecurityGroups?.forEach(psg => {\n psg.properties.forEach(propertyName => {\n invariant(\n validPropertyNames.has(propertyName),\n `Property \"${propertyName}\" in property security group ${psg.name} does not exist in the properties list`,\n );\n invariant(\n !usedProperties.has(propertyName),\n `Property \"${propertyName}\" is used in multiple property security groups`,\n );\n invariant(\n propertyName !== primaryKeyPropertyApiName,\n `Property \"${propertyName}\" in property security group ${psg.name} cannot be the primary key`,\n );\n usedProperties.add(propertyName);\n });\n });\n\n const objectSecurityPolicyGroup: OntologyIrPropertySecurityGroup = {\n rid: ds.objectSecurityPolicy?.name || \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: convertGranularPolicy(\n ds.objectSecurityPolicy?.granularPolicy,\n ds.objectSecurityPolicy?.additionalMandatoryMarkings,\n ),\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n properties: properties\n .filter(prop => !usedProperties.has(prop.apiName))\n .map(prop => prop.apiName),\n };\n\n return {\n groups: [\n objectSecurityPolicyGroup,\n ...(ds.propertySecurityGroups?.map(psg => ({\n rid: psg.name,\n security: {\n type: \"granular\" as const,\n granular: convertGranularPolicy(\n psg.granularPolicy,\n psg.additionalMandatoryMarkings,\n ),\n },\n type: {\n type: \"property\" as const,\n property: {\n name: psg.name,\n },\n },\n properties: psg.properties ?? [],\n })) ?? []),\n ],\n };\n}\n\nfunction convertGranularPolicy(\n granularPolicy?: SecurityConditionDefinition,\n additionalMandatoryMarkings?: Record<string, MarkingType>,\n): OntologyIrSecurityGroupGranularSecurityDefinition {\n return {\n viewPolicy: {\n granularPolicyCondition: granularPolicy\n ? convertSecurityCondition(granularPolicy)\n : {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: additionalMandatoryMarkings ?? {},\n assumedMarkings: [],\n },\n },\n };\n}\n\nfunction convertSecurityCondition(\n condition: SecurityConditionDefinition,\n): OntologyIrSecurityGroupGranularCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"markingProperty\":\n return {\n type: \"markings\",\n markings: {\n property: condition.property,\n },\n };\n case \"groupProperty\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"property\",\n property: condition.property,\n },\n },\n };\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"constant\",\n constant: {\n type: \"strings\",\n strings: [\n condition.name,\n ],\n },\n },\n },\n };\n\n default:\n return condition;\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAMtC,OAAO,SAASC,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,MAAMC,cAAc,GAAGF,UAAU,CAACG,WAAW,EAAEC,IAAI,CAACC,EAAE,IACpD,CAAC,SAA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,SAAS,CAACT,IAAI;YAElB;UACF;QACF;MACF,CAAC;IAEH;MACE,OAAOS,SAAS;EACpB;AACF;AAEA,SAASxC,oBAAoBA,CAC3BxB,UAAgC,EACS;EACzC,OAAOa,MAAM,CAACC,WAAW,CACvBd,UAAU,CAACe,GAAG,CAAEC,IAAI,IAAK;IACvB;IACA,IAAIA,IAAI,CAAC2D,QAAQ,EAAE;MACjB,OAAO,CAAC3D,IAAI,CAACC,OAAO,EAAE;QAAEX,IAAI,EAAE,UAAU;QAAEqE,QAAQ,EAAE,CAAC;MAAE,CAAC,CAAC;IAC3D;IACA;IACA,IAAI,OAAO3D,IAAI,CAACV,IAAI,KAAK,QAAQ,IAAIU,IAAI,CAACV,IAAI,EAAEA,IAAI,KAAK,QAAQ,EAAE;MACjE,MAAMsE,aAAa,GAAG;QACpBtE,IAAI,EAAE,QAAQ;QACduE,MAAM,EAAE;UACNC,MAAM,EAAE9D,IAAI,CAACC,OAAO;UACpB8D,OAAO,EAAElE,MAAM,CAACC,WAAW,CACzBD,MAAM,CAACmE,IAAI,CAAChE,IAAI,CAACV,IAAI,CAAC2E,gBAAgB,CAAC,CAAClE,GAAG,CAAEmE,SAAS,IAAK,CACzDA,SAAS,EACT;YAAEjE,OAAO,EAAEiE,SAAS;YAAEC,QAAQ,EAAE,CAAC;UAAE,CAAC,CACrC,CACH;QACF;MACF,CAAC;MACD,OAAO,CAACnE,IAAI,CAACC,OAAO,EAAE2D,aAAa,CAAC;IACtC;IACA;IACA,OAAO,CAAC5D,IAAI,CAACC,OAAO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAEwE,MAAM,EAAE9D,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertDatasourceDefinition.js","names":["invariant","convertDatasourceDefinition","objectType","properties","baseDatasource","datasources","find","ds","includes","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","direct","directSourceRid","convertPropertySecurityGroups","primaryKeyPropertyApiName","some","objectSecurityPolicy","datasetV3","branchId","groups","rid","security","granular","viewPolicy","granularPolicyCondition","and","conditions","additionalMandatory","markings","assumedMarkingsV2","assumedMarkings","primaryKey","validPropertyNames","Set","usedProperties","forEach","psg","propertyName","has","process","env","NODE_ENV","name","add","objectSecurityPolicyGroup","convertGranularPolicy","granularPolicy","appliedMarkings","filter","property","convertSecurityCondition","condition","c","or","comparison","operator","left","userProperty","groupIds","right","constant","strings","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 MarkingType,\n OntologyIrObjectTypeDatasourceDefinition,\n OntologyIrPropertySecurityGroup,\n OntologyIrPropertySecurityGroups,\n OntologyIrSecurityGroupGranularCondition,\n OntologyIrSecurityGroupGranularSecurityDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type {\n ObjectTypeDatasourceDefinition_dataset,\n ObjectTypeDatasourceDefinition_direct,\n} from \"../../api/object/ObjectTypeDatasourceDefinition.js\";\nimport type { SecurityConditionDefinition } from \"../../api/object/SecurityCondition.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n const baseDatasource = objectType.datasources?.find(ds =>\n [\"dataset\", \"stream\", \"restrictedView\", \"direct\"].includes(ds.type)\n );\n switch (baseDatasource?.type) {\n case \"stream\":\n const window = baseDatasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"derived\":\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"direct\":\n return {\n type: \"direct\",\n direct: {\n directSourceRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n case \"dataset\":\n default:\n if (\n objectType.properties?.some(prop =>\n typeof prop.type === \"object\" && prop.type.type === \"marking\"\n )\n || baseDatasource?.objectSecurityPolicy\n || baseDatasource?.propertySecurityGroups\n ) {\n return {\n type: \"datasetV3\",\n datasetV3: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n branchId: \"master\",\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n }\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction convertPropertySecurityGroups(\n ds:\n | ObjectTypeDatasourceDefinition_dataset\n | ObjectTypeDatasourceDefinition_direct\n | undefined,\n properties: ObjectPropertyType[],\n primaryKeyPropertyApiName: string,\n): OntologyIrPropertySecurityGroups {\n if (\n !ds\n || (!(\"objectSecurityPolicy\" in ds) && !(\"propertySecurityGroups\" in ds))\n ) {\n return {\n groups: [\n {\n properties: properties.map(prop => prop.apiName),\n rid: \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: {\n viewPolicy: {\n granularPolicyCondition: {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: {},\n assumedMarkingsV2: {},\n assumedMarkings: [],\n },\n },\n },\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n },\n ],\n };\n }\n\n const validPropertyNames = new Set(properties.map(prop => prop.apiName));\n const usedProperties = new Set();\n\n ds.propertySecurityGroups?.forEach(psg => {\n psg.properties.forEach(propertyName => {\n invariant(\n validPropertyNames.has(propertyName),\n `Property \"${propertyName}\" in property security group ${psg.name} does not exist in the properties list`,\n );\n invariant(\n !usedProperties.has(propertyName),\n `Property \"${propertyName}\" is used in multiple property security groups`,\n );\n invariant(\n propertyName !== primaryKeyPropertyApiName,\n `Property \"${propertyName}\" in property security group ${psg.name} cannot be the primary key`,\n );\n usedProperties.add(propertyName);\n });\n });\n\n const objectSecurityPolicyGroup: OntologyIrPropertySecurityGroup = {\n rid: ds.objectSecurityPolicy?.name || \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: convertGranularPolicy(\n ds.objectSecurityPolicy?.granularPolicy,\n ds.objectSecurityPolicy?.appliedMarkings,\n ds.objectSecurityPolicy?.assumedMarkings,\n ),\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n properties: properties\n .filter(prop => !usedProperties.has(prop.apiName))\n .map(prop => prop.apiName),\n };\n\n return {\n groups: [\n objectSecurityPolicyGroup,\n ...(ds.propertySecurityGroups?.map(psg => ({\n rid: psg.name,\n security: {\n type: \"granular\" as const,\n granular: convertGranularPolicy(\n psg.granularPolicy,\n psg.appliedMarkings,\n psg.assumedMarkings,\n ),\n },\n type: {\n type: \"property\" as const,\n property: {\n name: psg.name,\n },\n },\n properties: psg.properties ?? [],\n })) ?? []),\n ],\n };\n}\n\nfunction convertGranularPolicy(\n granularPolicy?: SecurityConditionDefinition,\n appliedMarkings?: Record<string, MarkingType>,\n assumedMarkings?: Record<string, MarkingType>,\n): OntologyIrSecurityGroupGranularSecurityDefinition {\n return {\n viewPolicy: {\n granularPolicyCondition: granularPolicy\n ? convertSecurityCondition(granularPolicy)\n : {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: appliedMarkings ?? {},\n assumedMarkings: [],\n assumedMarkingsV2: assumedMarkings ?? {},\n },\n },\n };\n}\n\nfunction convertSecurityCondition(\n condition: SecurityConditionDefinition,\n): OntologyIrSecurityGroupGranularCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"markingProperty\":\n return {\n type: \"markings\",\n markings: {\n property: condition.property,\n },\n };\n case \"groupProperty\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"property\",\n property: condition.property,\n },\n },\n };\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"constant\",\n constant: {\n type: \"strings\",\n strings: [\n condition.name,\n ],\n },\n },\n },\n };\n\n default:\n return condition;\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAStC,OAAO,SAASC,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,MAAMC,cAAc,GAAGF,UAAU,CAACG,WAAW,EAAEC,IAAI,CAACC,EAAE,IACpD,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAACD,EAAE,CAACE,IAAI,CACpE,CAAC;EACD,QAAQL,cAAc,EAAEK,IAAI;IAC1B,KAAK,QAAQ;MACX,MAAMC,MAAM,GAAGN,cAAc,CAACO,eAAe;MAC7C,MAAMC,eAAgC,GAAGF,MAAM,GAC3C;QAAED,IAAI,EAAE,MAAM;QAAEI,IAAI,EAAE;UAAEH;QAAO;MAAE,CAAC,GAClC;QAAED,IAAI,EAAE,MAAM;QAAEK,IAAI,EAAE,CAAC;MAAE,CAAC;MAC9B,MAAMC,eAAe,GAAGC,MAAM,CAACC,WAAW,CACxCd,UAAU,CAACe,GAAG,CACZC,IAAI,IACD,CAACA,IAAI,CAACC,OAAO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E,OAAOS,SAAS;EACpB;AACF;AAEA,SAAS3C,oBAAoBA,CAC3BxB,UAAgC,EACS;EACzC,OAAOa,MAAM,CAACC,WAAW,CACvBd,UAAU,CAACe,GAAG,CAAEC,IAAI,IAAK;IACvB;IACA,IAAIA,IAAI,CAAC8D,QAAQ,EAAE;MACjB,OAAO,CAAC9D,IAAI,CAACC,OAAO,EAAE;QAAEX,IAAI,EAAE,UAAU;QAAEwE,QAAQ,EAAE,CAAC;MAAE,CAAC,CAAC;IAC3D;IACA;IACA,IAAI,OAAO9D,IAAI,CAACV,IAAI,KAAK,QAAQ,IAAIU,IAAI,CAACV,IAAI,EAAEA,IAAI,KAAK,QAAQ,EAAE;MACjE,MAAMyE,aAAa,GAAG;QACpBzE,IAAI,EAAE,QAAQ;QACd0E,MAAM,EAAE;UACNC,MAAM,EAAEjE,IAAI,CAACC,OAAO;UACpBiE,OAAO,EAAErE,MAAM,CAACC,WAAW,CACzBD,MAAM,CAACsE,IAAI,CAACnE,IAAI,CAACV,IAAI,CAAC8E,gBAAgB,CAAC,CAACrE,GAAG,CAAEsE,SAAS,IAAK,CACzDA,SAAS,EACT;YAAEpE,OAAO,EAAEoE,SAAS;YAAEC,QAAQ,EAAE,CAAC;UAAE,CAAC,CACrC,CACH;QACF;MACF,CAAC;MACD,OAAO,CAACtE,IAAI,CAACC,OAAO,EAAE8D,aAAa,CAAC;IACtC;IACA;IACA,OAAO,CAAC/D,IAAI,CAACC,OAAO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAE2E,MAAM,EAAEjE,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -41,7 +41,8 @@ export function convertInterface(interfaceType) {
|
|
|
41
41
|
extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),
|
|
42
42
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
43
43
|
properties: [],
|
|
44
|
-
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
|
|
44
|
+
propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName))),
|
|
45
|
+
extendsInterfacesMetadata: interfaceType.extendsInterfaces.map(i => convertInterface(i))
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
//# sourceMappingURL=convertInterface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertInterface.js","names":["convertInterfaceProperty","convertSpt","convertInterface","interfaceType","__type","other","propertiesV2","Object","fromEntries","values","map","spt","sharedPropertyType","apiName","required","displayMetadata","displayName","description","icon","type","blueprint","color","locator","extendsInterfaces","i","properties","propertiesV3","entries","prop"],"sources":["convertInterface.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 { OntologyIrMarketplaceInterfaceType } from \"@osdk/client.unstable\";\nimport type { InterfaceType } from \"../../api/interface/InterfaceType.js\";\nimport { convertInterfaceProperty } from \"./convertInterfacePropertyType.js\";\nimport { convertSpt } from \"./convertSpt.js\";\n\nexport function convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrMarketplaceInterfaceType {\n const { __type, ...other } = interfaceType;\n return {\n ...other,\n propertiesV2: Object.fromEntries(\n Object.values(interfaceType.propertiesV2)\n .map((\n spt,\n ) => [spt.sharedPropertyType.apiName, {\n required: spt.required,\n sharedPropertyType: convertSpt(spt.sharedPropertyType),\n }]),\n ),\n displayMetadata: {\n displayName: interfaceType.displayMetadata.displayName,\n description: interfaceType.displayMetadata.description,\n icon: interfaceType.displayMetadata.icon ?? {\n type: \"blueprint\",\n blueprint: { color: \"#4C90F0\", locator: \"layout-hierarchy\" },\n },\n },\n extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),\n // these are omitted from our internal types but we need to re-add them for the final json\n properties: [],\n propertiesV3: Object.fromEntries(\n Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) =>\n convertInterfaceProperty(prop, apiName)\n ),\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,SAASC,gBAAgBA,CAC9BC,aAA4B,EACQ;EACpC,MAAM;IAAEC,MAAM;IAAE,GAAGC;EAAM,CAAC,GAAGF,aAAa;EAC1C,OAAO;IACL,GAAGE,KAAK;IACRC,YAAY,EAAEC,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,MAAM,CAACN,aAAa,CAACG,YAAY,CAAC,CACtCI,GAAG,CACFC,GAAG,IACA,CAACA,GAAG,CAACC,kBAAkB,CAACC,OAAO,EAAE;MACpCC,QAAQ,EAAEH,GAAG,CAACG,QAAQ;MACtBF,kBAAkB,EAAEX,UAAU,CAACU,GAAG,CAACC,kBAAkB;IACvD,CAAC,CAAC,CACN,CAAC;IACDG,eAAe,EAAE;MACfC,WAAW,EAAEb,aAAa,CAACY,eAAe,CAACC,WAAW;MACtDC,WAAW,EAAEd,aAAa,CAACY,eAAe,CAACE,WAAW;MACtDC,IAAI,EAAEf,aAAa,CAACY,eAAe,CAACG,IAAI,IAAI;QAC1CC,IAAI,EAAE,WAAW;QACjBC,SAAS,EAAE;UAAEC,KAAK,EAAE,SAAS;UAAEC,OAAO,EAAE;QAAmB;MAC7D;IACF,CAAC;IACDC,iBAAiB,EAAEpB,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAAIA,CAAC,CAACX,OAAO,CAAC;IACtE;IACAY,UAAU,EAAE,EAAE;IACdC,YAAY,EAAEnB,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACoB,OAAO,CAACxB,aAAa,CAACuB,YAAY,CAAC,CAAChB,GAAG,CAAC,CAAC,CAACG,OAAO,EAAEe,IAAI,CAAC,KAC7D5B,wBAAwB,CAAC4B,IAAI,EAAEf,OAAO,CACxC,CACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertInterface.js","names":["convertInterfaceProperty","convertSpt","convertInterface","interfaceType","__type","other","propertiesV2","Object","fromEntries","values","map","spt","sharedPropertyType","apiName","required","displayMetadata","displayName","description","icon","type","blueprint","color","locator","extendsInterfaces","i","properties","propertiesV3","entries","prop","extendsInterfacesMetadata"],"sources":["convertInterface.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 { OntologyIrMarketplaceInterfaceType } from \"@osdk/client.unstable\";\nimport type { InterfaceType } from \"../../api/interface/InterfaceType.js\";\nimport { convertInterfaceProperty } from \"./convertInterfacePropertyType.js\";\nimport { convertSpt } from \"./convertSpt.js\";\n\nexport function convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrMarketplaceInterfaceType {\n const { __type, ...other } = interfaceType;\n return {\n ...other,\n propertiesV2: Object.fromEntries(\n Object.values(interfaceType.propertiesV2)\n .map((\n spt,\n ) => [spt.sharedPropertyType.apiName, {\n required: spt.required,\n sharedPropertyType: convertSpt(spt.sharedPropertyType),\n }]),\n ),\n displayMetadata: {\n displayName: interfaceType.displayMetadata.displayName,\n description: interfaceType.displayMetadata.description,\n icon: interfaceType.displayMetadata.icon ?? {\n type: \"blueprint\",\n blueprint: { color: \"#4C90F0\", locator: \"layout-hierarchy\" },\n },\n },\n extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),\n // these are omitted from our internal types but we need to re-add them for the final json\n properties: [],\n propertiesV3: Object.fromEntries(\n Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) =>\n convertInterfaceProperty(prop, apiName)\n ),\n ),\n extendsInterfacesMetadata: interfaceType.extendsInterfaces.map(i =>\n convertInterface(i)\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,SAASC,gBAAgBA,CAC9BC,aAA4B,EACQ;EACpC,MAAM;IAAEC,MAAM;IAAE,GAAGC;EAAM,CAAC,GAAGF,aAAa;EAC1C,OAAO;IACL,GAAGE,KAAK;IACRC,YAAY,EAAEC,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,MAAM,CAACN,aAAa,CAACG,YAAY,CAAC,CACtCI,GAAG,CACFC,GAAG,IACA,CAACA,GAAG,CAACC,kBAAkB,CAACC,OAAO,EAAE;MACpCC,QAAQ,EAAEH,GAAG,CAACG,QAAQ;MACtBF,kBAAkB,EAAEX,UAAU,CAACU,GAAG,CAACC,kBAAkB;IACvD,CAAC,CAAC,CACN,CAAC;IACDG,eAAe,EAAE;MACfC,WAAW,EAAEb,aAAa,CAACY,eAAe,CAACC,WAAW;MACtDC,WAAW,EAAEd,aAAa,CAACY,eAAe,CAACE,WAAW;MACtDC,IAAI,EAAEf,aAAa,CAACY,eAAe,CAACG,IAAI,IAAI;QAC1CC,IAAI,EAAE,WAAW;QACjBC,SAAS,EAAE;UAAEC,KAAK,EAAE,SAAS;UAAEC,OAAO,EAAE;QAAmB;MAC7D;IACF,CAAC;IACDC,iBAAiB,EAAEpB,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAAIA,CAAC,CAACX,OAAO,CAAC;IACtE;IACAY,UAAU,EAAE,EAAE;IACdC,YAAY,EAAEnB,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACoB,OAAO,CAACxB,aAAa,CAACuB,YAAY,CAAC,CAAChB,GAAG,CAAC,CAAC,CAACG,OAAO,EAAEe,IAAI,CAAC,KAC7D5B,wBAAwB,CAAC4B,IAAI,EAAEf,OAAO,CACxC,CACF,CAAC;IACDgB,yBAAyB,EAAE1B,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAC9DtB,gBAAgB,CAACsB,CAAC,CACpB;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { isStruct } from "../../api/properties/PropertyTypeType.js";
|
|
18
|
+
import { propertyTypeTypeToOntologyIrType } from "./propertyTypeTypeToOntologyIrType.js";
|
|
19
|
+
export function convertMainValue(type, apiName, sharedPropertyType) {
|
|
20
|
+
if (sharedPropertyType && isStruct(sharedPropertyType.type) && sharedPropertyType.type.mainValue) {
|
|
21
|
+
return {
|
|
22
|
+
fieldApiNames: Array.isArray(sharedPropertyType.type.mainValue.fields) ? sharedPropertyType.type.mainValue.fields : [sharedPropertyType.type.mainValue.fields],
|
|
23
|
+
structApiName: sharedPropertyType.apiName,
|
|
24
|
+
type: propertyTypeTypeToOntologyIrType(sharedPropertyType.type.mainValue.type)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (isStruct(type) && type.mainValue) {
|
|
28
|
+
return {
|
|
29
|
+
fieldApiNames: Array.isArray(type.mainValue.fields) ? type.mainValue.fields : [type.mainValue.fields],
|
|
30
|
+
structApiName: apiName,
|
|
31
|
+
type: propertyTypeTypeToOntologyIrType(type.mainValue.type)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=convertMainValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertMainValue.js","names":["isStruct","propertyTypeTypeToOntologyIrType","convertMainValue","type","apiName","sharedPropertyType","mainValue","fieldApiNames","Array","isArray","fields","structApiName","undefined"],"sources":["convertMainValue.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 { OntologyIrStructMainValue } from \"@osdk/client.unstable\";\nimport {\n isStruct,\n type PropertyTypeType,\n} from \"../../api/properties/PropertyTypeType.js\";\nimport type { SharedPropertyType } from \"../../api/properties/SharedPropertyType.js\";\nimport { propertyTypeTypeToOntologyIrType } from \"./propertyTypeTypeToOntologyIrType.js\";\n\nexport function convertMainValue(\n type: PropertyTypeType,\n apiName?: string,\n sharedPropertyType?: SharedPropertyType,\n): OntologyIrStructMainValue | undefined {\n if (\n sharedPropertyType && isStruct(sharedPropertyType.type)\n && sharedPropertyType.type.mainValue\n ) {\n return {\n fieldApiNames: Array.isArray(sharedPropertyType.type.mainValue.fields)\n ? sharedPropertyType.type.mainValue.fields\n : [sharedPropertyType.type.mainValue.fields],\n structApiName: sharedPropertyType.apiName,\n type: propertyTypeTypeToOntologyIrType(\n sharedPropertyType.type.mainValue.type,\n ),\n };\n }\n if (isStruct(type) && type.mainValue) {\n return {\n fieldApiNames: Array.isArray(type.mainValue.fields)\n ? type.mainValue.fields\n : [type.mainValue.fields],\n structApiName: apiName!,\n type: propertyTypeTypeToOntologyIrType(type.mainValue.type),\n };\n }\n\n return undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,QAAQ,QAEH,0CAA0C;AAEjD,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,OAAO,SAASC,gBAAgBA,CAC9BC,IAAsB,EACtBC,OAAgB,EAChBC,kBAAuC,EACA;EACvC,IACEA,kBAAkB,IAAIL,QAAQ,CAACK,kBAAkB,CAACF,IAAI,CAAC,IACpDE,kBAAkB,CAACF,IAAI,CAACG,SAAS,EACpC;IACA,OAAO;MACLC,aAAa,EAAEC,KAAK,CAACC,OAAO,CAACJ,kBAAkB,CAACF,IAAI,CAACG,SAAS,CAACI,MAAM,CAAC,GAClEL,kBAAkB,CAACF,IAAI,CAACG,SAAS,CAACI,MAAM,GACxC,CAACL,kBAAkB,CAACF,IAAI,CAACG,SAAS,CAACI,MAAM,CAAC;MAC9CC,aAAa,EAAEN,kBAAkB,CAACD,OAAO;MACzCD,IAAI,EAAEF,gCAAgC,CACpCI,kBAAkB,CAACF,IAAI,CAACG,SAAS,CAACH,IACpC;IACF,CAAC;EACH;EACA,IAAIH,QAAQ,CAACG,IAAI,CAAC,IAAIA,IAAI,CAACG,SAAS,EAAE;IACpC,OAAO;MACLC,aAAa,EAAEC,KAAK,CAACC,OAAO,CAACN,IAAI,CAACG,SAAS,CAACI,MAAM,CAAC,GAC/CP,IAAI,CAACG,SAAS,CAACI,MAAM,GACrB,CAACP,IAAI,CAACG,SAAS,CAACI,MAAM,CAAC;MAC3BC,aAAa,EAAEP,OAAQ;MACvBD,IAAI,EAAEF,gCAAgC,CAACE,IAAI,CAACG,SAAS,CAACH,IAAI;IAC5D,CAAC;EACH;EAEA,OAAOS,SAAS;AAClB","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ import invariant from "tiny-invariant";
|
|
|
18
18
|
import { convertObjectStatus, namespace } from "../../api/defineOntology.js";
|
|
19
19
|
import { defaultTypeClasses, getPropertyTypeName, hasRenderHints, shouldBeIndexedForSearch, shouldNotHaveRenderHints } from "../../api/propertyConversionUtils.js";
|
|
20
20
|
import { convertNullabilityToDataConstraint } from "./convertNullabilityToDataConstraint.js";
|
|
21
|
+
import { convertReducers } from "./convertReducers.js";
|
|
21
22
|
import { convertValueType } from "./convertValueType.js";
|
|
22
23
|
import { convertValueTypeDataConstraints } from "./convertValueTypeDataConstraints.js";
|
|
23
24
|
import { propertyTypeTypeToOntologyIrType } from "./propertyTypeTypeToOntologyIrType.js";
|
|
@@ -38,10 +39,10 @@ export function convertObjectPropertyType(property) {
|
|
|
38
39
|
type: property.array ? {
|
|
39
40
|
type: "array",
|
|
40
41
|
array: {
|
|
41
|
-
subtype: propertyTypeTypeToOntologyIrType(property.type),
|
|
42
|
-
reducers: []
|
|
42
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type, property.apiName, property.sharedPropertyType),
|
|
43
|
+
reducers: convertReducers(property.type, property.apiName, property.reducers ?? [], property.sharedPropertyType)
|
|
43
44
|
}
|
|
44
|
-
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
45
|
+
} : propertyTypeTypeToOntologyIrType(property.type, property.apiName),
|
|
45
46
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
46
47
|
status: convertObjectStatus(property.status),
|
|
47
48
|
inlineAction: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertObjectPropertyType.js","names":["invariant","convertObjectStatus","namespace","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldBeIndexedForSearch","shouldNotHaveRenderHints","convertNullabilityToDataConstraint","convertValueType","convertValueTypeDataConstraints","propertyTypeTypeToOntologyIrType","convertObjectPropertyType","property","apiName","type","typeClasses","process","env","NODE_ENV","output","sharedPropertyTypeApiName","sharedPropertyType","displayMetadata","displayName","description","visibility","indexedForSearch","ruleSetBinding","undefined","baseFormatter","array","subtype","reducers","status","inlineAction","dataConstraints","valueType","constraints","sharedPropertyTypeRid"],"sources":["convertObjectPropertyType.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 { OntologyIrPropertyType } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { convertObjectStatus, namespace } from \"../../api/defineOntology.js\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldBeIndexedForSearch,\n shouldNotHaveRenderHints,\n} from \"../../api/propertyConversionUtils.js\";\nimport { convertNullabilityToDataConstraint } from \"./convertNullabilityToDataConstraint.js\";\nimport { convertValueType } from \"./convertValueType.js\";\nimport { convertValueTypeDataConstraints } from \"./convertValueTypeDataConstraints.js\";\nimport { propertyTypeTypeToOntologyIrType } from \"./propertyTypeTypeToOntologyIrType.js\";\n\nexport function convertObjectPropertyType(\n property: ObjectPropertyType,\n): OntologyIrPropertyType {\n const apiName = namespace + property.apiName;\n invariant(\n !shouldNotHaveRenderHints(property.type)\n || !hasRenderHints(property.typeClasses),\n `Property type ${apiName} of type '${\n getPropertyTypeName(property.type)\n }' should not have render hints`,\n );\n const output: OntologyIrPropertyType = {\n apiName: property.apiName,\n sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,\n displayMetadata: {\n displayName: property.displayName,\n description: property.description,\n visibility: property.visibility ?? \"NORMAL\",\n },\n indexedForSearch: property.indexedForSearch\n ?? shouldBeIndexedForSearch(property.type),\n ruleSetBinding: undefined,\n baseFormatter: property.baseFormatter,\n type: property.array\n ? {\n type: \"array\" as const,\n array: {\n subtype: propertyTypeTypeToOntologyIrType(property.type),\n reducers: [],\n },\n }\n : propertyTypeTypeToOntologyIrType(property.type),\n typeClasses: property.typeClasses\n ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),\n status: convertObjectStatus(property.status),\n inlineAction: undefined,\n dataConstraints: property.valueType\n ? convertValueTypeDataConstraints(property.valueType.constraints)\n : convertNullabilityToDataConstraint(property),\n sharedPropertyTypeRid: property.sharedPropertyType?.apiName,\n valueType: property.valueType\n ? convertValueType(property.valueType)\n : undefined,\n };\n return output;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,mBAAmB,EAAEC,SAAS,QAAQ,6BAA6B;AAE5E,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,wBAAwB,QACnB,sCAAsC;AAC7C,SAASC,kCAAkC,QAAQ,yCAAyC;AAC5F,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,+BAA+B,QAAQ,sCAAsC;AACtF,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,OAAO,SAASC,yBAAyBA,CACvCC,QAA4B,EACJ;EACxB,MAAMC,OAAO,
|
|
1
|
+
{"version":3,"file":"convertObjectPropertyType.js","names":["invariant","convertObjectStatus","namespace","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldBeIndexedForSearch","shouldNotHaveRenderHints","convertNullabilityToDataConstraint","convertReducers","convertValueType","convertValueTypeDataConstraints","propertyTypeTypeToOntologyIrType","convertObjectPropertyType","property","apiName","type","typeClasses","process","env","NODE_ENV","output","sharedPropertyTypeApiName","sharedPropertyType","displayMetadata","displayName","description","visibility","indexedForSearch","ruleSetBinding","undefined","baseFormatter","array","subtype","reducers","status","inlineAction","dataConstraints","valueType","constraints","sharedPropertyTypeRid"],"sources":["convertObjectPropertyType.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 { OntologyIrPropertyType } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { convertObjectStatus, namespace } from \"../../api/defineOntology.js\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldBeIndexedForSearch,\n shouldNotHaveRenderHints,\n} from \"../../api/propertyConversionUtils.js\";\nimport { convertNullabilityToDataConstraint } from \"./convertNullabilityToDataConstraint.js\";\nimport { convertReducers } from \"./convertReducers.js\";\nimport { convertValueType } from \"./convertValueType.js\";\nimport { convertValueTypeDataConstraints } from \"./convertValueTypeDataConstraints.js\";\nimport { propertyTypeTypeToOntologyIrType } from \"./propertyTypeTypeToOntologyIrType.js\";\n\nexport function convertObjectPropertyType(\n property: ObjectPropertyType,\n): OntologyIrPropertyType {\n const apiName = namespace + property.apiName;\n invariant(\n !shouldNotHaveRenderHints(property.type)\n || !hasRenderHints(property.typeClasses),\n `Property type ${apiName} of type '${\n getPropertyTypeName(property.type)\n }' should not have render hints`,\n );\n const output: OntologyIrPropertyType = {\n apiName: property.apiName,\n sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,\n displayMetadata: {\n displayName: property.displayName,\n description: property.description,\n visibility: property.visibility ?? \"NORMAL\",\n },\n indexedForSearch: property.indexedForSearch\n ?? shouldBeIndexedForSearch(property.type),\n ruleSetBinding: undefined,\n baseFormatter: property.baseFormatter,\n type: property.array\n ? {\n type: \"array\" as const,\n array: {\n subtype: propertyTypeTypeToOntologyIrType(\n property.type,\n property.apiName,\n property.sharedPropertyType,\n ),\n reducers: convertReducers(\n property.type,\n property.apiName,\n property.reducers ?? [],\n property.sharedPropertyType,\n ),\n },\n }\n : propertyTypeTypeToOntologyIrType(property.type, property.apiName),\n typeClasses: property.typeClasses\n ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),\n status: convertObjectStatus(property.status),\n inlineAction: undefined,\n dataConstraints: property.valueType\n ? convertValueTypeDataConstraints(property.valueType.constraints)\n : convertNullabilityToDataConstraint(property),\n sharedPropertyTypeRid: property.sharedPropertyType?.apiName,\n valueType: property.valueType\n ? convertValueType(property.valueType)\n : undefined,\n };\n return output;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,mBAAmB,EAAEC,SAAS,QAAQ,6B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EACbF,QAAQ,CAACC,OAAO,EAChBD,QAAQ,CAACS,kBACX,CAAC;QACDW,QAAQ,EAAEzB,eAAe,CACvBK,QAAQ,CAACE,IAAI,EACbF,QAAQ,CAACC,OAAO,EAChBD,QAAQ,CAACoB,QAAQ,IAAI,EAAE,EACvBpB,QAAQ,CAACS,kBACX;MACF;IACF,CAAC,GACCX,gCAAgC,CAACE,QAAQ,CAACE,IAAI,EAAEF,QAAQ,CAACC,OAAO,CAAC;IACrEE,WAAW,EAAEH,QAAQ,CAACG,WAAW,KAC3BV,wBAAwB,CAACO,QAAQ,CAACE,IAAI,CAAC,GAAG,EAAE,GAAGb,kBAAkB,CAAC;IACxEgC,MAAM,EAAElC,mBAAmB,CAACa,QAAQ,CAACqB,MAAM,CAAC;IAC5CC,YAAY,EAAEN,SAAS;IACvBO,eAAe,EAAEvB,QAAQ,CAACwB,SAAS,GAC/B3B,+BAA+B,CAACG,QAAQ,CAACwB,SAAS,CAACC,WAAW,CAAC,GAC/D/B,kCAAkC,CAACM,QAAQ,CAAC;IAChD0B,qBAAqB,EAAE1B,QAAQ,CAACS,kBAAkB,EAAER,OAAO;IAC3DuB,SAAS,EAAExB,QAAQ,CAACwB,SAAS,GACzB5B,gBAAgB,CAACI,QAAQ,CAACwB,SAAS,CAAC,GACpCR;EACN,CAAC;EACD,OAAOT,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
import { isStruct } from "../../api/properties/PropertyTypeType.js";
|
|
19
|
+
export function convertReducers(type, apiName, reducers, sharedPropertyType) {
|
|
20
|
+
reducers?.forEach(reducer => {
|
|
21
|
+
if (reducer.structField) {
|
|
22
|
+
!(isStruct(type) && Object.keys(type.structDefinition).includes(reducer.structField)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Reducer structField ${reducer.structField} does not exist in struct definition`) : invariant(false) : void 0;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (sharedPropertyType) {
|
|
26
|
+
return mapReducers(sharedPropertyType.apiName, sharedPropertyType.reducers);
|
|
27
|
+
} else {
|
|
28
|
+
return mapReducers(apiName, reducers);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function mapReducers(apiName, reducers) {
|
|
32
|
+
return reducers?.map(reducer => {
|
|
33
|
+
switch (reducer.direction) {
|
|
34
|
+
case "ascending":
|
|
35
|
+
return {
|
|
36
|
+
direction: "ASCENDING_NULLS_LAST",
|
|
37
|
+
structApiName: reducer.structField ? apiName : undefined,
|
|
38
|
+
fieldApiName: reducer.structField
|
|
39
|
+
};
|
|
40
|
+
case "descending":
|
|
41
|
+
return {
|
|
42
|
+
direction: "DESCENDING_NULLS_LAST",
|
|
43
|
+
structApiName: reducer.structField ? apiName : undefined,
|
|
44
|
+
fieldApiName: reducer.structField
|
|
45
|
+
};
|
|
46
|
+
default:
|
|
47
|
+
{
|
|
48
|
+
throw new Error(`Unsupported reducer direction: ${reducer.direction}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}) ?? [];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=convertReducers.js.map
|