@plitzi/sdk-shared 0.39.1 → 0.39.2

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 (505) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +1 -2
  3. package/dist/actions/access.mjs +1 -2
  4. package/dist/actions/cron.mjs +1 -2
  5. package/dist/actions/failureHandler.mjs +1 -2
  6. package/dist/actions/flowDelay.d.ts +6 -0
  7. package/dist/actions/flowDelay.mjs +3 -0
  8. package/dist/actions/functions.d.ts +6 -3
  9. package/dist/actions/functions.mjs +12 -8
  10. package/dist/actions/index.d.ts +2 -1
  11. package/dist/actions/index.mjs +10 -9
  12. package/dist/actions/jobs.mjs +1 -2
  13. package/dist/actions/smtp.mjs +1 -2
  14. package/dist/actions/triggerParams.mjs +1 -2
  15. package/dist/actions/triggers.mjs +1 -2
  16. package/dist/actions/validateDocument.mjs +133 -123
  17. package/dist/activity/describe.mjs +1 -2
  18. package/dist/activity/guard.mjs +1 -2
  19. package/dist/activity/types.mjs +1 -2
  20. package/dist/auth/failureChannel.mjs +1 -2
  21. package/dist/auth/visitorRoles.mjs +1 -2
  22. package/dist/authoring/builder.mjs +1 -2
  23. package/dist/authoring/declare.mjs +1 -2
  24. package/dist/authoring/elementCallbacks.mjs +1 -2
  25. package/dist/authoring/index.mjs +3 -3
  26. package/dist/authoring/paramSpec.mjs +1 -2
  27. package/dist/authoring/spaceCallbacks.mjs +1 -2
  28. package/dist/builder/contexts/BuilderContext.mjs +1 -2
  29. package/dist/builder/contexts/index.mjs +1 -2
  30. package/dist/conditions/dates.d.ts +2 -0
  31. package/dist/conditions/dates.mjs +12 -0
  32. package/dist/conditions/evaluateRuleGroup.d.ts +13 -0
  33. package/dist/conditions/evaluateRuleGroup.mjs +4 -0
  34. package/dist/conditions/evaluator.d.ts +39 -0
  35. package/dist/conditions/evaluator.mjs +75 -0
  36. package/dist/conditions/index.d.ts +10 -0
  37. package/dist/conditions/index.mjs +5 -0
  38. package/dist/conditions/rules.d.ts +3 -0
  39. package/dist/conditions/rules.mjs +3 -0
  40. package/dist/conditions/types.d.ts +44 -0
  41. package/dist/connectors/constants.mjs +1 -2
  42. package/dist/connectors/manifestTokens.mjs +1 -2
  43. package/dist/connectors/presets.mjs +1 -2
  44. package/dist/connectors/validateManifest.mjs +56 -57
  45. package/dist/dataSource/computed.mjs +16 -17
  46. package/dist/dataSource/getBindingsDetails.d.ts +5 -6
  47. package/dist/dataSource/getBindingsDetails.mjs +65 -40
  48. package/dist/dataSource/globalSources.d.ts +1 -1
  49. package/dist/dataSource/globalSources.mjs +1 -2
  50. package/dist/dataSource/helpers/getSourceName.mjs +1 -2
  51. package/dist/dataSource/index.mjs +5 -5
  52. package/dist/dataSource/utility/arrayMap.mjs +2 -2
  53. package/dist/dataSource/utility/capitalize.mjs +1 -2
  54. package/dist/dataSource/utility/checkboxParams.mjs +1 -2
  55. package/dist/dataSource/utility/dateConverter.mjs +0 -1
  56. package/dist/dataSource/utility/index.mjs +15 -16
  57. package/dist/dataSource/utility/not.mjs +1 -2
  58. package/dist/dataSource/utility/staticValue.mjs +0 -1
  59. package/dist/dataSource/utility/stringToArray.mjs +0 -1
  60. package/dist/dataSource/utility/styleSelector.mjs +1 -2
  61. package/dist/dataSource/utility/styleVariant.mjs +2 -3
  62. package/dist/dataSource/utility/truthiness.mjs +1 -2
  63. package/dist/dataSource/utility/twigTemplate.mjs +0 -1
  64. package/dist/dataSource/variables/resolveVariables.mjs +2 -3
  65. package/dist/dates/formatDate.mjs +29 -30
  66. package/dist/dates/isDate.mjs +1 -2
  67. package/dist/devTools/chrome.mjs +1 -2
  68. package/dist/devTools/debugCookie.mjs +1 -2
  69. package/dist/devTools/index.mjs +5 -5
  70. package/dist/devTools/interactionLog.mjs +1 -2
  71. package/dist/devTools/react/DevToolsContext.mjs +1 -2
  72. package/dist/devTools/sight/sight.mjs +1 -2
  73. package/dist/devTools/utils/PlitziConsole.mjs +1 -2
  74. package/dist/elements/ComponentContext.mjs +1 -2
  75. package/dist/flags/flagsCookie.mjs +5 -6
  76. package/dist/flags/index.d.ts +1 -0
  77. package/dist/flags/index.mjs +4 -3
  78. package/dist/flags/overrides.d.ts +36 -0
  79. package/dist/flags/overrides.mjs +13 -0
  80. package/dist/flags/react/useFlagResolution.mjs +5 -6
  81. package/dist/flags/resolveFlags.d.ts +1 -1
  82. package/dist/flags/resolveFlags.mjs +2 -3
  83. package/dist/flags/schemaFlag.mjs +1 -2
  84. package/dist/functions/contract.d.ts +326 -0
  85. package/dist/functions/contract.mjs +3 -0
  86. package/dist/functions/index.d.ts +15 -0
  87. package/dist/functions/index.mjs +9 -0
  88. package/dist/functions/kv.d.ts +80 -0
  89. package/dist/functions/kvChange.d.ts +67 -0
  90. package/dist/functions/kvChange.mjs +24 -0
  91. package/dist/functions/later.d.ts +18 -0
  92. package/dist/functions/messages.d.ts +4 -0
  93. package/dist/functions/messages.mjs +205 -0
  94. package/dist/functions/protocol.d.ts +416 -0
  95. package/dist/functions/protocol.mjs +37 -0
  96. package/dist/functions/rateLimit.d.ts +17 -0
  97. package/dist/functions/rateLimit.mjs +0 -0
  98. package/dist/functions/refusal.d.ts +26 -0
  99. package/dist/functions/refusal.mjs +11 -0
  100. package/dist/functions/runtime.d.ts +44 -0
  101. package/dist/functions/runtime.mjs +13 -0
  102. package/dist/functions/sizes.d.ts +27 -0
  103. package/dist/functions/sizes.mjs +7 -0
  104. package/dist/functions/wire.d.ts +11 -0
  105. package/dist/functions/wire.mjs +39 -0
  106. package/dist/helpers/canonicalJson.mjs +1 -2
  107. package/dist/helpers/clipboard.mjs +1 -2
  108. package/dist/helpers/cookies.mjs +1 -2
  109. package/dist/helpers/deepEqual/deepEqual.d.ts +5 -0
  110. package/dist/helpers/deepEqual/deepEqual.mjs +44 -0
  111. package/dist/helpers/deepEqual/index.d.ts +1 -0
  112. package/dist/helpers/deepEqual/index.mjs +1 -0
  113. package/dist/helpers/eventTarget.mjs +1 -2
  114. package/dist/helpers/fetchManifest.mjs +1 -2
  115. package/dist/helpers/images.mjs +1 -2
  116. package/dist/helpers/index.d.ts +4 -6
  117. package/dist/helpers/index.mjs +24 -20
  118. package/dist/helpers/interval.mjs +1 -2
  119. package/dist/helpers/isRecord.mjs +1 -2
  120. package/dist/helpers/keys.mjs +1 -2
  121. package/dist/helpers/lodash/camelCase.d.ts +1 -0
  122. package/dist/helpers/lodash/camelCase.mjs +7 -0
  123. package/dist/helpers/lodash/capitalize.d.ts +1 -0
  124. package/dist/helpers/lodash/capitalize.mjs +5 -0
  125. package/dist/helpers/lodash/cloneDeep.d.ts +8 -0
  126. package/dist/helpers/lodash/cloneDeep.mjs +53 -0
  127. package/dist/helpers/lodash/get.d.ts +11 -0
  128. package/dist/helpers/lodash/get.mjs +14 -0
  129. package/dist/helpers/lodash/has.d.ts +2 -0
  130. package/dist/helpers/lodash/has.mjs +12 -0
  131. package/dist/helpers/lodash/index.d.ts +11 -0
  132. package/dist/helpers/lodash/index.mjs +7 -0
  133. package/dist/helpers/lodash/omit.d.ts +4 -0
  134. package/dist/helpers/lodash/omit.mjs +35 -0
  135. package/dist/helpers/lodash/set.d.ts +2 -0
  136. package/dist/helpers/lodash/set.mjs +20 -0
  137. package/dist/helpers/lodash/shared.d.ts +2 -0
  138. package/dist/helpers/lodash/shared.mjs +37 -0
  139. package/dist/helpers/reducerOrigin.mjs +1 -2
  140. package/dist/helpers/replaceEqualDeep/index.d.ts +1 -0
  141. package/dist/helpers/replaceEqualDeep/index.mjs +1 -0
  142. package/dist/helpers/replaceEqualDeep/replaceEqualDeep.d.ts +12 -0
  143. package/dist/helpers/replaceEqualDeep/replaceEqualDeep.mjs +30 -0
  144. package/dist/helpers/resources.d.ts +21 -0
  145. package/dist/helpers/resources.mjs +40 -0
  146. package/dist/helpers/scroll.mjs +1 -2
  147. package/dist/helpers/security.d.ts +15 -0
  148. package/dist/helpers/security.mjs +8 -4
  149. package/dist/helpers/spaceRoot.mjs +1 -2
  150. package/dist/helpers/syntaxHighlight.mjs +1 -2
  151. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +75 -76
  152. package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +1 -2
  153. package/dist/helpers/twigWrapper/Lexer/Lexer.mjs +1 -2
  154. package/dist/helpers/twigWrapper/Lexer/types.mjs +1 -2
  155. package/dist/helpers/twigWrapper/Parser/Cursor.mjs +1 -2
  156. package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +1 -2
  157. package/dist/helpers/twigWrapper/Parser/Parser.mjs +1 -2
  158. package/dist/helpers/twigWrapper/Parser/helpers.mjs +1 -2
  159. package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -2
  160. package/dist/helpers/twigWrapper/charClass.mjs +1 -2
  161. package/dist/helpers/twigWrapper/filters/arrays.mjs +1 -2
  162. package/dist/helpers/twigWrapper/filters/catalog/index.mjs +1 -2
  163. package/dist/helpers/twigWrapper/filters/dateParts.mjs +1 -2
  164. package/dist/helpers/twigWrapper/filters/dates.mjs +13 -14
  165. package/dist/helpers/twigWrapper/filters/filters.mjs +21 -22
  166. package/dist/helpers/twigWrapper/filters/hashing.mjs +1 -2
  167. package/dist/helpers/twigWrapper/filters/misc.mjs +27 -28
  168. package/dist/helpers/twigWrapper/filters/numbers.mjs +1 -2
  169. package/dist/helpers/twigWrapper/filters/objects.mjs +1 -2
  170. package/dist/helpers/twigWrapper/filters/raw.mjs +1 -2
  171. package/dist/helpers/twigWrapper/filters/strings.mjs +23 -24
  172. package/dist/helpers/twigWrapper/filters/types.mjs +1 -2
  173. package/dist/helpers/twigWrapper/filters/values.mjs +1 -2
  174. package/dist/helpers/twigWrapper/index.mjs +8 -8
  175. package/dist/helpers/twigWrapper/inspectTemplate.mjs +12 -13
  176. package/dist/helpers/twigWrapper/processTwig/helpers.mjs +1 -2
  177. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +1 -2
  178. package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +1 -2
  179. package/dist/helpers/twigWrapper/templateRoots.d.ts +3 -9
  180. package/dist/helpers/twigWrapper/templateRoots.mjs +14 -9
  181. package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs +1 -2
  182. package/dist/helpers/twigWrapper/tokens/hasValidToken.mjs +1 -2
  183. package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +1 -2
  184. package/dist/helpers/utils.mjs +2 -3
  185. package/dist/history/describe.mjs +1 -2
  186. package/dist/history/diff.mjs +1 -2
  187. package/dist/hooks/index.mjs +5 -5
  188. package/dist/hooks/useFontHead.mjs +1 -2
  189. package/dist/hooks/useNetwork.mjs +1 -2
  190. package/dist/hooks/usePlitzi.d.ts +7 -6
  191. package/dist/hooks/usePlitzi.mjs +1 -2
  192. package/dist/hooks/useStableValue.mjs +5 -6
  193. package/dist/navigation/index.mjs +3 -3
  194. package/dist/navigation/matchPath.mjs +19 -11
  195. package/dist/navigation/routes.mjs +57 -38
  196. package/dist/navigation/sitemap.mjs +9 -10
  197. package/dist/network/entitlements.d.ts +21 -0
  198. package/dist/network/entitlements.mjs +1 -2
  199. package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +1 -2
  200. package/dist/network/graphql/builder/Mutations/Space/SpaceAddPluginMutation.mjs +1 -2
  201. package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +1 -2
  202. package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +1 -2
  203. package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.mjs +1 -2
  204. package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +1 -2
  205. package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +1 -2
  206. package/dist/network/graphql/builder/Mutations/Space/SpacePublishMutation.mjs +1 -2
  207. package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +1 -2
  208. package/dist/network/graphql/builder/Mutations/Space/SpaceRemovePluginMutation.mjs +1 -2
  209. package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.mjs +1 -2
  210. package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.mjs +1 -2
  211. package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.mjs +1 -2
  212. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +1 -2
  213. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +1 -2
  214. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +1 -2
  215. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +1 -2
  216. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +1 -2
  217. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -2
  218. package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.mjs +1 -2
  219. package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.mjs +1 -2
  220. package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -2
  221. package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.mjs +1 -2
  222. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceAddCdnBucketMutation.mjs +1 -2
  223. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceAddCdnMutation.mjs +1 -2
  224. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceRemoveCdnBucketMutation.mjs +1 -2
  225. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceRemoveCdnMutation.mjs +1 -2
  226. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceSetCdnCredentialMutation.mjs +1 -2
  227. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceUpdateCdnBucketMutation.mjs +1 -2
  228. package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceUpdateCdnMutation.mjs +1 -2
  229. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +1 -2
  230. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +1 -2
  231. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +1 -2
  232. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +1 -2
  233. package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceAddConnectorMutation.mjs +1 -2
  234. package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceRemoveConnectorMutation.mjs +1 -2
  235. package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceUpdateConnectorMutation.mjs +1 -2
  236. package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceAddCredentialMutation.mjs +1 -2
  237. package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceRemoveCredentialMutation.mjs +1 -2
  238. package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceUpdateCredentialMutation.mjs +1 -2
  239. package/dist/network/graphql/builder/Mutations/Space/data/SpaceSaveDataMutation.mjs +1 -2
  240. package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +1 -2
  241. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +1 -2
  242. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +1 -2
  243. package/dist/network/graphql/builder/Mutations/Space/folders/SpaceAddPageFolderMutation.mjs +1 -2
  244. package/dist/network/graphql/builder/Mutations/Space/folders/SpaceRemovePageFolderMutation.mjs +1 -2
  245. package/dist/network/graphql/builder/Mutations/Space/folders/SpaceUpdatePageFolderMutation.mjs +1 -2
  246. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceInstallTemplateFunctionsMutation.mjs +1 -2
  247. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +1 -2
  248. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +1 -2
  249. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +1 -2
  250. package/dist/network/graphql/builder/Mutations/Space/jobs/SpaceControlJobMutation.mjs +1 -2
  251. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +1 -2
  252. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceHomePageMutation.mjs +1 -2
  253. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceRemovePageMutation.mjs +1 -2
  254. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +1 -2
  255. package/dist/network/graphql/builder/Mutations/Space/resources/SpaceAddResourceMutation.mjs +1 -2
  256. package/dist/network/graphql/builder/Mutations/Space/resources/SpaceMoveResourceMutation.mjs +1 -2
  257. package/dist/network/graphql/builder/Mutations/Space/resources/SpaceRemoveResourceMutation.mjs +1 -2
  258. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +1 -2
  259. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +1 -2
  260. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +1 -2
  261. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +1 -2
  262. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +1 -2
  263. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +1 -2
  264. package/dist/network/graphql/builder/Mutations/Space/variables/SpaceAddVariableMutation.mjs +1 -2
  265. package/dist/network/graphql/builder/Mutations/Space/variables/SpaceRemoveVariableMutation.mjs +1 -2
  266. package/dist/network/graphql/builder/Mutations/Space/variables/SpaceUpdateVariableMutation.mjs +1 -2
  267. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +1 -2
  268. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +1 -2
  269. package/dist/network/graphql/builder/Mutations/Style/StyleUpdateMutation.mjs +1 -2
  270. package/dist/network/graphql/builder/Mutations/Style/StyleUpdateSettingsMutation.mjs +1 -2
  271. package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.mjs +1 -2
  272. package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.mjs +1 -2
  273. package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.mjs +1 -2
  274. package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleAddSelectorVariableMutation.mjs +1 -2
  275. package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleRemoveSelectorVariableMutation.mjs +1 -2
  276. package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleUpdateSelectorVariableMutation.mjs +1 -2
  277. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleAddSelectorMutation.mjs +1 -2
  278. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorMutation.mjs +1 -2
  279. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.mjs +1 -2
  280. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleUpdateSelectorMutation.mjs +1 -2
  281. package/dist/network/graphql/builder/Mutations/Style/variables/StyleAddVariableMutation.mjs +1 -2
  282. package/dist/network/graphql/builder/Mutations/Style/variables/StyleRemoveVariableMutation.mjs +1 -2
  283. package/dist/network/graphql/builder/Mutations/Style/variables/StyleUpdateVariableMutation.mjs +1 -2
  284. package/dist/network/graphql/builder/Mutations/index.mjs +155 -156
  285. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -2
  286. package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.mjs +1 -2
  287. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -2
  288. package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.mjs +1 -2
  289. package/dist/network/graphql/builder/Queries/Space/SpaceCdnsQuery.mjs +1 -2
  290. package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +1 -2
  291. package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.mjs +1 -2
  292. package/dist/network/graphql/builder/Queries/Space/SpaceConnectorsQuery.mjs +1 -2
  293. package/dist/network/graphql/builder/Queries/Space/SpaceCredentialsQuery.mjs +1 -2
  294. package/dist/network/graphql/builder/Queries/Space/SpaceDataQuery.mjs +1 -2
  295. package/dist/network/graphql/builder/Queries/Space/SpaceDeploymentsQuery.mjs +1 -2
  296. package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +1 -1
  297. package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +2 -3
  298. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -2
  299. package/dist/network/graphql/builder/Queries/Space/SpaceJobsQuery.mjs +1 -2
  300. package/dist/network/graphql/builder/Queries/Space/SpaceLatestRevisionQuery.mjs +1 -2
  301. package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.mjs +1 -2
  302. package/dist/network/graphql/builder/Queries/Space/SpaceResourcesQuery.mjs +1 -2
  303. package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +1 -1
  304. package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +2 -3
  305. package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.mjs +1 -2
  306. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +1 -2
  307. package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +1 -2
  308. package/dist/network/graphql/builder/Queries/index.mjs +37 -38
  309. package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.mjs +1 -2
  310. package/dist/network/graphql/builder/Subscriptions/index.mjs +1 -2
  311. package/dist/network/graphql/builder/fragments/cdnFields.mjs +1 -2
  312. package/dist/network/graphql/index.d.ts +0 -1
  313. package/dist/network/graphql/index.mjs +1 -3
  314. package/dist/network/index.d.ts +1 -5
  315. package/dist/network/index.mjs +7 -11
  316. package/dist/network/{NetworkContext.d.ts → react/NetworkContext.d.ts} +12 -11
  317. package/dist/network/{NetworkContext.mjs → react/NetworkContext.mjs} +1 -2
  318. package/dist/network/{NetworkInternalContext.d.ts → react/NetworkInternalContext.d.ts} +1 -1
  319. package/dist/network/react/NetworkInternalContext.mjs +4 -0
  320. package/dist/network/react/index.d.ts +5 -0
  321. package/dist/network/react/index.mjs +3 -0
  322. package/dist/network/spaceEvents.mjs +16 -17
  323. package/dist/plugins/bundle/bundle.mjs +1 -2
  324. package/dist/plugins/declaration.mjs +1 -2
  325. package/dist/plugins/react/ElementRegistryContext.d.ts +26 -0
  326. package/dist/plugins/react/ElementRegistryContext.mjs +17 -0
  327. package/dist/plugins/react/PluginAssetsContext.d.ts +11 -0
  328. package/dist/plugins/react/PluginAssetsContext.mjs +4 -0
  329. package/dist/plugins/react/PluginsContext.mjs +6 -3
  330. package/dist/plugins/react/index.d.ts +3 -0
  331. package/dist/plugins/react/index.mjs +4 -1
  332. package/dist/project/index.mjs +7 -7
  333. package/dist/project/layout/check.mjs +26 -27
  334. package/dist/project/layout/codes.mjs +1 -2
  335. package/dist/project/layout/contents.mjs +12 -13
  336. package/dist/project/layout/files.mjs +1 -2
  337. package/dist/project/layout/folders.mjs +43 -44
  338. package/dist/project/layout/index.mjs +3 -3
  339. package/dist/project/layout/plugins.mjs +56 -57
  340. package/dist/project/layout/vendor.mjs +14 -15
  341. package/dist/project/network.mjs +1 -2
  342. package/dist/project/pages/index.mjs +1 -2
  343. package/dist/project/paths/index.d.ts +8 -2
  344. package/dist/project/paths/index.mjs +3 -4
  345. package/dist/project/root.mjs +1 -2
  346. package/dist/queries/index.mjs +1 -2
  347. package/dist/queries/queryCache.mjs +1 -2
  348. package/dist/queries/serverQueries.mjs +1 -2
  349. package/dist/queries/useQuery.mjs +1 -2
  350. package/dist/queries/useServerQuery.mjs +1 -2
  351. package/dist/{helpers → react}/enclosingSpace.mjs +1 -2
  352. package/dist/react/generateFacade.d.ts +1 -0
  353. package/dist/{helpers → react}/generateFacade.mjs +4 -5
  354. package/dist/react/index.d.ts +8 -0
  355. package/dist/react/index.mjs +4 -0
  356. package/dist/{helpers → react}/sharedContext.mjs +0 -1
  357. package/dist/realtime/client.mjs +3 -4
  358. package/dist/realtime/index.mjs +4 -4
  359. package/dist/realtime/presence.mjs +1 -2
  360. package/dist/realtime/topics.mjs +1 -2
  361. package/dist/runs/index.mjs +1 -2
  362. package/dist/runs/report.mjs +1 -2
  363. package/dist/schema/anchor.mjs +1 -2
  364. package/dist/schema/index.mjs +18 -18
  365. package/dist/schema/layoutChain.mjs +1 -2
  366. package/dist/schema/markdownHeadings.mjs +1 -2
  367. package/dist/schema/motion.mjs +1 -2
  368. package/dist/schema/motionReveal.mjs +1 -2
  369. package/dist/schema/pageAccess.d.ts +9 -0
  370. package/dist/schema/pageAccess.mjs +42 -36
  371. package/dist/schema/pageElements.d.ts +3 -1
  372. package/dist/schema/pageElements.mjs +9 -3
  373. package/dist/schema/pageHead.d.ts +5 -2
  374. package/dist/schema/pageHead.mjs +3 -4
  375. package/dist/schema/providerAnswer.mjs +1 -2
  376. package/dist/schema/providerWhen.d.ts +1 -1
  377. package/dist/schema/providerWhen.mjs +6 -7
  378. package/dist/schema/react/SchemaContext.mjs +1 -2
  379. package/dist/schema/schemaConstants.mjs +1 -2
  380. package/dist/schema/schemaSettings.mjs +1 -2
  381. package/dist/schema/serverElements.d.ts +0 -24
  382. package/dist/schema/serverElements.mjs +60 -39
  383. package/dist/schema/serverInput.mjs +23 -24
  384. package/dist/schema/serverQuery.d.ts +15 -5
  385. package/dist/schema/serverQuery.mjs +47 -35
  386. package/dist/schema/snippet.mjs +1 -2
  387. package/dist/schema/wire.mjs +1 -2
  388. package/dist/security/index.d.ts +49 -0
  389. package/dist/security/index.mjs +44 -0
  390. package/dist/server/actions/useActionsSync.mjs +1 -2
  391. package/dist/server/actions/useImagesSync.mjs +1 -2
  392. package/dist/server/actions/useRealtimeSync.mjs +1 -2
  393. package/dist/server/index.mjs +7 -7
  394. package/dist/server/rsc/refreshRsc.mjs +23 -24
  395. package/dist/server/rsc/useRscRefresh.mjs +1 -2
  396. package/dist/server/rsc/useRscSync.mjs +1 -2
  397. package/dist/server/usePluginRoute.mjs +1 -2
  398. package/dist/source/export.d.ts +1 -1
  399. package/dist/source/export.mjs +1 -2
  400. package/dist/source/import.mjs +1 -2
  401. package/dist/source/index.mjs +4 -4
  402. package/dist/source/snapshot.mjs +1 -2
  403. package/dist/state/index.d.ts +0 -1
  404. package/dist/state/index.mjs +1 -3
  405. package/dist/state/paintedState.mjs +10 -11
  406. package/dist/store/actionRuns/actionRunsRecorder.mjs +1 -2
  407. package/dist/store/actionRuns/actionRunsStore.mjs +1 -2
  408. package/dist/store/actionRuns/index.mjs +3 -3
  409. package/dist/store/actionRuns/useActionRuns.mjs +5 -6
  410. package/dist/store/index.d.ts +1 -0
  411. package/dist/store/index.mjs +2 -1
  412. package/dist/store/renderSettings.d.ts +1 -1
  413. package/dist/store/renderSettings.mjs +1 -2
  414. package/dist/{state → store}/runtimeStatePersist.mjs +29 -30
  415. package/dist/store/storeHooks.d.ts +45 -45
  416. package/dist/store/storeHooks.mjs +1 -2
  417. package/dist/store/tracing/index.mjs +5 -5
  418. package/dist/store/tracing/preview.mjs +1 -2
  419. package/dist/store/tracing/tracingCollector.d.ts +2 -2
  420. package/dist/store/tracing/tracingCollector.mjs +79 -78
  421. package/dist/store/tracing/tracingMiddleware.mjs +1 -2
  422. package/dist/store/tracing/tracingStore.mjs +1 -2
  423. package/dist/store/tracing/useTracing.mjs +6 -7
  424. package/dist/style/breakpoints.mjs +1 -2
  425. package/dist/style/cssLayers.mjs +1 -2
  426. package/dist/style/displayModes.mjs +1 -2
  427. package/dist/style/fontAssets.mjs +1 -2
  428. package/dist/style/fontValidation.mjs +14 -15
  429. package/dist/style/fonts.d.ts +5 -3
  430. package/dist/style/fonts.mjs +23 -24
  431. package/dist/style/fontsFromCss.mjs +1 -2
  432. package/dist/style/index.mjs +18 -18
  433. package/dist/style/keyframes.mjs +1 -2
  434. package/dist/style/layoutGrid.mjs +1 -2
  435. package/dist/style/notifications.mjs +1 -2
  436. package/dist/style/react/useDisplayMode.mjs +1 -2
  437. package/dist/style/react/useElementSize.mjs +1 -2
  438. package/dist/style/runtimeStyle.d.ts +19 -21
  439. package/dist/style/runtimeStyle.mjs +4 -7
  440. package/dist/style/snippetStyle.mjs +5 -6
  441. package/dist/style/styleConditions.mjs +1 -2
  442. package/dist/style/styleConstants.mjs +1 -2
  443. package/dist/style/stylePseudos.mjs +1 -2
  444. package/dist/style/styleStates.mjs +1 -2
  445. package/dist/style/styleTarget.mjs +24 -25
  446. package/dist/theme/cookie/index.mjs +1 -1
  447. package/dist/theme/cookie/themeCookie.d.ts +21 -1
  448. package/dist/theme/cookie/themeCookie.mjs +19 -4
  449. package/dist/theme/index.d.ts +1 -9
  450. package/dist/theme/index.mjs +1 -6
  451. package/dist/theme/{ThemeProvider.d.ts → react/ThemeProvider.d.ts} +8 -2
  452. package/dist/theme/react/ThemeProvider.mjs +78 -0
  453. package/dist/theme/{ThemeScope.d.ts → react/ThemeScope.d.ts} +6 -2
  454. package/dist/theme/react/ThemeScope.mjs +9 -0
  455. package/dist/theme/react/index.d.ts +9 -0
  456. package/dist/theme/react/index.mjs +5 -0
  457. package/dist/theme/{themeStore.d.ts → react/themeStore.d.ts} +5 -5
  458. package/dist/theme/{themeStore.mjs → react/themeStore.mjs} +4 -4
  459. package/dist/theme/{useTheme.d.ts → react/useTheme.d.ts} +1 -1
  460. package/dist/theme/react/useTheme.mjs +19 -0
  461. package/dist/types/ActionTypes.d.ts +33 -0
  462. package/dist/types/AuthTypes.d.ts +6 -0
  463. package/dist/types/CommonTypes.d.ts +14 -3
  464. package/dist/types/DataSourceTypes.d.ts +1 -1
  465. package/dist/types/FunctionTypes.d.ts +16 -6
  466. package/dist/types/InteractionTypes.d.ts +1 -1
  467. package/dist/types/JobTypes.d.ts +56 -182
  468. package/dist/types/PluginTypes.d.ts +8 -1
  469. package/dist/types/SchemaTypes.d.ts +1 -1
  470. package/dist/types/SchemaTypes.mjs +1 -2
  471. package/dist/types/ServerAdapterTypes.d.ts +0 -326
  472. package/dist/types/ServerTypes.d.ts +0 -311
  473. package/dist/types/SpaceTypes.d.ts +5 -2
  474. package/dist/types/StoreTypes.d.ts +9 -3
  475. package/dist/types/StyleTypes.d.ts +6 -0
  476. package/dist/types/StyleTypes.mjs +1 -2
  477. package/dist/types/index.d.ts +0 -3
  478. package/dist/websockets/RTCodec.mjs +1 -2
  479. package/eslint.config.mjs +25 -0
  480. package/package.json +29 -18
  481. package/vite.config.ts +58 -0
  482. package/dist/helpers/generateFacade.d.ts +0 -2
  483. package/dist/helpers/ruleEvaluator.d.ts +0 -16
  484. package/dist/helpers/ruleEvaluator.mjs +0 -5
  485. package/dist/network/NetworkInternalContext.mjs +0 -5
  486. package/dist/network/graphql/sdk/Mutations/index.d.ts +0 -3
  487. package/dist/network/graphql/sdk/Mutations/index.mjs +0 -4
  488. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +0 -16
  489. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +0 -4
  490. package/dist/network/graphql/sdk/Queries/index.d.ts +0 -6
  491. package/dist/network/graphql/sdk/Queries/index.mjs +0 -5
  492. package/dist/network/graphql/sdk/index.d.ts +0 -5
  493. package/dist/network/graphql/sdk/index.mjs +0 -3
  494. package/dist/theme/ThemeProvider.mjs +0 -69
  495. package/dist/theme/ThemeScope.mjs +0 -10
  496. package/dist/theme/useTheme.mjs +0 -20
  497. package/dist/types/OAuthTypes.d.ts +0 -246
  498. package/dist/types/ServerConfigTypes.d.ts +0 -527
  499. package/dist/types/ServerLogTypes.d.ts +0 -119
  500. /package/dist/{types/OAuthTypes.mjs → conditions/types.mjs} +0 -0
  501. /package/dist/{types/ServerConfigTypes.mjs → functions/kv.mjs} +0 -0
  502. /package/dist/{types/ServerLogTypes.mjs → functions/later.mjs} +0 -0
  503. /package/dist/{helpers → react}/enclosingSpace.d.ts +0 -0
  504. /package/dist/{helpers → react}/sharedContext.d.ts +0 -0
  505. /package/dist/{state → store}/runtimeStatePersist.d.ts +0 -0
@@ -0,0 +1,24 @@
1
+ // src/functions/kvChange.ts
2
+ var e = async (e, t, n, { lifetime: r, refusal: i }) => {
3
+ for (let i = 0; i < 25; i += 1) {
4
+ let a = await e.get(t), o = await n(a);
5
+ if (o === void 0) return;
6
+ if (await e.swap(t, a, o, typeof r == "function" ? r(o) : r)) return o;
7
+ await new Promise((e) => setTimeout(e, Math.random() * Math.min(5 + i * 5, 50)));
8
+ }
9
+ throw i("Many people are changing this at once — try again in a moment");
10
+ }, t = async (e, t, n, r, { refusal: i }) => {
11
+ for (let i = 0; i < 25; i += 1) {
12
+ let a = (await e.listRange(t)).find((e) => e.id === n), o = await r(a);
13
+ if (o === void 0 || o === null && a === void 0) return;
14
+ let s = o === null ? null : {
15
+ id: n,
16
+ score: o.score,
17
+ value: o.value
18
+ };
19
+ if (await e.listSwap(t, n, a, s)) return s;
20
+ await new Promise((e) => setTimeout(e, Math.random() * Math.min(5 + i * 5, 50)));
21
+ }
22
+ throw i("Many people are changing this at once — try again in a moment");
23
+ };
24
+ export { e as changeKv, t as changeListEntry };
@@ -0,0 +1,18 @@
1
+ /** What a run asks to start later: one of the space's actions, in so many seconds, with its input — and a name. */
2
+ export type LaterRequest = {
3
+ /** The action, by its identifier. It says it may be started this way with a `later` trigger. */
4
+ action: string;
5
+ /** Seconds from now, by the queue's clock — whole or not, from 0 to a month. */
6
+ in: number;
7
+ input?: Record<string, unknown>;
8
+ /**
9
+ * What it is known by in this space: setting another under the same key replaces the one still waiting — a turn's
10
+ * timer moved on by a move — and `cancelLater(key)` drops it. The one already running is left be.
11
+ */
12
+ key?: string;
13
+ };
14
+ /** The job it became, and when it is due — epoch ms, by the queue's clock. */
15
+ export type LaterAnswer = {
16
+ id: string;
17
+ at: number;
18
+ };
@@ -0,0 +1,4 @@
1
+ import { RunnerRequestMessage, RunnerResponseMessage } from './protocol';
2
+ /** What the platform sent the runner, or nothing when it is not one of the protocol's messages. */
3
+ export declare const readRequestMessage: (data: string) => RunnerRequestMessage | undefined;
4
+ export declare const readResponseMessage: (data: string) => RunnerResponseMessage | undefined;
@@ -0,0 +1,205 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
2
+ // src/functions/messages.ts
3
+ var t = {
4
+ production: !0,
5
+ staging: !0,
6
+ development: !0,
7
+ main: !0
8
+ }, n = (e) => typeof e == "string" && Object.hasOwn(t, e), r = (t) => {
9
+ try {
10
+ let n = JSON.parse(t);
11
+ return e(n) ? n : void 0;
12
+ } catch {
13
+ return;
14
+ }
15
+ }, i = (t) => e(t) && typeof t.id == "string" && typeof t.code == "string" ? {
16
+ id: t.id,
17
+ code: t.code
18
+ } : void 0, a = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : void 0, o = (t) => {
19
+ if (!e(t)) return;
20
+ let n = a(t.cpuMs), r = a(t.wallMs), i = a(t.memoryMb), o = a(t.outputBytes), s = a(t.calls);
21
+ return n !== void 0 && r !== void 0 && i !== void 0 && o !== void 0 && s !== void 0 ? {
22
+ cpuMs: n,
23
+ wallMs: r,
24
+ memoryMb: i,
25
+ outputBytes: o,
26
+ calls: s
27
+ } : void 0;
28
+ }, s = (t) => {
29
+ if (!e(t) || !e(t.context) || t.kind !== "task" && t.kind !== "route" && t.kind !== "job") return;
30
+ let { context: r } = t;
31
+ if (typeof r.spaceId != "number" || typeof r.runId != "string" || typeof r.trigger != "string" || typeof r.callerId != "string" || !n(r.environment)) return;
32
+ let i = {
33
+ spaceId: r.spaceId,
34
+ environment: r.environment,
35
+ runId: r.runId,
36
+ trigger: r.trigger,
37
+ callerId: r.callerId
38
+ }, o = e(r.user) ? r.user : void 0, s = o && typeof o.id == "number" && typeof o.username == "string" && typeof o.email == "string" && typeof o.verified == "boolean" && Array.isArray(o.permissions) && Array.isArray(o.roles) ? {
39
+ ...i,
40
+ user: {
41
+ id: o.id,
42
+ username: o.username,
43
+ email: o.email,
44
+ verified: o.verified,
45
+ permissions: o.permissions.filter((e) => typeof e == "string"),
46
+ roles: o.roles.filter((e) => typeof e == "string")
47
+ }
48
+ } : i;
49
+ if (t.kind === "task") return typeof t.name == "string" && e(t.params) ? {
50
+ kind: "task",
51
+ name: t.name,
52
+ params: t.params,
53
+ context: s
54
+ } : void 0;
55
+ if (t.kind === "job") {
56
+ let n = e(t.job) ? t.job : void 0, r = a(t.graceMs);
57
+ return typeof t.name == "string" && e(t.input) && n && typeof n.id == "string" && typeof n.attempt == "number" && r !== void 0 ? {
58
+ kind: "job",
59
+ name: t.name,
60
+ input: t.input,
61
+ job: {
62
+ id: n.id,
63
+ attempt: n.attempt,
64
+ ...n.state === void 0 ? {} : { state: n.state }
65
+ },
66
+ context: s,
67
+ graceMs: r
68
+ } : void 0;
69
+ }
70
+ let c = e(t.request) ? t.request : void 0;
71
+ if (!c || typeof t.key != "string" || typeof c.method != "string" || typeof c.url != "string") return;
72
+ let l = e(t.params) ? t.params : {}, u = e(c.body) ? c.body : void 0;
73
+ return {
74
+ kind: "route",
75
+ key: t.key,
76
+ params: Object.fromEntries(Object.entries(l).map(([e, t]) => [e, String(t)])),
77
+ request: {
78
+ method: c.method,
79
+ url: c.url,
80
+ headers: Array.isArray(c.headers) ? c.headers.flatMap((e) => Array.isArray(e) && typeof e[0] == "string" && typeof e[1] == "string" ? [[e[0], e[1]]] : []) : [],
81
+ body: u && typeof u.text == "string" ? { text: u.text } : u && typeof u.base64 == "string" ? { base64: u.base64 } : null
82
+ },
83
+ context: s
84
+ };
85
+ }, c = (t) => {
86
+ if (e(t)) {
87
+ if (t.ok === !0) return {
88
+ ok: !0,
89
+ value: t.value
90
+ };
91
+ if (t.ok === !1 && typeof t.error == "string") return {
92
+ ok: !1,
93
+ error: t.error,
94
+ ...t.refused === !0 ? { refused: !0 } : {},
95
+ ...typeof t.code == "string" ? { code: t.code } : {}
96
+ };
97
+ }
98
+ }, l = (e) => {
99
+ let t = r(e);
100
+ switch (t?.type) {
101
+ case "describe": {
102
+ let e = i(t.bundle);
103
+ return e && typeof t.protocol == "string" ? {
104
+ type: "describe",
105
+ protocol: t.protocol,
106
+ bundle: e
107
+ } : void 0;
108
+ }
109
+ case "invoke": {
110
+ let e = s(t.invocation), n = o(t.limits);
111
+ return e && n && typeof t.bundleId == "string" && typeof t.protocol == "string" ? {
112
+ type: "invoke",
113
+ protocol: t.protocol,
114
+ bundleId: t.bundleId,
115
+ invocation: e,
116
+ limits: n,
117
+ ...t.queue === !0 ? { queue: !0 } : {}
118
+ } : void 0;
119
+ }
120
+ case "bundle": {
121
+ let e = i(t.bundle);
122
+ return e ? {
123
+ type: "bundle",
124
+ bundle: e
125
+ } : void 0;
126
+ }
127
+ case "answer": {
128
+ let e = c(t.answer);
129
+ return e && typeof t.id == "number" ? {
130
+ type: "answer",
131
+ id: t.id,
132
+ answer: e
133
+ } : void 0;
134
+ }
135
+ case "abort": return typeof t.reason == "string" ? {
136
+ type: "abort",
137
+ reason: t.reason
138
+ } : { type: "abort" };
139
+ default: return;
140
+ }
141
+ }, u = [
142
+ "cpu",
143
+ "wall",
144
+ "memory",
145
+ "output",
146
+ "calls",
147
+ "aborted",
148
+ "error",
149
+ "refused",
150
+ "busy",
151
+ "too_large"
152
+ ], d = (e) => u.find((t) => t === e) ?? "error", f = (t) => {
153
+ if (!e(t)) return {};
154
+ let n = a(t.cpuMs), r = a(t.wallMs), i = a(t.calls);
155
+ return n !== void 0 && r !== void 0 && i !== void 0 ? { usage: {
156
+ cpuMs: n,
157
+ wallMs: r,
158
+ calls: i
159
+ } } : {};
160
+ }, p = (e) => Array.isArray(e) ? e.flatMap((e) => Array.isArray(e) && typeof e[0] == "string" && typeof e[1] == "string" ? [[e[0], e[1]]] : []) : [], m = (t) => {
161
+ let n = r(t);
162
+ switch (n?.type) {
163
+ case "accepted": return { type: "accepted" };
164
+ case "queued": return { type: "queued" };
165
+ case "waited": return typeof n.ms == "number" && Number.isFinite(n.ms) && n.ms >= 0 ? {
166
+ type: "waited",
167
+ ms: n.ms
168
+ } : void 0;
169
+ case "needBundle": return { type: "needBundle" };
170
+ case "head": return typeof n.status == "number" ? {
171
+ type: "head",
172
+ status: n.status,
173
+ statusText: typeof n.statusText == "string" ? n.statusText : "",
174
+ headers: p(n.headers)
175
+ } : void 0;
176
+ case "chunk": {
177
+ let t = e(n.chunk) ? n.chunk : void 0;
178
+ return typeof t?.base64 == "string" ? {
179
+ type: "chunk",
180
+ chunk: { base64: t.base64 }
181
+ } : typeof t?.text == "string" ? {
182
+ type: "chunk",
183
+ chunk: { text: t.text }
184
+ } : void 0;
185
+ }
186
+ case "call": return typeof n.id == "number" ? {
187
+ type: "call",
188
+ id: n.id,
189
+ call: n.call
190
+ } : void 0;
191
+ case "done": return {
192
+ type: "done",
193
+ value: n.value,
194
+ ...f(n.usage)
195
+ };
196
+ case "failed": return typeof n.error == "string" ? {
197
+ type: "failed",
198
+ reason: d(n.reason),
199
+ error: n.error,
200
+ ...f(n.usage)
201
+ } : void 0;
202
+ default: return;
203
+ }
204
+ };
205
+ export { l as readRequestMessage, m as readResponseMessage };
@@ -0,0 +1,416 @@
1
+ import { FunctionContext, FunctionFetchInit } from './contract';
2
+ import { LaterRequest } from './later';
3
+ import { RateLimit } from './rateLimit';
4
+ import { FunctionsManifest } from '../types';
5
+ /**
6
+ * The messages between the platform and whatever runs a space's code — the one protocol every runner speaks, whether
7
+ * it is in the process, a service of ours or a provider's. Versioned, because a runner is deployed apart from the
8
+ * platform that calls it: `major.minor`, where a minor only adds and a major may change what was there.
9
+ *
10
+ * 1.1 added the `busy` refusal: a runner short of memory takes no new invocation. A 1.0 platform reads it as an error.
11
+ * 1.2 added `accepted`: the runner took the invocation — an isolate free and memory for it — and the platform's wait for
12
+ * its answer starts then, not while it was being placed. A runner sends it to a 1.2 platform alone.
13
+ * 1.3 added `waited`: how long the invocation waited for the runner's CPU — a turn at running JavaScript, shared with the
14
+ * other invocations — which is the runner's time, not the code's: the platform's wait for its answer grows by it. A
15
+ * runner sends it to a 1.3 platform alone. And `queue`: with every runner full, the platform asks one to keep the
16
+ * invocation until it has room rather than turn it away — the runner says `queued`, then `accepted` once it starts.
17
+ * 1.4 added the `too_large` refusal: an invocation of a size this runner could not hold even with nothing else running —
18
+ * never `busy`, which waits for room that will never come. The platform gives it to another runner (a larger class), and
19
+ * fails it at once, naming the size, when none can. A runner sends it to a 1.4 platform alone; to an older one, `busy`.
20
+ */
21
+ export declare const FUNCTIONS_PROTOCOL = "1.4";
22
+ /** Whether a side speaking `theirs` knows what `since` added: the same major, and that minor or a later one. */
23
+ export declare const protocolKnows: (theirs: unknown, since: string) => boolean;
24
+ /** Who speaks each side of a versioned protocol, as its refusal names them: `here` answers, `there` calls. */
25
+ export type ProtocolSides = {
26
+ here: string;
27
+ there: string;
28
+ };
29
+ /**
30
+ * Why the side speaking `ours` cannot take a message of `theirs` — or undefined when it can: the same major, and a minor
31
+ * it knows (the answering side takes an older caller's messages, never the other way round). The answering side is
32
+ * deployed first for that reason, so the message names which side to upgrade. The functions protocol's sides by
33
+ * default: a runner, answering the platform.
34
+ */
35
+ export declare const protocolRefusal: (theirs: unknown, ours?: string, { here, there }?: ProtocolSides) => string | undefined;
36
+ /** A built bundle: `id` is its content digest, so a runner that has one never needs the code again. */
37
+ export type FunctionsBundle = {
38
+ id: string;
39
+ code: string;
40
+ };
41
+ /**
42
+ * A bundle as a run knows it: its id, and how to fetch its code — which only a runner that has never seen that id asks
43
+ * for. A run carries no code of its own: up to a megabyte read and sent on every run would be the run's whole cost.
44
+ */
45
+ export type FunctionsBundleRef = {
46
+ id: string;
47
+ load: () => Promise<string>;
48
+ };
49
+ /**
50
+ * What one invocation may spend — the portable subset every runner can enforce, each mapped to its own knobs. The
51
+ * platform sets them per space (its plan) and never above the deployment's ceilings.
52
+ */
53
+ export type FunctionLimits = {
54
+ /** CPU time the code may use, awaits not counted. */
55
+ cpuMs: number;
56
+ /** Wall time, from the moment it starts: the run's remaining budget, at most. */
57
+ wallMs: number;
58
+ memoryMb: number;
59
+ /** The size of what it answers, as JSON. */
60
+ outputBytes: number;
61
+ /** Calls back to the platform: `kv`, `fetch`, `publish`… */
62
+ calls: number;
63
+ };
64
+ /** Text travels as text; anything else base64, so a body is never mangled crossing a boundary that only speaks JSON. */
65
+ export type WireBody = {
66
+ text: string;
67
+ } | {
68
+ base64: string;
69
+ };
70
+ export type WireHeaders = [string, string][];
71
+ export type WireRequest = {
72
+ method: string;
73
+ url: string;
74
+ headers: WireHeaders;
75
+ body: WireBody | null;
76
+ };
77
+ export type WireResponse = {
78
+ status: number;
79
+ statusText: string;
80
+ headers: WireHeaders;
81
+ body: WireBody | null;
82
+ };
83
+ /**
84
+ * A route's answer as it is written rather than once it is done — what a space's runtime answers, so a route there
85
+ * streams as an endpoint does, with the platform's `ctx` all the same: its head at once, its body as the code writes it.
86
+ * Never JSON: it lives in the process that holds the run, its body fed by the runner's `chunk` messages.
87
+ */
88
+ export type StreamedRouteAnswer = {
89
+ streamed: true;
90
+ status: number;
91
+ statusText: string;
92
+ headers: WireHeaders;
93
+ body: ReadableStream<Uint8Array>;
94
+ };
95
+ export declare const isStreamedRouteAnswer: (value: unknown) => value is StreamedRouteAnswer;
96
+ /** Who and what an invocation is for: the facts a {@link FunctionContext} carries, sent with it rather than asked for. */
97
+ export type FunctionInvocationContext = Pick<FunctionContext, 'spaceId' | 'environment' | 'runId' | 'trigger' | 'callerId' | 'user'>;
98
+ /** The slice of a job an invocation runs: which job, what it saved so far, and which attempt this is. */
99
+ export type FunctionJobSlice = {
100
+ id: string;
101
+ state?: unknown;
102
+ attempt: number;
103
+ };
104
+ export type FunctionInvocation = {
105
+ kind: 'task';
106
+ name: string;
107
+ params: Record<string, unknown>;
108
+ context: FunctionInvocationContext;
109
+ } | {
110
+ kind: 'job';
111
+ name: string;
112
+ input: Record<string, unknown>;
113
+ job: FunctionJobSlice;
114
+ context: FunctionInvocationContext;
115
+ /**
116
+ * How long the code gets to save and return once the slice is asked to end (`signal` aborting with why: the
117
+ * `FunctionJobStop`), before the runner cuts it.
118
+ */
119
+ graceMs: number;
120
+ } | {
121
+ kind: 'route';
122
+ key: string;
123
+ params: Record<string, string>;
124
+ request: WireRequest;
125
+ context: FunctionInvocationContext;
126
+ };
127
+ /**
128
+ * Whether someone waits on an invocation's answer as it runs — a visitor's request to a route, an action a page called
129
+ * or renders, a webhook's sender — or nothing does: a schedule, a run put off for later, a job's slice. What a runner
130
+ * lets in first, and what it keeps room for: a visitor never waits behind a minute-long job.
131
+ */
132
+ export type FunctionUrgency = 'interactive' | 'background';
133
+ /** An invocation's {@link FunctionUrgency}, read off what it is and what started its run. */
134
+ export declare const invocationUrgency: (invocation: FunctionInvocation) => FunctionUrgency;
135
+ /** A request's init as the wire carries it: what the code wrote but its `signal`, which never crosses (`request`). */
136
+ export type WireFetchInit = Omit<FunctionFetchInit, 'signal'>;
137
+ /**
138
+ * One call back from the code to the platform: a {@link FunctionContext} method, by name, with its arguments. The
139
+ * platform answers it with the run's own context — scoped to the space and the run before anything is done.
140
+ *
141
+ * A request the code may cut short (its init had a `signal`) carries `request`, the code's own number for it, and the
142
+ * code's `abort` names that number when the signal fires: a signal is the code's object, and does not cross.
143
+ */
144
+ export type FunctionCall = {
145
+ op: 'kv';
146
+ method: string;
147
+ args: unknown[];
148
+ } | {
149
+ op: 'fetch';
150
+ url: string;
151
+ init: WireFetchInit;
152
+ request?: number;
153
+ } | {
154
+ op: 'abort';
155
+ request: number;
156
+ } | {
157
+ op: 'publish';
158
+ topic: string;
159
+ type: string;
160
+ data: unknown;
161
+ } | {
162
+ op: 'presence';
163
+ topic: string;
164
+ } | {
165
+ op: 'visitor';
166
+ who: string | number;
167
+ } | {
168
+ op: 'grant';
169
+ topic: string;
170
+ ttlSeconds?: number;
171
+ } | {
172
+ op: 'revoke';
173
+ topic: string;
174
+ grant?: string;
175
+ } | {
176
+ op: 'later';
177
+ request: LaterRequest;
178
+ } | {
179
+ op: 'cancelLater';
180
+ key: string;
181
+ } | {
182
+ op: 'rateLimit';
183
+ bucket: string;
184
+ limit: RateLimit;
185
+ } | {
186
+ op: 'sign';
187
+ value: string;
188
+ } | {
189
+ op: 'verify';
190
+ value: string;
191
+ signature: string;
192
+ } | {
193
+ op: 'data';
194
+ file: string;
195
+ } | {
196
+ op: 'oauth';
197
+ method: 'connect';
198
+ connection: string;
199
+ returnTo: string;
200
+ authorizeParams?: Record<string, string>;
201
+ owner?: string;
202
+ } | {
203
+ op: 'oauth';
204
+ method: 'status' | 'disconnect' | 'token';
205
+ connection: string;
206
+ owner?: string;
207
+ } | {
208
+ op: 'oauth';
209
+ method: 'callbackUrl';
210
+ } | {
211
+ op: 'oauth';
212
+ method: 'fetch';
213
+ connection: string;
214
+ url: string;
215
+ init: Omit<WireFetchInit, 'credential'>;
216
+ owner?: string;
217
+ request?: number;
218
+ }
219
+ /** `ctx.jobs`: the space's jobs, started and stopped by its code. */
220
+ | {
221
+ op: 'jobs';
222
+ method: 'start';
223
+ name: string;
224
+ input: Record<string, unknown>;
225
+ key?: string;
226
+ } | {
227
+ op: 'jobs';
228
+ method: 'get' | 'pause' | 'resume' | 'cancel';
229
+ id: string;
230
+ }
231
+ /** A job's `save` and `report`: what its slice keeps, and how far it is. */
232
+ | {
233
+ op: 'job';
234
+ method: 'save';
235
+ state: unknown;
236
+ } | {
237
+ op: 'job';
238
+ method: 'report';
239
+ fraction: number;
240
+ step?: string;
241
+ }
242
+ /** Each value as the guest could send it: JSON, with what JSON cannot say already said as text. */
243
+ | {
244
+ op: 'log';
245
+ values: unknown[];
246
+ } | {
247
+ op: 'emit';
248
+ chunk: unknown;
249
+ };
250
+ /**
251
+ * How a call or an invocation ended: its value, or why not — never a thrown object crossing the boundary. A refusal
252
+ * (`refused`, with its `code`) stays one on the other side: the code that made the call catches what the platform threw.
253
+ */
254
+ export type FunctionAnswer = {
255
+ ok: true;
256
+ value: unknown;
257
+ } | {
258
+ ok: false;
259
+ error: string;
260
+ refused?: true;
261
+ code?: string;
262
+ };
263
+ /** What a call that threw answers across a boundary: its message, and whether — and as what — it was a refusal. */
264
+ export declare const failedAnswerOf: (error: unknown) => Extract<FunctionAnswer, {
265
+ ok: false;
266
+ }>;
267
+ /** …and that answer thrown again on the side that made the call: a refusal as a refusal, anything else as an error. */
268
+ export declare const errorOfAnswer: ({ error, refused, code }: Extract<FunctionAnswer, {
269
+ ok: false;
270
+ }>) => Error;
271
+ /** Why the runner stopped an invocation, when it was not the code's own error. */
272
+ export type FunctionStopReason = 'cpu' | 'wall' | 'memory' | 'output' | 'calls' | 'aborted';
273
+ /** The stops that are limits: the code asked for more than it may — never the runner's fault, nor fixed by asking again. */
274
+ export type FunctionLimitReason = Exclude<FunctionStopReason, 'aborted'>;
275
+ /** Whether an invocation was stopped at a limit of its own ({@link FunctionLimitReason}). */
276
+ export declare const isFunctionLimit: (reason: string) => reason is FunctionLimitReason;
277
+ /** What the platform asks a runner for: every runner implements this, and nothing else of it is assumed. */
278
+ export type FunctionRunner = {
279
+ /** Loads a bundle and answers what it declares — when the space's functions are saved, never on a run. */
280
+ describe: (bundle: FunctionsBundle) => Promise<unknown>;
281
+ /**
282
+ * Runs one task, route or slice of a job of a bundle. Each call the code makes is handed to `answer`, whose result
283
+ * goes back to it; `signal` aborting ends the invocation — its `reason` handed to the code as the signal's, and a
284
+ * job's slice given its `graceMs` to save before it is cut. Resolves with what the code returned, and rejects with a
285
+ * {@link FunctionFailure}.
286
+ */
287
+ invoke: (request: FunctionInvokeRequest) => Promise<unknown>;
288
+ /**
289
+ * Whether a runner for this space answered the last time one was asked — false for a while after none could be
290
+ * reached. What lets a call that needs the space's code wait in the queue instead of starting and failing half-way.
291
+ * Absent: always reachable (the runner is this process).
292
+ */
293
+ reachable?: (spaceId?: number) => boolean;
294
+ /**
295
+ * How many invocations this process asked of it that no runner has taken yet — being placed, or kept in a runner's
296
+ * queue. What a job worker holds back by: with runs waiting for room, a job it claims would wait beside them, held
297
+ * as running, while it could wait in the queue. Absent: none ever waits (the runner is this process).
298
+ */
299
+ waitingForRoom?: () => number;
300
+ close?: () => Promise<void>;
301
+ };
302
+ /** What one invocation spent — what a deployment meters and budgets by. */
303
+ export type FunctionUsage = {
304
+ cpuMs: number;
305
+ wallMs: number;
306
+ calls: number;
307
+ };
308
+ export type FunctionInvokeRequest = {
309
+ bundle: FunctionsBundleRef;
310
+ invocation: FunctionInvocation;
311
+ limits: FunctionLimits;
312
+ /** Handed each call exactly as the code sent it: the platform reads it (`readCall`), trusting no runner to have. */
313
+ answer: (call: unknown) => Promise<unknown>;
314
+ signal: AbortSignal;
315
+ /** Told what the invocation spent once it ends, however it ended — before `invoke` settles. */
316
+ onUsage?: (usage: FunctionUsage) => void;
317
+ /**
318
+ * Told how long it waited for the runner's CPU, as it waits — a turn shared with the other invocations: the runner's
319
+ * time, which neither its time limit nor whoever waits for its answer should count.
320
+ */
321
+ onWaited?: (ms: number) => void;
322
+ };
323
+ /**
324
+ * Why an invocation did not answer: the code refused (`refused` — an `ActionRefusal`, its message written for whoever
325
+ * asked), it threw (`error`), the runner stopped it (a {@link FunctionStopReason}), the runner took none, short of
326
+ * memory (`busy` — another instance, or a moment later, takes it), no runner could be reached at all
327
+ * (`unreachable` — the invocation was never sent, so nothing of it ran), or the runner went away while it ran it
328
+ * (`lost` — the platform's doing, never the code's, but it may have run in part, so it is not sent again for it).
329
+ */
330
+ export type FunctionFailureReason = FunctionStopReason | 'error' | 'refused' | 'busy' | 'too_large' | 'unreachable' | 'lost';
331
+ /** An invocation that did not answer, and why ({@link FunctionFailureReason}). */
332
+ export declare class FunctionFailure extends Error {
333
+ readonly reason: FunctionFailureReason;
334
+ constructor(reason: FunctionFailureReason, message: string);
335
+ }
336
+ /**
337
+ * A space's functions as a run reaches them: the bundle by reference, what it declared when it was saved, and the limits
338
+ * its plan sets.
339
+ */
340
+ export type SpaceFunctions = {
341
+ bundle: FunctionsBundleRef;
342
+ manifest: FunctionsManifest;
343
+ limits?: Partial<FunctionLimits>;
344
+ /**
345
+ * What runs them, when it is not the deployment's sandbox: the space's own runtime (`createRemoteRunner` to it). Its
346
+ * bundle id then names that runtime's code, so a registry built for one never answers for another.
347
+ */
348
+ runner?: FunctionRunner;
349
+ };
350
+ /** The messages of one runner connection (our own runner service), each side's in turn. */
351
+ export type RunnerRequestMessage = {
352
+ type: 'describe';
353
+ protocol: string;
354
+ bundle: FunctionsBundle;
355
+ } | {
356
+ type: 'invoke';
357
+ protocol: string;
358
+ bundleId: string;
359
+ invocation: FunctionInvocation;
360
+ limits: FunctionLimits;
361
+ /** Every runner was full: keep it until there is room, rather than turn it away (1.3). */
362
+ queue?: boolean;
363
+ } | {
364
+ type: 'bundle';
365
+ bundle: FunctionsBundle;
366
+ } | {
367
+ type: 'answer';
368
+ id: number;
369
+ answer: FunctionAnswer;
370
+ }
371
+ /** The invocation is asked to end — for a job's slice, with why (a `FunctionJobStop`). */
372
+ | {
373
+ type: 'abort';
374
+ reason?: string;
375
+ };
376
+ export type RunnerResponseMessage =
377
+ /** The invocation was taken — a free isolate and memory for it (1.2): what its answer is waited for from. */
378
+ {
379
+ type: 'accepted';
380
+ }
381
+ /** Kept until it has room for it (1.3, `queue`): `accepted` follows once it starts — what its time is counted from. */
382
+ | {
383
+ type: 'queued';
384
+ }
385
+ /** It waited this long for the runner's CPU since it last said (1.3): the runner's time, which the deadline grows by. */
386
+ | {
387
+ type: 'waited';
388
+ ms: number;
389
+ } | {
390
+ type: 'needBundle';
391
+ }
392
+ /** A route answering as it writes: its head, then each `chunk` of its body, then `done`. */
393
+ | {
394
+ type: 'head';
395
+ status: number;
396
+ statusText: string;
397
+ headers: WireHeaders;
398
+ } | {
399
+ type: 'chunk';
400
+ chunk: WireBody;
401
+ }
402
+ /** As the code sent it: the platform reads it, trusting no runner to have. */
403
+ | {
404
+ type: 'call';
405
+ id: number;
406
+ call: unknown;
407
+ } | {
408
+ type: 'done';
409
+ value: unknown;
410
+ usage?: FunctionUsage;
411
+ } | {
412
+ type: 'failed';
413
+ reason: FunctionFailureReason;
414
+ error: string;
415
+ usage?: FunctionUsage;
416
+ };