auto_gen.dart 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /// Auto gen code from rust ast, do not edit
  2. part of 'cqrs.dart';
  3. class WorkspaceCreateRequest {
  4. WorkspaceCreation body;
  5. WorkspaceCreateRequest(this.body);
  6. Future<Either<Workspace, FlowyError>> send() {
  7. final command = Command.Workspace_Create;
  8. var request = RequestPacket.create()
  9. ..command = command
  10. ..id = uuid();
  11. return protobufToBytes(body).fold(
  12. (req_bytes) {
  13. request.body = req_bytes;
  14. return asyncCommand(request).then((response) {
  15. try {
  16. if (response.hasErr()) {
  17. return right(FlowyError.from(response));
  18. } else {
  19. final pb = Workspace.fromBuffer(response.body);
  20. return left(pb);
  21. }
  22. } catch (e, s) {
  23. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  24. return right(error);
  25. }
  26. });
  27. },
  28. (err) => Future(() {
  29. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  30. return right(error);
  31. }),
  32. );
  33. }
  34. }
  35. class WorkspaceDeleteRequest {
  36. IdentifiableEntity body;
  37. WorkspaceDeleteRequest(this.body);
  38. Future<Either<Workspace, FlowyError>> send() {
  39. final command = Command.Workspace_Delete;
  40. var request = RequestPacket.create()
  41. ..command = command
  42. ..id = uuid();
  43. return protobufToBytes(body).fold(
  44. (req_bytes) {
  45. request.body = req_bytes;
  46. return asyncCommand(request).then((response) {
  47. try {
  48. if (response.hasErr()) {
  49. return right(FlowyError.from(response));
  50. } else {
  51. final pb = Workspace.fromBuffer(response.body);
  52. return left(pb);
  53. }
  54. } catch (e, s) {
  55. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  56. return right(error);
  57. }
  58. });
  59. },
  60. (err) => Future(() {
  61. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  62. return right(error);
  63. }),
  64. );
  65. }
  66. }
  67. class WorkspaceUpdateRequest {
  68. WorkspaceChangeset body;
  69. WorkspaceUpdateRequest(this.body);
  70. Future<Either<Workspace, FlowyError>> send() {
  71. final command = Command.Workspace_Update;
  72. var request = RequestPacket.create()
  73. ..command = command
  74. ..id = uuid();
  75. return protobufToBytes(body).fold(
  76. (req_bytes) {
  77. request.body = req_bytes;
  78. return asyncCommand(request).then((response) {
  79. try {
  80. if (response.hasErr()) {
  81. return right(FlowyError.from(response));
  82. } else {
  83. final pb = Workspace.fromBuffer(response.body);
  84. return left(pb);
  85. }
  86. } catch (e, s) {
  87. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  88. return right(error);
  89. }
  90. });
  91. },
  92. (err) => Future(() {
  93. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  94. return right(error);
  95. }),
  96. );
  97. }
  98. }
  99. class WorkspaceQueryRequest {
  100. WorkspaceQuery body;
  101. WorkspaceQueryRequest(this.body);
  102. Future<Either<WorkspaceQueryResult, FlowyError>> send() {
  103. final command = Command.Workspace_Query;
  104. var request = RequestPacket.create()
  105. ..command = command
  106. ..id = uuid();
  107. return protobufToBytes(body).fold(
  108. (req_bytes) {
  109. request.body = req_bytes;
  110. return asyncQuery(request).then((response) {
  111. try {
  112. if (response.hasErr()) {
  113. return right(FlowyError.from(response));
  114. } else {
  115. final pb = WorkspaceQueryResult.fromBuffer(response.body);
  116. return left(pb);
  117. }
  118. } catch (e, s) {
  119. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  120. return right(error);
  121. }
  122. });
  123. },
  124. (err) => Future(() {
  125. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  126. return right(error);
  127. }),
  128. );
  129. }
  130. }
  131. class ViewCreateRequest {
  132. ViewCreation body;
  133. ViewCreateRequest(this.body);
  134. Future<Either<ViewCreation, FlowyError>> send() {
  135. final command = Command.View_Create;
  136. var request = RequestPacket.create()
  137. ..command = command
  138. ..id = uuid();
  139. return protobufToBytes(body).fold(
  140. (req_bytes) {
  141. request.body = req_bytes;
  142. return asyncCommand(request).then((response) {
  143. try {
  144. if (response.hasErr()) {
  145. return right(FlowyError.from(response));
  146. } else {
  147. final pb = ViewCreation.fromBuffer(response.body);
  148. return left(pb);
  149. }
  150. } catch (e, s) {
  151. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  152. return right(error);
  153. }
  154. });
  155. },
  156. (err) => Future(() {
  157. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  158. return right(error);
  159. }),
  160. );
  161. }
  162. }
  163. class ViewDeleteRequest {
  164. IdentifiableEntity body;
  165. ViewDeleteRequest(this.body);
  166. Future<Either<View, FlowyError>> send() {
  167. final command = Command.View_Delete;
  168. var request = RequestPacket.create()
  169. ..command = command
  170. ..id = uuid();
  171. return protobufToBytes(body).fold(
  172. (req_bytes) {
  173. request.body = req_bytes;
  174. return asyncCommand(request).then((response) {
  175. try {
  176. if (response.hasErr()) {
  177. return right(FlowyError.from(response));
  178. } else {
  179. final pb = View.fromBuffer(response.body);
  180. return left(pb);
  181. }
  182. } catch (e, s) {
  183. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  184. return right(error);
  185. }
  186. });
  187. },
  188. (err) => Future(() {
  189. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  190. return right(error);
  191. }),
  192. );
  193. }
  194. }
  195. class ViewUpdateRequest {
  196. ViewChangeset body;
  197. ViewUpdateRequest(this.body);
  198. Future<Either<View, FlowyError>> send() {
  199. final command = Command.View_Update;
  200. var request = RequestPacket.create()
  201. ..command = command
  202. ..id = uuid();
  203. return protobufToBytes(body).fold(
  204. (req_bytes) {
  205. request.body = req_bytes;
  206. return asyncCommand(request).then((response) {
  207. try {
  208. if (response.hasErr()) {
  209. return right(FlowyError.from(response));
  210. } else {
  211. final pb = View.fromBuffer(response.body);
  212. return left(pb);
  213. }
  214. } catch (e, s) {
  215. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  216. return right(error);
  217. }
  218. });
  219. },
  220. (err) => Future(() {
  221. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  222. return right(error);
  223. }),
  224. );
  225. }
  226. }
  227. class ViewQueryRequest {
  228. ViewQuery body;
  229. ViewQueryRequest(this.body);
  230. Future<Either<ViewQueryResult, FlowyError>> send() {
  231. final command = Command.View_Query;
  232. var request = RequestPacket.create()
  233. ..command = command
  234. ..id = uuid();
  235. return protobufToBytes(body).fold(
  236. (req_bytes) {
  237. request.body = req_bytes;
  238. return asyncQuery(request).then((response) {
  239. try {
  240. if (response.hasErr()) {
  241. return right(FlowyError.from(response));
  242. } else {
  243. final pb = ViewQueryResult.fromBuffer(response.body);
  244. return left(pb);
  245. }
  246. } catch (e, s) {
  247. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  248. return right(error);
  249. }
  250. });
  251. },
  252. (err) => Future(() {
  253. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  254. return right(error);
  255. }),
  256. );
  257. }
  258. }
  259. class GridViewCreateRequest {
  260. GridViewCreation body;
  261. GridViewCreateRequest(this.body);
  262. Future<Either<GridViewCreationResult, FlowyError>> send() {
  263. final command = Command.Grid_View_Create;
  264. var request = RequestPacket.create()
  265. ..command = command
  266. ..id = uuid();
  267. return protobufToBytes(body).fold(
  268. (req_bytes) {
  269. request.body = req_bytes;
  270. return asyncCommand(request).then((response) {
  271. try {
  272. if (response.hasErr()) {
  273. return right(FlowyError.from(response));
  274. } else {
  275. final pb = GridViewCreationResult.fromBuffer(response.body);
  276. return left(pb);
  277. }
  278. } catch (e, s) {
  279. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  280. return right(error);
  281. }
  282. });
  283. },
  284. (err) => Future(() {
  285. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  286. return right(error);
  287. }),
  288. );
  289. }
  290. }
  291. class ViewDisplayUpdateRequest {
  292. ViewDisplayChangeset body;
  293. ViewDisplayUpdateRequest(this.body);
  294. Future<Either<ViewDisplay, FlowyError>> send() {
  295. final command = Command.View_Display_Update;
  296. var request = RequestPacket.create()
  297. ..command = command
  298. ..id = uuid();
  299. return protobufToBytes(body).fold(
  300. (req_bytes) {
  301. request.body = req_bytes;
  302. return asyncCommand(request).then((response) {
  303. try {
  304. if (response.hasErr()) {
  305. return right(FlowyError.from(response));
  306. } else {
  307. final pb = ViewDisplay.fromBuffer(response.body);
  308. return left(pb);
  309. }
  310. } catch (e, s) {
  311. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  312. return right(error);
  313. }
  314. });
  315. },
  316. (err) => Future(() {
  317. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  318. return right(error);
  319. }),
  320. );
  321. }
  322. }
  323. class TableCreateRequest {
  324. TableCreation body;
  325. TableCreateRequest(this.body);
  326. Future<Either<TableCreation, FlowyError>> send() {
  327. final command = Command.Table_Create;
  328. var request = RequestPacket.create()
  329. ..command = command
  330. ..id = uuid();
  331. return protobufToBytes(body).fold(
  332. (req_bytes) {
  333. request.body = req_bytes;
  334. return asyncCommand(request).then((response) {
  335. try {
  336. if (response.hasErr()) {
  337. return right(FlowyError.from(response));
  338. } else {
  339. final pb = TableCreation.fromBuffer(response.body);
  340. return left(pb);
  341. }
  342. } catch (e, s) {
  343. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  344. return right(error);
  345. }
  346. });
  347. },
  348. (err) => Future(() {
  349. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  350. return right(error);
  351. }),
  352. );
  353. }
  354. }
  355. class TableDeleteRequest {
  356. IdentifiableEntity body;
  357. TableDeleteRequest(this.body);
  358. Future<Either<FYTable, FlowyError>> send() {
  359. final command = Command.Table_Delete;
  360. var request = RequestPacket.create()
  361. ..command = command
  362. ..id = uuid();
  363. return protobufToBytes(body).fold(
  364. (req_bytes) {
  365. request.body = req_bytes;
  366. return asyncCommand(request).then((response) {
  367. try {
  368. if (response.hasErr()) {
  369. return right(FlowyError.from(response));
  370. } else {
  371. final pb = FYTable.fromBuffer(response.body);
  372. return left(pb);
  373. }
  374. } catch (e, s) {
  375. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  376. return right(error);
  377. }
  378. });
  379. },
  380. (err) => Future(() {
  381. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  382. return right(error);
  383. }),
  384. );
  385. }
  386. }
  387. class TableUpdateRequest {
  388. FYTableChangeset body;
  389. TableUpdateRequest(this.body);
  390. Future<Either<FYTable, FlowyError>> send() {
  391. final command = Command.Table_Update;
  392. var request = RequestPacket.create()
  393. ..command = command
  394. ..id = uuid();
  395. return protobufToBytes(body).fold(
  396. (req_bytes) {
  397. request.body = req_bytes;
  398. return asyncCommand(request).then((response) {
  399. try {
  400. if (response.hasErr()) {
  401. return right(FlowyError.from(response));
  402. } else {
  403. final pb = FYTable.fromBuffer(response.body);
  404. return left(pb);
  405. }
  406. } catch (e, s) {
  407. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  408. return right(error);
  409. }
  410. });
  411. },
  412. (err) => Future(() {
  413. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  414. return right(error);
  415. }),
  416. );
  417. }
  418. }
  419. class TableQueryRequest {
  420. TableQuery body;
  421. TableQueryRequest(this.body);
  422. Future<Either<TableQueryResult, FlowyError>> send() {
  423. final command = Command.Table_Query;
  424. var request = RequestPacket.create()
  425. ..command = command
  426. ..id = uuid();
  427. return protobufToBytes(body).fold(
  428. (req_bytes) {
  429. request.body = req_bytes;
  430. return asyncQuery(request).then((response) {
  431. try {
  432. if (response.hasErr()) {
  433. return right(FlowyError.from(response));
  434. } else {
  435. final pb = TableQueryResult.fromBuffer(response.body);
  436. return left(pb);
  437. }
  438. } catch (e, s) {
  439. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  440. return right(error);
  441. }
  442. });
  443. },
  444. (err) => Future(() {
  445. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  446. return right(error);
  447. }),
  448. );
  449. }
  450. }
  451. class RowCreateRequest {
  452. RowCreation body;
  453. RowCreateRequest(this.body);
  454. Future<Either<Row, FlowyError>> send() {
  455. final command = Command.Row_Create;
  456. var request = RequestPacket.create()
  457. ..command = command
  458. ..id = uuid();
  459. return protobufToBytes(body).fold(
  460. (req_bytes) {
  461. request.body = req_bytes;
  462. return asyncCommand(request).then((response) {
  463. try {
  464. if (response.hasErr()) {
  465. return right(FlowyError.from(response));
  466. } else {
  467. final pb = Row.fromBuffer(response.body);
  468. return left(pb);
  469. }
  470. } catch (e, s) {
  471. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  472. return right(error);
  473. }
  474. });
  475. },
  476. (err) => Future(() {
  477. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  478. return right(error);
  479. }),
  480. );
  481. }
  482. }
  483. class RowDeleteRequest {
  484. IdentifiableEntity body;
  485. RowDeleteRequest(this.body);
  486. Future<Either<Row, FlowyError>> send() {
  487. final command = Command.Row_Delete;
  488. var request = RequestPacket.create()
  489. ..command = command
  490. ..id = uuid();
  491. return protobufToBytes(body).fold(
  492. (req_bytes) {
  493. request.body = req_bytes;
  494. return asyncCommand(request).then((response) {
  495. try {
  496. if (response.hasErr()) {
  497. return right(FlowyError.from(response));
  498. } else {
  499. final pb = Row.fromBuffer(response.body);
  500. return left(pb);
  501. }
  502. } catch (e, s) {
  503. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  504. return right(error);
  505. }
  506. });
  507. },
  508. (err) => Future(() {
  509. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  510. return right(error);
  511. }),
  512. );
  513. }
  514. }
  515. class RowUpdateRequest {
  516. RowChangeset body;
  517. RowUpdateRequest(this.body);
  518. Future<Either<Row, FlowyError>> send() {
  519. final command = Command.Row_Update;
  520. var request = RequestPacket.create()
  521. ..command = command
  522. ..id = uuid();
  523. return protobufToBytes(body).fold(
  524. (req_bytes) {
  525. request.body = req_bytes;
  526. return asyncCommand(request).then((response) {
  527. try {
  528. if (response.hasErr()) {
  529. return right(FlowyError.from(response));
  530. } else {
  531. final pb = Row.fromBuffer(response.body);
  532. return left(pb);
  533. }
  534. } catch (e, s) {
  535. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  536. return right(error);
  537. }
  538. });
  539. },
  540. (err) => Future(() {
  541. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  542. return right(error);
  543. }),
  544. );
  545. }
  546. }
  547. class RowQueryRequest {
  548. RowQuery body;
  549. RowQueryRequest(this.body);
  550. Future<Either<RowQueryResult, FlowyError>> send() {
  551. final command = Command.Row_Query;
  552. var request = RequestPacket.create()
  553. ..command = command
  554. ..id = uuid();
  555. return protobufToBytes(body).fold(
  556. (req_bytes) {
  557. request.body = req_bytes;
  558. return asyncQuery(request).then((response) {
  559. try {
  560. if (response.hasErr()) {
  561. return right(FlowyError.from(response));
  562. } else {
  563. final pb = RowQueryResult.fromBuffer(response.body);
  564. return left(pb);
  565. }
  566. } catch (e, s) {
  567. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  568. return right(error);
  569. }
  570. });
  571. },
  572. (err) => Future(() {
  573. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  574. return right(error);
  575. }),
  576. );
  577. }
  578. }
  579. class FieldCreateRequest {
  580. FieldCreation body;
  581. FieldCreateRequest(this.body);
  582. Future<Either<Field, FlowyError>> send() {
  583. final command = Command.Field_Create;
  584. var request = RequestPacket.create()
  585. ..command = command
  586. ..id = uuid();
  587. return protobufToBytes(body).fold(
  588. (req_bytes) {
  589. request.body = req_bytes;
  590. return asyncCommand(request).then((response) {
  591. try {
  592. if (response.hasErr()) {
  593. return right(FlowyError.from(response));
  594. } else {
  595. final pb = Field.fromBuffer(response.body);
  596. return left(pb);
  597. }
  598. } catch (e, s) {
  599. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  600. return right(error);
  601. }
  602. });
  603. },
  604. (err) => Future(() {
  605. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  606. return right(error);
  607. }),
  608. );
  609. }
  610. }
  611. class FieldDeleteRequest {
  612. IdentifiableEntity body;
  613. FieldDeleteRequest(this.body);
  614. Future<Either<Field, FlowyError>> send() {
  615. final command = Command.Field_Delete;
  616. var request = RequestPacket.create()
  617. ..command = command
  618. ..id = uuid();
  619. return protobufToBytes(body).fold(
  620. (req_bytes) {
  621. request.body = req_bytes;
  622. return asyncCommand(request).then((response) {
  623. try {
  624. if (response.hasErr()) {
  625. return right(FlowyError.from(response));
  626. } else {
  627. final pb = Field.fromBuffer(response.body);
  628. return left(pb);
  629. }
  630. } catch (e, s) {
  631. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  632. return right(error);
  633. }
  634. });
  635. },
  636. (err) => Future(() {
  637. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  638. return right(error);
  639. }),
  640. );
  641. }
  642. }
  643. class FieldUpdateRequest {
  644. FieldChangeset body;
  645. FieldUpdateRequest(this.body);
  646. Future<Either<Field, FlowyError>> send() {
  647. final command = Command.Field_Update;
  648. var request = RequestPacket.create()
  649. ..command = command
  650. ..id = uuid();
  651. return protobufToBytes(body).fold(
  652. (req_bytes) {
  653. request.body = req_bytes;
  654. return asyncCommand(request).then((response) {
  655. try {
  656. if (response.hasErr()) {
  657. return right(FlowyError.from(response));
  658. } else {
  659. final pb = Field.fromBuffer(response.body);
  660. return left(pb);
  661. }
  662. } catch (e, s) {
  663. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  664. return right(error);
  665. }
  666. });
  667. },
  668. (err) => Future(() {
  669. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  670. return right(error);
  671. }),
  672. );
  673. }
  674. }
  675. class FieldQueryRequest {
  676. FieldQuery body;
  677. FieldQueryRequest(this.body);
  678. Future<Either<FieldQueryResult, FlowyError>> send() {
  679. final command = Command.Field_Query;
  680. var request = RequestPacket.create()
  681. ..command = command
  682. ..id = uuid();
  683. return protobufToBytes(body).fold(
  684. (req_bytes) {
  685. request.body = req_bytes;
  686. return asyncQuery(request).then((response) {
  687. try {
  688. if (response.hasErr()) {
  689. return right(FlowyError.from(response));
  690. } else {
  691. final pb = FieldQueryResult.fromBuffer(response.body);
  692. return left(pb);
  693. }
  694. } catch (e, s) {
  695. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  696. return right(error);
  697. }
  698. });
  699. },
  700. (err) => Future(() {
  701. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  702. return right(error);
  703. }),
  704. );
  705. }
  706. }
  707. class AppCreateRequest {
  708. AppCreation body;
  709. AppCreateRequest(this.body);
  710. Future<Either<App, FlowyError>> send() {
  711. final command = Command.App_Create;
  712. var request = RequestPacket.create()
  713. ..command = command
  714. ..id = uuid();
  715. return protobufToBytes(body).fold(
  716. (req_bytes) {
  717. request.body = req_bytes;
  718. return asyncCommand(request).then((response) {
  719. try {
  720. if (response.hasErr()) {
  721. return right(FlowyError.from(response));
  722. } else {
  723. final pb = App.fromBuffer(response.body);
  724. return left(pb);
  725. }
  726. } catch (e, s) {
  727. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  728. return right(error);
  729. }
  730. });
  731. },
  732. (err) => Future(() {
  733. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  734. return right(error);
  735. }),
  736. );
  737. }
  738. }
  739. class AppDeleteRequest {
  740. IdentifiableEntity body;
  741. AppDeleteRequest(this.body);
  742. Future<Either<App, FlowyError>> send() {
  743. final command = Command.App_Delete;
  744. var request = RequestPacket.create()
  745. ..command = command
  746. ..id = uuid();
  747. return protobufToBytes(body).fold(
  748. (req_bytes) {
  749. request.body = req_bytes;
  750. return asyncCommand(request).then((response) {
  751. try {
  752. if (response.hasErr()) {
  753. return right(FlowyError.from(response));
  754. } else {
  755. final pb = App.fromBuffer(response.body);
  756. return left(pb);
  757. }
  758. } catch (e, s) {
  759. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  760. return right(error);
  761. }
  762. });
  763. },
  764. (err) => Future(() {
  765. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  766. return right(error);
  767. }),
  768. );
  769. }
  770. }
  771. class AppUpdateRequest {
  772. AppChangeset body;
  773. AppUpdateRequest(this.body);
  774. Future<Either<App, FlowyError>> send() {
  775. final command = Command.App_Update;
  776. var request = RequestPacket.create()
  777. ..command = command
  778. ..id = uuid();
  779. return protobufToBytes(body).fold(
  780. (req_bytes) {
  781. request.body = req_bytes;
  782. return asyncCommand(request).then((response) {
  783. try {
  784. if (response.hasErr()) {
  785. return right(FlowyError.from(response));
  786. } else {
  787. final pb = App.fromBuffer(response.body);
  788. return left(pb);
  789. }
  790. } catch (e, s) {
  791. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  792. return right(error);
  793. }
  794. });
  795. },
  796. (err) => Future(() {
  797. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  798. return right(error);
  799. }),
  800. );
  801. }
  802. }
  803. class AppQueryRequest {
  804. AppQuery body;
  805. AppQueryRequest(this.body);
  806. Future<Either<AppQueryResult, FlowyError>> send() {
  807. final command = Command.App_Query;
  808. var request = RequestPacket.create()
  809. ..command = command
  810. ..id = uuid();
  811. return protobufToBytes(body).fold(
  812. (req_bytes) {
  813. request.body = req_bytes;
  814. return asyncQuery(request).then((response) {
  815. try {
  816. if (response.hasErr()) {
  817. return right(FlowyError.from(response));
  818. } else {
  819. final pb = AppQueryResult.fromBuffer(response.body);
  820. return left(pb);
  821. }
  822. } catch (e, s) {
  823. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  824. return right(error);
  825. }
  826. });
  827. },
  828. (err) => Future(() {
  829. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  830. return right(error);
  831. }),
  832. );
  833. }
  834. }
  835. class CellCreateRequest {
  836. CellCreation body;
  837. CellCreateRequest(this.body);
  838. Future<Either<Cell, FlowyError>> send() {
  839. final command = Command.Cell_Create;
  840. var request = RequestPacket.create()
  841. ..command = command
  842. ..id = uuid();
  843. return protobufToBytes(body).fold(
  844. (req_bytes) {
  845. request.body = req_bytes;
  846. return asyncCommand(request).then((response) {
  847. try {
  848. if (response.hasErr()) {
  849. return right(FlowyError.from(response));
  850. } else {
  851. final pb = Cell.fromBuffer(response.body);
  852. return left(pb);
  853. }
  854. } catch (e, s) {
  855. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  856. return right(error);
  857. }
  858. });
  859. },
  860. (err) => Future(() {
  861. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  862. return right(error);
  863. }),
  864. );
  865. }
  866. }
  867. class CellDeleteRequest {
  868. IdentifiableEntity body;
  869. CellDeleteRequest(this.body);
  870. Future<Either<Cell, FlowyError>> send() {
  871. final command = Command.Cell_Delete;
  872. var request = RequestPacket.create()
  873. ..command = command
  874. ..id = uuid();
  875. return protobufToBytes(body).fold(
  876. (req_bytes) {
  877. request.body = req_bytes;
  878. return asyncCommand(request).then((response) {
  879. try {
  880. if (response.hasErr()) {
  881. return right(FlowyError.from(response));
  882. } else {
  883. final pb = Cell.fromBuffer(response.body);
  884. return left(pb);
  885. }
  886. } catch (e, s) {
  887. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  888. return right(error);
  889. }
  890. });
  891. },
  892. (err) => Future(() {
  893. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  894. return right(error);
  895. }),
  896. );
  897. }
  898. }
  899. class CellUpdateRequest {
  900. CellChangeset body;
  901. CellUpdateRequest(this.body);
  902. Future<Either<Cell, FlowyError>> send() {
  903. final command = Command.Cell_Update;
  904. var request = RequestPacket.create()
  905. ..command = command
  906. ..id = uuid();
  907. return protobufToBytes(body).fold(
  908. (req_bytes) {
  909. request.body = req_bytes;
  910. return asyncCommand(request).then((response) {
  911. try {
  912. if (response.hasErr()) {
  913. return right(FlowyError.from(response));
  914. } else {
  915. final pb = Cell.fromBuffer(response.body);
  916. return left(pb);
  917. }
  918. } catch (e, s) {
  919. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  920. return right(error);
  921. }
  922. });
  923. },
  924. (err) => Future(() {
  925. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  926. return right(error);
  927. }),
  928. );
  929. }
  930. }
  931. class CellQueryRequest {
  932. CellQuery body;
  933. CellQueryRequest(this.body);
  934. Future<Either<CellQueryResult, FlowyError>> send() {
  935. final command = Command.Cell_Query;
  936. var request = RequestPacket.create()
  937. ..command = command
  938. ..id = uuid();
  939. return protobufToBytes(body).fold(
  940. (req_bytes) {
  941. request.body = req_bytes;
  942. return asyncQuery(request).then((response) {
  943. try {
  944. if (response.hasErr()) {
  945. return right(FlowyError.from(response));
  946. } else {
  947. final pb = CellQueryResult.fromBuffer(response.body);
  948. return left(pb);
  949. }
  950. } catch (e, s) {
  951. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  952. return right(error);
  953. }
  954. });
  955. },
  956. (err) => Future(() {
  957. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  958. return right(error);
  959. }),
  960. );
  961. }
  962. }
  963. class UserQueryRequest {
  964. Uint8List? body;
  965. UserQueryRequest();
  966. Future<Either<UserQueryResult, FlowyError>> send() {
  967. final command = Command.User_Query;
  968. var request = RequestPacket.create()
  969. ..command = command
  970. ..id = uuid();
  971. return asyncQuery(request).then((response) {
  972. try {
  973. if (response.hasErr()) {
  974. return right(FlowyError.from(response));
  975. } else {
  976. final pb = UserQueryResult.fromBuffer(response.body);
  977. return left(pb);
  978. }
  979. } catch (e, s) {
  980. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  981. return right(error);
  982. }
  983. });
  984. }
  985. }
  986. class UserCheckRequest {
  987. Uint8List? body;
  988. UserCheckRequest();
  989. Future<Either<User, FlowyError>> send() {
  990. final command = Command.User_Check;
  991. var request = RequestPacket.create()
  992. ..command = command
  993. ..id = uuid();
  994. return asyncQuery(request).then((response) {
  995. try {
  996. if (response.hasErr()) {
  997. return right(FlowyError.from(response));
  998. } else {
  999. final pb = User.fromBuffer(response.body);
  1000. return left(pb);
  1001. }
  1002. } catch (e, s) {
  1003. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1004. return right(error);
  1005. }
  1006. });
  1007. }
  1008. }
  1009. class UserSignInRequest {
  1010. UserSignIn body;
  1011. UserSignInRequest(this.body);
  1012. Future<Either<UserSignInResult, FlowyError>> send() {
  1013. final command = Command.User_Sign_In;
  1014. var request = RequestPacket.create()
  1015. ..command = command
  1016. ..id = uuid();
  1017. return protobufToBytes(body).fold(
  1018. (req_bytes) {
  1019. request.body = req_bytes;
  1020. return asyncCommand(request).then((response) {
  1021. try {
  1022. if (response.hasErr()) {
  1023. return right(FlowyError.from(response));
  1024. } else {
  1025. final pb = UserSignInResult.fromBuffer(response.body);
  1026. return left(pb);
  1027. }
  1028. } catch (e, s) {
  1029. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1030. return right(error);
  1031. }
  1032. });
  1033. },
  1034. (err) => Future(() {
  1035. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1036. return right(error);
  1037. }),
  1038. );
  1039. }
  1040. }
  1041. class UserSignUpRequest {
  1042. UserSignUp body;
  1043. UserSignUpRequest(this.body);
  1044. Future<Either<UserSignUpResult, FlowyError>> send() {
  1045. final command = Command.User_Sign_Up;
  1046. var request = RequestPacket.create()
  1047. ..command = command
  1048. ..id = uuid();
  1049. return protobufToBytes(body).fold(
  1050. (req_bytes) {
  1051. request.body = req_bytes;
  1052. return asyncCommand(request).then((response) {
  1053. try {
  1054. if (response.hasErr()) {
  1055. return right(FlowyError.from(response));
  1056. } else {
  1057. final pb = UserSignUpResult.fromBuffer(response.body);
  1058. return left(pb);
  1059. }
  1060. } catch (e, s) {
  1061. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1062. return right(error);
  1063. }
  1064. });
  1065. },
  1066. (err) => Future(() {
  1067. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1068. return right(error);
  1069. }),
  1070. );
  1071. }
  1072. }
  1073. class UserSignOutRequest {
  1074. UserSignOut body;
  1075. UserSignOutRequest(this.body);
  1076. Future<Either<ResponsePacket, FlowyError>> send() {
  1077. final command = Command.User_Sign_Out;
  1078. var request = RequestPacket.create()
  1079. ..command = command
  1080. ..id = uuid();
  1081. return protobufToBytes(body).fold(
  1082. (req_bytes) {
  1083. request.body = req_bytes;
  1084. return asyncCommand(request).then((response) {
  1085. return left(response);
  1086. });
  1087. },
  1088. (err) => Future(() {
  1089. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1090. return right(error);
  1091. }),
  1092. );
  1093. }
  1094. }
  1095. class UserActiveRequest {
  1096. User body;
  1097. UserActiveRequest(this.body);
  1098. Future<Either<ResponsePacket, FlowyError>> send() {
  1099. final command = Command.User_Active;
  1100. var request = RequestPacket.create()
  1101. ..command = command
  1102. ..id = uuid();
  1103. return protobufToBytes(body).fold(
  1104. (req_bytes) {
  1105. request.body = req_bytes;
  1106. return asyncCommand(request).then((response) {
  1107. return left(response);
  1108. });
  1109. },
  1110. (err) => Future(() {
  1111. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1112. return right(error);
  1113. }),
  1114. );
  1115. }
  1116. }
  1117. class UserMobileCodeRequest {
  1118. VerificationCodeRequest body;
  1119. UserMobileCodeRequest(this.body);
  1120. Future<Either<VerificationCodeResponse, FlowyError>> send() {
  1121. final command = Command.User_Mobile_Code;
  1122. var request = RequestPacket.create()
  1123. ..command = command
  1124. ..id = uuid();
  1125. return protobufToBytes(body).fold(
  1126. (req_bytes) {
  1127. request.body = req_bytes;
  1128. return asyncQuery(request).then((response) {
  1129. try {
  1130. if (response.hasErr()) {
  1131. return right(FlowyError.from(response));
  1132. } else {
  1133. final pb = VerificationCodeResponse.fromBuffer(response.body);
  1134. return left(pb);
  1135. }
  1136. } catch (e, s) {
  1137. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1138. return right(error);
  1139. }
  1140. });
  1141. },
  1142. (err) => Future(() {
  1143. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1144. return right(error);
  1145. }),
  1146. );
  1147. }
  1148. }
  1149. class UserAuthInputRequest {
  1150. UserAuthInput body;
  1151. UserAuthInputRequest(this.body);
  1152. Future<Either<UserAuthInput, FlowyError>> send() {
  1153. final command = Command.User_Auth_Input;
  1154. var request = RequestPacket.create()
  1155. ..command = command
  1156. ..id = uuid();
  1157. return protobufToBytes(body).fold(
  1158. (req_bytes) {
  1159. request.body = req_bytes;
  1160. return asyncQuery(request).then((response) {
  1161. try {
  1162. if (response.hasErr()) {
  1163. return right(FlowyError.from(response));
  1164. } else {
  1165. final pb = UserAuthInput.fromBuffer(response.body);
  1166. return left(pb);
  1167. }
  1168. } catch (e, s) {
  1169. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1170. return right(error);
  1171. }
  1172. });
  1173. },
  1174. (err) => Future(() {
  1175. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1176. return right(error);
  1177. }),
  1178. );
  1179. }
  1180. }
  1181. class BucketSetRequest {
  1182. BucketItem body;
  1183. BucketSetRequest(this.body);
  1184. Future<Either<ResponsePacket, FlowyError>> send() {
  1185. final command = Command.Bucket_Set;
  1186. var request = RequestPacket.create()
  1187. ..command = command
  1188. ..id = uuid();
  1189. return protobufToBytes(body).fold(
  1190. (req_bytes) {
  1191. request.body = req_bytes;
  1192. return asyncCommand(request).then((response) {
  1193. return left(response);
  1194. });
  1195. },
  1196. (err) => Future(() {
  1197. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1198. return right(error);
  1199. }),
  1200. );
  1201. }
  1202. }
  1203. class BucketGetRequest {
  1204. BucketItem body;
  1205. BucketGetRequest(this.body);
  1206. Future<Either<BucketItem, FlowyError>> send() {
  1207. final command = Command.Bucket_Get;
  1208. var request = RequestPacket.create()
  1209. ..command = command
  1210. ..id = uuid();
  1211. return protobufToBytes(body).fold(
  1212. (req_bytes) {
  1213. request.body = req_bytes;
  1214. return asyncQuery(request).then((response) {
  1215. try {
  1216. if (response.hasErr()) {
  1217. return right(FlowyError.from(response));
  1218. } else {
  1219. final pb = BucketItem.fromBuffer(response.body);
  1220. return left(pb);
  1221. }
  1222. } catch (e, s) {
  1223. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1224. return right(error);
  1225. }
  1226. });
  1227. },
  1228. (err) => Future(() {
  1229. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1230. return right(error);
  1231. }),
  1232. );
  1233. }
  1234. }
  1235. class BucketDeleteRequest {
  1236. BucketItem body;
  1237. BucketDeleteRequest(this.body);
  1238. Future<Either<ResponsePacket, FlowyError>> send() {
  1239. final command = Command.Bucket_Delete;
  1240. var request = RequestPacket.create()
  1241. ..command = command
  1242. ..id = uuid();
  1243. return protobufToBytes(body).fold(
  1244. (req_bytes) {
  1245. request.body = req_bytes;
  1246. return asyncCommand(request).then((response) {
  1247. return left(response);
  1248. });
  1249. },
  1250. (err) => Future(() {
  1251. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1252. return right(error);
  1253. }),
  1254. );
  1255. }
  1256. }
  1257. class CSVImportRequest {
  1258. FlowyResource body;
  1259. CSVImportRequest(this.body);
  1260. Future<Either<ShareResult, FlowyError>> send() {
  1261. final command = Command.CSV_Import;
  1262. var request = RequestPacket.create()
  1263. ..command = command
  1264. ..id = uuid();
  1265. return protobufToBytes(body).fold(
  1266. (req_bytes) {
  1267. request.body = req_bytes;
  1268. return asyncCommand(request).then((response) {
  1269. try {
  1270. if (response.hasErr()) {
  1271. return right(FlowyError.from(response));
  1272. } else {
  1273. final pb = ShareResult.fromBuffer(response.body);
  1274. return left(pb);
  1275. }
  1276. } catch (e, s) {
  1277. final error = FlowyError.fromError('error: ${e.runtimeType}. Stack trace: $s', StatusCode.ProtobufDeserializeError);
  1278. return right(error);
  1279. }
  1280. });
  1281. },
  1282. (err) => Future(() {
  1283. final error = FlowyError.fromError(err, StatusCode.ProtobufSerializeError);
  1284. return right(error);
  1285. }),
  1286. );
  1287. }
  1288. }