/* eslint-disable */ /* generated by definy. Do not edit! */ /** * UserId, ProjectIdなどのIdをバイナリ形式にエンコードする */ export const encodeId = (value: string): globalThis.ReadonlyArray => (globalThis.Array.from({ length: 16 }, (_: undefined, i: number): number => (globalThis.Number.parseInt(value.slice(i * 2, i * 2 + 2), 16)))); /** * バイナリ形式をUserId, ProjectIdなどのIdにデコードする * @param index バイナリを読み込み開始位置 * @param binary バイナリ */ export const decodeId = (index: number, binary: globalThis.Uint8Array): { readonly result: string; readonly nextIndex: number } => ({ result: [...binary.slice(index, index + 16)].map((n: number): string => (n.toString(16).padStart(2, "0"))).join(""), nextIndex: index + 16 }); /** * ImageTokenなどのTokenをバイナリ形式にエンコードする */ export const encodeToken = (value: string): globalThis.ReadonlyArray => (globalThis.Array.from({ length: 32 }, (_: undefined, i: number): number => (globalThis.Number.parseInt(value.slice(i * 2, i * 2 + 2), 16)))); /** * バイナリ形式をImageTokenなどのTokenにエンコードする * @param index バイナリを読み込み開始位置 * @param binary バイナリ */ export const decodeToken = (index: number, binary: globalThis.Uint8Array): { readonly result: string; readonly nextIndex: number } => ({ result: [...binary.slice(index, index + 32)].map((n: number): string => (n.toString(16).padStart(2, "0"))).join(""), nextIndex: index + 32 }); /** * バイナリと相互変換するための関数 */ export type Codec = { readonly encode: (a: T) => globalThis.ReadonlyArray; readonly decode: (a: number, b: globalThis.Uint8Array) => { readonly result: T; readonly nextIndex: number } }; /** * バリアント. 値コンストラクタ. タグ * @typePartId 0bc2e5ab2fd2caeb6e6c331573ae735f */ export type ElmVariant = { /** * バリアント名 */ readonly name: ElmVariantName; /** * パラメーター */ readonly parameter: List }; /** * 外部に公開する定義 * @typePartId 0c8b854b812290a054877ca5de6c4daf */ export type ExportDefinition = { readonly _: "TypeAlias"; readonly typeAlias: TypeAlias } | { readonly _: "Function"; readonly function: Function } | { readonly _: "Variable"; readonly variable: Variable }; /** * 単項演算子と適用される式 * @typePartId 0cb0a34b3953e57b30f4a5c8f9d305da */ export type UnaryOperatorExpr = { /** * 単項演算子 */ readonly operator: UnaryOperator; /** * 適用される式 */ readonly expr: TsExpr }; /** * プロジェクトの識別子 * @typePartId 0cd913118a2ad1469d656146a08c5f76 */ export type ProjectId = string & { readonly _projectId: never }; /** * 英語,日本語,エスペラント語 * * ナルミンチョが使える? プログラミングじゃない言語 * @typePartId 0d9510723f4d34605e41f3a47a8b0ea7 */ export type Language = "Japanese" | "English" | "Esperanto"; /** * Elmで使う型の名前. Elmで使える型名ということを確認済み * @typePartId 13e52324ba81c7ffe655455ad739ea73 */ export type ElmTypeName = { readonly _: "ElmTypeName"; readonly string: String }; /** * -2 147 483 648 ~ 2 147 483 647. 32bit 符号付き整数. JavaScriptのnumberとして扱える. numberの32bit符号あり整数をSigned Leb128のバイナリに変換する * @typePartId 16c2d8602e3e5e2d38b9215bd0c44d8d */ export type Int32 = number; /** * Elm の 型 * @typePartId 173f661790b059baf212043f816ba1a9 */ export type ElmType = { readonly _: "ImportedType"; readonly elmImportedType: ElmImportedType } | { readonly _: "TypeParameter"; readonly string: String } | { readonly _: "Function"; readonly elmFunctionType: ElmFunctionType } | { readonly _: "List"; readonly elmType: ElmType } | { readonly _: "Tuple0" } | { readonly _: "Tuple2"; readonly elmTuple2: ElmTuple2 } | { readonly _: "Tuple3"; readonly elmTuple3: ElmTuple3 } | { readonly _: "Record"; readonly elmFieldList: List } | { readonly _: "LocalType"; readonly elmLocalType: ElmLocalType }; /** * @typePartId 1835ebdc909b0fa93d11ae0ed93d0606 */ export type TsType = { readonly _: "Number" } | { readonly _: "String" } | { readonly _: "Boolean" } | { readonly _: "Undefined" } | { readonly _: "Null" } | { readonly _: "Never" } | { readonly _: "Void" } | { readonly _: "Object"; readonly tsMemberTypeList: List } | { readonly _: "Function"; readonly functionType: FunctionType } | { readonly _: "WithTypeParameter"; readonly tsTypeWithTypeParameter: TsTypeWithTypeParameter } | { readonly _: "Union"; readonly tsTypeList: List } | { readonly _: "Intersection"; readonly intersectionType: IntersectionType } | { readonly _: "ImportedType"; readonly importedType: ImportedType } | { readonly _: "ScopeInFile"; readonly tsIdentifier: TsIdentifier } | { readonly _: "ScopeInGlobal"; readonly tsIdentifier: TsIdentifier } | { readonly _: "StringLiteral"; readonly string: String }; /** * Project, Account, TypePartなどのリソースの状態とデータ. 読み込み中だとか * @typePartId 18cbd2fa4bd72a0eacf3f0f44aeb6feb */ export type ResourceState = { readonly _: "Loaded"; readonly dataWithTime: WithTime } | { readonly _: "Deleted"; readonly time: Time } | { readonly _: "Unknown"; readonly time: Time } | { readonly _: "Requesting" }; /** * Unit. 1つの値しかない型. JavaScriptのundefinedで扱う * @typePartId 217263d8cdca613c2d1ba77e19d4cbb0 */ export type Unit = undefined; /** * コンパイラに向けた, 型のデータ形式をどうするかの情報 * @typePartId 22d8f2d392c573a7aa54c39fa4c98ad0 */ export type TypeAttribute = "AsBoolean" | "AsUndefined" | "AsNumber"; /** * @typePartId 2392b884a9c2238a65ecd272bd23a9cd */ export type ElmField = { /** * フィールド名 */ readonly name: ElmFieldName; /** * 型 */ readonly type: ElmType }; /** * パラメーター付きの型 * @typePartId 23fa0e8b66c9d093d4c18579ffefaaa3 */ export type TsTypeWithTypeParameter = { /** * パラメーターをつけられる型 */ readonly type: TsType; /** * パラメーターに指定する型. なにも要素を入れなけければ T<>ではなく T の形式で出力される */ readonly typeParameterList: List }; /** * 評価したときに失敗した原因を表すもの * @typePartId 25d0af5522da614f7617016ca7868edd */ export type EvaluateExprError = { readonly _: "NeedPartDefinition"; readonly partId: PartId } | { readonly _: "Blank" } | { readonly _: "TypeError"; readonly string: String } | { readonly _: "NotSupported" }; /** * TypeScriptの識別子として使える文字 * @typePartId 2a75ad7c7ccc58ba56f6c8545c8150d1 */ export type TsIdentifier = { readonly _: "Identifier"; readonly string: String }; /** * モジュール内の型 * @typePartId 2b42264a878355f0257141fa013fed5c */ export type ElmLocalType = { /** * 型名 */ readonly typeName: ElmTypeName; /** * 型パラメーター */ readonly parameter: List }; /** * 関数呼び出し * @typePartId 2f9784d2c41d0974487a1ca2b0a51ec5 */ export type FunctionCall = { /** * 関数 */ readonly function: Expr; /** * パラメーター */ readonly parameter: Expr }; /** * Maybe. nullableのようなもの. 今後はRustのstd::Optionに出力するために属性をつけよう (確信) * @typePartId 304f21ae8208a21d08731aa6d183742d */ export type Maybe = { readonly _: "Just"; readonly value: value } | { readonly _: "Nothing" }; /** * 配列リテラルの要素 * @typePartId 35f7e442c0838f9982e6b49da398d97f */ export type ArrayItem = { /** * 式 */ readonly expr: TsExpr; /** * スプレッド ...a のようにするか */ readonly spread: Bool }; /** * バイナリ. JavaScriptのUint8Arrayで扱える. 最初にLED128でバイト数, その次にバイナリそのまま * @typePartId 3e2f740c88923b0393a1ef93d92f157b */ export type Binary = globalThis.Uint8Array; /** * 3つの要素のタプルの型 * @typePartId 42e5ab4936af4abf8673472ce96fd794 */ export type ElmTuple3 = { /** * 左の型 */ readonly first: ElmType; /** * 真ん中の型 */ readonly second: ElmType; /** * 右の型 */ readonly third: ElmType }; /** * 外部のモジュールの型 * @typePartId 43aa21ed2225cacc4489c30113e87787 */ export type ElmImportedType = { /** * モジュール名 */ readonly moduleName: String; /** * 型名 */ readonly typeName: ElmTypeName; /** * 型パラメーター */ readonly parameter: List }; /** * 2項演算子 * @typePartId 4953938f040aefdaa5f2601e2a78d43b */ export type BinaryOperator = "Exponentiation" | "Multiplication" | "Division" | "Remainder" | "Addition" | "Subtraction" | "LeftShift" | "SignedRightShift" | "UnsignedRightShift" | "LessThan" | "LessThanOrEqual" | "Equal" | "NotEqual" | "BitwiseAnd" | "BitwiseXOr" | "BitwiseOr" | "LogicalAnd" | "LogicalOr"; /** * 型アサーション * @typePartId 49f05a756bd75da670fa5b64ed8bf1ae */ export type TypeAssertion = { /** * 型アサーションを受ける式 */ readonly expr: TsExpr; /** * 型 */ readonly type: TsType }; /** * JavaScriptの単項演算子 * @typePartId 4b4c3f8f34d1c05bb9d7d1b930bc9c9a */ export type UnaryOperator = "Minus" | "BitwiseNot" | "LogicalNot"; /** * 型の定義本体 * @typePartId 4c60c73d6b8f236d34281fbb9119a598 */ export type TypePartBody = { readonly _: "Product"; readonly memberList: List } | { readonly _: "Sum"; readonly patternList: List } | { readonly _: "Kernel"; readonly typePartBodyKernel: TypePartBodyKernel }; /** * カスタム型の公開レベル * @typePartId 4e1cab8c9074c1a058d6ef3ffcf29ab0 */ export type ElmCustomTypeExportLevel = "NoExport" | "ExportTypeOnly" | "ExportTypeAndVariant"; /** * 関数のパラメーター. パラメーター名, 型 * @typePartId 5433bade7738da21e7663ff043f588d5 */ export type Parameter = { /** * パラメーター名 */ readonly name: TsIdentifier; /** * パラメーターの型 */ readonly type: TsType }; /** * 辞書型. TypeScriptでは ReadonlyMap として扱う * @typePartId 5516d41d180b98b7f5a8950d4f43dfd6 */ export type Dict = globalThis.ReadonlyMap; /** * 取得日時と任意のデータ * @typePartId 55d4de38cfb884b9008abd7f7f63325e */ export type WithTime = { /** * データベースから取得した日時 */ readonly getTime: Time; /** * データ */ readonly data: data }; /** * 型エイリアス. 型に名前を付け, レコード型の場合, その名前の関数を作成する * @typePartId 57f429fd5c67eb2542447a2eaeb34497 */ export type ElmTypeAlias = { /** * 型エイリアス名 */ readonly name: ElmTypeName; /** * 外部に公開するか */ readonly export: Bool; /** * コメント */ readonly comment: String; /** * 型パラメーター */ readonly parameter: List; /** * 別名を付ける型 */ readonly type: ElmType }; /** * パーツの識別子 * @typePartId 5880cd7c0b6f0205c739a06181898d03 */ export type PartId = string & { readonly _partId: never }; /** * AccountToken と AccountId * @typePartId 5d291325e9d7bc27ff35e907f59bde54 */ export type AccountTokenAccountId = { /** * accountToken */ readonly accountToken: AccountToken; /** * accountId */ readonly accountId: AccountId }; /** * タグの識別子. タグは直和型に使うもの. * * 実行時に使わないことは確定しているが, コード内の形式としてタグにUUIDを使うべきかは考慮中. index で充分かと思ったが別に型の情報も必要になることが多い * @typePartId 5ec292c48424e5e9ee8cc2d672830ecd */ export type TagId = string & { readonly _tagId: never }; /** * 関数の型. 入力と出力 * @typePartId 5ec9dae951d8d2b250c81185a259adca */ export type ElmFunctionType = { /** * 入力の型 */ readonly input: ElmType; /** * 出力の型 */ readonly output: ElmType }; /** * switch文のcase "text": { statementList } の部分 * @typePartId 6126431def47ecba239b3add7f472b19 */ export type TsPattern = { /** * case に使う文字列 */ readonly caseString: String; /** * マッチしたときに実行する部分 */ readonly statementList: List }; /** * Elmのコードを表現するもの * @typePartId 62923d32a2730114e665cef13f93ff13 */ export type ElmCode = { /** * モジュール名 */ readonly moduleName: String; /** * 型定義 */ readonly typeDeclarationList: List }; /** * definyだけでは表現できないデータ型 * @typePartId 657b5a5519b095480a21fdadd0f6fbd1 */ export type TypePartBodyKernel = "Int32" | "String" | "Binary" | "Id" | "Token" | "List" | "Dict"; /** * 文字列. JavaScriptのstringで扱う. バイナリ形式はUTF-8. 不正な文字が入っている可能性がある * @typePartId 666361c9ae68ab64f273c47f3feb8c73 */ export type String = string; /** * ユーザー名. 表示される名前. 他のユーザーとかぶっても良い. 絵文字も使える. 全角英数は半角英数,半角カタカナは全角カタカナ, (株)の合字を分解するなどのNFKCの正規化がされる. U+0000-U+0019 と U+007F-U+00A0 の範囲の文字は入らない. 前後に空白を含められない. 間の空白は2文字以上連続しない. 文字数のカウント方法は正規化されたあとのCodePoint単位. Twitterと同じ, 1文字以上50文字以下 * @typePartId 67d4e3bc4f13e1132b6c5e81d5b74395 */ export type Account = { /** * プロフィール画像 */ readonly imageHash: ImageHash; /** * initMemberDescription */ readonly introduction: String; /** * definyでユーザーが作成された日時 */ readonly createTime: Time; /** * アカウント名. 表示される名前. 他のユーザーとかぶっても良い. 絵文字も使える. 全角英数は半角英数,半角カタカナは全角カタカナ, (株)の合字を分解するなどのNFKCの正規化がされる. U+0000-U+0019 と U+007F-U+00A0 の範囲の文字は入らない. 前後に空白を含められない. 間の空白は2文字以上連続しない. 文字数のカウント方法は正規化されたあとのCodePoint単位. Twitterと同じ, 1文字以上50文字以下 */ readonly name: String; /** * アカウントを識別するID */ readonly id: AccountId }; /** * キーであるTokenによってデータが必ず1つに決まるもの. 絶対に更新されない. リソースがないということはデータが不正な状態になっているということ * @typePartId 68d925f7b35bab8f265cd9e5eb7ea3da */ export type StaticResourceState = { readonly _: "Loaded"; readonly data: data } | { readonly _: "Unknown" } | { readonly _: "Loading" } | { readonly _: "Requesting" }; /** * 代入文 * @typePartId 6a5a7886b0f117a50d9d7b11ffe87c9f */ export type SetStatement = { /** * 対象となる式. 指定の仕方によってはJSのSyntaxErrorになる */ readonly target: TsExpr; /** * 演算子を=の左につける */ readonly operatorMaybe: Maybe; /** * 式 */ readonly expr: TsExpr }; /** * ドキュメント付きの関数のパラメーター. パラメーター名, ドキュメント, 型 * @typePartId 6b05e33009ade6b4decd452e8fd4bff1 */ export type ParameterWithDocument = { /** * パラメーター名 */ readonly name: TsIdentifier; /** * ドキュメント */ readonly document: String; /** * パラメーターの型 */ readonly type: TsType }; /** * 型パーツの識別子. データ型パラメータが含まれることはなくなった * @typePartId 6e3cff317f8bfbbd1391c0afb9ad6b72 */ export type TypePartId = string & { readonly _typePartId: never }; /** * 成功と失敗を表す型. 今後はRustのstd::Resultに出力するために属性をつける? * @typePartId 6f937e46fce1cf70d29c54780f132c18 */ export type Result = { readonly _: "Ok"; readonly ok: ok } | { readonly _: "Error"; readonly error: error }; /** * 言語とページの場所. URLとして表現されるデータ * @typePartId 7210f04a85c5f0f58f7aa20826d67f05 */ export type LocationAndLanguage = { /** * 場所 */ readonly location: Location; /** * 言語 */ readonly language: Language }; /** * switch文 * @typePartId 725f84ef82e6c3b5b5f6fd5208977dd8 */ export type SwitchStatement = { /** * switch(a) {} の a */ readonly expr: TsExpr; /** * case "text": { statementList } */ readonly patternList: List }; /** * ローカル変数定義 * @typePartId 7277cf2483388ee2f5ad7a7fc8585d98 */ export type VariableDefinitionStatement = { /** * 変数名 */ readonly name: TsIdentifier; /** * 変数の型 */ readonly type: TsType; /** * 式 */ readonly expr: TsExpr; /** * constかどうか. falseはlet */ readonly isConst: Bool }; /** * プロジェクト作成時に必要なパラメーター * @typePartId 7b987551cc112a64f5c9a8cb1647f4bd */ export type CreateProjectParameter = { /** * プロジェクトを作るときのアカウント */ readonly accountToken: AccountToken; /** * プロジェクト名 */ readonly projectName: String }; /** * JavaScript の 文 * @typePartId 7c957d411f448a03764f16d43e6e5008 */ export type Statement = { readonly _: "EvaluateExpr"; readonly tsExpr: TsExpr } | { readonly _: "Set"; readonly setStatement: SetStatement } | { readonly _: "If"; readonly ifStatement: IfStatement } | { readonly _: "ThrowError"; readonly tsExpr: TsExpr } | { readonly _: "Return"; readonly tsExpr: TsExpr } | { readonly _: "ReturnVoid" } | { readonly _: "Continue" } | { readonly _: "VariableDefinition"; readonly variableDefinitionStatement: VariableDefinitionStatement } | { readonly _: "FunctionDefinition"; readonly functionDefinitionStatement: FunctionDefinitionStatement } | { readonly _: "For"; readonly forStatement: ForStatement } | { readonly _: "ForOf"; readonly forOfStatement: ForOfStatement } | { readonly _: "WhileTrue"; readonly statementList: List } | { readonly _: "Break" } | { readonly _: "Switch"; readonly switchStatement: SwitchStatement }; /** * 日時. `0001-01-01T00:00:00.000Z to 9999-12-31T23:59:59.999Z` 最小単位はミリ秒. ミリ秒の求め方は `day*1000*60*60*24 + millisecond` * @typePartId 7d91f0f70643799692aa144ee51a62b1 */ export type Time = { /** * `1970-01-01` からの経過日数. マイナスになることもある */ readonly day: Int32; /** * 日にちの中のミリ秒. `0 to 86399999 (=1000*60*60*24-1)` */ readonly millisecond: Int32 }; /** * アカウントトークンとプロジェクトID * @typePartId 7e4613f18e8e3bcfdfc00356654414d5 */ export type AccountTokenAndProjectId = { /** * アカウントトークン */ readonly accountToken: AccountToken; /** * プロジェクトID */ readonly projectId: ProjectId }; /** * インポートした変数 * @typePartId 8150e2833dc1f2a77715aa1bb7b2baad */ export type ImportedVariable = { /** * モジュール名, 使うときにはnamedインポートされ, そのモジュール識別子は自動的につけられる */ readonly moduleName: String; /** * 変数名 */ readonly name: TsIdentifier }; /** * ソーシャルログインを提供するプロバイダー Googleのみサポート * @typePartId 84597034eb252267ce1a599ab7a0b543 */ export type OpenIdConnectProvider = "Google"; /** * 型パーツ * @typePartId 87fc411d10f6986dd33e5dbaff6d06ae */ export type TypePart = { /** * 型パーツの名前 */ readonly name: String; /** * 型パーツの説明 */ readonly description: String; /** * 所属しているプロジェクトのID */ readonly projectId: ProjectId; /** * コンパイラに与える,この型を表現するのにどういう特殊な状態にするかという情報 */ readonly attribute: Maybe; /** * データ型パラメーター */ readonly dataTypeParameterList: List; /** * 定義本体 */ readonly body: TypePartBody; /** * 型パーツを識別するID */ readonly id: TypePartId }; /** * プロジェクトのデータファイル * パーツや,型パーツのデータが含まれている * @typePartId 8aa41233812aab908b1d71d11ad97375 */ export type ProjectDataFile = { /** * プロジェクトID */ readonly id: ProjectId; /** * プロジェクト名 */ readonly name: String; /** * 型パーツの定義 */ readonly typePartList: List; /** * パーツの定義 */ readonly partList: List }; /** * JavaScript の 式 * @typePartId 8b0bdbeae05df3badac2ee69bf22011f */ export type TsExpr = { readonly _: "NumberLiteral"; readonly int32: Int32 } | { readonly _: "StringLiteral"; readonly string: String } | { readonly _: "BooleanLiteral"; readonly bool: Bool } | { readonly _: "NullLiteral" } | { readonly _: "UndefinedLiteral" } | { readonly _: "UnaryOperator"; readonly unaryOperatorExpr: UnaryOperatorExpr } | { readonly _: "BinaryOperator"; readonly binaryOperatorExpr: BinaryOperatorExpr } | { readonly _: "ConditionalOperator"; readonly conditionalOperatorExpr: ConditionalOperatorExpr } | { readonly _: "ArrayLiteral"; readonly arrayItemList: List } | { readonly _: "ObjectLiteral"; readonly tsMemberList: List } | { readonly _: "Lambda"; readonly lambdaExpr: LambdaExpr } | { readonly _: "Variable"; readonly tsIdentifier: TsIdentifier } | { readonly _: "GlobalObjects"; readonly tsIdentifier: TsIdentifier } | { readonly _: "ImportedVariable"; readonly importedVariable: ImportedVariable } | { readonly _: "Get"; readonly getExpr: GetExpr } | { readonly _: "Call"; readonly callExpr: CallExpr } | { readonly _: "New"; readonly callExpr: CallExpr } | { readonly _: "TypeAssertion"; readonly typeAssertion: TypeAssertion }; /** * 2つの要素のタプルの型 * @typePartId 8b479d8726bb494ac76d529fbf03908c */ export type ElmTuple2 = { /** * 左の型 */ readonly first: ElmType; /** * 右の型 */ readonly second: ElmType }; /** * definy の プロジェクト * @typePartId 8bc81fa2a15bdbd8c2414d22f3e1b462 */ export type Project = { /** * プロジェクト名 */ readonly name: String; /** * プロジェクトのアイコン画像 */ readonly iconHash: ImageHash; /** * initMemberDescription */ readonly imageHash: ImageHash; /** * initMemberDescription */ readonly createTime: Time; /** * プロジェクトを作成したアカウント */ readonly createAccountId: AccountId; /** * 更新日時 */ readonly updateTime: Time; /** * プロジェクトを識別するID */ readonly id: ProjectId }; /** * forOf文 * @typePartId 8be8db4404f302dd36c8a2c6c6e37e7c */ export type ForOfStatement = { /** * 要素の変数名 */ readonly elementVariableName: TsIdentifier; /** * 繰り返す対象 */ readonly iterableExpr: TsExpr; /** * 繰り返す文 */ readonly statementList: List }; /** * TypeScriptやJavaScriptのコードを表現する. TypeScriptでも出力できるように型情報をつける必要がある * @typePartId 92ea504049ca5b7e2227a95195fe74eb */ export type JsTsCode = { /** * 外部に公開する定義 */ readonly exportDefinitionList: List; /** * 定義した後に実行するコード */ readonly statementList: List }; /** * 直積型のメンバー * @typePartId 9481ceae2c3e2765243f5c7ce7eb76c7 */ export type Member = { /** * メンバー名 */ readonly name: String; /** * メンバーの説明 */ readonly description: String; /** * メンバー値の型 */ readonly type: Type }; /** * Elm の 式 * @typePartId 94e53139b3a82087777ea3e001b2adb4 */ export type ElmExpr = { readonly _: "StringLiteral"; readonly string: String } | { readonly _: "IntLiteral"; readonly int32: Int32 } | { readonly _: "LocalVariant" } | { readonly _: "ImportedVariant" } | { readonly _: "List"; readonly elmExprList: List } | { readonly _: "Op" } | { readonly _: "Negate"; readonly elmExpr: ElmExpr } | { readonly _: "Binops" } | { readonly _: "Lambda" } | { readonly _: "Call" } | { readonly _: "If" } | { readonly _: "Let" } | { readonly _: "Case" } | { readonly _: "Accessor"; readonly string: String } | { readonly _: "Access" } | { readonly _: "Update" } | { readonly _: "Record" } | { readonly _: "Unit" } | { readonly _: "Tuple2" } | { readonly _: "Tuple3" }; /** * 関数の型 * @typePartId 98904215e50e04fa2197a7a96df8f646 */ export type FunctionType = { /** * 型パラメーターのリスト */ readonly typeParameterList: List; /** * パラメーターの型. 意味のない引数名は適当に付く */ readonly parameterList: List; /** * 戻り値の型 */ readonly return: TsType }; /** * 2つの値を持つ型 * @typePartId 9b55e2a5ed07246355fbeba998eaf5fe */ export type Tuple2 = { /** * 0番目の値 */ readonly first: first; /** * 1番目の値 */ readonly second: second }; /** * カスタム型. 代数的データ型 * @typePartId a0cee28e982f5fbcae6b2c7bd1e27e2a */ export type ElmCustomType = { /** * カスタム型名 */ readonly name: ElmTypeName; /** * 外部に公開するレベル */ readonly export: ElmCustomTypeExportLevel; /** * コメント */ readonly comment: String; /** * 型パラメーター */ readonly parameter: List; /** * バリアントのリスト. 値コンストラクタ. タグ */ readonly variantList: List }; /** * 式と呼ぶパラメーター * @typePartId a1f71188b7c3ab2a21954471f3ac67f1 */ export type CallExpr = { /** * 呼ばれる式 */ readonly expr: TsExpr; /** * パラメーター */ readonly parameterList: List }; /** * @typePartId a2580a29c047f54d635c4456696bbef3 */ export type Variable = { /** * 変数の名前 */ readonly name: TsIdentifier; /** * ドキュメント */ readonly document: String; /** * 変数の型 */ readonly type: TsType; /** * 変数の式 */ readonly expr: TsExpr }; /** * 複数の引数が必要な内部関数の部分呼び出し * @typePartId a8c830bd6b3473f2fac7a62ede58ecf0 */ export type KernelCall = { /** * 関数 */ readonly kernel: KernelExpr; /** * 呼び出すパラメーター */ readonly expr: EvaluatedExpr }; /** * プロパティアクセス * @typePartId a9ce526a22f09800aa3773a1614cce89 */ export type GetExpr = { /** * 式 */ readonly expr: TsExpr; /** * プロパティの式 */ readonly propertyExpr: TsExpr }; /** * インポートされた型 * @typePartId b44289bc65640d4ad0ad79a5a627ef78 */ export type ImportedType = { /** * モジュール名. namedImportされるがその識別子は自動的に作成される */ readonly moduleName: String; /** * 型の名前 */ readonly name: TsIdentifier }; /** * アカウントトークンのハッシュ値. データベースに保存する用 * @typePartId b553ab17ca45f4975d9fe17fe1a63ac4 */ export type AccountTokenHash = string & { readonly _accountTokenHash: never }; /** * definyだけでは表現できない式 * @typePartId b6eef263a982482747a8ad0bc9f05e21 */ export type KernelExpr = "Int32Add" | "Int32Sub" | "Int32Mul"; /** * プロジェクトデータファイルのハッシュ値 * Cloud Storage に保存するときのファイル名 * @typePartId b8bf6c22e275c06c7dc42300c332b47d */ export type ProjectDataFileHashValue = string & { readonly _projectDataFileHashValue: never }; /** * definyWebアプリ内での場所を示すもの. URLから求められる. URLに変換できる * @typePartId bbcb8e43df8afff9fe24b001c66fb065 */ export type Location = { readonly _: "Home" } | { readonly _: "CreateProject" } | { readonly _: "Project"; readonly projectId: ProjectId } | { readonly _: "Account"; readonly accountId: AccountId } | { readonly _: "Setting" } | { readonly _: "About" } | { readonly _: "TypePart"; readonly typePartId: TypePartId } | { readonly _: "Part"; readonly partId: PartId } | { readonly _: "LocalProject" } | { readonly _: "ToolList" } | { readonly _: "Tool"; readonly toolName: ToolName }; /** * Tool名 * @typePartId 40986ff02e1371e56d78b4905305724c */ export type ToolName = "ThemeColorRainbow" | "SoundQuiz"; /** * TypeAlias. `export type T = {}` * @typePartId bf69f7e46f5e4949fe801c234fc3ad15 */ export type TypeAlias = { /** * 型の名前 */ readonly name: TsIdentifier; /** * 型パラメーターのリスト */ readonly typeParameterList: List; /** * ドキュメント */ readonly document: String; /** * 型本体 */ readonly type: TsType }; /** * アカウントを識別するためのID * @typePartId c1a17b07e8e664ca80217833ff2ad3f1 */ export type AccountId = string & { readonly _accountId: never }; /** * 文字列のkeyと式のvalue * @typePartId c2428cbcd62b33ce2c904a200b876863 */ export type KeyValue = { /** * key */ readonly key: String; /** * value */ readonly value: TsExpr }; /** * リスト. JavaScriptのArrayで扱う * @typePartId c3fc2a6cea61086db59e11dc2bef0eee */ export type List = globalThis.ReadonlyArray; /** * definy.app の ログイン状態 * @typePartId c4b574e3ca8bad17022054d5e77fd3d0 */ export type LogInState = { readonly _: "LoadingAccountTokenFromIndexedDB" } | { readonly _: "Guest" } | { readonly _: "RequestingLogInUrl"; readonly openIdConnectProvider: OpenIdConnectProvider } | { readonly _: "JumpingToLogInPage" } | { readonly _: "LoadingAccountData" } | { readonly _: "LoggedIn"; readonly accountTokenAccountId: AccountTokenAccountId }; /** * for文 * @typePartId c53be8bcaf56ff90080cf7a75f1e4815 */ export type ForStatement = { /** * カウンタ変数名 */ readonly counterVariableName: TsIdentifier; /** * ループの上限の式 */ readonly untilExpr: TsExpr; /** * 繰り返す文 */ readonly statementList: List }; /** * オブジェクトのメンバーの型 * @typePartId c68bac5afb1a1d35af096bf317d09339 */ export type TsMemberType = { /** * プロパティ名 */ readonly name: String; /** * 必須かどうか falseの場合 ? がつく */ readonly required: Bool; /** * 型 */ readonly type: TsType; /** * ドキュメント */ readonly document: String }; /** * 条件演算子 * @typePartId c7a771f770f0f92690faeb59eaff6268 */ export type ConditionalOperatorExpr = { /** * 条件の式 */ readonly condition: TsExpr; /** * 条件がtrueのときに評価される式 */ readonly thenExpr: TsExpr; /** * 条件がfalseのときに評価される式 */ readonly elseExpr: TsExpr }; /** * if文 * @typePartId cd325760f992e47a8438ae78ca9b1529 */ export type IfStatement = { /** * 条件の式 */ readonly condition: TsExpr; /** * 条件がtrueのときに実行する文 */ readonly thenStatementList: List }; /** * フィールド名 * @typePartId d256109676f834b74931495891b61d1b */ export type ElmFieldName = { readonly _: "FieldName"; readonly string: String }; /** * バリアント名 * @typePartId d77f1f967b892c739a1555f74d2ff9fd */ export type ElmVariantName = { readonly _: "VariantName"; readonly string: String }; /** * 交差型 * @typePartId d82150857d0f2e78c1df0f418ba9b01a */ export type IntersectionType = { /** * 左に指定する型 */ readonly left: TsType; /** * 右に指定する型 */ readonly right: TsType }; /** * パーツの定義. 他のプログラミング言語でいう関数や, 変数のこと * @typePartId d8bccc70252cee9ce70784bf5dfa493b */ export type Part = { /** * パーツの名前 */ readonly name: String; /** * パーツの説明 */ readonly description: String; /** * パーツの型 */ readonly type: Type; /** * パーツの式 */ readonly expr: Expr; /** * 所属しているプロジェクトのID */ readonly projectId: ProjectId; /** * パーツを識別するID */ readonly id: PartId }; /** * definyの評価しきった式 * @typePartId daa9bf22c3f2e52ff92edcdd896d6a6d */ export type EvaluatedExpr = { readonly _: "Kernel"; readonly kernelExpr: KernelExpr } | { readonly _: "Int32"; readonly int32: Int32 } | { readonly _: "TagReference"; readonly tagReference: TagReference } | { readonly _: "KernelCall"; readonly kernelCall: KernelCall }; /** * # 型の変更が必要 * * https://www.notion.so/setTypePart-definy-app-api-a2500046da77432796b7ccaab6e4e3ee * * 1つの型パーツを保存するために指定するパラメーター * * @typePartId dac038758a5c45f762de388bb5193fb8 */ export type SetTypePartParameter = { /** * アカウントトークン */ readonly accountToken: AccountToken; /** * 型パーツのID */ readonly typePartId: TypePartId; /** * 設定する型パーツ名 */ readonly name: String; /** * 設定する説明文 */ readonly description: String; /** * 設定する属性 */ readonly attribute: Maybe; /** * 設定する型パラメーター */ readonly typeParameterList: List; /** * 設定する型定義本体 */ readonly body: TypePartBody }; /** * Bool. 真か偽. JavaScriptのbooleanで扱える. true: 1, false: 0. (1byte)としてバイナリに変換する * @typePartId db57caf129f60db969b5b5224a72b937 */ export type Bool = boolean; /** * Elmの関数の定義. 引数がない関数(定数)も含まれる * @typePartId db8b9f83d99ef58fd206acca4e56d098 */ export type ElmDefinition = { /** * 関数名 */ readonly name: String; /** * 型 */ readonly type: ElmType; /** * 式 */ readonly expr: ElmExpr; /** * コメント */ readonly comment: String }; /** * 外部に公開する関数 * @typePartId dd3366ce7254327c85732d2932ff219b */ export type Function = { /** * 外部に公開する関数の名前 */ readonly name: TsIdentifier; /** * ドキュメント */ readonly document: String; /** * 型パラメーターのリスト */ readonly typeParameterList: List; /** * パラメーター */ readonly parameterList: List; /** * 戻り値の型 */ readonly returnType: TsType; /** * 関数の本体 */ readonly statementList: List }; /** * アカウントトークン. アカウントトークンを持っていればアクセストークンをdefinyのサーバーにリクエストした際に得られるIDのアカウントを保有していると証明できる. サーバーにハッシュ化したものを保存している. これが盗まれた場合,不正に得た人はアカウントを乗っ取ることができる. 有効期限はなし, 最後に発行したアカウントトークン以外は無効になる * @typePartId deb01f82879754c03aa4d244e136e59d */ export type AccountToken = string & { readonly _accountToken: never }; /** * ローカル関数定義 * @typePartId df5c5388248252a92864ceb219628b8e */ export type FunctionDefinitionStatement = { /** * 変数名 */ readonly name: TsIdentifier; /** * 型パラメーターのリスト */ readonly typeParameterList: List; /** * パラメーターのリスト */ readonly parameterList: List; /** * 戻り値の型 */ readonly returnType: TsType; /** * 関数本体 */ readonly statementList: List }; /** * 直積型のパターン * @typePartId e4ef8a0713aceb0eaa7606cd516ad847 */ export type Pattern = { /** * タグ名 */ readonly name: String; /** * パターンの説明 */ readonly description: String; /** * そのパターンにつけるデータの型 */ readonly parameter: Maybe }; /** * 画像から求められるトークン.キャッシュのキーとして使われる.1つのトークンに対して永久に1つの画像データしか表さない. キャッシュを更新する必要はない * @typePartId e71e15a15b0883940a75e58367151d1a */ export type ImageHash = string & { readonly _imageHash: never }; /** * definy の 式 * @typePartId ed9a046b5f121f6e54ac7f3834cbc644 */ export type Expr = { readonly _: "Kernel"; readonly kernelExpr: KernelExpr } | { readonly _: "Int32Literal"; readonly int32: Int32 } | { readonly _: "PartReference"; readonly partId: PartId } | { readonly _: "TagReference"; readonly tagReference: TagReference } | { readonly _: "FunctionCall"; readonly functionCall: FunctionCall }; /** * タグの参照を表す * @typePartId edd59bd2ab4852c149f6ce5917767908 */ export type TagReference = { /** * 型ID. タグIDがあれば, 型を導出できそうだが…… */ readonly typePartId: TypePartId; /** * タグID */ readonly tagId: TagId }; /** * definy.app を開発する上での動作モード. デベロップモード(http://localhost:2520)か, リリースモード(https://definy.app) * @typePartId ee0590e764618611ffa8e1a0a2e22f79 */ export type Mode = "Develop" | "Release"; /** * 2項演算子と左右の式 * @typePartId eec2dab74fbcd3237bfa1c773f9b9d21 */ export type BinaryOperatorExpr = { /** * 2項演算子 */ readonly operator: BinaryOperator; /** * 左の式 */ readonly left: TsExpr; /** * 右の式 */ readonly right: TsExpr }; /** * 出力するコードの種類 * @typePartId eedf73c97f9dd61159572322f6d7e0a5 */ export type CodeType = "JavaScript" | "TypeScript"; /** * ラムダ式 * @typePartId eeeef818144e5a42460c4efdaa221460 */ export type LambdaExpr = { /** * パラメーターのリスト */ readonly parameterList: List; /** * 型パラメーターのリスト */ readonly typeParameterList: List; /** * 戻り値の型 */ readonly returnType: TsType; /** * ラムダ式本体 */ readonly statementList: List }; /** * ログインのURLを発行するために必要なデータ * @typePartId f03ea5331c1a3adcde80a04054d35e07 */ export type RequestLogInUrlRequestData = { /** * ログインに使用するプロバイダー */ readonly openIdConnectProvider: OpenIdConnectProvider; /** * ログインした後に返ってくるURLに必要なデータ */ readonly locationAndLanguage: LocationAndLanguage }; /** * Elmの型定義 * @typePartId f4bed793b657b39db5a579c9e158eba5 */ export type ElmTypeDeclaration = { readonly _: "TypeAlias"; readonly elmTypeAlias: ElmTypeAlias } | { readonly _: "CustomType"; readonly elmCustomType: ElmCustomType }; /** * JavaScriptのオブジェクトリテラルの要素 * @typePartId fddd2a65994fae205dd636f3a6b9f1ea */ export type TsMember = { readonly _: "Spread"; readonly tsExpr: TsExpr } | { readonly _: "KeyValue"; readonly keyValue: KeyValue }; /** * definy の型 * @typePartId b3b36f39469d23321ed01b92f048ccc0 */ export type Type = { /** * 入力のデータ型 */ readonly input: Maybe; /** * 出力のデータ型 */ readonly output: DataTypeOrDataTypeParameter }; /** * データ型パラメータに指定するもの * @typePartId 627dc8fa15214481812af12268d97b6b */ export type DataTypeParameter = { /** * データ型パラメータの名前 */ readonly name: String; /** * データ型パラメータの説明文 */ readonly description: String }; /** * 直接的に, 関数ではないデータ型 (内部に関数を保つ場合はある) * @typePartId a9c4fac6168c374e3a4e1579d588bf99 */ export type DataType = { /** * 型パーツID */ readonly typePartId: TypePartId; /** * データ型のパラメータに指定する. arguments */ readonly arguments: List }; /** * データタイプか, データタイプパラメーターで定義されたもの * @typePartId b4c160bb8b69e290abf7b60faca0856b */ export type DataTypeOrDataTypeParameter = { readonly _: "DataType"; readonly dataType: DataType } | { readonly _: "DataTypeParameter"; readonly int32: Int32 }; /** * ソーシャルログインしたあとに返ってくるパラメーター * @typePartId f332dc92c18678b3c61bad7cf0e8010d */ export type CodeAndState = { readonly code: String; readonly state: String; readonly openIdConnectProvider: OpenIdConnectProvider }; /** * アカウントトークンとUrlData (場所と言語) * @typePartId bf38704fac7ddb2c86d107f928e9d88f */ export type AccountTokenAndUrlDataAndAccount = { /** * アカウントトークン */ readonly accountToken: AccountToken; /** * 場所と言語 */ readonly locationAndLanguage: LocationAndLanguage; /** * ログインした account */ readonly account: Account }; /** * logInCallback も含めた URL に入る場所と言語 * @typePartId 24b5c609255152717a191a7af8e1ceed */ export type UrlData = { readonly _: "Normal"; readonly locationAndLanguage: LocationAndLanguage } | { readonly _: "LogInCallback"; readonly codeAndState: CodeAndState }; /** * バリアント. 値コンストラクタ. タグ * @typePartId 0bc2e5ab2fd2caeb6e6c331573ae735f */ export const ElmVariant: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmVariant) => ElmVariant } = { typePartId: "0bc2e5ab2fd2caeb6e6c331573ae735f" as TypePartId, helper: (elmVariant: ElmVariant): ElmVariant => elmVariant, codec: { encode: (value: ElmVariant): globalThis.ReadonlyArray => (ElmVariantName.codec.encode(value.name).concat(List.codec(ElmType.codec).encode(value.parameter))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmVariant; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: ElmVariantName; readonly nextIndex: number } = ElmVariantName.codec.decode(index, binary); const parameterAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(ElmType.codec).decode(nameAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, parameter: parameterAndNextIndex.result }, nextIndex: parameterAndNextIndex.nextIndex }; } } }; /** * 外部に公開する定義 * @typePartId 0c8b854b812290a054877ca5de6c4daf */ export const ExportDefinition: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * TypeAlias */ readonly TypeAlias: (a: TypeAlias) => ExportDefinition; /** * Function */ readonly Function: (a: Function) => ExportDefinition; /** * Variable */ readonly Variable: (a: Variable) => ExportDefinition } = { TypeAlias: (typeAlias: TypeAlias): ExportDefinition => ({ _: "TypeAlias", typeAlias }), Function: (function_: Function): ExportDefinition => ({ _: "Function", function: function_ }), Variable: (variable: Variable): ExportDefinition => ({ _: "Variable", variable }), typePartId: "0c8b854b812290a054877ca5de6c4daf" as TypePartId, codec: { encode: (value: ExportDefinition): globalThis.ReadonlyArray => { switch (value._) { case "TypeAlias": { return [0].concat(TypeAlias.codec.encode(value.typeAlias)); } case "Function": { return [1].concat(Function.codec.encode(value.function)); } case "Variable": { return [2].concat(Variable.codec.encode(value.variable)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ExportDefinition; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: TypeAlias; readonly nextIndex: number } = TypeAlias.codec.decode(patternIndex.nextIndex, binary); return { result: ExportDefinition.TypeAlias(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: Function; readonly nextIndex: number } = Function.codec.decode(patternIndex.nextIndex, binary); return { result: ExportDefinition.Function(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: Variable; readonly nextIndex: number } = Variable.codec.decode(patternIndex.nextIndex, binary); return { result: ExportDefinition.Variable(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 単項演算子と適用される式 * @typePartId 0cb0a34b3953e57b30f4a5c8f9d305da */ export const UnaryOperatorExpr: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: UnaryOperatorExpr) => UnaryOperatorExpr } = { typePartId: "0cb0a34b3953e57b30f4a5c8f9d305da" as TypePartId, helper: (unaryOperatorExpr: UnaryOperatorExpr): UnaryOperatorExpr => unaryOperatorExpr, codec: { encode: (value: UnaryOperatorExpr): globalThis.ReadonlyArray => (UnaryOperator.codec.encode(value.operator).concat(TsExpr.codec.encode(value.expr))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: UnaryOperatorExpr; readonly nextIndex: number } => { const operatorAndNextIndex: { readonly result: UnaryOperator; readonly nextIndex: number } = UnaryOperator.codec.decode(index, binary); const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(operatorAndNextIndex.nextIndex, binary); return { result: { operator: operatorAndNextIndex.result, expr: exprAndNextIndex.result }, nextIndex: exprAndNextIndex.nextIndex }; } } }; /** * プロジェクトの識別子 * @typePartId 0cd913118a2ad1469d656146a08c5f76 */ export const ProjectId: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 文字列から変換する */ readonly fromString: (a: string) => ProjectId } = { typePartId: "0cd913118a2ad1469d656146a08c5f76" as TypePartId, codec: { encode: (value: ProjectId): globalThis.ReadonlyArray => (encodeId(value)), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ProjectId; readonly nextIndex: number } => (decodeId(index, binary) as { readonly result: ProjectId; readonly nextIndex: number }) }, fromString: (str: string): ProjectId => (str as ProjectId) }; /** * 英語,日本語,エスペラント語 * * ナルミンチョが使える? プログラミングじゃない言語 * @typePartId 0d9510723f4d34605e41f3a47a8b0ea7 */ export const Language: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 日本語 */ readonly Japanese: Language; /** * 英語 */ readonly English: Language; /** * エスペラント語 */ readonly Esperanto: Language } = { Japanese: "Japanese", English: "English", Esperanto: "Esperanto", typePartId: "0d9510723f4d34605e41f3a47a8b0ea7" as TypePartId, codec: { encode: (value: Language): globalThis.ReadonlyArray => { switch (value) { case "Japanese": { return [0]; } case "English": { return [1]; } case "Esperanto": { return [2]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Language; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: Language.Japanese, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: Language.English, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: Language.Esperanto, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * Elmで使う型の名前. Elmで使える型名ということを確認済み * @typePartId 13e52324ba81c7ffe655455ad739ea73 */ export const ElmTypeName: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * **直接 ElmTypeName.ElmTypeName("Int") と指定してはいけない!! Elmの識別子として使える文字としてチェックできないため** */ readonly ElmTypeName: (a: String) => ElmTypeName } = { ElmTypeName: (string_: String): ElmTypeName => ({ _: "ElmTypeName", string: string_ }), typePartId: "13e52324ba81c7ffe655455ad739ea73" as TypePartId, codec: { encode: (value: ElmTypeName): globalThis.ReadonlyArray => { switch (value._) { case "ElmTypeName": { return [0].concat(String.codec.encode(value.string)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmTypeName; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: String; readonly nextIndex: number } = String.codec.decode(patternIndex.nextIndex, binary); return { result: ElmTypeName.ElmTypeName(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * -2 147 483 648 ~ 2 147 483 647. 32bit 符号付き整数. JavaScriptのnumberとして扱える. numberの32bit符号あり整数をSigned Leb128のバイナリに変換する * @typePartId 16c2d8602e3e5e2d38b9215bd0c44d8d */ export const Int32: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec } = { typePartId: "16c2d8602e3e5e2d38b9215bd0c44d8d" as TypePartId, codec: { encode: (value: Int32): globalThis.ReadonlyArray => { let rest: number = value | 0; const result: globalThis.Array = []; while (true) { const byte: number = rest & 127; rest >>= 7; if (rest === 0 && (byte & 64) === 0 || rest === -1 && (byte & 64) !== 0) { result.push(byte); return result; } result.push(byte | 128); } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Int32; readonly nextIndex: number } => { let result: number = 0; let offset: number = 0; while (true) { const byte: number | undefined = binary[index + offset]; if (byte === undefined) { throw new Error("invalid byte in decode int32"); } result |= (byte & 127) << offset * 7; offset += 1; if ((128 & byte) === 0) { if (offset * 7 < 32 && (byte & 64) !== 0) { return { result: result | ~0 << offset * 7, nextIndex: index + offset }; } return { result, nextIndex: index + offset }; } } } } }; /** * Elm の 型 * @typePartId 173f661790b059baf212043f816ba1a9 */ export const ElmType: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * インポートした型 */ readonly ImportedType: (a: ElmImportedType) => ElmType; /** * 型パラメーター */ readonly TypeParameter: (a: String) => ElmType; /** * 関数 */ readonly Function: (a: ElmFunctionType) => ElmType; /** * List リスト */ readonly List: (a: ElmType) => ElmType; /** * () 1種類の値だけ持つ型. Unit */ readonly Tuple0: ElmType; /** * (a, b) */ readonly Tuple2: (a: ElmTuple2) => ElmType; /** * (a, b, c) */ readonly Tuple3: (a: ElmTuple3) => ElmType; /** * { name: String, age: Int } レコード型 */ readonly Record: (a: List) => ElmType; /** * モジュール内にある型 */ readonly LocalType: (a: ElmLocalType) => ElmType } = { ImportedType: (elmImportedType: ElmImportedType): ElmType => ({ _: "ImportedType", elmImportedType }), TypeParameter: (string_: String): ElmType => ({ _: "TypeParameter", string: string_ }), Function: (elmFunctionType: ElmFunctionType): ElmType => ({ _: "Function", elmFunctionType }), List: (elmType: ElmType): ElmType => ({ _: "List", elmType }), Tuple0: { _: "Tuple0" }, Tuple2: (elmTuple2: ElmTuple2): ElmType => ({ _: "Tuple2", elmTuple2 }), Tuple3: (elmTuple3: ElmTuple3): ElmType => ({ _: "Tuple3", elmTuple3 }), Record: (elmFieldList: List): ElmType => ({ _: "Record", elmFieldList }), LocalType: (elmLocalType: ElmLocalType): ElmType => ({ _: "LocalType", elmLocalType }), typePartId: "173f661790b059baf212043f816ba1a9" as TypePartId, codec: { encode: (value: ElmType): globalThis.ReadonlyArray => { switch (value._) { case "ImportedType": { return [0].concat(ElmImportedType.codec.encode(value.elmImportedType)); } case "TypeParameter": { return [1].concat(String.codec.encode(value.string)); } case "Function": { return [2].concat(ElmFunctionType.codec.encode(value.elmFunctionType)); } case "List": { return [3].concat(ElmType.codec.encode(value.elmType)); } case "Tuple0": { return [4]; } case "Tuple2": { return [5].concat(ElmTuple2.codec.encode(value.elmTuple2)); } case "Tuple3": { return [6].concat(ElmTuple3.codec.encode(value.elmTuple3)); } case "Record": { return [7].concat(List.codec(ElmField.codec).encode(value.elmFieldList)); } case "LocalType": { return [8].concat(ElmLocalType.codec.encode(value.elmLocalType)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmType; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: ElmImportedType; readonly nextIndex: number } = ElmImportedType.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.ImportedType(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: String; readonly nextIndex: number } = String.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.TypeParameter(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: ElmFunctionType; readonly nextIndex: number } = ElmFunctionType.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.Function(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 3) { const result: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.List(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 4) { return { result: ElmType.Tuple0, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 5) { const result: { readonly result: ElmTuple2; readonly nextIndex: number } = ElmTuple2.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.Tuple2(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 6) { const result: { readonly result: ElmTuple3; readonly nextIndex: number } = ElmTuple3.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.Tuple3(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 7) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(ElmField.codec).decode(patternIndex.nextIndex, binary); return { result: ElmType.Record(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 8) { const result: { readonly result: ElmLocalType; readonly nextIndex: number } = ElmLocalType.codec.decode(patternIndex.nextIndex, binary); return { result: ElmType.LocalType(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * @typePartId 1835ebdc909b0fa93d11ae0ed93d0606 */ export const TsType: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * プリミティブの型のnumber */ readonly Number: TsType; /** * プリミティブの型のstring */ readonly String: TsType; /** * プリミティブの型のboolean */ readonly Boolean: TsType; /** * プリミティブの型のundefined */ readonly Undefined: TsType; /** * プリミティブの型のnull */ readonly Null: TsType; /** * never型 */ readonly Never: TsType; /** * void型 */ readonly Void: TsType; /** * オブジェクト */ readonly Object: (a: List) => TsType; /** * 関数 `(parameter: parameter) => returnType` */ readonly Function: (a: FunctionType) => TsType; /** * 型パラメータ付きの型 `Promise` `ReadonlyArray` */ readonly WithTypeParameter: (a: TsTypeWithTypeParameter) => TsType; /** * ユニオン型 `a | b` */ readonly Union: (a: List) => TsType; /** * "交差型 `left & right` */ readonly Intersection: (a: IntersectionType) => TsType; /** * インポートされた外部の型 */ readonly ImportedType: (a: ImportedType) => TsType; /** * ファイル内で定義された型 */ readonly ScopeInFile: (a: TsIdentifier) => TsType; /** * グローバル空間の型 */ readonly ScopeInGlobal: (a: TsIdentifier) => TsType; /** * 文字列リテラル型 */ readonly StringLiteral: (a: String) => TsType } = { Number: { _: "Number" }, String: { _: "String" }, Boolean: { _: "Boolean" }, Undefined: { _: "Undefined" }, Null: { _: "Null" }, Never: { _: "Never" }, Void: { _: "Void" }, Object: (tsMemberTypeList: List): TsType => ({ _: "Object", tsMemberTypeList }), Function: (functionType: FunctionType): TsType => ({ _: "Function", functionType }), WithTypeParameter: (tsTypeWithTypeParameter: TsTypeWithTypeParameter): TsType => ({ _: "WithTypeParameter", tsTypeWithTypeParameter }), Union: (tsTypeList: List): TsType => ({ _: "Union", tsTypeList }), Intersection: (intersectionType: IntersectionType): TsType => ({ _: "Intersection", intersectionType }), ImportedType: (importedType: ImportedType): TsType => ({ _: "ImportedType", importedType }), ScopeInFile: (tsIdentifier: TsIdentifier): TsType => ({ _: "ScopeInFile", tsIdentifier }), ScopeInGlobal: (tsIdentifier: TsIdentifier): TsType => ({ _: "ScopeInGlobal", tsIdentifier }), StringLiteral: (string_: String): TsType => ({ _: "StringLiteral", string: string_ }), typePartId: "1835ebdc909b0fa93d11ae0ed93d0606" as TypePartId, codec: { encode: (value: TsType): globalThis.ReadonlyArray => { switch (value._) { case "Number": { return [0]; } case "String": { return [1]; } case "Boolean": { return [2]; } case "Undefined": { return [3]; } case "Null": { return [4]; } case "Never": { return [5]; } case "Void": { return [6]; } case "Object": { return [7].concat(List.codec(TsMemberType.codec).encode(value.tsMemberTypeList)); } case "Function": { return [8].concat(FunctionType.codec.encode(value.functionType)); } case "WithTypeParameter": { return [9].concat(TsTypeWithTypeParameter.codec.encode(value.tsTypeWithTypeParameter)); } case "Union": { return [10].concat(List.codec(TsType.codec).encode(value.tsTypeList)); } case "Intersection": { return [11].concat(IntersectionType.codec.encode(value.intersectionType)); } case "ImportedType": { return [12].concat(ImportedType.codec.encode(value.importedType)); } case "ScopeInFile": { return [13].concat(TsIdentifier.codec.encode(value.tsIdentifier)); } case "ScopeInGlobal": { return [14].concat(TsIdentifier.codec.encode(value.tsIdentifier)); } case "StringLiteral": { return [15].concat(String.codec.encode(value.string)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TsType; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: TsType.Number, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: TsType.String, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: TsType.Boolean, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 3) { return { result: TsType.Undefined, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 4) { return { result: TsType.Null, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 5) { return { result: TsType.Never, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 6) { return { result: TsType.Void, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 7) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(TsMemberType.codec).decode(patternIndex.nextIndex, binary); return { result: TsType.Object(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 8) { const result: { readonly result: FunctionType; readonly nextIndex: number } = FunctionType.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.Function(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 9) { const result: { readonly result: TsTypeWithTypeParameter; readonly nextIndex: number } = TsTypeWithTypeParameter.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.WithTypeParameter(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 10) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(TsType.codec).decode(patternIndex.nextIndex, binary); return { result: TsType.Union(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 11) { const result: { readonly result: IntersectionType; readonly nextIndex: number } = IntersectionType.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.Intersection(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 12) { const result: { readonly result: ImportedType; readonly nextIndex: number } = ImportedType.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.ImportedType(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 13) { const result: { readonly result: TsIdentifier; readonly nextIndex: number } = TsIdentifier.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.ScopeInFile(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 14) { const result: { readonly result: TsIdentifier; readonly nextIndex: number } = TsIdentifier.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.ScopeInGlobal(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 15) { const result: { readonly result: String; readonly nextIndex: number } = String.codec.decode(patternIndex.nextIndex, binary); return { result: TsType.StringLiteral(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * Project, Account, TypePartなどのリソースの状態とデータ. 読み込み中だとか * @typePartId 18cbd2fa4bd72a0eacf3f0f44aeb6feb */ export const ResourceState: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec) => Codec>; /** * 読み込み済み */ readonly Loaded: (a: WithTime) => ResourceState; /** * 削除されたか, 存在しない */ readonly Deleted: (a: Time) => ResourceState; /** * 削除されたか, 存在しない */ readonly Unknown: (a: Time) => ResourceState; /** * サーバに問い合わせ中 */ readonly Requesting: () => ResourceState } = { Loaded: (dataWithTime: WithTime): ResourceState => ({ _: "Loaded", dataWithTime }), Deleted: (time: Time): ResourceState => ({ _: "Deleted", time }), Unknown: (time: Time): ResourceState => ({ _: "Unknown", time }), Requesting: (): ResourceState => ({ _: "Requesting" }), typePartId: "18cbd2fa4bd72a0eacf3f0f44aeb6feb" as TypePartId, codec: (dataCodec: Codec): Codec> => ({ encode: (value: ResourceState): globalThis.ReadonlyArray => { switch (value._) { case "Loaded": { return [0].concat(WithTime.codec(dataCodec).encode(value.dataWithTime)); } case "Deleted": { return [1].concat(Time.codec.encode(value.time)); } case "Unknown": { return [2].concat(Time.codec.encode(value.time)); } case "Requesting": { return [3]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ResourceState; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: WithTime; readonly nextIndex: number } = WithTime.codec(dataCodec).decode(patternIndex.nextIndex, binary); return { result: ResourceState.Loaded(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: Time; readonly nextIndex: number } = Time.codec.decode(patternIndex.nextIndex, binary); return { result: ResourceState.Deleted(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: Time; readonly nextIndex: number } = Time.codec.decode(patternIndex.nextIndex, binary); return { result: ResourceState.Unknown(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 3) { return { result: ResourceState.Requesting(), nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } }) }; /** * Unit. 1つの値しかない型. JavaScriptのundefinedで扱う * @typePartId 217263d8cdca613c2d1ba77e19d4cbb0 */ export const Unit: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * Unit型にある.唯一の値 */ readonly UnitValue: Unit } = { UnitValue: undefined, typePartId: "217263d8cdca613c2d1ba77e19d4cbb0" as TypePartId, codec: { encode: (value: Unit): globalThis.ReadonlyArray => [], decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Unit; readonly nextIndex: number } => ({ result: Unit.UnitValue, nextIndex: index }) } }; /** * コンパイラに向けた, 型のデータ形式をどうするかの情報 * @typePartId 22d8f2d392c573a7aa54c39fa4c98ad0 */ export const TypeAttribute: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * JavaScript, TypeScript で boolean として扱うように指示する. 定義が2つのパターンで両方パラメーターなし false, trueの順である必要がある */ readonly AsBoolean: TypeAttribute; /** * JavaScript, TypeScript で undefined として扱うように指示する. 定義が1つのパターンでパラメーターなしである必要がある */ readonly AsUndefined: TypeAttribute; /** * JavaScript, TypeScript で number & {_typeName: never} として扱うように指示する. 定義が1つのパターンでパラメーターが Int32 である必要がある */ readonly AsNumber: TypeAttribute } = { AsBoolean: "AsBoolean", AsUndefined: "AsUndefined", AsNumber: "AsNumber", typePartId: "22d8f2d392c573a7aa54c39fa4c98ad0" as TypePartId, codec: { encode: (value: TypeAttribute): globalThis.ReadonlyArray => { switch (value) { case "AsBoolean": { return [0]; } case "AsUndefined": { return [1]; } case "AsNumber": { return [2]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TypeAttribute; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: TypeAttribute.AsBoolean, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: TypeAttribute.AsUndefined, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: TypeAttribute.AsNumber, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * @typePartId 2392b884a9c2238a65ecd272bd23a9cd */ export const ElmField: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmField) => ElmField } = { typePartId: "2392b884a9c2238a65ecd272bd23a9cd" as TypePartId, helper: (elmField: ElmField): ElmField => elmField, codec: { encode: (value: ElmField): globalThis.ReadonlyArray => (ElmFieldName.codec.encode(value.name).concat(ElmType.codec.encode(value.type))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmField; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: ElmFieldName; readonly nextIndex: number } = ElmFieldName.codec.decode(index, binary); const typeAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(nameAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, type: typeAndNextIndex.result }, nextIndex: typeAndNextIndex.nextIndex }; } } }; /** * パラメーター付きの型 * @typePartId 23fa0e8b66c9d093d4c18579ffefaaa3 */ export const TsTypeWithTypeParameter: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: TsTypeWithTypeParameter) => TsTypeWithTypeParameter } = { typePartId: "23fa0e8b66c9d093d4c18579ffefaaa3" as TypePartId, helper: (tsTypeWithTypeParameter: TsTypeWithTypeParameter): TsTypeWithTypeParameter => tsTypeWithTypeParameter, codec: { encode: (value: TsTypeWithTypeParameter): globalThis.ReadonlyArray => (TsType.codec.encode(value.type).concat(List.codec(TsType.codec).encode(value.typeParameterList))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TsTypeWithTypeParameter; readonly nextIndex: number } => { const typeAndNextIndex: { readonly result: TsType; readonly nextIndex: number } = TsType.codec.decode(index, binary); const typeParameterListAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(TsType.codec).decode(typeAndNextIndex.nextIndex, binary); return { result: { type: typeAndNextIndex.result, typeParameterList: typeParameterListAndNextIndex.result }, nextIndex: typeParameterListAndNextIndex.nextIndex }; } } }; /** * 評価したときに失敗した原因を表すもの * @typePartId 25d0af5522da614f7617016ca7868edd */ export const EvaluateExprError: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 式を評価するには,このパーツの定義が必要だと言っている */ readonly NeedPartDefinition: (a: PartId) => EvaluateExprError; /** * 計算結果にblankが含まれている */ readonly Blank: EvaluateExprError; /** * 型が合わない */ readonly TypeError: (a: String) => EvaluateExprError; /** * まだサポートしていないものが含まれている */ readonly NotSupported: EvaluateExprError } = { NeedPartDefinition: (partId: PartId): EvaluateExprError => ({ _: "NeedPartDefinition", partId }), Blank: { _: "Blank" }, TypeError: (string_: String): EvaluateExprError => ({ _: "TypeError", string: string_ }), NotSupported: { _: "NotSupported" }, typePartId: "25d0af5522da614f7617016ca7868edd" as TypePartId, codec: { encode: (value: EvaluateExprError): globalThis.ReadonlyArray => { switch (value._) { case "NeedPartDefinition": { return [0].concat(PartId.codec.encode(value.partId)); } case "Blank": { return [1]; } case "TypeError": { return [2].concat(String.codec.encode(value.string)); } case "NotSupported": { return [3]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: EvaluateExprError; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: PartId; readonly nextIndex: number } = PartId.codec.decode(patternIndex.nextIndex, binary); return { result: EvaluateExprError.NeedPartDefinition(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { return { result: EvaluateExprError.Blank, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: String; readonly nextIndex: number } = String.codec.decode(patternIndex.nextIndex, binary); return { result: EvaluateExprError.TypeError(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 3) { return { result: EvaluateExprError.NotSupported, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * TypeScriptの識別子として使える文字 * @typePartId 2a75ad7c7ccc58ba56f6c8545c8150d1 */ export const TsIdentifier: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * **直接 TsIdentifier.Identifier("name") と指定してはいけない!! TypeScriptの識別子として使える文字としてチェックできないため** */ readonly Identifier: (a: String) => TsIdentifier } = { Identifier: (string_: String): TsIdentifier => ({ _: "Identifier", string: string_ }), typePartId: "2a75ad7c7ccc58ba56f6c8545c8150d1" as TypePartId, codec: { encode: (value: TsIdentifier): globalThis.ReadonlyArray => { switch (value._) { case "Identifier": { return [0].concat(String.codec.encode(value.string)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TsIdentifier; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: String; readonly nextIndex: number } = String.codec.decode(patternIndex.nextIndex, binary); return { result: TsIdentifier.Identifier(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * モジュール内の型 * @typePartId 2b42264a878355f0257141fa013fed5c */ export const ElmLocalType: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmLocalType) => ElmLocalType } = { typePartId: "2b42264a878355f0257141fa013fed5c" as TypePartId, helper: (elmLocalType: ElmLocalType): ElmLocalType => elmLocalType, codec: { encode: (value: ElmLocalType): globalThis.ReadonlyArray => (ElmTypeName.codec.encode(value.typeName).concat(List.codec(ElmType.codec).encode(value.parameter))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmLocalType; readonly nextIndex: number } => { const typeNameAndNextIndex: { readonly result: ElmTypeName; readonly nextIndex: number } = ElmTypeName.codec.decode(index, binary); const parameterAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(ElmType.codec).decode(typeNameAndNextIndex.nextIndex, binary); return { result: { typeName: typeNameAndNextIndex.result, parameter: parameterAndNextIndex.result }, nextIndex: parameterAndNextIndex.nextIndex }; } } }; /** * 関数呼び出し * @typePartId 2f9784d2c41d0974487a1ca2b0a51ec5 */ export const FunctionCall: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: FunctionCall) => FunctionCall } = { typePartId: "2f9784d2c41d0974487a1ca2b0a51ec5" as TypePartId, helper: (functionCall: FunctionCall): FunctionCall => functionCall, codec: { encode: (value: FunctionCall): globalThis.ReadonlyArray => (Expr.codec.encode(value.function).concat(Expr.codec.encode(value.parameter))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: FunctionCall; readonly nextIndex: number } => { const functionAndNextIndex: { readonly result: Expr; readonly nextIndex: number } = Expr.codec.decode(index, binary); const parameterAndNextIndex: { readonly result: Expr; readonly nextIndex: number } = Expr.codec.decode(functionAndNextIndex.nextIndex, binary); return { result: { function: functionAndNextIndex.result, parameter: parameterAndNextIndex.result }, nextIndex: parameterAndNextIndex.nextIndex }; } } }; /** * Maybe. nullableのようなもの. 今後はRustのstd::Optionに出力するために属性をつけよう (確信) * @typePartId 304f21ae8208a21d08731aa6d183742d */ export const Maybe: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec) => Codec>; /** * 値があるということ */ readonly Just: (a: value) => Maybe; /** * 値がないということ */ readonly Nothing: () => Maybe } = { Just: (value: value): Maybe => ({ _: "Just", value }), Nothing: (): Maybe => ({ _: "Nothing" }), typePartId: "304f21ae8208a21d08731aa6d183742d" as TypePartId, codec: (valueCodec: Codec): Codec> => ({ encode: (value: Maybe): globalThis.ReadonlyArray => { switch (value._) { case "Just": { return [0].concat(valueCodec.encode(value.value)); } case "Nothing": { return [1]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Maybe; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: value; readonly nextIndex: number } = valueCodec.decode(patternIndex.nextIndex, binary); return { result: Maybe.Just(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { return { result: Maybe.Nothing(), nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } }) }; /** * 配列リテラルの要素 * @typePartId 35f7e442c0838f9982e6b49da398d97f */ export const ArrayItem: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ArrayItem) => ArrayItem } = { typePartId: "35f7e442c0838f9982e6b49da398d97f" as TypePartId, helper: (arrayItem: ArrayItem): ArrayItem => arrayItem, codec: { encode: (value: ArrayItem): globalThis.ReadonlyArray => (TsExpr.codec.encode(value.expr).concat(Bool.codec.encode(value.spread))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ArrayItem; readonly nextIndex: number } => { const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(index, binary); const spreadAndNextIndex: { readonly result: Bool; readonly nextIndex: number } = Bool.codec.decode(exprAndNextIndex.nextIndex, binary); return { result: { expr: exprAndNextIndex.result, spread: spreadAndNextIndex.result }, nextIndex: spreadAndNextIndex.nextIndex }; } } }; /** * バイナリ. JavaScriptのUint8Arrayで扱える. 最初にLED128でバイト数, その次にバイナリそのまま * @typePartId 3e2f740c88923b0393a1ef93d92f157b */ export const Binary: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec } = { typePartId: "3e2f740c88923b0393a1ef93d92f157b" as TypePartId, codec: { encode: (value: Binary): globalThis.ReadonlyArray => (Int32.codec.encode(value.length).concat([...value])), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Binary; readonly nextIndex: number } => { const length: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); const nextIndex: number = length.nextIndex + length.result; return { result: binary.slice(length.nextIndex, nextIndex), nextIndex }; } } }; /** * 3つの要素のタプルの型 * @typePartId 42e5ab4936af4abf8673472ce96fd794 */ export const ElmTuple3: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmTuple3) => ElmTuple3 } = { typePartId: "42e5ab4936af4abf8673472ce96fd794" as TypePartId, helper: (elmTuple3: ElmTuple3): ElmTuple3 => elmTuple3, codec: { encode: (value: ElmTuple3): globalThis.ReadonlyArray => (ElmType.codec.encode(value.first).concat(ElmType.codec.encode(value.second)).concat(ElmType.codec.encode(value.third))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmTuple3; readonly nextIndex: number } => { const firstAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(index, binary); const secondAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(firstAndNextIndex.nextIndex, binary); const thirdAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(secondAndNextIndex.nextIndex, binary); return { result: { first: firstAndNextIndex.result, second: secondAndNextIndex.result, third: thirdAndNextIndex.result }, nextIndex: thirdAndNextIndex.nextIndex }; } } }; /** * 外部のモジュールの型 * @typePartId 43aa21ed2225cacc4489c30113e87787 */ export const ElmImportedType: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmImportedType) => ElmImportedType } = { typePartId: "43aa21ed2225cacc4489c30113e87787" as TypePartId, helper: (elmImportedType: ElmImportedType): ElmImportedType => elmImportedType, codec: { encode: (value: ElmImportedType): globalThis.ReadonlyArray => (String.codec.encode(value.moduleName).concat(ElmTypeName.codec.encode(value.typeName)).concat(List.codec(ElmType.codec).encode(value.parameter))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmImportedType; readonly nextIndex: number } => { const moduleNameAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(index, binary); const typeNameAndNextIndex: { readonly result: ElmTypeName; readonly nextIndex: number } = ElmTypeName.codec.decode(moduleNameAndNextIndex.nextIndex, binary); const parameterAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(ElmType.codec).decode(typeNameAndNextIndex.nextIndex, binary); return { result: { moduleName: moduleNameAndNextIndex.result, typeName: typeNameAndNextIndex.result, parameter: parameterAndNextIndex.result }, nextIndex: parameterAndNextIndex.nextIndex }; } } }; /** * 2項演算子 * @typePartId 4953938f040aefdaa5f2601e2a78d43b */ export const BinaryOperator: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * べき乗 `a ** b` */ readonly Exponentiation: BinaryOperator; /** * 数値の掛け算 `a * b` */ readonly Multiplication: BinaryOperator; /** * 数値の割り算 `a / b` */ readonly Division: BinaryOperator; /** * 剰余演算 `a % b` */ readonly Remainder: BinaryOperator; /** * 数値の足し算, 文字列の結合 `a + b` */ readonly Addition: BinaryOperator; /** * 数値の引き算 `a - b` */ readonly Subtraction: BinaryOperator; /** * 左シフト `a << b` */ readonly LeftShift: BinaryOperator; /** * 符号を維持する右シフト `a >> b` */ readonly SignedRightShift: BinaryOperator; /** * 符号を維持しない(0埋め)右シフト `a >>> b` */ readonly UnsignedRightShift: BinaryOperator; /** * 未満 `a < b` */ readonly LessThan: BinaryOperator; /** * 以下 `a <= b` */ readonly LessThanOrEqual: BinaryOperator; /** * 等号 `a === b` */ readonly Equal: BinaryOperator; /** * 不等号 `a !== b` */ readonly NotEqual: BinaryOperator; /** * ビットAND `a & b` */ readonly BitwiseAnd: BinaryOperator; /** * ビットXOR `a ^ b` */ readonly BitwiseXOr: BinaryOperator; /** * ビットOR `a | b` */ readonly BitwiseOr: BinaryOperator; /** * 論理AND `a && b` */ readonly LogicalAnd: BinaryOperator; /** * 論理OR `a || b` */ readonly LogicalOr: BinaryOperator } = { Exponentiation: "Exponentiation", Multiplication: "Multiplication", Division: "Division", Remainder: "Remainder", Addition: "Addition", Subtraction: "Subtraction", LeftShift: "LeftShift", SignedRightShift: "SignedRightShift", UnsignedRightShift: "UnsignedRightShift", LessThan: "LessThan", LessThanOrEqual: "LessThanOrEqual", Equal: "Equal", NotEqual: "NotEqual", BitwiseAnd: "BitwiseAnd", BitwiseXOr: "BitwiseXOr", BitwiseOr: "BitwiseOr", LogicalAnd: "LogicalAnd", LogicalOr: "LogicalOr", typePartId: "4953938f040aefdaa5f2601e2a78d43b" as TypePartId, codec: { encode: (value: BinaryOperator): globalThis.ReadonlyArray => { switch (value) { case "Exponentiation": { return [0]; } case "Multiplication": { return [1]; } case "Division": { return [2]; } case "Remainder": { return [3]; } case "Addition": { return [4]; } case "Subtraction": { return [5]; } case "LeftShift": { return [6]; } case "SignedRightShift": { return [7]; } case "UnsignedRightShift": { return [8]; } case "LessThan": { return [9]; } case "LessThanOrEqual": { return [10]; } case "Equal": { return [11]; } case "NotEqual": { return [12]; } case "BitwiseAnd": { return [13]; } case "BitwiseXOr": { return [14]; } case "BitwiseOr": { return [15]; } case "LogicalAnd": { return [16]; } case "LogicalOr": { return [17]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: BinaryOperator; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: BinaryOperator.Exponentiation, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: BinaryOperator.Multiplication, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: BinaryOperator.Division, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 3) { return { result: BinaryOperator.Remainder, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 4) { return { result: BinaryOperator.Addition, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 5) { return { result: BinaryOperator.Subtraction, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 6) { return { result: BinaryOperator.LeftShift, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 7) { return { result: BinaryOperator.SignedRightShift, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 8) { return { result: BinaryOperator.UnsignedRightShift, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 9) { return { result: BinaryOperator.LessThan, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 10) { return { result: BinaryOperator.LessThanOrEqual, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 11) { return { result: BinaryOperator.Equal, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 12) { return { result: BinaryOperator.NotEqual, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 13) { return { result: BinaryOperator.BitwiseAnd, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 14) { return { result: BinaryOperator.BitwiseXOr, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 15) { return { result: BinaryOperator.BitwiseOr, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 16) { return { result: BinaryOperator.LogicalAnd, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 17) { return { result: BinaryOperator.LogicalOr, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 型アサーション * @typePartId 49f05a756bd75da670fa5b64ed8bf1ae */ export const TypeAssertion: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: TypeAssertion) => TypeAssertion } = { typePartId: "49f05a756bd75da670fa5b64ed8bf1ae" as TypePartId, helper: (typeAssertion: TypeAssertion): TypeAssertion => typeAssertion, codec: { encode: (value: TypeAssertion): globalThis.ReadonlyArray => (TsExpr.codec.encode(value.expr).concat(TsType.codec.encode(value.type))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TypeAssertion; readonly nextIndex: number } => { const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(index, binary); const typeAndNextIndex: { readonly result: TsType; readonly nextIndex: number } = TsType.codec.decode(exprAndNextIndex.nextIndex, binary); return { result: { expr: exprAndNextIndex.result, type: typeAndNextIndex.result }, nextIndex: typeAndNextIndex.nextIndex }; } } }; /** * JavaScriptの単項演算子 * @typePartId 4b4c3f8f34d1c05bb9d7d1b930bc9c9a */ export const UnaryOperator: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 単項マイナス演算子 `-a` */ readonly Minus: UnaryOperator; /** * ビット否定 `~a` */ readonly BitwiseNot: UnaryOperator; /** * 論理否定 `!a` */ readonly LogicalNot: UnaryOperator } = { Minus: "Minus", BitwiseNot: "BitwiseNot", LogicalNot: "LogicalNot", typePartId: "4b4c3f8f34d1c05bb9d7d1b930bc9c9a" as TypePartId, codec: { encode: (value: UnaryOperator): globalThis.ReadonlyArray => { switch (value) { case "Minus": { return [0]; } case "BitwiseNot": { return [1]; } case "LogicalNot": { return [2]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: UnaryOperator; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: UnaryOperator.Minus, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: UnaryOperator.BitwiseNot, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: UnaryOperator.LogicalNot, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 型の定義本体 * @typePartId 4c60c73d6b8f236d34281fbb9119a598 */ export const TypePartBody: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 直積型 */ readonly Product: (a: List) => TypePartBody; /** * 直和型 */ readonly Sum: (a: List) => TypePartBody; /** * definyだけでは表現できないデータ型 */ readonly Kernel: (a: TypePartBodyKernel) => TypePartBody } = { Product: (memberList: List): TypePartBody => ({ _: "Product", memberList }), Sum: (patternList: List): TypePartBody => ({ _: "Sum", patternList }), Kernel: (typePartBodyKernel: TypePartBodyKernel): TypePartBody => ({ _: "Kernel", typePartBodyKernel }), typePartId: "4c60c73d6b8f236d34281fbb9119a598" as TypePartId, codec: { encode: (value: TypePartBody): globalThis.ReadonlyArray => { switch (value._) { case "Product": { return [0].concat(List.codec(Member.codec).encode(value.memberList)); } case "Sum": { return [1].concat(List.codec(Pattern.codec).encode(value.patternList)); } case "Kernel": { return [2].concat(TypePartBodyKernel.codec.encode(value.typePartBodyKernel)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TypePartBody; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(Member.codec).decode(patternIndex.nextIndex, binary); return { result: TypePartBody.Product(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(Pattern.codec).decode(patternIndex.nextIndex, binary); return { result: TypePartBody.Sum(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: TypePartBodyKernel; readonly nextIndex: number } = TypePartBodyKernel.codec.decode(patternIndex.nextIndex, binary); return { result: TypePartBody.Kernel(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * カスタム型の公開レベル * @typePartId 4e1cab8c9074c1a058d6ef3ffcf29ab0 */ export const ElmCustomTypeExportLevel: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 公開しない */ readonly NoExport: ElmCustomTypeExportLevel; /** * 型の指定のみ公開. 外部のモジュールで値の構成とパターンマッチングの分岐がされることはない */ readonly ExportTypeOnly: ElmCustomTypeExportLevel; /** * 型とバリアントを公開する. 外部のモジュールで値の構成とパターンマッチングができる */ readonly ExportTypeAndVariant: ElmCustomTypeExportLevel } = { NoExport: "NoExport", ExportTypeOnly: "ExportTypeOnly", ExportTypeAndVariant: "ExportTypeAndVariant", typePartId: "4e1cab8c9074c1a058d6ef3ffcf29ab0" as TypePartId, codec: { encode: (value: ElmCustomTypeExportLevel): globalThis.ReadonlyArray => { switch (value) { case "NoExport": { return [0]; } case "ExportTypeOnly": { return [1]; } case "ExportTypeAndVariant": { return [2]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmCustomTypeExportLevel; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: ElmCustomTypeExportLevel.NoExport, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: ElmCustomTypeExportLevel.ExportTypeOnly, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: ElmCustomTypeExportLevel.ExportTypeAndVariant, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 関数のパラメーター. パラメーター名, 型 * @typePartId 5433bade7738da21e7663ff043f588d5 */ export const Parameter: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: Parameter) => Parameter } = { typePartId: "5433bade7738da21e7663ff043f588d5" as TypePartId, helper: (parameter: Parameter): Parameter => parameter, codec: { encode: (value: Parameter): globalThis.ReadonlyArray => (TsIdentifier.codec.encode(value.name).concat(TsType.codec.encode(value.type))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Parameter; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: TsIdentifier; readonly nextIndex: number } = TsIdentifier.codec.decode(index, binary); const typeAndNextIndex: { readonly result: TsType; readonly nextIndex: number } = TsType.codec.decode(nameAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, type: typeAndNextIndex.result }, nextIndex: typeAndNextIndex.nextIndex }; } } }; /** * 辞書型. TypeScriptでは ReadonlyMap として扱う * @typePartId 5516d41d180b98b7f5a8950d4f43dfd6 */ export const Dict: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec, b: Codec) => Codec> } = { typePartId: "5516d41d180b98b7f5a8950d4f43dfd6" as TypePartId, codec: (keyCodec: Codec, valueCodec: Codec): Codec> => ({ encode: (value: Dict): globalThis.ReadonlyArray => { let result: globalThis.Array = Int32.codec.encode(value.size) as globalThis.Array; for (const element of value){ result = [...result, ...keyCodec.encode(element[0]), ...valueCodec.encode(element[1])]; } return result; }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Dict; readonly nextIndex: number } => { const lengthResult: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); let nextIndex: number = lengthResult.nextIndex; const result: globalThis.Map = new globalThis.Map([]); for (let i = 0; i < lengthResult.result; i += 1){ const keyResult: { readonly result: key; readonly nextIndex: number } = keyCodec.decode(nextIndex, binary); const valueResult: { readonly result: value; readonly nextIndex: number } = valueCodec.decode(keyResult.nextIndex, binary); result.set(keyResult.result, valueResult.result); nextIndex = valueResult.nextIndex; } return { result, nextIndex }; } }) }; /** * 取得日時と任意のデータ * @typePartId 55d4de38cfb884b9008abd7f7f63325e */ export const WithTime: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec) => Codec>; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: WithTime) => WithTime } = { typePartId: "55d4de38cfb884b9008abd7f7f63325e" as TypePartId, helper: (withTime: WithTime): WithTime => withTime, codec: (dataCodec: Codec): Codec> => ({ encode: (value: WithTime): globalThis.ReadonlyArray => (Time.codec.encode(value.getTime).concat(dataCodec.encode(value.data))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: WithTime; readonly nextIndex: number } => { const getTimeAndNextIndex: { readonly result: Time; readonly nextIndex: number } = Time.codec.decode(index, binary); const dataAndNextIndex: { readonly result: data; readonly nextIndex: number } = dataCodec.decode(getTimeAndNextIndex.nextIndex, binary); return { result: { getTime: getTimeAndNextIndex.result, data: dataAndNextIndex.result }, nextIndex: dataAndNextIndex.nextIndex }; } }) }; /** * 型エイリアス. 型に名前を付け, レコード型の場合, その名前の関数を作成する * @typePartId 57f429fd5c67eb2542447a2eaeb34497 */ export const ElmTypeAlias: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmTypeAlias) => ElmTypeAlias } = { typePartId: "57f429fd5c67eb2542447a2eaeb34497" as TypePartId, helper: (elmTypeAlias: ElmTypeAlias): ElmTypeAlias => elmTypeAlias, codec: { encode: (value: ElmTypeAlias): globalThis.ReadonlyArray => (ElmTypeName.codec.encode(value.name).concat(Bool.codec.encode(value.export)).concat(String.codec.encode(value.comment)).concat(List.codec(String.codec).encode(value.parameter)).concat(ElmType.codec.encode(value.type))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmTypeAlias; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: ElmTypeName; readonly nextIndex: number } = ElmTypeName.codec.decode(index, binary); const exportAndNextIndex: { readonly result: Bool; readonly nextIndex: number } = Bool.codec.decode(nameAndNextIndex.nextIndex, binary); const commentAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(exportAndNextIndex.nextIndex, binary); const parameterAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(String.codec).decode(commentAndNextIndex.nextIndex, binary); const typeAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(parameterAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, export: exportAndNextIndex.result, comment: commentAndNextIndex.result, parameter: parameterAndNextIndex.result, type: typeAndNextIndex.result }, nextIndex: typeAndNextIndex.nextIndex }; } } }; /** * パーツの識別子 * @typePartId 5880cd7c0b6f0205c739a06181898d03 */ export const PartId: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 文字列から変換する */ readonly fromString: (a: string) => PartId } = { typePartId: "5880cd7c0b6f0205c739a06181898d03" as TypePartId, codec: { encode: (value: PartId): globalThis.ReadonlyArray => (encodeId(value)), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: PartId; readonly nextIndex: number } => (decodeId(index, binary) as { readonly result: PartId; readonly nextIndex: number }) }, fromString: (str: string): PartId => (str as PartId) }; /** * AccountToken と AccountId * @typePartId 5d291325e9d7bc27ff35e907f59bde54 */ export const AccountTokenAccountId: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: AccountTokenAccountId) => AccountTokenAccountId } = { typePartId: "5d291325e9d7bc27ff35e907f59bde54" as TypePartId, helper: (accountTokenAccountId: AccountTokenAccountId): AccountTokenAccountId => accountTokenAccountId, codec: { encode: (value: AccountTokenAccountId): globalThis.ReadonlyArray => (AccountToken.codec.encode(value.accountToken).concat(AccountId.codec.encode(value.accountId))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: AccountTokenAccountId; readonly nextIndex: number } => { const accountTokenAndNextIndex: { readonly result: AccountToken; readonly nextIndex: number } = AccountToken.codec.decode(index, binary); const accountIdAndNextIndex: { readonly result: AccountId; readonly nextIndex: number } = AccountId.codec.decode(accountTokenAndNextIndex.nextIndex, binary); return { result: { accountToken: accountTokenAndNextIndex.result, accountId: accountIdAndNextIndex.result }, nextIndex: accountIdAndNextIndex.nextIndex }; } } }; /** * タグの識別子. タグは直和型に使うもの. * * 実行時に使わないことは確定しているが, コード内の形式としてタグにUUIDを使うべきかは考慮中. index で充分かと思ったが別に型の情報も必要になることが多い * @typePartId 5ec292c48424e5e9ee8cc2d672830ecd */ export const TagId: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 文字列から変換する */ readonly fromString: (a: string) => TagId } = { typePartId: "5ec292c48424e5e9ee8cc2d672830ecd" as TypePartId, codec: { encode: (value: TagId): globalThis.ReadonlyArray => (encodeId(value)), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TagId; readonly nextIndex: number } => (decodeId(index, binary) as { readonly result: TagId; readonly nextIndex: number }) }, fromString: (str: string): TagId => (str as TagId) }; /** * 関数の型. 入力と出力 * @typePartId 5ec9dae951d8d2b250c81185a259adca */ export const ElmFunctionType: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmFunctionType) => ElmFunctionType } = { typePartId: "5ec9dae951d8d2b250c81185a259adca" as TypePartId, helper: (elmFunctionType: ElmFunctionType): ElmFunctionType => elmFunctionType, codec: { encode: (value: ElmFunctionType): globalThis.ReadonlyArray => (ElmType.codec.encode(value.input).concat(ElmType.codec.encode(value.output))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmFunctionType; readonly nextIndex: number } => { const inputAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(index, binary); const outputAndNextIndex: { readonly result: ElmType; readonly nextIndex: number } = ElmType.codec.decode(inputAndNextIndex.nextIndex, binary); return { result: { input: inputAndNextIndex.result, output: outputAndNextIndex.result }, nextIndex: outputAndNextIndex.nextIndex }; } } }; /** * switch文のcase "text": { statementList } の部分 * @typePartId 6126431def47ecba239b3add7f472b19 */ export const TsPattern: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: TsPattern) => TsPattern } = { typePartId: "6126431def47ecba239b3add7f472b19" as TypePartId, helper: (tsPattern: TsPattern): TsPattern => tsPattern, codec: { encode: (value: TsPattern): globalThis.ReadonlyArray => (String.codec.encode(value.caseString).concat(List.codec(Statement.codec).encode(value.statementList))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TsPattern; readonly nextIndex: number } => { const caseStringAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(index, binary); const statementListAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(Statement.codec).decode(caseStringAndNextIndex.nextIndex, binary); return { result: { caseString: caseStringAndNextIndex.result, statementList: statementListAndNextIndex.result }, nextIndex: statementListAndNextIndex.nextIndex }; } } }; /** * Elmのコードを表現するもの * @typePartId 62923d32a2730114e665cef13f93ff13 */ export const ElmCode: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ElmCode) => ElmCode } = { typePartId: "62923d32a2730114e665cef13f93ff13" as TypePartId, helper: (elmCode: ElmCode): ElmCode => elmCode, codec: { encode: (value: ElmCode): globalThis.ReadonlyArray => (String.codec.encode(value.moduleName).concat(List.codec(ElmTypeDeclaration.codec).encode(value.typeDeclarationList))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ElmCode; readonly nextIndex: number } => { const moduleNameAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(index, binary); const typeDeclarationListAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(ElmTypeDeclaration.codec).decode(moduleNameAndNextIndex.nextIndex, binary); return { result: { moduleName: moduleNameAndNextIndex.result, typeDeclarationList: typeDeclarationListAndNextIndex.result }, nextIndex: typeDeclarationListAndNextIndex.nextIndex }; } } }; /** * definyだけでは表現できないデータ型 * @typePartId 657b5a5519b095480a21fdadd0f6fbd1 */ export const TypePartBodyKernel: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 32bit整数 */ readonly Int32: TypePartBodyKernel; /** * 文字列 */ readonly String: TypePartBodyKernel; /** * バイナリ型. TypeScriptではUint8Arrayとして扱う */ readonly Binary: TypePartBodyKernel; /** * UUID (16byte) を表現する. 内部表現はとりあえず0-f長さ32の文字列 */ readonly Id: TypePartBodyKernel; /** * sha256などでハッシュ化したもの (32byte) を表現する. 内部表現はとりあえず0-f長さ64の文字列 */ readonly Token: TypePartBodyKernel; /** * 配列型. TypeScriptではReadonlyArrayとして扱う */ readonly List: TypePartBodyKernel; /** * 辞書型. TypeScriptでは ReadonlyMapとして扱う */ readonly Dict: TypePartBodyKernel } = { Int32: "Int32", String: "String", Binary: "Binary", Id: "Id", Token: "Token", List: "List", Dict: "Dict", typePartId: "657b5a5519b095480a21fdadd0f6fbd1" as TypePartId, codec: { encode: (value: TypePartBodyKernel): globalThis.ReadonlyArray => { switch (value) { case "Int32": { return [0]; } case "String": { return [1]; } case "Binary": { return [2]; } case "Id": { return [3]; } case "Token": { return [4]; } case "List": { return [5]; } case "Dict": { return [6]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TypePartBodyKernel; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { return { result: TypePartBodyKernel.Int32, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 1) { return { result: TypePartBodyKernel.String, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: TypePartBodyKernel.Binary, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 3) { return { result: TypePartBodyKernel.Id, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 4) { return { result: TypePartBodyKernel.Token, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 5) { return { result: TypePartBodyKernel.List, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 6) { return { result: TypePartBodyKernel.Dict, nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 文字列. JavaScriptのstringで扱う. バイナリ形式はUTF-8. 不正な文字が入っている可能性がある * @typePartId 666361c9ae68ab64f273c47f3feb8c73 */ export const String: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec } = { typePartId: "666361c9ae68ab64f273c47f3feb8c73" as TypePartId, codec: { encode: (value: String): globalThis.ReadonlyArray => { const result: globalThis.ReadonlyArray = [...new globalThis.TextEncoder().encode(value)]; return Int32.codec.encode(result.length).concat(result); }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: String; readonly nextIndex: number } => { const length: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); const nextIndex: number = length.nextIndex + length.result; const textBinary: globalThis.Uint8Array = binary.slice(length.nextIndex, nextIndex); return { result: new globalThis.TextDecoder().decode(textBinary), nextIndex }; } } }; /** * ユーザー名. 表示される名前. 他のユーザーとかぶっても良い. 絵文字も使える. 全角英数は半角英数,半角カタカナは全角カタカナ, (株)の合字を分解するなどのNFKCの正規化がされる. U+0000-U+0019 と U+007F-U+00A0 の範囲の文字は入らない. 前後に空白を含められない. 間の空白は2文字以上連続しない. 文字数のカウント方法は正規化されたあとのCodePoint単位. Twitterと同じ, 1文字以上50文字以下 * @typePartId 67d4e3bc4f13e1132b6c5e81d5b74395 */ export const Account: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: Account) => Account } = { typePartId: "67d4e3bc4f13e1132b6c5e81d5b74395" as TypePartId, helper: (account: Account): Account => account, codec: { encode: (value: Account): globalThis.ReadonlyArray => (ImageHash.codec.encode(value.imageHash).concat(String.codec.encode(value.introduction)).concat(Time.codec.encode(value.createTime)).concat(String.codec.encode(value.name)).concat(AccountId.codec.encode(value.id))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Account; readonly nextIndex: number } => { const imageHashAndNextIndex: { readonly result: ImageHash; readonly nextIndex: number } = ImageHash.codec.decode(index, binary); const introductionAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(imageHashAndNextIndex.nextIndex, binary); const createTimeAndNextIndex: { readonly result: Time; readonly nextIndex: number } = Time.codec.decode(introductionAndNextIndex.nextIndex, binary); const nameAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(createTimeAndNextIndex.nextIndex, binary); const idAndNextIndex: { readonly result: AccountId; readonly nextIndex: number } = AccountId.codec.decode(nameAndNextIndex.nextIndex, binary); return { result: { imageHash: imageHashAndNextIndex.result, introduction: introductionAndNextIndex.result, createTime: createTimeAndNextIndex.result, name: nameAndNextIndex.result, id: idAndNextIndex.result }, nextIndex: idAndNextIndex.nextIndex }; } } }; /** * キーであるTokenによってデータが必ず1つに決まるもの. 絶対に更新されない. リソースがないということはデータが不正な状態になっているということ * @typePartId 68d925f7b35bab8f265cd9e5eb7ea3da */ export const StaticResourceState: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec) => Codec>; /** * 取得済み */ readonly Loaded: (a: data) => StaticResourceState; /** * データを取得できなかった (サーバーの障害, オフライン) */ readonly Unknown: () => StaticResourceState; /** * indexedDBにアクセス中 */ readonly Loading: () => StaticResourceState; /** * サーバに問い合わせ中 */ readonly Requesting: () => StaticResourceState } = { Loaded: (data: data): StaticResourceState => ({ _: "Loaded", data }), Unknown: (): StaticResourceState => ({ _: "Unknown" }), Loading: (): StaticResourceState => ({ _: "Loading" }), Requesting: (): StaticResourceState => ({ _: "Requesting" }), typePartId: "68d925f7b35bab8f265cd9e5eb7ea3da" as TypePartId, codec: (dataCodec: Codec): Codec> => ({ encode: (value: StaticResourceState): globalThis.ReadonlyArray => { switch (value._) { case "Loaded": { return [0].concat(dataCodec.encode(value.data)); } case "Unknown": { return [1]; } case "Loading": { return [2]; } case "Requesting": { return [3]; } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: StaticResourceState; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: data; readonly nextIndex: number } = dataCodec.decode(patternIndex.nextIndex, binary); return { result: StaticResourceState.Loaded(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { return { result: StaticResourceState.Unknown(), nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 2) { return { result: StaticResourceState.Loading(), nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 3) { return { result: StaticResourceState.Requesting(), nextIndex: patternIndex.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } }) }; /** * 代入文 * @typePartId 6a5a7886b0f117a50d9d7b11ffe87c9f */ export const SetStatement: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: SetStatement) => SetStatement } = { typePartId: "6a5a7886b0f117a50d9d7b11ffe87c9f" as TypePartId, helper: (setStatement: SetStatement): SetStatement => setStatement, codec: { encode: (value: SetStatement): globalThis.ReadonlyArray => (TsExpr.codec.encode(value.target).concat(Maybe.codec(BinaryOperator.codec).encode(value.operatorMaybe)).concat(TsExpr.codec.encode(value.expr))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: SetStatement; readonly nextIndex: number } => { const targetAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(index, binary); const operatorMaybeAndNextIndex: { readonly result: Maybe; readonly nextIndex: number } = Maybe.codec(BinaryOperator.codec).decode(targetAndNextIndex.nextIndex, binary); const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(operatorMaybeAndNextIndex.nextIndex, binary); return { result: { target: targetAndNextIndex.result, operatorMaybe: operatorMaybeAndNextIndex.result, expr: exprAndNextIndex.result }, nextIndex: exprAndNextIndex.nextIndex }; } } }; /** * ドキュメント付きの関数のパラメーター. パラメーター名, ドキュメント, 型 * @typePartId 6b05e33009ade6b4decd452e8fd4bff1 */ export const ParameterWithDocument: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: ParameterWithDocument) => ParameterWithDocument } = { typePartId: "6b05e33009ade6b4decd452e8fd4bff1" as TypePartId, helper: (parameterWithDocument: ParameterWithDocument): ParameterWithDocument => parameterWithDocument, codec: { encode: (value: ParameterWithDocument): globalThis.ReadonlyArray => (TsIdentifier.codec.encode(value.name).concat(String.codec.encode(value.document)).concat(TsType.codec.encode(value.type))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: ParameterWithDocument; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: TsIdentifier; readonly nextIndex: number } = TsIdentifier.codec.decode(index, binary); const documentAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(nameAndNextIndex.nextIndex, binary); const typeAndNextIndex: { readonly result: TsType; readonly nextIndex: number } = TsType.codec.decode(documentAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, document: documentAndNextIndex.result, type: typeAndNextIndex.result }, nextIndex: typeAndNextIndex.nextIndex }; } } }; /** * 型パーツの識別子. データ型パラメータが含まれることはなくなった * @typePartId 6e3cff317f8bfbbd1391c0afb9ad6b72 */ export const TypePartId: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 文字列から変換する */ readonly fromString: (a: string) => TypePartId } = { typePartId: "6e3cff317f8bfbbd1391c0afb9ad6b72" as TypePartId, codec: { encode: (value: TypePartId): globalThis.ReadonlyArray => (encodeId(value)), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: TypePartId; readonly nextIndex: number } => (decodeId(index, binary) as { readonly result: TypePartId; readonly nextIndex: number }) }, fromString: (str: string): TypePartId => (str as TypePartId) }; /** * 成功と失敗を表す型. 今後はRustのstd::Resultに出力するために属性をつける? * @typePartId 6f937e46fce1cf70d29c54780f132c18 */ export const Result: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: (a: Codec, b: Codec) => Codec>; /** * 成功 */ readonly Ok: (a: ok) => Result; /** * 失敗 */ readonly Error: (a: error) => Result } = { Ok: (ok: ok): Result => ({ _: "Ok", ok }), Error: (error: error): Result => ({ _: "Error", error }), typePartId: "6f937e46fce1cf70d29c54780f132c18" as TypePartId, codec: (okCodec: Codec, errorCodec: Codec): Codec> => ({ encode: (value: Result): globalThis.ReadonlyArray => { switch (value._) { case "Ok": { return [0].concat(okCodec.encode(value.ok)); } case "Error": { return [1].concat(errorCodec.encode(value.error)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Result; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: ok; readonly nextIndex: number } = okCodec.decode(patternIndex.nextIndex, binary); return { result: Result.Ok(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: error; readonly nextIndex: number } = errorCodec.decode(patternIndex.nextIndex, binary); return { result: Result.Error(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } }) }; /** * 言語とページの場所. URLとして表現されるデータ * @typePartId 7210f04a85c5f0f58f7aa20826d67f05 */ export const LocationAndLanguage: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: LocationAndLanguage) => LocationAndLanguage } = { typePartId: "7210f04a85c5f0f58f7aa20826d67f05" as TypePartId, helper: (locationAndLanguage: LocationAndLanguage): LocationAndLanguage => locationAndLanguage, codec: { encode: (value: LocationAndLanguage): globalThis.ReadonlyArray => (Location.codec.encode(value.location).concat(Language.codec.encode(value.language))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: LocationAndLanguage; readonly nextIndex: number } => { const locationAndNextIndex: { readonly result: Location; readonly nextIndex: number } = Location.codec.decode(index, binary); const languageAndNextIndex: { readonly result: Language; readonly nextIndex: number } = Language.codec.decode(locationAndNextIndex.nextIndex, binary); return { result: { location: locationAndNextIndex.result, language: languageAndNextIndex.result }, nextIndex: languageAndNextIndex.nextIndex }; } } }; /** * switch文 * @typePartId 725f84ef82e6c3b5b5f6fd5208977dd8 */ export const SwitchStatement: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: SwitchStatement) => SwitchStatement } = { typePartId: "725f84ef82e6c3b5b5f6fd5208977dd8" as TypePartId, helper: (switchStatement: SwitchStatement): SwitchStatement => switchStatement, codec: { encode: (value: SwitchStatement): globalThis.ReadonlyArray => (TsExpr.codec.encode(value.expr).concat(List.codec(TsPattern.codec).encode(value.patternList))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: SwitchStatement; readonly nextIndex: number } => { const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(index, binary); const patternListAndNextIndex: { readonly result: List; readonly nextIndex: number } = List.codec(TsPattern.codec).decode(exprAndNextIndex.nextIndex, binary); return { result: { expr: exprAndNextIndex.result, patternList: patternListAndNextIndex.result }, nextIndex: patternListAndNextIndex.nextIndex }; } } }; /** * ローカル変数定義 * @typePartId 7277cf2483388ee2f5ad7a7fc8585d98 */ export const VariableDefinitionStatement: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: VariableDefinitionStatement) => VariableDefinitionStatement } = { typePartId: "7277cf2483388ee2f5ad7a7fc8585d98" as TypePartId, helper: (variableDefinitionStatement: VariableDefinitionStatement): VariableDefinitionStatement => variableDefinitionStatement, codec: { encode: (value: VariableDefinitionStatement): globalThis.ReadonlyArray => (TsIdentifier.codec.encode(value.name).concat(TsType.codec.encode(value.type)).concat(TsExpr.codec.encode(value.expr)).concat(Bool.codec.encode(value.isConst))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: VariableDefinitionStatement; readonly nextIndex: number } => { const nameAndNextIndex: { readonly result: TsIdentifier; readonly nextIndex: number } = TsIdentifier.codec.decode(index, binary); const typeAndNextIndex: { readonly result: TsType; readonly nextIndex: number } = TsType.codec.decode(nameAndNextIndex.nextIndex, binary); const exprAndNextIndex: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(typeAndNextIndex.nextIndex, binary); const isConstAndNextIndex: { readonly result: Bool; readonly nextIndex: number } = Bool.codec.decode(exprAndNextIndex.nextIndex, binary); return { result: { name: nameAndNextIndex.result, type: typeAndNextIndex.result, expr: exprAndNextIndex.result, isConst: isConstAndNextIndex.result }, nextIndex: isConstAndNextIndex.nextIndex }; } } }; /** * プロジェクト作成時に必要なパラメーター * @typePartId 7b987551cc112a64f5c9a8cb1647f4bd */ export const CreateProjectParameter: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 型を合わせる上で便利なヘルパー関数 */ readonly helper: (a: CreateProjectParameter) => CreateProjectParameter } = { typePartId: "7b987551cc112a64f5c9a8cb1647f4bd" as TypePartId, helper: (createProjectParameter: CreateProjectParameter): CreateProjectParameter => createProjectParameter, codec: { encode: (value: CreateProjectParameter): globalThis.ReadonlyArray => (AccountToken.codec.encode(value.accountToken).concat(String.codec.encode(value.projectName))), decode: (index: number, binary: globalThis.Uint8Array): { readonly result: CreateProjectParameter; readonly nextIndex: number } => { const accountTokenAndNextIndex: { readonly result: AccountToken; readonly nextIndex: number } = AccountToken.codec.decode(index, binary); const projectNameAndNextIndex: { readonly result: String; readonly nextIndex: number } = String.codec.decode(accountTokenAndNextIndex.nextIndex, binary); return { result: { accountToken: accountTokenAndNextIndex.result, projectName: projectNameAndNextIndex.result }, nextIndex: projectNameAndNextIndex.nextIndex }; } } }; /** * JavaScript の 文 * @typePartId 7c957d411f448a03764f16d43e6e5008 */ export const Statement: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec; /** * 式を評価する */ readonly EvaluateExpr: (a: TsExpr) => Statement; /** * 代入やプロパティの値を設定する */ readonly Set: (a: SetStatement) => Statement; /** * if (condition) { thenStatementList } */ readonly If: (a: IfStatement) => Statement; /** * throw new Error("エラーメッセージ"); */ readonly ThrowError: (a: TsExpr) => Statement; /** * return expr; */ readonly Return: (a: TsExpr) => Statement; /** * 戻り値がvoidの関数を早く抜ける */ readonly ReturnVoid: Statement; /** * forの繰り返しを次に進める */ readonly Continue: Statement; /** * `const a: type_ = expr`\nローカル変数の定義 */ readonly VariableDefinition: (a: VariableDefinitionStatement) => Statement; /** * `const name = (parameterList): returnType => { statementList }`\nローカル関数の定義 */ readonly FunctionDefinition: (a: FunctionDefinitionStatement) => Statement; /** * for文. 繰り返し. */ readonly For: (a: ForStatement) => Statement; /** * for文. 繰り返し. */ readonly ForOf: (a: ForOfStatement) => Statement; /** * while (true) での無限ループ */ readonly WhileTrue: (a: List) => Statement; /** * whileのループから抜ける */ readonly Break: Statement; /** * switch文 */ readonly Switch: (a: SwitchStatement) => Statement } = { EvaluateExpr: (tsExpr: TsExpr): Statement => ({ _: "EvaluateExpr", tsExpr }), Set: (setStatement: SetStatement): Statement => ({ _: "Set", setStatement }), If: (ifStatement: IfStatement): Statement => ({ _: "If", ifStatement }), ThrowError: (tsExpr: TsExpr): Statement => ({ _: "ThrowError", tsExpr }), Return: (tsExpr: TsExpr): Statement => ({ _: "Return", tsExpr }), ReturnVoid: { _: "ReturnVoid" }, Continue: { _: "Continue" }, VariableDefinition: (variableDefinitionStatement: VariableDefinitionStatement): Statement => ({ _: "VariableDefinition", variableDefinitionStatement }), FunctionDefinition: (functionDefinitionStatement: FunctionDefinitionStatement): Statement => ({ _: "FunctionDefinition", functionDefinitionStatement }), For: (forStatement: ForStatement): Statement => ({ _: "For", forStatement }), ForOf: (forOfStatement: ForOfStatement): Statement => ({ _: "ForOf", forOfStatement }), WhileTrue: (statementList: List): Statement => ({ _: "WhileTrue", statementList }), Break: { _: "Break" }, Switch: (switchStatement: SwitchStatement): Statement => ({ _: "Switch", switchStatement }), typePartId: "7c957d411f448a03764f16d43e6e5008" as TypePartId, codec: { encode: (value: Statement): globalThis.ReadonlyArray => { switch (value._) { case "EvaluateExpr": { return [0].concat(TsExpr.codec.encode(value.tsExpr)); } case "Set": { return [1].concat(SetStatement.codec.encode(value.setStatement)); } case "If": { return [2].concat(IfStatement.codec.encode(value.ifStatement)); } case "ThrowError": { return [3].concat(TsExpr.codec.encode(value.tsExpr)); } case "Return": { return [4].concat(TsExpr.codec.encode(value.tsExpr)); } case "ReturnVoid": { return [5]; } case "Continue": { return [6]; } case "VariableDefinition": { return [7].concat(VariableDefinitionStatement.codec.encode(value.variableDefinitionStatement)); } case "FunctionDefinition": { return [8].concat(FunctionDefinitionStatement.codec.encode(value.functionDefinitionStatement)); } case "For": { return [9].concat(ForStatement.codec.encode(value.forStatement)); } case "ForOf": { return [10].concat(ForOfStatement.codec.encode(value.forOfStatement)); } case "WhileTrue": { return [11].concat(List.codec(Statement.codec).encode(value.statementList)); } case "Break": { return [12]; } case "Switch": { return [13].concat(SwitchStatement.codec.encode(value.switchStatement)); } } }, decode: (index: number, binary: globalThis.Uint8Array): { readonly result: Statement; readonly nextIndex: number } => { const patternIndex: { readonly result: number; readonly nextIndex: number } = Int32.codec.decode(index, binary); if (patternIndex.result === 0) { const result: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.EvaluateExpr(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 1) { const result: { readonly result: SetStatement; readonly nextIndex: number } = SetStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.Set(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 2) { const result: { readonly result: IfStatement; readonly nextIndex: number } = IfStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.If(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 3) { const result: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.ThrowError(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 4) { const result: { readonly result: TsExpr; readonly nextIndex: number } = TsExpr.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.Return(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 5) { return { result: Statement.ReturnVoid, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 6) { return { result: Statement.Continue, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 7) { const result: { readonly result: VariableDefinitionStatement; readonly nextIndex: number } = VariableDefinitionStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.VariableDefinition(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 8) { const result: { readonly result: FunctionDefinitionStatement; readonly nextIndex: number } = FunctionDefinitionStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.FunctionDefinition(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 9) { const result: { readonly result: ForStatement; readonly nextIndex: number } = ForStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.For(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 10) { const result: { readonly result: ForOfStatement; readonly nextIndex: number } = ForOfStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.ForOf(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 11) { const result: { readonly result: List; readonly nextIndex: number } = List.codec(Statement.codec).decode(patternIndex.nextIndex, binary); return { result: Statement.WhileTrue(result.result), nextIndex: result.nextIndex }; } if (patternIndex.result === 12) { return { result: Statement.Break, nextIndex: patternIndex.nextIndex }; } if (patternIndex.result === 13) { const result: { readonly result: SwitchStatement; readonly nextIndex: number } = SwitchStatement.codec.decode(patternIndex.nextIndex, binary); return { result: Statement.Switch(result.result), nextIndex: result.nextIndex }; } throw new Error("存在しないパターンを指定された 型を更新してください"); } } }; /** * 日時. `0001-01-01T00:00:00.000Z to 9999-12-31T23:59:59.999Z` 最小単位はミリ秒. ミリ秒の求め方は `day*1000*60*60*24 + millisecond` * @typePartId 7d91f0f70643799692aa144ee51a62b1 */ export const Time: { /** * definy.app 内 の 型パーツの Id */ readonly typePartId: TypePartId; /** * 独自のバイナリ形式の変換処理ができるコーデック */ readonly codec: Codec