@appsemble/lang-sdk 0.33.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/BasicValidator.d.ts +56 -0
  2. package/BasicValidator.js +174 -0
  3. package/LICENSE.md +126 -0
  4. package/README.md +119 -0
  5. package/allActions.d.ts +1 -0
  6. package/allActions.js +11 -0
  7. package/appMembers.d.ts +1 -0
  8. package/appMembers.js +9 -0
  9. package/authorization.d.ts +10 -0
  10. package/authorization.js +147 -0
  11. package/blockUtils.d.ts +31 -0
  12. package/blockUtils.js +65 -0
  13. package/constants/baseTheme.d.ts +2 -0
  14. package/constants/baseTheme.js +16 -0
  15. package/constants/fonts.d.ts +6 -0
  16. package/constants/fonts.js +1607 -0
  17. package/constants/index.d.ts +4 -0
  18. package/constants/index.js +5 -0
  19. package/constants/locale.d.ts +4 -0
  20. package/constants/locale.js +5 -0
  21. package/constants/patterns.d.ts +41 -0
  22. package/constants/patterns.js +42 -0
  23. package/examples.d.ts +23 -0
  24. package/examples.js +975 -0
  25. package/findPageByName.d.ts +2 -0
  26. package/findPageByName.js +15 -0
  27. package/ics.d.ts +3 -0
  28. package/ics.js +41 -0
  29. package/index.d.ts +18 -0
  30. package/index.js +19 -0
  31. package/iterApp.d.ts +64 -0
  32. package/iterApp.js +150 -0
  33. package/jsonPointer.d.ts +18 -0
  34. package/jsonPointer.js +24 -0
  35. package/jsonschema.d.ts +54 -0
  36. package/jsonschema.js +185 -0
  37. package/mapValues.d.ts +1 -0
  38. package/mapValues.js +8 -0
  39. package/miscellaneous.d.ts +38 -0
  40. package/miscellaneous.js +66 -0
  41. package/noop.d.ts +4 -0
  42. package/noop.js +6 -0
  43. package/normalize.d.ts +13 -0
  44. package/normalize.js +24 -0
  45. package/package.json +66 -0
  46. package/reference-schemas/actions/appMember.d.ts +2 -0
  47. package/reference-schemas/actions/appMember.js +21 -0
  48. package/reference-schemas/actions/flow.d.ts +2 -0
  49. package/reference-schemas/actions/flow.js +13 -0
  50. package/reference-schemas/actions/group.d.ts +2 -0
  51. package/reference-schemas/actions/group.js +13 -0
  52. package/reference-schemas/actions/index.d.ts +7 -0
  53. package/reference-schemas/actions/index.js +8 -0
  54. package/reference-schemas/actions/link.d.ts +2 -0
  55. package/reference-schemas/actions/link.js +9 -0
  56. package/reference-schemas/actions/miscellaneous.d.ts +2 -0
  57. package/reference-schemas/actions/miscellaneous.js +43 -0
  58. package/reference-schemas/actions/resources.d.ts +2 -0
  59. package/reference-schemas/actions/resources.js +19 -0
  60. package/reference-schemas/actions/storage.d.ts +2 -0
  61. package/reference-schemas/actions/storage.js +15 -0
  62. package/reference-schemas/index.d.ts +2 -0
  63. package/reference-schemas/index.js +3 -0
  64. package/reference-schemas/remappers/arrays.d.ts +2 -0
  65. package/reference-schemas/remappers/arrays.js +297 -0
  66. package/reference-schemas/remappers/conditionals.d.ts +2 -0
  67. package/reference-schemas/remappers/conditionals.js +167 -0
  68. package/reference-schemas/remappers/config.d.ts +2 -0
  69. package/reference-schemas/remappers/config.js +13 -0
  70. package/reference-schemas/remappers/data.d.ts +2 -0
  71. package/reference-schemas/remappers/data.js +394 -0
  72. package/reference-schemas/remappers/dates.d.ts +2 -0
  73. package/reference-schemas/remappers/dates.js +94 -0
  74. package/reference-schemas/remappers/history.d.ts +2 -0
  75. package/reference-schemas/remappers/history.js +246 -0
  76. package/reference-schemas/remappers/index.d.ts +12 -0
  77. package/reference-schemas/remappers/index.js +13 -0
  78. package/reference-schemas/remappers/numbers.d.ts +2 -0
  79. package/reference-schemas/remappers/numbers.js +30 -0
  80. package/reference-schemas/remappers/objects.d.ts +2 -0
  81. package/reference-schemas/remappers/objects.js +127 -0
  82. package/reference-schemas/remappers/odata.d.ts +2 -0
  83. package/reference-schemas/remappers/odata.js +95 -0
  84. package/reference-schemas/remappers/randoms.d.ts +2 -0
  85. package/reference-schemas/remappers/randoms.js +82 -0
  86. package/reference-schemas/remappers/strings.d.ts +2 -0
  87. package/reference-schemas/remappers/strings.js +93 -0
  88. package/reference-schemas/remappers/unsorted.d.ts +2 -0
  89. package/reference-schemas/remappers/unsorted.js +276 -0
  90. package/remap.d.ts +75 -0
  91. package/remap.js +691 -0
  92. package/schemas/AppDefinition.d.ts +2 -0
  93. package/schemas/AppDefinition.js +126 -0
  94. package/schemas/AppLayoutDefinition.d.ts +2 -0
  95. package/schemas/AppLayoutDefinition.js +59 -0
  96. package/schemas/AppMemberPropertyDefinition.d.ts +2 -0
  97. package/schemas/AppMemberPropertyDefinition.js +49 -0
  98. package/schemas/AppMembersDefinition.d.ts +2 -0
  99. package/schemas/AppMembersDefinition.js +17 -0
  100. package/schemas/ArrayRemapperDefinition.d.ts +2 -0
  101. package/schemas/ArrayRemapperDefinition.js +22 -0
  102. package/schemas/BasePageDefinition.d.ts +2 -0
  103. package/schemas/BasePageDefinition.js +92 -0
  104. package/schemas/BlockDefinition.d.ts +2 -0
  105. package/schemas/BlockDefinition.js +94 -0
  106. package/schemas/ContainerDefinition.d.ts +2 -0
  107. package/schemas/ContainerDefinition.js +52 -0
  108. package/schemas/ContainerPageDefinition.d.ts +1 -0
  109. package/schemas/ContainerPageDefinition.js +56 -0
  110. package/schemas/ControllerDefinition.d.ts +2 -0
  111. package/schemas/ControllerDefinition.js +17 -0
  112. package/schemas/CronDefinition.d.ts +2 -0
  113. package/schemas/CronDefinition.js +20 -0
  114. package/schemas/CustomFontDefinition.d.ts +2 -0
  115. package/schemas/CustomFontDefinition.js +20 -0
  116. package/schemas/EventsDefinition.d.ts +2 -0
  117. package/schemas/EventsDefinition.js +29 -0
  118. package/schemas/FilterParametersDefinition.d.ts +2 -0
  119. package/schemas/FilterParametersDefinition.js +15 -0
  120. package/schemas/FlowPageActionsDefinition.d.ts +2 -0
  121. package/schemas/FlowPageActionsDefinition.js +23 -0
  122. package/schemas/FlowPageDefinition.d.ts +1 -0
  123. package/schemas/FlowPageDefinition.js +37 -0
  124. package/schemas/GoogleFontDefinition.d.ts +2 -0
  125. package/schemas/GoogleFontDefinition.js +22 -0
  126. package/schemas/LoopPageActionsDefinition.d.ts +2 -0
  127. package/schemas/LoopPageActionsDefinition.js +24 -0
  128. package/schemas/LoopPageDefinition.d.ts +1 -0
  129. package/schemas/LoopPageDefinition.js +32 -0
  130. package/schemas/NotificationHookDataDefinition.d.ts +2 -0
  131. package/schemas/NotificationHookDataDefinition.js +24 -0
  132. package/schemas/NotificationHookDefinition.d.ts +2 -0
  133. package/schemas/NotificationHookDefinition.js +32 -0
  134. package/schemas/ObjectRemapperDefinition.d.ts +2 -0
  135. package/schemas/ObjectRemapperDefinition.js +17 -0
  136. package/schemas/PageActionsDefinition.d.ts +2 -0
  137. package/schemas/PageActionsDefinition.js +12 -0
  138. package/schemas/PageDefinition.d.ts +1 -0
  139. package/schemas/PageDefinition.js +26 -0
  140. package/schemas/RemapperDefinition.d.ts +2 -0
  141. package/schemas/RemapperDefinition.js +27 -0
  142. package/schemas/ResourceDefinition.d.ts +2 -0
  143. package/schemas/ResourceDefinition.js +263 -0
  144. package/schemas/ResourceHistoryDefinition.d.ts +2 -0
  145. package/schemas/ResourceHistoryDefinition.js +14 -0
  146. package/schemas/ResourceHooksDefinition.d.ts +2 -0
  147. package/schemas/ResourceHooksDefinition.js +10 -0
  148. package/schemas/ResourceViewDefinition.d.ts +2 -0
  149. package/schemas/ResourceViewDefinition.js +24 -0
  150. package/schemas/SecurityCronDefinition.d.ts +2 -0
  151. package/schemas/SecurityCronDefinition.js +26 -0
  152. package/schemas/SecurityDefaultDefinition.d.ts +2 -0
  153. package/schemas/SecurityDefaultDefinition.js +34 -0
  154. package/schemas/SecurityDefinition.d.ts +2 -0
  155. package/schemas/SecurityDefinition.js +17 -0
  156. package/schemas/SecurityGuestDefinition.d.ts +2 -0
  157. package/schemas/SecurityGuestDefinition.js +26 -0
  158. package/schemas/SecurityRoleDefinition.d.ts +2 -0
  159. package/schemas/SecurityRoleDefinition.js +35 -0
  160. package/schemas/SubPage.d.ts +2 -0
  161. package/schemas/SubPage.js +36 -0
  162. package/schemas/TabsPageDefinition.d.ts +1 -0
  163. package/schemas/TabsPageDefinition.js +46 -0
  164. package/schemas/Theme.d.ts +2 -0
  165. package/schemas/Theme.js +81 -0
  166. package/schemas/WebhookDefinition.d.ts +2 -0
  167. package/schemas/WebhookDefinition.js +17 -0
  168. package/schemas/actions/ActionDefinition.d.ts +2 -0
  169. package/schemas/actions/ActionDefinition.js +95 -0
  170. package/schemas/actions/AnalyticsActionDefinition.d.ts +1 -0
  171. package/schemas/actions/AnalyticsActionDefinition.js +25 -0
  172. package/schemas/actions/AppMemberCurrentPatchActionDefinition.d.ts +1 -0
  173. package/schemas/actions/AppMemberCurrentPatchActionDefinition.js +30 -0
  174. package/schemas/actions/AppMemberDeleteActionDefinition.d.ts +1 -0
  175. package/schemas/actions/AppMemberDeleteActionDefinition.js +20 -0
  176. package/schemas/actions/AppMemberInviteActionDefinition.d.ts +1 -0
  177. package/schemas/actions/AppMemberInviteActionDefinition.js +24 -0
  178. package/schemas/actions/AppMemberLoginActionDefinition.d.ts +1 -0
  179. package/schemas/actions/AppMemberLoginActionDefinition.js +24 -0
  180. package/schemas/actions/AppMemberLogoutActionDefinition.d.ts +1 -0
  181. package/schemas/actions/AppMemberLogoutActionDefinition.js +14 -0
  182. package/schemas/actions/AppMemberPropertiesPatchActionDefinition.d.ts +1 -0
  183. package/schemas/actions/AppMemberPropertiesPatchActionDefinition.js +26 -0
  184. package/schemas/actions/AppMemberQueryActionDefinition.d.ts +1 -0
  185. package/schemas/actions/AppMemberQueryActionDefinition.js +24 -0
  186. package/schemas/actions/AppMemberRegisterActionDefinition.d.ts +1 -0
  187. package/schemas/actions/AppMemberRegisterActionDefinition.js +43 -0
  188. package/schemas/actions/AppMemberRoleUpdateActionDefinition.d.ts +1 -0
  189. package/schemas/actions/AppMemberRoleUpdateActionDefinition.js +27 -0
  190. package/schemas/actions/BaseActionDefinition.d.ts +2 -0
  191. package/schemas/actions/BaseActionDefinition.js +10 -0
  192. package/schemas/actions/ConditionActionDefinition.d.ts +1 -0
  193. package/schemas/actions/ConditionActionDefinition.js +30 -0
  194. package/schemas/actions/ControllerActionDefinition.d.ts +1 -0
  195. package/schemas/actions/ControllerActionDefinition.js +18 -0
  196. package/schemas/actions/CsvParseActionDefinition.d.ts +1 -0
  197. package/schemas/actions/CsvParseActionDefinition.js +22 -0
  198. package/schemas/actions/DialogActionDefinition.d.ts +1 -0
  199. package/schemas/actions/DialogActionDefinition.js +40 -0
  200. package/schemas/actions/DialogErrorActionDefinition.d.ts +1 -0
  201. package/schemas/actions/DialogErrorActionDefinition.js +17 -0
  202. package/schemas/actions/DialogOkActionDefinition.d.ts +1 -0
  203. package/schemas/actions/DialogOkActionDefinition.js +17 -0
  204. package/schemas/actions/DownloadActionDefinition.d.ts +1 -0
  205. package/schemas/actions/DownloadActionDefinition.js +19 -0
  206. package/schemas/actions/EachActionDefinition.d.ts +1 -0
  207. package/schemas/actions/EachActionDefinition.js +26 -0
  208. package/schemas/actions/EmailActionDefinition.d.ts +1 -0
  209. package/schemas/actions/EmailActionDefinition.js +54 -0
  210. package/schemas/actions/EventActionDefinition.d.ts +1 -0
  211. package/schemas/actions/EventActionDefinition.js +27 -0
  212. package/schemas/actions/FlowBackActionDefinition.d.ts +1 -0
  213. package/schemas/actions/FlowBackActionDefinition.js +16 -0
  214. package/schemas/actions/FlowCancelActionDefinition.d.ts +1 -0
  215. package/schemas/actions/FlowCancelActionDefinition.js +14 -0
  216. package/schemas/actions/FlowFinishActionDefinition.d.ts +1 -0
  217. package/schemas/actions/FlowFinishActionDefinition.js +16 -0
  218. package/schemas/actions/FlowNextActionDefinition.d.ts +1 -0
  219. package/schemas/actions/FlowNextActionDefinition.js +17 -0
  220. package/schemas/actions/FlowToActionDefinition.d.ts +1 -0
  221. package/schemas/actions/FlowToActionDefinition.js +21 -0
  222. package/schemas/actions/GroupMemberDeleteActionDefinition.d.ts +1 -0
  223. package/schemas/actions/GroupMemberDeleteActionDefinition.js +18 -0
  224. package/schemas/actions/GroupMemberInviteActionDefinition.d.ts +1 -0
  225. package/schemas/actions/GroupMemberInviteActionDefinition.js +26 -0
  226. package/schemas/actions/GroupMemberQueryActionDefinition.d.ts +1 -0
  227. package/schemas/actions/GroupMemberQueryActionDefinition.js +18 -0
  228. package/schemas/actions/GroupMemberRoleUpdateActionDefinition.d.ts +1 -0
  229. package/schemas/actions/GroupMemberRoleUpdateActionDefinition.js +22 -0
  230. package/schemas/actions/GroupQueryActionDefinition.d.ts +1 -0
  231. package/schemas/actions/GroupQueryActionDefinition.js +14 -0
  232. package/schemas/actions/LinkActionDefinition.d.ts +1 -0
  233. package/schemas/actions/LinkActionDefinition.js +29 -0
  234. package/schemas/actions/LinkBackActionDefinition.d.ts +1 -0
  235. package/schemas/actions/LinkBackActionDefinition.js +14 -0
  236. package/schemas/actions/LinkNextActionDefinition.d.ts +1 -0
  237. package/schemas/actions/LinkNextActionDefinition.js +14 -0
  238. package/schemas/actions/LogActionDefinition.d.ts +1 -0
  239. package/schemas/actions/LogActionDefinition.js +22 -0
  240. package/schemas/actions/MatchActionDefinition.d.ts +1 -0
  241. package/schemas/actions/MatchActionDefinition.js +35 -0
  242. package/schemas/actions/MessageActionDefinition.d.ts +1 -0
  243. package/schemas/actions/MessageActionDefinition.js +40 -0
  244. package/schemas/actions/NoopActionDefinition.d.ts +1 -0
  245. package/schemas/actions/NoopActionDefinition.js +17 -0
  246. package/schemas/actions/NotifyActionDefinition.d.ts +1 -0
  247. package/schemas/actions/NotifyActionDefinition.js +32 -0
  248. package/schemas/actions/RequestActionDefinition.d.ts +1 -0
  249. package/schemas/actions/RequestActionDefinition.js +75 -0
  250. package/schemas/actions/ResourceCountActionDefinition.d.ts +1 -0
  251. package/schemas/actions/ResourceCountActionDefinition.js +22 -0
  252. package/schemas/actions/ResourceCreateActionDefinition.d.ts +1 -0
  253. package/schemas/actions/ResourceCreateActionDefinition.js +18 -0
  254. package/schemas/actions/ResourceDeleteActionDefinition.d.ts +1 -0
  255. package/schemas/actions/ResourceDeleteActionDefinition.js +18 -0
  256. package/schemas/actions/ResourceDeleteAllActionDefinition.d.ts +1 -0
  257. package/schemas/actions/ResourceDeleteAllActionDefinition.js +21 -0
  258. package/schemas/actions/ResourceDeleteBulkActionDefinition.d.ts +1 -0
  259. package/schemas/actions/ResourceDeleteBulkActionDefinition.js +18 -0
  260. package/schemas/actions/ResourceGetActionDefinition.d.ts +1 -0
  261. package/schemas/actions/ResourceGetActionDefinition.js +25 -0
  262. package/schemas/actions/ResourceHistoryGetActionDefinition.d.ts +1 -0
  263. package/schemas/actions/ResourceHistoryGetActionDefinition.js +18 -0
  264. package/schemas/actions/ResourcePatchActionDefinition.d.ts +1 -0
  265. package/schemas/actions/ResourcePatchActionDefinition.js +21 -0
  266. package/schemas/actions/ResourceQueryActionDefinition.d.ts +1 -0
  267. package/schemas/actions/ResourceQueryActionDefinition.js +26 -0
  268. package/schemas/actions/ResourceSubscriptionStatusActionDefinition.d.ts +1 -0
  269. package/schemas/actions/ResourceSubscriptionStatusActionDefinition.js +23 -0
  270. package/schemas/actions/ResourceSubscriptionSubscribeActionDefinition.d.ts +1 -0
  271. package/schemas/actions/ResourceSubscriptionSubscribeActionDefinition.js +23 -0
  272. package/schemas/actions/ResourceSubscriptionToggleActionDefinition.d.ts +1 -0
  273. package/schemas/actions/ResourceSubscriptionToggleActionDefinition.js +23 -0
  274. package/schemas/actions/ResourceSubscriptionUnsubscribeActionDefinition.d.ts +1 -0
  275. package/schemas/actions/ResourceSubscriptionUnsubscribeActionDefinition.js +23 -0
  276. package/schemas/actions/ResourceUpdateActionDefinition.d.ts +1 -0
  277. package/schemas/actions/ResourceUpdateActionDefinition.js +18 -0
  278. package/schemas/actions/ResourceUpdatePositionsActionDefinition.d.ts +1 -0
  279. package/schemas/actions/ResourceUpdatePositionsActionDefinition.js +21 -0
  280. package/schemas/actions/ShareActionDefinition.d.ts +1 -0
  281. package/schemas/actions/ShareActionDefinition.js +30 -0
  282. package/schemas/actions/StaticActionDefinition.d.ts +1 -0
  283. package/schemas/actions/StaticActionDefinition.js +20 -0
  284. package/schemas/actions/StorageAppendActionDefinition.d.ts +1 -0
  285. package/schemas/actions/StorageAppendActionDefinition.js +43 -0
  286. package/schemas/actions/StorageDeleteActionDefinition.d.ts +1 -0
  287. package/schemas/actions/StorageDeleteActionDefinition.js +31 -0
  288. package/schemas/actions/StorageReadActionDefinition.d.ts +1 -0
  289. package/schemas/actions/StorageReadActionDefinition.js +32 -0
  290. package/schemas/actions/StorageSubtractActionDefinition.d.ts +1 -0
  291. package/schemas/actions/StorageSubtractActionDefinition.js +35 -0
  292. package/schemas/actions/StorageUpdateActionDefinition.d.ts +1 -0
  293. package/schemas/actions/StorageUpdateActionDefinition.js +46 -0
  294. package/schemas/actions/StorageWriteActionDefinition.d.ts +1 -0
  295. package/schemas/actions/StorageWriteActionDefinition.js +46 -0
  296. package/schemas/actions/ThrowActionDefinition.d.ts +1 -0
  297. package/schemas/actions/ThrowActionDefinition.js +17 -0
  298. package/schemas/index.d.ts +121 -0
  299. package/schemas/index.js +122 -0
  300. package/schemas/json/BaseJSONSchema.d.ts +2 -0
  301. package/schemas/json/BaseJSONSchema.js +24 -0
  302. package/schemas/json/JSONPointer.d.ts +1 -0
  303. package/schemas/json/JSONPointer.js +20 -0
  304. package/schemas/json/JSONSchema.d.ts +2 -0
  305. package/schemas/json/JSONSchema.js +20 -0
  306. package/schemas/json/JSONSchemaAnyOf.d.ts +1 -0
  307. package/schemas/json/JSONSchemaAnyOf.js +26 -0
  308. package/schemas/json/JSONSchemaArray.d.ts +1 -0
  309. package/schemas/json/JSONSchemaArray.js +47 -0
  310. package/schemas/json/JSONSchemaBoolean.d.ts +1 -0
  311. package/schemas/json/JSONSchemaBoolean.js +37 -0
  312. package/schemas/json/JSONSchemaConst.d.ts +1 -0
  313. package/schemas/json/JSONSchemaConst.js +16 -0
  314. package/schemas/json/JSONSchemaEnum.d.ts +1 -0
  315. package/schemas/json/JSONSchemaEnum.js +36 -0
  316. package/schemas/json/JSONSchemaInteger.d.ts +1 -0
  317. package/schemas/json/JSONSchemaInteger.js +55 -0
  318. package/schemas/json/JSONSchemaMultiType.d.ts +1 -0
  319. package/schemas/json/JSONSchemaMultiType.js +48 -0
  320. package/schemas/json/JSONSchemaNot.d.ts +1 -0
  321. package/schemas/json/JSONSchemaNot.js +23 -0
  322. package/schemas/json/JSONSchemaNull.d.ts +1 -0
  323. package/schemas/json/JSONSchemaNull.js +16 -0
  324. package/schemas/json/JSONSchemaNumber.d.ts +1 -0
  325. package/schemas/json/JSONSchemaNumber.js +63 -0
  326. package/schemas/json/JSONSchemaObject.d.ts +1 -0
  327. package/schemas/json/JSONSchemaObject.js +74 -0
  328. package/schemas/json/JSONSchemaOneOf.d.ts +1 -0
  329. package/schemas/json/JSONSchemaOneOf.js +24 -0
  330. package/schemas/json/JSONSchemaRemapper.d.ts +1 -0
  331. package/schemas/json/JSONSchemaRemapper.js +19 -0
  332. package/schemas/json/JSONSchemaRoot.d.ts +1 -0
  333. package/schemas/json/JSONSchemaRoot.js +21 -0
  334. package/schemas/json/JSONSchemaString.d.ts +1 -0
  335. package/schemas/json/JSONSchemaString.js +107 -0
  336. package/schemas/utils/extendJSONSchema.d.ts +13 -0
  337. package/schemas/utils/extendJSONSchema.js +34 -0
  338. package/serverActions.d.ts +2 -0
  339. package/serverActions.js +21 -0
  340. package/string.d.ts +23 -0
  341. package/string.js +30 -0
  342. package/types/ActionError.d.ts +38 -0
  343. package/types/ActionError.js +30 -0
  344. package/types/action.d.ts +51 -0
  345. package/types/action.js +2 -0
  346. package/types/actionDefinition.d.ts +605 -0
  347. package/types/actionDefinition.js +2 -0
  348. package/types/block.d.ts +81 -0
  349. package/types/block.js +2 -0
  350. package/types/bulma.d.ts +5 -0
  351. package/types/bulma.js +2 -0
  352. package/types/container.d.ts +46 -0
  353. package/types/container.js +2 -0
  354. package/types/core.d.ts +322 -0
  355. package/types/core.js +2 -0
  356. package/types/http.d.ts +6 -0
  357. package/types/http.js +2 -0
  358. package/types/index.d.ts +115 -0
  359. package/types/index.js +17 -0
  360. package/types/layout.d.ts +2 -0
  361. package/types/layout.js +2 -0
  362. package/types/member.d.ts +43 -0
  363. package/types/member.js +2 -0
  364. package/types/permission.d.ts +102 -0
  365. package/types/permission.js +104 -0
  366. package/types/remapper.d.ts +584 -0
  367. package/types/remapper.js +2 -0
  368. package/types/resource.d.ts +145 -0
  369. package/types/resource.js +2 -0
  370. package/types/roles.d.ts +20 -0
  371. package/types/roles.js +61 -0
  372. package/types/security.d.ts +42 -0
  373. package/types/security.js +2 -0
  374. package/types/theme.d.ts +54 -0
  375. package/types/theme.js +2 -0
  376. package/validation.d.ts +25 -0
  377. package/validation.js +1237 -0
package/remap.js ADDED
@@ -0,0 +1,691 @@
1
+ import { filter, literalValues, param } from '@odata/parser';
2
+ import { addMilliseconds, format, parse, parseISO } from 'date-fns';
3
+ import equal from 'fast-deep-equal';
4
+ import { XMLParser } from 'fast-xml-parser';
5
+ import { createEvent } from 'ics';
6
+ import parseDuration from 'parse-duration';
7
+ import { getDuration, processLocation } from './ics.js';
8
+ import { mapValues } from './mapValues.js';
9
+ import { has, stripNullValues } from './miscellaneous.js';
10
+ class RemapperError extends TypeError {
11
+ constructor(message, remapper) {
12
+ super(message);
13
+ this.name = 'RemapperError';
14
+ this.remapper = remapper;
15
+ }
16
+ }
17
+ function isPlainObject(value) {
18
+ return value != null && typeof value === 'object' && !Array.isArray(value);
19
+ }
20
+ function isEqualArray(a, b) {
21
+ if (a.length !== b.length) {
22
+ return false;
23
+ }
24
+ return a.every((val, i) => val === b[i]);
25
+ }
26
+ function isEqualObject(a, b) {
27
+ const aKeys = Object.keys(a);
28
+ const bKeys = Object.keys(b);
29
+ if (aKeys.length !== bKeys.length) {
30
+ return false;
31
+ }
32
+ return aKeys.every((key) => bKeys.includes(key) && equal(a[key], b[key]));
33
+ }
34
+ function isNumber(a) {
35
+ return a !== undefined && a != null && a !== '' && !Number.isNaN(Number(a));
36
+ }
37
+ export function remap(remapper, input, context) {
38
+ if (typeof remapper === 'string' ||
39
+ typeof remapper === 'number' ||
40
+ typeof remapper === 'boolean' ||
41
+ remapper == null) {
42
+ return remapper;
43
+ }
44
+ let result = input;
45
+ // Workaround for ts(2589) Type instantiation is excessively deep and possibly infinite
46
+ const remappers = Array.isArray(remapper)
47
+ ? remapper.flat(Number.POSITIVE_INFINITY)
48
+ : [remapper];
49
+ for (const mapper of remappers) {
50
+ const entries = Object.entries(mapper);
51
+ if (entries.length !== 1) {
52
+ console.error(mapper);
53
+ throw new RemapperError(`Remapper has multiple keys: ${Object.keys(mapper)
54
+ .map((key) => JSON.stringify(key))
55
+ .join(', ')}`, mapper);
56
+ }
57
+ const [[name, args]] = entries;
58
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
59
+ if (!has(mapperImplementations, name)) {
60
+ console.error(mapper);
61
+ throw new RemapperError(`Remapper name does not exist: ${JSON.stringify(name)}`, mapper);
62
+ }
63
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
64
+ const implementation = mapperImplementations[name];
65
+ result = implementation(args, result, { root: input, ...context });
66
+ }
67
+ return result;
68
+ }
69
+ /**
70
+ * Implementations of all remappers.
71
+ *
72
+ * All arguments are deferred from remappers.
73
+ *
74
+ * @see Remappers
75
+ */
76
+ const mapperImplementations = {
77
+ app(prop, input, context) {
78
+ if (prop === 'id') {
79
+ return context.appId;
80
+ }
81
+ if (prop === 'locale') {
82
+ return context.locale;
83
+ }
84
+ if (prop === 'url') {
85
+ return context.appUrl;
86
+ }
87
+ throw new Error(`Unknown app property: ${prop}`);
88
+ },
89
+ page(prop, input, context) {
90
+ if (prop === 'data') {
91
+ return context.pageData;
92
+ }
93
+ if (prop === 'url') {
94
+ return context.url;
95
+ }
96
+ throw new Error(`Unknown page property: ${prop}`);
97
+ },
98
+ context(prop, input, context) {
99
+ let result = context.context;
100
+ for (const p of String(prop).split('.')) {
101
+ if (result == null) {
102
+ return null;
103
+ }
104
+ result = result[p];
105
+ }
106
+ return result ?? null;
107
+ },
108
+ variable(name, input, context) {
109
+ if (context.getVariable) {
110
+ return context.getVariable(name);
111
+ }
112
+ return { variable: name };
113
+ },
114
+ equals(mappers, input, context) {
115
+ if (mappers.length <= 1) {
116
+ return true;
117
+ }
118
+ const values = mappers.map((mapper) => remap(mapper, input, context));
119
+ return values.every((value) => equal(values[0], value));
120
+ },
121
+ not(mappers, input, context) {
122
+ if (mappers.length <= 1) {
123
+ return !remap(mappers[0], input, context);
124
+ }
125
+ const [firstValue, ...otherValues] = mappers.map((mapper) => remap(mapper, input, context));
126
+ return !otherValues.some((value) => equal(firstValue, value));
127
+ },
128
+ or(mappers, input, context) {
129
+ const values = mappers.map((mapper) => Boolean(remap(mapper, input, context)));
130
+ return values.length > 0 ? values.includes(true) : true;
131
+ },
132
+ and(mappers, input, context) {
133
+ const values = mappers.map((mapper) => remap(mapper, input, context));
134
+ return values.every(Boolean);
135
+ },
136
+ step(mapper, input, context) {
137
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
138
+ // @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
139
+ return context.stepRef.current[mapper];
140
+ },
141
+ 'tab.name'(mapper, input, context) {
142
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
143
+ // @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
144
+ return context.tabRef.current.name;
145
+ },
146
+ gt: ([left, right], input, context) =>
147
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
148
+ // @ts-ignore Messed up - 2571 Object is of type 'unknown'.
149
+ remap(left, input, context) > remap(right, input, context),
150
+ lt: ([left, right], input, context) =>
151
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
152
+ // @ts-ignore Messed up - 2571 Object is of type 'unknown'.
153
+ remap(left, input, context) < remap(right, input, context),
154
+ ics(mappers, input, context) {
155
+ let event;
156
+ const mappedStart = remap(mappers.start, input, context);
157
+ const start = mappedStart instanceof Date ? mappedStart : parseISO(mappedStart);
158
+ const sharedAttributes = {
159
+ start: [
160
+ start.getUTCFullYear(),
161
+ start.getUTCMonth() + 1,
162
+ start.getUTCDate(),
163
+ start.getUTCHours(),
164
+ start.getUTCMinutes(),
165
+ ],
166
+ startInputType: 'utc',
167
+ startOutputType: 'utc',
168
+ title: remap(mappers.title, input, context),
169
+ description: remap(mappers.description ?? null, input, context),
170
+ url: remap(mappers.url ?? null, input, context),
171
+ location: remap(mappers.location ?? null, input, context),
172
+ geo: processLocation(remap(mappers.coordinates ?? null, input, context)),
173
+ productId: context.appUrl,
174
+ };
175
+ if ('end' in mappers) {
176
+ const mappedEnd = remap(mappers.end, input, context);
177
+ const end = mappedEnd instanceof Date ? mappedEnd : parseISO(mappedEnd);
178
+ event = {
179
+ ...sharedAttributes,
180
+ endInputType: 'utc',
181
+ endOutputType: 'utc',
182
+ end: [
183
+ end.getUTCFullYear(),
184
+ end.getUTCMonth() + 1,
185
+ end.getUTCDate(),
186
+ end.getUTCHours(),
187
+ end.getUTCMinutes(),
188
+ ],
189
+ };
190
+ }
191
+ else {
192
+ event = {
193
+ ...sharedAttributes,
194
+ duration: getDuration(remap(mappers.duration, input, context)),
195
+ };
196
+ }
197
+ const { error, value } = createEvent(event);
198
+ if (error) {
199
+ throw error;
200
+ }
201
+ return value;
202
+ },
203
+ if(mappers, input, context) {
204
+ const condition = remap(mappers.condition, input, context);
205
+ return remap(condition ? mappers.then : mappers.else, input, context);
206
+ },
207
+ match(mappers, input, context) {
208
+ return (remap(mappers.find((mapper) => remap(mapper.case, input, context))?.value ?? null, input, context) ?? null);
209
+ },
210
+ 'object.from': (mappers, input, context) => mapValues(mappers, (mapper) => remap(mapper, input, context)),
211
+ 'object.assign': (mappers, input, context) => ({
212
+ ...input,
213
+ ...mapValues(mappers, (mapper) => remap(mapper, input, context)),
214
+ }),
215
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
216
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
217
+ 'object.omit'(keys, input) {
218
+ const result = { ...input };
219
+ for (const key of keys) {
220
+ if (Array.isArray(key)) {
221
+ let acc = result;
222
+ for (const [index, k] of key.entries()) {
223
+ if (index === key.length - 1) {
224
+ delete acc[k];
225
+ }
226
+ else {
227
+ acc = acc?.[k];
228
+ }
229
+ }
230
+ }
231
+ else {
232
+ delete result[key];
233
+ }
234
+ }
235
+ return result;
236
+ },
237
+ 'object.compare'([remapper1, remapper2], input, context) {
238
+ const remapped1 = remap(remapper1, input, context);
239
+ const remapped2 = remap(remapper2, input, context);
240
+ function deepDiff(object1, object2) {
241
+ const stack = [{ obj1: object1, obj2: object2, path: [] }];
242
+ const diffs = [];
243
+ while (stack.length !== 0) {
244
+ const { obj1, obj2, path } = stack.pop();
245
+ const keys = new Set([...Object.keys(obj1 || {}), ...Object.keys(obj2 || {})]);
246
+ for (const key of keys) {
247
+ const val1 = obj1?.[key];
248
+ const val2 = obj2?.[key];
249
+ const currentPath = [...path, key];
250
+ if (isPlainObject(val1) && isPlainObject(val2)) {
251
+ stack.push({ obj1: val1, obj2: val2, path: currentPath });
252
+ }
253
+ else if (Array.isArray(val1) && Array.isArray(val2) && !isEqualArray(val1, val2)) {
254
+ diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
255
+ }
256
+ else if (!(key in obj1)) {
257
+ diffs.push({ path: currentPath, type: 'added', value: val2 });
258
+ }
259
+ else if (!(key in obj2)) {
260
+ diffs.push({ path: currentPath, type: 'removed', value: val1 });
261
+ }
262
+ else if (val1 !== val2) {
263
+ diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
264
+ }
265
+ }
266
+ }
267
+ return diffs;
268
+ }
269
+ if (!isPlainObject(remapped1) || !isPlainObject(remapped2)) {
270
+ return [];
271
+ }
272
+ return deepDiff(remapped1, remapped2);
273
+ },
274
+ 'object.explode'(property, input) {
275
+ if (!isPlainObject(input)) {
276
+ return [];
277
+ }
278
+ const { [property]: arrayValue, ...rest } = input;
279
+ if (!Array.isArray(arrayValue)) {
280
+ return [];
281
+ }
282
+ return arrayValue.map((item) => ({
283
+ ...rest,
284
+ ...item,
285
+ }));
286
+ },
287
+ type(args, input) {
288
+ // eslint-disable-next-line eqeqeq
289
+ if (input === null) {
290
+ return null;
291
+ }
292
+ if (Array.isArray(input)) {
293
+ return 'array';
294
+ }
295
+ return typeof input;
296
+ },
297
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
298
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
299
+ 'array.map': (mapper, input, context) => input?.map((item, index) => remap(mapper, item, {
300
+ ...context,
301
+ array: {
302
+ index,
303
+ length: input.length,
304
+ item,
305
+ prevItem: input[index - 1],
306
+ nextItem: input[index + 1],
307
+ },
308
+ })) ?? [],
309
+ 'array.contains'(mapper, input, context) {
310
+ if (!Array.isArray(input)) {
311
+ return false;
312
+ }
313
+ const remapped = remap(mapper, input, context);
314
+ if (isPlainObject(remapped)) {
315
+ return input.some((item) => isEqualObject(item, remapped ?? {}));
316
+ }
317
+ if (Array.isArray(remapped)) {
318
+ return input.some((item) => isEqualArray(item, remapped));
319
+ }
320
+ return input.includes(remapped);
321
+ },
322
+ 'array.unique'(mapper, input, context) {
323
+ if (!Array.isArray(input)) {
324
+ return input;
325
+ }
326
+ const remapped = input.map((item, index) => mapper == null
327
+ ? item
328
+ : remap(mapper, item, {
329
+ ...context,
330
+ array: {
331
+ index,
332
+ length: input.length,
333
+ item,
334
+ prevItem: input[index - 1],
335
+ nextItem: input[index + 1],
336
+ },
337
+ }));
338
+ return input.filter((value, index) => {
339
+ for (let i = 0; i < index; i += 1) {
340
+ if (equal(remapped[index], remapped[i])) {
341
+ return false;
342
+ }
343
+ }
344
+ return true;
345
+ });
346
+ },
347
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
348
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
349
+ array: (prop, input, context) => context.array?.[prop],
350
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
351
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
352
+ 'array.filter'(mapper, input, context) {
353
+ if (!Array.isArray(input)) {
354
+ console.error(`${input} is not an array!`);
355
+ return null;
356
+ }
357
+ return input?.filter((item, index) => {
358
+ const remapped = remap(mapper, item, {
359
+ ...context,
360
+ array: {
361
+ index,
362
+ length: input.length,
363
+ item,
364
+ prevItem: input[index - 1],
365
+ nextItem: input[index + 1],
366
+ },
367
+ });
368
+ return remapped;
369
+ });
370
+ },
371
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
372
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
373
+ 'array.find'(mapper, input, context) {
374
+ if (!Array.isArray(input)) {
375
+ console.error(`${input} is not an array!`);
376
+ return null;
377
+ }
378
+ return (input?.find((item) => {
379
+ const remapped = remap(mapper, item, context);
380
+ switch (typeof remapped) {
381
+ case 'boolean':
382
+ return remap(mapper, item, context) ? item : null;
383
+ default:
384
+ return equal(remapped, item) ? item : null;
385
+ }
386
+ }) ?? null);
387
+ },
388
+ 'array.from': (mappers, input, context) => mappers.map((mapper) => remap(mapper, input, context)),
389
+ 'array.append': (mappers, input, context) => Array.isArray(input)
390
+ ? input.concat(mappers.map((mapper) => remap(mapper, input, context)))
391
+ : [],
392
+ 'array.omit'(mappers, input, context) {
393
+ const indices = new Set(mappers.map((mapper) => {
394
+ const remapped = remap(mapper, input, context);
395
+ if (typeof remapped === 'number') {
396
+ return remapped;
397
+ }
398
+ }));
399
+ return Array.isArray(input) ? input.filter((value, i) => !indices.has(i)) : [];
400
+ },
401
+ 'array.flatten'(mapper, input, context) {
402
+ if (!Array.isArray(input)) {
403
+ return input;
404
+ }
405
+ const depth = remap(mapper, input, context);
406
+ return input.flat(depth || Number.POSITIVE_INFINITY);
407
+ },
408
+ static: (input) => input,
409
+ prop(prop, obj, context) {
410
+ let result = obj;
411
+ if (result == null) {
412
+ return result;
413
+ }
414
+ if (Array.isArray(prop)) {
415
+ if (prop.every((item) => typeof item === 'number' || typeof item === 'string')) {
416
+ // This runs if the provided value is an array of property names or indexes
417
+ for (const p of [prop].flat()) {
418
+ result = result[p];
419
+ }
420
+ }
421
+ else if (prop.every((item) => typeof item === 'object' && !Array.isArray(item))) {
422
+ // This runs if the provided value is an array of remappers
423
+ const remapped = remap(prop, obj, context);
424
+ if (typeof remapped === 'number' || typeof remapped === 'string') {
425
+ result = result[remapped];
426
+ }
427
+ else {
428
+ console.error(`Invalid remapper ${JSON.stringify(prop)}`);
429
+ }
430
+ }
431
+ }
432
+ else if (typeof prop === 'object') {
433
+ if (prop == null) {
434
+ result = result.null;
435
+ return result;
436
+ }
437
+ // This runs if the provided value is a remapper
438
+ const remapped = remap(prop, result, context);
439
+ if (typeof remapped === 'number' || typeof remapped === 'string') {
440
+ result = result[remapped];
441
+ }
442
+ else {
443
+ console.error(`Invalid remapper ${JSON.stringify(prop)}`);
444
+ }
445
+ }
446
+ else if (typeof prop === 'number' || typeof prop === 'string') {
447
+ result =
448
+ Array.isArray(result) && typeof prop === 'number' && prop < 0
449
+ ? result[result.length + prop]
450
+ : result[prop];
451
+ }
452
+ return result;
453
+ },
454
+ 'number.parse'(remapper, input, context) {
455
+ if (!remapper) {
456
+ const inputConverted = Number(input);
457
+ if (!Number.isNaN(inputConverted)) {
458
+ return inputConverted;
459
+ }
460
+ return input;
461
+ }
462
+ const remapped = remap(remapper, input, context);
463
+ const remappedConverted = Number(remapped);
464
+ if (!Number.isNaN(remappedConverted)) {
465
+ return remappedConverted;
466
+ }
467
+ return remapped;
468
+ },
469
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
470
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
471
+ 'date.parse': (fmt, input) => (fmt ? parse(input, fmt, new Date()) : parseISO(input)),
472
+ 'date.now': () => new Date(),
473
+ 'date.add'(time, input) {
474
+ const expireDuration = parseDuration(time);
475
+ if (!expireDuration || !input || (!Number.isFinite(input) && !(input instanceof Date))) {
476
+ return input;
477
+ }
478
+ return addMilliseconds(input, expireDuration);
479
+ },
480
+ 'date.format'(args, input) {
481
+ const date = input instanceof Date
482
+ ? input
483
+ : typeof input === 'number'
484
+ ? new Date(input)
485
+ : parseISO(String(input));
486
+ return args ? format(date, args) : date.toJSON();
487
+ },
488
+ 'null.strip': (args, input) => stripNullValues(input, args || {}),
489
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
490
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
491
+ 'random.choice': (args, input) => Array.isArray(input) ? input[Math.floor(Math.random() * input.length)] : input,
492
+ 'random.integer'(args) {
493
+ const min = Math.min(...args);
494
+ const max = Math.max(...args);
495
+ return Math.floor(Math.random() * (max - min) + min);
496
+ },
497
+ 'random.float'(args) {
498
+ const min = Math.min(...args);
499
+ const max = Math.max(...args);
500
+ return Math.random() * (max - min) + min;
501
+ },
502
+ 'random.string'(args) {
503
+ const result = [];
504
+ const characters = [...new Set(args.choice.split(''))];
505
+ for (let i = 0; i <= args.length; i += 1) {
506
+ result.push(characters[Math.floor(Math.random() * characters.length)]);
507
+ }
508
+ return result.join('');
509
+ },
510
+ root: (args, input, context) => context.root,
511
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
512
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
513
+ len: (args, input) => input?.length,
514
+ history: (index, input, context) => context.history?.[index],
515
+ 'from.history': ({ index, props }, input, context) => mapValues(props, (mapper) => remap(mapper, context.history?.[index], context)),
516
+ 'assign.history': ({ index, props }, input, context) => ({
517
+ ...input,
518
+ ...mapValues(props, (mapper) => remap(mapper, context.history?.[index], context)),
519
+ }),
520
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
521
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
522
+ 'omit.history'({ index, keys }, input, context) {
523
+ const result = { ...context.history?.[index] };
524
+ for (const key of keys) {
525
+ if (Array.isArray(key)) {
526
+ let acc = result;
527
+ for (const [i, k] of key.entries()) {
528
+ if (i === key.length - 1) {
529
+ delete acc[k];
530
+ }
531
+ else {
532
+ acc = acc?.[k];
533
+ }
534
+ }
535
+ }
536
+ else {
537
+ delete result[key];
538
+ }
539
+ }
540
+ return { ...input, ...result };
541
+ },
542
+ 'string.case'(stringCase, input) {
543
+ if (stringCase === 'lower') {
544
+ return String(input).toLowerCase();
545
+ }
546
+ if (stringCase === 'upper') {
547
+ return String(input).toUpperCase();
548
+ }
549
+ return input;
550
+ },
551
+ 'string.contains'(stringToCheck, input) {
552
+ if (!(typeof input === 'string')) {
553
+ return false;
554
+ }
555
+ return input.includes(stringToCheck);
556
+ },
557
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
558
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
559
+ 'string.startsWith'(substring, input) {
560
+ if (typeof substring === 'string') {
561
+ return input.startsWith(substring);
562
+ }
563
+ if (substring.strict || substring.strict === undefined) {
564
+ return input.startsWith(substring.substring);
565
+ }
566
+ return input.toLowerCase().startsWith(substring.substring.toLowerCase());
567
+ },
568
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
569
+ // @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
570
+ 'string.endsWith'(substring, input) {
571
+ if (typeof substring === 'string') {
572
+ return input.endsWith(substring);
573
+ }
574
+ if (substring.strict || substring.strict === undefined) {
575
+ return input.endsWith(substring.substring);
576
+ }
577
+ return input.toLowerCase().endsWith(substring.substring.toLowerCase());
578
+ },
579
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
580
+ // @ts-ignore 2322 null is not assignable to type (strictNullChecks)
581
+ slice(sliceIndex, input) {
582
+ try {
583
+ return Array.isArray(sliceIndex) ? input.slice(...sliceIndex) : input.slice(sliceIndex);
584
+ }
585
+ catch {
586
+ return null;
587
+ }
588
+ },
589
+ log(level, input, context) {
590
+ console[level ?? 'info'](JSON.stringify({ input, context }, null, 2));
591
+ return input;
592
+ },
593
+ 'string.format'({ messageId, template, values }, input, context) {
594
+ try {
595
+ const remappedMessageId = remap(messageId ?? null, input, context);
596
+ const message = context.getMessage({ id: remappedMessageId, defaultMessage: template });
597
+ return message.format(values ? mapValues(values, (val) => remap(val, input, context)) : undefined);
598
+ }
599
+ catch (error) {
600
+ if (messageId) {
601
+ return `{${messageId}}`;
602
+ }
603
+ return error.message;
604
+ }
605
+ },
606
+ 'string.replace'(values, input) {
607
+ const [[regex, replacer]] = Object.entries(values);
608
+ return String(input).replaceAll(new RegExp(regex, 'gm'), replacer);
609
+ },
610
+ translate(messageId, input, context) {
611
+ const remappedId = remap(messageId, input, context);
612
+ if (typeof remappedId !== 'string') {
613
+ return null;
614
+ }
615
+ const message = context.getMessage({ id: remappedId });
616
+ return message.format() || `{${remappedId}}`;
617
+ },
618
+ 'app.member': (property, input, context) => context.appMemberInfo?.[property],
619
+ container(property, input, context) {
620
+ // This value is replaced when the request is made
621
+ // By using the value of the release name
622
+ const namespace = 'companion-containers-appsemble';
623
+ const appName = context.appUrl.split('.')[0].replace(/^https?:\/\//, '');
624
+ const endpoint = property.split('/').slice(1).join('/');
625
+ const containerName = `${property.split('/')[0]}-${appName}-${context.appId}`
626
+ .replaceAll(' ', '-')
627
+ .toLowerCase();
628
+ const url = `http://${containerName}.${namespace}.svc.cluster.local/${endpoint}`;
629
+ return url;
630
+ },
631
+ 'filter.from'(values, input, context) {
632
+ let result = filter();
633
+ for (const [field, { comparator, type, value }] of Object.entries(values)) {
634
+ const remapped = remap(value, input, context);
635
+ const remappedDefined = remapped === undefined ? null : remapped;
636
+ const literal = type === 'String' && remapped != null
637
+ ? literalValues[type](String(remappedDefined).replaceAll("'", "''").replaceAll('\\', '\\\\'))
638
+ : literalValues[type === 'Number' ? 'Decimal' : type](remappedDefined);
639
+ result = result.field(field)[comparator](literal);
640
+ }
641
+ return String(param().filter(result)).replace(/^\$filter=/, '');
642
+ },
643
+ 'order.from'(values) {
644
+ return String(param().orderby(Object.entries(values).map(([key, order]) => ({ field: key, order })))).replace('$orderby=', '');
645
+ },
646
+ 'xml.parse'(value, input, context) {
647
+ const parser = new XMLParser({
648
+ ignoreAttributes: false,
649
+ attributeNamePrefix: '',
650
+ });
651
+ try {
652
+ return parser.parse(remap(value, input, context) || '');
653
+ }
654
+ catch (error) {
655
+ console.error(error);
656
+ return {};
657
+ }
658
+ },
659
+ defined(value, input, context) {
660
+ const remapped = remap(value, input, context);
661
+ return remapped !== undefined && remapped != null;
662
+ },
663
+ maths(value, input, context) {
664
+ const { a, b, operation } = value;
665
+ const aRemapped = remap(a, input, context);
666
+ const bRemapped = remap(b, input, context);
667
+ if (!isNumber(aRemapped) || !isNumber(bRemapped)) {
668
+ return -1;
669
+ }
670
+ const na = Number(aRemapped);
671
+ const nb = Number(bRemapped);
672
+ switch (operation) {
673
+ case 'add':
674
+ return na + nb;
675
+ case 'subtract':
676
+ return na - nb;
677
+ case 'multiply':
678
+ return na * nb;
679
+ case 'divide':
680
+ if (nb === 0) {
681
+ return -1;
682
+ }
683
+ return na / nb;
684
+ case 'mod':
685
+ return na % nb;
686
+ default:
687
+ return -1;
688
+ }
689
+ },
690
+ };
691
+ //# sourceMappingURL=remap.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const AppDefinition: OpenAPIV3.NonArraySchemaObject;