@osdk/maker 0.13.0-beta.9 → 0.14.0-beta.2
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 +91 -0
- package/README.md +55 -13
- package/build/browser/api/action/ActionLevelValidationDefinition.js +2 -0
- package/build/browser/api/action/ActionLevelValidationDefinition.js.map +1 -0
- package/build/browser/api/action/ActionParameter.js +2 -0
- package/build/browser/api/action/ActionParameter.js.map +1 -0
- package/build/browser/api/action/ActionParameterAllowedValues.js +2 -0
- package/build/browser/api/action/ActionParameterAllowedValues.js.map +1 -0
- package/build/browser/api/action/ActionParameterConditionalOverride.js +2 -0
- package/build/browser/api/action/ActionParameterConditionalOverride.js.map +1 -0
- package/build/browser/api/action/ActionParameterConfiguration.js +2 -0
- package/build/browser/api/action/ActionParameterConfiguration.js.map +1 -0
- package/build/browser/api/action/ActionParameterType.js +22 -0
- package/build/browser/api/action/ActionParameterType.js.map +1 -0
- package/build/browser/api/action/ActionSection.js +2 -0
- package/build/browser/api/action/ActionSection.js.map +1 -0
- package/build/browser/api/action/ActionStatus.js +2 -0
- package/build/browser/api/action/ActionStatus.js.map +1 -0
- package/build/browser/api/action/ActionType.js +2 -0
- package/build/browser/api/action/ActionType.js.map +1 -0
- package/build/browser/api/action/ActionValidationRule.js +2 -0
- package/build/browser/api/action/ActionValidationRule.js.map +1 -0
- package/build/browser/api/action/ConditionDefinition.js +2 -0
- package/build/browser/api/action/ConditionDefinition.js.map +1 -0
- package/build/browser/api/action/MappingValue.js +2 -0
- package/build/browser/api/action/MappingValue.js.map +1 -0
- package/build/browser/api/action/SectionConditionalOverride.js +2 -0
- package/build/browser/api/action/SectionConditionalOverride.js.map +1 -0
- package/build/browser/api/action/SubmissionMetadata.js +2 -0
- package/build/browser/api/action/SubmissionMetadata.js.map +1 -0
- package/build/browser/api/common/BlueprintIcons.js +2 -0
- package/build/browser/api/common/BlueprintIcons.js.map +1 -0
- package/build/browser/api/common/OntologyDefinition.js +2 -0
- package/build/browser/api/common/OntologyDefinition.js.map +1 -0
- package/build/browser/api/common/OntologyEntityBase.js +2 -0
- package/build/browser/api/common/OntologyEntityBase.js.map +1 -0
- package/build/browser/api/{types.js → common/OntologyEntityTypeEnum.js} +2 -8
- package/build/browser/api/common/OntologyEntityTypeEnum.js.map +1 -0
- package/build/browser/api/common/OntologyEntityTypeMapping.js +2 -0
- package/build/browser/api/common/OntologyEntityTypeMapping.js.map +1 -0
- package/build/browser/api/common/TypeClass.js +2 -0
- package/build/browser/api/common/TypeClass.js.map +1 -0
- package/build/browser/api/defineAction.js +69 -46
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineInterface.js +14 -34
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +3 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineLink.js +33 -12
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.js +9 -29
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +17 -552
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +1 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/importOntologyEntity.js +1 -1
- package/build/browser/api/importOntologyEntity.js.map +1 -1
- package/build/browser/api/{defineImportSpt.js → importSharedPropertyType.js} +2 -3
- package/build/browser/api/importSharedPropertyType.js.map +1 -0
- package/build/browser/api/interface/InterfacePropertyType.js +2 -0
- package/build/browser/api/interface/InterfacePropertyType.js.map +1 -0
- package/build/browser/api/interface/InterfaceType.js +2 -0
- package/build/browser/api/interface/InterfaceType.js.map +1 -0
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js +27 -0
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js.map +1 -0
- package/build/browser/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js +42 -0
- package/build/browser/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js.map +1 -0
- package/build/browser/api/links/LinkType.js +2 -0
- package/build/browser/api/links/LinkType.js.map +1 -0
- package/build/browser/api/namespace/combineApiNamespaceIfMissing.js +20 -0
- package/build/browser/api/namespace/combineApiNamespaceIfMissing.js.map +1 -0
- package/build/browser/api/object/InterfaceImplementation.js +2 -0
- package/build/browser/api/object/InterfaceImplementation.js.map +1 -0
- package/build/browser/api/object/ObjectPropertyType.js +2 -0
- package/build/browser/api/object/ObjectPropertyType.js.map +1 -0
- package/build/browser/api/object/ObjectPropertyTypeUserDefinition.js +2 -0
- package/build/browser/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -0
- package/build/browser/api/object/ObjectType.js +2 -0
- package/build/browser/api/object/ObjectType.js.map +1 -0
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js +2 -0
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -0
- package/build/browser/api/object/ObjectTypeDefinition.js +2 -0
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -0
- package/build/browser/api/object/ObjectTypeStatus.js +2 -0
- package/build/browser/api/object/ObjectTypeStatus.js.map +1 -0
- package/build/browser/api/objectStatus.test.js.map +1 -1
- package/build/browser/api/overall.test.js +1987 -691
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/properties/Nullability.js +2 -0
- package/build/browser/api/properties/Nullability.js.map +1 -0
- package/build/browser/api/properties/PropertyTypeType.js +34 -0
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -0
- package/build/browser/api/properties/SharedPropertyType.js +2 -0
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -0
- package/build/browser/api/propertyConversionUtils.js +0 -238
- package/build/browser/api/propertyConversionUtils.js.map +1 -1
- package/build/browser/api/values/ValueTypeDefinitionVersion.js +2 -0
- package/build/browser/api/values/ValueTypeDefinitionVersion.js.map +1 -0
- package/build/browser/api/values/ValueTypeType.js +2 -0
- package/build/browser/api/values/ValueTypeType.js.map +1 -0
- package/build/browser/api/wrapWithProxy.js +1 -0
- package/build/browser/api/wrapWithProxy.js.map +1 -1
- package/build/browser/cli/main.js +13 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toConjure/distributeTypeHelper.js +23 -0
- package/build/browser/conversion/toConjure/distributeTypeHelper.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +88 -0
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertActionParameters.js +31 -0
- package/build/browser/conversion/toMarketplace/convertActionParameters.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertActionSections.js +43 -0
- package/build/browser/conversion/toMarketplace/convertActionSections.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +93 -0
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertActionVisibility.js +41 -0
- package/build/browser/conversion/toMarketplace/convertActionVisibility.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertCardinality.js +23 -0
- package/build/browser/conversion/toMarketplace/convertCardinality.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +88 -0
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertDataConstraintToDataConstraints.js +26 -0
- package/build/browser/conversion/toMarketplace/convertDataConstraintToDataConstraints.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +89 -0
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertInterface.js +47 -0
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertLink.js +132 -0
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js +41 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertNullabilityToDataConstraint.js +43 -0
- package/build/browser/conversion/toMarketplace/convertNullabilityToDataConstraint.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObject.js +108 -0
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +53 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertOntologyDefinition.js +29 -0
- package/build/browser/conversion/toMarketplace/convertOntologyDefinition.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +57 -0
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertOntologyToValueTypeIr.js +24 -0
- package/build/browser/conversion/toMarketplace/convertOntologyToValueTypeIr.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +35 -0
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js +62 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertValueType.js +25 -0
- package/build/browser/conversion/toMarketplace/convertValueType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertValueTypeDataConstraints.js +30 -0
- package/build/browser/conversion/toMarketplace/convertValueTypeDataConstraints.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertValueTypesToIr.js +34 -0
- package/build/browser/conversion/toMarketplace/convertValueTypesToIr.js.map +1 -0
- package/build/browser/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.js +83 -0
- package/build/browser/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.js.map +1 -0
- package/build/browser/conversion/toMarketplace/getFormContentOrdering.js +39 -0
- package/build/browser/conversion/toMarketplace/getFormContentOrdering.js.map +1 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +124 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -0
- package/build/browser/index.js +5 -5
- package/build/browser/index.js.map +1 -1
- package/build/browser/util/OptionalFields.js +2 -0
- package/build/browser/util/OptionalFields.js.map +1 -0
- package/build/browser/util/RequiredFields.js +2 -0
- package/build/browser/util/RequiredFields.js.map +1 -0
- package/build/cjs/index.cjs +1177 -1045
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +417 -346
- package/build/esm/api/action/ActionLevelValidationDefinition.js +2 -0
- package/build/esm/api/action/ActionLevelValidationDefinition.js.map +1 -0
- package/build/esm/api/action/ActionParameter.js +2 -0
- package/build/esm/api/action/ActionParameter.js.map +1 -0
- package/build/esm/api/action/ActionParameterAllowedValues.js +2 -0
- package/build/esm/api/action/ActionParameterAllowedValues.js.map +1 -0
- package/build/esm/api/action/ActionParameterConditionalOverride.js +2 -0
- package/build/esm/api/action/ActionParameterConditionalOverride.js.map +1 -0
- package/build/esm/api/action/ActionParameterConfiguration.js +2 -0
- package/build/esm/api/action/ActionParameterConfiguration.js.map +1 -0
- package/build/esm/api/action/ActionParameterType.js +22 -0
- package/build/esm/api/action/ActionParameterType.js.map +1 -0
- package/build/esm/api/action/ActionSection.js +2 -0
- package/build/esm/api/action/ActionSection.js.map +1 -0
- package/build/esm/api/action/ActionStatus.js +2 -0
- package/build/esm/api/action/ActionStatus.js.map +1 -0
- package/build/esm/api/action/ActionType.js +2 -0
- package/build/esm/api/action/ActionType.js.map +1 -0
- package/build/esm/api/action/ActionValidationRule.js +2 -0
- package/build/esm/api/action/ActionValidationRule.js.map +1 -0
- package/build/esm/api/action/ConditionDefinition.js +2 -0
- package/build/esm/api/action/ConditionDefinition.js.map +1 -0
- package/build/esm/api/action/MappingValue.js +2 -0
- package/build/esm/api/action/MappingValue.js.map +1 -0
- package/build/esm/api/action/SectionConditionalOverride.js +2 -0
- package/build/esm/api/action/SectionConditionalOverride.js.map +1 -0
- package/build/esm/api/action/SubmissionMetadata.js +2 -0
- package/build/esm/api/action/SubmissionMetadata.js.map +1 -0
- package/build/esm/api/common/BlueprintIcons.js +2 -0
- package/build/esm/api/common/BlueprintIcons.js.map +1 -0
- package/build/esm/api/common/OntologyDefinition.js +2 -0
- package/build/esm/api/common/OntologyDefinition.js.map +1 -0
- package/build/esm/api/common/OntologyEntityBase.js +2 -0
- package/build/esm/api/common/OntologyEntityBase.js.map +1 -0
- package/build/esm/api/{types.js → common/OntologyEntityTypeEnum.js} +2 -8
- package/build/esm/api/common/OntologyEntityTypeEnum.js.map +1 -0
- package/build/esm/api/common/OntologyEntityTypeMapping.js +2 -0
- package/build/esm/api/common/OntologyEntityTypeMapping.js.map +1 -0
- package/build/esm/api/common/TypeClass.js +2 -0
- package/build/esm/api/common/TypeClass.js.map +1 -0
- package/build/esm/api/defineAction.js +69 -46
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineInterface.js +14 -34
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +3 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineLink.js +33 -12
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.js +9 -29
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +17 -552
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +1 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/importOntologyEntity.js +1 -1
- package/build/esm/api/importOntologyEntity.js.map +1 -1
- package/build/esm/api/{defineImportSpt.js → importSharedPropertyType.js} +2 -3
- package/build/esm/api/importSharedPropertyType.js.map +1 -0
- package/build/esm/api/interface/InterfacePropertyType.js +2 -0
- package/build/esm/api/interface/InterfacePropertyType.js.map +1 -0
- package/build/esm/api/interface/InterfaceType.js +2 -0
- package/build/esm/api/interface/InterfaceType.js.map +1 -0
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js +27 -0
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js.map +1 -0
- package/build/esm/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js +42 -0
- package/build/esm/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.js.map +1 -0
- package/build/esm/api/links/LinkType.js +2 -0
- package/build/esm/api/links/LinkType.js.map +1 -0
- package/build/esm/api/namespace/combineApiNamespaceIfMissing.js +20 -0
- package/build/esm/api/namespace/combineApiNamespaceIfMissing.js.map +1 -0
- package/build/esm/api/object/InterfaceImplementation.js +2 -0
- package/build/esm/api/object/InterfaceImplementation.js.map +1 -0
- package/build/esm/api/object/ObjectPropertyType.js +2 -0
- package/build/esm/api/object/ObjectPropertyType.js.map +1 -0
- package/build/esm/api/object/ObjectPropertyTypeUserDefinition.js +2 -0
- package/build/esm/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -0
- package/build/esm/api/object/ObjectType.js +2 -0
- package/build/esm/api/object/ObjectType.js.map +1 -0
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js +2 -0
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -0
- package/build/esm/api/object/ObjectTypeDefinition.js +2 -0
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -0
- package/build/esm/api/object/ObjectTypeStatus.js +2 -0
- package/build/esm/api/object/ObjectTypeStatus.js.map +1 -0
- package/build/esm/api/objectStatus.test.js.map +1 -1
- package/build/esm/api/overall.test.js +1987 -691
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/properties/Nullability.js +2 -0
- package/build/esm/api/properties/Nullability.js.map +1 -0
- package/build/esm/api/properties/PropertyTypeType.js +34 -0
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -0
- package/build/esm/api/properties/SharedPropertyType.js +2 -0
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -0
- package/build/esm/api/propertyConversionUtils.js +0 -238
- package/build/esm/api/propertyConversionUtils.js.map +1 -1
- package/build/esm/api/values/ValueTypeDefinitionVersion.js +2 -0
- package/build/esm/api/values/ValueTypeDefinitionVersion.js.map +1 -0
- package/build/esm/api/values/ValueTypeType.js +2 -0
- package/build/esm/api/values/ValueTypeType.js.map +1 -0
- package/build/esm/api/wrapWithProxy.js +1 -0
- package/build/esm/api/wrapWithProxy.js.map +1 -1
- package/build/esm/cli/main.js +13 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toConjure/distributeTypeHelper.js +23 -0
- package/build/esm/conversion/toConjure/distributeTypeHelper.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +88 -0
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertActionParameters.js +31 -0
- package/build/esm/conversion/toMarketplace/convertActionParameters.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertActionSections.js +43 -0
- package/build/esm/conversion/toMarketplace/convertActionSections.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +93 -0
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertActionVisibility.js +41 -0
- package/build/esm/conversion/toMarketplace/convertActionVisibility.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertCardinality.js +23 -0
- package/build/esm/conversion/toMarketplace/convertCardinality.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +88 -0
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertDataConstraintToDataConstraints.js +26 -0
- package/build/esm/conversion/toMarketplace/convertDataConstraintToDataConstraints.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +89 -0
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertInterface.js +47 -0
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertLink.js +132 -0
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js +41 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertNullabilityToDataConstraint.js +43 -0
- package/build/esm/conversion/toMarketplace/convertNullabilityToDataConstraint.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObject.js +108 -0
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +53 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertOntologyDefinition.js +29 -0
- package/build/esm/conversion/toMarketplace/convertOntologyDefinition.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +57 -0
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertOntologyToValueTypeIr.js +24 -0
- package/build/esm/conversion/toMarketplace/convertOntologyToValueTypeIr.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +35 -0
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js +62 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertValueType.js +25 -0
- package/build/esm/conversion/toMarketplace/convertValueType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertValueTypeDataConstraints.js +30 -0
- package/build/esm/conversion/toMarketplace/convertValueTypeDataConstraints.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertValueTypesToIr.js +34 -0
- package/build/esm/conversion/toMarketplace/convertValueTypesToIr.js.map +1 -0
- package/build/esm/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.js +83 -0
- package/build/esm/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.js.map +1 -0
- package/build/esm/conversion/toMarketplace/getFormContentOrdering.js +39 -0
- package/build/esm/conversion/toMarketplace/getFormContentOrdering.js.map +1 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +124 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -0
- package/build/esm/index.js +5 -5
- package/build/esm/index.js.map +1 -1
- package/build/esm/util/OptionalFields.js +2 -0
- package/build/esm/util/OptionalFields.js.map +1 -0
- package/build/esm/util/RequiredFields.js +2 -0
- package/build/esm/util/RequiredFields.js.map +1 -0
- package/build/types/api/action/ActionLevelValidationDefinition.d.ts +7 -0
- package/build/types/api/action/ActionLevelValidationDefinition.d.ts.map +1 -0
- package/build/types/api/action/ActionParameter.d.ts +14 -0
- package/build/types/api/action/ActionParameter.d.ts.map +1 -0
- package/build/types/api/action/ActionParameterAllowedValues.d.ts +50 -0
- package/build/types/api/action/ActionParameterAllowedValues.d.ts.map +1 -0
- package/build/types/api/action/ActionParameterConditionalOverride.d.ts +26 -0
- package/build/types/api/action/ActionParameterConditionalOverride.d.ts.map +1 -0
- package/build/types/api/action/ActionParameterConfiguration.d.ts +20 -0
- package/build/types/api/action/ActionParameterConfiguration.d.ts.map +1 -0
- package/build/types/api/action/ActionParameterType.d.ts +6 -0
- package/build/types/api/action/ActionParameterType.d.ts.map +1 -0
- package/build/types/api/action/ActionSection.d.ts +13 -0
- package/build/types/api/action/ActionSection.d.ts.map +1 -0
- package/build/types/api/action/ActionStatus.d.ts +2 -0
- package/build/types/api/action/ActionStatus.d.ts.map +1 -0
- package/build/types/api/action/ActionType.d.ts +36 -0
- package/build/types/api/action/ActionType.d.ts.map +1 -0
- package/build/types/api/action/ActionValidationRule.d.ts +2 -0
- package/build/types/api/action/ActionValidationRule.d.ts.map +1 -0
- package/build/types/api/action/ConditionDefinition.d.ts +15 -0
- package/build/types/api/action/ConditionDefinition.d.ts.map +1 -0
- package/build/types/api/action/MappingValue.d.ts +13 -0
- package/build/types/api/action/MappingValue.d.ts.map +1 -0
- package/build/types/api/action/SectionConditionalOverride.d.ts +2 -0
- package/build/types/api/action/SectionConditionalOverride.d.ts.map +1 -0
- package/build/types/api/action/SubmissionMetadata.d.ts +6 -0
- package/build/types/api/action/SubmissionMetadata.d.ts.map +1 -0
- package/build/types/api/{iconNames.d.ts.map → common/BlueprintIcons.d.ts.map} +1 -1
- package/build/types/api/common/OntologyDefinition.d.ts +6 -0
- package/build/types/api/common/OntologyDefinition.d.ts.map +1 -0
- package/build/types/api/common/OntologyEntityBase.d.ts +5 -0
- package/build/types/api/common/OntologyEntityBase.d.ts.map +1 -0
- package/build/types/api/common/OntologyEntityTypeEnum.d.ts +8 -0
- package/build/types/api/common/OntologyEntityTypeEnum.d.ts.map +1 -0
- package/build/types/api/common/OntologyEntityTypeMapping.d.ts +16 -0
- package/build/types/api/common/OntologyEntityTypeMapping.d.ts.map +1 -0
- package/build/types/api/common/TypeClass.d.ts +4 -0
- package/build/types/api/common/TypeClass.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +38 -3
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts +5 -3
- 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/defineObject.d.ts +2 -4
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +11 -4
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +2 -1
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/defineValueType.d.ts +2 -1
- package/build/types/api/defineValueType.d.ts.map +1 -1
- package/build/types/api/importOntologyEntity.d.ts +1 -1
- package/build/types/api/importOntologyEntity.d.ts.map +1 -1
- package/build/types/api/{defineImportSpt.d.ts → importSharedPropertyType.d.ts} +2 -1
- package/build/types/api/importSharedPropertyType.d.ts.map +1 -0
- package/build/types/api/interface/InterfacePropertyType.d.ts +5 -0
- package/build/types/api/interface/InterfacePropertyType.d.ts.map +1 -0
- package/build/types/api/interface/InterfaceType.d.ts +10 -0
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -0
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts +3 -0
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts.map +1 -0
- package/build/types/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.d.ts +3 -0
- package/build/types/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.d.ts.map +1 -0
- package/build/types/api/links/LinkType.d.ts +100 -0
- package/build/types/api/links/LinkType.d.ts.map +1 -0
- package/build/types/api/namespace/combineApiNamespaceIfMissing.d.ts +1 -0
- package/build/types/api/namespace/combineApiNamespaceIfMissing.d.ts.map +1 -0
- package/build/types/api/object/InterfaceImplementation.d.ts +8 -0
- package/build/types/api/object/InterfaceImplementation.d.ts.map +1 -0
- package/build/types/api/object/ObjectPropertyType.d.ts +27 -0
- package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -0
- package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts +3 -0
- package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts.map +1 -0
- package/build/types/api/object/ObjectType.d.ts +29 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -0
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +11 -0
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts +26 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -0
- package/build/types/api/object/ObjectTypeStatus.d.ts +5 -0
- package/build/types/api/object/ObjectTypeStatus.d.ts.map +1 -0
- package/build/types/api/properties/Nullability.d.ts +4 -0
- package/build/types/api/properties/Nullability.d.ts.map +1 -0
- package/build/types/api/properties/PropertyTypeType.d.ts +33 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts +22 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -0
- package/build/types/api/propertyConversionUtils.d.ts +2 -20
- package/build/types/api/propertyConversionUtils.d.ts.map +1 -1
- package/build/types/api/values/ValueTypeDefinitionVersion.d.ts +14 -0
- package/build/types/api/values/ValueTypeDefinitionVersion.d.ts.map +1 -0
- package/build/types/api/values/ValueTypeType.d.ts +178 -0
- package/build/types/api/values/ValueTypeType.d.ts.map +1 -0
- package/build/types/api/wrapWithProxy.d.ts +1 -1
- package/build/types/api/wrapWithProxy.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toConjure/distributeTypeHelper.d.ts +3 -0
- package/build/types/conversion/toConjure/distributeTypeHelper.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionParameters.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertActionParameters.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionSections.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertActionSections.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionVisibility.d.ts +2 -0
- package/build/types/conversion/toMarketplace/convertActionVisibility.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertCardinality.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertCardinality.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertDataConstraintToDataConstraints.d.ts +2 -0
- package/build/types/conversion/toMarketplace/convertDataConstraintToDataConstraints.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertDatasourceDefinition.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertDatasourceDefinition.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertInterface.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertInterface.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertLink.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertNullabilityToDataConstraint.d.ts +7 -0
- package/build/types/conversion/toMarketplace/convertNullabilityToDataConstraint.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObject.d.ts +9 -0
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertOntologyDefinition.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertOntologyDefinition.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertOntologyToValueTypeIr.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertOntologyToValueTypeIr.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertSpt.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertValueType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertValueType.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertValueTypeDataConstraints.d.ts +2 -0
- package/build/types/conversion/toMarketplace/convertValueTypeDataConstraints.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertValueTypesToIr.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertValueTypesToIr.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.d.ts +2 -0
- package/build/types/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/getFormContentOrdering.d.ts +3 -0
- package/build/types/conversion/toMarketplace/getFormContentOrdering.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -0
- package/build/types/index.d.ts +22 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/util/OptionalFields.d.ts +4 -0
- package/build/types/util/OptionalFields.d.ts.map +1 -0
- package/build/types/util/RequiredFields.d.ts +4 -0
- package/build/types/util/RequiredFields.d.ts.map +1 -0
- package/package.json +5 -5
- package/build/browser/api/defineImportSpt.js.map +0 -1
- package/build/browser/api/iconNames.js +0 -2
- package/build/browser/api/iconNames.js.map +0 -1
- package/build/browser/api/ontologyUtils.js +0 -243
- package/build/browser/api/ontologyUtils.js.map +0 -1
- package/build/browser/api/types.js.map +0 -1
- package/build/esm/api/defineImportSpt.js.map +0 -1
- package/build/esm/api/iconNames.js +0 -2
- package/build/esm/api/iconNames.js.map +0 -1
- package/build/esm/api/ontologyUtils.js +0 -243
- package/build/esm/api/ontologyUtils.js.map +0 -1
- package/build/esm/api/types.js.map +0 -1
- package/build/types/api/defineImportSpt.d.ts.map +0 -1
- package/build/types/api/ontologyUtils.d.ts +0 -8
- package/build/types/api/ontologyUtils.d.ts.map +0 -1
- package/build/types/api/types.d.ts +0 -625
- package/build/types/api/types.d.ts.map +0 -1
- /package/build/types/api/{iconNames.d.ts → common/BlueprintIcons.d.ts} +0 -0
package/build/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var consola = require('consola');
|
|
6
6
|
var fs2 = require('fs/promises');
|
|
7
7
|
var path2 = require('path');
|
|
8
|
-
var
|
|
8
|
+
var invariant6 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
11
|
var fs = require('fs');
|
|
@@ -33,13 +33,29 @@ function _interopNamespace(e) {
|
|
|
33
33
|
|
|
34
34
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
35
35
|
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
36
|
-
var
|
|
36
|
+
var invariant6__default = /*#__PURE__*/_interopDefault(invariant6);
|
|
37
37
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
38
38
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
39
39
|
|
|
40
40
|
// src/cli/main.ts
|
|
41
41
|
|
|
42
|
-
// src/
|
|
42
|
+
// src/conversion/toMarketplace/convertActionParameters.ts
|
|
43
|
+
function convertActionParameters(action) {
|
|
44
|
+
return Object.fromEntries((action.parameters ?? []).map((p) => [p.id, {
|
|
45
|
+
id: p.id,
|
|
46
|
+
type: typeof p.type === "string" ? {
|
|
47
|
+
type: p.type,
|
|
48
|
+
[p.type]: {}
|
|
49
|
+
} : p.type,
|
|
50
|
+
displayMetadata: {
|
|
51
|
+
displayName: p.displayName,
|
|
52
|
+
description: p.description ?? "",
|
|
53
|
+
typeClasses: []
|
|
54
|
+
}
|
|
55
|
+
}]));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/api/common/OntologyEntityTypeEnum.ts
|
|
43
59
|
var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2) {
|
|
44
60
|
OntologyEntityTypeEnum2["OBJECT_TYPE"] = "OBJECT_TYPE";
|
|
45
61
|
OntologyEntityTypeEnum2["LINK_TYPE"] = "LINK_TYPE";
|
|
@@ -49,8 +65,37 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2)
|
|
|
49
65
|
OntologyEntityTypeEnum2["VALUE_TYPE"] = "VALUE_TYPE";
|
|
50
66
|
return OntologyEntityTypeEnum2;
|
|
51
67
|
})({});
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
|
|
69
|
+
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
70
|
+
function getFlattenedInterfaceProperties(interfaceType) {
|
|
71
|
+
let properties = interfaceType.propertiesV2;
|
|
72
|
+
interfaceType.extendsInterfaces.forEach((ext) => {
|
|
73
|
+
properties = {
|
|
74
|
+
...properties,
|
|
75
|
+
...getFlattenedInterfaceProperties(ext)
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
return properties;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/api/properties/PropertyTypeType.ts
|
|
82
|
+
function isPropertyTypeType(v) {
|
|
83
|
+
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || typeof v === "object" && v.type === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
84
|
+
}
|
|
85
|
+
function isExotic(type) {
|
|
86
|
+
if (type === void 0) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (typeof type === "string") {
|
|
90
|
+
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
91
|
+
} else if (typeof type === "object" && type != null) {
|
|
92
|
+
return type.type === "marking" || type.type === "struct";
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
function isStruct(type) {
|
|
97
|
+
return typeof type === "object" && type.type === "struct";
|
|
98
|
+
}
|
|
54
99
|
|
|
55
100
|
// src/api/defineObject.ts
|
|
56
101
|
var ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+D)|(?:\d+(?:\.|,)\d+D$))?(T((?:\d+H)|(?:\d+(?:\.|,)\d+H$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+S)|(?:\d+(?:\.|,)\d+S$))?)?)|(?:\d+(?:(?:\.|,)\d+)?W))$/;
|
|
@@ -62,12 +107,12 @@ function defineObject(objectDef) {
|
|
|
62
107
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
63
108
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
64
109
|
}
|
|
65
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
66
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
67
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
68
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
110
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant6__default.default(false) : void 0;
|
|
111
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
112
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
113
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant6__default.default(false) : void 0;
|
|
69
114
|
const retentionPeriod = objectDef.datasource?.retentionPeriod;
|
|
70
|
-
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ?
|
|
115
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant6__default.default(false) : void 0;
|
|
71
116
|
if (objectDef.status === "experimental") {
|
|
72
117
|
const activeProperties = [];
|
|
73
118
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -75,16 +120,16 @@ function defineObject(objectDef) {
|
|
|
75
120
|
activeProperties.push(apiName2);
|
|
76
121
|
}
|
|
77
122
|
});
|
|
78
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
123
|
+
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant6__default.default(false) : void 0;
|
|
79
124
|
}
|
|
80
125
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
81
126
|
const deadline = objectDef.status.deadline;
|
|
82
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
127
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant6__default.default(false) : void 0;
|
|
83
128
|
}
|
|
84
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
85
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
129
|
+
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant6__default.default(false) : void 0;
|
|
130
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant6__default.default(false) : void 0;
|
|
86
131
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
87
|
-
const allInterfaceProperties =
|
|
132
|
+
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
88
133
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
89
134
|
type: "invalid",
|
|
90
135
|
reason: `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
@@ -99,9 +144,9 @@ function defineObject(objectDef) {
|
|
|
99
144
|
reason: `Interface property ${interfaceProp[1].sharedPropertyType.apiName} not implemented by ${objectDef.apiName} object definition`
|
|
100
145
|
};
|
|
101
146
|
};
|
|
102
|
-
const validations = Object.entries(
|
|
147
|
+
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
103
148
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
104
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
149
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant6__default.default(false) : void 0;
|
|
105
150
|
});
|
|
106
151
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
107
152
|
const finalObject = {
|
|
@@ -114,17 +159,6 @@ function defineObject(objectDef) {
|
|
|
114
159
|
objectDef.apiName = apiName;
|
|
115
160
|
return objectDef;
|
|
116
161
|
}
|
|
117
|
-
function isExotic(type) {
|
|
118
|
-
if (type === void 0) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
if (typeof type === "string") {
|
|
122
|
-
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
123
|
-
} else if (typeof type === "object" && type != null) {
|
|
124
|
-
return type.type === "marking" || type.type === "struct";
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
162
|
function formatValidationErrors(error) {
|
|
129
163
|
return `Ontology Definition Error: ${error.reason}
|
|
130
164
|
`;
|
|
@@ -147,57 +181,122 @@ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
|
147
181
|
type: "valid"
|
|
148
182
|
};
|
|
149
183
|
}
|
|
150
|
-
function
|
|
184
|
+
function uppercaseFirstLetter(s) {
|
|
151
185
|
return s === void 0 || s == null ? "" : s.charAt(0).toUpperCase() + s.slice(1);
|
|
152
186
|
}
|
|
153
187
|
function convertToPluralDisplayName(s) {
|
|
154
|
-
return s === void 0 || s == null ? "" : s.endsWith("s") ?
|
|
155
|
-
}
|
|
156
|
-
function getAllInterfaceProperties(interfaceType) {
|
|
157
|
-
let properties = interfaceType.propertiesV2;
|
|
158
|
-
interfaceType.extendsInterfaces.forEach((ext) => {
|
|
159
|
-
properties = {
|
|
160
|
-
...properties,
|
|
161
|
-
...getAllInterfaceProperties(ext)
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
return properties;
|
|
188
|
+
return s === void 0 || s == null ? "" : s.endsWith("s") ? uppercaseFirstLetter(s) : uppercaseFirstLetter(s) + "s";
|
|
165
189
|
}
|
|
166
190
|
function convertUserObjectPropertyType(apiName, property) {
|
|
167
191
|
property.apiName = apiName;
|
|
168
|
-
property.displayName = property.displayName ??
|
|
192
|
+
property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);
|
|
169
193
|
return {
|
|
170
194
|
...property,
|
|
171
195
|
apiName,
|
|
172
|
-
displayName: property.displayName ??
|
|
196
|
+
displayName: property.displayName ?? uppercaseFirstLetter(apiName),
|
|
173
197
|
type: property.type
|
|
174
198
|
};
|
|
175
199
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
200
|
+
|
|
201
|
+
// src/conversion/toMarketplace/convertActionSections.ts
|
|
202
|
+
function convertActionSections(action) {
|
|
203
|
+
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [sectionId, {
|
|
204
|
+
id: sectionId,
|
|
205
|
+
content: section.parameters.map((p) => ({
|
|
206
|
+
type: "parameterId",
|
|
207
|
+
parameterId: p
|
|
208
|
+
})),
|
|
209
|
+
displayMetadata: {
|
|
210
|
+
collapsedByDefault: section.collapsedByDefault ?? false,
|
|
211
|
+
columnCount: section.columnCount ?? 1,
|
|
212
|
+
description: section.description ?? "",
|
|
213
|
+
displayName: section.displayName ?? uppercaseFirstLetter(sectionId),
|
|
214
|
+
showTitleBar: section.showTitleBar ?? true,
|
|
215
|
+
...section.style && {
|
|
216
|
+
style: section.style === "box" ? {
|
|
217
|
+
type: "box",
|
|
218
|
+
box: {}
|
|
219
|
+
} : {
|
|
220
|
+
type: "minimal",
|
|
221
|
+
minimal: {}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}]));
|
|
226
|
+
}
|
|
227
|
+
function convertConditionDefinition(condition, actionParameters) {
|
|
228
|
+
switch (condition.type) {
|
|
229
|
+
case "and":
|
|
230
|
+
if ("conditions" in condition) {
|
|
231
|
+
return {
|
|
232
|
+
type: "and",
|
|
233
|
+
and: {
|
|
234
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
} else {
|
|
238
|
+
return condition;
|
|
239
|
+
}
|
|
240
|
+
case "or":
|
|
241
|
+
if ("conditions" in condition) {
|
|
242
|
+
return {
|
|
243
|
+
type: "or",
|
|
244
|
+
or: {
|
|
245
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
} else {
|
|
249
|
+
return condition;
|
|
250
|
+
}
|
|
251
|
+
case "group":
|
|
184
252
|
return {
|
|
185
|
-
type: "
|
|
186
|
-
|
|
253
|
+
type: "comparison",
|
|
254
|
+
comparison: {
|
|
255
|
+
operator: "INTERSECTS",
|
|
256
|
+
left: {
|
|
257
|
+
type: "userProperty",
|
|
258
|
+
userProperty: {
|
|
259
|
+
userId: {
|
|
260
|
+
type: "currentUser",
|
|
261
|
+
currentUser: {}
|
|
262
|
+
},
|
|
263
|
+
propertyValue: {
|
|
264
|
+
type: "groupIds",
|
|
265
|
+
groupIds: {}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
right: {
|
|
270
|
+
type: "staticValue",
|
|
271
|
+
staticValue: {
|
|
272
|
+
type: "stringList",
|
|
273
|
+
stringList: {
|
|
274
|
+
strings: [condition.name]
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
187
279
|
};
|
|
188
|
-
case "
|
|
280
|
+
case "parameter":
|
|
281
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
189
282
|
return {
|
|
190
|
-
type: "
|
|
191
|
-
|
|
283
|
+
type: "comparison",
|
|
284
|
+
comparison: {
|
|
285
|
+
operator: "EQUALS",
|
|
286
|
+
left: {
|
|
287
|
+
type: "parameterId",
|
|
288
|
+
parameterId: condition.parameterId
|
|
289
|
+
},
|
|
290
|
+
right: condition.matches
|
|
291
|
+
}
|
|
192
292
|
};
|
|
193
293
|
default:
|
|
194
|
-
return
|
|
195
|
-
type: "editable",
|
|
196
|
-
editable: {}
|
|
197
|
-
};
|
|
294
|
+
return condition;
|
|
198
295
|
}
|
|
199
296
|
}
|
|
200
|
-
|
|
297
|
+
|
|
298
|
+
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
299
|
+
function convertActionParameterConditionalOverride(override, validation, actionParameters) {
|
|
201
300
|
let parameterBlockOverride;
|
|
202
301
|
switch (override.type) {
|
|
203
302
|
case "required":
|
|
@@ -262,13 +361,41 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
262
361
|
throw new Error(`Unknown parameter override type`);
|
|
263
362
|
}
|
|
264
363
|
return {
|
|
265
|
-
condition: convertConditionDefinition(override.condition),
|
|
364
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
266
365
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
267
366
|
};
|
|
268
367
|
}
|
|
269
|
-
|
|
368
|
+
|
|
369
|
+
// src/conversion/toMarketplace/convertActionVisibility.ts
|
|
370
|
+
function convertActionVisibility(visibility) {
|
|
371
|
+
switch (visibility) {
|
|
372
|
+
case "editable":
|
|
373
|
+
return {
|
|
374
|
+
type: "editable",
|
|
375
|
+
editable: {}
|
|
376
|
+
};
|
|
377
|
+
case "disabled":
|
|
378
|
+
return {
|
|
379
|
+
type: "disabled",
|
|
380
|
+
disabled: {}
|
|
381
|
+
};
|
|
382
|
+
case "hidden":
|
|
383
|
+
return {
|
|
384
|
+
type: "hidden",
|
|
385
|
+
hidden: {}
|
|
386
|
+
};
|
|
387
|
+
default:
|
|
388
|
+
return {
|
|
389
|
+
type: "editable",
|
|
390
|
+
editable: {}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/conversion/toMarketplace/convertSectionConditionalOverride.ts
|
|
396
|
+
function convertSectionConditionalOverride(override, defaultVisibility, actionParameters) {
|
|
270
397
|
return {
|
|
271
|
-
condition: convertConditionDefinition(override.condition),
|
|
398
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
272
399
|
sectionBlockOverrides: [{
|
|
273
400
|
type: "visibility",
|
|
274
401
|
visibility: {
|
|
@@ -283,227 +410,78 @@ function convertSectionConditionalOverride(override, defaultVisibility) {
|
|
|
283
410
|
}]
|
|
284
411
|
};
|
|
285
412
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
case "group":
|
|
311
|
-
return {
|
|
312
|
-
type: "comparison",
|
|
313
|
-
comparison: {
|
|
314
|
-
operator: "INTERSECTS",
|
|
315
|
-
left: {
|
|
316
|
-
type: "userProperty",
|
|
317
|
-
userProperty: {
|
|
318
|
-
userId: {
|
|
319
|
-
type: "currentUser",
|
|
320
|
-
currentUser: {}
|
|
321
|
-
},
|
|
322
|
-
propertyValue: {
|
|
323
|
-
type: "groupIds",
|
|
324
|
-
groupIds: {}
|
|
325
|
-
}
|
|
413
|
+
|
|
414
|
+
// src/conversion/toMarketplace/convertActionValidation.ts
|
|
415
|
+
function convertActionValidation(action) {
|
|
416
|
+
return {
|
|
417
|
+
actionTypeLevelValidation: {
|
|
418
|
+
rules: Object.fromEntries((action.validation ?? [{
|
|
419
|
+
condition: {
|
|
420
|
+
type: "true",
|
|
421
|
+
true: {}
|
|
422
|
+
},
|
|
423
|
+
displayMetadata: {
|
|
424
|
+
failureMessage: "",
|
|
425
|
+
typeClasses: []
|
|
426
|
+
}
|
|
427
|
+
}]).map((rule, idx) => [idx, rule]))
|
|
428
|
+
},
|
|
429
|
+
parameterValidations: Object.fromEntries((action.parameters ?? []).map((p) => {
|
|
430
|
+
return [p.id, {
|
|
431
|
+
defaultValidation: {
|
|
432
|
+
display: {
|
|
433
|
+
renderHint: renderHintFromBaseType(p),
|
|
434
|
+
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
435
|
+
...p.defaultValue && {
|
|
436
|
+
prefill: p.defaultValue
|
|
326
437
|
}
|
|
327
438
|
},
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type: "stringList",
|
|
332
|
-
stringList: {
|
|
333
|
-
strings: [condition.name]
|
|
334
|
-
}
|
|
335
|
-
}
|
|
439
|
+
validation: {
|
|
440
|
+
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
441
|
+
required: convertParameterRequirementConstraint(p.validation.required)
|
|
336
442
|
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
type: "
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (!action.sections) return [];
|
|
357
|
-
const parametersToSection = Object.fromEntries(Object.entries(action.sections).flatMap(([sectionId, section]) => section.parameters.map((param) => [param, sectionId])));
|
|
358
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
359
|
-
const formContentOrdering = [];
|
|
360
|
-
parameterOrdering.forEach((param) => {
|
|
361
|
-
if (param in parametersToSection && !seenIds.has(parametersToSection[param])) {
|
|
362
|
-
formContentOrdering.push({
|
|
363
|
-
type: "sectionId",
|
|
364
|
-
sectionId: parametersToSection[param]
|
|
365
|
-
});
|
|
366
|
-
seenIds.add(parametersToSection[param]);
|
|
367
|
-
} else if (!(param in parametersToSection)) {
|
|
368
|
-
formContentOrdering.push({
|
|
369
|
-
type: "parameterId",
|
|
370
|
-
parameterId: param
|
|
371
|
-
});
|
|
372
|
-
seenIds.add(param);
|
|
443
|
+
},
|
|
444
|
+
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation, action.parameters)) ?? []
|
|
445
|
+
}];
|
|
446
|
+
})),
|
|
447
|
+
sectionValidations: {
|
|
448
|
+
...Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [section.id, {
|
|
449
|
+
defaultDisplayMetadata: section.defaultVisibility === "hidden" ? {
|
|
450
|
+
visibility: {
|
|
451
|
+
type: "hidden",
|
|
452
|
+
hidden: {}
|
|
453
|
+
}
|
|
454
|
+
} : {
|
|
455
|
+
visibility: {
|
|
456
|
+
type: "visible",
|
|
457
|
+
visible: {}
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", action.parameters)) ?? []
|
|
461
|
+
}]))
|
|
373
462
|
}
|
|
374
|
-
});
|
|
375
|
-
return formContentOrdering;
|
|
376
|
-
}
|
|
377
|
-
function convertMappingValue(value) {
|
|
378
|
-
switch (value.type) {
|
|
379
|
-
case "uuid":
|
|
380
|
-
return {
|
|
381
|
-
type: "uniqueIdentifier",
|
|
382
|
-
uniqueIdentifier: {
|
|
383
|
-
linkId: value.linkId ?? crypto.randomUUID()
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
case "currentTime":
|
|
387
|
-
return {
|
|
388
|
-
type: "currentTime",
|
|
389
|
-
currentTime: {}
|
|
390
|
-
};
|
|
391
|
-
case "currentUser":
|
|
392
|
-
return {
|
|
393
|
-
type: "currentUser",
|
|
394
|
-
currentUser: {}
|
|
395
|
-
};
|
|
396
|
-
default:
|
|
397
|
-
return value;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
var defaultTypeClasses = [{
|
|
401
|
-
kind: "render_hint",
|
|
402
|
-
name: "SELECTABLE"
|
|
403
|
-
}, {
|
|
404
|
-
kind: "render_hint",
|
|
405
|
-
name: "SORTABLE"
|
|
406
|
-
}];
|
|
407
|
-
function shouldNotHaveRenderHints(type) {
|
|
408
|
-
return ["struct", "mediaReference", "geotimeSeries"].includes(getPropertyTypeName(type));
|
|
409
|
-
}
|
|
410
|
-
function hasRenderHints(typeClasses) {
|
|
411
|
-
return (typeClasses ?? []).some((tc) => tc.kind.toLowerCase() === "render_hint");
|
|
412
|
-
}
|
|
413
|
-
function getPropertyTypeName(type) {
|
|
414
|
-
return typeof type === "object" ? type.type : type;
|
|
415
|
-
}
|
|
416
|
-
function convertValueType(valueType) {
|
|
417
|
-
return {
|
|
418
|
-
apiName: valueType.apiName,
|
|
419
|
-
version: valueType.version,
|
|
420
|
-
packageNamespace: valueType.packageNamespace,
|
|
421
|
-
displayMetadata: valueType.displayMetadata
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
function convertValueTypeDataConstraints(dataConstraints) {
|
|
425
|
-
if (dataConstraints.length === 0) {
|
|
426
|
-
return void 0;
|
|
427
|
-
}
|
|
428
|
-
const propertyTypeConstraints = dataConstraints.map((constraint) => ({
|
|
429
|
-
constraints: dataConstraintToPropertyTypeDataConstraint(constraint.constraint.constraint),
|
|
430
|
-
failureMessage: constraint.constraint.failureMessage
|
|
431
|
-
}));
|
|
432
|
-
return {
|
|
433
|
-
propertyTypeConstraints
|
|
434
463
|
};
|
|
435
464
|
}
|
|
436
|
-
function
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
case "binary":
|
|
447
|
-
throw new Error("Binary type constraints are not supported");
|
|
448
|
-
case "date":
|
|
449
|
-
return {
|
|
450
|
-
...dc
|
|
451
|
-
};
|
|
452
|
-
case "decimal":
|
|
453
|
-
return {
|
|
454
|
-
...dc
|
|
455
|
-
};
|
|
456
|
-
case "double":
|
|
457
|
-
return {
|
|
458
|
-
...dc
|
|
459
|
-
};
|
|
460
|
-
case "float":
|
|
461
|
-
return {
|
|
462
|
-
...dc
|
|
463
|
-
};
|
|
464
|
-
case "integer":
|
|
465
|
-
return {
|
|
466
|
-
...dc
|
|
467
|
-
};
|
|
468
|
-
case "long":
|
|
469
|
-
return {
|
|
470
|
-
...dc
|
|
471
|
-
};
|
|
472
|
-
case "map":
|
|
473
|
-
throw new Error("Map type constraints are not supported");
|
|
474
|
-
case "nullable":
|
|
475
|
-
throw new Error("Nullable constraints are not supported");
|
|
476
|
-
case "short":
|
|
477
|
-
return {
|
|
478
|
-
...dc
|
|
479
|
-
};
|
|
480
|
-
case "string":
|
|
481
|
-
return {
|
|
482
|
-
...dc
|
|
483
|
-
};
|
|
484
|
-
case "struct":
|
|
485
|
-
return {
|
|
486
|
-
type: "struct",
|
|
487
|
-
struct: {
|
|
488
|
-
elementConstraints: Object.fromEntries(Object.entries(dc.struct.elementConstraints).map(([field, constraint]) => [field, convertDataConstraintToDataConstraints(constraint)]))
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
case "structV2":
|
|
492
|
-
throw new Error("StructV2 constraints are not supported");
|
|
493
|
-
case "timestamp":
|
|
494
|
-
return {
|
|
495
|
-
...dc
|
|
496
|
-
};
|
|
497
|
-
default:
|
|
498
|
-
throw new Error(`Unknown DataConstraint type: ${dc.type}`);
|
|
465
|
+
function convertParameterRequirementConstraint(required) {
|
|
466
|
+
if (typeof required === "boolean") {
|
|
467
|
+
return required ? {
|
|
468
|
+
type: "required",
|
|
469
|
+
required: {}
|
|
470
|
+
} : {
|
|
471
|
+
type: "notRequired",
|
|
472
|
+
notRequired: {}
|
|
473
|
+
};
|
|
499
474
|
}
|
|
500
|
-
|
|
501
|
-
|
|
475
|
+
const {
|
|
476
|
+
min,
|
|
477
|
+
max
|
|
478
|
+
} = required.listLength;
|
|
502
479
|
return {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
480
|
+
type: "listLengthValidation",
|
|
481
|
+
listLengthValidation: {
|
|
482
|
+
minLength: min,
|
|
483
|
+
maxLength: max
|
|
484
|
+
}
|
|
507
485
|
};
|
|
508
486
|
}
|
|
509
487
|
function convertNullabilityToDataConstraint(prop) {
|
|
@@ -518,7 +496,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
518
496
|
}
|
|
519
497
|
};
|
|
520
498
|
}
|
|
521
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
499
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant6__default.default(false) : void 0;
|
|
522
500
|
return {
|
|
523
501
|
propertyTypeConstraints: [],
|
|
524
502
|
nullability: void 0,
|
|
@@ -531,7 +509,17 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
531
509
|
nullabilityV2: prop.nullability
|
|
532
510
|
};
|
|
533
511
|
}
|
|
534
|
-
|
|
512
|
+
|
|
513
|
+
// src/conversion/toConjure/distributeTypeHelper.ts
|
|
514
|
+
function distributeTypeHelper(type) {
|
|
515
|
+
return {
|
|
516
|
+
type,
|
|
517
|
+
[type]: {}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
|
|
522
|
+
function propertyTypeTypeToOntologyIrType(type) {
|
|
535
523
|
switch (true) {
|
|
536
524
|
case (typeof type === "object" && "markingType" in type):
|
|
537
525
|
return {
|
|
@@ -554,14 +542,14 @@ function convertType(type) {
|
|
|
554
542
|
},
|
|
555
543
|
typeClasses: [],
|
|
556
544
|
aliases: [],
|
|
557
|
-
fieldType:
|
|
545
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
558
546
|
};
|
|
559
547
|
} else {
|
|
560
548
|
if ("fieldType" in fieldTypeDefinition) {
|
|
561
549
|
field = {
|
|
562
550
|
...fieldTypeDefinition,
|
|
563
551
|
apiName: key,
|
|
564
|
-
fieldType:
|
|
552
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition.fieldType),
|
|
565
553
|
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
566
554
|
aliases: fieldTypeDefinition.aliases ?? []
|
|
567
555
|
};
|
|
@@ -574,7 +562,7 @@ function convertType(type) {
|
|
|
574
562
|
},
|
|
575
563
|
typeClasses: [],
|
|
576
564
|
aliases: [],
|
|
577
|
-
fieldType:
|
|
565
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
578
566
|
};
|
|
579
567
|
}
|
|
580
568
|
}
|
|
@@ -635,284 +623,207 @@ function convertType(type) {
|
|
|
635
623
|
return distributeTypeHelper(type);
|
|
636
624
|
}
|
|
637
625
|
}
|
|
638
|
-
|
|
639
|
-
|
|
626
|
+
|
|
627
|
+
// src/conversion/toMarketplace/convertSpt.ts
|
|
628
|
+
function convertSpt({
|
|
629
|
+
type,
|
|
630
|
+
array,
|
|
631
|
+
description,
|
|
632
|
+
apiName,
|
|
633
|
+
displayName,
|
|
634
|
+
visibility,
|
|
635
|
+
gothamMapping,
|
|
636
|
+
typeClasses,
|
|
637
|
+
valueType,
|
|
638
|
+
nullability
|
|
639
|
+
}) {
|
|
640
|
+
const dataConstraint = convertNullabilityToDataConstraint({
|
|
640
641
|
type,
|
|
641
|
-
|
|
642
|
+
nullability
|
|
643
|
+
});
|
|
644
|
+
return {
|
|
645
|
+
apiName,
|
|
646
|
+
displayMetadata: {
|
|
647
|
+
displayName: displayName ?? apiName,
|
|
648
|
+
visibility: visibility ?? "NORMAL",
|
|
649
|
+
description
|
|
650
|
+
},
|
|
651
|
+
type: array ? {
|
|
652
|
+
type: "array",
|
|
653
|
+
array: {
|
|
654
|
+
subtype: propertyTypeTypeToOntologyIrType(type)
|
|
655
|
+
}
|
|
656
|
+
} : propertyTypeTypeToOntologyIrType(type),
|
|
657
|
+
aliases: [],
|
|
658
|
+
baseFormatter: void 0,
|
|
659
|
+
dataConstraints: dataConstraint,
|
|
660
|
+
gothamMapping,
|
|
661
|
+
indexedForSearch: true,
|
|
662
|
+
typeClasses: typeClasses ?? [],
|
|
663
|
+
valueType: valueType === void 0 ? void 0 : {
|
|
664
|
+
apiName: valueType.apiName,
|
|
665
|
+
version: valueType.version,
|
|
666
|
+
packageNamespace: valueType.packageNamespace,
|
|
667
|
+
displayMetadata: valueType.displayMetadata
|
|
668
|
+
}
|
|
642
669
|
};
|
|
643
670
|
}
|
|
644
671
|
|
|
645
|
-
// src/
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
OBJECT_TYPE: {},
|
|
674
|
-
ACTION_TYPE: {},
|
|
675
|
-
LINK_TYPE: {},
|
|
676
|
-
INTERFACE_TYPE: {},
|
|
677
|
-
VALUE_TYPE: {}
|
|
672
|
+
// src/conversion/toMarketplace/convertInterface.ts
|
|
673
|
+
function convertInterface(interfaceType) {
|
|
674
|
+
const {
|
|
675
|
+
__type,
|
|
676
|
+
...other
|
|
677
|
+
} = interfaceType;
|
|
678
|
+
return {
|
|
679
|
+
...other,
|
|
680
|
+
propertiesV2: Object.fromEntries(Object.values(interfaceType.propertiesV2).map((spt) => [spt.sharedPropertyType.apiName, {
|
|
681
|
+
required: spt.required,
|
|
682
|
+
sharedPropertyType: convertSpt(spt.sharedPropertyType)
|
|
683
|
+
}])),
|
|
684
|
+
displayMetadata: {
|
|
685
|
+
displayName: interfaceType.displayMetadata.displayName,
|
|
686
|
+
description: interfaceType.displayMetadata.description,
|
|
687
|
+
icon: interfaceType.displayMetadata.icon ?? {
|
|
688
|
+
type: "blueprint",
|
|
689
|
+
blueprint: {
|
|
690
|
+
color: "#4C90F0",
|
|
691
|
+
locator: "layout-hierarchy"
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
696
|
+
// these are omitted from our internal types but we need to re-add them for the final json
|
|
697
|
+
properties: [],
|
|
698
|
+
// TODO(mwalther): Support propertiesV3
|
|
699
|
+
propertiesV3: {}
|
|
678
700
|
};
|
|
679
|
-
try {
|
|
680
|
-
await body();
|
|
681
|
-
} catch (e) {
|
|
682
|
-
console.error("Unexpected error while processing the body of the ontology", e);
|
|
683
|
-
throw e;
|
|
684
|
-
}
|
|
685
|
-
if (outputDir) {
|
|
686
|
-
writeStaticObjects(outputDir);
|
|
687
|
-
}
|
|
688
|
-
if (dependencyFile) {
|
|
689
|
-
writeDependencyFile(dependencyFile);
|
|
690
|
-
}
|
|
691
|
-
return convertToWireOntologyIr(ontologyDefinition);
|
|
692
701
|
}
|
|
693
|
-
function writeStaticObjects(outputDir) {
|
|
694
|
-
const codegenDir = path2__namespace.resolve(outputDir, "codegen");
|
|
695
|
-
const typeDirs = {
|
|
696
|
-
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
697
|
-
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
698
|
-
[OntologyEntityTypeEnum.OBJECT_TYPE]: "object-types",
|
|
699
|
-
[OntologyEntityTypeEnum.LINK_TYPE]: "link-types",
|
|
700
|
-
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
701
|
-
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
702
|
-
};
|
|
703
|
-
if (!fs__namespace.existsSync(codegenDir)) {
|
|
704
|
-
fs__namespace.mkdirSync(codegenDir, {
|
|
705
|
-
recursive: true
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
709
|
-
const currentTypeDirPath = path2__namespace.join(codegenDir, typeDirNameFromMap);
|
|
710
|
-
if (fs__namespace.existsSync(currentTypeDirPath)) {
|
|
711
|
-
fs__namespace.rmSync(currentTypeDirPath, {
|
|
712
|
-
recursive: true,
|
|
713
|
-
force: true
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
fs__namespace.mkdirSync(currentTypeDirPath, {
|
|
717
|
-
recursive: true
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
const topLevelExportStatements = [];
|
|
721
|
-
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
722
|
-
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
723
|
-
const typeDirPath = path2__namespace.join(codegenDir, typeDirName);
|
|
724
|
-
const entityModuleNames = [];
|
|
725
|
-
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
726
|
-
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
727
|
-
const filePath = path2__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
728
|
-
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
729
|
-
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
730
|
-
const content = `
|
|
731
|
-
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
732
|
-
import type { ${entityTypeName} } from '@osdk/maker';
|
|
733
702
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
fs__namespace.writeFileSync(filePath, content, {
|
|
739
|
-
flag: "w"
|
|
740
|
-
});
|
|
741
|
-
entityModuleNames.push(entityFileNameBase);
|
|
742
|
-
});
|
|
743
|
-
for (const entityModuleName of entityModuleNames) {
|
|
744
|
-
topLevelExportStatements.push(`export { ${entityModuleName} } from "./codegen/${typeDirName}/${entityModuleName}.js";`);
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
if (topLevelExportStatements.length > 0) {
|
|
748
|
-
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
749
|
-
const mainIndexFilePath = path2__namespace.join(outputDir, "index.ts");
|
|
750
|
-
fs__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
751
|
-
flag: "w"
|
|
752
|
-
});
|
|
703
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
704
|
+
function convertCardinality(cardinality) {
|
|
705
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
706
|
+
return "ONE_TO_MANY";
|
|
753
707
|
}
|
|
708
|
+
return "ONE_TO_ONE";
|
|
754
709
|
}
|
|
755
|
-
|
|
710
|
+
|
|
711
|
+
// src/conversion/toMarketplace/convertLink.ts
|
|
712
|
+
function convertLink(linkType) {
|
|
713
|
+
let definition;
|
|
714
|
+
let datasource = void 0;
|
|
715
|
+
if ("one" in linkType) {
|
|
716
|
+
definition = {
|
|
717
|
+
type: "oneToMany",
|
|
718
|
+
oneToMany: {
|
|
719
|
+
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
720
|
+
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
721
|
+
objectTypeRidManySide: linkType.toMany.object.apiName,
|
|
722
|
+
objectTypeRidOneSide: linkType.one.object.apiName,
|
|
723
|
+
oneToManyLinkMetadata: linkType.one.metadata,
|
|
724
|
+
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
725
|
+
from: {
|
|
726
|
+
apiName: linkType.one.object.primaryKeyPropertyApiName,
|
|
727
|
+
object: linkType.one.object.apiName
|
|
728
|
+
},
|
|
729
|
+
to: {
|
|
730
|
+
apiName: linkType.manyForeignKeyProperty,
|
|
731
|
+
object: linkType.toMany.object.apiName
|
|
732
|
+
}
|
|
733
|
+
}]
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
737
|
+
definition = {
|
|
738
|
+
type: "intermediary",
|
|
739
|
+
intermediary: {
|
|
740
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
741
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
742
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
743
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
744
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
745
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
746
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
} else {
|
|
750
|
+
definition = {
|
|
751
|
+
type: "manyToMany",
|
|
752
|
+
manyToMany: {
|
|
753
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
754
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
755
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
756
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
757
|
+
peeringMetadata: void 0,
|
|
758
|
+
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
759
|
+
from: {
|
|
760
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
761
|
+
object: linkType.many.object.apiName
|
|
762
|
+
},
|
|
763
|
+
to: {
|
|
764
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
765
|
+
object: linkType.many.object.apiName
|
|
766
|
+
}
|
|
767
|
+
}],
|
|
768
|
+
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
769
|
+
from: {
|
|
770
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
771
|
+
object: linkType.toMany.object.apiName
|
|
772
|
+
},
|
|
773
|
+
to: {
|
|
774
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
775
|
+
object: linkType.toMany.object.apiName
|
|
776
|
+
}
|
|
777
|
+
}]
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
datasource = {
|
|
781
|
+
datasourceName: linkType.apiName,
|
|
782
|
+
datasource: {
|
|
783
|
+
type: "dataset",
|
|
784
|
+
dataset: {
|
|
785
|
+
datasetRid: "link-".concat(linkType.apiName),
|
|
786
|
+
writebackDatasetRid: void 0,
|
|
787
|
+
objectTypeAPrimaryKeyMapping: [{
|
|
788
|
+
property: {
|
|
789
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
790
|
+
object: linkType.many.object.apiName
|
|
791
|
+
},
|
|
792
|
+
column: linkType.many.object.primaryKeyPropertyApiName
|
|
793
|
+
}],
|
|
794
|
+
objectTypeBPrimaryKeyMapping: [{
|
|
795
|
+
property: {
|
|
796
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
797
|
+
object: linkType.toMany.object.apiName
|
|
798
|
+
},
|
|
799
|
+
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
800
|
+
}]
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
editsConfiguration: {
|
|
804
|
+
onlyAllowPrivilegedEdits: false
|
|
805
|
+
},
|
|
806
|
+
redacted: linkType.redacted
|
|
807
|
+
};
|
|
808
|
+
}
|
|
756
809
|
return {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
displayMetadata: definitions[0].displayMetadata,
|
|
766
|
-
status: definitions[0].status
|
|
810
|
+
linkType: {
|
|
811
|
+
definition,
|
|
812
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
813
|
+
status: linkType.status ?? {
|
|
814
|
+
type: "active",
|
|
815
|
+
active: {}
|
|
816
|
+
},
|
|
817
|
+
redacted: linkType.redacted ?? false
|
|
767
818
|
},
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
constraints: definition.constraints,
|
|
773
|
-
exampleValues: definition.exampleValues
|
|
774
|
-
}))
|
|
775
|
-
}));
|
|
776
|
-
}
|
|
777
|
-
function convertToWireOntologyIr(ontology) {
|
|
778
|
-
return {
|
|
779
|
-
ontology: convertToWireBlockData(ontology),
|
|
780
|
-
importedOntology: convertToWireBlockData(importedTypes),
|
|
781
|
-
valueTypes: convertOntologyToValueTypeIr(ontology),
|
|
782
|
-
importedValueTypes: convertOntologyToValueTypeIr(importedTypes)
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
function convertToWireBlockData(ontology) {
|
|
786
|
-
return {
|
|
787
|
-
objectTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.OBJECT_TYPE]).map(([apiName, objectType]) => {
|
|
788
|
-
return [apiName, convertObject(objectType)];
|
|
789
|
-
})),
|
|
790
|
-
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]).map(([apiName, spt]) => [apiName, {
|
|
791
|
-
sharedPropertyType: convertSpt(spt)
|
|
792
|
-
}])),
|
|
793
|
-
interfaceTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.INTERFACE_TYPE]).map(([apiName, interfaceType]) => {
|
|
794
|
-
return [apiName, {
|
|
795
|
-
interfaceType: convertInterface(interfaceType)
|
|
796
|
-
}];
|
|
797
|
-
})),
|
|
798
|
-
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
799
|
-
return [id, convertLink(link)];
|
|
800
|
-
})),
|
|
801
|
-
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
802
|
-
return [apiName, convertAction(action)];
|
|
803
|
-
})),
|
|
804
|
-
blockPermissionInformation: {
|
|
805
|
-
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).filter(([apiName, action]) => action.validation).map(([apiName, action]) => {
|
|
806
|
-
return [apiName, {
|
|
807
|
-
restrictionStatus: {
|
|
808
|
-
hasRolesApplied: true,
|
|
809
|
-
ontologyPackageRid: null,
|
|
810
|
-
publicProject: false
|
|
811
|
-
}
|
|
812
|
-
}];
|
|
813
|
-
})),
|
|
814
|
-
linkTypes: {},
|
|
815
|
-
objectTypes: {}
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function convertObject(objectType) {
|
|
820
|
-
const propertyDatasources = (objectType.properties ?? []).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
821
|
-
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
822
|
-
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
823
|
-
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
824
|
-
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
825
|
-
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, objectType.properties ?? []), classificationInputGroup, mandatoryInputGroup);
|
|
826
|
-
const implementations = objectType.implementsInterfaces ?? [];
|
|
827
|
-
return {
|
|
828
|
-
objectType: {
|
|
829
|
-
displayMetadata: {
|
|
830
|
-
description: objectType.description,
|
|
831
|
-
displayName: objectType.displayName,
|
|
832
|
-
groupDisplayName: void 0,
|
|
833
|
-
icon: {
|
|
834
|
-
type: "blueprint",
|
|
835
|
-
blueprint: objectType.icon ?? {
|
|
836
|
-
locator: "cube",
|
|
837
|
-
color: "#2D72D2"
|
|
838
|
-
}
|
|
839
|
-
},
|
|
840
|
-
pluralDisplayName: objectType.pluralDisplayName,
|
|
841
|
-
visibility: objectType.visibility ?? "NORMAL"
|
|
842
|
-
},
|
|
843
|
-
primaryKeys: [objectType.primaryKeyPropertyApiName],
|
|
844
|
-
propertyTypes: Object.fromEntries(objectType.properties?.map((val) => [val.apiName, convertProperty(val)]) ?? []),
|
|
845
|
-
titlePropertyTypeRid: objectType.titlePropertyApiName,
|
|
846
|
-
apiName: objectType.apiName,
|
|
847
|
-
status: convertObjectStatus(objectType.status),
|
|
848
|
-
redacted: false,
|
|
849
|
-
implementsInterfaces2: implementations.map((impl) => ({
|
|
850
|
-
interfaceTypeApiName: impl.implements.apiName,
|
|
851
|
-
linksV2: {},
|
|
852
|
-
propertiesV2: {},
|
|
853
|
-
properties: Object.fromEntries(impl.propertyMapping.map((mapping) => [addNamespaceIfNone(mapping.interfaceProperty), {
|
|
854
|
-
propertyTypeRid: mapping.mapsTo
|
|
855
|
-
}]))
|
|
856
|
-
})),
|
|
857
|
-
allImplementsInterfaces: {}
|
|
858
|
-
},
|
|
859
|
-
datasources: [...propertyDatasources, objectDatasource],
|
|
860
|
-
entityMetadata: {
|
|
861
|
-
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
function extractPropertyDatasource(property, objectTypeApiName) {
|
|
866
|
-
if (!isExotic(property.type)) {
|
|
867
|
-
return [];
|
|
868
|
-
}
|
|
869
|
-
const identifier = objectTypeApiName + "." + property.apiName;
|
|
870
|
-
switch (property.type) {
|
|
871
|
-
case "geotimeSeries":
|
|
872
|
-
const geotimeDefinition = {
|
|
873
|
-
type: "geotimeSeries",
|
|
874
|
-
geotimeSeries: {
|
|
875
|
-
geotimeSeriesIntegrationRid: identifier,
|
|
876
|
-
properties: [property.apiName]
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
return [buildDatasource(property.apiName, geotimeDefinition)];
|
|
880
|
-
case "mediaReference":
|
|
881
|
-
const mediaSetDefinition = {
|
|
882
|
-
type: "mediaSetView",
|
|
883
|
-
mediaSetView: {
|
|
884
|
-
assumedMarkings: [],
|
|
885
|
-
mediaSetViewLocator: identifier,
|
|
886
|
-
properties: [property.apiName]
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
return [buildDatasource(property.apiName, mediaSetDefinition)];
|
|
890
|
-
default:
|
|
891
|
-
return [];
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
function buildDatasource(apiName, definition, classificationMarkingGroupName, mandatoryMarkingGroupName) {
|
|
895
|
-
const needsSecurity = classificationMarkingGroupName !== void 0 || mandatoryMarkingGroupName !== void 0;
|
|
896
|
-
const securityConfig = needsSecurity ? {
|
|
897
|
-
classificationConstraint: classificationMarkingGroupName ? {
|
|
898
|
-
markingGroupName: classificationMarkingGroupName
|
|
899
|
-
} : void 0,
|
|
900
|
-
markingConstraint: mandatoryMarkingGroupName ? {
|
|
901
|
-
markingGroupName: mandatoryMarkingGroupName
|
|
902
|
-
} : void 0
|
|
903
|
-
} : void 0;
|
|
904
|
-
return {
|
|
905
|
-
rid: "ri.ontology.main.datasource.".concat(apiName),
|
|
906
|
-
datasource: definition,
|
|
907
|
-
editsConfiguration: {
|
|
908
|
-
onlyAllowPrivilegedEdits: false
|
|
909
|
-
},
|
|
910
|
-
redacted: false,
|
|
911
|
-
...securityConfig !== void 0 && {
|
|
912
|
-
dataSecurity: securityConfig
|
|
913
|
-
}
|
|
819
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
820
|
+
entityMetadata: {
|
|
821
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
822
|
+
}
|
|
914
823
|
};
|
|
915
824
|
}
|
|
825
|
+
|
|
826
|
+
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
916
827
|
function convertDatasourceDefinition(objectType, properties) {
|
|
917
828
|
switch (objectType.datasource?.type) {
|
|
918
829
|
case "stream":
|
|
@@ -955,14 +866,6 @@ function convertDatasourceDefinition(objectType, properties) {
|
|
|
955
866
|
};
|
|
956
867
|
}
|
|
957
868
|
}
|
|
958
|
-
function extractMarkingGroups(properties, markingType) {
|
|
959
|
-
return properties.map((prop) => {
|
|
960
|
-
if (typeof prop.type === "object" && prop.type.type === "marking" && prop.type.markingType === markingType) {
|
|
961
|
-
return prop.type.markingInputGroupName;
|
|
962
|
-
}
|
|
963
|
-
return void 0;
|
|
964
|
-
}).filter((val) => val !== void 0);
|
|
965
|
-
}
|
|
966
869
|
function buildPropertyMapping(properties) {
|
|
967
870
|
return Object.fromEntries(properties.map((prop) => {
|
|
968
871
|
if (prop.editOnly) {
|
|
@@ -990,9 +893,130 @@ function buildPropertyMapping(properties) {
|
|
|
990
893
|
}];
|
|
991
894
|
}));
|
|
992
895
|
}
|
|
993
|
-
|
|
896
|
+
|
|
897
|
+
// src/api/propertyConversionUtils.ts
|
|
898
|
+
var defaultTypeClasses = [{
|
|
899
|
+
kind: "render_hint",
|
|
900
|
+
name: "SELECTABLE"
|
|
901
|
+
}, {
|
|
902
|
+
kind: "render_hint",
|
|
903
|
+
name: "SORTABLE"
|
|
904
|
+
}];
|
|
905
|
+
function shouldNotHaveRenderHints(type) {
|
|
906
|
+
return ["struct", "mediaReference", "geotimeSeries"].includes(getPropertyTypeName(type));
|
|
907
|
+
}
|
|
908
|
+
function hasRenderHints(typeClasses) {
|
|
909
|
+
return (typeClasses ?? []).some((tc) => tc.kind.toLowerCase() === "render_hint");
|
|
910
|
+
}
|
|
911
|
+
function getPropertyTypeName(type) {
|
|
912
|
+
return typeof type === "object" ? type.type : type;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// src/conversion/toMarketplace/convertValueType.ts
|
|
916
|
+
function convertValueType(valueType) {
|
|
917
|
+
return {
|
|
918
|
+
apiName: valueType.apiName,
|
|
919
|
+
version: valueType.version,
|
|
920
|
+
packageNamespace: valueType.packageNamespace,
|
|
921
|
+
displayMetadata: valueType.displayMetadata
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// src/conversion/toMarketplace/convertDataConstraintToDataConstraints.ts
|
|
926
|
+
function convertDataConstraintToDataConstraints(dc) {
|
|
927
|
+
return {
|
|
928
|
+
propertyTypeConstraints: [{
|
|
929
|
+
constraints: dataConstraintToPropertyTypeDataConstraint(dc)
|
|
930
|
+
// known limitation: structs don't carry field-level data constraint failure messages
|
|
931
|
+
}]
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// src/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.ts
|
|
936
|
+
function dataConstraintToPropertyTypeDataConstraint(dc) {
|
|
937
|
+
switch (dc.type) {
|
|
938
|
+
case "array":
|
|
939
|
+
return {
|
|
940
|
+
...dc
|
|
941
|
+
};
|
|
942
|
+
case "boolean":
|
|
943
|
+
return {
|
|
944
|
+
...dc
|
|
945
|
+
};
|
|
946
|
+
case "binary":
|
|
947
|
+
throw new Error("Binary type constraints are not supported");
|
|
948
|
+
case "date":
|
|
949
|
+
return {
|
|
950
|
+
...dc
|
|
951
|
+
};
|
|
952
|
+
case "decimal":
|
|
953
|
+
return {
|
|
954
|
+
...dc
|
|
955
|
+
};
|
|
956
|
+
case "double":
|
|
957
|
+
return {
|
|
958
|
+
...dc
|
|
959
|
+
};
|
|
960
|
+
case "float":
|
|
961
|
+
return {
|
|
962
|
+
...dc
|
|
963
|
+
};
|
|
964
|
+
case "integer":
|
|
965
|
+
return {
|
|
966
|
+
...dc
|
|
967
|
+
};
|
|
968
|
+
case "long":
|
|
969
|
+
return {
|
|
970
|
+
...dc
|
|
971
|
+
};
|
|
972
|
+
case "map":
|
|
973
|
+
throw new Error("Map type constraints are not supported");
|
|
974
|
+
case "nullable":
|
|
975
|
+
throw new Error("Nullable constraints are not supported");
|
|
976
|
+
case "short":
|
|
977
|
+
return {
|
|
978
|
+
...dc
|
|
979
|
+
};
|
|
980
|
+
case "string":
|
|
981
|
+
return {
|
|
982
|
+
...dc
|
|
983
|
+
};
|
|
984
|
+
case "struct":
|
|
985
|
+
return {
|
|
986
|
+
type: "struct",
|
|
987
|
+
struct: {
|
|
988
|
+
elementConstraints: Object.fromEntries(Object.entries(dc.struct.elementConstraints).map(([field, constraint]) => [field, convertDataConstraintToDataConstraints(constraint)]))
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
case "structV2":
|
|
992
|
+
throw new Error("StructV2 constraints are not supported");
|
|
993
|
+
case "timestamp":
|
|
994
|
+
return {
|
|
995
|
+
...dc
|
|
996
|
+
};
|
|
997
|
+
default:
|
|
998
|
+
throw new Error(`Unknown DataConstraint type: ${dc.type}`);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/conversion/toMarketplace/convertValueTypeDataConstraints.ts
|
|
1003
|
+
function convertValueTypeDataConstraints(dataConstraints) {
|
|
1004
|
+
if (dataConstraints.length === 0) {
|
|
1005
|
+
return void 0;
|
|
1006
|
+
}
|
|
1007
|
+
const propertyTypeConstraints = dataConstraints.map((constraint) => ({
|
|
1008
|
+
constraints: dataConstraintToPropertyTypeDataConstraint(constraint.constraint.constraint),
|
|
1009
|
+
failureMessage: constraint.constraint.failureMessage
|
|
1010
|
+
}));
|
|
1011
|
+
return {
|
|
1012
|
+
propertyTypeConstraints
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1017
|
+
function convertObjectPropertyType(property) {
|
|
994
1018
|
const apiName = namespace + property.apiName;
|
|
995
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1019
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant6__default.default(false) : void 0;
|
|
996
1020
|
const output = {
|
|
997
1021
|
apiName: property.apiName,
|
|
998
1022
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1007,9 +1031,9 @@ function convertProperty(property) {
|
|
|
1007
1031
|
type: property.array ? {
|
|
1008
1032
|
type: "array",
|
|
1009
1033
|
array: {
|
|
1010
|
-
subtype:
|
|
1034
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type)
|
|
1011
1035
|
}
|
|
1012
|
-
} :
|
|
1036
|
+
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1013
1037
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
1014
1038
|
status: convertObjectStatus(property.status),
|
|
1015
1039
|
inlineAction: void 0,
|
|
@@ -1019,103 +1043,319 @@ function convertProperty(property) {
|
|
|
1019
1043
|
};
|
|
1020
1044
|
return output;
|
|
1021
1045
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}]
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
} else {
|
|
1047
|
-
definition = {
|
|
1048
|
-
type: "manyToMany",
|
|
1049
|
-
manyToMany: {
|
|
1050
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
1051
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
1052
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
1053
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
1054
|
-
peeringMetadata: void 0,
|
|
1055
|
-
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
1056
|
-
from: {
|
|
1057
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1058
|
-
object: linkType.many.object.apiName
|
|
1059
|
-
},
|
|
1060
|
-
to: {
|
|
1061
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1062
|
-
object: linkType.many.object.apiName
|
|
1063
|
-
}
|
|
1064
|
-
}],
|
|
1065
|
-
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
1066
|
-
from: {
|
|
1067
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1068
|
-
object: linkType.toMany.object.apiName
|
|
1069
|
-
},
|
|
1070
|
-
to: {
|
|
1071
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1072
|
-
object: linkType.toMany.object.apiName
|
|
1046
|
+
|
|
1047
|
+
// src/conversion/toMarketplace/convertObject.ts
|
|
1048
|
+
function convertObject(objectType) {
|
|
1049
|
+
const propertyDatasources = (objectType.properties ?? []).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
1050
|
+
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1051
|
+
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1052
|
+
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1053
|
+
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1054
|
+
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, objectType.properties ?? []), classificationInputGroup, mandatoryInputGroup);
|
|
1055
|
+
const implementations = objectType.implementsInterfaces ?? [];
|
|
1056
|
+
return {
|
|
1057
|
+
objectType: {
|
|
1058
|
+
displayMetadata: {
|
|
1059
|
+
description: objectType.description,
|
|
1060
|
+
displayName: objectType.displayName,
|
|
1061
|
+
groupDisplayName: void 0,
|
|
1062
|
+
icon: {
|
|
1063
|
+
type: "blueprint",
|
|
1064
|
+
blueprint: objectType.icon ?? {
|
|
1065
|
+
locator: "cube",
|
|
1066
|
+
color: "#2D72D2"
|
|
1073
1067
|
}
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
datasource = {
|
|
1078
|
-
rid: "ri.ontology.main.datasource.link-".concat(linkType.apiName),
|
|
1079
|
-
datasource: {
|
|
1080
|
-
type: "dataset",
|
|
1081
|
-
dataset: {
|
|
1082
|
-
datasetRid: "link-".concat(linkType.apiName),
|
|
1083
|
-
writebackDatasetRid: void 0,
|
|
1084
|
-
objectTypeAPrimaryKeyMapping: [{
|
|
1085
|
-
property: {
|
|
1086
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1087
|
-
object: linkType.many.object.apiName
|
|
1088
|
-
},
|
|
1089
|
-
column: linkType.many.object.primaryKeyPropertyApiName
|
|
1090
|
-
}],
|
|
1091
|
-
objectTypeBPrimaryKeyMapping: [{
|
|
1092
|
-
property: {
|
|
1093
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1094
|
-
object: linkType.toMany.object.apiName
|
|
1095
|
-
},
|
|
1096
|
-
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
1097
|
-
}]
|
|
1098
|
-
}
|
|
1099
|
-
},
|
|
1100
|
-
editsConfiguration: {
|
|
1101
|
-
onlyAllowPrivilegedEdits: false
|
|
1068
|
+
},
|
|
1069
|
+
pluralDisplayName: objectType.pluralDisplayName,
|
|
1070
|
+
visibility: objectType.visibility ?? "NORMAL"
|
|
1102
1071
|
},
|
|
1103
|
-
|
|
1104
|
-
|
|
1072
|
+
primaryKeys: [objectType.primaryKeyPropertyApiName],
|
|
1073
|
+
propertyTypes: Object.fromEntries(objectType.properties?.map((val) => [val.apiName, convertObjectPropertyType(val)]) ?? []),
|
|
1074
|
+
titlePropertyTypeRid: objectType.titlePropertyApiName,
|
|
1075
|
+
apiName: objectType.apiName,
|
|
1076
|
+
status: convertObjectStatus(objectType.status),
|
|
1077
|
+
redacted: false,
|
|
1078
|
+
implementsInterfaces2: implementations.map((impl) => ({
|
|
1079
|
+
interfaceTypeApiName: impl.implements.apiName,
|
|
1080
|
+
linksV2: {},
|
|
1081
|
+
propertiesV2: {},
|
|
1082
|
+
properties: Object.fromEntries(impl.propertyMapping.map((mapping) => [addNamespaceIfNone(mapping.interfaceProperty), {
|
|
1083
|
+
propertyTypeRid: mapping.mapsTo
|
|
1084
|
+
}]))
|
|
1085
|
+
})),
|
|
1086
|
+
allImplementsInterfaces: {}
|
|
1087
|
+
},
|
|
1088
|
+
datasources: [...propertyDatasources, objectDatasource],
|
|
1089
|
+
entityMetadata: {
|
|
1090
|
+
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function extractMarkingGroups(properties, markingType) {
|
|
1095
|
+
return properties.map((prop) => {
|
|
1096
|
+
if (typeof prop.type === "object" && prop.type.type === "marking" && prop.type.markingType === markingType) {
|
|
1097
|
+
return prop.type.markingInputGroupName;
|
|
1098
|
+
}
|
|
1099
|
+
return void 0;
|
|
1100
|
+
}).filter((val) => val !== void 0);
|
|
1101
|
+
}
|
|
1102
|
+
function extractPropertyDatasource(property, objectTypeApiName) {
|
|
1103
|
+
if (!isExotic(property.type)) {
|
|
1104
|
+
return [];
|
|
1105
|
+
}
|
|
1106
|
+
const identifier = objectTypeApiName + "." + property.apiName;
|
|
1107
|
+
switch (property.type) {
|
|
1108
|
+
case "geotimeSeries":
|
|
1109
|
+
const geotimeDefinition = {
|
|
1110
|
+
type: "geotimeSeries",
|
|
1111
|
+
geotimeSeries: {
|
|
1112
|
+
geotimeSeriesIntegrationRid: identifier,
|
|
1113
|
+
properties: [property.apiName]
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
return [buildDatasource(property.apiName, geotimeDefinition)];
|
|
1117
|
+
case "mediaReference":
|
|
1118
|
+
const mediaSetDefinition = {
|
|
1119
|
+
type: "mediaSetView",
|
|
1120
|
+
mediaSetView: {
|
|
1121
|
+
assumedMarkings: [],
|
|
1122
|
+
mediaSetViewLocator: identifier,
|
|
1123
|
+
properties: [property.apiName]
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
return [buildDatasource(property.apiName, mediaSetDefinition)];
|
|
1127
|
+
default:
|
|
1128
|
+
return [];
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1133
|
+
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
1134
|
+
return {
|
|
1135
|
+
objectTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.OBJECT_TYPE]).map(([apiName, objectType]) => {
|
|
1136
|
+
return [apiName, convertObject(objectType)];
|
|
1137
|
+
})),
|
|
1138
|
+
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]).map(([apiName, spt]) => [apiName, {
|
|
1139
|
+
sharedPropertyType: convertSpt(spt)
|
|
1140
|
+
}])),
|
|
1141
|
+
interfaceTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.INTERFACE_TYPE]).map(([apiName, interfaceType]) => {
|
|
1142
|
+
return [apiName, {
|
|
1143
|
+
interfaceType: convertInterface(interfaceType)
|
|
1144
|
+
}];
|
|
1145
|
+
})),
|
|
1146
|
+
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
1147
|
+
return [cleanAndValidateLinkTypeId(id), convertLink(link)];
|
|
1148
|
+
})),
|
|
1149
|
+
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
1150
|
+
return [apiName, convertAction(action)];
|
|
1151
|
+
})),
|
|
1152
|
+
blockPermissionInformation: {
|
|
1153
|
+
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).filter(([apiName, action]) => action.validation).map(([apiName, action]) => {
|
|
1154
|
+
return [apiName, {
|
|
1155
|
+
restrictionStatus: {
|
|
1156
|
+
hasRolesApplied: true,
|
|
1157
|
+
ontologyPackageRid: null,
|
|
1158
|
+
publicProject: false
|
|
1159
|
+
}
|
|
1160
|
+
}];
|
|
1161
|
+
})),
|
|
1162
|
+
linkTypes: {},
|
|
1163
|
+
objectTypes: {}
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// src/conversion/toMarketplace/convertValueTypesToIr.ts
|
|
1169
|
+
function convertValueTypesToIr(valueTypes) {
|
|
1170
|
+
return Object.values(valueTypes).map((definitions) => ({
|
|
1171
|
+
metadata: {
|
|
1172
|
+
apiName: definitions[0].apiName,
|
|
1173
|
+
packageNamespace: definitions[0].packageNamespace,
|
|
1174
|
+
displayMetadata: definitions[0].displayMetadata,
|
|
1175
|
+
status: definitions[0].status
|
|
1176
|
+
},
|
|
1177
|
+
// TODO(dpaquin): instead of deduping here, we should refactor the value type types from arrays to maps
|
|
1178
|
+
versions: Array.from(new Map(definitions.map((definition) => [definition.version, definition])).values()).map((definition) => ({
|
|
1179
|
+
version: definition.version,
|
|
1180
|
+
baseType: definition.baseType,
|
|
1181
|
+
constraints: definition.constraints,
|
|
1182
|
+
exampleValues: definition.exampleValues
|
|
1183
|
+
}))
|
|
1184
|
+
}));
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// src/conversion/toMarketplace/convertOntologyToValueTypeIr.ts
|
|
1188
|
+
function convertOntologyToValueTypeIr(ontology) {
|
|
1189
|
+
return {
|
|
1190
|
+
valueTypes: convertValueTypesToIr(ontology[OntologyEntityTypeEnum.VALUE_TYPE])
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/conversion/toMarketplace/convertOntologyDefinition.ts
|
|
1195
|
+
function convertOntologyDefinition(ontology, randomnessKey) {
|
|
1196
|
+
return {
|
|
1197
|
+
ontology: convertOntologyDefinitionToWireBlockData(ontology),
|
|
1198
|
+
importedOntology: convertOntologyDefinitionToWireBlockData(importedTypes),
|
|
1199
|
+
valueTypes: convertOntologyToValueTypeIr(ontology),
|
|
1200
|
+
importedValueTypes: convertOntologyToValueTypeIr(importedTypes),
|
|
1201
|
+
randomnessKey
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/conversion/toMarketplace/getFormContentOrdering.ts
|
|
1206
|
+
function getFormContentOrdering(action, parameterOrdering) {
|
|
1207
|
+
if (!action.sections) return [];
|
|
1208
|
+
const parametersToSection = Object.fromEntries(Object.entries(action.sections).flatMap(([sectionId, section]) => section.parameters.map((param) => [param, sectionId])));
|
|
1209
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
1210
|
+
const formContentOrdering = [];
|
|
1211
|
+
parameterOrdering.forEach((param) => {
|
|
1212
|
+
if (param in parametersToSection && !seenIds.has(parametersToSection[param])) {
|
|
1213
|
+
formContentOrdering.push({
|
|
1214
|
+
type: "sectionId",
|
|
1215
|
+
sectionId: parametersToSection[param]
|
|
1216
|
+
});
|
|
1217
|
+
seenIds.add(parametersToSection[param]);
|
|
1218
|
+
} else if (!(param in parametersToSection)) {
|
|
1219
|
+
formContentOrdering.push({
|
|
1220
|
+
type: "parameterId",
|
|
1221
|
+
parameterId: param
|
|
1222
|
+
});
|
|
1223
|
+
seenIds.add(param);
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
return formContentOrdering;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/api/defineOntology.ts
|
|
1230
|
+
var ontologyDefinition;
|
|
1231
|
+
var importedTypes;
|
|
1232
|
+
var dependencies;
|
|
1233
|
+
var namespace;
|
|
1234
|
+
function updateOntology(entity) {
|
|
1235
|
+
if (entity.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
1236
|
+
ontologyDefinition[entity.__type][entity.apiName] = entity;
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
if (ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName] === void 0) {
|
|
1240
|
+
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName] = [];
|
|
1241
|
+
}
|
|
1242
|
+
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1243
|
+
}
|
|
1244
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1245
|
+
namespace = ns;
|
|
1246
|
+
dependencies = {};
|
|
1247
|
+
ontologyDefinition = {
|
|
1248
|
+
OBJECT_TYPE: {},
|
|
1249
|
+
ACTION_TYPE: {},
|
|
1250
|
+
LINK_TYPE: {},
|
|
1251
|
+
INTERFACE_TYPE: {},
|
|
1252
|
+
SHARED_PROPERTY_TYPE: {},
|
|
1253
|
+
VALUE_TYPE: {}
|
|
1254
|
+
};
|
|
1255
|
+
importedTypes = {
|
|
1256
|
+
SHARED_PROPERTY_TYPE: {},
|
|
1257
|
+
OBJECT_TYPE: {},
|
|
1258
|
+
ACTION_TYPE: {},
|
|
1259
|
+
LINK_TYPE: {},
|
|
1260
|
+
INTERFACE_TYPE: {},
|
|
1261
|
+
VALUE_TYPE: {}
|
|
1262
|
+
};
|
|
1263
|
+
try {
|
|
1264
|
+
await body();
|
|
1265
|
+
} catch (e) {
|
|
1266
|
+
console.error("Unexpected error while processing the body of the ontology", e);
|
|
1267
|
+
throw e;
|
|
1268
|
+
}
|
|
1269
|
+
if (outputDir) {
|
|
1270
|
+
writeStaticObjects(outputDir);
|
|
1271
|
+
}
|
|
1272
|
+
if (dependencyFile) {
|
|
1273
|
+
writeDependencyFile(dependencyFile);
|
|
1274
|
+
}
|
|
1275
|
+
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1276
|
+
}
|
|
1277
|
+
function writeStaticObjects(outputDir) {
|
|
1278
|
+
const codegenDir = path2__namespace.resolve(outputDir, "codegen");
|
|
1279
|
+
const typeDirs = {
|
|
1280
|
+
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1281
|
+
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
1282
|
+
[OntologyEntityTypeEnum.OBJECT_TYPE]: "object-types",
|
|
1283
|
+
[OntologyEntityTypeEnum.LINK_TYPE]: "link-types",
|
|
1284
|
+
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1285
|
+
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1286
|
+
};
|
|
1287
|
+
if (!fs__namespace.existsSync(codegenDir)) {
|
|
1288
|
+
fs__namespace.mkdirSync(codegenDir, {
|
|
1289
|
+
recursive: true
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1293
|
+
const currentTypeDirPath = path2__namespace.join(codegenDir, typeDirNameFromMap);
|
|
1294
|
+
if (fs__namespace.existsSync(currentTypeDirPath)) {
|
|
1295
|
+
fs__namespace.rmSync(currentTypeDirPath, {
|
|
1296
|
+
recursive: true,
|
|
1297
|
+
force: true
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
fs__namespace.mkdirSync(currentTypeDirPath, {
|
|
1301
|
+
recursive: true
|
|
1302
|
+
});
|
|
1303
|
+
});
|
|
1304
|
+
const topLevelExportStatements = [];
|
|
1305
|
+
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1306
|
+
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1307
|
+
const typeDirPath = path2__namespace.join(codegenDir, typeDirName);
|
|
1308
|
+
const entityModuleNames = [];
|
|
1309
|
+
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1310
|
+
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1311
|
+
const filePath = path2__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1312
|
+
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1313
|
+
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1314
|
+
const content = `
|
|
1315
|
+
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
1316
|
+
import type { ${entityTypeName} } from '@osdk/maker';
|
|
1317
|
+
|
|
1318
|
+
/** @type {import('@osdk/maker').${entityTypeName}} */
|
|
1319
|
+
const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey === "VALUE_TYPE" ? entityJSON.slice(1, -2) : entityJSON} as unknown as ${entityTypeName};
|
|
1320
|
+
|
|
1321
|
+
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1322
|
+
`;
|
|
1323
|
+
fs__namespace.writeFileSync(filePath, content, {
|
|
1324
|
+
flag: "w"
|
|
1325
|
+
});
|
|
1326
|
+
entityModuleNames.push(entityFileNameBase);
|
|
1327
|
+
});
|
|
1328
|
+
for (const entityModuleName of entityModuleNames) {
|
|
1329
|
+
topLevelExportStatements.push(`export { ${entityModuleName} } from "./codegen/${typeDirName}/${entityModuleName}.js";`);
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
if (topLevelExportStatements.length > 0) {
|
|
1333
|
+
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1334
|
+
const mainIndexFilePath = path2__namespace.join(outputDir, "index.ts");
|
|
1335
|
+
fs__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1336
|
+
flag: "w"
|
|
1337
|
+
});
|
|
1105
1338
|
}
|
|
1339
|
+
}
|
|
1340
|
+
function buildDatasource(apiName, definition, classificationMarkingGroupName, mandatoryMarkingGroupName) {
|
|
1341
|
+
const needsSecurity = classificationMarkingGroupName !== void 0 || mandatoryMarkingGroupName !== void 0;
|
|
1342
|
+
const securityConfig = needsSecurity ? {
|
|
1343
|
+
classificationConstraint: classificationMarkingGroupName ? {
|
|
1344
|
+
markingGroupName: classificationMarkingGroupName
|
|
1345
|
+
} : void 0,
|
|
1346
|
+
markingConstraint: mandatoryMarkingGroupName ? {
|
|
1347
|
+
markingGroupName: mandatoryMarkingGroupName
|
|
1348
|
+
} : void 0
|
|
1349
|
+
} : void 0;
|
|
1106
1350
|
return {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
type: "active",
|
|
1112
|
-
active: {}
|
|
1113
|
-
},
|
|
1114
|
-
redacted: linkType.redacted ?? false
|
|
1351
|
+
datasourceName: apiName,
|
|
1352
|
+
datasource: definition,
|
|
1353
|
+
editsConfiguration: {
|
|
1354
|
+
onlyAllowPrivilegedEdits: false
|
|
1115
1355
|
},
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1356
|
+
redacted: false,
|
|
1357
|
+
...securityConfig !== void 0 && {
|
|
1358
|
+
dataSecurity: securityConfig
|
|
1119
1359
|
}
|
|
1120
1360
|
};
|
|
1121
1361
|
}
|
|
@@ -1128,73 +1368,8 @@ function cleanAndValidateLinkTypeId(apiName) {
|
|
|
1128
1368
|
}
|
|
1129
1369
|
return linkTypeId;
|
|
1130
1370
|
}
|
|
1131
|
-
function convertInterface(interfaceType) {
|
|
1132
|
-
const {
|
|
1133
|
-
__type,
|
|
1134
|
-
...other
|
|
1135
|
-
} = interfaceType;
|
|
1136
|
-
return {
|
|
1137
|
-
...other,
|
|
1138
|
-
propertiesV2: Object.fromEntries(Object.values(interfaceType.propertiesV2).map((spt) => [spt.sharedPropertyType.apiName, {
|
|
1139
|
-
required: spt.required,
|
|
1140
|
-
sharedPropertyType: convertSpt(spt.sharedPropertyType)
|
|
1141
|
-
}])),
|
|
1142
|
-
displayMetadata: {
|
|
1143
|
-
displayName: interfaceType.displayMetadata.displayName,
|
|
1144
|
-
description: interfaceType.displayMetadata.description
|
|
1145
|
-
},
|
|
1146
|
-
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1147
|
-
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1148
|
-
properties: [],
|
|
1149
|
-
// TODO(mwalther): Support propertiesV3
|
|
1150
|
-
propertiesV3: {}
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
1371
|
function dumpOntologyFullMetadata() {
|
|
1154
|
-
return
|
|
1155
|
-
}
|
|
1156
|
-
function convertSpt({
|
|
1157
|
-
type,
|
|
1158
|
-
array,
|
|
1159
|
-
description,
|
|
1160
|
-
apiName,
|
|
1161
|
-
displayName,
|
|
1162
|
-
visibility,
|
|
1163
|
-
gothamMapping,
|
|
1164
|
-
typeClasses,
|
|
1165
|
-
valueType,
|
|
1166
|
-
nullability
|
|
1167
|
-
}) {
|
|
1168
|
-
const dataConstraint = convertNullabilityToDataConstraint({
|
|
1169
|
-
type,
|
|
1170
|
-
nullability
|
|
1171
|
-
});
|
|
1172
|
-
return {
|
|
1173
|
-
apiName,
|
|
1174
|
-
displayMetadata: {
|
|
1175
|
-
displayName: displayName ?? apiName,
|
|
1176
|
-
visibility: visibility ?? "NORMAL",
|
|
1177
|
-
description
|
|
1178
|
-
},
|
|
1179
|
-
type: array ? {
|
|
1180
|
-
type: "array",
|
|
1181
|
-
array: {
|
|
1182
|
-
subtype: convertType(type)
|
|
1183
|
-
}
|
|
1184
|
-
} : convertType(type),
|
|
1185
|
-
aliases: [],
|
|
1186
|
-
baseFormatter: void 0,
|
|
1187
|
-
dataConstraints: dataConstraint,
|
|
1188
|
-
gothamMapping,
|
|
1189
|
-
indexedForSearch: true,
|
|
1190
|
-
typeClasses: typeClasses ?? [],
|
|
1191
|
-
valueType: valueType === void 0 ? void 0 : {
|
|
1192
|
-
apiName: valueType.apiName,
|
|
1193
|
-
version: valueType.version,
|
|
1194
|
-
packageNamespace: valueType.packageNamespace,
|
|
1195
|
-
displayMetadata: valueType.displayMetadata
|
|
1196
|
-
}
|
|
1197
|
-
};
|
|
1372
|
+
return convertOntologyDefinition(ontologyDefinition);
|
|
1198
1373
|
}
|
|
1199
1374
|
function convertObjectStatus(status) {
|
|
1200
1375
|
if (status === void 0) {
|
|
@@ -1241,143 +1416,54 @@ function convertAction(action) {
|
|
|
1241
1416
|
validation: actionValidation
|
|
1242
1417
|
},
|
|
1243
1418
|
metadata: {
|
|
1244
|
-
apiName: action.apiName,
|
|
1245
|
-
displayMetadata: {
|
|
1246
|
-
configuration: {
|
|
1247
|
-
defaultLayout: action.defaultFormat ?? "FORM",
|
|
1248
|
-
displayAndFormat: action.displayAndFormat ?? {
|
|
1249
|
-
table: {
|
|
1250
|
-
columnWidthByParameterRid: {},
|
|
1251
|
-
enableFileImport: true,
|
|
1252
|
-
fitHorizontally: false,
|
|
1253
|
-
frozenColumnCount: 0,
|
|
1254
|
-
rowHeightInLines: 1
|
|
1255
|
-
}
|
|
1256
|
-
},
|
|
1257
|
-
enableLayoutUserSwitch: action.enableLayoutSwitch ?? false
|
|
1258
|
-
},
|
|
1259
|
-
description: action.description ?? "",
|
|
1260
|
-
displayName: action.displayName,
|
|
1261
|
-
icon: {
|
|
1262
|
-
type: "blueprint",
|
|
1263
|
-
blueprint: action.icon ?? {
|
|
1264
|
-
locator: "edit",
|
|
1265
|
-
color: "#000000"
|
|
1266
|
-
}
|
|
1267
|
-
},
|
|
1268
|
-
successMessage: action.submissionMetadata?.successMessage ? [{
|
|
1269
|
-
type: "message",
|
|
1270
|
-
message: action.submissionMetadata.successMessage
|
|
1271
|
-
}] : [],
|
|
1272
|
-
typeClasses: action.typeClasses ?? [],
|
|
1273
|
-
...action.submissionMetadata?.submitButtonDisplayMetadata && {
|
|
1274
|
-
submitButtonDisplayMetadata: action.submissionMetadata.submitButtonDisplayMetadata
|
|
1275
|
-
},
|
|
1276
|
-
...action.submissionMetadata?.undoButtonConfiguration && {
|
|
1277
|
-
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1278
|
-
}
|
|
1279
|
-
},
|
|
1280
|
-
parameterOrdering,
|
|
1281
|
-
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1282
|
-
parameters: actionParameters,
|
|
1283
|
-
sections: actionSections,
|
|
1284
|
-
status: typeof action.status === "string" ? {
|
|
1285
|
-
type: action.status,
|
|
1286
|
-
[action.status]: {}
|
|
1287
|
-
} : action.status,
|
|
1288
|
-
entities: action.entities
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
|
-
function convertActionValidation(action) {
|
|
1294
|
-
return {
|
|
1295
|
-
actionTypeLevelValidation: {
|
|
1296
|
-
rules: Object.fromEntries((action.validation ?? [{
|
|
1297
|
-
condition: {
|
|
1298
|
-
type: "true",
|
|
1299
|
-
true: {}
|
|
1300
|
-
},
|
|
1301
|
-
displayMetadata: {
|
|
1302
|
-
failureMessage: "",
|
|
1303
|
-
typeClasses: []
|
|
1304
|
-
}
|
|
1305
|
-
}]).map((rule, idx) => [idx, rule]))
|
|
1306
|
-
},
|
|
1307
|
-
parameterValidations: Object.fromEntries((action.parameters ?? []).map((p) => {
|
|
1308
|
-
return [p.id, {
|
|
1309
|
-
defaultValidation: {
|
|
1310
|
-
display: {
|
|
1311
|
-
renderHint: renderHintFromBaseType(p),
|
|
1312
|
-
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
1313
|
-
...p.defaultValue && {
|
|
1314
|
-
prefill: p.defaultValue
|
|
1315
|
-
}
|
|
1316
|
-
},
|
|
1317
|
-
validation: {
|
|
1318
|
-
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
1319
|
-
required: convertParameterRequirementConstraint(p.validation.required)
|
|
1320
|
-
}
|
|
1321
|
-
},
|
|
1322
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
1323
|
-
}];
|
|
1324
|
-
})),
|
|
1325
|
-
sectionValidations: {
|
|
1326
|
-
...Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [section.id, {
|
|
1327
|
-
defaultDisplayMetadata: section.defaultVisibility === "hidden" ? {
|
|
1328
|
-
visibility: {
|
|
1329
|
-
type: "hidden",
|
|
1330
|
-
hidden: {}
|
|
1331
|
-
}
|
|
1332
|
-
} : {
|
|
1333
|
-
visibility: {
|
|
1334
|
-
type: "visible",
|
|
1335
|
-
visible: {}
|
|
1336
|
-
}
|
|
1337
|
-
},
|
|
1338
|
-
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible")) ?? []
|
|
1339
|
-
}]))
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
function convertActionParameters(action) {
|
|
1344
|
-
return Object.fromEntries((action.parameters ?? []).map((p) => [p.id, {
|
|
1345
|
-
id: p.id,
|
|
1346
|
-
type: typeof p.type === "string" ? {
|
|
1347
|
-
type: p.type,
|
|
1348
|
-
[p.type]: {}
|
|
1349
|
-
} : p.type,
|
|
1350
|
-
displayMetadata: {
|
|
1351
|
-
displayName: p.displayName,
|
|
1352
|
-
description: p.description ?? "",
|
|
1353
|
-
typeClasses: []
|
|
1354
|
-
}
|
|
1355
|
-
}]));
|
|
1356
|
-
}
|
|
1357
|
-
function convertActionSections(action) {
|
|
1358
|
-
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [sectionId, {
|
|
1359
|
-
id: sectionId,
|
|
1360
|
-
content: section.parameters.map((p) => ({
|
|
1361
|
-
type: "parameterId",
|
|
1362
|
-
parameterId: p
|
|
1363
|
-
})),
|
|
1364
|
-
displayMetadata: {
|
|
1365
|
-
collapsedByDefault: section.collapsedByDefault ?? false,
|
|
1366
|
-
columnCount: section.columnCount ?? 1,
|
|
1367
|
-
description: section.description ?? "",
|
|
1368
|
-
displayName: section.displayName ?? convertToDisplayName(sectionId),
|
|
1369
|
-
showTitleBar: section.showTitleBar ?? true,
|
|
1370
|
-
...section.style && {
|
|
1371
|
-
style: section.style === "box" ? {
|
|
1372
|
-
type: "box",
|
|
1373
|
-
box: {}
|
|
1374
|
-
} : {
|
|
1375
|
-
type: "minimal",
|
|
1376
|
-
minimal: {}
|
|
1377
|
-
}
|
|
1419
|
+
apiName: action.apiName,
|
|
1420
|
+
displayMetadata: {
|
|
1421
|
+
configuration: {
|
|
1422
|
+
defaultLayout: action.defaultFormat ?? "FORM",
|
|
1423
|
+
displayAndFormat: action.displayAndFormat ?? {
|
|
1424
|
+
table: {
|
|
1425
|
+
columnWidthByParameterRid: {},
|
|
1426
|
+
enableFileImport: true,
|
|
1427
|
+
fitHorizontally: false,
|
|
1428
|
+
frozenColumnCount: 0,
|
|
1429
|
+
rowHeightInLines: 1
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1432
|
+
enableLayoutUserSwitch: action.enableLayoutSwitch ?? false
|
|
1433
|
+
},
|
|
1434
|
+
description: action.description ?? "",
|
|
1435
|
+
displayName: action.displayName,
|
|
1436
|
+
icon: {
|
|
1437
|
+
type: "blueprint",
|
|
1438
|
+
blueprint: action.icon ?? {
|
|
1439
|
+
locator: "edit",
|
|
1440
|
+
color: "#000000"
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
successMessage: action.submissionMetadata?.successMessage ? [{
|
|
1444
|
+
type: "message",
|
|
1445
|
+
message: action.submissionMetadata.successMessage
|
|
1446
|
+
}] : [],
|
|
1447
|
+
typeClasses: action.typeClasses ?? [],
|
|
1448
|
+
...action.submissionMetadata?.submitButtonDisplayMetadata && {
|
|
1449
|
+
submitButtonDisplayMetadata: action.submissionMetadata.submitButtonDisplayMetadata
|
|
1450
|
+
},
|
|
1451
|
+
...action.submissionMetadata?.undoButtonConfiguration && {
|
|
1452
|
+
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1455
|
+
parameterOrdering,
|
|
1456
|
+
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1457
|
+
parameters: actionParameters,
|
|
1458
|
+
sections: actionSections,
|
|
1459
|
+
status: typeof action.status === "string" ? {
|
|
1460
|
+
type: action.status,
|
|
1461
|
+
[action.status]: {}
|
|
1462
|
+
} : action.status,
|
|
1463
|
+
entities: action.entities
|
|
1378
1464
|
}
|
|
1379
1465
|
}
|
|
1380
|
-
}
|
|
1466
|
+
};
|
|
1381
1467
|
}
|
|
1382
1468
|
function extractAllowedValues(allowedValues) {
|
|
1383
1469
|
switch (allowedValues.type) {
|
|
@@ -1576,31 +1662,6 @@ function renderHintFromBaseType(parameter) {
|
|
|
1576
1662
|
throw new Error(`Unknown type ${type}`);
|
|
1577
1663
|
}
|
|
1578
1664
|
}
|
|
1579
|
-
function convertParameterRequirementConstraint(required) {
|
|
1580
|
-
if (typeof required === "boolean") {
|
|
1581
|
-
return required ? {
|
|
1582
|
-
type: "required",
|
|
1583
|
-
required: {}
|
|
1584
|
-
} : {
|
|
1585
|
-
type: "notRequired",
|
|
1586
|
-
notRequired: {}
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
const {
|
|
1590
|
-
min,
|
|
1591
|
-
max
|
|
1592
|
-
} = required.listLength;
|
|
1593
|
-
return {
|
|
1594
|
-
type: "listLengthValidation",
|
|
1595
|
-
listLengthValidation: {
|
|
1596
|
-
minLength: min,
|
|
1597
|
-
maxLength: max
|
|
1598
|
-
}
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1601
|
-
function sanitize(namespace2, s) {
|
|
1602
|
-
return s.includes(".") ? s : namespace2 + s;
|
|
1603
|
-
}
|
|
1604
1665
|
function withoutNamespace(apiName) {
|
|
1605
1666
|
const lastDot = apiName.lastIndexOf(".");
|
|
1606
1667
|
if (lastDot === -1) {
|
|
@@ -1639,17 +1700,12 @@ addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
|
1639
1700
|
function addNamespaceIfNone(apiName) {
|
|
1640
1701
|
return apiName.includes(".") ? apiName : namespace + apiName;
|
|
1641
1702
|
}
|
|
1642
|
-
function convertCardinality(cardinality) {
|
|
1643
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
1644
|
-
return "ONE_TO_MANY";
|
|
1645
|
-
}
|
|
1646
|
-
return "ONE_TO_ONE";
|
|
1647
|
-
}
|
|
1648
1703
|
|
|
1649
1704
|
// src/cli/main.ts
|
|
1650
1705
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1706
|
+
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1651
1707
|
async function main(args = process.argv) {
|
|
1652
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
1708
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.2").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1653
1709
|
input: {
|
|
1654
1710
|
alias: "i",
|
|
1655
1711
|
describe: "Input file",
|
|
@@ -1692,24 +1748,32 @@ async function main(args = process.argv) {
|
|
|
1692
1748
|
describe: "File to write dependencies to",
|
|
1693
1749
|
type: "string",
|
|
1694
1750
|
coerce: path2__namespace.resolve
|
|
1751
|
+
},
|
|
1752
|
+
randomnessKey: {
|
|
1753
|
+
describe: "Value used to assure uniqueness of entities",
|
|
1754
|
+
type: "string",
|
|
1755
|
+
coerce: path2__namespace.resolve
|
|
1695
1756
|
}
|
|
1696
1757
|
}).parseAsync();
|
|
1697
1758
|
let apiNamespace = "";
|
|
1698
1759
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1699
1760
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
1700
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
1701
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
1761
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "API namespace is too long.") : invariant6__default.default(false) : void 0;
|
|
1762
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant6__default.default(false) : void 0;
|
|
1702
1763
|
}
|
|
1703
1764
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1704
|
-
|
|
1765
|
+
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1766
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant6__default.default(false) : void 0;
|
|
1767
|
+
}
|
|
1768
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
1705
1769
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1706
1770
|
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1707
1771
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1708
1772
|
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1709
1773
|
}
|
|
1710
1774
|
}
|
|
1711
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1712
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
|
|
1775
|
+
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
|
|
1776
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
1713
1777
|
return q;
|
|
1714
1778
|
}
|
|
1715
1779
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -1732,36 +1796,68 @@ function addDependency(namespaceNoDot, fileInPackage) {
|
|
|
1732
1796
|
const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1733
1797
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1734
1798
|
}
|
|
1735
|
-
function
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1799
|
+
function convertMappingValue(value) {
|
|
1800
|
+
switch (value.type) {
|
|
1801
|
+
case "uuid":
|
|
1802
|
+
return {
|
|
1803
|
+
type: "uniqueIdentifier",
|
|
1804
|
+
uniqueIdentifier: {
|
|
1805
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
case "currentTime":
|
|
1809
|
+
return {
|
|
1810
|
+
type: "currentTime",
|
|
1811
|
+
currentTime: {}
|
|
1812
|
+
};
|
|
1813
|
+
case "currentUser":
|
|
1814
|
+
return {
|
|
1815
|
+
type: "currentUser",
|
|
1816
|
+
currentUser: {}
|
|
1817
|
+
};
|
|
1818
|
+
default:
|
|
1819
|
+
return value;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// src/api/action/ActionParameterType.ts
|
|
1824
|
+
function isActionParameterTypePrimitive(type) {
|
|
1825
|
+
return ["boolean", "booleanList", "integer", "integerList", "long", "longList", "double", "doubleList", "string", "stringList", "decimal", "decimalList", "timestamp", "timestampList", "geohash", "geohashList", "geoshape", "geoshapeList", "timeSeriesReference", "date", "dateList", "objectTypeReference", "objectReference", "attachment", "attachmentList", "marking", "markingList", "mediaReference", "mediaReferenceList", "geotimeSeriesReference", "geotimeSeriesReferenceList"].includes(type);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
// src/api/defineAction.ts
|
|
1829
|
+
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1830
|
+
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1831
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
1832
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1833
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1834
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the create action because they are structs`);
|
|
1739
1835
|
}
|
|
1740
1836
|
return defineAction({
|
|
1741
|
-
apiName: `create-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1742
|
-
displayName: `Create ${interfaceType.displayMetadata.displayName}`,
|
|
1837
|
+
apiName: `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1838
|
+
displayName: `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
1743
1839
|
parameters: [{
|
|
1744
1840
|
id: "objectTypeParameter",
|
|
1745
1841
|
displayName: "Object type to create",
|
|
1746
1842
|
type: {
|
|
1747
1843
|
type: "objectTypeReference",
|
|
1748
1844
|
objectTypeReference: {
|
|
1749
|
-
interfaceTypeRids: [interfaceType.apiName]
|
|
1845
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1750
1846
|
}
|
|
1751
1847
|
},
|
|
1752
1848
|
validation: {
|
|
1753
1849
|
required: true,
|
|
1754
|
-
allowedValues: objectType === void 0 ? {
|
|
1850
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1755
1851
|
type: "objectTypeReference",
|
|
1756
|
-
interfaceTypes: [interfaceType.apiName]
|
|
1852
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
1757
1853
|
} : {
|
|
1758
1854
|
type: "oneOf",
|
|
1759
1855
|
oneOf: [{
|
|
1760
|
-
label: objectType.displayName,
|
|
1856
|
+
label: def.objectType.displayName,
|
|
1761
1857
|
value: {
|
|
1762
1858
|
type: "objectType",
|
|
1763
1859
|
objectType: {
|
|
1764
|
-
objectTypeId: objectType.apiName
|
|
1860
|
+
objectTypeId: def.objectType.apiName
|
|
1765
1861
|
}
|
|
1766
1862
|
}
|
|
1767
1863
|
}]
|
|
@@ -1779,9 +1875,9 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1779
1875
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1780
1876
|
}
|
|
1781
1877
|
}))],
|
|
1782
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
1878
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1783
1879
|
entities: {
|
|
1784
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
1880
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1785
1881
|
affectedObjectTypes: [],
|
|
1786
1882
|
affectedLinkTypes: [],
|
|
1787
1883
|
typeGroups: []
|
|
@@ -1789,7 +1885,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1789
1885
|
rules: [{
|
|
1790
1886
|
type: "addInterfaceRule",
|
|
1791
1887
|
addInterfaceRule: {
|
|
1792
|
-
interfaceApiName: interfaceType.apiName,
|
|
1888
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
1793
1889
|
objectTypeParameter: "objectTypeParameter",
|
|
1794
1890
|
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1795
1891
|
type: "parameterId",
|
|
@@ -1797,8 +1893,8 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1797
1893
|
}]))
|
|
1798
1894
|
}
|
|
1799
1895
|
}],
|
|
1800
|
-
...validation ? {
|
|
1801
|
-
validation: convertValidationRule(validation)
|
|
1896
|
+
...def.validation ? {
|
|
1897
|
+
validation: convertValidationRule(def.validation)
|
|
1802
1898
|
} : {}
|
|
1803
1899
|
});
|
|
1804
1900
|
}
|
|
@@ -1840,7 +1936,7 @@ function defineCreateObjectAction(def) {
|
|
|
1840
1936
|
}],
|
|
1841
1937
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1842
1938
|
...def.actionLevelValidation ? {
|
|
1843
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
1939
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
1844
1940
|
} : {},
|
|
1845
1941
|
...def.defaultFormat && {
|
|
1846
1942
|
defaultFormat: def.defaultFormat
|
|
@@ -1859,35 +1955,35 @@ function defineCreateObjectAction(def) {
|
|
|
1859
1955
|
}
|
|
1860
1956
|
});
|
|
1861
1957
|
}
|
|
1862
|
-
function defineModifyInterfaceObjectAction(
|
|
1863
|
-
const allProperties = Object.entries(
|
|
1864
|
-
if (allProperties.length !== Object.entries(
|
|
1865
|
-
consola.consola.info(`Some properties on ${interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1958
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
1959
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1960
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1961
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1866
1962
|
}
|
|
1867
1963
|
return defineAction({
|
|
1868
|
-
apiName: `modify-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1869
|
-
displayName: `Modify ${interfaceType.displayMetadata.displayName}`,
|
|
1964
|
+
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1965
|
+
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1870
1966
|
parameters: [{
|
|
1871
1967
|
id: "interfaceObjectToModifyParameter",
|
|
1872
1968
|
displayName: "Object type to modify",
|
|
1873
1969
|
type: {
|
|
1874
1970
|
type: "interfaceReference",
|
|
1875
1971
|
interfaceReference: {
|
|
1876
|
-
interfaceTypeRid: interfaceType.apiName
|
|
1972
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
1877
1973
|
}
|
|
1878
1974
|
},
|
|
1879
1975
|
validation: {
|
|
1880
1976
|
required: true,
|
|
1881
|
-
allowedValues: objectType === void 0 ? {
|
|
1977
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1882
1978
|
type: "interfaceObjectQuery"
|
|
1883
1979
|
} : {
|
|
1884
1980
|
type: "oneOf",
|
|
1885
1981
|
oneOf: [{
|
|
1886
|
-
label: objectType.displayName,
|
|
1982
|
+
label: def.objectType.displayName,
|
|
1887
1983
|
value: {
|
|
1888
1984
|
type: "objectType",
|
|
1889
1985
|
objectType: {
|
|
1890
|
-
objectTypeId: objectType.apiName
|
|
1986
|
+
objectTypeId: def.objectType.apiName
|
|
1891
1987
|
}
|
|
1892
1988
|
}
|
|
1893
1989
|
}]
|
|
@@ -1905,9 +2001,9 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1905
2001
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1906
2002
|
}
|
|
1907
2003
|
}))],
|
|
1908
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
2004
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1909
2005
|
entities: {
|
|
1910
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
2006
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1911
2007
|
affectedObjectTypes: [],
|
|
1912
2008
|
affectedLinkTypes: [],
|
|
1913
2009
|
typeGroups: []
|
|
@@ -1922,8 +2018,8 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1922
2018
|
}]))
|
|
1923
2019
|
}
|
|
1924
2020
|
}],
|
|
1925
|
-
...validation ? {
|
|
1926
|
-
validation: convertValidationRule(validation)
|
|
2021
|
+
...def.validation ? {
|
|
2022
|
+
validation: convertValidationRule(def.validation)
|
|
1927
2023
|
} : {}
|
|
1928
2024
|
});
|
|
1929
2025
|
}
|
|
@@ -1980,7 +2076,7 @@ function defineModifyObjectAction(def) {
|
|
|
1980
2076
|
},
|
|
1981
2077
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
1982
2078
|
...def.actionLevelValidation ? {
|
|
1983
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2079
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
1984
2080
|
} : {},
|
|
1985
2081
|
...def.defaultFormat && {
|
|
1986
2082
|
defaultFormat: def.defaultFormat
|
|
@@ -2090,7 +2186,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2090
2186
|
},
|
|
2091
2187
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2092
2188
|
...def.actionLevelValidation ? {
|
|
2093
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2189
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2094
2190
|
} : {},
|
|
2095
2191
|
...def.defaultFormat && {
|
|
2096
2192
|
defaultFormat: def.defaultFormat
|
|
@@ -2115,21 +2211,38 @@ function defineAction(actionDef) {
|
|
|
2115
2211
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2116
2212
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2117
2213
|
}
|
|
2118
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2214
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant6__default.default(false) : void 0;
|
|
2119
2215
|
const parameterIdsSet = new Set(parameterIds);
|
|
2120
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2216
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ids must be unique`) : invariant6__default.default(false) : void 0;
|
|
2121
2217
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2122
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2218
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant6__default.default(false) : void 0;
|
|
2123
2219
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2124
2220
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2125
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2126
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2221
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant6__default.default(false) : void 0;
|
|
2222
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant6__default.default(false) : void 0;
|
|
2127
2223
|
actionDef.rules.forEach((rule) => {
|
|
2128
2224
|
if (rule.type === "modifyObjectRule") {
|
|
2129
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2225
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2130
2226
|
}
|
|
2131
2227
|
if (rule.type === "deleteObjectRule") {
|
|
2132
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2228
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2229
|
+
}
|
|
2230
|
+
if (rule.type === "modifyInterfaceRule") {
|
|
2231
|
+
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2232
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant6__default.default(false) : void 0;
|
|
2233
|
+
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2234
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2235
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2236
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2237
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant6__default.default(false) : void 0;
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
if (rule.type === "addInterfaceRule") {
|
|
2241
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2242
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2243
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2244
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2245
|
+
});
|
|
2133
2246
|
}
|
|
2134
2247
|
});
|
|
2135
2248
|
const fullAction = {
|
|
@@ -2204,7 +2317,7 @@ function createParameters(def, parameterSet) {
|
|
|
2204
2317
|
});
|
|
2205
2318
|
return [...targetParam, ...Array.from(parameterSet).map((id) => ({
|
|
2206
2319
|
id,
|
|
2207
|
-
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ??
|
|
2320
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2208
2321
|
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2209
2322
|
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2210
2323
|
...def.parameterConfiguration?.[id],
|
|
@@ -2233,14 +2346,14 @@ function referencedParameterIds(actionDef) {
|
|
|
2233
2346
|
actionDef.rules.forEach((rule) => {
|
|
2234
2347
|
switch (rule.type) {
|
|
2235
2348
|
case "addInterfaceRule":
|
|
2236
|
-
rule.addInterfaceRule.interfaceApiName =
|
|
2349
|
+
rule.addInterfaceRule.interfaceApiName = sanitize(rule.addInterfaceRule.interfaceApiName);
|
|
2237
2350
|
parameterIds.add(rule.addInterfaceRule.objectTypeParameter);
|
|
2238
2351
|
Object.entries(rule.addInterfaceRule.sharedPropertyValues).forEach(([k, v]) => {
|
|
2239
2352
|
if (v.type === "parameterId") {
|
|
2240
2353
|
parameterIds.add(v.parameterId);
|
|
2241
2354
|
}
|
|
2242
2355
|
delete rule.addInterfaceRule.sharedPropertyValues[k];
|
|
2243
|
-
rule.addInterfaceRule.sharedPropertyValues[
|
|
2356
|
+
rule.addInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2244
2357
|
});
|
|
2245
2358
|
break;
|
|
2246
2359
|
case "modifyInterfaceRule":
|
|
@@ -2250,7 +2363,7 @@ function referencedParameterIds(actionDef) {
|
|
|
2250
2363
|
parameterIds.add(v.parameterId);
|
|
2251
2364
|
}
|
|
2252
2365
|
delete rule.modifyInterfaceRule.sharedPropertyValues[k];
|
|
2253
|
-
rule.modifyInterfaceRule.sharedPropertyValues[
|
|
2366
|
+
rule.modifyInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2254
2367
|
});
|
|
2255
2368
|
break;
|
|
2256
2369
|
case "addObjectRule":
|
|
@@ -2479,22 +2592,16 @@ function extractActionParameterType(pt) {
|
|
|
2479
2592
|
function maybeAddList(type, pt) {
|
|
2480
2593
|
return pt.array ?? false ? type + "List" : type;
|
|
2481
2594
|
}
|
|
2482
|
-
function isActionParameterTypePrimitive(type) {
|
|
2483
|
-
return ["boolean", "booleanList", "integer", "integerList", "long", "longList", "double", "doubleList", "string", "stringList", "decimal", "decimalList", "timestamp", "timestampList", "geohash", "geohashList", "geoshape", "geoshapeList", "timeSeriesReference", "date", "dateList", "objectTypeReference", "objectReference", "attachment", "attachmentList", "marking", "markingList", "mediaReference", "mediaReferenceList", "geotimeSeriesReference", "geotimeSeriesReferenceList"].includes(type);
|
|
2484
|
-
}
|
|
2485
|
-
function isStruct(type) {
|
|
2486
|
-
return typeof type === "object" && type.type === "struct";
|
|
2487
|
-
}
|
|
2488
2595
|
function kebab(s) {
|
|
2489
2596
|
return s.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/\./g, "-").toLowerCase();
|
|
2490
2597
|
}
|
|
2491
|
-
function
|
|
2598
|
+
function sanitize(s) {
|
|
2492
2599
|
return s.includes(".") ? s : namespace + s;
|
|
2493
2600
|
}
|
|
2494
|
-
function convertValidationRule(actionValidation) {
|
|
2601
|
+
function convertValidationRule(actionValidation, actionParameters) {
|
|
2495
2602
|
return actionValidation.map((rule) => {
|
|
2496
2603
|
return {
|
|
2497
|
-
condition: convertConditionDefinition(rule.condition),
|
|
2604
|
+
condition: convertConditionDefinition(rule.condition, actionParameters),
|
|
2498
2605
|
displayMetadata: rule.displayMetadata ?? {
|
|
2499
2606
|
failureMessage: "Did not satisfy validation",
|
|
2500
2607
|
typeClasses: []
|
|
@@ -2521,9 +2628,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
2521
2628
|
switch (condition.type) {
|
|
2522
2629
|
case "parameter":
|
|
2523
2630
|
const overrideParamId = condition.parameterId;
|
|
2524
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2525
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2526
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2631
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2632
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant6__default.default(false) : void 0;
|
|
2633
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2527
2634
|
break;
|
|
2528
2635
|
case "and":
|
|
2529
2636
|
if ("conditions" in condition) {
|
|
@@ -2551,11 +2658,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2551
2658
|
if (!defaultValue) return;
|
|
2552
2659
|
switch (defaultValue.type) {
|
|
2553
2660
|
case "objectParameterPropertyValue":
|
|
2554
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2555
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2661
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2662
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2556
2663
|
break;
|
|
2557
2664
|
case "staticValue":
|
|
2558
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
2665
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant6__default.default(false) : void 0;
|
|
2559
2666
|
break;
|
|
2560
2667
|
case "staticObject":
|
|
2561
2668
|
case "interfaceParameterPropertyValue":
|
|
@@ -2570,10 +2677,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2570
2677
|
}
|
|
2571
2678
|
function validateActionParameters(def) {
|
|
2572
2679
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2573
|
-
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ?
|
|
2680
|
+
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant6__default.default(false) : void 0;
|
|
2574
2681
|
});
|
|
2575
2682
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2576
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2683
|
+
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2577
2684
|
});
|
|
2578
2685
|
}
|
|
2579
2686
|
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
@@ -2583,48 +2690,12 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2583
2690
|
const orderingSet = new Set(parameterOrdering);
|
|
2584
2691
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2585
2692
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2586
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
// src/api/importOntologyEntity.ts
|
|
2590
|
-
function importOntologyEntity(e) {
|
|
2591
|
-
if (e.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
2592
|
-
importedTypes[e.__type][e.apiName] = e;
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
|
-
if (importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] === void 0) {
|
|
2596
|
-
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] = [];
|
|
2597
|
-
}
|
|
2598
|
-
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName].push(e);
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2601
|
-
// src/api/defineImportSpt.ts
|
|
2602
|
-
function importSharedPropertyType(opts) {
|
|
2603
|
-
const {
|
|
2604
|
-
apiName,
|
|
2605
|
-
packageName,
|
|
2606
|
-
typeHint,
|
|
2607
|
-
array
|
|
2608
|
-
} = opts;
|
|
2609
|
-
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
2610
|
-
if (packageName !== void 0) {
|
|
2611
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Package name format invalid ends with period") : invariant5__default.default(false) : void 0;
|
|
2612
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Package name includes upper case characters") : invariant5__default.default(false) : void 0;
|
|
2613
|
-
}
|
|
2614
|
-
const spt = {
|
|
2615
|
-
apiName: fullApiName,
|
|
2616
|
-
type: typeHint,
|
|
2617
|
-
nonNameSpacedApiName: apiName,
|
|
2618
|
-
array: array ?? false,
|
|
2619
|
-
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
2620
|
-
};
|
|
2621
|
-
importOntologyEntity(spt);
|
|
2622
|
-
return spt;
|
|
2693
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant6__default.default(false) : void 0;
|
|
2623
2694
|
}
|
|
2624
2695
|
function defineSharedPropertyType(sptDef) {
|
|
2625
2696
|
const apiName = namespace + sptDef.apiName;
|
|
2626
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2627
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
2697
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${apiName} already exists`) : invariant6__default.default(false) : void 0;
|
|
2698
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant6__default.default(false) : void 0;
|
|
2628
2699
|
const fullSpt = {
|
|
2629
2700
|
...sptDef,
|
|
2630
2701
|
apiName,
|
|
@@ -2638,27 +2709,61 @@ function defineSharedPropertyType(sptDef) {
|
|
|
2638
2709
|
return fullSpt;
|
|
2639
2710
|
}
|
|
2640
2711
|
|
|
2712
|
+
// src/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.ts
|
|
2713
|
+
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
2714
|
+
switch (status.type) {
|
|
2715
|
+
case "deprecated":
|
|
2716
|
+
return {
|
|
2717
|
+
type: "deprecated",
|
|
2718
|
+
deprecated: {
|
|
2719
|
+
message: status.message,
|
|
2720
|
+
deadline: status.deadline,
|
|
2721
|
+
replacedBy: void 0
|
|
2722
|
+
}
|
|
2723
|
+
};
|
|
2724
|
+
case "active":
|
|
2725
|
+
return {
|
|
2726
|
+
type: "active",
|
|
2727
|
+
active: {}
|
|
2728
|
+
};
|
|
2729
|
+
case "experimental":
|
|
2730
|
+
return {
|
|
2731
|
+
type: "experimental",
|
|
2732
|
+
experimental: {}
|
|
2733
|
+
};
|
|
2734
|
+
default:
|
|
2735
|
+
throw new Error(`Invalid status type: ${status.type}`);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
// src/api/namespace/combineApiNamespaceIfMissing.ts
|
|
2740
|
+
function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
2741
|
+
return apiName.includes(".") ? apiName : namespace2 + apiName;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2641
2744
|
// src/api/defineInterface.ts
|
|
2642
2745
|
function defineInterface(interfaceDef) {
|
|
2643
2746
|
const apiName = namespace + interfaceDef.apiName;
|
|
2644
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2645
|
-
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([
|
|
2747
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface ${apiName} already exists`) : invariant6__default.default(false) : void 0;
|
|
2748
|
+
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2646
2749
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2647
|
-
|
|
2750
|
+
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
2751
|
+
return [apiName3, {
|
|
2648
2752
|
required: type.required,
|
|
2649
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2753
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type.propertyDefinition)
|
|
2650
2754
|
}];
|
|
2651
2755
|
}
|
|
2652
|
-
|
|
2756
|
+
const apiName2 = combineApiNamespaceIfMissing(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
2757
|
+
return [apiName2, {
|
|
2653
2758
|
required: true,
|
|
2654
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2759
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
2655
2760
|
}];
|
|
2656
2761
|
}));
|
|
2657
2762
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
2658
2763
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2659
2764
|
type: "active"
|
|
2660
2765
|
});
|
|
2661
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
2766
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant6__default.default(false) : void 0;
|
|
2662
2767
|
const fullInterface = {
|
|
2663
2768
|
apiName,
|
|
2664
2769
|
displayMetadata: {
|
|
@@ -2682,37 +2787,9 @@ function defineInterface(interfaceDef) {
|
|
|
2682
2787
|
updateOntology(fullInterface);
|
|
2683
2788
|
return fullInterface;
|
|
2684
2789
|
}
|
|
2685
|
-
function isPropertyTypeType(v) {
|
|
2686
|
-
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || typeof v === "object" && v.type === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
2687
|
-
}
|
|
2688
|
-
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
2689
|
-
switch (status.type) {
|
|
2690
|
-
case "deprecated":
|
|
2691
|
-
return {
|
|
2692
|
-
type: "deprecated",
|
|
2693
|
-
deprecated: {
|
|
2694
|
-
message: status.message,
|
|
2695
|
-
deadline: status.deadline,
|
|
2696
|
-
replacedBy: void 0
|
|
2697
|
-
}
|
|
2698
|
-
};
|
|
2699
|
-
case "active":
|
|
2700
|
-
return {
|
|
2701
|
-
type: "active",
|
|
2702
|
-
active: {}
|
|
2703
|
-
};
|
|
2704
|
-
case "experimental":
|
|
2705
|
-
return {
|
|
2706
|
-
type: "experimental",
|
|
2707
|
-
experimental: {}
|
|
2708
|
-
};
|
|
2709
|
-
default:
|
|
2710
|
-
throw new Error(`Invalid status type: ${status.type}`);
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
2790
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2714
2791
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2715
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
2792
|
+
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant6__default.default(false) : void 0;
|
|
2716
2793
|
const spt = defineSharedPropertyType({
|
|
2717
2794
|
apiName,
|
|
2718
2795
|
displayName: apiName,
|
|
@@ -2722,16 +2799,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2722
2799
|
return spt;
|
|
2723
2800
|
} else {
|
|
2724
2801
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2725
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
2802
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
2726
2803
|
key: apiName,
|
|
2727
2804
|
apiName: type.apiName
|
|
2728
|
-
})}`) :
|
|
2805
|
+
})}`) : invariant6__default.default(false) : void 0;
|
|
2729
2806
|
return type;
|
|
2730
2807
|
}
|
|
2731
2808
|
}
|
|
2732
2809
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2733
2810
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2734
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
2811
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2735
2812
|
linkDef.from.links.push({
|
|
2736
2813
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2737
2814
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2751,7 +2828,7 @@ function getLinkMeta(meta) {
|
|
|
2751
2828
|
displayName,
|
|
2752
2829
|
description
|
|
2753
2830
|
} = meta;
|
|
2754
|
-
const apiNameWithNamespace =
|
|
2831
|
+
const apiNameWithNamespace = combineApiNamespaceIfMissing(namespace, apiName);
|
|
2755
2832
|
const apiNameWithoutNamespace = withoutNamespace(apiNameWithNamespace);
|
|
2756
2833
|
return {
|
|
2757
2834
|
apiName: apiNameWithNamespace,
|
|
@@ -2763,20 +2840,35 @@ var typeIdPattern = /([a-z][a-z0-9\\-]*)/;
|
|
|
2763
2840
|
function defineLink(linkDefinition) {
|
|
2764
2841
|
if ("one" in linkDefinition) {
|
|
2765
2842
|
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2766
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2767
|
-
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2843
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant6__default.default(false) : void 0;
|
|
2844
|
+
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant6__default.default(false) : void 0;
|
|
2768
2845
|
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2769
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
2770
|
-
}
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
one
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2846
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant6__default.default(false) : void 0;
|
|
2847
|
+
}
|
|
2848
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
2849
|
+
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2850
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2851
|
+
}
|
|
2852
|
+
let fullLinkDefinition;
|
|
2853
|
+
if ("one" in linkDefinition) {
|
|
2854
|
+
fullLinkDefinition = {
|
|
2855
|
+
...linkDefinition,
|
|
2856
|
+
one: convertUserOneToManyLinkDefinition(linkDefinition.one),
|
|
2857
|
+
toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany)
|
|
2858
|
+
};
|
|
2859
|
+
} else if ("intermediaryObjectType" in linkDefinition) {
|
|
2860
|
+
fullLinkDefinition = {
|
|
2861
|
+
...linkDefinition,
|
|
2862
|
+
many: convertUserIntermediaryLinkDefinition(linkDefinition.many),
|
|
2863
|
+
toMany: convertUserIntermediaryLinkDefinition(linkDefinition.toMany)
|
|
2864
|
+
};
|
|
2865
|
+
} else {
|
|
2866
|
+
fullLinkDefinition = {
|
|
2867
|
+
...linkDefinition,
|
|
2868
|
+
many: convertUserManyToManyLinkDefinition(linkDefinition.many),
|
|
2869
|
+
toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany)
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2780
2872
|
const linkType = {
|
|
2781
2873
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2782
2874
|
...fullLinkDefinition,
|
|
@@ -2797,11 +2889,17 @@ function convertUserManyToManyLinkDefinition(manyToMany) {
|
|
|
2797
2889
|
metadata: convertLinkTypeMetadata(manyToMany.metadata)
|
|
2798
2890
|
};
|
|
2799
2891
|
}
|
|
2892
|
+
function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
2893
|
+
return {
|
|
2894
|
+
...intermediary,
|
|
2895
|
+
metadata: convertLinkTypeMetadata(intermediary.metadata)
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2800
2898
|
function convertLinkTypeMetadata(metadata) {
|
|
2801
2899
|
return {
|
|
2802
2900
|
apiName: metadata.apiName,
|
|
2803
2901
|
displayMetadata: {
|
|
2804
|
-
displayName: metadata.displayName ??
|
|
2902
|
+
displayName: metadata.displayName ?? uppercaseFirstLetter(metadata.apiName),
|
|
2805
2903
|
pluralDisplayName: metadata.pluralDisplayName ?? convertToPluralDisplayName(metadata.apiName),
|
|
2806
2904
|
visibility: metadata.visibility ?? "NORMAL",
|
|
2807
2905
|
groupDisplayName: metadata.groupDisplayName ?? ""
|
|
@@ -2861,7 +2959,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2861
2959
|
version
|
|
2862
2960
|
} = valueTypeDef;
|
|
2863
2961
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
2864
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
2962
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Version is not a valid semver") : invariant6__default.default(false) : void 0;
|
|
2865
2963
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2866
2964
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2867
2965
|
const output = {
|
|
@@ -2897,6 +2995,40 @@ function defineValueType(valueTypeDef) {
|
|
|
2897
2995
|
return vt;
|
|
2898
2996
|
}
|
|
2899
2997
|
|
|
2998
|
+
// src/api/importOntologyEntity.ts
|
|
2999
|
+
function importOntologyEntity(e) {
|
|
3000
|
+
if (e.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
3001
|
+
importedTypes[e.__type][e.apiName] = e;
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
if (importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] === void 0) {
|
|
3005
|
+
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] = [];
|
|
3006
|
+
}
|
|
3007
|
+
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName].push(e);
|
|
3008
|
+
}
|
|
3009
|
+
function importSharedPropertyType(opts) {
|
|
3010
|
+
const {
|
|
3011
|
+
apiName,
|
|
3012
|
+
packageName,
|
|
3013
|
+
typeHint,
|
|
3014
|
+
array
|
|
3015
|
+
} = opts;
|
|
3016
|
+
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3017
|
+
if (packageName !== void 0) {
|
|
3018
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Package name format invalid ends with period") : invariant6__default.default(false) : void 0;
|
|
3019
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Package name includes upper case characters") : invariant6__default.default(false) : void 0;
|
|
3020
|
+
}
|
|
3021
|
+
const spt = {
|
|
3022
|
+
apiName: fullApiName,
|
|
3023
|
+
type: typeHint,
|
|
3024
|
+
nonNameSpacedApiName: apiName,
|
|
3025
|
+
array: array ?? false,
|
|
3026
|
+
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
3027
|
+
};
|
|
3028
|
+
importOntologyEntity(spt);
|
|
3029
|
+
return spt;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
2900
3032
|
// src/api/wrapWithProxy.ts
|
|
2901
3033
|
function wrapWithProxy(entity) {
|
|
2902
3034
|
return new Proxy(entity, {
|
|
@@ -2912,9 +3044,9 @@ exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
|
2912
3044
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
2913
3045
|
exports.addDependency = addDependency;
|
|
2914
3046
|
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
2915
|
-
exports.convertToDisplayName =
|
|
3047
|
+
exports.convertToDisplayName = uppercaseFirstLetter;
|
|
2916
3048
|
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
2917
|
-
exports.convertType =
|
|
3049
|
+
exports.convertType = propertyTypeTypeToOntologyIrType;
|
|
2918
3050
|
exports.default = main;
|
|
2919
3051
|
exports.defineAction = defineAction;
|
|
2920
3052
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|