UNPKG

@taqueria/protocol

Version:

A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.

558 lines (557 loc) • 15.2 kB
/** @minLength 1 */ export type NonEmptyString = { __type: NonEmptyString; } & string; /** @pattern ^[A-Za-z]$ */ export type SingleChar = { __type: SingleChar; } & SingleCharRaw; type SingleCharRaw = NonEmptyString; /** @pattern ^[A-Za-z\-\ ]+ */ export type Verb = { __type: Verb; } & VerbRaw; type VerbRaw = NonEmptyString; export type Alias = { __type: Alias; } & AliasRaw; type AliasRaw = Verb | SingleChar; /** @pattern ^[A-Za-z]+[A-Za-z0-9-_ ]*$ */ export type HumanReadableIdentifier = { __type: HumanReadableIdentifier; } & HumanReadableIdentifierRaw; type HumanReadableIdentifierRaw = NonEmptyString; export type SanitizedAbsPath = { __type: SanitizedAbsPath; } & SanitizedAbsPathRaw; type SanitizedAbsPathRaw = NonEmptyString; export type SanitizedPath = { __type: SanitizedPath; } & SanitizedPathRaw; type SanitizedPathRaw = NonEmptyString; export type Settings = { __type: Settings; } & { consent: 'opt_in' | 'opt_out' | 'unspecified'; }; /** * @minimum 1651846877 * @integer */ export type Timestamp = { __type: Timestamp; } & number; /** * @minLength 1 * @pattern ^\d([\d_]+\d)?$ */ export type Tz = { __type: Tz; } & TzRaw; type TzRaw = NonEmptyString; /** * @minLength 1 * @pattern ^\d+\.\d+(\.\d+)*$ */ export type VersionNumber = { __type: VersionNumber; } & VersionNumberRaw; type VersionNumberRaw = NonEmptyString; /** @format url */ export type Url = { __type: Url; } & UrlRaw; type UrlRaw = NonEmptyString; /** interpreted using yargs @pattern ^([A-Za-z-_ ]+ ?)((\[.+\] ?)|(\<.+\>) ?)*$ */ export type Command = { __type: Command; } & CommandRaw; type CommandRaw = NonEmptyString; export type Option = { __type: Option; } & { shortFlag?: SingleChar; flag: Verb; description: NonEmptyString; defaultValue?: string | number | boolean; type?: 'string' | 'number' | 'boolean' | 'count'; required?: boolean; boolean?: boolean; choices?: NonEmptyString[]; }; export type PositionalArg = { __type: PositionalArg; } & { placeholder: HumanReadableIdentifier; description: NonEmptyString; defaultValue?: string | number | boolean; type?: 'string' | 'number' | 'boolean'; required?: boolean; }; export type InstalledPlugin = { __type: InstalledPlugin; } & { type: 'npm' | 'binary' | 'deno'; name: NonEmptyString; }; export type Operation = { __type: Operation; } & { operation: Verb; command: Command; description?: NonEmptyString; positionals?: PositionalArg[]; options?: Option[]; handler?: (args: PersistentState) => (args: RequestArgs) => void; }; export type ParsedOperation = { __type: ParsedOperation; } & ParsedOperationRaw; type ParsedOperationRaw = Omit<Operation, 'handler'>; export type Template = { __type: Template; } & { template: Verb; command: Command; description: NonEmptyString; hidden?: boolean; options?: Option[]; positionals?: PositionalArg[]; handler: TemplateHandler; encoding?: PluginResponseEncoding; }; type TemplateHandler = NonEmptyString | ((args: RequestArgs) => PluginJsonResponse | Promise<PluginJsonResponse>) | Promise<void>; export type ParsedTemplate = { __type: ParsedTemplate; } & ParsedTemplateRaw; type ParsedTemplateRaw = Omit<Template, 'handler'> & { handler: string; }; type PluginSchemaBase = { name: NonEmptyString; version: VersionNumber; schema: VersionNumber; alias: Alias; tasks?: Task[]; postInstall?: string; }; export type PluginInfo = { __type: PluginInfo; } & PluginInfoRaw; type PluginInfoRaw = PluginSchemaBase & { operations?: ParsedOperation[]; templates?: ParsedTemplate[]; }; export type PluginSchema = { __type: PluginSchema; } & PluginSchemaRaw; type PluginSchemaRaw = PluginSchemaBase & { operations?: Operation[]; templates?: Template[]; proxy?: (args: RequestArgs) => Promise<PluginProxyResponse>; checkRuntimeDependencies?: (args: RequestArgs) => Promise<PluginDependenciesResponse>; installRuntimeDependencies?: (args: RequestArgs) => Promise<PluginDependenciesResponse>; }; export type Task = { __type: Task; } & { task: Verb; command: Command; aliases?: Alias[]; /** @minLength 3 */ description?: NonEmptyString; example?: NonEmptyString; hidden?: boolean; encoding?: PluginResponseEncoding; handler: 'proxy' | NonEmptyString; options?: Option[]; positionals?: PositionalArg[]; }; export type RuntimeDependency = { __type: RuntimeDependency; } & { name: HumanReadableIdentifier; path: string; version: string; kind: 'required' | 'optional'; }; export type RuntimeDependencyReport = { __type: RuntimeDependencyReport; } & RuntimeDependencyReportRaw; type RuntimeDependencyReportRaw = RuntimeDependency & { met: boolean; }; export type PluginDependenciesResponse = { __type: PluginDependenciesResponse; } & { report: RuntimeDependencyReport[]; }; export type PluginJsonResponse = { __type: PluginJsonResponse; } & { data?: unknown; messages?: { header?: string; footer?: string; }; /** @default none */ render: 'none' | 'table' | 'string'; } | void; export type PluginProxyResponse = { __type: PluginProxyResponse; } & PluginProxyResponseRaw; type PluginProxyResponseRaw = void | PluginJsonResponse; /** @default none */ export type PluginResponseEncoding = { __type: PluginResponseEncoding; } & PluginResponseEncodingRaw; type PluginResponseEncodingRaw = 'none' | 'json' | 'application/json'; /** * @min 100 */ export type BuildNumber = { __type: BuildNumber; } & number; export type SanitizedArgs = { __type: SanitizedArgs; } & { _: string[]; projectDir: SanitizedPath; maxConcurrency: number; debug: boolean; disableState: boolean; logPluginRequests: boolean; fromVsCode: boolean; version: boolean; build: boolean; help: boolean; yes: boolean; plugin?: NonEmptyString; env: NonEmptyString; quickstart: NonEmptyString; setBuild: NonEmptyString | BuildNumber; setVersion: NonEmptyString; }; export type PluginActionName = { __type: PluginActionName; } & PluginActionNameRaw; type PluginActionNameRaw = 'proxy' | 'pluginInfo' | 'checkRuntimeDependencies' | 'installRuntimeDependencies' | 'runPostInstall' | 'proxyTemplate'; export type RequestArgs = { __type: RequestArgs; } & RequestArgsRaw; type RequestArgsRaw = Omit<SanitizedArgs, 'quickstart'> & { taqRun: PluginActionName; config: LoadedConfig; }; export type ProxyTaskArgs = { __type: ProxyTaskArgs; } & ProxyTaskArgsRaw; type ProxyTaskArgsRaw = RequestArgs & { task: NonEmptyString; }; export type ProxyTemplateArgs = { __type: ProxyTemplateArgs; } & ProxyTemplateArgsRaw; type ProxyTemplateArgsRaw = RequestArgs & { template: NonEmptyString; }; /** @min 1 */ export type EconomicalProtocolHash = { __type: EconomicalProtocolHash; } & string; /** @pattern ^tz\d[A-Za-z0-9]{33}$ */ export type PublicKeyHash = { __type: PublicKeyHash; } & string; /** @pattern ^[A-Fa-f0-9]{64}$ */ export type SHA256 = { __type: SHA256; } & string; export type Contract = { __type: Contract; } & { sourceFile: NonEmptyString; hash: SHA256; }; export type Faucet = { __type: Faucet; } & { pkh: PublicKeyHash; mnemonic: string[]; /** @format email */ email: string; password: string; /** @pattern ^\d+$ */ amount: string; activation_code: string; }; /** Port number for postgresql container * @default 5432 */ type TzKtConfigPostgresqlPort = number; /** Port number for TzKt API * @default 5000 */ type TzKtConfigApiPort = number; export type TzKtConfig = { __type: TzKtConfig; } & { /** Do not start TzKt when sandbox starts */ disableAutostartWithSandbox?: boolean; postgresqlPort?: TzKtConfigPostgresqlPort; apiPort?: TzKtConfigApiPort; }; export type EphemeralState = { __type: EphemeralState; } & { build: string; configHash: string; /** Task/Plugin Mapping */ tasks: Record<string, InstalledPlugin & Task>; /** Operation/Plugin Mapping */ operations: Record<string, InstalledPlugin & ParsedOperation>; /** Templates/Plugin Mapping */ templates: Record<string, InstalledPlugin & ParsedTemplate>; plugins: PluginInfo[]; }; export type PersistentState = { __type: PersistentState; } & { operations: Record<string, PersistedOperation>; tasks: Record<string, PersistedTask>; }; export type PersistedTask = { __type: PersistedTask; } & { task: Verb; plugin: NonEmptyString; time: Timestamp; output?: unknown; }; export type PersistedOperation = { __type: PersistedOperation; } & { hash: SHA256; time: Timestamp; output?: unknown; }; /** * @minLength 1 * @pattern ^[A-Za-z0-9]+[A-Za-z0-9-_]+\.[A-Za-z0-9]+[A-Za-z0-9-_]+\.[A-Za-z0-9]+[A-Za-z0-9-_]+$ */ export type ProvisionerID = { __type: ProvisionerID; } & string; export type Provisioner = { __type: Provisioner; } & { id: ProvisionerID; plugin: NonEmptyString; operation: NonEmptyString | 'custom'; command?: string; label?: string; depends_on?: ProvisionerID[]; }; export type Provisions = { __type: Provisions; } & ProvisionsRaw; type ProvisionsRaw = Provisioner[]; export type Environment = { __type: Environment; } & { networks: NonEmptyString[]; sandboxes: NonEmptyString[]; storage?: Record<string, NonEmptyString>; aliases?: Record<string, Record<string, NonEmptyString>>; }; /** @minLength 1 Default environment must reference the name of an existing environment.*/ type EnvironmentName = NonEmptyString; /** @default en */ type HumanLanguage = 'en' | 'fr'; /** * @default contracts * @minLength 1 */ export type ConfigContractsDir = { __type: ConfigContractsDir; } & string; /** * @default artifacts * @minLength 1 */ export type ConfigArtifactsDir = { __type: ConfigArtifactsDir; } & string; export type ConfigAccount = { __type: ConfigAccount; } & { balance: CurrencyAmountV2; }; export type Config = { __type: Config; } & { language?: HumanLanguage; metadata?: MetadataConfig; artifactsDir?: ConfigArtifactsDir; contractsDir?: ConfigContractsDir; contracts?: Record<string, Contract>; plugins?: InstalledPlugin[]; accounts?: Record<string, Tz>; environment: Record<string, Environment | EnvironmentName>; network?: Record<string, NetworkConfig>; sandbox?: Record<string, SandboxConfig>; }; export type ConfigFileV1 = { __type: ConfigFileV1; } & { language?: HumanLanguage; plugins?: InstalledPlugin[]; contractsDir?: ConfigContractsDir; artifactsDir?: ConfigArtifactsDir; network?: Record<string, NetworkConfig>; sandbox?: Record<string, SandboxConfig>; environment?: Record<string, Environment | EnvironmentName>; accounts?: Record<string, Tz>; contracts?: Record<string, Contract>; metadata?: MetadataConfig; }; export type CurrencyAmountV2 = { __type: CurrencyAmountV2; } & { amount: string; units: string; }; /** * Workaround: zod won`t support VersionV2 = `v2` * @pattern ^v2$ */ type VersionV2 = string; export type ConfigFileV2 = { __type: ConfigFileV2; } & { version: VersionV2; language?: HumanLanguage; metadata?: MetadataConfig; artifactsDir?: ConfigArtifactsDir; contractsDir?: ConfigContractsDir; /** Declared accounts */ accounts?: Record<string, ConfigAccount>; contracts?: Record<string, Contract>; /** The default environment key */ environmentDefault?: EnvironmentName; /** Environments * * An environment represents a unique context on a network with its own account instances and contracts. * * The environment implementation is provided by a plugin which enables network control, account management, and contract interaction. * * Example environment types: * * - a sandbox running locally (using flextesa and taquito plugin) * - teztnets.xyz (using taquito plugin) * - mainnet (using taquito plugin with a custom rpcUrl) * * The environment implementation also implements the account types that are supported by that environmentType: * * - flextesa * - in-memory signer * - mainnet * - beacon wallet * - multi-sig * * Using the above as an example, the flextesa sandbox only needs an in-memory signer since it generates it's own accounts, * but mainnet might support something like a beacon wallet or a multi-sig account. */ environments?: Record<string, ConfigEnvironmentFileV2>; plugins?: InstalledPlugin[]; }; /** Account overrides for this environment */ export type SandboxAccount = { __type: SandboxAccount; } & { type?: string; }; export type SandboxAccounts = { __type: SandboxAccounts; } & SandboxAccountsRaw; type SandboxAccountsRaw = Record<string, SandboxAccount>; export type ConfigEnvironmentFileV2 = { __type: ConfigEnvironmentFileV2; } & { /** environment types provided by plugins * * Examples: flextesa, teztnet, mainnet * * annotations provides plugin specific data like rpcUrl */ type?: string; accounts?: SandboxAccounts; accountDefault?: keyof SandboxAccounts; /** Contract deployment data for this environment */ contracts?: Record<string, { address?: string; }>; }; export type LoadedConfig = { __type: LoadedConfig; } & LoadedConfigRaw; type LoadedConfigRaw = Config & { projectDir: SanitizedAbsPath; configFile: SanitizedAbsPath; hash: SHA256; }; export type MetadataConfig = { __type: MetadataConfig; } & { name?: string; projectDescription?: string; authors?: string[]; license?: string; homepage?: string; }; export type NetworkConfig = { __type: NetworkConfig; } & { label: HumanReadableIdentifier; rpcUrl: Url; accounts?: Record<string, NetworkAccountConfig>; faucet?: Faucet; }; export type NetworkAccountConfig = { __type: NetworkAccountConfig; } & { publicKey?: NonEmptyString; publicKeyHash?: PublicKeyHash; privateKey?: NonEmptyString; /** TODO: Should this be secretKey: @see {SandboxAccountConfig} */ mnemonic?: NonEmptyString; }; export type SandboxAccountConfig = { __type: SandboxAccountConfig; } & { encryptedKey?: NonEmptyString; publicKeyHash: PublicKeyHash; secretKey: NonEmptyString; }; export type SandboxConfig = { __type: SandboxConfig; } & { label: NonEmptyString; rpcUrl: Url; protocol?: EconomicalProtocolHash; plugin?: Verb; blockTime?: number; baking?: 'enabled' | 'disabled'; accounts?: Record<string, SandboxAccountConfig | NonEmptyString>; tzkt?: TzKtConfig; annotations?: Record<string, unknown>; }; export type ScaffoldConfig = { __type: ScaffoldConfig; } & { postInit?: string; }; export type ParsedConfig = { __type: ParsedConfig; } & ParsedConfigRaw; type ParsedConfigRaw = Omit<Config, 'sandbox'> & { sandbox: Record<string, SandboxConfig | NonEmptyString>; }; export {};