import {z} from 'zod' export type CoreSortOrder = 'ASC' | 'DESC'; export type CoreEventScope = 'Self' | 'SelfAndDescendants'; export type GetApiV1DomainsDomainIdEventsArgs = {domainId: string, limit?: number | undefined, startingAfter?: string | undefined, sortBy?: 'sequenceNumber' | undefined, sortOrder?: CoreSortOrder | undefined, scope?: CoreEventScope | undefined}; export type GetApiV1DomainsDomainIdEventsOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const coreAccountCreated = z.object({id: z.string(), type: z.literal("AccountCreated")}); export const coreAccountUpdated = z.object({id: z.string(), type: z.literal("AccountUpdated")}); export const coreAccountReference = z.object({id: z.string(), domainId: z.string()}); export const coreAddressCreated = z.object({id: z.string(), accountReference: coreAccountReference, type: z.literal("AddressCreated")}); export const coreBackupCreated = z.object({id: z.string(), type: z.literal("BackupCreated")}); export const coreBackupUpdated = z.object({id: z.string(), type: z.literal("BackupUpdated")}); export const coreBalancesUpdated = z.object({accountReference: coreAccountReference, tickerIds: z.array(z.string()), type: z.literal("BalancesUpdated")}); export const coreSkipQuarantineScope = z.enum(["None", "Domain", "Instance"]); export const coreUserReference = z.object({id: z.string(), domainId: z.string()}); export const coreComplianceConfigurationUpdated = z.object({accountReference: coreAccountReference, skipQuarantineFrom: coreSkipQuarantineScope, revision: z.number().int().gte(1), modifiedBy: coreUserReference.optional(), type: z.literal("ComplianceConfigurationUpdated")}); export const coreDomainCreated = z.object({id: z.string(), parentId: z.string(), type: z.literal("DomainCreated")}); export const coreDomainUpdated = z.object({id: z.string(), parentId: z.string().optional(), type: z.literal("DomainUpdated")}); export const coreEndpointCreated = z.object({id: z.string(), type: z.literal("EndpointCreated")}); export const coreEndpointUpdated = z.object({id: z.string(), type: z.literal("EndpointUpdated")}); export const coreIntentLockStatus = z.enum(["Unlocked", "Locked"]); export const coreGoverningStrategy = z.enum(["ConsiderDescendants", "CoerceDescendants"]); export const coreReadAccess = z.object({domains: z.array(z.string().min(1).max(50)), users: z.array(z.string().min(1).max(50)), endpoints: z.array(z.string().min(1).max(50)), policies: z.array(z.string().min(1).max(50)), accounts: z.array(z.string().min(1).max(50)), transactions: z.array(z.string().min(1).max(50)), requests: z.array(z.string().min(1).max(50)), events: z.array(z.string().min(1).max(50))}); export const corePermissions = z.object({readAccess: coreReadAccess}); export const coreStringsMap = z.record(z.string(), z.string()); export const coreLoginId = z.object({id: z.string().min(1).max(500), providerId: z.string().min(1).max(100)}); export const coreCreateDomainGenesisUser = z.object({id: z.string(), alias: z.string().min(1).max(75), publicKey: z.string(), roles: z.array(z.string().min(1).max(50)), lock: coreIntentLockStatus, description: z.string().max(250).optional(), customProperties: coreStringsMap, loginIds: z.array(coreLoginId).optional()}); export const coreIntentType = z.enum(["v0_NotarizeData", "v0_ExecuteExtension", "v0_CreateDomain", "v0_UpdateDomain", "v0_UpdateDomainPermissions", "v0_UnlockDomain", "v0_LockDomain", "v0_CreateUser", "v0_UpdateUser", "v0_UnlockUser", "v0_LockUser", "v0_CreatePolicy", "v0_UpdatePolicy", "v0_UnlockPolicy", "v0_LockPolicy", "v0_CreateVault", "v0_UpdateVault", "v0_UnlockVault", "v0_LockVault", "v0_RewrapVaultKeyMaterial", "v0_UnlockTicker", "v0_LockTicker", "v0_CreateEndpoint", "v0_UpdateEndpoint", "v0_UnlockEndpoint", "v0_LockEndpoint", "v0_CreateAccount", "v0_MigrateSilo3AccountBatch", "v0_UpdateAccount", "v0_UnlockAccount", "v0_LockAccount", "v0_AddAccountLedgers", "v0_CreateTransactionOrder", "v0_ReleaseQuarantinedTransfers", "v0_CreateTicker", "v0_AttemptTransactionOrderCancellation", "v0_ValidateTickers", "v0_UpdateTicker", "v0_CreateTransferOrder", "v0_SignManifest", "v0_SetSystemProperty", "v0_CreateLedger", "v0_UpdateLedger", "v0_AddTrustedPublicKeysForMigration", "v0_RegisterTrustedPublicKey", "v0_CreateBackup", "v0_AcknowledgeBackup"]); export const corePolicyScope = z.enum(["Self", "Descendants", "SelfAndDescendants"]); export const coreScriptingEngine = z.literal("Javascript_v0"); export const corePolicyConditionAnd = z.object({left: z.lazy(() => corePolicyCondition), right: z.lazy(() => corePolicyCondition), type: z.literal("And")}); export const corePolicyConditionExpression = z.object({expression: z.string().min(1).max(10000), type: z.literal("Expression")}); export const corePolicyConditionOr = z.object({left: z.lazy(() => corePolicyCondition), right: z.lazy(() => corePolicyCondition), type: z.literal("Or")}); export const corePolicyCondition: z.ZodType = z.discriminatedUnion("type", [corePolicyConditionAnd, corePolicyConditionExpression, corePolicyConditionOr]); export const coreWorkflowConditionAnd = z.object({left: z.lazy(() => coreWorkflowCondition), right: z.lazy(() => coreWorkflowCondition), type: z.literal("And")}); export const coreWorkflowConditionOr = z.object({left: z.lazy(() => coreWorkflowCondition), right: z.lazy(() => coreWorkflowCondition), type: z.literal("Or")}); export const coreWorkflowConditionRoleQuorum = z.object({role: z.string().min(1).max(50), quorum: z.number().int().gte(1), type: z.literal("RoleQuorum")}); export const coreWorkflowCondition: z.ZodType = z.discriminatedUnion("type", [coreWorkflowConditionAnd, coreWorkflowConditionOr, coreWorkflowConditionRoleQuorum]); export const coreIntentOrigin = z.enum(["UserSigned", "SystemSigned"]); export const coreCreateDomainGenesisPolicy = z.object({id: z.string(), alias: z.string().min(1).max(75), rank: z.number().int().gte(0).lte(1000), intentTypes: z.array(coreIntentType).optional(), scope: corePolicyScope, scriptingEngine: coreScriptingEngine, condition: corePolicyCondition.optional(), workflow: z.array(coreWorkflowCondition).optional(), lock: coreIntentLockStatus, description: z.string().max(250).optional(), customProperties: coreStringsMap, intentOrigin: coreIntentOrigin.optional()}); export const coreCreateDomainsPayload: z.ZodType = z.object({id: z.string(), alias: z.string().min(1).max(75), lock: coreIntentLockStatus, governingStrategy: coreGoverningStrategy.optional(), permissions: corePermissions, description: z.string().max(250).optional(), customProperties: coreStringsMap, users: z.array(coreCreateDomainGenesisUser), policies: z.array(coreCreateDomainGenesisPolicy), descendants: z.array(z.lazy(() => coreCreateDomainsPayload))}); export const coreRootDomainSetup = z.object({id: z.string(), alias: z.string().min(1).max(75), lock: coreIntentLockStatus, governingStrategy: coreGoverningStrategy.optional(), permissions: corePermissions, description: z.string().max(250).optional(), customProperties: coreStringsMap, users: z.array(coreCreateDomainGenesisUser), policies: z.array(coreCreateDomainGenesisPolicy), descendants: z.array(coreCreateDomainsPayload).optional()}); export const coreKeyType = z.enum(["Secp256r1", "Secp256k1", "Ed25519"]); export const coreGenesisCryptoSetup = z.object({apiSigning: coreKeyType, collectionSigning: coreKeyType, messageSigning: coreKeyType}); export const coreValidatedTickerKind = z.enum(["Native", "Contract", "Token"]); export const coreAlgorandTickerProperties = z.object({type: z.literal("Native")}); export const coreTickerLedgerDetailsAlgorand = z.object({properties: coreAlgorandTickerProperties, type: z.literal("Algorand")}); export const coreBitcoinTickerProperties = z.object({type: z.literal("Native")}); export const coreTickerLedgerDetailsBitcoin = z.object({properties: coreBitcoinTickerProperties, type: z.literal("Bitcoin")}); export const coreCardanoTickerProperties = z.object({type: z.literal("Native")}); export const coreTickerLedgerDetailsCardano = z.object({properties: coreCardanoTickerProperties, type: z.literal("Cardano")}); export const coreEthereumTickerPropertiesERC1155 = z.object({address: z.string().min(1).max(512), tokenId: z.string(), type: z.literal("ERC1155")}); export const coreEthereumTickerPropertiesERC20 = z.object({address: z.string().min(1).max(512), type: z.literal("ERC20")}); export const coreEthereumTickerPropertiesERC721 = z.object({address: z.string().min(1).max(512), tokenId: z.string(), type: z.literal("ERC721")}); export const coreEthereumTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreEthereumTickerProperties = z.discriminatedUnion("type", [coreEthereumTickerPropertiesERC1155, coreEthereumTickerPropertiesERC20, coreEthereumTickerPropertiesERC721, coreEthereumTickerPropertiesNative]); export const coreTickerLedgerDetailsEthereum = z.object({properties: coreEthereumTickerProperties, type: z.literal("Ethereum")}); export const coreHederaTickerPropertiesFungibleToken = z.object({id: z.string().min(5).max(20), type: z.literal("FungibleToken")}); export const coreHederaTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreHederaTickerPropertiesNonFungibleToken = z.object({id: z.string().min(5).max(20), serialNumber: z.number().int(), type: z.literal("NonFungibleToken")}); export const coreHederaTickerProperties = z.discriminatedUnion("type", [coreHederaTickerPropertiesFungibleToken, coreHederaTickerPropertiesNative, coreHederaTickerPropertiesNonFungibleToken]); export const coreTickerLedgerDetailsHedera = z.object({properties: coreHederaTickerProperties, type: z.literal("Hedera")}); export const coreSolanaTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreSolanaTokenType = z.enum(["SPL", "SPL2022"]); export const coreSolanaTickerPropertiesToken = z.object({mint: z.string().min(1).max(512), tokenType: coreSolanaTokenType, type: z.literal("Token")}); export const coreSolanaTickerProperties = z.discriminatedUnion("type", [coreSolanaTickerPropertiesNative, coreSolanaTickerPropertiesToken]); export const coreTickerLedgerDetailsSolana = z.object({properties: coreSolanaTickerProperties, type: z.literal("Solana")}); export const coreStellarTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreStellarTickerPropertiesToken = z.object({code: z.string().min(1).max(100), issuer: z.string().min(1).max(512), type: z.literal("Token")}); export const coreStellarTickerProperties = z.discriminatedUnion("type", [coreStellarTickerPropertiesNative, coreStellarTickerPropertiesToken]); export const coreTickerLedgerDetailsStellar = z.object({properties: coreStellarTickerProperties, type: z.literal("Stellar")}); export const coreSubstrateTickerProperties = z.object({type: z.literal("Native")}); export const coreTickerLedgerDetailsSubstrate = z.object({properties: coreSubstrateTickerProperties, type: z.literal("Substrate")}); export const coreTezosTickerProperties = z.object({type: z.literal("Native")}); export const coreTickerLedgerDetailsTezos = z.object({properties: coreTezosTickerProperties, type: z.literal("Tezos")}); export const coreTronTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreTronTickerPropertiesTRC20 = z.object({contractAddress: z.string().min(1).max(512), type: z.literal("TRC20")}); export const coreTronTickerProperties = z.discriminatedUnion("type", [coreTronTickerPropertiesNative, coreTronTickerPropertiesTRC20]); export const coreTickerLedgerDetailsTron = z.object({properties: coreTronTickerProperties, type: z.literal("Tron")}); export const coreXrplTickerPropertiesFungibleToken = z.object({currencyCode: z.string().min(1).max(100), issuer: z.string().min(25).max(35), type: z.literal("FungibleToken")}); export const coreXrplTickerPropertiesMultiPurposeToken = z.object({issuanceId: z.string(), type: z.literal("MultiPurposeToken")}); export const coreXrplTickerPropertiesNative = z.object({type: z.literal("Native")}); export const coreXrplTickerProperties = z.discriminatedUnion("type", [coreXrplTickerPropertiesFungibleToken, coreXrplTickerPropertiesMultiPurposeToken, coreXrplTickerPropertiesNative]); export const coreTickerLedgerDetailsXRPL = z.object({properties: coreXrplTickerProperties, type: z.literal("XRPL")}); export const coreTickerLedgerDetails = z.discriminatedUnion("type", [coreTickerLedgerDetailsAlgorand, coreTickerLedgerDetailsBitcoin, coreTickerLedgerDetailsCardano, coreTickerLedgerDetailsEthereum, coreTickerLedgerDetailsHedera, coreTickerLedgerDetailsSolana, coreTickerLedgerDetailsStellar, coreTickerLedgerDetailsSubstrate, coreTickerLedgerDetailsTezos, coreTickerLedgerDetailsTron, coreTickerLedgerDetailsXRPL]); export const coreTickerToValidate = z.object({id: z.string(), ledgerId: z.string().min(1).max(100), kind: coreValidatedTickerKind, name: z.string().min(1).max(100), decimals: z.number().int().optional(), symbol: z.string().min(1).max(100).optional(), ledgerDetails: coreTickerLedgerDetails, lock: coreIntentLockStatus, description: z.string().max(250).optional(), customProperties: coreStringsMap}); export const coreNotarySystemSignedIntentsEnabledValue = z.object({enabled: z.boolean()}); export const coreReadWriteSystemPropertyKeyValueNotarySystemSignedIntentsEnabledProperty = z.object({value: coreNotarySystemSignedIntentsEnabledValue, type: z.literal("NotarySystemSignedIntentsEnabledProperty")}); export const coreAccountPublicKeyOnly = z.object({value: z.string(), type: z.literal("PublicKey")}); export const coreStateReviewAuthorityValue = z.object({publicKey: coreAccountPublicKeyOnly}); export const coreReadWriteSystemPropertyKeyValueStateReviewAuthorityProperty = z.object({value: coreStateReviewAuthorityValue, type: z.literal("StateReviewAuthorityProperty")}); export const coreReadWriteSystemPropertyKeyValue = z.discriminatedUnion("type", [coreReadWriteSystemPropertyKeyValueNotarySystemSignedIntentsEnabledProperty, coreReadWriteSystemPropertyKeyValueStateReviewAuthorityProperty]); export const coreLedgerParametersAlgorand = z.object({genesisId: z.string().max(50), genesisHash: z.string().min(44).max(44), nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), nativeTickerDecimals: z.number().int(), type: z.literal("Algorand")}); export const coreBitcoinLikeVaultLedgerIdentifier = z.enum(["btc", "ltc", "bch", "doge", "dash"]); export const coreNetwork = z.enum(["mainnet", "testnet", "regtest"]); export const coreLedgerParametersBitcoin = z.object({supportsSegWit: z.boolean(), vaultLedgerIdentifier: coreBitcoinLikeVaultLedgerIdentifier, network: coreNetwork, tickerSymbol: z.string().min(1).max(100), tickerName: z.string().min(1).max(100), dustLimit: z.string(), type: z.literal("Bitcoin")}); export const coreLedgerParametersCardano = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), testnetMagic: z.number().int().gte(0).lte(4294967295).optional(), type: z.literal("Cardano")}); export const coreEthereumLikeVaultLedgerIdentifier = z.enum(["eth", "etc"]); export const coreLedgerParametersEthereum = z.object({chainId: z.number().int(), vaultLedgerIdentifier: coreEthereumLikeVaultLedgerIdentifier, nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), supportsEIP1559: z.boolean(), type: z.literal("Ethereum")}); export const coreLedgerParametersHedera = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), type: z.literal("Hedera")}); export const coreLedgerParametersSolana = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), lamportsPerSignature: z.string(), type: z.literal("Solana")}); export const coreLedgerParametersStellar = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), networkPassphrase: z.string().min(12).max(100), type: z.literal("Stellar")}); export const coreSubstrateFeeParameters = z.object({baseExtrinsic: z.number().int().gte(0), readWeight: z.number().int().gte(0), writeWeight: z.number().int().gte(0), transactionByteFee: z.string(), weightToFeePolynomial: z.array(z.string()), type: z.literal("TransactionPayment")}); export const coreSubstrateMethodFeeParameters = z.object({base: z.number().int().gte(0), reads: z.number().int().gte(0), writes: z.number().int().gte(0), type: z.literal("MethodWeight")}); export const coreSubstrateMethodInfo = z.object({name: z.string(), methodId: z.number().int(), feeParameters: coreSubstrateMethodFeeParameters}); export const coreSubstratePalletInfo = z.object({name: z.string(), moduleId: z.number().int(), methods: z.array(coreSubstrateMethodInfo)}); export const coreSubstrateChainType = z.enum(["RelayChain", "AssetHub"]); export const coreSubstrateRuntimeInfo = z.object({transactionVersion: z.number().int(), feeParameters: coreSubstrateFeeParameters, pallets: z.array(coreSubstratePalletInfo), chainType: coreSubstrateChainType.optional()}); export const coreLedgerParametersSubstrate = z.object({genesisHash: z.string(), addressPrefix: z.number().int().gte(0).lte(16383), nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), nativeTickerDecimals: z.number().int(), supportedRuntimeVersions: z.array(coreSubstrateRuntimeInfo), type: z.literal("Substrate")}); export const coreLedgerParametersTezos = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), chainId: z.string(), type: z.literal("Tezos")}); export const coreLedgerParametersTron = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), type: z.literal("Tron")}); export const coreLedgerParametersXRPL = z.object({nativeTickerSymbol: z.string().min(1).max(100), nativeTickerName: z.string().min(1).max(100), networkId: z.number().int(), type: z.literal("XRPL")}); export const coreLedgerParameters = z.discriminatedUnion("type", [coreLedgerParametersAlgorand, coreLedgerParametersBitcoin, coreLedgerParametersCardano, coreLedgerParametersEthereum, coreLedgerParametersHedera, coreLedgerParametersSolana, coreLedgerParametersStellar, coreLedgerParametersSubstrate, coreLedgerParametersTezos, coreLedgerParametersTron, coreLedgerParametersXRPL]); export const coreCreateLedgerGenesis = z.object({id: z.string(), alias: z.string().min(1).max(200), parameters: coreLedgerParameters, description: z.string().max(250).optional(), customProperties: coreStringsMap}); export const coreGenesisPayload = z.object({rootDomainSetup: coreRootDomainSetup, cryptoSetup: coreGenesisCryptoSetup, tickers: z.array(coreTickerToValidate).optional(), systemProperties: z.array(coreReadWriteSystemPropertyKeyValue).optional(), ledgers: z.array(coreCreateLedgerGenesis).optional(), systemSignaturesPublicKey: z.string().optional()}); export const coreGenesisData = z.object({executedAt: z.string(), payload: coreGenesisPayload}); export const coreGenesis = z.object({data: coreGenesisData, signature: z.string()}); export const coreCreatedEntitiesReferencesUser = z.object({id: z.string()}); export const coreCreatedEntitiesReferencesPolicy = z.object({id: z.string()}); export const coreCreatedEntitiesReferences = z.object({rootUsers: z.array(coreCreatedEntitiesReferencesUser), rootPolicies: z.array(coreCreatedEntitiesReferencesPolicy)}); export const coreGenesisSucceeded = z.object({apiPublicKey: z.string(), messagingPublicKey: z.string(), genesis: coreGenesis.optional(), createdEntitiesReferences: coreCreatedEntitiesReferences.optional(), systemSignaturesPublicKey: z.string().optional(), type: z.literal("GenesisSucceeded")}); export const coreIntentClosed = z.object({id: z.string(), type: z.literal("IntentClosed")}); export const coreIntentCreated = z.object({id: z.string(), type: z.literal("IntentCreated")}); export const coreIntentExecuted = z.object({id: z.string(), type: z.literal("IntentExecuted")}); export const coreIntentUpdated = z.object({id: z.string(), type: z.literal("IntentUpdated")}); export const coreLedgerCreated = z.object({id: z.string().min(1).max(100), type: z.literal("LedgerCreated")}); export const coreLedgerUpdated = z.object({id: z.string().min(1).max(100), type: z.literal("LedgerUpdated")}); export const coreManifestCreated = z.object({id: z.string(), accountId: z.string().optional(), type: z.literal("ManifestCreated")}); export const coreManifestUpdated = z.object({id: z.string(), accountId: z.string().optional(), type: z.literal("ManifestUpdated")}); export const corePolicyCreated = z.object({id: z.string(), type: z.literal("PolicyCreated")}); export const corePolicyUpdated = z.object({id: z.string(), type: z.literal("PolicyUpdated")}); export const coreQuarantineApplied = z.object({transferId: z.string(), type: z.literal("QuarantineApplied")}); export const coreQuarantineSkipped = z.object({transferId: z.string(), type: z.literal("QuarantineSkipped")}); export const coreSystemPropertyId = z.enum(["NOTARY_COMMUNICATION_KEY", "NOTARY_COLLECTIONS_KEY", "NOTARY_API_KEY", "STATE_REVIEW_AUTHORITY", "NOTARY_SYSTEM_SIGNING_KEY", "NOTARY_SYSTEM_SIGNED_INTENTS_ENABLED"]); export const coreSystemPropertySet = z.object({id: coreSystemPropertyId, type: z.literal("SystemPropertySet")}); export const coreTickerCreated = z.object({id: z.string(), type: z.literal("TickerCreated")}); export const coreTickerUpdated = z.object({id: z.string(), type: z.literal("TickerUpdated")}); export const coreTransactionCreated = z.object({id: z.string(), senderReferences: z.array(coreAccountReference), type: z.literal("TransactionCreated")}); export const coreTransactionDetected = z.object({id: z.string(), accountReferences: z.array(coreAccountReference), type: z.literal("TransactionDetected")}); export const coreTransactionUpdated = z.object({id: z.string(), accountReferences: z.array(coreAccountReference), type: z.literal("TransactionUpdated")}); export const coreTransferUpdated = z.object({id: z.string(), type: z.literal("TransferUpdated")}); export const coreTrustedPublicKeyPurpose = z.enum(["ApiSignatures", "TrustedCollectionSignatures", "MessagingSignatures", "SystemSignatures"]); export const coreTrustedPublicKeyAdded = z.object({publicKey: z.string(), signingPurpose: coreTrustedPublicKeyPurpose, type: z.literal("TrustedPublicKeyAdded")}); export const coreTrustedPublicKeyUpdated = z.object({publicKey: z.string(), signingPurpose: coreTrustedPublicKeyPurpose, type: z.literal("TrustedPublicKeyUpdated")}); export const coreUserCreated = z.object({id: z.string(), type: z.literal("UserCreated")}); export const coreUserUpdated = z.object({id: z.string(), type: z.literal("UserUpdated")}); export const coreVaultCreated = z.object({id: z.string(), type: z.literal("VaultCreated")}); export const coreVaultKeyMaterialRewrapCompleted = z.object({id: z.string(), type: z.literal("VaultKeyMaterialRewrapCompleted")}); export const coreVaultKeyMaterialRewrapFailed = z.object({id: z.string(), type: z.literal("VaultKeyMaterialRewrapFailed")}); export const coreVaultUpdated = z.object({id: z.string(), type: z.literal("VaultUpdated")}); export const coreHarmonizeEventPayload = z.discriminatedUnion("type", [coreAccountCreated, coreAccountUpdated, coreAddressCreated, coreBackupCreated, coreBackupUpdated, coreBalancesUpdated, coreComplianceConfigurationUpdated, coreDomainCreated, coreDomainUpdated, coreEndpointCreated, coreEndpointUpdated, coreGenesisSucceeded, coreIntentClosed, coreIntentCreated, coreIntentExecuted, coreIntentUpdated, coreLedgerCreated, coreLedgerUpdated, coreManifestCreated, coreManifestUpdated, corePolicyCreated, corePolicyUpdated, coreQuarantineApplied, coreQuarantineSkipped, coreSystemPropertySet, coreTickerCreated, coreTickerUpdated, coreTransactionCreated, coreTransactionDetected, coreTransactionUpdated, coreTransferUpdated, coreTrustedPublicKeyAdded, coreTrustedPublicKeyUpdated, coreUserCreated, coreUserUpdated, coreVaultCreated, coreVaultKeyMaterialRewrapCompleted, coreVaultKeyMaterialRewrapFailed, coreVaultUpdated]); export const coreHarmonizeEvent = z.object({domainId: z.string(), payload: coreHarmonizeEventPayload, id: z.string(), sequenceNumber: z.number().int(), savedAt: z.string()}); export const coreEventsCollection = z.object({items: z.array(coreHarmonizeEvent), count: z.number().int(), currentStartingAfter: z.string().optional(), nextStartingAfter: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List events * * GET /v1/domains/{domainId}/events */ export const getApiV1DomainsDomainIdEvents = async (args: GetApiV1DomainsDomainIdEventsArgs, options: GetApiV1DomainsDomainIdEventsOptions) => { const {baseUrl, fetch: fetchFn = fetch, httpAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.startingAfter != null) query.append("startingAfter", String(args.startingAfter)) if (args.sortBy != null) query.append("sortBy", String(args.sortBy)) if (args.sortOrder != null) query.append("sortOrder", String(args.sortOrder)) if (args.scope != null) query.append("scope", String(args.scope)) if (httpAuth !== undefined) headers.set('authorization', `Bearer ${httpAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/domains/${encodeURIComponent(String(args.domainId))}/events${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(coreEventsCollection, await res.json()) };