@osdk/maker 0.13.0-beta.8 → 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 +95 -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 +11 -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 +1988 -692
- 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 +1150 -1002
- 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 +11 -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 +1988 -692
- 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 -6
- 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,23 +65,54 @@ 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))$/;
|
|
57
102
|
var ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
103
|
+
var API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
58
104
|
function defineObject(objectDef) {
|
|
59
105
|
const apiName = namespace + objectDef.apiName;
|
|
60
106
|
const propertyApiNames = objectDef.properties ? Object.keys(objectDef.properties) : [];
|
|
61
107
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
62
108
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
63
109
|
}
|
|
64
|
-
!
|
|
65
|
-
!propertyApiNames.includes(objectDef.
|
|
66
|
-
|
|
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;
|
|
67
114
|
const retentionPeriod = objectDef.datasource?.retentionPeriod;
|
|
68
|
-
!(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;
|
|
69
116
|
if (objectDef.status === "experimental") {
|
|
70
117
|
const activeProperties = [];
|
|
71
118
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -73,16 +120,16 @@ function defineObject(objectDef) {
|
|
|
73
120
|
activeProperties.push(apiName2);
|
|
74
121
|
}
|
|
75
122
|
});
|
|
76
|
-
!(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;
|
|
77
124
|
}
|
|
78
125
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
79
126
|
const deadline = objectDef.status.deadline;
|
|
80
|
-
!(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;
|
|
81
128
|
}
|
|
82
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
83
|
-
!!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;
|
|
84
131
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
85
|
-
const allInterfaceProperties =
|
|
132
|
+
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
86
133
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
87
134
|
type: "invalid",
|
|
88
135
|
reason: `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
@@ -97,9 +144,9 @@ function defineObject(objectDef) {
|
|
|
97
144
|
reason: `Interface property ${interfaceProp[1].sharedPropertyType.apiName} not implemented by ${objectDef.apiName} object definition`
|
|
98
145
|
};
|
|
99
146
|
};
|
|
100
|
-
const validations = Object.entries(
|
|
147
|
+
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
101
148
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
102
|
-
!(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;
|
|
103
150
|
});
|
|
104
151
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
105
152
|
const finalObject = {
|
|
@@ -112,17 +159,6 @@ function defineObject(objectDef) {
|
|
|
112
159
|
objectDef.apiName = apiName;
|
|
113
160
|
return objectDef;
|
|
114
161
|
}
|
|
115
|
-
function isExotic(type) {
|
|
116
|
-
if (type === void 0) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
if (typeof type === "string") {
|
|
120
|
-
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
121
|
-
} else if (typeof type === "object" && type != null) {
|
|
122
|
-
return type.type === "marking" || type.type === "struct";
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
162
|
function formatValidationErrors(error) {
|
|
127
163
|
return `Ontology Definition Error: ${error.reason}
|
|
128
164
|
`;
|
|
@@ -145,57 +181,122 @@ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
|
145
181
|
type: "valid"
|
|
146
182
|
};
|
|
147
183
|
}
|
|
148
|
-
function
|
|
184
|
+
function uppercaseFirstLetter(s) {
|
|
149
185
|
return s === void 0 || s == null ? "" : s.charAt(0).toUpperCase() + s.slice(1);
|
|
150
186
|
}
|
|
151
187
|
function convertToPluralDisplayName(s) {
|
|
152
|
-
return s === void 0 || s == null ? "" : s.endsWith("s") ?
|
|
153
|
-
}
|
|
154
|
-
function getAllInterfaceProperties(interfaceType) {
|
|
155
|
-
let properties = interfaceType.propertiesV2;
|
|
156
|
-
interfaceType.extendsInterfaces.forEach((ext) => {
|
|
157
|
-
properties = {
|
|
158
|
-
...properties,
|
|
159
|
-
...getAllInterfaceProperties(ext)
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
return properties;
|
|
188
|
+
return s === void 0 || s == null ? "" : s.endsWith("s") ? uppercaseFirstLetter(s) : uppercaseFirstLetter(s) + "s";
|
|
163
189
|
}
|
|
164
190
|
function convertUserObjectPropertyType(apiName, property) {
|
|
165
191
|
property.apiName = apiName;
|
|
166
|
-
property.displayName = property.displayName ??
|
|
192
|
+
property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);
|
|
167
193
|
return {
|
|
168
194
|
...property,
|
|
169
195
|
apiName,
|
|
170
|
-
displayName: property.displayName ??
|
|
196
|
+
displayName: property.displayName ?? uppercaseFirstLetter(apiName),
|
|
171
197
|
type: property.type
|
|
172
198
|
};
|
|
173
199
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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":
|
|
182
252
|
return {
|
|
183
|
-
type: "
|
|
184
|
-
|
|
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
|
+
}
|
|
185
279
|
};
|
|
186
|
-
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;
|
|
187
282
|
return {
|
|
188
|
-
type: "
|
|
189
|
-
|
|
283
|
+
type: "comparison",
|
|
284
|
+
comparison: {
|
|
285
|
+
operator: "EQUALS",
|
|
286
|
+
left: {
|
|
287
|
+
type: "parameterId",
|
|
288
|
+
parameterId: condition.parameterId
|
|
289
|
+
},
|
|
290
|
+
right: condition.matches
|
|
291
|
+
}
|
|
190
292
|
};
|
|
191
293
|
default:
|
|
192
|
-
return
|
|
193
|
-
type: "editable",
|
|
194
|
-
editable: {}
|
|
195
|
-
};
|
|
294
|
+
return condition;
|
|
196
295
|
}
|
|
197
296
|
}
|
|
198
|
-
|
|
297
|
+
|
|
298
|
+
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
299
|
+
function convertActionParameterConditionalOverride(override, validation, objectProperties) {
|
|
199
300
|
let parameterBlockOverride;
|
|
200
301
|
switch (override.type) {
|
|
201
302
|
case "required":
|
|
@@ -260,13 +361,41 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
260
361
|
throw new Error(`Unknown parameter override type`);
|
|
261
362
|
}
|
|
262
363
|
return {
|
|
263
|
-
condition: convertConditionDefinition(override.condition),
|
|
364
|
+
condition: convertConditionDefinition(override.condition, objectProperties),
|
|
264
365
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
265
366
|
};
|
|
266
367
|
}
|
|
267
|
-
|
|
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) {
|
|
268
397
|
return {
|
|
269
|
-
condition: convertConditionDefinition(override.condition),
|
|
398
|
+
condition: convertConditionDefinition(override.condition, objectProperties),
|
|
270
399
|
sectionBlockOverrides: [{
|
|
271
400
|
type: "visibility",
|
|
272
401
|
visibility: {
|
|
@@ -281,229 +410,94 @@ function convertSectionConditionalOverride(override, defaultVisibility) {
|
|
|
281
410
|
}]
|
|
282
411
|
};
|
|
283
412
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
case "group":
|
|
309
|
-
return {
|
|
310
|
-
type: "comparison",
|
|
311
|
-
comparison: {
|
|
312
|
-
operator: "INTERSECTS",
|
|
313
|
-
left: {
|
|
314
|
-
type: "userProperty",
|
|
315
|
-
userProperty: {
|
|
316
|
-
userId: {
|
|
317
|
-
type: "currentUser",
|
|
318
|
-
currentUser: {}
|
|
319
|
-
},
|
|
320
|
-
propertyValue: {
|
|
321
|
-
type: "groupIds",
|
|
322
|
-
groupIds: {}
|
|
323
|
-
}
|
|
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
|
|
324
437
|
}
|
|
325
438
|
},
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
type: "stringList",
|
|
330
|
-
stringList: {
|
|
331
|
-
strings: [condition.name]
|
|
332
|
-
}
|
|
333
|
-
}
|
|
439
|
+
validation: {
|
|
440
|
+
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
441
|
+
required: convertParameterRequirementConstraint(p.validation.required)
|
|
334
442
|
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
type: "
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (!action.sections) return [];
|
|
355
|
-
const parametersToSection = Object.fromEntries(Object.entries(action.sections).flatMap(([sectionId, section]) => section.parameters.map((param) => [param, sectionId])));
|
|
356
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
357
|
-
const formContentOrdering = [];
|
|
358
|
-
parameterOrdering.forEach((param) => {
|
|
359
|
-
if (param in parametersToSection && !seenIds.has(parametersToSection[param])) {
|
|
360
|
-
formContentOrdering.push({
|
|
361
|
-
type: "sectionId",
|
|
362
|
-
sectionId: parametersToSection[param]
|
|
363
|
-
});
|
|
364
|
-
seenIds.add(parametersToSection[param]);
|
|
365
|
-
} else if (!(param in parametersToSection)) {
|
|
366
|
-
formContentOrdering.push({
|
|
367
|
-
type: "parameterId",
|
|
368
|
-
parameterId: param
|
|
369
|
-
});
|
|
370
|
-
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
|
+
}]))
|
|
371
462
|
}
|
|
372
|
-
});
|
|
373
|
-
return formContentOrdering;
|
|
374
|
-
}
|
|
375
|
-
function convertMappingValue(value) {
|
|
376
|
-
switch (value.type) {
|
|
377
|
-
case "uuid":
|
|
378
|
-
return {
|
|
379
|
-
type: "uniqueIdentifier",
|
|
380
|
-
uniqueIdentifier: {
|
|
381
|
-
linkId: value.linkId ?? crypto.randomUUID()
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
case "currentTime":
|
|
385
|
-
return {
|
|
386
|
-
type: "currentTime",
|
|
387
|
-
currentTime: {}
|
|
388
|
-
};
|
|
389
|
-
case "currentUser":
|
|
390
|
-
return {
|
|
391
|
-
type: "currentUser",
|
|
392
|
-
currentUser: {}
|
|
393
|
-
};
|
|
394
|
-
default:
|
|
395
|
-
return value;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
var defaultTypeClasses = [{
|
|
399
|
-
kind: "render_hint",
|
|
400
|
-
name: "SELECTABLE"
|
|
401
|
-
}, {
|
|
402
|
-
kind: "render_hint",
|
|
403
|
-
name: "SORTABLE"
|
|
404
|
-
}];
|
|
405
|
-
function shouldNotHaveRenderHints(type) {
|
|
406
|
-
return ["struct", "mediaReference", "geotimeSeries"].includes(getPropertyTypeName(type));
|
|
407
|
-
}
|
|
408
|
-
function hasRenderHints(typeClasses) {
|
|
409
|
-
return (typeClasses ?? []).some((tc) => tc.kind.toLowerCase() === "render_hint");
|
|
410
|
-
}
|
|
411
|
-
function getPropertyTypeName(type) {
|
|
412
|
-
return typeof type === "object" ? type.type : type;
|
|
413
|
-
}
|
|
414
|
-
function convertValueType(valueType) {
|
|
415
|
-
return {
|
|
416
|
-
apiName: valueType.apiName,
|
|
417
|
-
version: valueType.version,
|
|
418
|
-
packageNamespace: valueType.packageNamespace,
|
|
419
|
-
displayMetadata: valueType.displayMetadata
|
|
420
463
|
};
|
|
421
464
|
}
|
|
422
|
-
function
|
|
423
|
-
if (
|
|
424
|
-
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
|
+
};
|
|
425
474
|
}
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
475
|
+
const {
|
|
476
|
+
min,
|
|
477
|
+
max
|
|
478
|
+
} = required.listLength;
|
|
430
479
|
return {
|
|
431
|
-
|
|
480
|
+
type: "listLengthValidation",
|
|
481
|
+
listLengthValidation: {
|
|
482
|
+
minLength: min,
|
|
483
|
+
maxLength: max
|
|
484
|
+
}
|
|
432
485
|
};
|
|
433
486
|
}
|
|
434
|
-
function
|
|
435
|
-
switch (
|
|
436
|
-
case "
|
|
437
|
-
return
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
case "
|
|
441
|
-
return
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
case "binary":
|
|
445
|
-
throw new Error("Binary type constraints are not supported");
|
|
446
|
-
case "date":
|
|
447
|
-
return {
|
|
448
|
-
...dc
|
|
449
|
-
};
|
|
450
|
-
case "decimal":
|
|
451
|
-
return {
|
|
452
|
-
...dc
|
|
453
|
-
};
|
|
454
|
-
case "double":
|
|
455
|
-
return {
|
|
456
|
-
...dc
|
|
457
|
-
};
|
|
458
|
-
case "float":
|
|
459
|
-
return {
|
|
460
|
-
...dc
|
|
461
|
-
};
|
|
462
|
-
case "integer":
|
|
463
|
-
return {
|
|
464
|
-
...dc
|
|
465
|
-
};
|
|
466
|
-
case "long":
|
|
467
|
-
return {
|
|
468
|
-
...dc
|
|
469
|
-
};
|
|
470
|
-
case "map":
|
|
471
|
-
throw new Error("Map type constraints are not supported");
|
|
472
|
-
case "nullable":
|
|
473
|
-
throw new Error("Nullable constraints are not supported");
|
|
474
|
-
case "short":
|
|
475
|
-
return {
|
|
476
|
-
...dc
|
|
477
|
-
};
|
|
478
|
-
case "string":
|
|
479
|
-
return {
|
|
480
|
-
...dc
|
|
481
|
-
};
|
|
482
|
-
case "struct":
|
|
483
|
-
return {
|
|
484
|
-
type: "struct",
|
|
485
|
-
struct: {
|
|
486
|
-
elementConstraints: Object.fromEntries(Object.entries(dc.struct.elementConstraints).map(([field, constraint]) => [field, convertDataConstraintToDataConstraints(constraint)]))
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
case "structV2":
|
|
490
|
-
throw new Error("StructV2 constraints are not supported");
|
|
491
|
-
case "timestamp":
|
|
492
|
-
return {
|
|
493
|
-
...dc
|
|
494
|
-
};
|
|
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 [];
|
|
495
497
|
default:
|
|
496
|
-
|
|
498
|
+
return void 0;
|
|
497
499
|
}
|
|
498
500
|
}
|
|
499
|
-
function convertDataConstraintToDataConstraints(dc) {
|
|
500
|
-
return {
|
|
501
|
-
propertyTypeConstraints: [{
|
|
502
|
-
constraints: dataConstraintToPropertyTypeDataConstraint(dc)
|
|
503
|
-
// known limitation: structs don't carry field-level data constraint failure messages
|
|
504
|
-
}]
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
501
|
function convertNullabilityToDataConstraint(prop) {
|
|
508
502
|
if (typeof prop.type === "object" && prop.type.type === "marking") {
|
|
509
503
|
if (prop.nullability === void 0) {
|
|
@@ -516,7 +510,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
516
510
|
}
|
|
517
511
|
};
|
|
518
512
|
}
|
|
519
|
-
!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;
|
|
520
514
|
return {
|
|
521
515
|
propertyTypeConstraints: [],
|
|
522
516
|
nullability: void 0,
|
|
@@ -529,7 +523,17 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
529
523
|
nullabilityV2: prop.nullability
|
|
530
524
|
};
|
|
531
525
|
}
|
|
532
|
-
|
|
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) {
|
|
533
537
|
switch (true) {
|
|
534
538
|
case (typeof type === "object" && "markingType" in type):
|
|
535
539
|
return {
|
|
@@ -552,14 +556,14 @@ function convertType(type) {
|
|
|
552
556
|
},
|
|
553
557
|
typeClasses: [],
|
|
554
558
|
aliases: [],
|
|
555
|
-
fieldType:
|
|
559
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
556
560
|
};
|
|
557
561
|
} else {
|
|
558
562
|
if ("fieldType" in fieldTypeDefinition) {
|
|
559
563
|
field = {
|
|
560
564
|
...fieldTypeDefinition,
|
|
561
565
|
apiName: key,
|
|
562
|
-
fieldType:
|
|
566
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition.fieldType),
|
|
563
567
|
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
564
568
|
aliases: fieldTypeDefinition.aliases ?? []
|
|
565
569
|
};
|
|
@@ -572,7 +576,7 @@ function convertType(type) {
|
|
|
572
576
|
},
|
|
573
577
|
typeClasses: [],
|
|
574
578
|
aliases: [],
|
|
575
|
-
fieldType:
|
|
579
|
+
fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition)
|
|
576
580
|
};
|
|
577
581
|
}
|
|
578
582
|
}
|
|
@@ -633,284 +637,207 @@ function convertType(type) {
|
|
|
633
637
|
return distributeTypeHelper(type);
|
|
634
638
|
}
|
|
635
639
|
}
|
|
636
|
-
|
|
637
|
-
|
|
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({
|
|
638
655
|
type,
|
|
639
|
-
|
|
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
|
+
}
|
|
640
683
|
};
|
|
641
684
|
}
|
|
642
685
|
|
|
643
|
-
// src/
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
OBJECT_TYPE: {},
|
|
672
|
-
ACTION_TYPE: {},
|
|
673
|
-
LINK_TYPE: {},
|
|
674
|
-
INTERFACE_TYPE: {},
|
|
675
|
-
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: {}
|
|
676
714
|
};
|
|
677
|
-
try {
|
|
678
|
-
await body();
|
|
679
|
-
} catch (e) {
|
|
680
|
-
console.error("Unexpected error while processing the body of the ontology", e);
|
|
681
|
-
throw e;
|
|
682
|
-
}
|
|
683
|
-
if (outputDir) {
|
|
684
|
-
writeStaticObjects(outputDir);
|
|
685
|
-
}
|
|
686
|
-
if (dependencyFile) {
|
|
687
|
-
writeDependencyFile(dependencyFile);
|
|
688
|
-
}
|
|
689
|
-
return convertToWireOntologyIr(ontologyDefinition);
|
|
690
715
|
}
|
|
691
|
-
function writeStaticObjects(outputDir) {
|
|
692
|
-
const codegenDir = path2__namespace.resolve(outputDir, "codegen");
|
|
693
|
-
const typeDirs = {
|
|
694
|
-
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
695
|
-
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
696
|
-
[OntologyEntityTypeEnum.OBJECT_TYPE]: "object-types",
|
|
697
|
-
[OntologyEntityTypeEnum.LINK_TYPE]: "link-types",
|
|
698
|
-
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
699
|
-
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
700
|
-
};
|
|
701
|
-
if (!fs__namespace.existsSync(codegenDir)) {
|
|
702
|
-
fs__namespace.mkdirSync(codegenDir, {
|
|
703
|
-
recursive: true
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
707
|
-
const currentTypeDirPath = path2__namespace.join(codegenDir, typeDirNameFromMap);
|
|
708
|
-
if (fs__namespace.existsSync(currentTypeDirPath)) {
|
|
709
|
-
fs__namespace.rmSync(currentTypeDirPath, {
|
|
710
|
-
recursive: true,
|
|
711
|
-
force: true
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
fs__namespace.mkdirSync(currentTypeDirPath, {
|
|
715
|
-
recursive: true
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
const topLevelExportStatements = [];
|
|
719
|
-
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
720
|
-
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
721
|
-
const typeDirPath = path2__namespace.join(codegenDir, typeDirName);
|
|
722
|
-
const entityModuleNames = [];
|
|
723
|
-
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
724
|
-
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
725
|
-
const filePath = path2__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
726
|
-
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
727
|
-
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
728
|
-
const content = `
|
|
729
|
-
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
730
|
-
import type { ${entityTypeName} } from '@osdk/maker';
|
|
731
716
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
fs__namespace.writeFileSync(filePath, content, {
|
|
737
|
-
flag: "w"
|
|
738
|
-
});
|
|
739
|
-
entityModuleNames.push(entityFileNameBase);
|
|
740
|
-
});
|
|
741
|
-
for (const entityModuleName of entityModuleNames) {
|
|
742
|
-
topLevelExportStatements.push(`export { ${entityModuleName} } from "./codegen/${typeDirName}/${entityModuleName}.js";`);
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
if (topLevelExportStatements.length > 0) {
|
|
746
|
-
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
747
|
-
const mainIndexFilePath = path2__namespace.join(outputDir, "index.ts");
|
|
748
|
-
fs__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
749
|
-
flag: "w"
|
|
750
|
-
});
|
|
717
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
718
|
+
function convertCardinality(cardinality) {
|
|
719
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
720
|
+
return "ONE_TO_MANY";
|
|
751
721
|
}
|
|
722
|
+
return "ONE_TO_ONE";
|
|
752
723
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
function convertToWireOntologyIr(ontology) {
|
|
776
|
-
return {
|
|
777
|
-
ontology: convertToWireBlockData(ontology),
|
|
778
|
-
importedOntology: convertToWireBlockData(importedTypes),
|
|
779
|
-
valueTypes: convertOntologyToValueTypeIr(ontology),
|
|
780
|
-
importedValueTypes: convertOntologyToValueTypeIr(importedTypes)
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
function convertToWireBlockData(ontology) {
|
|
784
|
-
return {
|
|
785
|
-
objectTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.OBJECT_TYPE]).map(([apiName, objectType]) => {
|
|
786
|
-
return [apiName, convertObject(objectType)];
|
|
787
|
-
})),
|
|
788
|
-
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]).map(([apiName, spt]) => [apiName, {
|
|
789
|
-
sharedPropertyType: convertSpt(spt)
|
|
790
|
-
}])),
|
|
791
|
-
interfaceTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.INTERFACE_TYPE]).map(([apiName, interfaceType]) => {
|
|
792
|
-
return [apiName, {
|
|
793
|
-
interfaceType: convertInterface(interfaceType)
|
|
794
|
-
}];
|
|
795
|
-
})),
|
|
796
|
-
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
797
|
-
return [id, convertLink(link)];
|
|
798
|
-
})),
|
|
799
|
-
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
800
|
-
return [apiName, convertAction(action)];
|
|
801
|
-
})),
|
|
802
|
-
blockPermissionInformation: {
|
|
803
|
-
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).filter(([apiName, action]) => action.validation).map(([apiName, action]) => {
|
|
804
|
-
return [apiName, {
|
|
805
|
-
restrictionStatus: {
|
|
806
|
-
hasRolesApplied: true,
|
|
807
|
-
ontologyPackageRid: null,
|
|
808
|
-
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
|
|
809
746
|
}
|
|
810
|
-
}]
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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
|
|
836
780
|
}
|
|
837
|
-
},
|
|
838
|
-
|
|
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
|
-
type: "geotimeSeries",
|
|
872
|
-
geotimeSeries: {
|
|
873
|
-
geotimeSeriesIntegrationRid: identifier,
|
|
874
|
-
properties: [property.apiName]
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
return [buildDatasource(property.apiName, geotimeDefinition)];
|
|
878
|
-
case "mediaReference":
|
|
879
|
-
const mediaSetDefinition = {
|
|
880
|
-
type: "mediaSetView",
|
|
881
|
-
mediaSetView: {
|
|
882
|
-
assumedMarkings: [],
|
|
883
|
-
mediaSetViewLocator: identifier,
|
|
884
|
-
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
|
+
}]
|
|
885
815
|
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
816
|
+
},
|
|
817
|
+
editsConfiguration: {
|
|
818
|
+
onlyAllowPrivilegedEdits: false
|
|
819
|
+
},
|
|
820
|
+
redacted: linkType.redacted
|
|
821
|
+
};
|
|
890
822
|
}
|
|
891
|
-
}
|
|
892
|
-
function buildDatasource(apiName, definition, classificationMarkingGroupName, mandatoryMarkingGroupName) {
|
|
893
|
-
const needsSecurity = classificationMarkingGroupName !== void 0 || mandatoryMarkingGroupName !== void 0;
|
|
894
|
-
const securityConfig = needsSecurity ? {
|
|
895
|
-
classificationConstraint: classificationMarkingGroupName ? {
|
|
896
|
-
markingGroupName: classificationMarkingGroupName
|
|
897
|
-
} : void 0,
|
|
898
|
-
markingConstraint: mandatoryMarkingGroupName ? {
|
|
899
|
-
markingGroupName: mandatoryMarkingGroupName
|
|
900
|
-
} : void 0
|
|
901
|
-
} : void 0;
|
|
902
823
|
return {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
824
|
+
linkType: {
|
|
825
|
+
definition,
|
|
826
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
827
|
+
status: linkType.status ?? {
|
|
828
|
+
type: "active",
|
|
829
|
+
active: {}
|
|
830
|
+
},
|
|
831
|
+
redacted: linkType.redacted ?? false
|
|
907
832
|
},
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
833
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
834
|
+
entityMetadata: {
|
|
835
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
911
836
|
}
|
|
912
837
|
};
|
|
913
838
|
}
|
|
839
|
+
|
|
840
|
+
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
914
841
|
function convertDatasourceDefinition(objectType, properties) {
|
|
915
842
|
switch (objectType.datasource?.type) {
|
|
916
843
|
case "stream":
|
|
@@ -953,14 +880,6 @@ function convertDatasourceDefinition(objectType, properties) {
|
|
|
953
880
|
};
|
|
954
881
|
}
|
|
955
882
|
}
|
|
956
|
-
function extractMarkingGroups(properties, markingType) {
|
|
957
|
-
return properties.map((prop) => {
|
|
958
|
-
if (typeof prop.type === "object" && prop.type.type === "marking" && prop.type.markingType === markingType) {
|
|
959
|
-
return prop.type.markingInputGroupName;
|
|
960
|
-
}
|
|
961
|
-
return void 0;
|
|
962
|
-
}).filter((val) => val !== void 0);
|
|
963
|
-
}
|
|
964
883
|
function buildPropertyMapping(properties) {
|
|
965
884
|
return Object.fromEntries(properties.map((prop) => {
|
|
966
885
|
if (prop.editOnly) {
|
|
@@ -988,9 +907,130 @@ function buildPropertyMapping(properties) {
|
|
|
988
907
|
}];
|
|
989
908
|
}));
|
|
990
909
|
}
|
|
991
|
-
|
|
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) {
|
|
992
1032
|
const apiName = namespace + property.apiName;
|
|
993
|
-
!(!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;
|
|
994
1034
|
const output = {
|
|
995
1035
|
apiName: property.apiName,
|
|
996
1036
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1005,9 +1045,9 @@ function convertProperty(property) {
|
|
|
1005
1045
|
type: property.array ? {
|
|
1006
1046
|
type: "array",
|
|
1007
1047
|
array: {
|
|
1008
|
-
subtype:
|
|
1048
|
+
subtype: propertyTypeTypeToOntologyIrType(property.type)
|
|
1009
1049
|
}
|
|
1010
|
-
} :
|
|
1050
|
+
} : propertyTypeTypeToOntologyIrType(property.type),
|
|
1011
1051
|
typeClasses: property.typeClasses ?? (shouldNotHaveRenderHints(property.type) ? [] : defaultTypeClasses),
|
|
1012
1052
|
status: convertObjectStatus(property.status),
|
|
1013
1053
|
inlineAction: void 0,
|
|
@@ -1017,103 +1057,319 @@ function convertProperty(property) {
|
|
|
1017
1057
|
};
|
|
1018
1058
|
return output;
|
|
1019
1059
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}]
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
} else {
|
|
1045
|
-
definition = {
|
|
1046
|
-
type: "manyToMany",
|
|
1047
|
-
manyToMany: {
|
|
1048
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
1049
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
1050
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
1051
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
1052
|
-
peeringMetadata: void 0,
|
|
1053
|
-
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
1054
|
-
from: {
|
|
1055
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1056
|
-
object: linkType.many.object.apiName
|
|
1057
|
-
},
|
|
1058
|
-
to: {
|
|
1059
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1060
|
-
object: linkType.many.object.apiName
|
|
1061
|
-
}
|
|
1062
|
-
}],
|
|
1063
|
-
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
1064
|
-
from: {
|
|
1065
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1066
|
-
object: linkType.toMany.object.apiName
|
|
1067
|
-
},
|
|
1068
|
-
to: {
|
|
1069
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1070
|
-
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"
|
|
1071
1081
|
}
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
datasource = {
|
|
1076
|
-
rid: "ri.ontology.main.datasource.link-".concat(linkType.apiName),
|
|
1077
|
-
datasource: {
|
|
1078
|
-
type: "dataset",
|
|
1079
|
-
dataset: {
|
|
1080
|
-
datasetRid: "link-".concat(linkType.apiName),
|
|
1081
|
-
writebackDatasetRid: void 0,
|
|
1082
|
-
objectTypeAPrimaryKeyMapping: [{
|
|
1083
|
-
property: {
|
|
1084
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
1085
|
-
object: linkType.many.object.apiName
|
|
1086
|
-
},
|
|
1087
|
-
column: linkType.many.object.primaryKeyPropertyApiName
|
|
1088
|
-
}],
|
|
1089
|
-
objectTypeBPrimaryKeyMapping: [{
|
|
1090
|
-
property: {
|
|
1091
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
1092
|
-
object: linkType.toMany.object.apiName
|
|
1093
|
-
},
|
|
1094
|
-
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
1095
|
-
}]
|
|
1096
|
-
}
|
|
1097
|
-
},
|
|
1098
|
-
editsConfiguration: {
|
|
1099
|
-
onlyAllowPrivilegedEdits: false
|
|
1082
|
+
},
|
|
1083
|
+
pluralDisplayName: objectType.pluralDisplayName,
|
|
1084
|
+
visibility: objectType.visibility ?? "NORMAL"
|
|
1100
1085
|
},
|
|
1101
|
-
|
|
1102
|
-
|
|
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
|
+
});
|
|
1103
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;
|
|
1104
1364
|
return {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
type: "active",
|
|
1110
|
-
active: {}
|
|
1111
|
-
},
|
|
1112
|
-
redacted: linkType.redacted ?? false
|
|
1365
|
+
datasourceName: apiName,
|
|
1366
|
+
datasource: definition,
|
|
1367
|
+
editsConfiguration: {
|
|
1368
|
+
onlyAllowPrivilegedEdits: false
|
|
1113
1369
|
},
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1370
|
+
redacted: false,
|
|
1371
|
+
...securityConfig !== void 0 && {
|
|
1372
|
+
dataSecurity: securityConfig
|
|
1117
1373
|
}
|
|
1118
1374
|
};
|
|
1119
1375
|
}
|
|
@@ -1126,73 +1382,8 @@ function cleanAndValidateLinkTypeId(apiName) {
|
|
|
1126
1382
|
}
|
|
1127
1383
|
return linkTypeId;
|
|
1128
1384
|
}
|
|
1129
|
-
function convertInterface(interfaceType) {
|
|
1130
|
-
const {
|
|
1131
|
-
__type,
|
|
1132
|
-
...other
|
|
1133
|
-
} = interfaceType;
|
|
1134
|
-
return {
|
|
1135
|
-
...other,
|
|
1136
|
-
propertiesV2: Object.fromEntries(Object.values(interfaceType.propertiesV2).map((spt) => [spt.sharedPropertyType.apiName, {
|
|
1137
|
-
required: spt.required,
|
|
1138
|
-
sharedPropertyType: convertSpt(spt.sharedPropertyType)
|
|
1139
|
-
}])),
|
|
1140
|
-
displayMetadata: {
|
|
1141
|
-
displayName: interfaceType.displayMetadata.displayName,
|
|
1142
|
-
description: interfaceType.displayMetadata.description
|
|
1143
|
-
},
|
|
1144
|
-
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1145
|
-
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1146
|
-
properties: [],
|
|
1147
|
-
// TODO(mwalther): Support propertiesV3
|
|
1148
|
-
propertiesV3: {}
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
1385
|
function dumpOntologyFullMetadata() {
|
|
1152
|
-
return
|
|
1153
|
-
}
|
|
1154
|
-
function convertSpt({
|
|
1155
|
-
type,
|
|
1156
|
-
array,
|
|
1157
|
-
description,
|
|
1158
|
-
apiName,
|
|
1159
|
-
displayName,
|
|
1160
|
-
visibility,
|
|
1161
|
-
gothamMapping,
|
|
1162
|
-
typeClasses,
|
|
1163
|
-
valueType,
|
|
1164
|
-
nullability
|
|
1165
|
-
}) {
|
|
1166
|
-
const dataConstraint = convertNullabilityToDataConstraint({
|
|
1167
|
-
type,
|
|
1168
|
-
nullability
|
|
1169
|
-
});
|
|
1170
|
-
return {
|
|
1171
|
-
apiName,
|
|
1172
|
-
displayMetadata: {
|
|
1173
|
-
displayName: displayName ?? apiName,
|
|
1174
|
-
visibility: visibility ?? "NORMAL",
|
|
1175
|
-
description
|
|
1176
|
-
},
|
|
1177
|
-
type: array ? {
|
|
1178
|
-
type: "array",
|
|
1179
|
-
array: {
|
|
1180
|
-
subtype: convertType(type)
|
|
1181
|
-
}
|
|
1182
|
-
} : convertType(type),
|
|
1183
|
-
aliases: [],
|
|
1184
|
-
baseFormatter: void 0,
|
|
1185
|
-
dataConstraints: dataConstraint,
|
|
1186
|
-
gothamMapping,
|
|
1187
|
-
indexedForSearch: true,
|
|
1188
|
-
typeClasses: typeClasses ?? [],
|
|
1189
|
-
valueType: valueType === void 0 ? void 0 : {
|
|
1190
|
-
apiName: valueType.apiName,
|
|
1191
|
-
version: valueType.version,
|
|
1192
|
-
packageNamespace: valueType.packageNamespace,
|
|
1193
|
-
displayMetadata: valueType.displayMetadata
|
|
1194
|
-
}
|
|
1195
|
-
};
|
|
1386
|
+
return convertOntologyDefinition(ontologyDefinition);
|
|
1196
1387
|
}
|
|
1197
1388
|
function convertObjectStatus(status) {
|
|
1198
1389
|
if (status === void 0) {
|
|
@@ -1272,110 +1463,21 @@ function convertAction(action) {
|
|
|
1272
1463
|
submitButtonDisplayMetadata: action.submissionMetadata.submitButtonDisplayMetadata
|
|
1273
1464
|
},
|
|
1274
1465
|
...action.submissionMetadata?.undoButtonConfiguration && {
|
|
1275
|
-
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1276
|
-
}
|
|
1277
|
-
},
|
|
1278
|
-
parameterOrdering,
|
|
1279
|
-
formContentOrdering: getFormContentOrdering(action, parameterOrdering),
|
|
1280
|
-
parameters: actionParameters,
|
|
1281
|
-
sections: actionSections,
|
|
1282
|
-
status: typeof action.status === "string" ? {
|
|
1283
|
-
type: action.status,
|
|
1284
|
-
[action.status]: {}
|
|
1285
|
-
} : action.status,
|
|
1286
|
-
entities: action.entities
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
function convertActionValidation(action) {
|
|
1292
|
-
return {
|
|
1293
|
-
actionTypeLevelValidation: {
|
|
1294
|
-
rules: Object.fromEntries((action.validation ?? [{
|
|
1295
|
-
condition: {
|
|
1296
|
-
type: "true",
|
|
1297
|
-
true: {}
|
|
1298
|
-
},
|
|
1299
|
-
displayMetadata: {
|
|
1300
|
-
failureMessage: "",
|
|
1301
|
-
typeClasses: []
|
|
1302
|
-
}
|
|
1303
|
-
}]).map((rule, idx) => [idx, rule]))
|
|
1304
|
-
},
|
|
1305
|
-
parameterValidations: Object.fromEntries((action.parameters ?? []).map((p) => {
|
|
1306
|
-
return [p.id, {
|
|
1307
|
-
defaultValidation: {
|
|
1308
|
-
display: {
|
|
1309
|
-
renderHint: renderHintFromBaseType(p),
|
|
1310
|
-
visibility: convertActionVisibility(p.validation.defaultVisibility),
|
|
1311
|
-
...p.defaultValue && {
|
|
1312
|
-
prefill: p.defaultValue
|
|
1313
|
-
}
|
|
1314
|
-
},
|
|
1315
|
-
validation: {
|
|
1316
|
-
allowedValues: extractAllowedValues(p.validation.allowedValues),
|
|
1317
|
-
required: convertParameterRequirementConstraint(p.validation.required)
|
|
1318
|
-
}
|
|
1319
|
-
},
|
|
1320
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
1321
|
-
}];
|
|
1322
|
-
})),
|
|
1323
|
-
sectionValidations: {
|
|
1324
|
-
...Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [section.id, {
|
|
1325
|
-
defaultDisplayMetadata: section.defaultVisibility === "hidden" ? {
|
|
1326
|
-
visibility: {
|
|
1327
|
-
type: "hidden",
|
|
1328
|
-
hidden: {}
|
|
1329
|
-
}
|
|
1330
|
-
} : {
|
|
1331
|
-
visibility: {
|
|
1332
|
-
type: "visible",
|
|
1333
|
-
visible: {}
|
|
1466
|
+
undoButtonConfiguration: action.submissionMetadata.undoButtonConfiguration
|
|
1334
1467
|
}
|
|
1335
1468
|
},
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
type: p.type,
|
|
1346
|
-
[p.type]: {}
|
|
1347
|
-
} : p.type,
|
|
1348
|
-
displayMetadata: {
|
|
1349
|
-
displayName: p.displayName,
|
|
1350
|
-
description: p.description ?? "",
|
|
1351
|
-
typeClasses: []
|
|
1352
|
-
}
|
|
1353
|
-
}]));
|
|
1354
|
-
}
|
|
1355
|
-
function convertActionSections(action) {
|
|
1356
|
-
return Object.fromEntries(Object.entries(action.sections ?? {}).map(([sectionId, section]) => [sectionId, {
|
|
1357
|
-
id: sectionId,
|
|
1358
|
-
content: section.parameters.map((p) => ({
|
|
1359
|
-
type: "parameterId",
|
|
1360
|
-
parameterId: p
|
|
1361
|
-
})),
|
|
1362
|
-
displayMetadata: {
|
|
1363
|
-
collapsedByDefault: section.collapsedByDefault ?? false,
|
|
1364
|
-
columnCount: section.columnCount ?? 1,
|
|
1365
|
-
description: section.description ?? "",
|
|
1366
|
-
displayName: section.displayName ?? convertToDisplayName(sectionId),
|
|
1367
|
-
showTitleBar: section.showTitleBar ?? true,
|
|
1368
|
-
...section.style && {
|
|
1369
|
-
style: section.style === "box" ? {
|
|
1370
|
-
type: "box",
|
|
1371
|
-
box: {}
|
|
1372
|
-
} : {
|
|
1373
|
-
type: "minimal",
|
|
1374
|
-
minimal: {}
|
|
1375
|
-
}
|
|
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
|
|
1376
1478
|
}
|
|
1377
1479
|
}
|
|
1378
|
-
}
|
|
1480
|
+
};
|
|
1379
1481
|
}
|
|
1380
1482
|
function extractAllowedValues(allowedValues) {
|
|
1381
1483
|
switch (allowedValues.type) {
|
|
@@ -1574,31 +1676,6 @@ function renderHintFromBaseType(parameter) {
|
|
|
1574
1676
|
throw new Error(`Unknown type ${type}`);
|
|
1575
1677
|
}
|
|
1576
1678
|
}
|
|
1577
|
-
function convertParameterRequirementConstraint(required) {
|
|
1578
|
-
if (typeof required === "boolean") {
|
|
1579
|
-
return required ? {
|
|
1580
|
-
type: "required",
|
|
1581
|
-
required: {}
|
|
1582
|
-
} : {
|
|
1583
|
-
type: "notRequired",
|
|
1584
|
-
notRequired: {}
|
|
1585
|
-
};
|
|
1586
|
-
}
|
|
1587
|
-
const {
|
|
1588
|
-
min,
|
|
1589
|
-
max
|
|
1590
|
-
} = required.listLength;
|
|
1591
|
-
return {
|
|
1592
|
-
type: "listLengthValidation",
|
|
1593
|
-
listLengthValidation: {
|
|
1594
|
-
minLength: min,
|
|
1595
|
-
maxLength: max
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
}
|
|
1599
|
-
function sanitize(namespace2, s) {
|
|
1600
|
-
return s.includes(".") ? s : namespace2 + s;
|
|
1601
|
-
}
|
|
1602
1679
|
function withoutNamespace(apiName) {
|
|
1603
1680
|
const lastDot = apiName.lastIndexOf(".");
|
|
1604
1681
|
if (lastDot === -1) {
|
|
@@ -1637,17 +1714,12 @@ addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
|
1637
1714
|
function addNamespaceIfNone(apiName) {
|
|
1638
1715
|
return apiName.includes(".") ? apiName : namespace + apiName;
|
|
1639
1716
|
}
|
|
1640
|
-
function convertCardinality(cardinality) {
|
|
1641
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
1642
|
-
return "ONE_TO_MANY";
|
|
1643
|
-
}
|
|
1644
|
-
return "ONE_TO_ONE";
|
|
1645
|
-
}
|
|
1646
1717
|
|
|
1647
1718
|
// src/cli/main.ts
|
|
1648
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}$/;
|
|
1649
1721
|
async function main(args = process.argv) {
|
|
1650
|
-
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({
|
|
1651
1723
|
input: {
|
|
1652
1724
|
alias: "i",
|
|
1653
1725
|
describe: "Input file",
|
|
@@ -1690,24 +1762,32 @@ async function main(args = process.argv) {
|
|
|
1690
1762
|
describe: "File to write dependencies to",
|
|
1691
1763
|
type: "string",
|
|
1692
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
|
|
1693
1770
|
}
|
|
1694
1771
|
}).parseAsync();
|
|
1695
1772
|
let apiNamespace = "";
|
|
1696
1773
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1697
1774
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
1698
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
1699
|
-
!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;
|
|
1700
1777
|
}
|
|
1701
1778
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1702
|
-
|
|
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);
|
|
1703
1783
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1704
1784
|
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1705
1785
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1706
1786
|
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1707
1787
|
}
|
|
1708
1788
|
}
|
|
1709
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1710
|
-
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);
|
|
1711
1791
|
return q;
|
|
1712
1792
|
}
|
|
1713
1793
|
var MAX_SEARCH_DEPTH = 5;
|
|
@@ -1730,36 +1810,68 @@ function addDependency(namespaceNoDot, fileInPackage) {
|
|
|
1730
1810
|
const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1731
1811
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1732
1812
|
}
|
|
1733
|
-
function
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
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`);
|
|
1737
1849
|
}
|
|
1738
1850
|
return defineAction({
|
|
1739
|
-
apiName: `create-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1740
|
-
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}`,
|
|
1741
1853
|
parameters: [{
|
|
1742
1854
|
id: "objectTypeParameter",
|
|
1743
1855
|
displayName: "Object type to create",
|
|
1744
1856
|
type: {
|
|
1745
1857
|
type: "objectTypeReference",
|
|
1746
1858
|
objectTypeReference: {
|
|
1747
|
-
interfaceTypeRids: [interfaceType.apiName]
|
|
1859
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1748
1860
|
}
|
|
1749
1861
|
},
|
|
1750
1862
|
validation: {
|
|
1751
1863
|
required: true,
|
|
1752
|
-
allowedValues: objectType === void 0 ? {
|
|
1864
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1753
1865
|
type: "objectTypeReference",
|
|
1754
|
-
interfaceTypes: [interfaceType.apiName]
|
|
1866
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
1755
1867
|
} : {
|
|
1756
1868
|
type: "oneOf",
|
|
1757
1869
|
oneOf: [{
|
|
1758
|
-
label: objectType.displayName,
|
|
1870
|
+
label: def.objectType.displayName,
|
|
1759
1871
|
value: {
|
|
1760
1872
|
type: "objectType",
|
|
1761
1873
|
objectType: {
|
|
1762
|
-
objectTypeId: objectType.apiName
|
|
1874
|
+
objectTypeId: def.objectType.apiName
|
|
1763
1875
|
}
|
|
1764
1876
|
}
|
|
1765
1877
|
}]
|
|
@@ -1777,9 +1889,9 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1777
1889
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1778
1890
|
}
|
|
1779
1891
|
}))],
|
|
1780
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
1892
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1781
1893
|
entities: {
|
|
1782
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
1894
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1783
1895
|
affectedObjectTypes: [],
|
|
1784
1896
|
affectedLinkTypes: [],
|
|
1785
1897
|
typeGroups: []
|
|
@@ -1787,7 +1899,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1787
1899
|
rules: [{
|
|
1788
1900
|
type: "addInterfaceRule",
|
|
1789
1901
|
addInterfaceRule: {
|
|
1790
|
-
interfaceApiName: interfaceType.apiName,
|
|
1902
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
1791
1903
|
objectTypeParameter: "objectTypeParameter",
|
|
1792
1904
|
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1793
1905
|
type: "parameterId",
|
|
@@ -1795,8 +1907,8 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1795
1907
|
}]))
|
|
1796
1908
|
}
|
|
1797
1909
|
}],
|
|
1798
|
-
...validation ? {
|
|
1799
|
-
validation: convertValidationRule(validation)
|
|
1910
|
+
...def.validation ? {
|
|
1911
|
+
validation: convertValidationRule(def.validation)
|
|
1800
1912
|
} : {}
|
|
1801
1913
|
});
|
|
1802
1914
|
}
|
|
@@ -1838,7 +1950,7 @@ function defineCreateObjectAction(def) {
|
|
|
1838
1950
|
}],
|
|
1839
1951
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1840
1952
|
...def.actionLevelValidation ? {
|
|
1841
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
1953
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
1842
1954
|
} : {},
|
|
1843
1955
|
...def.defaultFormat && {
|
|
1844
1956
|
defaultFormat: def.defaultFormat
|
|
@@ -1857,35 +1969,35 @@ function defineCreateObjectAction(def) {
|
|
|
1857
1969
|
}
|
|
1858
1970
|
});
|
|
1859
1971
|
}
|
|
1860
|
-
function defineModifyInterfaceObjectAction(
|
|
1861
|
-
const allProperties = Object.entries(
|
|
1862
|
-
if (allProperties.length !== Object.entries(
|
|
1863
|
-
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`);
|
|
1864
1976
|
}
|
|
1865
1977
|
return defineAction({
|
|
1866
|
-
apiName: `modify-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1867
|
-
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}`,
|
|
1868
1980
|
parameters: [{
|
|
1869
1981
|
id: "interfaceObjectToModifyParameter",
|
|
1870
1982
|
displayName: "Object type to modify",
|
|
1871
1983
|
type: {
|
|
1872
1984
|
type: "interfaceReference",
|
|
1873
1985
|
interfaceReference: {
|
|
1874
|
-
interfaceTypeRid: interfaceType.apiName
|
|
1986
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
1875
1987
|
}
|
|
1876
1988
|
},
|
|
1877
1989
|
validation: {
|
|
1878
1990
|
required: true,
|
|
1879
|
-
allowedValues: objectType === void 0 ? {
|
|
1991
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1880
1992
|
type: "interfaceObjectQuery"
|
|
1881
1993
|
} : {
|
|
1882
1994
|
type: "oneOf",
|
|
1883
1995
|
oneOf: [{
|
|
1884
|
-
label: objectType.displayName,
|
|
1996
|
+
label: def.objectType.displayName,
|
|
1885
1997
|
value: {
|
|
1886
1998
|
type: "objectType",
|
|
1887
1999
|
objectType: {
|
|
1888
|
-
objectTypeId: objectType.apiName
|
|
2000
|
+
objectTypeId: def.objectType.apiName
|
|
1889
2001
|
}
|
|
1890
2002
|
}
|
|
1891
2003
|
}]
|
|
@@ -1903,9 +2015,9 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1903
2015
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1904
2016
|
}
|
|
1905
2017
|
}))],
|
|
1906
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
2018
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1907
2019
|
entities: {
|
|
1908
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
2020
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1909
2021
|
affectedObjectTypes: [],
|
|
1910
2022
|
affectedLinkTypes: [],
|
|
1911
2023
|
typeGroups: []
|
|
@@ -1920,8 +2032,8 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1920
2032
|
}]))
|
|
1921
2033
|
}
|
|
1922
2034
|
}],
|
|
1923
|
-
...validation ? {
|
|
1924
|
-
validation: convertValidationRule(validation)
|
|
2035
|
+
...def.validation ? {
|
|
2036
|
+
validation: convertValidationRule(def.validation)
|
|
1925
2037
|
} : {}
|
|
1926
2038
|
});
|
|
1927
2039
|
}
|
|
@@ -1978,7 +2090,7 @@ function defineModifyObjectAction(def) {
|
|
|
1978
2090
|
},
|
|
1979
2091
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
1980
2092
|
...def.actionLevelValidation ? {
|
|
1981
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2093
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
1982
2094
|
} : {},
|
|
1983
2095
|
...def.defaultFormat && {
|
|
1984
2096
|
defaultFormat: def.defaultFormat
|
|
@@ -2031,7 +2143,7 @@ function defineDeleteObjectAction(def) {
|
|
|
2031
2143
|
typeGroups: []
|
|
2032
2144
|
},
|
|
2033
2145
|
...def.actionLevelValidation ? {
|
|
2034
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2146
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2035
2147
|
} : {}
|
|
2036
2148
|
});
|
|
2037
2149
|
}
|
|
@@ -2088,7 +2200,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2088
2200
|
},
|
|
2089
2201
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2090
2202
|
...def.actionLevelValidation ? {
|
|
2091
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2203
|
+
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2092
2204
|
} : {},
|
|
2093
2205
|
...def.defaultFormat && {
|
|
2094
2206
|
defaultFormat: def.defaultFormat
|
|
@@ -2113,21 +2225,38 @@ function defineAction(actionDef) {
|
|
|
2113
2225
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2114
2226
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2115
2227
|
}
|
|
2116
|
-
!/^[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;
|
|
2117
2229
|
const parameterIdsSet = new Set(parameterIds);
|
|
2118
|
-
!(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;
|
|
2119
2231
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2120
|
-
!(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;
|
|
2121
2233
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2122
2234
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2123
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2124
|
-
!(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;
|
|
2125
2237
|
actionDef.rules.forEach((rule) => {
|
|
2126
2238
|
if (rule.type === "modifyObjectRule") {
|
|
2127
|
-
!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;
|
|
2128
2240
|
}
|
|
2129
2241
|
if (rule.type === "deleteObjectRule") {
|
|
2130
|
-
!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
|
+
});
|
|
2131
2260
|
}
|
|
2132
2261
|
});
|
|
2133
2262
|
const fullAction = {
|
|
@@ -2202,7 +2331,7 @@ function createParameters(def, parameterSet) {
|
|
|
2202
2331
|
});
|
|
2203
2332
|
return [...targetParam, ...Array.from(parameterSet).map((id) => ({
|
|
2204
2333
|
id,
|
|
2205
|
-
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ??
|
|
2334
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2206
2335
|
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2207
2336
|
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2208
2337
|
...def.parameterConfiguration?.[id],
|
|
@@ -2231,14 +2360,14 @@ function referencedParameterIds(actionDef) {
|
|
|
2231
2360
|
actionDef.rules.forEach((rule) => {
|
|
2232
2361
|
switch (rule.type) {
|
|
2233
2362
|
case "addInterfaceRule":
|
|
2234
|
-
rule.addInterfaceRule.interfaceApiName =
|
|
2363
|
+
rule.addInterfaceRule.interfaceApiName = sanitize(rule.addInterfaceRule.interfaceApiName);
|
|
2235
2364
|
parameterIds.add(rule.addInterfaceRule.objectTypeParameter);
|
|
2236
2365
|
Object.entries(rule.addInterfaceRule.sharedPropertyValues).forEach(([k, v]) => {
|
|
2237
2366
|
if (v.type === "parameterId") {
|
|
2238
2367
|
parameterIds.add(v.parameterId);
|
|
2239
2368
|
}
|
|
2240
2369
|
delete rule.addInterfaceRule.sharedPropertyValues[k];
|
|
2241
|
-
rule.addInterfaceRule.sharedPropertyValues[
|
|
2370
|
+
rule.addInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2242
2371
|
});
|
|
2243
2372
|
break;
|
|
2244
2373
|
case "modifyInterfaceRule":
|
|
@@ -2248,7 +2377,7 @@ function referencedParameterIds(actionDef) {
|
|
|
2248
2377
|
parameterIds.add(v.parameterId);
|
|
2249
2378
|
}
|
|
2250
2379
|
delete rule.modifyInterfaceRule.sharedPropertyValues[k];
|
|
2251
|
-
rule.modifyInterfaceRule.sharedPropertyValues[
|
|
2380
|
+
rule.modifyInterfaceRule.sharedPropertyValues[sanitize(k)] = v;
|
|
2252
2381
|
});
|
|
2253
2382
|
break;
|
|
2254
2383
|
case "addObjectRule":
|
|
@@ -2477,22 +2606,16 @@ function extractActionParameterType(pt) {
|
|
|
2477
2606
|
function maybeAddList(type, pt) {
|
|
2478
2607
|
return pt.array ?? false ? type + "List" : type;
|
|
2479
2608
|
}
|
|
2480
|
-
function isActionParameterTypePrimitive(type) {
|
|
2481
|
-
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);
|
|
2482
|
-
}
|
|
2483
|
-
function isStruct(type) {
|
|
2484
|
-
return typeof type === "object" && type.type === "struct";
|
|
2485
|
-
}
|
|
2486
2609
|
function kebab(s) {
|
|
2487
2610
|
return s.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/\./g, "-").toLowerCase();
|
|
2488
2611
|
}
|
|
2489
|
-
function
|
|
2612
|
+
function sanitize(s) {
|
|
2490
2613
|
return s.includes(".") ? s : namespace + s;
|
|
2491
2614
|
}
|
|
2492
|
-
function convertValidationRule(actionValidation) {
|
|
2615
|
+
function convertValidationRule(actionValidation, objectProperties) {
|
|
2493
2616
|
return actionValidation.map((rule) => {
|
|
2494
2617
|
return {
|
|
2495
|
-
condition: convertConditionDefinition(rule.condition),
|
|
2618
|
+
condition: convertConditionDefinition(rule.condition, objectProperties),
|
|
2496
2619
|
displayMetadata: rule.displayMetadata ?? {
|
|
2497
2620
|
failureMessage: "Did not satisfy validation",
|
|
2498
2621
|
typeClasses: []
|
|
@@ -2519,9 +2642,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
2519
2642
|
switch (condition.type) {
|
|
2520
2643
|
case "parameter":
|
|
2521
2644
|
const overrideParamId = condition.parameterId;
|
|
2522
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2523
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2524
|
-
!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;
|
|
2525
2648
|
break;
|
|
2526
2649
|
case "and":
|
|
2527
2650
|
if ("conditions" in condition) {
|
|
@@ -2549,11 +2672,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2549
2672
|
if (!defaultValue) return;
|
|
2550
2673
|
switch (defaultValue.type) {
|
|
2551
2674
|
case "objectParameterPropertyValue":
|
|
2552
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2553
|
-
!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;
|
|
2554
2677
|
break;
|
|
2555
2678
|
case "staticValue":
|
|
2556
|
-
!(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;
|
|
2557
2680
|
break;
|
|
2558
2681
|
case "staticObject":
|
|
2559
2682
|
case "interfaceParameterPropertyValue":
|
|
@@ -2568,10 +2691,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2568
2691
|
}
|
|
2569
2692
|
function validateActionParameters(def) {
|
|
2570
2693
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2571
|
-
!(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;
|
|
2572
2695
|
});
|
|
2573
2696
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2574
|
-
!(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;
|
|
2575
2698
|
});
|
|
2576
2699
|
}
|
|
2577
2700
|
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
@@ -2581,48 +2704,12 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2581
2704
|
const orderingSet = new Set(parameterOrdering);
|
|
2582
2705
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2583
2706
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2584
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
// src/api/importOntologyEntity.ts
|
|
2588
|
-
function importOntologyEntity(e) {
|
|
2589
|
-
if (e.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
2590
|
-
importedTypes[e.__type][e.apiName] = e;
|
|
2591
|
-
return;
|
|
2592
|
-
}
|
|
2593
|
-
if (importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] === void 0) {
|
|
2594
|
-
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName] = [];
|
|
2595
|
-
}
|
|
2596
|
-
importedTypes[OntologyEntityTypeEnum.VALUE_TYPE][e.apiName].push(e);
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
// src/api/defineImportSpt.ts
|
|
2600
|
-
function importSharedPropertyType(opts) {
|
|
2601
|
-
const {
|
|
2602
|
-
apiName,
|
|
2603
|
-
packageName,
|
|
2604
|
-
typeHint,
|
|
2605
|
-
array
|
|
2606
|
-
} = opts;
|
|
2607
|
-
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
2608
|
-
if (packageName !== void 0) {
|
|
2609
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Package name format invalid ends with period") : invariant5__default.default(false) : void 0;
|
|
2610
|
-
!(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;
|
|
2611
|
-
}
|
|
2612
|
-
const spt = {
|
|
2613
|
-
apiName: fullApiName,
|
|
2614
|
-
type: typeHint,
|
|
2615
|
-
nonNameSpacedApiName: apiName,
|
|
2616
|
-
array: array ?? false,
|
|
2617
|
-
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
2618
|
-
};
|
|
2619
|
-
importOntologyEntity(spt);
|
|
2620
|
-
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;
|
|
2621
2708
|
}
|
|
2622
2709
|
function defineSharedPropertyType(sptDef) {
|
|
2623
2710
|
const apiName = namespace + sptDef.apiName;
|
|
2624
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2625
|
-
!(!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;
|
|
2626
2713
|
const fullSpt = {
|
|
2627
2714
|
...sptDef,
|
|
2628
2715
|
apiName,
|
|
@@ -2636,27 +2723,61 @@ function defineSharedPropertyType(sptDef) {
|
|
|
2636
2723
|
return fullSpt;
|
|
2637
2724
|
}
|
|
2638
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
|
+
|
|
2639
2758
|
// src/api/defineInterface.ts
|
|
2640
2759
|
function defineInterface(interfaceDef) {
|
|
2641
2760
|
const apiName = namespace + interfaceDef.apiName;
|
|
2642
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2643
|
-
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]) => {
|
|
2644
2763
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2645
|
-
|
|
2764
|
+
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
2765
|
+
return [apiName3, {
|
|
2646
2766
|
required: type.required,
|
|
2647
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2767
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type.propertyDefinition)
|
|
2648
2768
|
}];
|
|
2649
2769
|
}
|
|
2650
|
-
|
|
2770
|
+
const apiName2 = combineApiNamespaceIfMissing(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
2771
|
+
return [apiName2, {
|
|
2651
2772
|
required: true,
|
|
2652
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2773
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
2653
2774
|
}];
|
|
2654
2775
|
}));
|
|
2655
2776
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
2656
2777
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2657
2778
|
type: "active"
|
|
2658
2779
|
});
|
|
2659
|
-
!(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;
|
|
2660
2781
|
const fullInterface = {
|
|
2661
2782
|
apiName,
|
|
2662
2783
|
displayMetadata: {
|
|
@@ -2680,37 +2801,9 @@ function defineInterface(interfaceDef) {
|
|
|
2680
2801
|
updateOntology(fullInterface);
|
|
2681
2802
|
return fullInterface;
|
|
2682
2803
|
}
|
|
2683
|
-
function isPropertyTypeType(v) {
|
|
2684
|
-
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";
|
|
2685
|
-
}
|
|
2686
|
-
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
2687
|
-
switch (status.type) {
|
|
2688
|
-
case "deprecated":
|
|
2689
|
-
return {
|
|
2690
|
-
type: "deprecated",
|
|
2691
|
-
deprecated: {
|
|
2692
|
-
message: status.message,
|
|
2693
|
-
deadline: status.deadline,
|
|
2694
|
-
replacedBy: void 0
|
|
2695
|
-
}
|
|
2696
|
-
};
|
|
2697
|
-
case "active":
|
|
2698
|
-
return {
|
|
2699
|
-
type: "active",
|
|
2700
|
-
active: {}
|
|
2701
|
-
};
|
|
2702
|
-
case "experimental":
|
|
2703
|
-
return {
|
|
2704
|
-
type: "experimental",
|
|
2705
|
-
experimental: {}
|
|
2706
|
-
};
|
|
2707
|
-
default:
|
|
2708
|
-
throw new Error(`Invalid status type: ${status.type}`);
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
2804
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2712
2805
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2713
|
-
!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;
|
|
2714
2807
|
const spt = defineSharedPropertyType({
|
|
2715
2808
|
apiName,
|
|
2716
2809
|
displayName: apiName,
|
|
@@ -2720,16 +2813,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2720
2813
|
return spt;
|
|
2721
2814
|
} else {
|
|
2722
2815
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2723
|
-
!(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({
|
|
2724
2817
|
key: apiName,
|
|
2725
2818
|
apiName: type.apiName
|
|
2726
|
-
})}`) :
|
|
2819
|
+
})}`) : invariant6__default.default(false) : void 0;
|
|
2727
2820
|
return type;
|
|
2728
2821
|
}
|
|
2729
2822
|
}
|
|
2730
2823
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2731
2824
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2732
|
-
!(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;
|
|
2733
2826
|
linkDef.from.links.push({
|
|
2734
2827
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2735
2828
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2749,7 +2842,7 @@ function getLinkMeta(meta) {
|
|
|
2749
2842
|
displayName,
|
|
2750
2843
|
description
|
|
2751
2844
|
} = meta;
|
|
2752
|
-
const apiNameWithNamespace =
|
|
2845
|
+
const apiNameWithNamespace = combineApiNamespaceIfMissing(namespace, apiName);
|
|
2753
2846
|
const apiNameWithoutNamespace = withoutNamespace(apiNameWithNamespace);
|
|
2754
2847
|
return {
|
|
2755
2848
|
apiName: apiNameWithNamespace,
|
|
@@ -2761,20 +2854,35 @@ var typeIdPattern = /([a-z][a-z0-9\\-]*)/;
|
|
|
2761
2854
|
function defineLink(linkDefinition) {
|
|
2762
2855
|
if ("one" in linkDefinition) {
|
|
2763
2856
|
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2764
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2765
|
-
!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;
|
|
2766
2859
|
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2767
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ?
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
one
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
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
|
+
}
|
|
2778
2886
|
const linkType = {
|
|
2779
2887
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2780
2888
|
...fullLinkDefinition,
|
|
@@ -2795,11 +2903,17 @@ function convertUserManyToManyLinkDefinition(manyToMany) {
|
|
|
2795
2903
|
metadata: convertLinkTypeMetadata(manyToMany.metadata)
|
|
2796
2904
|
};
|
|
2797
2905
|
}
|
|
2906
|
+
function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
2907
|
+
return {
|
|
2908
|
+
...intermediary,
|
|
2909
|
+
metadata: convertLinkTypeMetadata(intermediary.metadata)
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2798
2912
|
function convertLinkTypeMetadata(metadata) {
|
|
2799
2913
|
return {
|
|
2800
2914
|
apiName: metadata.apiName,
|
|
2801
2915
|
displayMetadata: {
|
|
2802
|
-
displayName: metadata.displayName ??
|
|
2916
|
+
displayName: metadata.displayName ?? uppercaseFirstLetter(metadata.apiName),
|
|
2803
2917
|
pluralDisplayName: metadata.pluralDisplayName ?? convertToPluralDisplayName(metadata.apiName),
|
|
2804
2918
|
visibility: metadata.visibility ?? "NORMAL",
|
|
2805
2919
|
groupDisplayName: metadata.groupDisplayName ?? ""
|
|
@@ -2859,7 +2973,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2859
2973
|
version
|
|
2860
2974
|
} = valueTypeDef;
|
|
2861
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-]+)*))?)$/;
|
|
2862
|
-
!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;
|
|
2863
2977
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2864
2978
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2865
2979
|
const output = {
|
|
@@ -2895,6 +3009,40 @@ function defineValueType(valueTypeDef) {
|
|
|
2895
3009
|
return vt;
|
|
2896
3010
|
}
|
|
2897
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
|
+
|
|
2898
3046
|
// src/api/wrapWithProxy.ts
|
|
2899
3047
|
function wrapWithProxy(entity) {
|
|
2900
3048
|
return new Proxy(entity, {
|
|
@@ -2910,9 +3058,9 @@ exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
|
2910
3058
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
2911
3059
|
exports.addDependency = addDependency;
|
|
2912
3060
|
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
2913
|
-
exports.convertToDisplayName =
|
|
3061
|
+
exports.convertToDisplayName = uppercaseFirstLetter;
|
|
2914
3062
|
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
2915
|
-
exports.convertType =
|
|
3063
|
+
exports.convertType = propertyTypeTypeToOntologyIrType;
|
|
2916
3064
|
exports.default = main;
|
|
2917
3065
|
exports.defineAction = defineAction;
|
|
2918
3066
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|