PageRenderTime 72ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/pk-tools/src/lua/apigen/util.lua

https://github.com/logiceditor-com/codebase
Lua | 194 lines | 136 code | 16 blank | 42 comment | 0 complexity | c968bfd2d382e26a9bb0355de096c131 MD5 | raw file
  1. --------------------------------------------------------------------------------
  2. -- apigen/util.lua: apigen utility functions
  3. -- This file is a part of pk-tools library
  4. -- Copyright (c) Alexander Gladysh <ag@logiceditor.com>
  5. -- Copyright (c) Dmitry Potapov <dp@logiceditor.com>
  6. -- See file `COPYRIGHT` for the license
  7. --------------------------------------------------------------------------------
  8. local log, dbg, spam, log_error
  9. = import 'pk-core/log.lua' { 'make_loggers' } (
  10. "apigen/util", "AUT"
  11. )
  12. --------------------------------------------------------------------------------
  13. local arguments,
  14. optional_arguments,
  15. method_arguments
  16. = import 'lua-nucleo/args.lua'
  17. {
  18. 'arguments',
  19. 'optional_arguments',
  20. 'method_arguments',
  21. 'eat_true'
  22. }
  23. --------------------------------------------------------------------------------
  24. -- TODO: WTF?! Shouldn't it be described in schema/client_api/types.lua?
  25. local create_io_formats
  26. do
  27. -- Context must contain following generators:
  28. -- string(min, max)
  29. -- identifier(min, max)
  30. -- url()
  31. -- db_id()
  32. -- number()
  33. -- integer()
  34. -- nonnegative_integer()
  35. -- text()
  36. -- uuid()
  37. -- ilist()
  38. -- node()
  39. -- list_node()
  40. -- int_enum(name)
  41. -- string_enum(name)
  42. -- optional()
  43. -- root()
  44. --
  45. create_io_formats = function(context)
  46. arguments("table", context)
  47. return
  48. {
  49. DB_ID = context.db_id();
  50. IP = context.string(1, 15);
  51. TEXT = context.text();
  52. TIMEOFDAY = context.integer(); -- TODO: Not integer, integer(11)!
  53. WEEKDAYS = context.integer(); -- TODO: Not integer, integer(11)!
  54. FILE = context.file();
  55. OPTIONAL_FILE = context.optional(context.file());
  56. OPTIONAL_DB_ID = context.optional(context.db_id());
  57. OPTIONAL_INTEGER = context.optional(context.integer());
  58. OPTIONAL_NUMBER = context.optional(context.number());
  59. OPTIONAL_IP = context.optional(context.string(1, 15));
  60. OPTIONAL_STRING256 = context.optional(context.string(1, 256)); -- Not recommended to use.
  61. OPTIONAL_STRING128 = context.optional(context.string(1, 128)); -- Not recommended to use.
  62. OPTIONAL_STRING64 = context.optional(context.string(1, 64)); -- Not recommended to use.
  63. OPTIONAL_IDENTIFIER16 = context.optional(context.identifier(1, 16)); -- Not recommended to use.
  64. OPTIONAL_TEXT = context.optional(context.text());
  65. OPTIONAL_TIMEOFDAY = context.optional(context.integer()); -- TODO: Not integer, integer(11)!
  66. OPTIONAL_WEEKDAYS = context.optional(context.integer()); -- TODO: Not integer, integer(11)!
  67. ACCOUNT_ID = context.db_id();
  68. ABSOLUTE_URL = context.url();
  69. OPTIONAL_ABSOLUTE_URL = context.optional(context.url());
  70. API_VERSION = context.identifier(1, 256);
  71. BLOB = context.text(); -- Not recommended to use.
  72. CLIENT_API_QUERY_PARAM = context.text();
  73. CLIENT_API_QUERY_URL = context.string_enum("CLIENT_API_QUERY_URLS");
  74. DELTA_TIME = context.integer(); -- TODO: Not integer, delta_time!
  75. DESCRIPTION = context.text();
  76. EXTRA_INFO = context.text();
  77. FULLNAME = context.string(1, 256);
  78. GARDEN_ARTICUL_ID = context.db_id();
  79. GARDEN_ID = context.db_id();
  80. GARDEN_SLOT_ID = context.db_id();
  81. GARDEN_SLOT_TYPE_ID = context.db_id(); -- TODO: Enum?
  82. INTEGER = context.integer();
  83. NUMBER = context.number();
  84. LIST = context.ilist();
  85. LIST_NODE = context.root(context.list_node());
  86. MONEY_GAME = context.nonnegative_integer();
  87. MONEY_REAL = context.nonnegative_integer();
  88. NICKNAME = context.string(1, 256);
  89. NODE = context.node();
  90. OPTIONAL_ACCOUNT_ID = context.optional(context.db_id());
  91. OPTIONAL_LIST = context.optional(context.ilist());
  92. OPTIONAL_NODE = context.optional(context.node());
  93. OPTIONAL_PLANT_GROUP_ID = context.optional(context.db_id()); -- TODO: delete?
  94. OPTIONAL_SESSION_ID = context.optional(context.uuid());
  95. PLANT_ARTICUL_ID = context.db_id();
  96. PLANT_CARE_ACTION_ID = context.db_id();
  97. PLANT_GROUP_ID = context.db_id(); -- TODO: delete?
  98. PLANT_GROWTH_STAGE_NUMBER = context.integer(); -- TODO: delete?
  99. PLANT_HEALTH = context.number();
  100. PLANT_ID = context.db_id();
  101. PRICE_GAME = context.nonnegative_integer();
  102. PRICE_REAL = context.nonnegative_integer();
  103. PUBLIC_PARTNER_API_TOKEN = context.text();
  104. RELATIVE_URL = context.url();
  105. RESOURCE_SIZE = context.nonnegative_integer();
  106. RESOURCE_ID = context.db_id();
  107. ROOT_LIST = context.root(context.ilist());
  108. ROOT_NODE = context.root(context.node());
  109. SESSION_ID = context.uuid();
  110. SESSION_TTL = context.integer();
  111. STAT_EVENT_ID = context.db_id();
  112. STRING256 = context.string(1, 256); -- Not recommended to use.
  113. STRING128 = context.string(1, 128); -- Not recommended to use.
  114. STRING64 = context.string(1, 64); -- Not recommended to use.
  115. IDENTIFIER16 = context.identifier(1, 16); -- Not recommended to use.
  116. TIMESTAMP = context.integer();
  117. TITLE = context.string(1, 256);
  118. MODIFIER_ARTICUL_ID = context.db_id();
  119. GARDEN_POINTS = context.integer();
  120. BOOLEAN = context.boolean();
  121. ACTION_ID = context.integer(); -- TODO: Not integer, enumeration!
  122. PLANT_LEVEL = context.nonnegative_integer(); -- TODO: value has limit
  123. GARDEN_LEVEL = context.nonnegative_integer(); -- TODO: value has limit
  124. MODIFIER_INCOME = context.integer(); -- TODO: float with limits
  125. MODIFIER_RESISTANCE = context.integer(); -- TODO: float with limits
  126. POSITIVE_INTEGER = context.nonnegative_integer();
  127. MODIFIER_GIFT_ID = context.db_id();
  128. REDEEM_CODE = context.integer(); -- TODO: probably fixed size
  129. EXCHANGE_RATE = context.nonnegative_integer();
  130. MONEY_PARTNER = context.nonnegative_integer();
  131. MODIFIER_PERMIRIAD_VALUE = context.integer();
  132. MODIFIER_LINEAR_VALUE = context.integer();
  133. GIFT_TYPE_ID = context.db_id();
  134. GIFT_ID = context.db_id();
  135. PARAMETER_NAME = context.string(1, 256);
  136. FOTOSTRANA_ACCOUNT_ID = context.identifier(1, 256);
  137. FOTOSTRANA_SESSION_ID = context.identifier(1, 256);
  138. IPHONE_ACCOUNT_ID = context.identifier(1, 256);
  139. IPHONE_SESSION_ID = context.identifier(1, 256);
  140. TEST_ACCOUNT_ID = context.identifier(1, 256);
  141. TEST_SESSION_ID = context.identifier(1, 256);
  142. MOIMIR_VID = context.identifier(1, 256);
  143. MOIMIR_AUTHENTIFICATION_KEY = context.identifier(1, 256);
  144. VKONTAKTE_USER_ID = context.identifier(1, 256);
  145. VKONTAKTE_AUTH_KEY = context.identifier(1, 256);
  146. --------------------------------------------------------------------------------
  147. -- TYPES FOR SPPIP
  148. --------------------------------------------------------------------------------
  149. PAY_SYSTEM_ID = context.string(1, 64);
  150. PAY_SYSTEM_SUBID = context.optional(context.string(1, 64));
  151. APPLICATION_ID = context.string(1, 64);
  152. BILLING_ACCOUNT_ID = context.string(1, 256);
  153. PAYMENT_ID = context.string(1, 64);
  154. OPTIONAL_PAYMENT_ID = context.optional(context.string(1, 64));
  155. OPTIONAL_PAY_SYSTEM_ID = context.optional(context.string(1, 64));
  156. --------------------------------------------------------------------------------
  157. -- TYPES FOR MRX
  158. --------------------------------------------------------------------------------
  159. COUNTRY_CODE = context.string(2, 2);
  160. OPTIONAL_COUNTRY_CODE = context.optional(context.string(2, 2));
  161. --------------------------------------------------------------------------------
  162. -- BEGIN POSTCARDS
  163. --------------------------------------------------------------------------------
  164. -- TODO MOVE ELSEWHERE
  165. POSTCARD_GROUP_ID = context.db_id();
  166. COMMON_TEXT_ID = context.db_id();
  167. POSTCARD_ID = context.db_id();
  168. --------------------------------------------------------------------------------
  169. -- END POSTCARDS
  170. --------------------------------------------------------------------------------
  171. }
  172. end
  173. end
  174. --------------------------------------------------------------------------------
  175. return
  176. {
  177. create_io_formats = create_io_formats;
  178. }