@twin.org/engine-types 0.0.3-next.3 → 0.0.3-next.31
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/README.md +1 -1
- package/dist/es/components/attestation.js +20 -22
- package/dist/es/components/attestation.js.map +1 -1
- package/dist/es/components/auditableItemGraph.js +26 -22
- package/dist/es/components/auditableItemGraph.js.map +1 -1
- package/dist/es/components/auditableItemStream.js +26 -22
- package/dist/es/components/auditableItemStream.js.map +1 -1
- package/dist/es/components/backgroundTask.js +18 -18
- package/dist/es/components/backgroundTask.js.map +1 -1
- package/dist/es/components/blobStorage.js +69 -80
- package/dist/es/components/blobStorage.js.map +1 -1
- package/dist/es/components/contextIdHandler.js +31 -0
- package/dist/es/components/contextIdHandler.js.map +1 -0
- package/dist/es/components/dataProcessing.js +33 -32
- package/dist/es/components/dataProcessing.js.map +1 -1
- package/dist/es/components/dataspaceControlPlane.js +54 -0
- package/dist/es/components/dataspaceControlPlane.js.map +1 -0
- package/dist/es/components/dataspaceDataPlane.js +58 -0
- package/dist/es/components/dataspaceDataPlane.js.map +1 -0
- package/dist/es/components/documentManagement.js +12 -12
- package/dist/es/components/documentManagement.js.map +1 -1
- package/dist/es/components/entityStorage.js +48 -47
- package/dist/es/components/entityStorage.js.map +1 -1
- package/dist/es/components/eventBus.js +19 -27
- package/dist/es/components/eventBus.js.map +1 -1
- package/dist/es/components/faucet.js +18 -18
- package/dist/es/components/faucet.js.map +1 -1
- package/dist/es/components/federatedCatalogue.js +14 -18
- package/dist/es/components/federatedCatalogue.js.map +1 -1
- package/dist/es/components/federatedCatalogueFilter.js +34 -0
- package/dist/es/components/federatedCatalogueFilter.js.map +1 -0
- package/dist/es/components/identity.js +28 -31
- package/dist/es/components/identity.js.map +1 -1
- package/dist/es/components/identityProfile.js +26 -24
- package/dist/es/components/identityProfile.js.map +1 -1
- package/dist/es/components/identityResolver.js +36 -40
- package/dist/es/components/identityResolver.js.map +1 -1
- package/dist/es/components/immutableProof.js +23 -20
- package/dist/es/components/immutableProof.js.map +1 -1
- package/dist/es/components/logging.js +28 -28
- package/dist/es/components/logging.js.map +1 -1
- package/dist/es/components/messaging.js +77 -89
- package/dist/es/components/messaging.js.map +1 -1
- package/dist/es/components/nft.js +33 -33
- package/dist/es/components/nft.js.map +1 -1
- package/dist/es/components/notarization.js +78 -0
- package/dist/es/components/notarization.js.map +1 -0
- package/dist/es/components/rightsManagementPap.js +17 -17
- package/dist/es/components/rightsManagementPap.js.map +1 -1
- package/dist/es/components/rightsManagementPdp.js +11 -25
- package/dist/es/components/rightsManagementPdp.js.map +1 -1
- package/dist/es/components/rightsManagementPep.js +12 -24
- package/dist/es/components/rightsManagementPep.js.map +1 -1
- package/dist/es/components/rightsManagementPip.js +9 -25
- package/dist/es/components/rightsManagementPip.js.map +1 -1
- package/dist/es/components/rightsManagementPmp.js +10 -10
- package/dist/es/components/rightsManagementPmp.js.map +1 -1
- package/dist/es/components/rightsManagementPnap.js +21 -18
- package/dist/es/components/rightsManagementPnap.js.map +1 -1
- package/dist/es/components/rightsManagementPnp.js +14 -36
- package/dist/es/components/rightsManagementPnp.js.map +1 -1
- package/dist/es/components/rightsManagementPolicyArbiter.js +32 -0
- package/dist/es/components/rightsManagementPolicyArbiter.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyEnforcementProcessor.js +33 -0
- package/dist/es/components/rightsManagementPolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyExecutionAction.js +25 -0
- package/dist/es/components/rightsManagementPolicyExecutionAction.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyInformationSource.js +34 -0
- package/dist/es/components/rightsManagementPolicyInformationSource.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyNegotiator.js +27 -0
- package/dist/es/components/rightsManagementPolicyNegotiator.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyObligationEnforcer.js +27 -0
- package/dist/es/components/rightsManagementPolicyObligationEnforcer.js.map +1 -0
- package/dist/es/components/rightsManagementPolicyRequester.js +25 -0
- package/dist/es/components/rightsManagementPolicyRequester.js.map +1 -0
- package/dist/es/components/rightsManagementPxp.js +9 -25
- package/dist/es/components/rightsManagementPxp.js.map +1 -1
- package/dist/es/components/synchronisedStorage.js +25 -23
- package/dist/es/components/synchronisedStorage.js.map +1 -1
- package/dist/es/components/taskScheduler.js +17 -11
- package/dist/es/components/taskScheduler.js.map +1 -1
- package/dist/es/components/telemetry.js +29 -32
- package/dist/es/components/telemetry.js.map +1 -1
- package/dist/es/components/tenant.js +12 -11
- package/dist/es/components/tenant.js.map +1 -1
- package/dist/es/components/trust.js +27 -0
- package/dist/es/components/trust.js.map +1 -0
- package/dist/es/components/trustGenerator.js +28 -0
- package/dist/es/components/trustGenerator.js.map +1 -0
- package/dist/es/components/trustVerifier.js +28 -0
- package/dist/es/components/trustVerifier.js.map +1 -0
- package/dist/es/components/vault.js +15 -12
- package/dist/es/components/vault.js.map +1 -1
- package/dist/es/components/verifiableStorage.js +32 -34
- package/dist/es/components/verifiableStorage.js.map +1 -1
- package/dist/es/components/wallet.js +23 -24
- package/dist/es/components/wallet.js.map +1 -1
- package/dist/es/index.js +49 -14
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEngineConfig.js.map +1 -1
- package/dist/es/models/config/backgroundTaskComponentConfig.js +2 -0
- package/dist/es/models/config/backgroundTaskComponentConfig.js.map +1 -0
- package/dist/es/models/config/blobStorageConnectorConfig.js.map +1 -1
- package/dist/es/models/config/contextIdHandlerComponentConfig.js +2 -0
- package/dist/es/models/config/contextIdHandlerComponentConfig.js.map +1 -0
- package/dist/es/models/config/dataspaceControlPlaneComponentConfig.js +2 -0
- package/dist/es/models/config/dataspaceControlPlaneComponentConfig.js.map +1 -0
- package/dist/es/models/config/dataspaceDataPlaneComponentConfig.js +2 -0
- package/dist/es/models/config/dataspaceDataPlaneComponentConfig.js.map +1 -0
- package/dist/es/models/config/federatedCatalogueFilterComponentConfig.js +2 -0
- package/dist/es/models/config/federatedCatalogueFilterComponentConfig.js.map +1 -0
- package/dist/es/models/config/notarizationComponentConfig.js +2 -0
- package/dist/es/models/config/notarizationComponentConfig.js.map +1 -0
- package/dist/es/models/config/notarizationConnectorConfig.js +2 -0
- package/dist/es/models/config/notarizationConnectorConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPdpComponentConfig.js.map +1 -1
- package/dist/es/models/config/rightsManagementPepComponentConfig.js.map +1 -1
- package/dist/es/models/config/rightsManagementPipComponentConfig.js.map +1 -1
- package/dist/es/models/config/rightsManagementPnpComponentConfig.js.map +1 -1
- package/dist/es/models/config/rightsManagementPolicyArbiterComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyArbiterComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyEnforcementProcessorComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyEnforcementProcessorComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyExecutionActionComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyExecutionActionComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyInformationSourceComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyInformationSourceComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyNegotiatorComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyNegotiatorComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyObligationEnforcerComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyObligationEnforcerComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPolicyRequesterComponentConfig.js +2 -0
- package/dist/es/models/config/rightsManagementPolicyRequesterComponentConfig.js.map +1 -0
- package/dist/es/models/config/rightsManagementPxpComponentConfig.js.map +1 -1
- package/dist/es/models/config/trustComponentConfig.js +2 -0
- package/dist/es/models/config/trustComponentConfig.js.map +1 -0
- package/dist/es/models/config/trustGeneratorComponentConfig.js +2 -0
- package/dist/es/models/config/trustGeneratorComponentConfig.js.map +1 -0
- package/dist/es/models/config/trustVerifierComponentConfig.js +2 -0
- package/dist/es/models/config/trustVerifierComponentConfig.js.map +1 -0
- package/dist/es/models/types/{rightsManagementDarpComponentType.js → backgroundTaskComponentType.js} +3 -3
- package/dist/es/models/types/backgroundTaskComponentType.js.map +1 -0
- package/dist/es/models/types/contextIdHandlerComponentType.js +17 -0
- package/dist/es/models/types/contextIdHandlerComponentType.js.map +1 -0
- package/dist/es/models/types/dataspaceControlPlaneComponentType.js +17 -0
- package/dist/es/models/types/dataspaceControlPlaneComponentType.js.map +1 -0
- package/dist/es/models/types/{dataSpaceConnectorComponentType.js → dataspaceDataPlaneComponentType.js} +4 -4
- package/dist/es/models/types/dataspaceDataPlaneComponentType.js.map +1 -0
- package/dist/es/models/types/federatedCatalogueFilterComponentType.js +13 -0
- package/dist/es/models/types/federatedCatalogueFilterComponentType.js.map +1 -0
- package/dist/es/models/types/{rightsManagementDapComponentType.js → notarizationComponentType.js} +4 -4
- package/dist/es/models/types/notarizationComponentType.js.map +1 -0
- package/dist/es/models/types/notarizationConnectorType.js +17 -0
- package/dist/es/models/types/notarizationConnectorType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyArbiterComponentType.js +17 -0
- package/dist/es/models/types/rightsManagementPolicyArbiterComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyEnforcementProcessorComponentType.js +17 -0
- package/dist/es/models/types/rightsManagementPolicyEnforcementProcessorComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyExecutionActionComponentType.js +13 -0
- package/dist/es/models/types/rightsManagementPolicyExecutionActionComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyInformationSourceComponentType.js +17 -0
- package/dist/es/models/types/rightsManagementPolicyInformationSourceComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyNegotiatorComponentType.js +13 -0
- package/dist/es/models/types/rightsManagementPolicyNegotiatorComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyObligationEnforcerComponentType.js +13 -0
- package/dist/es/models/types/rightsManagementPolicyObligationEnforcerComponentType.js.map +1 -0
- package/dist/es/models/types/rightsManagementPolicyRequesterComponentType.js +13 -0
- package/dist/es/models/types/rightsManagementPolicyRequesterComponentType.js.map +1 -0
- package/dist/es/models/types/trustComponentType.js +13 -0
- package/dist/es/models/types/trustComponentType.js.map +1 -0
- package/dist/es/models/types/trustGeneratorComponentType.js +13 -0
- package/dist/es/models/types/trustGeneratorComponentType.js.map +1 -0
- package/dist/es/models/types/trustVerifierComponentType.js +13 -0
- package/dist/es/models/types/trustVerifierComponentType.js.map +1 -0
- package/dist/es/utils/engineTypeHelper.js +19 -1
- package/dist/es/utils/engineTypeHelper.js.map +1 -1
- package/dist/types/components/attestation.d.ts +5 -13
- package/dist/types/components/auditableItemGraph.d.ts +3 -7
- package/dist/types/components/auditableItemStream.d.ts +3 -7
- package/dist/types/components/backgroundTask.d.ts +5 -10
- package/dist/types/components/blobStorage.d.ts +4 -12
- package/dist/types/components/contextIdHandler.d.ts +12 -0
- package/dist/types/components/dataProcessing.d.ts +5 -17
- package/dist/types/components/dataspaceControlPlane.d.ts +12 -0
- package/dist/types/components/dataspaceDataPlane.d.ts +12 -0
- package/dist/types/components/documentManagement.d.ts +3 -7
- package/dist/types/components/entityStorage.d.ts +4 -9
- package/dist/types/components/eventBus.d.ts +4 -12
- package/dist/types/components/faucet.d.ts +2 -7
- package/dist/types/components/federatedCatalogue.d.ts +3 -7
- package/dist/types/components/federatedCatalogueFilter.d.ts +12 -0
- package/dist/types/components/identity.d.ts +4 -12
- package/dist/types/components/identityProfile.d.ts +4 -12
- package/dist/types/components/identityResolver.d.ts +4 -12
- package/dist/types/components/immutableProof.d.ts +3 -7
- package/dist/types/components/logging.d.ts +4 -12
- package/dist/types/components/messaging.d.ts +7 -27
- package/dist/types/components/nft.d.ts +4 -12
- package/dist/types/components/notarization.d.ts +22 -0
- package/dist/types/components/rightsManagementPap.d.ts +3 -7
- package/dist/types/components/rightsManagementPdp.d.ts +3 -7
- package/dist/types/components/rightsManagementPep.d.ts +3 -7
- package/dist/types/components/rightsManagementPip.d.ts +3 -7
- package/dist/types/components/rightsManagementPmp.d.ts +3 -7
- package/dist/types/components/rightsManagementPnap.d.ts +3 -7
- package/dist/types/components/rightsManagementPnp.d.ts +3 -7
- package/dist/types/components/rightsManagementPolicyArbiter.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyEnforcementProcessor.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyExecutionAction.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyInformationSource.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyNegotiator.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyObligationEnforcer.d.ts +12 -0
- package/dist/types/components/rightsManagementPolicyRequester.d.ts +12 -0
- package/dist/types/components/rightsManagementPxp.d.ts +3 -7
- package/dist/types/components/synchronisedStorage.d.ts +3 -7
- package/dist/types/components/taskScheduler.d.ts +3 -7
- package/dist/types/components/telemetry.d.ts +4 -12
- package/dist/types/components/tenant.d.ts +3 -7
- package/dist/types/components/trust.d.ts +12 -0
- package/dist/types/components/trustGenerator.d.ts +12 -0
- package/dist/types/components/trustVerifier.d.ts +12 -0
- package/dist/types/components/vault.d.ts +2 -7
- package/dist/types/components/verifiableStorage.d.ts +4 -12
- package/dist/types/components/wallet.d.ts +2 -7
- package/dist/types/index.d.ts +49 -14
- package/dist/types/models/IEngineConfig.d.ts +75 -15
- package/dist/types/models/config/backgroundTaskComponentConfig.d.ts +9 -0
- package/dist/types/models/config/blobStorageConnectorConfig.d.ts +4 -1
- package/dist/types/models/config/contextIdHandlerComponentConfig.d.ts +11 -0
- package/dist/types/models/config/dataspaceControlPlaneComponentConfig.d.ts +13 -0
- package/dist/types/models/config/dataspaceDataPlaneComponentConfig.d.ts +17 -0
- package/dist/types/models/config/federatedCatalogueFilterComponentConfig.d.ts +9 -0
- package/dist/types/models/config/notarizationComponentConfig.d.ts +13 -0
- package/dist/types/models/config/notarizationConnectorConfig.d.ts +13 -0
- package/dist/types/models/config/rightsManagementPdpComponentConfig.d.ts +1 -4
- package/dist/types/models/config/rightsManagementPepComponentConfig.d.ts +1 -4
- package/dist/types/models/config/rightsManagementPipComponentConfig.d.ts +1 -4
- package/dist/types/models/config/rightsManagementPnpComponentConfig.d.ts +1 -5
- package/dist/types/models/config/rightsManagementPolicyArbiterComponentConfig.d.ts +12 -0
- package/dist/types/models/config/rightsManagementPolicyEnforcementProcessorComponentConfig.d.ts +12 -0
- package/dist/types/models/config/rightsManagementPolicyExecutionActionComponentConfig.d.ts +9 -0
- package/dist/types/models/config/rightsManagementPolicyInformationSourceComponentConfig.d.ts +12 -0
- package/dist/types/models/config/rightsManagementPolicyNegotiatorComponentConfig.d.ts +9 -0
- package/dist/types/models/config/rightsManagementPolicyObligationEnforcerComponentConfig.d.ts +9 -0
- package/dist/types/models/config/rightsManagementPolicyRequesterComponentConfig.d.ts +9 -0
- package/dist/types/models/config/rightsManagementPxpComponentConfig.d.ts +1 -4
- package/dist/types/models/config/trustComponentConfig.d.ts +9 -0
- package/dist/types/models/config/trustGeneratorComponentConfig.d.ts +9 -0
- package/dist/types/models/config/trustVerifierComponentConfig.d.ts +9 -0
- package/dist/types/models/types/backgroundTaskComponentType.d.ts +13 -0
- package/dist/types/models/types/contextIdHandlerComponentType.d.ts +17 -0
- package/dist/types/models/types/dataspaceControlPlaneComponentType.d.ts +17 -0
- package/dist/types/models/types/dataspaceDataPlaneComponentType.d.ts +21 -0
- package/dist/types/models/types/federatedCatalogueFilterComponentType.d.ts +13 -0
- package/dist/types/models/types/notarizationComponentType.d.ts +17 -0
- package/dist/types/models/types/notarizationConnectorType.d.ts +17 -0
- package/dist/types/models/types/rightsManagementPolicyArbiterComponentType.d.ts +17 -0
- package/dist/types/models/types/rightsManagementPolicyEnforcementProcessorComponentType.d.ts +17 -0
- package/dist/types/models/types/rightsManagementPolicyExecutionActionComponentType.d.ts +13 -0
- package/dist/types/models/types/rightsManagementPolicyInformationSourceComponentType.d.ts +17 -0
- package/dist/types/models/types/rightsManagementPolicyNegotiatorComponentType.d.ts +13 -0
- package/dist/types/models/types/rightsManagementPolicyObligationEnforcerComponentType.d.ts +13 -0
- package/dist/types/models/types/rightsManagementPolicyRequesterComponentType.d.ts +13 -0
- package/dist/types/models/types/trustComponentType.d.ts +13 -0
- package/dist/types/models/types/trustGeneratorComponentType.d.ts +13 -0
- package/dist/types/models/types/trustVerifierComponentType.d.ts +13 -0
- package/dist/types/utils/engineTypeHelper.d.ts +11 -0
- package/docs/changelog.md +516 -1
- package/docs/examples.md +74 -1
- package/docs/reference/classes/EngineTypeHelper.md +57 -4
- package/docs/reference/functions/initialiseAttestationComponent.md +2 -2
- package/docs/reference/functions/initialiseAttestationConnector.md +3 -3
- package/docs/reference/functions/initialiseAuditableItemGraphComponent.md +2 -2
- package/docs/reference/functions/initialiseAuditableItemStreamComponent.md +2 -2
- package/docs/reference/functions/initialiseBackgroundTaskComponent.md +31 -0
- package/docs/reference/functions/initialiseBlobStorageComponent.md +2 -2
- package/docs/reference/functions/initialiseBlobStorageConnector.md +2 -2
- package/docs/reference/functions/initialiseContextIdHandlerComponent.md +31 -0
- package/docs/reference/functions/initialiseDataConverterConnector.md +2 -2
- package/docs/reference/functions/initialiseDataExtractorConnector.md +2 -2
- package/docs/reference/functions/initialiseDataProcessingComponent.md +2 -2
- package/docs/reference/functions/initialiseDataspaceControlPlaneComponent.md +31 -0
- package/docs/reference/functions/initialiseDataspaceDataPlaneComponent.md +31 -0
- package/docs/reference/functions/initialiseDocumentManagementComponent.md +2 -2
- package/docs/reference/functions/initialiseEntityStorageComponent.md +2 -2
- package/docs/reference/functions/initialiseEntityStorageConnector.md +4 -6
- package/docs/reference/functions/initialiseEventBusComponent.md +2 -2
- package/docs/reference/functions/initialiseEventBusConnector.md +2 -2
- package/docs/reference/functions/initialiseFaucetConnector.md +2 -2
- package/docs/reference/functions/initialiseFederatedCatalogueComponent.md +2 -2
- package/docs/reference/functions/initialiseFederatedCatalogueFilterComponent.md +31 -0
- package/docs/reference/functions/initialiseIdentityComponent.md +2 -2
- package/docs/reference/functions/initialiseIdentityConnector.md +2 -2
- package/docs/reference/functions/initialiseIdentityProfileComponent.md +2 -2
- package/docs/reference/functions/initialiseIdentityProfileConnector.md +2 -2
- package/docs/reference/functions/initialiseIdentityResolverComponent.md +2 -2
- package/docs/reference/functions/initialiseIdentityResolverConnector.md +2 -2
- package/docs/reference/functions/initialiseImmutableProofComponent.md +2 -2
- package/docs/reference/functions/initialiseLoggingComponent.md +2 -2
- package/docs/reference/functions/initialiseLoggingConnector.md +2 -2
- package/docs/reference/functions/initialiseMessagingAdminComponent.md +2 -2
- package/docs/reference/functions/initialiseMessagingComponent.md +2 -2
- package/docs/reference/functions/initialiseMessagingEmailConnector.md +2 -2
- package/docs/reference/functions/initialiseMessagingPushNotificationConnector.md +2 -2
- package/docs/reference/functions/initialiseMessagingSmsConnector.md +2 -2
- package/docs/reference/functions/initialiseNftComponent.md +2 -2
- package/docs/reference/functions/initialiseNftConnector.md +2 -2
- package/docs/reference/functions/initialiseNotarizationComponent.md +31 -0
- package/docs/reference/functions/initialiseNotarizationConnector.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPapComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPdpComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPepComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPipComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPmpComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPnapComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPnpComponent.md +2 -2
- package/docs/reference/functions/initialiseRightsManagementPolicyArbiterComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyEnforcementProcessorComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyExecutionActionComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyInformationSourceComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyNegotiatorComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyObligationEnforcerComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPolicyRequesterComponent.md +31 -0
- package/docs/reference/functions/initialiseRightsManagementPxpComponent.md +2 -2
- package/docs/reference/functions/initialiseSynchronisedStorageComponent.md +2 -2
- package/docs/reference/functions/initialiseTaskSchedulerComponent.md +2 -2
- package/docs/reference/functions/initialiseTelemetryComponent.md +2 -2
- package/docs/reference/functions/initialiseTelemetryConnector.md +2 -2
- package/docs/reference/functions/initialiseTenantAdminComponent.md +2 -2
- package/docs/reference/functions/initialiseTrustComponent.md +31 -0
- package/docs/reference/functions/initialiseTrustGeneratorComponent.md +31 -0
- package/docs/reference/functions/initialiseTrustVerifierComponent.md +31 -0
- package/docs/reference/functions/initialiseVaultConnector.md +2 -2
- package/docs/reference/functions/initialiseVerifiableStorageComponent.md +2 -2
- package/docs/reference/functions/initialiseVerifiableStorageConnector.md +2 -2
- package/docs/reference/functions/initialiseWalletConnector.md +2 -2
- package/docs/reference/index.md +68 -20
- package/docs/reference/interfaces/IEngineConfig.md +175 -67
- package/docs/reference/type-aliases/AttestationConnectorConfig.md +3 -3
- package/docs/reference/type-aliases/BackgroundTaskComponentConfig.md +17 -0
- package/docs/reference/type-aliases/BackgroundTaskComponentType.md +5 -0
- package/docs/reference/type-aliases/BlobStorageConnectorConfig.md +1 -1
- package/docs/reference/type-aliases/ContextIdHandlerComponentConfig.md +5 -0
- package/docs/reference/type-aliases/ContextIdHandlerComponentType.md +5 -0
- package/docs/reference/type-aliases/DataExtractorConnectorConfig.md +3 -3
- package/docs/reference/type-aliases/DataspaceControlPlaneComponentConfig.md +5 -0
- package/docs/reference/type-aliases/DataspaceControlPlaneComponentType.md +5 -0
- package/docs/reference/type-aliases/DataspaceDataPlaneComponentConfig.md +5 -0
- package/docs/reference/type-aliases/DataspaceDataPlaneComponentType.md +5 -0
- package/docs/reference/type-aliases/DltConfig.md +4 -4
- package/docs/reference/type-aliases/EventBusConnectorConfig.md +3 -3
- package/docs/reference/type-aliases/FederatedCatalogueFilterComponentConfig.md +17 -0
- package/docs/reference/type-aliases/FederatedCatalogueFilterComponentType.md +5 -0
- package/docs/reference/type-aliases/IdentityProfileConnectorConfig.md +3 -3
- package/docs/reference/type-aliases/MessagingAdminComponentConfig.md +3 -3
- package/docs/reference/type-aliases/MessagingComponentConfig.md +3 -3
- package/docs/reference/type-aliases/NotarizationComponentConfig.md +5 -0
- package/docs/reference/type-aliases/NotarizationComponentType.md +5 -0
- package/docs/reference/type-aliases/NotarizationConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/NotarizationConnectorType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPdpComponentConfig.md +3 -9
- package/docs/reference/type-aliases/RightsManagementPepComponentConfig.md +3 -9
- package/docs/reference/type-aliases/RightsManagementPipComponentConfig.md +3 -9
- package/docs/reference/type-aliases/RightsManagementPmpComponentConfig.md +3 -3
- package/docs/reference/type-aliases/RightsManagementPnpComponentConfig.md +1 -1
- package/docs/reference/type-aliases/RightsManagementPolicyArbiterComponentConfig.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyArbiterComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyEnforcementProcessorComponentConfig.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyEnforcementProcessorComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyExecutionActionComponentConfig.md +17 -0
- package/docs/reference/type-aliases/RightsManagementPolicyExecutionActionComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyInformationSourceComponentConfig.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyInformationSourceComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyNegotiatorComponentConfig.md +17 -0
- package/docs/reference/type-aliases/RightsManagementPolicyNegotiatorComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyObligationEnforcerComponentConfig.md +17 -0
- package/docs/reference/type-aliases/RightsManagementPolicyObligationEnforcerComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPolicyRequesterComponentConfig.md +17 -0
- package/docs/reference/type-aliases/RightsManagementPolicyRequesterComponentType.md +5 -0
- package/docs/reference/type-aliases/RightsManagementPxpComponentConfig.md +3 -9
- package/docs/reference/type-aliases/TaskSchedulerComponentConfig.md +3 -3
- package/docs/reference/type-aliases/TelemetryConnectorConfig.md +3 -3
- package/docs/reference/type-aliases/TenantAdminComponentConfig.md +3 -3
- package/docs/reference/type-aliases/TrustComponentConfig.md +17 -0
- package/docs/reference/type-aliases/TrustComponentType.md +5 -0
- package/docs/reference/type-aliases/TrustGeneratorComponentConfig.md +17 -0
- package/docs/reference/type-aliases/TrustGeneratorComponentType.md +5 -0
- package/docs/reference/type-aliases/TrustVerifierComponentConfig.md +17 -0
- package/docs/reference/type-aliases/TrustVerifierComponentType.md +5 -0
- package/docs/reference/variables/AttestationComponentType.md +2 -2
- package/docs/reference/variables/AttestationConnectorType.md +1 -1
- package/docs/reference/variables/AuditableItemGraphComponentType.md +2 -2
- package/docs/reference/variables/AuditableItemStreamComponentType.md +2 -2
- package/docs/reference/variables/BackgroundTaskComponentType.md +13 -0
- package/docs/reference/variables/BlobStorageComponentType.md +2 -2
- package/docs/reference/variables/BlobStorageConnectorType.md +6 -6
- package/docs/reference/variables/ContextIdHandlerComponentType.md +19 -0
- package/docs/reference/variables/DataConverterConnectorType.md +2 -2
- package/docs/reference/variables/DataExtractorConnectorType.md +1 -1
- package/docs/reference/variables/DataProcessingComponentType.md +2 -2
- package/docs/reference/variables/DataspaceControlPlaneComponentType.md +19 -0
- package/docs/reference/variables/{DataSpaceConnectorComponentType.md → DataspaceDataPlaneComponentType.md} +6 -6
- package/docs/reference/variables/DltConfigType.md +1 -1
- package/docs/reference/variables/DocumentManagementComponentType.md +2 -2
- package/docs/reference/variables/EntityStorageComponentType.md +2 -2
- package/docs/reference/variables/EntityStorageConnectorType.md +10 -10
- package/docs/reference/variables/EventBusComponentType.md +2 -2
- package/docs/reference/variables/EventBusConnectorType.md +1 -1
- package/docs/reference/variables/FaucetConnectorType.md +2 -2
- package/docs/reference/variables/FederatedCatalogueComponentType.md +2 -2
- package/docs/reference/variables/FederatedCatalogueFilterComponentType.md +13 -0
- package/docs/reference/variables/IdentityComponentType.md +2 -2
- package/docs/reference/variables/IdentityConnectorType.md +2 -2
- package/docs/reference/variables/IdentityProfileComponentType.md +2 -2
- package/docs/reference/variables/IdentityProfileConnectorType.md +1 -1
- package/docs/reference/variables/IdentityResolverComponentType.md +2 -2
- package/docs/reference/variables/IdentityResolverConnectorType.md +3 -3
- package/docs/reference/variables/ImmutableProofComponentType.md +2 -2
- package/docs/reference/variables/LoggingComponentType.md +2 -2
- package/docs/reference/variables/LoggingConnectorType.md +3 -3
- package/docs/reference/variables/MessagingAdminComponentType.md +1 -1
- package/docs/reference/variables/MessagingComponentType.md +1 -1
- package/docs/reference/variables/MessagingEmailConnectorType.md +2 -2
- package/docs/reference/variables/MessagingPushNotificationConnectorType.md +2 -2
- package/docs/reference/variables/MessagingSmsConnectorType.md +2 -2
- package/docs/reference/variables/NftComponentType.md +2 -2
- package/docs/reference/variables/NftConnectorType.md +2 -2
- package/docs/reference/variables/NotarizationComponentType.md +19 -0
- package/docs/reference/variables/NotarizationConnectorType.md +19 -0
- package/docs/reference/variables/RightsManagementPapComponentType.md +2 -2
- package/docs/reference/variables/RightsManagementPdpComponentType.md +1 -1
- package/docs/reference/variables/RightsManagementPepComponentType.md +2 -2
- package/docs/reference/variables/RightsManagementPipComponentType.md +1 -1
- package/docs/reference/variables/RightsManagementPmpComponentType.md +1 -1
- package/docs/reference/variables/RightsManagementPnapComponentType.md +2 -2
- package/docs/reference/variables/RightsManagementPnpComponentType.md +2 -2
- package/docs/reference/variables/RightsManagementPolicyArbiterComponentType.md +19 -0
- package/docs/reference/variables/RightsManagementPolicyEnforcementProcessorComponentType.md +19 -0
- package/docs/reference/variables/RightsManagementPolicyExecutionActionComponentType.md +13 -0
- package/docs/reference/variables/RightsManagementPolicyInformationSourceComponentType.md +19 -0
- package/docs/reference/variables/RightsManagementPolicyNegotiatorComponentType.md +13 -0
- package/docs/reference/variables/RightsManagementPolicyObligationEnforcerComponentType.md +13 -0
- package/docs/reference/variables/RightsManagementPolicyRequesterComponentType.md +13 -0
- package/docs/reference/variables/RightsManagementPxpComponentType.md +1 -1
- package/docs/reference/variables/SynchronisedStorageComponentType.md +2 -2
- package/docs/reference/variables/TaskSchedulerComponentType.md +1 -1
- package/docs/reference/variables/TelemetryComponentType.md +2 -2
- package/docs/reference/variables/TelemetryConnectorType.md +1 -1
- package/docs/reference/variables/TenantAdminComponentType.md +1 -1
- package/docs/reference/variables/TrustComponentType.md +13 -0
- package/docs/reference/variables/TrustGeneratorComponentType.md +13 -0
- package/docs/reference/variables/TrustVerifierComponentType.md +13 -0
- package/docs/reference/variables/VaultConnectorType.md +2 -2
- package/docs/reference/variables/VerifiableStorageComponentType.md +2 -2
- package/docs/reference/variables/VerifiableStorageConnectorType.md +2 -2
- package/docs/reference/variables/WalletConnectorType.md +2 -2
- package/package.json +22 -10
- package/dist/es/components/authenticationGenerator.js +0 -30
- package/dist/es/components/authenticationGenerator.js.map +0 -1
- package/dist/es/components/dataSpaceConnector.js +0 -52
- package/dist/es/components/dataSpaceConnector.js.map +0 -1
- package/dist/es/components/rightsManagementDap.js +0 -38
- package/dist/es/components/rightsManagementDap.js.map +0 -1
- package/dist/es/components/rightsManagementDarp.js +0 -29
- package/dist/es/components/rightsManagementDarp.js.map +0 -1
- package/dist/es/models/config/authenticationGeneratorComponentConfig.js +0 -2
- package/dist/es/models/config/authenticationGeneratorComponentConfig.js.map +0 -1
- package/dist/es/models/config/backgroundTaskConnectorConfig.js +0 -2
- package/dist/es/models/config/backgroundTaskConnectorConfig.js.map +0 -1
- package/dist/es/models/config/dataSpaceConnectorComponentConfig.js +0 -2
- package/dist/es/models/config/dataSpaceConnectorComponentConfig.js.map +0 -1
- package/dist/es/models/config/rightsManagementDapComponentConfig.js +0 -2
- package/dist/es/models/config/rightsManagementDapComponentConfig.js.map +0 -1
- package/dist/es/models/config/rightsManagementDarpComponentConfig.js +0 -2
- package/dist/es/models/config/rightsManagementDarpComponentConfig.js.map +0 -1
- package/dist/es/models/types/authenticationGeneratorComponentType.js +0 -13
- package/dist/es/models/types/authenticationGeneratorComponentType.js.map +0 -1
- package/dist/es/models/types/backgroundTaskConnectorType.js +0 -13
- package/dist/es/models/types/backgroundTaskConnectorType.js.map +0 -1
- package/dist/es/models/types/dataSpaceConnectorComponentType.js.map +0 -1
- package/dist/es/models/types/rightsManagementDapComponentType.js.map +0 -1
- package/dist/es/models/types/rightsManagementDarpComponentType.js.map +0 -1
- package/dist/types/components/authenticationGenerator.d.ts +0 -17
- package/dist/types/components/dataSpaceConnector.d.ts +0 -16
- package/dist/types/components/rightsManagementDap.d.ts +0 -16
- package/dist/types/components/rightsManagementDarp.d.ts +0 -16
- package/dist/types/models/config/authenticationGeneratorComponentConfig.d.ts +0 -9
- package/dist/types/models/config/backgroundTaskConnectorConfig.d.ts +0 -9
- package/dist/types/models/config/dataSpaceConnectorComponentConfig.d.ts +0 -17
- package/dist/types/models/config/rightsManagementDapComponentConfig.d.ts +0 -16
- package/dist/types/models/config/rightsManagementDarpComponentConfig.d.ts +0 -12
- package/dist/types/models/types/authenticationGeneratorComponentType.d.ts +0 -13
- package/dist/types/models/types/backgroundTaskConnectorType.d.ts +0 -13
- package/dist/types/models/types/dataSpaceConnectorComponentType.d.ts +0 -21
- package/dist/types/models/types/rightsManagementDapComponentType.d.ts +0 -17
- package/dist/types/models/types/rightsManagementDarpComponentType.d.ts +0 -13
- package/docs/reference/functions/initialiseAuthenticationGeneratorComponent.md +0 -31
- package/docs/reference/functions/initialiseBackgroundTaskConnector.md +0 -31
- package/docs/reference/functions/initialiseDataSpaceConnectorComponent.md +0 -31
- package/docs/reference/functions/initialiseRightsManagementDapComponent.md +0 -31
- package/docs/reference/functions/initialiseRightsManagementDarpComponent.md +0 -31
- package/docs/reference/type-aliases/AuthenticationGeneratorComponentConfig.md +0 -17
- package/docs/reference/type-aliases/AuthenticationGeneratorComponentType.md +0 -5
- package/docs/reference/type-aliases/BackgroundTaskConnectorConfig.md +0 -17
- package/docs/reference/type-aliases/BackgroundTaskConnectorType.md +0 -5
- package/docs/reference/type-aliases/DataSpaceConnectorComponentConfig.md +0 -5
- package/docs/reference/type-aliases/DataSpaceConnectorComponentType.md +0 -5
- package/docs/reference/type-aliases/RightsManagementDapComponentConfig.md +0 -5
- package/docs/reference/type-aliases/RightsManagementDapComponentType.md +0 -5
- package/docs/reference/type-aliases/RightsManagementDarpComponentConfig.md +0 -23
- package/docs/reference/type-aliases/RightsManagementDarpComponentType.md +0 -5
- package/docs/reference/variables/AuthenticationGeneratorComponentType.md +0 -13
- package/docs/reference/variables/BackgroundTaskConnectorType.md +0 -13
- package/docs/reference/variables/RightsManagementDapComponentType.md +0 -19
- package/docs/reference/variables/RightsManagementDarpComponentType.md +0 -13
|
@@ -17,6 +17,7 @@ import { EntityStorageRestClient } from "@twin.org/entity-storage-rest-client";
|
|
|
17
17
|
import { EntityStorageService } from "@twin.org/entity-storage-service";
|
|
18
18
|
import { EntityStorageComponentType } from "../models/types/entityStorageComponentType.js";
|
|
19
19
|
import { EntityStorageConnectorType } from "../models/types/entityStorageConnectorType.js";
|
|
20
|
+
import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
|
|
20
21
|
/**
|
|
21
22
|
* Initialise the entity storage connector.
|
|
22
23
|
* @param engineCore The engine core.
|
|
@@ -24,35 +25,38 @@ import { EntityStorageConnectorType } from "../models/types/entityStorageConnect
|
|
|
24
25
|
* @param typeCustom Override the type of connector to use instead of default configuration.
|
|
25
26
|
* @param schema The schema for the entity storage.
|
|
26
27
|
* @param partitionContextIds The context IDs to use for partitioning the data.
|
|
27
|
-
* @returns The name of the instance type that was created.
|
|
28
28
|
* @throws GeneralError when the configuration is invalid.
|
|
29
29
|
*/
|
|
30
30
|
export function initialiseEntityStorageConnector(engineCore, context, typeCustom, schema, partitionContextIds) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
31
|
+
const kebabName = StringHelper.kebabCase(schema);
|
|
32
|
+
let instanceName = kebabName;
|
|
33
|
+
let entityStorageConfig;
|
|
34
|
+
if (Is.stringValue(typeCustom)) {
|
|
35
|
+
// A custom type has been specified, so look it up
|
|
36
|
+
entityStorageConfig = context.config.types.entityStorageConnector?.find(c => c.type === typeCustom || c.overrideInstanceType === typeCustom);
|
|
37
|
+
if (Is.empty(entityStorageConfig)) {
|
|
38
|
+
throw new GeneralError("engineTypes", "entityStorageCustomMissing", {
|
|
39
|
+
typeCustom,
|
|
40
|
+
storageName: instanceName
|
|
41
|
+
});
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
// Since we have a custom type we need to use that as the instance name for the
|
|
44
|
+
// connector so that it can be looked up by other components
|
|
45
|
+
instanceName = typeCustom;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// The default entity storage method is either the one with the isDefault flag set
|
|
49
|
+
// or pick the first one if no default is set.
|
|
50
|
+
entityStorageConfig =
|
|
51
|
+
context.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??
|
|
52
|
+
context.config.types.entityStorageConnector?.[0];
|
|
53
|
+
if (Is.empty(entityStorageConfig)) {
|
|
54
|
+
throw new GeneralError("engineTypes", "entityStorageMissing", {
|
|
55
|
+
storageName: instanceName
|
|
56
|
+
});
|
|
55
57
|
}
|
|
58
|
+
}
|
|
59
|
+
if (!EntityStorageConnectorFactory.hasName(instanceName)) {
|
|
56
60
|
const type = entityStorageConfig.type;
|
|
57
61
|
let entityStorageConnector;
|
|
58
62
|
engineCore.logInfo(I18n.formatMessage("info.engineTypes.configuringEntityStorage", {
|
|
@@ -158,13 +162,13 @@ export function initialiseEntityStorageConnector(engineCore, context, typeCustom
|
|
|
158
162
|
// Create the entity storage that is wrapped by the synchronised connector
|
|
159
163
|
// by removing the custom type it will default to the standard storage
|
|
160
164
|
// mechanism for entity storage
|
|
161
|
-
|
|
165
|
+
initialiseEntityStorageConnector(engineCore, context, undefined, schema, partitionContextIds);
|
|
162
166
|
// Use the wrapped instance name as the entity storage connector type
|
|
163
167
|
// for the synchronised connector
|
|
164
168
|
entityStorageConnector = new SynchronisedEntityStorageConnector({
|
|
165
169
|
entitySchema: schema,
|
|
166
170
|
...entityStorageConfig.options,
|
|
167
|
-
entityStorageConnectorType:
|
|
171
|
+
entityStorageConnectorType: kebabName,
|
|
168
172
|
eventBusComponentType: engineCore.getRegisteredInstanceType("eventBusComponent"),
|
|
169
173
|
config: {
|
|
170
174
|
...entityStorageConfig.options.config
|
|
@@ -184,7 +188,6 @@ export function initialiseEntityStorageConnector(engineCore, context, typeCustom
|
|
|
184
188
|
});
|
|
185
189
|
EntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);
|
|
186
190
|
}
|
|
187
|
-
return instanceName;
|
|
188
191
|
}
|
|
189
192
|
/**
|
|
190
193
|
* Initialise the entity storage connector.
|
|
@@ -193,33 +196,31 @@ export function initialiseEntityStorageConnector(engineCore, context, typeCustom
|
|
|
193
196
|
* @param instanceConfig The instance config.
|
|
194
197
|
* @returns The instance created and the factory for it.
|
|
195
198
|
*/
|
|
196
|
-
export
|
|
197
|
-
let
|
|
198
|
-
let
|
|
199
|
+
export function initialiseEntityStorageComponent(engineCore, context, instanceConfig) {
|
|
200
|
+
let createComponent;
|
|
201
|
+
let instanceTypeName;
|
|
199
202
|
if (instanceConfig.type === EntityStorageComponentType.Service) {
|
|
200
203
|
const kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
instanceType = StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
204
|
+
createComponent = (createConfig) => {
|
|
205
|
+
// See if there is a custom entity storage for this type, otherwise just use the default one.
|
|
206
|
+
const hasCustom = context.config.types.entityStorageConnector?.some(c => c.type === kebabName || c.overrideInstanceType === kebabName);
|
|
207
|
+
initialiseEntityStorageConnector(engineCore, context, hasCustom ? kebabName : undefined, createConfig.options.entityStorageType, createConfig.options.partitionContextIds);
|
|
208
|
+
return new EntityStorageService(EngineTypeHelper.mergeConfig(createConfig.options, {
|
|
209
|
+
entityStorageType: kebabName
|
|
210
|
+
}));
|
|
211
|
+
};
|
|
212
|
+
instanceTypeName = kebabName;
|
|
211
213
|
}
|
|
212
214
|
else if (instanceConfig.type === EntityStorageComponentType.RestClient) {
|
|
213
215
|
const kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
214
|
-
|
|
215
|
-
pathPrefix: kebabName
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
instanceType = `${"entity-storage-rest-client"}-${kebabName}`;
|
|
216
|
+
createComponent = (createConfig) => new EntityStorageRestClient(EngineTypeHelper.mergeConfig(createConfig.options, {
|
|
217
|
+
pathPrefix: kebabName
|
|
218
|
+
}));
|
|
219
|
+
instanceTypeName = `${"entity-storage-rest-client"}-${kebabName}`;
|
|
219
220
|
}
|
|
220
221
|
return {
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
createComponent: createComponent,
|
|
223
|
+
instanceTypeName,
|
|
223
224
|
factory: ComponentFactory
|
|
224
225
|
};
|
|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AC5B,MAAM,EAAE;gBACP,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM;aAChC;SACD,CAAC,CAAC;QACH,YAAY,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjF,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,0BAA0B,CAAC,UAAU,EAAE,CAAC;QAC1E,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACnF,SAAS,GAAG,IAAI,uBAAuB,CAAC;YACvC,UAAU,EAAE,SAAS;YACrB,GAAG,cAAc,CAAC,OAAO;SACzB,CAAC,CAAC;QACH,YAAY,GAAG,GAAG,4BAAwC,IAAI,SAAS,EAAE,CAAC;IAC3E,CAAC;IAED,OAAO;QACN,SAAS;QACT,YAAY;QACZ,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tComponentFactory,\n\tGeneralError,\n\tI18n,\n\tIs,\n\tStringHelper,\n\ttype IComponent\n} from \"@twin.org/core\";\nimport type { IEngineCore, IEngineCoreContext } from \"@twin.org/engine-models\";\nimport { CosmosDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-cosmosdb\";\nimport { DynamoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-dynamodb\";\nimport { FileEntityStorageConnector } from \"@twin.org/entity-storage-connector-file\";\nimport { FirestoreEntityStorageConnector } from \"@twin.org/entity-storage-connector-gcp-firestore\";\nimport { MemoryEntityStorageConnector } from \"@twin.org/entity-storage-connector-memory\";\nimport { MongoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-mongodb\";\nimport { MySqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-mysql\";\nimport { PostgreSqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-postgresql\";\nimport { ScyllaDBTableConnector } from \"@twin.org/entity-storage-connector-scylladb\";\nimport { SynchronisedEntityStorageConnector } from \"@twin.org/entity-storage-connector-synchronised\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageComponent,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { EntityStorageRestClient } from \"@twin.org/entity-storage-rest-client\";\nimport { EntityStorageService } from \"@twin.org/entity-storage-service\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EntityStorageComponentConfig } from \"../models/config/entityStorageComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { EntityStorageComponentType } from \"../models/types/entityStorageComponentType.js\";\nimport { EntityStorageConnectorType } from \"../models/types/entityStorageConnectorType.js\";\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param typeCustom Override the type of connector to use instead of default configuration.\n * @param schema The schema for the entity storage.\n * @param partitionContextIds The context IDs to use for partitioning the data.\n * @returns The name of the instance type that was created.\n * @throws GeneralError when the configuration is invalid.\n */\nexport function initialiseEntityStorageConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\ttypeCustom: string | undefined,\n\tschema: string,\n\tpartitionContextIds: string[]\n): string {\n\tconst instanceName = StringHelper.kebabCase(schema);\n\n\tif (!EntityStorageConnectorFactory.hasName(instanceName)) {\n\t\tlet entityStorageConfig;\n\n\t\tif (Is.stringValue(typeCustom)) {\n\t\t\t// A custom type has been specified, so look it up\n\t\t\tentityStorageConfig = context.config.types.entityStorageConnector?.find(\n\t\t\t\tc => c.type === typeCustom || c.overrideInstanceType === typeCustom\n\t\t\t);\n\t\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageCustomMissing\", {\n\t\t\t\t\ttypeCustom,\n\t\t\t\t\tstorageName: instanceName\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// The default entity storage method is either the one with the isDefault flag set\n\t\t\t// or pick the first one if no default is set.\n\t\t\tentityStorageConfig =\n\t\t\t\tcontext.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??\n\t\t\t\tcontext.config.types.entityStorageConnector?.[0];\n\t\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageMissing\", {\n\t\t\t\t\tstorageName: instanceName\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst type = entityStorageConfig.type;\n\t\tlet entityStorageConnector: IEntityStorageConnector;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"info.engineTypes.configuringEntityStorage\", {\n\t\t\t\telement: \"Entity Storage\",\n\t\t\t\tstorageName: instanceName,\n\t\t\t\tstorageType: type\n\t\t\t})\n\t\t);\n\n\t\tif (type === EntityStorageConnectorType.Memory) {\n\t\t\tentityStorageConnector = new MemoryEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.File) {\n\t\t\tentityStorageConnector = new FileEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tdirectory: path.join(\n\t\t\t\t\t\tentityStorageConfig.options.config.directory,\n\t\t\t\t\t\t`${entityStorageConfig.options.folderPrefix ?? \"\"}${instanceName}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AwsDynamoDb) {\n\t\t\tentityStorageConnector = new DynamoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AzureCosmosDb) {\n\t\t\tentityStorageConnector = new CosmosDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcontainerId: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.GcpFirestoreDb) {\n\t\t\tentityStorageConnector = new FirestoreEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollectionName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.ScyllaDb) {\n\t\t\tentityStorageConnector = new ScyllaDBTableConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MySqlDb) {\n\t\t\tentityStorageConnector = new MySqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MongoDb) {\n\t\t\tentityStorageConnector = new MongoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollection: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.PostgreSql) {\n\t\t\tentityStorageConnector = new PostgreSqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.Synchronised) {\n\t\t\t// Create the entity storage that is wrapped by the synchronised connector\n\t\t\t// by removing the custom type it will default to the standard storage\n\t\t\t// mechanism for entity storage\n\t\t\tconst wrappedInstanceName = initialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tundefined,\n\t\t\t\tschema,\n\t\t\t\tpartitionContextIds\n\t\t\t);\n\n\t\t\t// Use the wrapped instance name as the entity storage connector type\n\t\t\t// for the synchronised connector\n\t\t\tentityStorageConnector = new SynchronisedEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tentityStorageConnectorType: wrappedInstanceName,\n\t\t\t\teventBusComponentType: engineCore.getRegisteredInstanceType(\"eventBusComponent\"),\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"connectorUnknownType\", {\n\t\t\t\ttype,\n\t\t\t\tconnectorType: \"entityStorageConnector\"\n\t\t\t});\n\t\t}\n\n\t\tcontext.componentInstances.push({\n\t\t\tinstanceType: instanceName,\n\t\t\tcomponent: entityStorageConnector,\n\t\t\tinitialised: false\n\t\t});\n\t\tEntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);\n\t}\n\n\treturn instanceName;\n}\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport async function initialiseEntityStorageComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EntityStorageComponentConfig\n): Promise<{\n\tinstanceType?: string;\n\tfactory?: typeof ComponentFactory;\n\tcomponent?: IComponent;\n}> {\n\tlet component: IEntityStorageComponent | undefined;\n\tlet instanceType: string | undefined;\n\n\tif (instanceConfig.type === EntityStorageComponentType.Service) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\n\t\t// See if there is a custom entity storage for this type, otherwise just use the default one.\n\t\tconst hasCustom = context.config.types.entityStorageConnector?.some(\n\t\t\tc => c.type === kebabName || c.overrideInstanceType === kebabName\n\t\t);\n\n\t\tinitialiseEntityStorageConnector(\n\t\t\tengineCore,\n\t\t\tcontext,\n\t\t\thasCustom ? kebabName : undefined,\n\t\t\tinstanceConfig.options.entityStorageType,\n\t\t\tinstanceConfig.options.partitionContextIds\n\t\t);\n\t\tcomponent = new EntityStorageService({\n\t\t\tentityStorageType: kebabName,\n\t\t\tconfig: {\n\t\t\t\t...instanceConfig.options.config\n\t\t\t}\n\t\t});\n\t\tinstanceType = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t} else if (instanceConfig.type === EntityStorageComponentType.RestClient) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcomponent = new EntityStorageRestClient({\n\t\t\tpathPrefix: kebabName,\n\t\t\t...instanceConfig.options\n\t\t});\n\t\tinstanceType = `${nameofKebabCase(EntityStorageRestClient)}-${kebabName}`;\n\t}\n\n\treturn {\n\t\tcomponent,\n\t\tinstanceType,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorage.js","sourceRoot":"","sources":["../../../src/components/entityStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,IAAI,EAEJ,EAAE,EACF,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,gBAAg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CAAC;YAEF,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACjC,YAAY,CAAC,OAAO,CAAC,iBAAiB,EACtC,YAAY,CAAC,OAAO,CAAC,mBAAmB,CACxC,CAAC;YAEF,OAAO,IAAI,oBAAoB,CAC9B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,EAAE;gBACtF,iBAAiB,EAAE,SAAS;aAC5B,CAAC,CACF,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,GAAG,SAAS,CAAC;IAC9B,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,0BAA0B,CAAC,UAAU,EAAE,CAAC;QAC1E,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACnF,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,uBAAuB,CAC1B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,EAAE;YACtF,UAAU,EAAE,SAAS;SACrB,CAAC,CACF,CAAC;QACH,gBAAgB,GAAG,GAAG,4BAAwC,IAAI,SAAS,EAAE,CAAC;IAC/E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tComponentFactory,\n\tGeneralError,\n\tI18n,\n\ttype IComponent,\n\tIs,\n\tStringHelper\n} from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { CosmosDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-cosmosdb\";\nimport { DynamoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-dynamodb\";\nimport { FileEntityStorageConnector } from \"@twin.org/entity-storage-connector-file\";\nimport { FirestoreEntityStorageConnector } from \"@twin.org/entity-storage-connector-gcp-firestore\";\nimport { MemoryEntityStorageConnector } from \"@twin.org/entity-storage-connector-memory\";\nimport { MongoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-mongodb\";\nimport { MySqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-mysql\";\nimport { PostgreSqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-postgresql\";\nimport { ScyllaDBTableConnector } from \"@twin.org/entity-storage-connector-scylladb\";\nimport { SynchronisedEntityStorageConnector } from \"@twin.org/entity-storage-connector-synchronised\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { EntityStorageRestClient } from \"@twin.org/entity-storage-rest-client\";\nimport { EntityStorageService } from \"@twin.org/entity-storage-service\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EntityStorageComponentConfig } from \"../models/config/entityStorageComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { EntityStorageComponentType } from \"../models/types/entityStorageComponentType.js\";\nimport { EntityStorageConnectorType } from \"../models/types/entityStorageConnectorType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param typeCustom Override the type of connector to use instead of default configuration.\n * @param schema The schema for the entity storage.\n * @param partitionContextIds The context IDs to use for partitioning the data.\n * @throws GeneralError when the configuration is invalid.\n */\nexport function initialiseEntityStorageConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\ttypeCustom: string | undefined,\n\tschema: string,\n\tpartitionContextIds: string[]\n): void {\n\tconst kebabName = StringHelper.kebabCase(schema);\n\tlet instanceName = kebabName;\n\n\tlet entityStorageConfig;\n\n\tif (Is.stringValue(typeCustom)) {\n\t\t// A custom type has been specified, so look it up\n\t\tentityStorageConfig = context.config.types.entityStorageConnector?.find(\n\t\t\tc => c.type === typeCustom || c.overrideInstanceType === typeCustom\n\t\t);\n\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageCustomMissing\", {\n\t\t\t\ttypeCustom,\n\t\t\t\tstorageName: instanceName\n\t\t\t});\n\t\t}\n\n\t\t// Since we have a custom type we need to use that as the instance name for the\n\t\t// connector so that it can be looked up by other components\n\t\tinstanceName = typeCustom;\n\t} else {\n\t\t// The default entity storage method is either the one with the isDefault flag set\n\t\t// or pick the first one if no default is set.\n\t\tentityStorageConfig =\n\t\t\tcontext.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??\n\t\t\tcontext.config.types.entityStorageConnector?.[0];\n\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageMissing\", {\n\t\t\t\tstorageName: instanceName\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!EntityStorageConnectorFactory.hasName(instanceName)) {\n\t\tconst type = entityStorageConfig.type;\n\t\tlet entityStorageConnector: IEntityStorageConnector;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"info.engineTypes.configuringEntityStorage\", {\n\t\t\t\telement: \"Entity Storage\",\n\t\t\t\tstorageName: instanceName,\n\t\t\t\tstorageType: type\n\t\t\t})\n\t\t);\n\n\t\tif (type === EntityStorageConnectorType.Memory) {\n\t\t\tentityStorageConnector = new MemoryEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.File) {\n\t\t\tentityStorageConnector = new FileEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tdirectory: path.join(\n\t\t\t\t\t\tentityStorageConfig.options.config.directory,\n\t\t\t\t\t\t`${entityStorageConfig.options.folderPrefix ?? \"\"}${instanceName}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AwsDynamoDb) {\n\t\t\tentityStorageConnector = new DynamoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AzureCosmosDb) {\n\t\t\tentityStorageConnector = new CosmosDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcontainerId: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.GcpFirestoreDb) {\n\t\t\tentityStorageConnector = new FirestoreEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollectionName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.ScyllaDb) {\n\t\t\tentityStorageConnector = new ScyllaDBTableConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MySqlDb) {\n\t\t\tentityStorageConnector = new MySqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MongoDb) {\n\t\t\tentityStorageConnector = new MongoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollection: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.PostgreSql) {\n\t\t\tentityStorageConnector = new PostgreSqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.Synchronised) {\n\t\t\t// Create the entity storage that is wrapped by the synchronised connector\n\t\t\t// by removing the custom type it will default to the standard storage\n\t\t\t// mechanism for entity storage\n\t\t\tinitialiseEntityStorageConnector(engineCore, context, undefined, schema, partitionContextIds);\n\n\t\t\t// Use the wrapped instance name as the entity storage connector type\n\t\t\t// for the synchronised connector\n\t\t\tentityStorageConnector = new SynchronisedEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tentityStorageConnectorType: kebabName,\n\t\t\t\teventBusComponentType: engineCore.getRegisteredInstanceType(\"eventBusComponent\"),\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"connectorUnknownType\", {\n\t\t\t\ttype,\n\t\t\t\tconnectorType: \"entityStorageConnector\"\n\t\t\t});\n\t\t}\n\n\t\tcontext.componentInstances.push({\n\t\t\tinstanceType: instanceName,\n\t\t\tcomponent: entityStorageConnector,\n\t\t\tinitialised: false\n\t\t});\n\t\tEntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);\n\t}\n}\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseEntityStorageComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EntityStorageComponentConfig\n): EngineTypeInitialiserReturn<EntityStorageComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === EntityStorageComponentType.Service) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\t// See if there is a custom entity storage for this type, otherwise just use the default one.\n\t\t\tconst hasCustom = context.config.types.entityStorageConnector?.some(\n\t\t\t\tc => c.type === kebabName || c.overrideInstanceType === kebabName\n\t\t\t);\n\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\thasCustom ? kebabName : undefined,\n\t\t\t\tcreateConfig.options.entityStorageType,\n\t\t\t\tcreateConfig.options.partitionContextIds\n\t\t\t);\n\n\t\t\treturn new EntityStorageService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tentityStorageType: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = kebabName;\n\t} else if (instanceConfig.type === EntityStorageComponentType.RestClient) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EntityStorageRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tpathPrefix: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\tinstanceTypeName = `${nameofKebabCase(EntityStorageRestClient)}-${kebabName}`;\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { EventBusService } from "@twin.org/event-bus-service";
|
|
|
7
7
|
import { EventBusSocketClient } from "@twin.org/event-bus-socket-client";
|
|
8
8
|
import { EventBusComponentType } from "../models/types/eventBusComponentType.js";
|
|
9
9
|
import { EventBusConnectorType } from "../models/types/eventBusConnectorType.js";
|
|
10
|
+
import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
|
|
10
11
|
/**
|
|
11
12
|
* Initialise a event bus connector.
|
|
12
13
|
* @param engineCore The engine core.
|
|
@@ -14,20 +15,17 @@ import { EventBusConnectorType } from "../models/types/eventBusConnectorType.js"
|
|
|
14
15
|
* @param instanceConfig The instance config.
|
|
15
16
|
* @returns The instance created and the factory for it.
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
-
let
|
|
19
|
-
let
|
|
18
|
+
export function initialiseEventBusConnector(engineCore, context, instanceConfig) {
|
|
19
|
+
let createComponent;
|
|
20
|
+
let instanceTypeName;
|
|
20
21
|
if (instanceConfig.type === EventBusConnectorType.Local) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
...instanceConfig.options
|
|
24
|
-
});
|
|
25
|
-
instanceType = LocalEventBusConnector.NAMESPACE;
|
|
22
|
+
createComponent = (createConfig) => new LocalEventBusConnector(EngineTypeHelper.mergeConfig({ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent") }, createConfig.options));
|
|
23
|
+
instanceTypeName = LocalEventBusConnector.NAMESPACE;
|
|
26
24
|
}
|
|
27
25
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
createComponent: createComponent,
|
|
27
|
+
instanceTypeName,
|
|
28
|
+
factory: EventBusConnectorFactory
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
@@ -37,27 +35,21 @@ export async function initialiseEventBusConnector(engineCore, context, instanceC
|
|
|
37
35
|
* @param instanceConfig The instance config.
|
|
38
36
|
* @returns The instance created and the factory for it.
|
|
39
37
|
*/
|
|
40
|
-
export
|
|
41
|
-
let
|
|
42
|
-
let
|
|
38
|
+
export function initialiseEventBusComponent(engineCore, context, instanceConfig) {
|
|
39
|
+
let createComponent;
|
|
40
|
+
let instanceTypeName;
|
|
43
41
|
if (instanceConfig.type === EventBusComponentType.Service) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
...instanceConfig.options
|
|
47
|
-
});
|
|
48
|
-
instanceType = "event-bus-service";
|
|
42
|
+
createComponent = (createConfig) => new EventBusService(EngineTypeHelper.mergeConfig({ eventBusConnectorType: engineCore.getRegisteredInstanceType("eventBusConnector") }, createConfig.options));
|
|
43
|
+
instanceTypeName = "event-bus-service";
|
|
49
44
|
}
|
|
50
45
|
else if (instanceConfig.type === EventBusComponentType.SocketClient) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...instanceConfig.options
|
|
54
|
-
});
|
|
55
|
-
instanceType = "event-bus-socket-client";
|
|
46
|
+
createComponent = (createConfig) => new EventBusSocketClient(EngineTypeHelper.mergeConfig({ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent") }, createConfig.options));
|
|
47
|
+
instanceTypeName = "event-bus-socket-client";
|
|
56
48
|
}
|
|
57
49
|
return {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
createComponent: createComponent,
|
|
51
|
+
instanceTypeName,
|
|
52
|
+
factory: ComponentFactory
|
|
61
53
|
};
|
|
62
54
|
}
|
|
63
55
|
//# sourceMappingURL=eventBus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventBus.js","sourceRoot":"","sources":["../../../src/components/eventBus.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"eventBus.js","sourceRoot":"","sources":["../../../src/components/eventBus.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAKzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAC1C,UAAsC,EACtC,OAA0C,EAC1C,cAAuC;IAEvC,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACzD,eAAe,GAAG,CA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iftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { LocalEventBusConnector } from \"@twin.org/event-bus-connector-local\";\nimport { EventBusConnectorFactory } from \"@twin.org/event-bus-models\";\nimport { EventBusService } from \"@twin.org/event-bus-service\";\nimport { EventBusSocketClient } from \"@twin.org/event-bus-socket-client\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EventBusComponentConfig } from \"../models/config/eventBusComponentConfig.js\";\nimport type { EventBusConnectorConfig } from \"../models/config/eventBusConnectorConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { EventBusComponentType } from \"../models/types/eventBusComponentType.js\";\nimport { EventBusConnectorType } from \"../models/types/eventBusConnectorType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise a event bus connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseEventBusConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EventBusConnectorConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof EventBusConnectorFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === EventBusConnectorType.Local) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew LocalEventBusConnector(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ loggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = LocalEventBusConnector.NAMESPACE;\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: EventBusConnectorFactory\n\t};\n}\n\n/**\n * Initialise the event bus component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseEventBusComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EventBusComponentConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === EventBusComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EventBusService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ eventBusConnectorType: engineCore.getRegisteredInstanceType(\"eventBusConnector\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(EventBusService);\n\t} else if (instanceConfig.type === EventBusComponentType.SocketClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EventBusSocketClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ loggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(EventBusSocketClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -12,29 +12,29 @@ import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
|
|
|
12
12
|
* @param instanceConfig The instance config.
|
|
13
13
|
* @returns The instance created and the factory for it.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
16
|
-
let
|
|
17
|
-
let
|
|
15
|
+
export function initialiseFaucetConnector(engineCore, context, instanceConfig) {
|
|
16
|
+
let createComponent;
|
|
17
|
+
let instanceTypeName;
|
|
18
18
|
if (instanceConfig.type === FaucetConnectorType.Iota) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
instanceType = IotaFaucetConnector.NAMESPACE;
|
|
19
|
+
createComponent = (createConfig) => {
|
|
20
|
+
const dltConfig = EngineTypeHelper.getConfigOfType(engineCore.getConfig(), "dltConfig", DltConfigType.Iota);
|
|
21
|
+
return new IotaFaucetConnector(EngineTypeHelper.mergeConfig({
|
|
22
|
+
config: dltConfig?.options?.config
|
|
23
|
+
}, createConfig.options));
|
|
24
|
+
};
|
|
25
|
+
instanceTypeName = IotaFaucetConnector.NAMESPACE;
|
|
28
26
|
}
|
|
29
27
|
else if (instanceConfig.type === FaucetConnectorType.EntityStorage) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
createComponent = (createConfig) => {
|
|
29
|
+
initSchemaWallet();
|
|
30
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.walletAddressEntityStorageType, "WalletAddress", []);
|
|
31
|
+
return new EntityStorageFaucetConnector(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
32
|
+
};
|
|
33
|
+
instanceTypeName = EntityStorageFaucetConnector.NAMESPACE;
|
|
34
34
|
}
|
|
35
35
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
createComponent: createComponent,
|
|
37
|
+
instanceTypeName,
|
|
38
38
|
factory: FaucetConnectorFactory
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faucet.js","sourceRoot":"","sources":["../../../src/components/faucet.ts"],"names":[],"mappings":"
|
|
1
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EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,8BAA8B,mBAEpD,EAAE,CACF,CAAC;YACF,OAAO,IAAI,4BAA4B,CACtC,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,GAAG,4BAA4B,CAAC,SAAS,CAAC;IAC3D,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,sBAAsB;KAC/B,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tEntityStorageFaucetConnector,\n\tinitSchema as initSchemaWallet,\n\ttype WalletAddress\n} from \"@twin.org/wallet-connector-entity-storage\";\nimport {\n\ttype IIotaFaucetConnectorConfig,\n\tIotaFaucetConnector\n} from \"@twin.org/wallet-connector-iota\";\nimport { FaucetConnectorFactory } from \"@twin.org/wallet-models\";\nimport { initialiseEntityStorageConnector } from \"./entityStorage.js\";\nimport type { DltConfig } from \"../models/config/dltConfig.js\";\nimport type { FaucetConnectorConfig } from \"../models/config/faucetConnectorConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { DltConfigType } from \"../models/types/dltConfigType.js\";\nimport { FaucetConnectorType } from \"../models/types/faucetConnectorType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise a faucet connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseFaucetConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: FaucetConnectorConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof FaucetConnectorFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === FaucetConnectorType.Iota) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\t\tengineCore.getConfig(),\n\t\t\t\t\"dltConfig\",\n\t\t\t\tDltConfigType.Iota\n\t\t\t);\n\t\t\treturn new IotaFaucetConnector(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\tconfig: dltConfig?.options?.config as IIotaFaucetConnectorConfig\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = IotaFaucetConnector.NAMESPACE;\n\t} else if (instanceConfig.type === FaucetConnectorType.EntityStorage) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaWallet();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.walletAddressEntityStorageType,\n\t\t\t\tnameof<WalletAddress>(),\n\t\t\t\t[]\n\t\t\t);\n\t\t\treturn new EntityStorageFaucetConnector(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = EntityStorageFaucetConnector.NAMESPACE;\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: FaucetConnectorFactory\n\t};\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { FederatedCatalogueRestClient } from "@twin.org/federated-catalogue-rest
|
|
|
6
6
|
import { FederatedCatalogueService, initSchema as initSchemaFederatedCatalogue } from "@twin.org/federated-catalogue-service";
|
|
7
7
|
import { initialiseEntityStorageConnector } from "./entityStorage.js";
|
|
8
8
|
import { FederatedCatalogueComponentType } from "../models/types/federatedCatalogueComponentType.js";
|
|
9
|
+
import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
|
|
9
10
|
/**
|
|
10
11
|
* Initialise the federated catalogue component.
|
|
11
12
|
* @param engineCore The engine core.
|
|
@@ -13,29 +14,24 @@ import { FederatedCatalogueComponentType } from "../models/types/federatedCatalo
|
|
|
13
14
|
* @param instanceConfig The instance config.
|
|
14
15
|
* @returns The instance created and the factory for it.
|
|
15
16
|
*/
|
|
16
|
-
export
|
|
17
|
-
let
|
|
18
|
-
let
|
|
17
|
+
export function initialiseFederatedCatalogueComponent(engineCore, context, instanceConfig) {
|
|
18
|
+
let createComponent;
|
|
19
|
+
let instanceTypeName;
|
|
19
20
|
if (instanceConfig.type === FederatedCatalogueComponentType.Service) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
|
|
27
|
-
identityResolverComponentType: engineCore.getRegisteredInstanceType("identityResolverComponent"),
|
|
28
|
-
...instanceConfig.options
|
|
29
|
-
});
|
|
30
|
-
instanceType = "federated-catalogue-service";
|
|
21
|
+
createComponent = (createConfig) => {
|
|
22
|
+
initSchemaFederatedCatalogue();
|
|
23
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.datasetEntityStorageType, "Dataset", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node]));
|
|
24
|
+
return new FederatedCatalogueService(EngineTypeHelper.mergeConfig({ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent") }, createConfig.options));
|
|
25
|
+
};
|
|
26
|
+
instanceTypeName = "federated-catalogue-service";
|
|
31
27
|
}
|
|
32
28
|
else if (instanceConfig.type === FederatedCatalogueComponentType.RestClient) {
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
createComponent = (createConfig) => new FederatedCatalogueRestClient(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
30
|
+
instanceTypeName = "federated-catalogue-rest-client";
|
|
35
31
|
}
|
|
36
32
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
createComponent: createComponent,
|
|
34
|
+
instanceTypeName,
|
|
39
35
|
factory: ComponentFactory
|
|
40
36
|
};
|
|
41
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"federatedCatalogue.js","sourceRoot":"","sources":["../../../src/components/federatedCatalogue.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"federatedCatalogue.js","sourceRoot":"","sources":["../../../src/components/federatedCatalogue.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAEN,yBAAyB,EACzB,UAAU,IAAI,4BAA4B,EAC1C,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACpD,UAAsC,EACtC,OAA0C,EAC1C,cAAiD;IAEjD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,+BAA+B,CAAC,OAAO,EAAE,CAAC;QACrE,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,4BAA4B,EAAE,CAAC;YAC/B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,wBAAwB,aAE9C,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAC1F,CAAC;YACF,OAAO,IAAI,yBAAyB,CACnC,gBAAgB,CAAC,WAAW,CAC3B,EAAE,oBAAoB,EAAE,UAAU,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,EAAE,EAClF,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,gCAA6C,CAAC;IAC/D,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,+BAA+B,CAAC,UAAU,EAAE,CAAC;QAC/E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,4BAA4B,CAC/B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,oCAAgD,CAAC;IAClE,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAEhB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { FederatedCatalogueRestClient } from \"@twin.org/federated-catalogue-rest-client\";\nimport {\n\ttype Dataset,\n\tFederatedCatalogueService,\n\tinitSchema as initSchemaFederatedCatalogue\n} from \"@twin.org/federated-catalogue-service\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport { initialiseEntityStorageConnector } from \"./entityStorage.js\";\nimport type { FederatedCatalogueComponentConfig } from \"../models/config/federatedCatalogueComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { FederatedCatalogueComponentType } from \"../models/types/federatedCatalogueComponentType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the federated catalogue component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseFederatedCatalogueComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: FederatedCatalogueComponentConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === FederatedCatalogueComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaFederatedCatalogue();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.datasetEntityStorageType,\n\t\t\t\tnameof<Dataset>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node])\n\t\t\t);\n\t\t\treturn new FederatedCatalogueService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ loggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueService);\n\t} else if (instanceConfig.type === FederatedCatalogueComponentType.RestClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew FederatedCatalogueRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueRestClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
4
|
+
import { FilterByExample } from "@twin.org/federated-catalogue-filters";
|
|
5
|
+
import { FederatedCatalogueFilterFactory } from "@twin.org/federated-catalogue-models";
|
|
6
|
+
import { initSchema as initSchemaFederatedCatalogue } from "@twin.org/federated-catalogue-service";
|
|
7
|
+
import { initialiseEntityStorageConnector } from "./entityStorage.js";
|
|
8
|
+
import { FederatedCatalogueFilterComponentType } from "../models/types/federatedCatalogueFilterComponentType.js";
|
|
9
|
+
import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
|
|
10
|
+
/**
|
|
11
|
+
* Initialise the federated catalogue filter component.
|
|
12
|
+
* @param engineCore The engine core.
|
|
13
|
+
* @param context The context for the engine.
|
|
14
|
+
* @param instanceConfig The instance config.
|
|
15
|
+
* @returns The instance created and the factory for it.
|
|
16
|
+
*/
|
|
17
|
+
export function initialiseFederatedCatalogueFilterComponent(engineCore, context, instanceConfig) {
|
|
18
|
+
let createComponent;
|
|
19
|
+
let instanceTypeName;
|
|
20
|
+
if (instanceConfig.type === FederatedCatalogueFilterComponentType.FilterByExample) {
|
|
21
|
+
createComponent = (createConfig) => {
|
|
22
|
+
initSchemaFederatedCatalogue();
|
|
23
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.datasetStorageConnectorType, "Dataset", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node]));
|
|
24
|
+
return new FilterByExample(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
25
|
+
};
|
|
26
|
+
instanceTypeName = "FilterByExample";
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
createComponent: createComponent,
|
|
30
|
+
instanceTypeName,
|
|
31
|
+
factory: FederatedCatalogueFilterFactory
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=federatedCatalogueFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federatedCatalogueFilter.js","sourceRoot":"","sources":["../../../src/components/federatedCatalogueFilter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOnE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAEN,UAAU,IAAI,4BAA4B,EAC1C,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EAAE,qCAAqC,EAAE,MAAM,0DAA0D,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,2CAA2C,CAC1D,UAAsC,EACtC,OAA0C,EAC1C,cAAuD;IAEvD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,qCAAqC,CAAC,eAAe,EAAE,CAAC;QACnF,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,4BAA4B,EAAE,CAAC;YAE/B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,2BAA2B,aAEjD,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAC1F,CAAC;YACF,OAAO,IAAI,eAAe,CACzB,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,oBAA0B,CAAC;IAC5C,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,+BAA+B;KACxC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { FilterByExample } from \"@twin.org/federated-catalogue-filters\";\nimport { FederatedCatalogueFilterFactory } from \"@twin.org/federated-catalogue-models\";\nimport {\n\ttype Dataset,\n\tinitSchema as initSchemaFederatedCatalogue\n} from \"@twin.org/federated-catalogue-service\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { initialiseEntityStorageConnector } from \"./entityStorage.js\";\nimport type { FederatedCatalogueFilterComponentConfig } from \"../models/config/federatedCatalogueFilterComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { FederatedCatalogueFilterComponentType } from \"../models/types/federatedCatalogueFilterComponentType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the federated catalogue filter component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseFederatedCatalogueFilterComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: FederatedCatalogueFilterComponentConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof FederatedCatalogueFilterFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === FederatedCatalogueFilterComponentType.FilterByExample) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaFederatedCatalogue();\n\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.datasetStorageConnectorType,\n\t\t\t\tnameof<Dataset>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node])\n\t\t\t);\n\t\t\treturn new FilterByExample(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameof(FilterByExample);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: FederatedCatalogueFilterFactory\n\t};\n}\n"]}
|