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