@osdk/maker 0.13.0-beta.9 → 0.14.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -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 +70 -47
- 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 +107 -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 +1149 -1003
- 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 +70 -47
- 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 +107 -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 +4 -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 +3 -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 +3 -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, objectProperties) {
|
|
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, objectProperties))
|
|
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, objectProperties))
|
|
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
|
+
!objectProperties?.includes(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, objectProperties) {
|
|
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, objectProperties),
|
|
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, objectProperties) {
|
|
270
397
|
return {
|
|
271
|
-
condition: convertConditionDefinition(override.condition),
|
|
398
|
+
condition: convertConditionDefinition(override.condition, objectProperties),
|
|
272
399
|
sectionBlockOverrides: [{
|
|
273
400
|
type: "visibility",
|
|
274
401
|
visibility: {
|
|
@@ -283,229 +410,94 @@ 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, getActionTypeObjectParameters(action))) ?? []
|
|
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", getActionTypeObjectParameters(action))) ?? []
|
|
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
463
|
};
|
|
423
464
|
}
|
|
424
|
-
function
|
|
425
|
-
if (
|
|
426
|
-
return
|
|
465
|
+
function convertParameterRequirementConstraint(required) {
|
|
466
|
+
if (typeof required === "boolean") {
|
|
467
|
+
return required ? {
|
|
468
|
+
type: "required",
|
|
469
|
+
required: {}
|
|
470
|
+
} : {
|
|
471
|
+
type: "notRequired",
|
|
472
|
+
notRequired: {}
|
|
473
|
+
};
|
|
427
474
|
}
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
475
|
+
const {
|
|
476
|
+
min,
|
|
477
|
+
max
|
|
478
|
+
} = required.listLength;
|
|
432
479
|
return {
|
|
433
|
-
|
|
480
|
+
type: "listLengthValidation",
|
|
481
|
+
listLengthValidation: {
|
|
482
|
+
minLength: min,
|
|
483
|
+
maxLength: max
|
|
484
|
+
}
|
|
434
485
|
};
|
|
435
486
|
}
|
|
436
|
-
function
|
|
437
|
-
switch (
|
|
438
|
-
case "
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
case "
|
|
443
|
-
return
|
|
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
|
-
};
|
|
487
|
+
function getActionTypeObjectParameters(actionType) {
|
|
488
|
+
switch (actionType.rules[0].type) {
|
|
489
|
+
case "addObjectRule":
|
|
490
|
+
return Object.keys(actionType.rules[0].addObjectRule.propertyValues);
|
|
491
|
+
case "modifyObjectRule":
|
|
492
|
+
return Object.keys(actionType.rules[0].modifyObjectRule.propertyValues);
|
|
493
|
+
case "addOrModifyObjectRuleV2":
|
|
494
|
+
return Object.keys(actionType.rules[0].addOrModifyObjectRuleV2.propertyValues);
|
|
495
|
+
case "deleteObjectRule":
|
|
496
|
+
return [];
|
|
497
497
|
default:
|
|
498
|
-
|
|
498
|
+
return void 0;
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
function convertDataConstraintToDataConstraints(dc) {
|
|
502
|
-
return {
|
|
503
|
-
propertyTypeConstraints: [{
|
|
504
|
-
constraints: dataConstraintToPropertyTypeDataConstraint(dc)
|
|
505
|
-
// known limitation: structs don't carry field-level data constraint failure messages
|
|
506
|
-
}]
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
501
|
function convertNullabilityToDataConstraint(prop) {
|
|
510
502
|
if (typeof prop.type === "object" && prop.type.type === "marking") {
|
|
511
503
|
if (prop.nullability === void 0) {
|
|
@@ -518,7 +510,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
518
510
|
}
|
|
519
511
|
};
|
|
520
512
|
}
|
|
521
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
513
|
+
!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
514
|
return {
|
|
523
515
|
propertyTypeConstraints: [],
|
|
524
516
|
nullability: void 0,
|
|
@@ -531,7 +523,17 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
531
523
|
nullabilityV2: prop.nullability
|
|
532
524
|
};
|
|
533
525
|
}
|
|
534
|
-
|
|
526
|
+
|
|
527
|
+
// src/conversion/toConjure/distributeTypeHelper.ts
|
|
528
|
+
function distributeTypeHelper(type) {
|
|
529
|
+
return {
|
|
530
|
+
type,
|
|
531
|
+
[type]: {}
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
|
|
536
|
+
function propertyTypeTypeToOntologyIrType(type) {
|
|
535
537
|
switch (true) {
|
|
536
538
|
case (typeof type === "object" && "markingType" in type):
|
|
537
539
|
return {
|
|
@@ -554,14 +556,14 @@ function convertType(type) {
|
|
|
554
556
|
},
|
|
555
557
|
typeClasses: [],
|
|
556
558
|
aliases: [],
|
|
557
|
-
fieldType:
|
|
559
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
558
560
|
};
|
|
559
561
|
} else {
|
|
560
562
|
if ("fieldType" in fieldTypeDefinition) {
|
|
561
563
|
field = {
|
|
562
564
|
...fieldTypeDefinition,
|
|
563
565
|
apiName: key,
|
|
564
|
-
fieldType:
|
|
566
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition.fieldType),
|
|
565
567
|
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
566
568
|
aliases: fieldTypeDefinition.aliases ?? []
|
|
567
569
|
};
|
|
@@ -574,7 +576,7 @@ function convertType(type) {
|
|
|
574
576
|
},
|
|
575
577
|
typeClasses: [],
|
|
576
578
|
aliases: [],
|
|
577
|
-
fieldType:
|
|
579
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
578
580
|
};
|
|
579
581
|
}
|
|
580
582
|
}
|
|
@@ -635,284 +637,207 @@ function convertType(type) {
|
|
|
635
637
|
return distributeTypeHelper(type);
|
|
636
638
|
}
|
|
637
639
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
+
|
|
641
|
+
// src/conversion/toMarketplace/convertSpt.ts
|
|
642
|
+
function convertSpt({
|
|
643
|
+
type,
|
|
644
|
+
array,
|
|
645
|
+
description,
|
|
646
|
+
apiName,
|
|
647
|
+
displayName,
|
|
648
|
+
visibility,
|
|
649
|
+
gothamMapping,
|
|
650
|
+
typeClasses,
|
|
651
|
+
valueType,
|
|
652
|
+
nullability
|
|
653
|
+
}) {
|
|
654
|
+
const dataConstraint = convertNullabilityToDataConstraint({
|
|
640
655
|
type,
|
|
641
|
-
|
|
656
|
+
nullability
|
|
657
|
+
});
|
|
658
|
+
return {
|
|
659
|
+
apiName,
|
|
660
|
+
displayMetadata: {
|
|
661
|
+
displayName: displayName ?? apiName,
|
|
662
|
+
visibility: visibility ?? "NORMAL",
|
|
663
|
+
description
|
|
664
|
+
},
|
|
665
|
+
type: array ? {
|
|
666
|
+
type: "array",
|
|
667
|
+
array: {
|
|
668
|
+
subtype: propertyTypeTypeToOntologyIrType(type)
|
|
669
|
+
}
|
|
670
|
+
} : propertyTypeTypeToOntologyIrType(type),
|
|
671
|
+
aliases: [],
|
|
672
|
+
baseFormatter: void 0,
|
|
673
|
+
dataConstraints: dataConstraint,
|
|
674
|
+
gothamMapping,
|
|
675
|
+
indexedForSearch: true,
|
|
676
|
+
typeClasses: typeClasses ?? [],
|
|
677
|
+
valueType: valueType === void 0 ? void 0 : {
|
|
678
|
+
apiName: valueType.apiName,
|
|
679
|
+
version: valueType.version,
|
|
680
|
+
packageNamespace: valueType.packageNamespace,
|
|
681
|
+
displayMetadata: valueType.displayMetadata
|
|
682
|
+
}
|
|
642
683
|
};
|
|
643
684
|
}
|
|
644
685
|
|
|
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: {}
|
|
686
|
+
// src/conversion/toMarketplace/convertInterface.ts
|
|
687
|
+
function convertInterface(interfaceType) {
|
|
688
|
+
const {
|
|
689
|
+
__type,
|
|
690
|
+
...other
|
|
691
|
+
} = interfaceType;
|
|
692
|
+
return {
|
|
693
|
+
...other,
|
|
694
|
+
propertiesV2: Object.fromEntries(Object.values(interfaceType.propertiesV2).map((spt) => [spt.sharedPropertyType.apiName, {
|
|
695
|
+
required: spt.required,
|
|
696
|
+
sharedPropertyType: convertSpt(spt.sharedPropertyType)
|
|
697
|
+
}])),
|
|
698
|
+
displayMetadata: {
|
|
699
|
+
displayName: interfaceType.displayMetadata.displayName,
|
|
700
|
+
description: interfaceType.displayMetadata.description,
|
|
701
|
+
icon: interfaceType.displayMetadata.icon ?? {
|
|
702
|
+
type: "blueprint",
|
|
703
|
+
blueprint: {
|
|
704
|
+
color: "#4C90F0",
|
|
705
|
+
locator: "layout-hierarchy"
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
710
|
+
// these are omitted from our internal types but we need to re-add them for the final json
|
|
711
|
+
properties: [],
|
|
712
|
+
// TODO(mwalther): Support propertiesV3
|
|
713
|
+
propertiesV3: {}
|
|
678
714
|
};
|
|
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
715
|
}
|
|
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
716
|
|
|
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
|
-
});
|
|
717
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
718
|
+
function convertCardinality(cardinality) {
|
|
719
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
720
|
+
return "ONE_TO_MANY";
|
|
753
721
|
}
|
|
722
|
+
return "ONE_TO_ONE";
|
|
754
723
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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
|
|
724
|
+
|
|
725
|
+
// src/conversion/toMarketplace/convertLink.ts
|
|
726
|
+
function convertLink(linkType) {
|
|
727
|
+
let definition;
|
|
728
|
+
let datasource = void 0;
|
|
729
|
+
if ("one" in linkType) {
|
|
730
|
+
definition = {
|
|
731
|
+
type: "oneToMany",
|
|
732
|
+
oneToMany: {
|
|
733
|
+
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
734
|
+
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
735
|
+
objectTypeRidManySide: linkType.toMany.object.apiName,
|
|
736
|
+
objectTypeRidOneSide: linkType.one.object.apiName,
|
|
737
|
+
oneToManyLinkMetadata: linkType.one.metadata,
|
|
738
|
+
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
739
|
+
from: {
|
|
740
|
+
apiName: linkType.one.object.primaryKeyPropertyApiName,
|
|
741
|
+
object: linkType.one.object.apiName
|
|
742
|
+
},
|
|
743
|
+
to: {
|
|
744
|
+
apiName: linkType.manyForeignKeyProperty,
|
|
745
|
+
object: linkType.toMany.object.apiName
|
|
811
746
|
}
|
|
812
|
-
}]
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
747
|
+
}]
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
751
|
+
definition = {
|
|
752
|
+
type: "intermediary",
|
|
753
|
+
intermediary: {
|
|
754
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
755
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
756
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
757
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
758
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
759
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
760
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
} else {
|
|
764
|
+
definition = {
|
|
765
|
+
type: "manyToMany",
|
|
766
|
+
manyToMany: {
|
|
767
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
768
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
769
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
770
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
771
|
+
peeringMetadata: void 0,
|
|
772
|
+
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
773
|
+
from: {
|
|
774
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
775
|
+
object: linkType.many.object.apiName
|
|
776
|
+
},
|
|
777
|
+
to: {
|
|
778
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
779
|
+
object: linkType.many.object.apiName
|
|
838
780
|
}
|
|
839
|
-
},
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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]
|
|
781
|
+
}],
|
|
782
|
+
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
783
|
+
from: {
|
|
784
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
785
|
+
object: linkType.toMany.object.apiName
|
|
786
|
+
},
|
|
787
|
+
to: {
|
|
788
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
789
|
+
object: linkType.toMany.object.apiName
|
|
790
|
+
}
|
|
791
|
+
}]
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
datasource = {
|
|
795
|
+
datasourceName: linkType.apiName,
|
|
796
|
+
datasource: {
|
|
797
|
+
type: "dataset",
|
|
798
|
+
dataset: {
|
|
799
|
+
datasetRid: "link-".concat(linkType.apiName),
|
|
800
|
+
writebackDatasetRid: void 0,
|
|
801
|
+
objectTypeAPrimaryKeyMapping: [{
|
|
802
|
+
property: {
|
|
803
|
+
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
804
|
+
object: linkType.many.object.apiName
|
|
805
|
+
},
|
|
806
|
+
column: linkType.many.object.primaryKeyPropertyApiName
|
|
807
|
+
}],
|
|
808
|
+
objectTypeBPrimaryKeyMapping: [{
|
|
809
|
+
property: {
|
|
810
|
+
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
811
|
+
object: linkType.toMany.object.apiName
|
|
812
|
+
},
|
|
813
|
+
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
814
|
+
}]
|
|
887
815
|
}
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
816
|
+
},
|
|
817
|
+
editsConfiguration: {
|
|
818
|
+
onlyAllowPrivilegedEdits: false
|
|
819
|
+
},
|
|
820
|
+
redacted: linkType.redacted
|
|
821
|
+
};
|
|
892
822
|
}
|
|
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
823
|
return {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
824
|
+
linkType: {
|
|
825
|
+
definition,
|
|
826
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
827
|
+
status: linkType.status ?? {
|
|
828
|
+
type: "active",
|
|
829
|
+
active: {}
|
|
830
|
+
},
|
|
831
|
+
redacted: linkType.redacted ?? false
|
|
909
832
|
},
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
833
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
834
|
+
entityMetadata: {
|
|
835
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
913
836
|
}
|
|
914
837
|
};
|
|
915
838
|
}
|
|
839
|
+
|
|
840
|
+
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
916
841
|
function convertDatasourceDefinition(objectType, properties) {
|
|
917
842
|
switch (objectType.datasource?.type) {
|
|
918
843
|
case "stream":
|
|
@@ -955,14 +880,6 @@ function convertDatasourceDefinition(objectType, properties) {
|
|
|
955
880
|
};
|
|
956
881
|
}
|
|
957
882
|
}
|
|
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
883
|
function buildPropertyMapping(properties) {
|
|
967
884
|
return Object.fromEntries(properties.map((prop) => {
|
|
968
885
|
if (prop.editOnly) {
|
|
@@ -990,9 +907,130 @@ function buildPropertyMapping(properties) {
|
|
|
990
907
|
}];
|
|
991
908
|
}));
|
|
992
909
|
}
|
|
993
|
-
|
|
910
|
+
|
|
911
|
+
// src/api/propertyConversionUtils.ts
|
|
912
|
+
var defaultTypeClasses = [{
|
|
913
|
+
kind: "render_hint",
|
|
914
|
+
name: "SELECTABLE"
|
|
915
|
+
}, {
|
|
916
|
+
kind: "render_hint",
|
|
917
|
+
name: "SORTABLE"
|
|
918
|
+
}];
|
|
919
|
+
function shouldNotHaveRenderHints(type) {
|
|
920
|
+
return ["struct", "mediaReference", "geotimeSeries"].includes(getPropertyTypeName(type));
|
|
921
|
+
}
|
|
922
|
+
function hasRenderHints(typeClasses) {
|
|
923
|
+
return (typeClasses ?? []).some((tc) => tc.kind.toLowerCase() === "render_hint");
|
|
924
|
+
}
|
|
925
|
+
function getPropertyTypeName(type) {
|
|
926
|
+
return typeof type === "object" ? type.type : type;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// src/conversion/toMarketplace/convertValueType.ts
|
|
930
|
+
function convertValueType(valueType) {
|
|
931
|
+
return {
|
|
932
|
+
apiName: valueType.apiName,
|
|
933
|
+
version: valueType.version,
|
|
934
|
+
packageNamespace: valueType.packageNamespace,
|
|
935
|
+
displayMetadata: valueType.displayMetadata
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// src/conversion/toMarketplace/convertDataConstraintToDataConstraints.ts
|
|
940
|
+
function convertDataConstraintToDataConstraints(dc) {
|
|
941
|
+
return {
|
|
942
|
+
propertyTypeConstraints: [{
|
|
943
|
+
constraints: dataConstraintToPropertyTypeDataConstraint(dc)
|
|
944
|
+
// known limitation: structs don't carry field-level data constraint failure messages
|
|
945
|
+
}]
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// src/conversion/toMarketplace/dataConstraintToPropertyTypeDataConstraint.ts
|
|
950
|
+
function dataConstraintToPropertyTypeDataConstraint(dc) {
|
|
951
|
+
switch (dc.type) {
|
|
952
|
+
case "array":
|
|
953
|
+
return {
|
|
954
|
+
...dc
|
|
955
|
+
};
|
|
956
|
+
case "boolean":
|
|
957
|
+
return {
|
|
958
|
+
...dc
|
|
959
|
+
};
|
|
960
|
+
case "binary":
|
|
961
|
+
throw new Error("Binary type constraints are not supported");
|
|
962
|
+
case "date":
|
|
963
|
+
return {
|
|
964
|
+
...dc
|
|
965
|
+
};
|
|
966
|
+
case "decimal":
|
|
967
|
+
return {
|
|
968
|
+
...dc
|
|
969
|
+
};
|
|
970
|
+
case "double":
|
|
971
|
+
return {
|
|
972
|
+
...dc
|
|
973
|
+
};
|
|
974
|
+
case "float":
|
|
975
|
+
return {
|
|
976
|
+
...dc
|
|
977
|
+
};
|
|
978
|
+
case "integer":
|
|
979
|
+
return {
|
|
980
|
+
...dc
|
|
981
|
+
};
|
|
982
|
+
case "long":
|
|
983
|
+
return {
|
|
984
|
+
...dc
|
|
985
|
+
};
|
|
986
|
+
case "map":
|
|
987
|
+
throw new Error("Map type constraints are not supported");
|
|
988
|
+
case "nullable":
|
|
989
|
+
throw new Error("Nullable constraints are not supported");
|
|
990
|
+
case "short":
|
|
991
|
+
return {
|
|
992
|
+
...dc
|
|
993
|
+
};
|
|
994
|
+
case "string":
|
|
995
|
+
return {
|
|
996
|
+
...dc
|
|
997
|
+
};
|
|
998
|
+
case "struct":
|
|
999
|
+
return {
|
|
1000
|
+
type: "struct",
|
|
1001
|
+
struct: {
|
|
1002
|
+
elementConstraints: Object.fromEntries(Object.entries(dc.struct.elementConstraints).map(([field, constraint]) => [field, convertDataConstraintToDataConstraints(constraint)]))
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
case "structV2":
|
|
1006
|
+
throw new Error("StructV2 constraints are not supported");
|
|
1007
|
+
case "timestamp":
|
|
1008
|
+
return {
|
|
1009
|
+
...dc
|
|
1010
|
+
};
|
|
1011
|
+
default:
|
|
1012
|
+
throw new Error(`Unknown DataConstraint type: ${dc.type}`);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/conversion/toMarketplace/convertValueTypeDataConstraints.ts
|
|
1017
|
+
function convertValueTypeDataConstraints(dataConstraints) {
|
|
1018
|
+
if (dataConstraints.length === 0) {
|
|
1019
|
+
return void 0;
|
|
1020
|
+
}
|
|
1021
|
+
const propertyTypeConstraints = dataConstraints.map((constraint) => ({
|
|
1022
|
+
constraints: dataConstraintToPropertyTypeDataConstraint(constraint.constraint.constraint),
|
|
1023
|
+
failureMessage: constraint.constraint.failureMessage
|
|
1024
|
+
}));
|
|
1025
|
+
return {
|
|
1026
|
+
propertyTypeConstraints
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1031
|
+
function convertObjectPropertyType(property) {
|
|
994
1032
|
const apiName = namespace + property.apiName;
|
|
995
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1033
|
+
!(!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
1034
|
const output = {
|
|
997
1035
|
apiName: property.apiName,
|
|
998
1036
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1007,9 +1045,9 @@ function convertProperty(property) {
|
|
|
1007
1045
|
type: property.array ? {
|
|
1008
1046
|
type: "array",
|
|
1009
1047
|
array: {
|
|
1010
|
-
subtype:
|
|
1048
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type)
|
|
1011
1049
|
}
|
|
1012
|
-
} :
|
|
1050
|
+
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1013
1051
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
1014
1052
|
status: convertObjectStatus(property.status),
|
|
1015
1053
|
inlineAction: void 0,
|
|
@@ -1019,103 +1057,319 @@ function convertProperty(property) {
|
|
|
1019
1057
|
};
|
|
1020
1058
|
return output;
|
|
1021
1059
|
}
|
|
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
|
|
1060
|
+
|
|
1061
|
+
// src/conversion/toMarketplace/convertObject.ts
|
|
1062
|
+
function convertObject(objectType) {
|
|
1063
|
+
const propertyDatasources = (objectType.properties ?? []).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
1064
|
+
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1065
|
+
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1066
|
+
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1067
|
+
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1068
|
+
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, objectType.properties ?? []), classificationInputGroup, mandatoryInputGroup);
|
|
1069
|
+
const implementations = objectType.implementsInterfaces ?? [];
|
|
1070
|
+
return {
|
|
1071
|
+
objectType: {
|
|
1072
|
+
displayMetadata: {
|
|
1073
|
+
description: objectType.description,
|
|
1074
|
+
displayName: objectType.displayName,
|
|
1075
|
+
groupDisplayName: void 0,
|
|
1076
|
+
icon: {
|
|
1077
|
+
type: "blueprint",
|
|
1078
|
+
blueprint: objectType.icon ?? {
|
|
1079
|
+
locator: "cube",
|
|
1080
|
+
color: "#2D72D2"
|
|
1073
1081
|
}
|
|
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
|
|
1082
|
+
},
|
|
1083
|
+
pluralDisplayName: objectType.pluralDisplayName,
|
|
1084
|
+
visibility: objectType.visibility ?? "NORMAL"
|
|
1102
1085
|
},
|
|
1103
|
-
|
|
1104
|
-
|
|
1086
|
+
primaryKeys: [objectType.primaryKeyPropertyApiName],
|
|
1087
|
+
propertyTypes: Object.fromEntries(objectType.properties?.map((val) => [val.apiName, convertObjectPropertyType(val)]) ?? []),
|
|
1088
|
+
titlePropertyTypeRid: objectType.titlePropertyApiName,
|
|
1089
|
+
apiName: objectType.apiName,
|
|
1090
|
+
status: convertObjectStatus(objectType.status),
|
|
1091
|
+
redacted: false,
|
|
1092
|
+
implementsInterfaces2: implementations.map((impl) => ({
|
|
1093
|
+
interfaceTypeApiName: impl.implements.apiName,
|
|
1094
|
+
linksV2: {},
|
|
1095
|
+
propertiesV2: {},
|
|
1096
|
+
properties: Object.fromEntries(impl.propertyMapping.map((mapping) => [addNamespaceIfNone(mapping.interfaceProperty), {
|
|
1097
|
+
propertyTypeRid: mapping.mapsTo
|
|
1098
|
+
}]))
|
|
1099
|
+
})),
|
|
1100
|
+
allImplementsInterfaces: {}
|
|
1101
|
+
},
|
|
1102
|
+
datasources: [...propertyDatasources, objectDatasource],
|
|
1103
|
+
entityMetadata: {
|
|
1104
|
+
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
function extractMarkingGroups(properties, markingType) {
|
|
1109
|
+
return properties.map((prop) => {
|
|
1110
|
+
if (typeof prop.type === "object" && prop.type.type === "marking" && prop.type.markingType === markingType) {
|
|
1111
|
+
return prop.type.markingInputGroupName;
|
|
1112
|
+
}
|
|
1113
|
+
return void 0;
|
|
1114
|
+
}).filter((val) => val !== void 0);
|
|
1115
|
+
}
|
|
1116
|
+
function extractPropertyDatasource(property, objectTypeApiName) {
|
|
1117
|
+
if (!isExotic(property.type)) {
|
|
1118
|
+
return [];
|
|
1119
|
+
}
|
|
1120
|
+
const identifier = objectTypeApiName + "." + property.apiName;
|
|
1121
|
+
switch (property.type) {
|
|
1122
|
+
case "geotimeSeries":
|
|
1123
|
+
const geotimeDefinition = {
|
|
1124
|
+
type: "geotimeSeries",
|
|
1125
|
+
geotimeSeries: {
|
|
1126
|
+
geotimeSeriesIntegrationRid: identifier,
|
|
1127
|
+
properties: [property.apiName]
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
return [buildDatasource(property.apiName, geotimeDefinition)];
|
|
1131
|
+
case "mediaReference":
|
|
1132
|
+
const mediaSetDefinition = {
|
|
1133
|
+
type: "mediaSetView",
|
|
1134
|
+
mediaSetView: {
|
|
1135
|
+
assumedMarkings: [],
|
|
1136
|
+
mediaSetViewLocator: identifier,
|
|
1137
|
+
properties: [property.apiName]
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
return [buildDatasource(property.apiName, mediaSetDefinition)];
|
|
1141
|
+
default:
|
|
1142
|
+
return [];
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1147
|
+
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
1148
|
+
return {
|
|
1149
|
+
objectTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.OBJECT_TYPE]).map(([apiName, objectType]) => {
|
|
1150
|
+
return [apiName, convertObject(objectType)];
|
|
1151
|
+
})),
|
|
1152
|
+
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]).map(([apiName, spt]) => [apiName, {
|
|
1153
|
+
sharedPropertyType: convertSpt(spt)
|
|
1154
|
+
}])),
|
|
1155
|
+
interfaceTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.INTERFACE_TYPE]).map(([apiName, interfaceType]) => {
|
|
1156
|
+
return [apiName, {
|
|
1157
|
+
interfaceType: convertInterface(interfaceType)
|
|
1158
|
+
}];
|
|
1159
|
+
})),
|
|
1160
|
+
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
1161
|
+
return [cleanAndValidateLinkTypeId(id), convertLink(link)];
|
|
1162
|
+
})),
|
|
1163
|
+
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
1164
|
+
return [apiName, convertAction(action)];
|
|
1165
|
+
})),
|
|
1166
|
+
blockPermissionInformation: {
|
|
1167
|
+
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).filter(([apiName, action]) => action.validation).map(([apiName, action]) => {
|
|
1168
|
+
return [apiName, {
|
|
1169
|
+
restrictionStatus: {
|
|
1170
|
+
hasRolesApplied: true,
|
|
1171
|
+
ontologyPackageRid: null,
|
|
1172
|
+
publicProject: false
|
|
1173
|
+
}
|
|
1174
|
+
}];
|
|
1175
|
+
})),
|
|
1176
|
+
linkTypes: {},
|
|
1177
|
+
objectTypes: {}
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// src/conversion/toMarketplace/convertValueTypesToIr.ts
|
|
1183
|
+
function convertValueTypesToIr(valueTypes) {
|
|
1184
|
+
return Object.values(valueTypes).map((definitions) => ({
|
|
1185
|
+
metadata: {
|
|
1186
|
+
apiName: definitions[0].apiName,
|
|
1187
|
+
packageNamespace: definitions[0].packageNamespace,
|
|
1188
|
+
displayMetadata: definitions[0].displayMetadata,
|
|
1189
|
+
status: definitions[0].status
|
|
1190
|
+
},
|
|
1191
|
+
// TODO(dpaquin): instead of deduping here, we should refactor the value type types from arrays to maps
|
|
1192
|
+
versions: Array.from(new Map(definitions.map((definition) => [definition.version, definition])).values()).map((definition) => ({
|
|
1193
|
+
version: definition.version,
|
|
1194
|
+
baseType: definition.baseType,
|
|
1195
|
+
constraints: definition.constraints,
|
|
1196
|
+
exampleValues: definition.exampleValues
|
|
1197
|
+
}))
|
|
1198
|
+
}));
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/conversion/toMarketplace/convertOntologyToValueTypeIr.ts
|
|
1202
|
+
function convertOntologyToValueTypeIr(ontology) {
|
|
1203
|
+
return {
|
|
1204
|
+
valueTypes: convertValueTypesToIr(ontology[OntologyEntityTypeEnum.VALUE_TYPE])
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// src/conversion/toMarketplace/convertOntologyDefinition.ts
|
|
1209
|
+
function convertOntologyDefinition(ontology, randomnessKey) {
|
|
1210
|
+
return {
|
|
1211
|
+
ontology: convertOntologyDefinitionToWireBlockData(ontology),
|
|
1212
|
+
importedOntology: convertOntologyDefinitionToWireBlockData(importedTypes),
|
|
1213
|
+
valueTypes: convertOntologyToValueTypeIr(ontology),
|
|
1214
|
+
importedValueTypes: convertOntologyToValueTypeIr(importedTypes),
|
|
1215
|
+
randomnessKey
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// src/conversion/toMarketplace/getFormContentOrdering.ts
|
|
1220
|
+
function getFormContentOrdering(action, parameterOrdering) {
|
|
1221
|
+
if (!action.sections) return [];
|
|
1222
|
+
const parametersToSection = Object.fromEntries(Object.entries(action.sections).flatMap(([sectionId, section]) => section.parameters.map((param) => [param, sectionId])));
|
|
1223
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
1224
|
+
const formContentOrdering = [];
|
|
1225
|
+
parameterOrdering.forEach((param) => {
|
|
1226
|
+
if (param in parametersToSection && !seenIds.has(parametersToSection[param])) {
|
|
1227
|
+
formContentOrdering.push({
|
|
1228
|
+
type: "sectionId",
|
|
1229
|
+
sectionId: parametersToSection[param]
|
|
1230
|
+
});
|
|
1231
|
+
seenIds.add(parametersToSection[param]);
|
|
1232
|
+
} else if (!(param in parametersToSection)) {
|
|
1233
|
+
formContentOrdering.push({
|
|
1234
|
+
type: "parameterId",
|
|
1235
|
+
parameterId: param
|
|
1236
|
+
});
|
|
1237
|
+
seenIds.add(param);
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
return formContentOrdering;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// src/api/defineOntology.ts
|
|
1244
|
+
var ontologyDefinition;
|
|
1245
|
+
var importedTypes;
|
|
1246
|
+
var dependencies;
|
|
1247
|
+
var namespace;
|
|
1248
|
+
function updateOntology(entity) {
|
|
1249
|
+
if (entity.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
1250
|
+
ontologyDefinition[entity.__type][entity.apiName] = entity;
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
if (ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName] === void 0) {
|
|
1254
|
+
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName] = [];
|
|
1255
|
+
}
|
|
1256
|
+
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1257
|
+
}
|
|
1258
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1259
|
+
namespace = ns;
|
|
1260
|
+
dependencies = {};
|
|
1261
|
+
ontologyDefinition = {
|
|
1262
|
+
OBJECT_TYPE: {},
|
|
1263
|
+
ACTION_TYPE: {},
|
|
1264
|
+
LINK_TYPE: {},
|
|
1265
|
+
INTERFACE_TYPE: {},
|
|
1266
|
+
SHARED_PROPERTY_TYPE: {},
|
|
1267
|
+
VALUE_TYPE: {}
|
|
1268
|
+
};
|
|
1269
|
+
importedTypes = {
|
|
1270
|
+
SHARED_PROPERTY_TYPE: {},
|
|
1271
|
+
OBJECT_TYPE: {},
|
|
1272
|
+
ACTION_TYPE: {},
|
|
1273
|
+
LINK_TYPE: {},
|
|
1274
|
+
INTERFACE_TYPE: {},
|
|
1275
|
+
VALUE_TYPE: {}
|
|
1276
|
+
};
|
|
1277
|
+
try {
|
|
1278
|
+
await body();
|
|
1279
|
+
} catch (e) {
|
|
1280
|
+
console.error("Unexpected error while processing the body of the ontology", e);
|
|
1281
|
+
throw e;
|
|
1282
|
+
}
|
|
1283
|
+
if (outputDir) {
|
|
1284
|
+
writeStaticObjects(outputDir);
|
|
1285
|
+
}
|
|
1286
|
+
if (dependencyFile) {
|
|
1287
|
+
writeDependencyFile(dependencyFile);
|
|
1288
|
+
}
|
|
1289
|
+
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1290
|
+
}
|
|
1291
|
+
function writeStaticObjects(outputDir) {
|
|
1292
|
+
const codegenDir = path2__namespace.resolve(outputDir, "codegen");
|
|
1293
|
+
const typeDirs = {
|
|
1294
|
+
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1295
|
+
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
1296
|
+
[OntologyEntityTypeEnum.OBJECT_TYPE]: "object-types",
|
|
1297
|
+
[OntologyEntityTypeEnum.LINK_TYPE]: "link-types",
|
|
1298
|
+
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1299
|
+
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1300
|
+
};
|
|
1301
|
+
if (!fs__namespace.existsSync(codegenDir)) {
|
|
1302
|
+
fs__namespace.mkdirSync(codegenDir, {
|
|
1303
|
+
recursive: true
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1307
|
+
const currentTypeDirPath = path2__namespace.join(codegenDir, typeDirNameFromMap);
|
|
1308
|
+
if (fs__namespace.existsSync(currentTypeDirPath)) {
|
|
1309
|
+
fs__namespace.rmSync(currentTypeDirPath, {
|
|
1310
|
+
recursive: true,
|
|
1311
|
+
force: true
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
fs__namespace.mkdirSync(currentTypeDirPath, {
|
|
1315
|
+
recursive: true
|
|
1316
|
+
});
|
|
1317
|
+
});
|
|
1318
|
+
const topLevelExportStatements = [];
|
|
1319
|
+
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1320
|
+
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1321
|
+
const typeDirPath = path2__namespace.join(codegenDir, typeDirName);
|
|
1322
|
+
const entityModuleNames = [];
|
|
1323
|
+
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1324
|
+
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1325
|
+
const filePath = path2__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1326
|
+
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1327
|
+
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1328
|
+
const content = `
|
|
1329
|
+
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
1330
|
+
import type { ${entityTypeName} } from '@osdk/maker';
|
|
1331
|
+
|
|
1332
|
+
/** @type {import('@osdk/maker').${entityTypeName}} */
|
|
1333
|
+
const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey === "VALUE_TYPE" ? entityJSON.slice(1, -2) : entityJSON} as unknown as ${entityTypeName};
|
|
1334
|
+
|
|
1335
|
+
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1336
|
+
`;
|
|
1337
|
+
fs__namespace.writeFileSync(filePath, content, {
|
|
1338
|
+
flag: "w"
|
|
1339
|
+
});
|
|
1340
|
+
entityModuleNames.push(entityFileNameBase);
|
|
1341
|
+
});
|
|
1342
|
+
for (const entityModuleName of entityModuleNames) {
|
|
1343
|
+
topLevelExportStatements.push(`export { ${entityModuleName} } from "./codegen/${typeDirName}/${entityModuleName}.js";`);
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
if (topLevelExportStatements.length > 0) {
|
|
1347
|
+
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1348
|
+
const mainIndexFilePath = path2__namespace.join(outputDir, "index.ts");
|
|
1349
|
+
fs__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1350
|
+
flag: "w"
|
|
1351
|
+
});
|
|
1105
1352
|
}
|
|
1353
|
+
}
|
|
1354
|
+
function buildDatasource(apiName, definition, classificationMarkingGroupName, mandatoryMarkingGroupName) {
|
|
1355
|
+
const needsSecurity = classificationMarkingGroupName !== void 0 || mandatoryMarkingGroupName !== void 0;
|
|
1356
|
+
const securityConfig = needsSecurity ? {
|
|
1357
|
+
classificationConstraint: classificationMarkingGroupName ? {
|
|
1358
|
+
markingGroupName: classificationMarkingGroupName
|
|
1359
|
+
} : void 0,
|
|
1360
|
+
markingConstraint: mandatoryMarkingGroupName ? {
|
|
1361
|
+
markingGroupName: mandatoryMarkingGroupName
|
|
1362
|
+
} : void 0
|
|
1363
|
+
} : void 0;
|
|
1106
1364
|
return {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
type: "active",
|
|
1112
|
-
active: {}
|
|
1113
|
-
},
|
|
1114
|
-
redacted: linkType.redacted ?? false
|
|
1365
|
+
datasourceName: apiName,
|
|
1366
|
+
datasource: definition,
|
|
1367
|
+
editsConfiguration: {
|
|
1368
|
+
onlyAllowPrivilegedEdits: false
|
|
1115
1369
|
},
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1370
|
+
redacted: false,
|
|
1371
|
+
...securityConfig !== void 0 && {
|
|
1372
|
+
dataSecurity: securityConfig
|
|
1119
1373
|
}
|
|
1120
1374
|
};
|
|
1121
1375
|
}
|
|
@@ -1128,73 +1382,8 @@ function cleanAndValidateLinkTypeId(apiName) {
|
|
|
1128
1382
|
}
|
|
1129
1383
|
return linkTypeId;
|
|
1130
1384
|
}
|
|
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
1385
|
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
|
-
};
|
|
1386
|
+
return convertOntologyDefinition(ontologyDefinition);
|
|
1198
1387
|
}
|
|
1199
1388
|
function convertObjectStatus(status) {
|
|
1200
1389
|
if (status === void 0) {
|
|
@@ -1274,110 +1463,21 @@ function convertAction(action) {
|
|
|
1274
1463
|
submitButtonDisplayMetadata: action.submissionMetadata.submitButtonDisplayMetadata
|
|
1275
1464
|
},
|
|
1276
1465
|
...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: {}
|
|
1466
|
+
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1336
1467
|
}
|
|
1337
1468
|
},
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
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
|
-
}
|
|
1469
|
+
parameterOrdering,
|
|
1470
|
+
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1471
|
+
parameters: actionParameters,
|
|
1472
|
+
sections: actionSections,
|
|
1473
|
+
status: typeof action.status === "string" ? {
|
|
1474
|
+
type: action.status,
|
|
1475
|
+
[action.status]: {}
|
|
1476
|
+
} : action.status,
|
|
1477
|
+
entities: action.entities
|
|
1378
1478
|
}
|
|
1379
1479
|
}
|
|
1380
|
-
}
|
|
1480
|
+
};
|
|
1381
1481
|
}
|
|
1382
1482
|
function extractAllowedValues(allowedValues) {
|
|
1383
1483
|
switch (allowedValues.type) {
|
|
@@ -1576,31 +1676,6 @@ function renderHintFromBaseType(parameter) {
|
|
|
1576
1676
|
throw new Error(`Unknown type ${type}`);
|
|
1577
1677
|
}
|
|
1578
1678
|
}
|
|
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
1679
|
function withoutNamespace(apiName) {
|
|
1605
1680
|
const lastDot = apiName.lastIndexOf(".");
|
|
1606
1681
|
if (lastDot === -1) {
|
|
@@ -1639,17 +1714,12 @@ addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
|
1639
1714
|
function addNamespaceIfNone(apiName) {
|
|
1640
1715
|
return apiName.includes(".") ? apiName : namespace + apiName;
|
|
1641
1716
|
}
|
|
1642
|
-
function convertCardinality(cardinality) {
|
|
1643
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
1644
|
-
return "ONE_TO_MANY";
|
|
1645
|
-
}
|
|
1646
|
-
return "ONE_TO_ONE";
|
|
1647
|
-
}
|
|
1648
1717
|
|
|
1649
1718
|
// src/cli/main.ts
|
|
1650
1719
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1720
|
+
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1651
1721
|
async function main(args = process.argv) {
|
|
1652
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
1722
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.1").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1653
1723
|
input: {
|
|
1654
1724
|
alias: "i",
|
|
1655
1725
|
describe: "Input file",
|
|
@@ -1692,24 +1762,32 @@ async function main(args = process.argv) {
|
|
|
1692
1762
|
describe: "File to write dependencies to",
|
|
1693
1763
|
type: "string",
|
|
1694
1764
|
coerce: path2__namespace.resolve
|
|
1765
|
+
},
|
|
1766
|
+
randomnessKey: {
|
|
1767
|
+
describe: "Value used to assure uniqueness of entities",
|
|
1768
|
+
type: "string",
|
|
1769
|
+
coerce: path2__namespace.resolve
|
|
1695
1770
|
}
|
|
1696
1771
|
}).parseAsync();
|
|
1697
1772
|
let apiNamespace = "";
|
|
1698
1773
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1699
1774
|
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" ?
|
|
1775
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "API namespace is too long.") : invariant6__default.default(false) : void 0;
|
|
1776
|
+
!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
1777
|
}
|
|
1703
1778
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1704
|
-
|
|
1779
|
+
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1780
|
+
!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;
|
|
1781
|
+
}
|
|
1782
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
1705
1783
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1706
1784
|
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1707
1785
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1708
1786
|
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1709
1787
|
}
|
|
1710
1788
|
}
|
|
1711
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1712
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
|
|
1789
|
+
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
|
|
1790
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
1713
1791
|
return q;
|
|
1714
1792
|
}
|
|
1715
1793
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -1732,36 +1810,68 @@ function addDependency(namespaceNoDot, fileInPackage) {
|
|
|
1732
1810
|
const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1733
1811
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1734
1812
|
}
|
|
1735
|
-
function
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1813
|
+
function convertMappingValue(value) {
|
|
1814
|
+
switch (value.type) {
|
|
1815
|
+
case "uuid":
|
|
1816
|
+
return {
|
|
1817
|
+
type: "uniqueIdentifier",
|
|
1818
|
+
uniqueIdentifier: {
|
|
1819
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
case "currentTime":
|
|
1823
|
+
return {
|
|
1824
|
+
type: "currentTime",
|
|
1825
|
+
currentTime: {}
|
|
1826
|
+
};
|
|
1827
|
+
case "currentUser":
|
|
1828
|
+
return {
|
|
1829
|
+
type: "currentUser",
|
|
1830
|
+
currentUser: {}
|
|
1831
|
+
};
|
|
1832
|
+
default:
|
|
1833
|
+
return value;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
// src/api/action/ActionParameterType.ts
|
|
1838
|
+
function isActionParameterTypePrimitive(type) {
|
|
1839
|
+
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);
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
// src/api/defineAction.ts
|
|
1843
|
+
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1844
|
+
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1845
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
1846
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1847
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1848
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the create action because they are structs`);
|
|
1739
1849
|
}
|
|
1740
1850
|
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}`,
|
|
1851
|
+
apiName: `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1852
|
+
displayName: `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
1743
1853
|
parameters: [{
|
|
1744
1854
|
id: "objectTypeParameter",
|
|
1745
1855
|
displayName: "Object type to create",
|
|
1746
1856
|
type: {
|
|
1747
1857
|
type: "objectTypeReference",
|
|
1748
1858
|
objectTypeReference: {
|
|
1749
|
-
interfaceTypeRids: [interfaceType.apiName]
|
|
1859
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1750
1860
|
}
|
|
1751
1861
|
},
|
|
1752
1862
|
validation: {
|
|
1753
1863
|
required: true,
|
|
1754
|
-
allowedValues: objectType === void 0 ? {
|
|
1864
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1755
1865
|
type: "objectTypeReference",
|
|
1756
|
-
interfaceTypes: [interfaceType.apiName]
|
|
1866
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
1757
1867
|
} : {
|
|
1758
1868
|
type: "oneOf",
|
|
1759
1869
|
oneOf: [{
|
|
1760
|
-
label: objectType.displayName,
|
|
1870
|
+
label: def.objectType.displayName,
|
|
1761
1871
|
value: {
|
|
1762
1872
|
type: "objectType",
|
|
1763
1873
|
objectType: {
|
|
1764
|
-
objectTypeId: objectType.apiName
|
|
1874
|
+
objectTypeId: def.objectType.apiName
|
|
1765
1875
|
}
|
|
1766
1876
|
}
|
|
1767
1877
|
}]
|
|
@@ -1779,9 +1889,9 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1779
1889
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1780
1890
|
}
|
|
1781
1891
|
}))],
|
|
1782
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
1892
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1783
1893
|
entities: {
|
|
1784
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
1894
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1785
1895
|
affectedObjectTypes: [],
|
|
1786
1896
|
affectedLinkTypes: [],
|
|
1787
1897
|
typeGroups: []
|
|
@@ -1789,7 +1899,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1789
1899
|
rules: [{
|
|
1790
1900
|
type: "addInterfaceRule",
|
|
1791
1901
|
addInterfaceRule: {
|
|
1792
|
-
interfaceApiName: interfaceType.apiName,
|
|
1902
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
1793
1903
|
objectTypeParameter: "objectTypeParameter",
|
|
1794
1904
|
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1795
1905
|
type: "parameterId",
|
|
@@ -1797,8 +1907,8 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1797
1907
|
}]))
|
|
1798
1908
|
}
|
|
1799
1909
|
}],
|
|
1800
|
-
...validation ? {
|
|
1801
|
-
validation: convertValidationRule(validation)
|
|
1910
|
+
...def.validation ? {
|
|
1911
|
+
validation: convertValidationRule(def.validation)
|
|
1802
1912
|
} : {}
|
|
1803
1913
|
});
|
|
1804
1914
|
}
|
|
@@ -1840,7 +1950,7 @@ function defineCreateObjectAction(def) {
|
|
|
1840
1950
|
}],
|
|
1841
1951
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1842
1952
|
...def.actionLevelValidation ? {
|
|
1843
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
1953
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
1844
1954
|
} : {},
|
|
1845
1955
|
...def.defaultFormat && {
|
|
1846
1956
|
defaultFormat: def.defaultFormat
|
|
@@ -1859,35 +1969,35 @@ function defineCreateObjectAction(def) {
|
|
|
1859
1969
|
}
|
|
1860
1970
|
});
|
|
1861
1971
|
}
|
|
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`);
|
|
1972
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
1973
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1974
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1975
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1866
1976
|
}
|
|
1867
1977
|
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}`,
|
|
1978
|
+
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1979
|
+
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1870
1980
|
parameters: [{
|
|
1871
1981
|
id: "interfaceObjectToModifyParameter",
|
|
1872
1982
|
displayName: "Object type to modify",
|
|
1873
1983
|
type: {
|
|
1874
1984
|
type: "interfaceReference",
|
|
1875
1985
|
interfaceReference: {
|
|
1876
|
-
interfaceTypeRid: interfaceType.apiName
|
|
1986
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
1877
1987
|
}
|
|
1878
1988
|
},
|
|
1879
1989
|
validation: {
|
|
1880
1990
|
required: true,
|
|
1881
|
-
allowedValues: objectType === void 0 ? {
|
|
1991
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1882
1992
|
type: "interfaceObjectQuery"
|
|
1883
1993
|
} : {
|
|
1884
1994
|
type: "oneOf",
|
|
1885
1995
|
oneOf: [{
|
|
1886
|
-
label: objectType.displayName,
|
|
1996
|
+
label: def.objectType.displayName,
|
|
1887
1997
|
value: {
|
|
1888
1998
|
type: "objectType",
|
|
1889
1999
|
objectType: {
|
|
1890
|
-
objectTypeId: objectType.apiName
|
|
2000
|
+
objectTypeId: def.objectType.apiName
|
|
1891
2001
|
}
|
|
1892
2002
|
}
|
|
1893
2003
|
}]
|
|
@@ -1905,9 +2015,9 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1905
2015
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1906
2016
|
}
|
|
1907
2017
|
}))],
|
|
1908
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
2018
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1909
2019
|
entities: {
|
|
1910
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
2020
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1911
2021
|
affectedObjectTypes: [],
|
|
1912
2022
|
affectedLinkTypes: [],
|
|
1913
2023
|
typeGroups: []
|
|
@@ -1922,8 +2032,8 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1922
2032
|
}]))
|
|
1923
2033
|
}
|
|
1924
2034
|
}],
|
|
1925
|
-
...validation ? {
|
|
1926
|
-
validation: convertValidationRule(validation)
|
|
2035
|
+
...def.validation ? {
|
|
2036
|
+
validation: convertValidationRule(def.validation)
|
|
1927
2037
|
} : {}
|
|
1928
2038
|
});
|
|
1929
2039
|
}
|
|
@@ -1980,7 +2090,7 @@ function defineModifyObjectAction(def) {
|
|
|
1980
2090
|
},
|
|
1981
2091
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
1982
2092
|
...def.actionLevelValidation ? {
|
|
1983
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2093
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
1984
2094
|
} : {},
|
|
1985
2095
|
...def.defaultFormat && {
|
|
1986
2096
|
defaultFormat: def.defaultFormat
|
|
@@ -2033,7 +2143,7 @@ function defineDeleteObjectAction(def) {
|
|
|
2033
2143
|
typeGroups: []
|
|
2034
2144
|
},
|
|
2035
2145
|
...def.actionLevelValidation ? {
|
|
2036
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2146
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2037
2147
|
} : {}
|
|
2038
2148
|
});
|
|
2039
2149
|
}
|
|
@@ -2090,7 +2200,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2090
2200
|
},
|
|
2091
2201
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2092
2202
|
...def.actionLevelValidation ? {
|
|
2093
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2203
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2094
2204
|
} : {},
|
|
2095
2205
|
...def.defaultFormat && {
|
|
2096
2206
|
defaultFormat: def.defaultFormat
|
|
@@ -2115,21 +2225,38 @@ function defineAction(actionDef) {
|
|
|
2115
2225
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2116
2226
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2117
2227
|
}
|
|
2118
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2228
|
+
!/^[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
2229
|
const parameterIdsSet = new Set(parameterIds);
|
|
2120
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2230
|
+
!(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
2231
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2122
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2232
|
+
!(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
2233
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2124
2234
|
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" ?
|
|
2235
|
+
!(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;
|
|
2236
|
+
!(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
2237
|
actionDef.rules.forEach((rule) => {
|
|
2128
2238
|
if (rule.type === "modifyObjectRule") {
|
|
2129
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2239
|
+
!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
2240
|
}
|
|
2131
2241
|
if (rule.type === "deleteObjectRule") {
|
|
2132
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2242
|
+
!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;
|
|
2243
|
+
}
|
|
2244
|
+
if (rule.type === "modifyInterfaceRule") {
|
|
2245
|
+
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2246
|
+
!(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;
|
|
2247
|
+
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2248
|
+
!(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;
|
|
2249
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2250
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2251
|
+
!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;
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
if (rule.type === "addInterfaceRule") {
|
|
2255
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2256
|
+
!(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;
|
|
2257
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2258
|
+
!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;
|
|
2259
|
+
});
|
|
2133
2260
|
}
|
|
2134
2261
|
});
|
|
2135
2262
|
const fullAction = {
|
|
@@ -2204,7 +2331,7 @@ function createParameters(def, parameterSet) {
|
|
|
2204
2331
|
});
|
|
2205
2332
|
return [...targetParam, ...Array.from(parameterSet).map((id) => ({
|
|
2206
2333
|
id,
|
|
2207
|
-
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ??
|
|
2334
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2208
2335
|
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2209
2336
|
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2210
2337
|
...def.parameterConfiguration?.[id],
|
|
@@ -2233,14 +2360,14 @@ function referencedParameterIds(actionDef) {
|
|
|
2233
2360
|
actionDef.rules.forEach((rule) => {
|
|
2234
2361
|
switch (rule.type) {
|
|
2235
2362
|
case "addInterfaceRule":
|
|
2236
|
-
rule.addInterfaceRule.interfaceApiName =
|
|
2363
|
+
rule.addInterfaceRule.interfaceApiName = sanitize(rule.addInterfaceRule.interfaceApiName);
|
|
2237
2364
|
parameterIds.add(rule.addInterfaceRule.objectTypeParameter);
|
|
2238
2365
|
Object.entries(rule.addInterfaceRule.sharedPropertyValues).forEach(([k, v]) => {
|
|
2239
2366
|
if (v.type === "parameterId") {
|
|
2240
2367
|
parameterIds.add(v.parameterId);
|
|
2241
2368
|
}
|
|
2242
2369
|
delete rule.addInterfaceRule.sharedPropertyValues[k];
|
|
2243
|
-
rule.addInterfaceRule.sharedPropertyValues[
|
|
2370
|
+
rule.addInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2244
2371
|
});
|
|
2245
2372
|
break;
|
|
2246
2373
|
case "modifyInterfaceRule":
|
|
@@ -2250,7 +2377,7 @@ function referencedParameterIds(actionDef) {
|
|
|
2250
2377
|
parameterIds.add(v.parameterId);
|
|
2251
2378
|
}
|
|
2252
2379
|
delete rule.modifyInterfaceRule.sharedPropertyValues[k];
|
|
2253
|
-
rule.modifyInterfaceRule.sharedPropertyValues[
|
|
2380
|
+
rule.modifyInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2254
2381
|
});
|
|
2255
2382
|
break;
|
|
2256
2383
|
case "addObjectRule":
|
|
@@ -2479,22 +2606,16 @@ function extractActionParameterType(pt) {
|
|
|
2479
2606
|
function maybeAddList(type, pt) {
|
|
2480
2607
|
return pt.array ?? false ? type + "List" : type;
|
|
2481
2608
|
}
|
|
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
2609
|
function kebab(s) {
|
|
2489
2610
|
return s.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/\./g, "-").toLowerCase();
|
|
2490
2611
|
}
|
|
2491
|
-
function
|
|
2612
|
+
function sanitize(s) {
|
|
2492
2613
|
return s.includes(".") ? s : namespace + s;
|
|
2493
2614
|
}
|
|
2494
|
-
function convertValidationRule(actionValidation) {
|
|
2615
|
+
function convertValidationRule(actionValidation, objectProperties) {
|
|
2495
2616
|
return actionValidation.map((rule) => {
|
|
2496
2617
|
return {
|
|
2497
|
-
condition: convertConditionDefinition(rule.condition),
|
|
2618
|
+
condition: convertConditionDefinition(rule.condition, objectProperties),
|
|
2498
2619
|
displayMetadata: rule.displayMetadata ?? {
|
|
2499
2620
|
failureMessage: "Did not satisfy validation",
|
|
2500
2621
|
typeClasses: []
|
|
@@ -2521,9 +2642,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
2521
2642
|
switch (condition.type) {
|
|
2522
2643
|
case "parameter":
|
|
2523
2644
|
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" ?
|
|
2645
|
+
!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;
|
|
2646
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant6__default.default(false) : void 0;
|
|
2647
|
+
!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
2648
|
break;
|
|
2528
2649
|
case "and":
|
|
2529
2650
|
if ("conditions" in condition) {
|
|
@@ -2551,11 +2672,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2551
2672
|
if (!defaultValue) return;
|
|
2552
2673
|
switch (defaultValue.type) {
|
|
2553
2674
|
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" ?
|
|
2675
|
+
!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;
|
|
2676
|
+
!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
2677
|
break;
|
|
2557
2678
|
case "staticValue":
|
|
2558
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
2679
|
+
!(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
2680
|
break;
|
|
2560
2681
|
case "staticObject":
|
|
2561
2682
|
case "interfaceParameterPropertyValue":
|
|
@@ -2570,10 +2691,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2570
2691
|
}
|
|
2571
2692
|
function validateActionParameters(def) {
|
|
2572
2693
|
[...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" ?
|
|
2694
|
+
!(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
2695
|
});
|
|
2575
2696
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2576
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2697
|
+
!(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
2698
|
});
|
|
2578
2699
|
}
|
|
2579
2700
|
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
@@ -2583,48 +2704,12 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2583
2704
|
const orderingSet = new Set(parameterOrdering);
|
|
2584
2705
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2585
2706
|
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;
|
|
2707
|
+
!(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
2708
|
}
|
|
2624
2709
|
function defineSharedPropertyType(sptDef) {
|
|
2625
2710
|
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" ?
|
|
2711
|
+
!(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;
|
|
2712
|
+
!(!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
2713
|
const fullSpt = {
|
|
2629
2714
|
...sptDef,
|
|
2630
2715
|
apiName,
|
|
@@ -2638,27 +2723,61 @@ function defineSharedPropertyType(sptDef) {
|
|
|
2638
2723
|
return fullSpt;
|
|
2639
2724
|
}
|
|
2640
2725
|
|
|
2726
|
+
// src/api/interface/mapSimplifiedStatusToInterfaceTypeStatus.ts
|
|
2727
|
+
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
2728
|
+
switch (status.type) {
|
|
2729
|
+
case "deprecated":
|
|
2730
|
+
return {
|
|
2731
|
+
type: "deprecated",
|
|
2732
|
+
deprecated: {
|
|
2733
|
+
message: status.message,
|
|
2734
|
+
deadline: status.deadline,
|
|
2735
|
+
replacedBy: void 0
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
case "active":
|
|
2739
|
+
return {
|
|
2740
|
+
type: "active",
|
|
2741
|
+
active: {}
|
|
2742
|
+
};
|
|
2743
|
+
case "experimental":
|
|
2744
|
+
return {
|
|
2745
|
+
type: "experimental",
|
|
2746
|
+
experimental: {}
|
|
2747
|
+
};
|
|
2748
|
+
default:
|
|
2749
|
+
throw new Error(`Invalid status type: ${status.type}`);
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
// src/api/namespace/combineApiNamespaceIfMissing.ts
|
|
2754
|
+
function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
2755
|
+
return apiName.includes(".") ? apiName : namespace2 + apiName;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2641
2758
|
// src/api/defineInterface.ts
|
|
2642
2759
|
function defineInterface(interfaceDef) {
|
|
2643
2760
|
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(([
|
|
2761
|
+
!(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;
|
|
2762
|
+
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2646
2763
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2647
|
-
|
|
2764
|
+
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
2765
|
+
return [apiName3, {
|
|
2648
2766
|
required: type.required,
|
|
2649
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2767
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type.propertyDefinition)
|
|
2650
2768
|
}];
|
|
2651
2769
|
}
|
|
2652
|
-
|
|
2770
|
+
const apiName2 = combineApiNamespaceIfMissing(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
2771
|
+
return [apiName2, {
|
|
2653
2772
|
required: true,
|
|
2654
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2773
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
2655
2774
|
}];
|
|
2656
2775
|
}));
|
|
2657
2776
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
2658
2777
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2659
2778
|
type: "active"
|
|
2660
2779
|
});
|
|
2661
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
2780
|
+
!(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
2781
|
const fullInterface = {
|
|
2663
2782
|
apiName,
|
|
2664
2783
|
displayMetadata: {
|
|
@@ -2682,37 +2801,9 @@ function defineInterface(interfaceDef) {
|
|
|
2682
2801
|
updateOntology(fullInterface);
|
|
2683
2802
|
return fullInterface;
|
|
2684
2803
|
}
|
|
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
2804
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2714
2805
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2715
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
2806
|
+
!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
2807
|
const spt = defineSharedPropertyType({
|
|
2717
2808
|
apiName,
|
|
2718
2809
|
displayName: apiName,
|
|
@@ -2722,16 +2813,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2722
2813
|
return spt;
|
|
2723
2814
|
} else {
|
|
2724
2815
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2725
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
2816
|
+
!(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
2817
|
key: apiName,
|
|
2727
2818
|
apiName: type.apiName
|
|
2728
|
-
})}`) :
|
|
2819
|
+
})}`) : invariant6__default.default(false) : void 0;
|
|
2729
2820
|
return type;
|
|
2730
2821
|
}
|
|
2731
2822
|
}
|
|
2732
2823
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2733
2824
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2734
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
2825
|
+
!(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
2826
|
linkDef.from.links.push({
|
|
2736
2827
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2737
2828
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2751,7 +2842,7 @@ function getLinkMeta(meta) {
|
|
|
2751
2842
|
displayName,
|
|
2752
2843
|
description
|
|
2753
2844
|
} = meta;
|
|
2754
|
-
const apiNameWithNamespace =
|
|
2845
|
+
const apiNameWithNamespace = combineApiNamespaceIfMissing(namespace, apiName);
|
|
2755
2846
|
const apiNameWithoutNamespace = withoutNamespace(apiNameWithNamespace);
|
|
2756
2847
|
return {
|
|
2757
2848
|
apiName: apiNameWithNamespace,
|
|
@@ -2763,20 +2854,35 @@ var typeIdPattern = /([a-z][a-z0-9\\-]*)/;
|
|
|
2763
2854
|
function defineLink(linkDefinition) {
|
|
2764
2855
|
if ("one" in linkDefinition) {
|
|
2765
2856
|
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" ?
|
|
2857
|
+
!(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;
|
|
2858
|
+
!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
2859
|
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
|
-
|
|
2860
|
+
!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;
|
|
2861
|
+
}
|
|
2862
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
2863
|
+
!("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;
|
|
2864
|
+
!("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;
|
|
2865
|
+
}
|
|
2866
|
+
let fullLinkDefinition;
|
|
2867
|
+
if ("one" in linkDefinition) {
|
|
2868
|
+
fullLinkDefinition = {
|
|
2869
|
+
...linkDefinition,
|
|
2870
|
+
one: convertUserOneToManyLinkDefinition(linkDefinition.one),
|
|
2871
|
+
toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany)
|
|
2872
|
+
};
|
|
2873
|
+
} else if ("intermediaryObjectType" in linkDefinition) {
|
|
2874
|
+
fullLinkDefinition = {
|
|
2875
|
+
...linkDefinition,
|
|
2876
|
+
many: convertUserIntermediaryLinkDefinition(linkDefinition.many),
|
|
2877
|
+
toMany: convertUserIntermediaryLinkDefinition(linkDefinition.toMany)
|
|
2878
|
+
};
|
|
2879
|
+
} else {
|
|
2880
|
+
fullLinkDefinition = {
|
|
2881
|
+
...linkDefinition,
|
|
2882
|
+
many: convertUserManyToManyLinkDefinition(linkDefinition.many),
|
|
2883
|
+
toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany)
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2780
2886
|
const linkType = {
|
|
2781
2887
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2782
2888
|
...fullLinkDefinition,
|
|
@@ -2797,11 +2903,17 @@ function convertUserManyToManyLinkDefinition(manyToMany) {
|
|
|
2797
2903
|
metadata: convertLinkTypeMetadata(manyToMany.metadata)
|
|
2798
2904
|
};
|
|
2799
2905
|
}
|
|
2906
|
+
function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
2907
|
+
return {
|
|
2908
|
+
...intermediary,
|
|
2909
|
+
metadata: convertLinkTypeMetadata(intermediary.metadata)
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2800
2912
|
function convertLinkTypeMetadata(metadata) {
|
|
2801
2913
|
return {
|
|
2802
2914
|
apiName: metadata.apiName,
|
|
2803
2915
|
displayMetadata: {
|
|
2804
|
-
displayName: metadata.displayName ??
|
|
2916
|
+
displayName: metadata.displayName ?? uppercaseFirstLetter(metadata.apiName),
|
|
2805
2917
|
pluralDisplayName: metadata.pluralDisplayName ?? convertToPluralDisplayName(metadata.apiName),
|
|
2806
2918
|
visibility: metadata.visibility ?? "NORMAL",
|
|
2807
2919
|
groupDisplayName: metadata.groupDisplayName ?? ""
|
|
@@ -2861,7 +2973,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2861
2973
|
version
|
|
2862
2974
|
} = valueTypeDef;
|
|
2863
2975
|
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" ?
|
|
2976
|
+
!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
2977
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2866
2978
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2867
2979
|
const output = {
|
|
@@ -2897,6 +3009,40 @@ function defineValueType(valueTypeDef) {
|
|
|
2897
3009
|
return vt;
|
|
2898
3010
|
}
|
|
2899
3011
|
|
|
3012
|
+
// src/api/importOntologyEntity.ts
|
|
3013
|
+
function importOntologyEntity(e) {
|
|
3014
|
+
if (e.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
3015
|
+
importedTypes[e.__type][e.apiName] = e;
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
if (importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] === void 0) {
|
|
3019
|
+
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] = [];
|
|
3020
|
+
}
|
|
3021
|
+
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName].push(e);
|
|
3022
|
+
}
|
|
3023
|
+
function importSharedPropertyType(opts) {
|
|
3024
|
+
const {
|
|
3025
|
+
apiName,
|
|
3026
|
+
packageName,
|
|
3027
|
+
typeHint,
|
|
3028
|
+
array
|
|
3029
|
+
} = opts;
|
|
3030
|
+
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3031
|
+
if (packageName !== void 0) {
|
|
3032
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, "Package name format invalid ends with period") : invariant6__default.default(false) : void 0;
|
|
3033
|
+
!(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;
|
|
3034
|
+
}
|
|
3035
|
+
const spt = {
|
|
3036
|
+
apiName: fullApiName,
|
|
3037
|
+
type: typeHint,
|
|
3038
|
+
nonNameSpacedApiName: apiName,
|
|
3039
|
+
array: array ?? false,
|
|
3040
|
+
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
3041
|
+
};
|
|
3042
|
+
importOntologyEntity(spt);
|
|
3043
|
+
return spt;
|
|
3044
|
+
}
|
|
3045
|
+
|
|
2900
3046
|
// src/api/wrapWithProxy.ts
|
|
2901
3047
|
function wrapWithProxy(entity) {
|
|
2902
3048
|
return new Proxy(entity, {
|
|
@@ -2912,9 +3058,9 @@ exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
|
2912
3058
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
2913
3059
|
exports.addDependency = addDependency;
|
|
2914
3060
|
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
2915
|
-
exports.convertToDisplayName =
|
|
3061
|
+
exports.convertToDisplayName = uppercaseFirstLetter;
|
|
2916
3062
|
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
2917
|
-
exports.convertType =
|
|
3063
|
+
exports.convertType = propertyTypeTypeToOntologyIrType;
|
|
2918
3064
|
exports.default = main;
|
|
2919
3065
|
exports.defineAction = defineAction;
|
|
2920
3066
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|