@makeswift/runtime 0.24.9-canary.0 → 0.25.0-canary.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 (250) hide show
  1. package/dist/cjs/api/site-version.js +8 -2
  2. package/dist/cjs/api/site-version.js.map +1 -1
  3. package/dist/cjs/api-handler/cookies.js +38 -0
  4. package/dist/cjs/api-handler/cookies.js.map +1 -0
  5. package/dist/cjs/api-handler/cors.js +48 -0
  6. package/dist/cjs/api-handler/cors.js.map +1 -0
  7. package/dist/cjs/api-handler/handlers/clear-draft.js +41 -0
  8. package/dist/cjs/api-handler/handlers/clear-draft.js.map +1 -0
  9. package/dist/cjs/api-handler/handlers/element-tree.js +41 -0
  10. package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -0
  11. package/dist/cjs/{next/api-handler → api-handler}/handlers/fonts.js +9 -9
  12. package/dist/cjs/api-handler/handlers/fonts.js.map +1 -0
  13. package/dist/cjs/api-handler/handlers/manifest.js +50 -0
  14. package/dist/cjs/api-handler/handlers/manifest.js.map +1 -0
  15. package/dist/cjs/api-handler/handlers/merge-translated-data.js +41 -0
  16. package/dist/cjs/api-handler/handlers/merge-translated-data.js.map +1 -0
  17. package/dist/cjs/api-handler/handlers/revalidate.js +60 -0
  18. package/dist/cjs/api-handler/handlers/revalidate.js.map +1 -0
  19. package/dist/cjs/api-handler/handlers/translatable-data.js +42 -0
  20. package/dist/cjs/api-handler/handlers/translatable-data.js.map +1 -0
  21. package/dist/cjs/{next/api-handler → api-handler}/handlers/webhook/index.js +16 -23
  22. package/dist/cjs/api-handler/handlers/webhook/index.js.map +1 -0
  23. package/dist/cjs/{next/api-handler → api-handler}/handlers/webhook/site-published.js +2 -4
  24. package/dist/cjs/api-handler/handlers/webhook/site-published.js.map +1 -0
  25. package/dist/cjs/api-handler/handlers/webhook/types.js.map +1 -0
  26. package/dist/cjs/api-handler/index.js +116 -0
  27. package/dist/cjs/api-handler/index.js.map +1 -0
  28. package/dist/cjs/api-handler/request-response.js +43 -0
  29. package/dist/cjs/api-handler/request-response.js.map +1 -0
  30. package/dist/cjs/next/api-handler/config/app-router.js +65 -0
  31. package/dist/cjs/next/api-handler/config/app-router.js.map +1 -0
  32. package/dist/cjs/next/api-handler/config/base.js +39 -0
  33. package/dist/cjs/next/api-handler/config/base.js.map +1 -0
  34. package/dist/cjs/next/api-handler/config/pages-router.js +123 -0
  35. package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -0
  36. package/dist/cjs/next/api-handler/{handlers/utils/draft.js → draft.js} +2 -14
  37. package/dist/cjs/next/api-handler/draft.js.map +1 -0
  38. package/dist/cjs/next/api-handler/handlers/redirect-draft.js +8 -17
  39. package/dist/cjs/next/api-handler/handlers/redirect-draft.js.map +1 -1
  40. package/dist/cjs/next/api-handler/handlers/redirect-preview.js +12 -19
  41. package/dist/cjs/next/api-handler/handlers/redirect-preview.js.map +1 -1
  42. package/dist/cjs/next/api-handler/index.js +19 -154
  43. package/dist/cjs/next/api-handler/index.js.map +1 -1
  44. package/dist/cjs/next/middleware/request-utils.js +1 -1
  45. package/dist/cjs/next/middleware/request-utils.js.map +1 -1
  46. package/dist/cjs/next/server.js.map +1 -1
  47. package/dist/cjs/next/tests/__fixtures__/element-tree.js +1776 -0
  48. package/dist/cjs/next/tests/__fixtures__/element-tree.js.map +1 -0
  49. package/dist/cjs/next/tests/__fixtures__/resources.js +99 -0
  50. package/dist/cjs/next/tests/__fixtures__/resources.js.map +1 -0
  51. package/dist/cjs/next/tests/__fixtures__/translated-data.js +83 -0
  52. package/dist/cjs/next/tests/__fixtures__/translated-data.js.map +1 -0
  53. package/dist/cjs/next/tests/test-utils.js +98 -23
  54. package/dist/cjs/next/tests/test-utils.js.map +1 -1
  55. package/dist/esm/api/site-version.js +6 -1
  56. package/dist/esm/api/site-version.js.map +1 -1
  57. package/dist/esm/api-handler/cookies.js +13 -0
  58. package/dist/esm/api-handler/cookies.js.map +1 -0
  59. package/dist/esm/api-handler/cors.js +24 -0
  60. package/dist/esm/api-handler/cors.js.map +1 -0
  61. package/dist/esm/api-handler/handlers/clear-draft.js +17 -0
  62. package/dist/esm/api-handler/handlers/clear-draft.js.map +1 -0
  63. package/dist/esm/api-handler/handlers/element-tree.js +17 -0
  64. package/dist/esm/api-handler/handlers/element-tree.js.map +1 -0
  65. package/dist/esm/api-handler/handlers/fonts.js +9 -0
  66. package/dist/esm/api-handler/handlers/fonts.js.map +1 -0
  67. package/dist/esm/api-handler/handlers/manifest.js +29 -0
  68. package/dist/esm/api-handler/handlers/manifest.js.map +1 -0
  69. package/dist/esm/api-handler/handlers/merge-translated-data.js +17 -0
  70. package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -0
  71. package/dist/esm/api-handler/handlers/revalidate.js +29 -0
  72. package/dist/esm/api-handler/handlers/revalidate.js.map +1 -0
  73. package/dist/esm/api-handler/handlers/translatable-data.js +18 -0
  74. package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -0
  75. package/dist/esm/api-handler/handlers/webhook/index.js +30 -0
  76. package/dist/esm/api-handler/handlers/webhook/index.js.map +1 -0
  77. package/dist/esm/api-handler/handlers/webhook/site-published.js +13 -0
  78. package/dist/esm/api-handler/handlers/webhook/site-published.js.map +1 -0
  79. package/dist/esm/api-handler/handlers/webhook/types.js.map +1 -0
  80. package/dist/esm/api-handler/index.js +95 -0
  81. package/dist/esm/api-handler/index.js.map +1 -0
  82. package/dist/esm/api-handler/request-response.js +18 -0
  83. package/dist/esm/api-handler/request-response.js.map +1 -0
  84. package/dist/esm/next/api-handler/config/app-router.js +40 -0
  85. package/dist/esm/next/api-handler/config/app-router.js.map +1 -0
  86. package/dist/esm/next/api-handler/config/base.js +15 -0
  87. package/dist/esm/next/api-handler/config/base.js.map +1 -0
  88. package/dist/esm/next/api-handler/config/pages-router.js +98 -0
  89. package/dist/esm/next/api-handler/config/pages-router.js.map +1 -0
  90. package/dist/esm/next/api-handler/{handlers/utils/draft.js → draft.js} +1 -11
  91. package/dist/esm/next/api-handler/draft.js.map +1 -0
  92. package/dist/esm/next/api-handler/handlers/redirect-draft.js +5 -21
  93. package/dist/esm/next/api-handler/handlers/redirect-draft.js.map +1 -1
  94. package/dist/esm/next/api-handler/handlers/redirect-preview.js +4 -21
  95. package/dist/esm/next/api-handler/handlers/redirect-preview.js.map +1 -1
  96. package/dist/esm/next/api-handler/index.js +20 -159
  97. package/dist/esm/next/api-handler/index.js.map +1 -1
  98. package/dist/esm/next/middleware/request-utils.js +1 -4
  99. package/dist/esm/next/middleware/request-utils.js.map +1 -1
  100. package/dist/esm/next/server.js.map +1 -1
  101. package/dist/esm/next/tests/__fixtures__/element-tree.js +1752 -0
  102. package/dist/esm/next/tests/__fixtures__/element-tree.js.map +1 -0
  103. package/dist/esm/next/tests/__fixtures__/resources.js +69 -0
  104. package/dist/esm/next/tests/__fixtures__/resources.js.map +1 -0
  105. package/dist/esm/next/tests/__fixtures__/translated-data.js +59 -0
  106. package/dist/esm/next/tests/__fixtures__/translated-data.js.map +1 -0
  107. package/dist/esm/next/tests/test-utils.js +98 -23
  108. package/dist/esm/next/tests/test-utils.js.map +1 -1
  109. package/dist/types/api/site-version.d.ts +1 -0
  110. package/dist/types/api/site-version.d.ts.map +1 -1
  111. package/dist/types/api-handler/cookies.d.ts +9 -0
  112. package/dist/types/api-handler/cookies.d.ts.map +1 -0
  113. package/dist/types/api-handler/cors.d.ts +10 -0
  114. package/dist/types/api-handler/cors.d.ts.map +1 -0
  115. package/dist/types/api-handler/handlers/clear-draft.d.ts +7 -0
  116. package/dist/types/api-handler/handlers/clear-draft.d.ts.map +1 -0
  117. package/dist/types/api-handler/handlers/element-tree.d.ts +9 -0
  118. package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -0
  119. package/dist/types/api-handler/handlers/fonts.d.ts +18 -0
  120. package/dist/types/api-handler/handlers/fonts.d.ts.map +1 -0
  121. package/dist/types/api-handler/handlers/manifest.d.ts +20 -0
  122. package/dist/types/api-handler/handlers/manifest.d.ts.map +1 -0
  123. package/dist/types/api-handler/handlers/merge-translated-data.d.ts +11 -0
  124. package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -0
  125. package/dist/types/api-handler/handlers/revalidate.d.ts +10 -0
  126. package/dist/types/api-handler/handlers/revalidate.d.ts.map +1 -0
  127. package/dist/types/api-handler/handlers/translatable-data.d.ts +15 -0
  128. package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -0
  129. package/dist/types/api-handler/handlers/webhook/index.d.ts +12 -0
  130. package/dist/types/api-handler/handlers/webhook/index.d.ts.map +1 -0
  131. package/dist/types/{next/api-handler → api-handler}/handlers/webhook/site-published.d.ts +2 -1
  132. package/dist/types/api-handler/handlers/webhook/site-published.d.ts.map +1 -0
  133. package/dist/types/{next/api-handler → api-handler}/handlers/webhook/types.d.ts +2 -4
  134. package/dist/types/api-handler/handlers/webhook/types.d.ts.map +1 -0
  135. package/dist/types/api-handler/index.d.ts +35 -0
  136. package/dist/types/api-handler/index.d.ts.map +1 -0
  137. package/dist/types/api-handler/request-response.d.ts +12 -0
  138. package/dist/types/api-handler/request-response.d.ts.map +1 -0
  139. package/dist/types/next/api-handler/config/app-router.d.ts +16 -0
  140. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -0
  141. package/dist/types/next/api-handler/config/base.d.ts +15 -0
  142. package/dist/types/next/api-handler/config/base.d.ts.map +1 -0
  143. package/dist/types/next/api-handler/config/pages-router.d.ts +10 -0
  144. package/dist/types/next/api-handler/config/pages-router.d.ts.map +1 -0
  145. package/dist/types/next/api-handler/{handlers/utils/draft.d.ts → draft.d.ts} +0 -8
  146. package/dist/types/next/api-handler/draft.d.ts.map +1 -0
  147. package/dist/types/next/api-handler/handlers/redirect-draft.d.ts +3 -16
  148. package/dist/types/next/api-handler/handlers/redirect-draft.d.ts.map +1 -1
  149. package/dist/types/next/api-handler/handlers/redirect-preview.d.ts +1 -14
  150. package/dist/types/next/api-handler/handlers/redirect-preview.d.ts.map +1 -1
  151. package/dist/types/next/api-handler/index.d.ts +10 -36
  152. package/dist/types/next/api-handler/index.d.ts.map +1 -1
  153. package/dist/types/next/middleware/request-utils.d.ts.map +1 -1
  154. package/dist/types/next/server.d.ts +2 -1
  155. package/dist/types/next/server.d.ts.map +1 -1
  156. package/dist/types/next/tests/__fixtures__/element-tree.d.ts +3 -0
  157. package/dist/types/next/tests/__fixtures__/element-tree.d.ts.map +1 -0
  158. package/dist/types/next/tests/__fixtures__/resources.d.ts +9 -0
  159. package/dist/types/next/tests/__fixtures__/resources.d.ts.map +1 -0
  160. package/dist/types/next/tests/__fixtures__/translated-data.d.ts +56 -0
  161. package/dist/types/next/tests/__fixtures__/translated-data.d.ts.map +1 -0
  162. package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts +2 -0
  163. package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts.map +1 -0
  164. package/dist/types/next/tests/server.api-handler-cors.test.d.ts +2 -0
  165. package/dist/types/next/tests/server.api-handler-cors.test.d.ts.map +1 -0
  166. package/dist/types/next/tests/server.api-handler-element-tree.test.d.ts +2 -0
  167. package/dist/types/next/tests/server.api-handler-element-tree.test.d.ts.map +1 -0
  168. package/dist/types/next/tests/server.api-handler-error-handling.test.d.ts +2 -0
  169. package/dist/types/next/tests/server.api-handler-error-handling.test.d.ts.map +1 -0
  170. package/dist/types/next/tests/server.api-handler-fonts.test.d.ts +2 -0
  171. package/dist/types/next/tests/server.api-handler-fonts.test.d.ts.map +1 -0
  172. package/dist/types/next/tests/server.api-handler-manifest.test.d.ts +2 -0
  173. package/dist/types/next/tests/server.api-handler-manifest.test.d.ts.map +1 -0
  174. package/dist/types/next/tests/server.api-handler-merge-translated-data.test.d.ts +2 -0
  175. package/dist/types/next/tests/server.api-handler-merge-translated-data.test.d.ts.map +1 -0
  176. package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts +2 -0
  177. package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts.map +1 -0
  178. package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts +2 -0
  179. package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts.map +1 -0
  180. package/dist/types/next/tests/server.api-handler-resources.test.d.ts +2 -0
  181. package/dist/types/next/tests/server.api-handler-resources.test.d.ts.map +1 -0
  182. package/dist/types/next/tests/server.api-handler-revalidate.test.d.ts +2 -0
  183. package/dist/types/next/tests/server.api-handler-revalidate.test.d.ts.map +1 -0
  184. package/dist/types/next/tests/server.api-handler-translatable-data.test.d.ts +2 -0
  185. package/dist/types/next/tests/server.api-handler-translatable-data.test.d.ts.map +1 -0
  186. package/dist/types/next/tests/server.api-handler-webhook.test.d.ts +2 -0
  187. package/dist/types/next/tests/server.api-handler-webhook.test.d.ts.map +1 -0
  188. package/dist/types/next/tests/test-utils.d.ts +37 -4
  189. package/dist/types/next/tests/test-utils.d.ts.map +1 -1
  190. package/package.json +3 -3
  191. package/dist/cjs/next/api-handler/handlers/clear-draft.js +0 -64
  192. package/dist/cjs/next/api-handler/handlers/clear-draft.js.map +0 -1
  193. package/dist/cjs/next/api-handler/handlers/element-tree.js +0 -47
  194. package/dist/cjs/next/api-handler/handlers/element-tree.js.map +0 -1
  195. package/dist/cjs/next/api-handler/handlers/fonts.js.map +0 -1
  196. package/dist/cjs/next/api-handler/handlers/manifest.js +0 -55
  197. package/dist/cjs/next/api-handler/handlers/manifest.js.map +0 -1
  198. package/dist/cjs/next/api-handler/handlers/merge-translated-data.js +0 -47
  199. package/dist/cjs/next/api-handler/handlers/merge-translated-data.js.map +0 -1
  200. package/dist/cjs/next/api-handler/handlers/revalidate.js +0 -74
  201. package/dist/cjs/next/api-handler/handlers/revalidate.js.map +0 -1
  202. package/dist/cjs/next/api-handler/handlers/translatable-data.js +0 -47
  203. package/dist/cjs/next/api-handler/handlers/translatable-data.js.map +0 -1
  204. package/dist/cjs/next/api-handler/handlers/utils/draft.js.map +0 -1
  205. package/dist/cjs/next/api-handler/handlers/webhook/index.js.map +0 -1
  206. package/dist/cjs/next/api-handler/handlers/webhook/site-published.js.map +0 -1
  207. package/dist/cjs/next/api-handler/handlers/webhook/types.js.map +0 -1
  208. package/dist/esm/next/api-handler/handlers/clear-draft.js +0 -50
  209. package/dist/esm/next/api-handler/handlers/clear-draft.js.map +0 -1
  210. package/dist/esm/next/api-handler/handlers/element-tree.js +0 -27
  211. package/dist/esm/next/api-handler/handlers/element-tree.js.map +0 -1
  212. package/dist/esm/next/api-handler/handlers/fonts.js +0 -13
  213. package/dist/esm/next/api-handler/handlers/fonts.js.map +0 -1
  214. package/dist/esm/next/api-handler/handlers/manifest.js +0 -35
  215. package/dist/esm/next/api-handler/handlers/manifest.js.map +0 -1
  216. package/dist/esm/next/api-handler/handlers/merge-translated-data.js +0 -27
  217. package/dist/esm/next/api-handler/handlers/merge-translated-data.js.map +0 -1
  218. package/dist/esm/next/api-handler/handlers/revalidate.js +0 -40
  219. package/dist/esm/next/api-handler/handlers/revalidate.js.map +0 -1
  220. package/dist/esm/next/api-handler/handlers/translatable-data.js +0 -27
  221. package/dist/esm/next/api-handler/handlers/translatable-data.js.map +0 -1
  222. package/dist/esm/next/api-handler/handlers/utils/draft.js.map +0 -1
  223. package/dist/esm/next/api-handler/handlers/webhook/index.js +0 -41
  224. package/dist/esm/next/api-handler/handlers/webhook/index.js.map +0 -1
  225. package/dist/esm/next/api-handler/handlers/webhook/site-published.js +0 -15
  226. package/dist/esm/next/api-handler/handlers/webhook/site-published.js.map +0 -1
  227. package/dist/esm/next/api-handler/handlers/webhook/types.js.map +0 -1
  228. package/dist/types/next/api-handler/handlers/clear-draft.d.ts +0 -20
  229. package/dist/types/next/api-handler/handlers/clear-draft.d.ts.map +0 -1
  230. package/dist/types/next/api-handler/handlers/element-tree.d.ts +0 -20
  231. package/dist/types/next/api-handler/handlers/element-tree.d.ts.map +0 -1
  232. package/dist/types/next/api-handler/handlers/fonts.d.ts +0 -28
  233. package/dist/types/next/api-handler/handlers/fonts.d.ts.map +0 -1
  234. package/dist/types/next/api-handler/handlers/manifest.d.ts +0 -32
  235. package/dist/types/next/api-handler/handlers/manifest.d.ts.map +0 -1
  236. package/dist/types/next/api-handler/handlers/merge-translated-data.d.ts +0 -20
  237. package/dist/types/next/api-handler/handlers/merge-translated-data.d.ts.map +0 -1
  238. package/dist/types/next/api-handler/handlers/revalidate.d.ts +0 -22
  239. package/dist/types/next/api-handler/handlers/revalidate.d.ts.map +0 -1
  240. package/dist/types/next/api-handler/handlers/translatable-data.d.ts +0 -20
  241. package/dist/types/next/api-handler/handlers/translatable-data.d.ts.map +0 -1
  242. package/dist/types/next/api-handler/handlers/utils/draft.d.ts.map +0 -1
  243. package/dist/types/next/api-handler/handlers/webhook/index.d.ts +0 -19
  244. package/dist/types/next/api-handler/handlers/webhook/index.d.ts.map +0 -1
  245. package/dist/types/next/api-handler/handlers/webhook/site-published.d.ts.map +0 -1
  246. package/dist/types/next/api-handler/handlers/webhook/types.d.ts.map +0 -1
  247. package/dist/types/next/tests/server.makeswift-api-handler.test.d.ts +0 -2
  248. package/dist/types/next/tests/server.makeswift-api-handler.test.d.ts.map +0 -1
  249. /package/dist/cjs/{next/api-handler → api-handler}/handlers/webhook/types.js +0 -0
  250. /package/dist/esm/{next/api-handler → api-handler}/handlers/webhook/types.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-fonts.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-fonts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-manifest.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-manifest.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-manifest.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-merge-translated-data.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-merge-translated-data.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-merge-translated-data.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-redirect-draft.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-redirect-draft.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-redirect-draft.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-redirect-preview.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-redirect-preview.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-redirect-preview.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-resources.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-resources.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-resources.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-revalidate.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-revalidate.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-revalidate.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-translatable-data.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-translatable-data.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-translatable-data.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.api-handler-webhook.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.api-handler-webhook.test.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/server.api-handler-webhook.test.ts"],"names":[],"mappings":""}
@@ -1,8 +1,41 @@
1
- import { NextApiRequest } from 'next';
2
- import { RequestMethod } from 'node-mocks-http';
3
- export declare function createNextApiRequest({ method, path, body, }: {
1
+ import { NextApiResponse } from 'next';
2
+ import { type RequestMethod, type MockResponse } from 'node-mocks-http';
3
+ import { MakeswiftApiHandler } from '../api-handler';
4
+ export type MakeswiftApiHandlerArgs = Partial<Parameters<typeof MakeswiftApiHandler>[1]>;
5
+ export declare const hostUrl: (path: string) => URL;
6
+ export type RequestParams = {
4
7
  method: RequestMethod;
5
8
  path: string;
9
+ originalPath?: string;
6
10
  body?: Record<string, unknown>;
7
- }): NextApiRequest;
11
+ headers?: Record<string, string>;
12
+ };
13
+ export declare function pagesRouterApiRequestFixture(args?: MakeswiftApiHandlerArgs, responseMock?: MockResponse<NextApiResponse>): {
14
+ testApiRequest: (reqParams: RequestParams) => Promise<{
15
+ statusCode: number;
16
+ readonly jsonBody: any;
17
+ readonly textBody: any;
18
+ headers: {
19
+ getSetCookie(): string[] | undefined;
20
+ get(key: string): string | string[] | undefined;
21
+ };
22
+ }>;
23
+ apiKey: string;
24
+ };
25
+ export declare function appRouterApiRequestFixture(args?: MakeswiftApiHandlerArgs): {
26
+ testApiRequest: (reqParams: RequestParams) => Promise<{
27
+ statusCode: number | undefined;
28
+ readonly jsonBody: Promise<any> | undefined;
29
+ readonly textBody: Promise<string> | undefined;
30
+ headers: Headers;
31
+ }>;
32
+ apiKey: string;
33
+ };
34
+ export declare const apiRequestFixtures: ({
35
+ fixture: typeof pagesRouterApiRequestFixture;
36
+ router: string;
37
+ } | {
38
+ fixture: typeof appRouterApiRequestFixture;
39
+ router: string;
40
+ })[];
8
41
  //# sourceMappingURL=test-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AACrC,OAAO,EAAiB,aAAa,EAAE,MAAM,iBAAiB,CAAA;AA0B9D,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,IAAI,EACJ,IAAI,GACL,EAAE;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,GAAG,cAAc,CAOjB"}
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/next/tests/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,MAAM,MAAM,CAAA;AAEtD,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAGpD,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAYxF,eAAO,MAAM,OAAO,SAAU,MAAM,QAAyC,CAAA;AAQ7E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC,CAAA;AAuCD,wBAAgB,4BAA4B,CAC1C,IAAI,GAAE,uBAA4B,EAClC,YAAY,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC;gCAMH,aAAa;;;;;;qBAcvC,MAAM;;;;EAUtB;AAED,wBAAgB,0BAA0B,CAAC,IAAI,GAAE,uBAA4B;gCAGlC,aAAa;;;;;;;EAevD;AAED,eAAO,MAAM,kBAAkB;;;;;;IAG9B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.24.9-canary.0",
3
+ "version": "0.25.0-canary.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -172,7 +172,7 @@
172
172
  "zod": "^3.21.4",
173
173
  "@makeswift/controls": "0.1.12",
174
174
  "@makeswift/next-plugin": "0.4.1",
175
- "@makeswift/prop-controllers": "0.4.6-canary.0"
175
+ "@makeswift/prop-controllers": "0.4.6-canary.1"
176
176
  },
177
177
  "devDependencies": {
178
178
  "@emotion/jest": "^11.11.0",
@@ -193,7 +193,7 @@
193
193
  "@types/react": "^18.2.14",
194
194
  "@types/react-dom": "^18.2.6",
195
195
  "@types/set-cookie-parser": "^2.4.10",
196
- "@types/web": "^0.0.208",
196
+ "@typescript/lib-dom": "npm:@types/web@^0.0.243",
197
197
  "concurrently": "^5.3.0",
198
198
  "expect-type": "^0.19.0",
199
199
  "jest": "^29.7.0",
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var clear_draft_exports = {};
20
- __export(clear_draft_exports, {
21
- default: () => clearDraftHandler
22
- });
23
- module.exports = __toCommonJS(clear_draft_exports);
24
- var import_server = require("next/server");
25
- var import_ts_pattern = require("ts-pattern");
26
- var import_draft = require("./utils/draft");
27
- var import_cookie = require("cookie");
28
- function clearCookiesHeader(cookieNames) {
29
- const headers = new Headers();
30
- cookieNames.forEach((name) => {
31
- headers.append(
32
- import_draft.SET_COOKIE_HEADER,
33
- (0, import_cookie.serialize)(name, "", { ...import_draft.cookieSettingOptions, expires: /* @__PURE__ */ new Date(0) })
34
- );
35
- });
36
- const setCookieHeader = headers.get(import_draft.SET_COOKIE_HEADER);
37
- if (setCookieHeader == null) {
38
- throw new Error(
39
- `Could not generate set-cookie header to clear cookies: ${cookieNames.join(", ")}`
40
- );
41
- }
42
- return setCookieHeader;
43
- }
44
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
45
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
46
- async function clearDraftHandler(...args) {
47
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, (args2) => clearDraftRouteHandler(...args2)).with(apiRoutePattern, (args2) => clearDraftApiRouteHandler(...args2)).exhaustive();
48
- }
49
- async function clearDraftRouteHandler(_request, _context, {}) {
50
- const headers = new Headers();
51
- headers.append(
52
- import_draft.SET_COOKIE_HEADER,
53
- clearCookiesHeader([import_draft.PRERENDER_BYPASS_COOKIE, import_draft.MAKESWIFT_DRAFT_DATA_COOKIE])
54
- );
55
- return import_server.NextResponse.json({ __brand: "ClearDraftResponse" }, { headers });
56
- }
57
- async function clearDraftApiRouteHandler(_req, res, {}) {
58
- res.setHeader(
59
- import_draft.SET_COOKIE_HEADER,
60
- clearCookiesHeader([import_draft.PRERENDER_BYPASS_COOKIE, import_draft.PREVIEW_DATA_COOKIE])
61
- );
62
- return res.json({ __brand: "ClearDraftResponse" });
63
- }
64
- //# sourceMappingURL=clear-draft.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/clear-draft.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport {\n MAKESWIFT_DRAFT_DATA_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SET_COOKIE_HEADER,\n cookieSettingOptions,\n} from './utils/draft'\nimport { serialize as serializeCookie } from 'cookie'\n\nfunction clearCookiesHeader(cookieNames: string[]): string {\n const headers = new Headers()\n\n cookieNames.forEach(name => {\n headers.append(\n SET_COOKIE_HEADER,\n serializeCookie(name, '', { ...cookieSettingOptions, expires: new Date(0) }),\n )\n })\n\n const setCookieHeader = headers.get(SET_COOKIE_HEADER)\n\n if (setCookieHeader == null) {\n throw new Error(\n `Could not generate set-cookie header to clear cookies: ${cookieNames.join(', ')}`,\n )\n }\n\n return setCookieHeader\n}\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype ClearDraftError = string\n\ntype Response = { __brand: 'ClearDraftResponse' }\n\nexport type ClearDraftResponse = ClearDraftError | Response\n\ntype ClearDraftHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<ClearDraftResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function clearDraftHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<ClearDraftResponse>>\nexport default async function clearDraftHandler(\n req: NextApiRequest,\n res: NextApiResponse<ClearDraftResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function clearDraftHandler(\n ...args: ClearDraftHandlerArgs\n): Promise<NextResponse<ClearDraftResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => clearDraftRouteHandler(...args))\n .with(apiRoutePattern, args => clearDraftApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function clearDraftRouteHandler(\n _request: NextRequest,\n _context: Context,\n {}: { apiKey: string },\n): Promise<NextResponse<ClearDraftResponse>> {\n const headers = new Headers()\n\n headers.append(\n SET_COOKIE_HEADER,\n clearCookiesHeader([PRERENDER_BYPASS_COOKIE, MAKESWIFT_DRAFT_DATA_COOKIE]),\n )\n\n return NextResponse.json({ __brand: 'ClearDraftResponse' }, { headers })\n}\n\nasync function clearDraftApiRouteHandler(\n _req: NextApiRequest,\n res: NextApiResponse<ClearDraftResponse>,\n {}: { apiKey: string },\n): Promise<void> {\n res.setHeader(\n SET_COOKIE_HEADER,\n clearCookiesHeader([PRERENDER_BYPASS_COOKIE, PREVIEW_DATA_COOKIE]),\n )\n\n return res.json({ __brand: 'ClearDraftResponse' })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AACzB,mBAMO;AACP,oBAA6C;AAE7C,SAAS,mBAAmB,aAA+B;AACzD,QAAM,UAAU,IAAI,QAAQ;AAE5B,cAAY,QAAQ,UAAQ;AAC1B,YAAQ;AAAA,MACN;AAAA,UACA,cAAAA,WAAgB,MAAM,IAAI,EAAE,GAAG,mCAAsB,SAAS,oBAAI,KAAK,CAAC,EAAE,CAAC;AAAA,IAC7E;AAAA,EACF,CAAC;AAED,QAAM,kBAAkB,QAAQ,IAAI,8BAAiB;AAErD,MAAI,mBAAmB,MAAM;AAC3B,UAAM,IAAI;AAAA,MACR,0DAA0D,YAAY,KAAK,IAAI,CAAC;AAAA,IAClF;AAAA,EACF;AAEA,SAAO;AACT;AAcA,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,qBACF,MAC+C;AAClD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAAC,UAAQ,uBAAuB,GAAGA,KAAI,CAAC,EACjE,KAAK,iBAAiB,CAAAA,UAAQ,0BAA0B,GAAGA,KAAI,CAAC,EAChE,WAAW;AAChB;AAEA,eAAe,uBACb,UACA,UACA,CAAC,GAC0C;AAC3C,QAAM,UAAU,IAAI,QAAQ;AAE5B,UAAQ;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC,sCAAyB,wCAA2B,CAAC;AAAA,EAC3E;AAEA,SAAO,2BAAa,KAAK,EAAE,SAAS,qBAAqB,GAAG,EAAE,QAAQ,CAAC;AACzE;AAEA,eAAe,0BACb,MACA,KACA,CAAC,GACc;AACf,MAAI;AAAA,IACF;AAAA,IACA,mBAAmB,CAAC,sCAAyB,gCAAmB,CAAC;AAAA,EACnE;AAEA,SAAO,IAAI,KAAK,EAAE,SAAS,qBAAqB,CAAC;AACnD;","names":["serializeCookie","args"]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var element_tree_exports = {};
20
- __export(element_tree_exports, {
21
- default: () => elementTree
22
- });
23
- module.exports = __toCommonJS(element_tree_exports);
24
- var import_server = require("next/server");
25
- var import_ts_pattern = require("ts-pattern");
26
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
27
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
28
- async function elementTree(...args) {
29
- const [, , runtime] = args;
30
- const body = await (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.json()).with(apiRoutePattern, ([req]) => req.body).exhaustive();
31
- const elementTree2 = body.elementTree;
32
- const replacementContext = body.replacementContext;
33
- if (elementTree2 == null) {
34
- const status = 400;
35
- const body2 = { message: "elementTree must be defined" };
36
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
37
- }
38
- if (replacementContext == null) {
39
- const status = 400;
40
- const body2 = { message: "replacementContext must be defined" };
41
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
42
- }
43
- const generatedElementTree = runtime.copyElementTree(elementTree2, replacementContext);
44
- const response = { elementTree: generatedElementTree };
45
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(response)).with(apiRoutePattern, ([, res]) => res.json(response)).exhaustive();
46
- }
47
- //# sourceMappingURL=element-tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { ReactRuntime } from '../../../react'\nimport { Element } from '../../../state/react-page'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype ElementTreeResult = { elementTree: Element }\n\ntype ElementTreeError = { message: string }\n\nexport type ElementTreeResponse = ElementTreeResult | ElementTreeError\n\ntype ElementTreeHandlerArgs =\n | [request: NextRequest, context: Context, runtime: ReactRuntime]\n | [req: NextApiRequest, res: NextApiResponse<ElementTreeResponse>, runtime: ReactRuntime]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function elementTree(\n request: NextRequest,\n context: Context,\n runtime: ReactRuntime,\n): Promise<NextResponse<ElementTreeResponse>>\nexport default async function elementTree(\n req: NextApiRequest,\n res: NextApiResponse<ElementTreeResponse>,\n runtime: ReactRuntime,\n): Promise<void>\nexport default async function elementTree(\n ...args: ElementTreeHandlerArgs\n): Promise<NextResponse<ElementTreeResponse> | void> {\n const [, , runtime] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n const elementTree = body.elementTree\n const replacementContext = body.replacementContext\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n if (replacementContext == null) {\n const status = 400\n const body = { message: 'replacementContext must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const generatedElementTree = runtime.copyElementTree(elementTree, replacementContext)\n\n const response = { elementTree: generatedElementTree }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(response))\n .with(apiRoutePattern, ([, res]) => res.json(response))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAczB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,eACF,MACgD;AACnD,QAAM,CAAC,EAAE,EAAE,OAAO,IAAI;AAEtB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AACd,QAAMA,eAAc,KAAK;AACzB,QAAM,qBAAqB,KAAK;AAEhC,MAAIA,gBAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMC,QAAO,EAAE,SAAS,8BAA8B;AAEtD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI,sBAAsB,MAAM;AAC9B,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,qCAAqC;AAE7D,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,uBAAuB,QAAQ,gBAAgBD,cAAa,kBAAkB;AAEpF,QAAM,WAAW,EAAE,aAAa,qBAAqB;AAErD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,QAAQ,CAAC,EAC3D,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,QAAQ,CAAC,EACrD,WAAW;AAChB;","names":["elementTree","body"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/fonts.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype FontVariant = { weight: string; style: 'italic' | 'normal'; src?: string }\n\nexport type Font = {\n family: string\n label?: string\n variants: FontVariant[]\n}\n\ntype Fonts = Font[]\n\nexport type GetFonts = () => Fonts | Promise<Fonts>\n\nexport type FontsResponse = Fonts\n\ntype FontsHandlerArgs =\n | [request: NextRequest, context: Context, params: { getFonts?: GetFonts }]\n | [req: NextApiRequest, res: NextApiResponse<FontsResponse>, params: { getFonts?: GetFonts }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function fonts(\n request: NextRequest,\n context: Context,\n { getFonts }: { getFonts?: GetFonts },\n): Promise<NextResponse<FontsResponse>>\nexport default async function fonts(\n _req: NextApiRequest,\n res: NextApiResponse<FontsResponse>,\n { getFonts }: { getFonts?: GetFonts },\n): Promise<void>\nexport default async function fonts(\n ...args: FontsHandlerArgs\n): Promise<NextResponse<FontsResponse> | void> {\n const [, , { getFonts }] = args\n\n const fonts = (await getFonts?.()) ?? []\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(fonts))\n .with(apiRoutePattern, ([, res]) => res.json(fonts))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AAsBzB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,SACF,MAC0C;AAC7C,QAAM,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI;AAE3B,QAAMA,SAAS,MAAM,WAAW,KAAM,CAAC;AAEvC,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,MAAK,CAAC,EACxD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAKA,MAAK,CAAC,EAClD,WAAW;AAChB;","names":["fonts"]}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var manifest_exports = {};
20
- __export(manifest_exports, {
21
- default: () => handler
22
- });
23
- module.exports = __toCommonJS(manifest_exports);
24
- var import_server = require("next/server");
25
- var import_ts_pattern = require("ts-pattern");
26
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
27
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
28
- async function handler(...args) {
29
- const [, , { apiKey }] = args;
30
- const secret = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get("secret")).with(apiRoutePattern, ([req]) => req.query.secret).exhaustive();
31
- if (secret !== apiKey) {
32
- const status = 401;
33
- const body2 = { message: "Unauthorized" };
34
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
35
- }
36
- const supportsPreviewMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => false).with(apiRoutePattern, () => true).exhaustive();
37
- const supportsDraftMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
38
- const supportsWebhook = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
39
- const body = {
40
- version: "0.24.9-canary.0",
41
- previewMode: supportsPreviewMode,
42
- draftMode: supportsDraftMode,
43
- interactionMode: true,
44
- clientSideNavigation: false,
45
- elementFromPoint: false,
46
- customBreakpoints: true,
47
- siteVersions: true,
48
- unstable_siteVersions: true,
49
- localizedPageSSR: true,
50
- webhook: supportsWebhook,
51
- localizedPagesOnlineByDefault: true
52
- };
53
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body)).with(apiRoutePattern, ([, res]) => res.json(body)).exhaustive();
54
- }
55
- //# sourceMappingURL=manifest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/manifest.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\nexport type Manifest = {\n version: string\n previewMode: boolean\n interactionMode: boolean\n clientSideNavigation: boolean\n elementFromPoint: boolean\n customBreakpoints: boolean\n siteVersions: boolean\n unstable_siteVersions: boolean\n localizedPageSSR: boolean\n webhook: boolean\n localizedPagesOnlineByDefault: boolean\n}\n\ntype ManifestError = { message: string }\n\nexport type ManifestResponse = Manifest | ManifestError\n\ntype ManifestHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<ManifestResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function handler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<ManifestResponse>>\nexport default async function handler(\n req: NextApiRequest,\n res: NextApiResponse<ManifestResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function handler(\n ...args: ManifestHandlerArgs\n): Promise<NextResponse<ManifestResponse> | void> {\n const [, , { apiKey }] = args\n\n const secret = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n\n if (secret !== apiKey) {\n const status = 401\n const body = { message: 'Unauthorized' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const supportsPreviewMode = match(args)\n .with(routeHandlerPattern, () => false)\n .with(apiRoutePattern, () => true)\n .exhaustive()\n\n const supportsDraftMode = match(args)\n .with(routeHandlerPattern, () => true)\n .with(apiRoutePattern, () => false)\n .exhaustive()\n\n const supportsWebhook = match(args)\n .with(routeHandlerPattern, () => true)\n .with(apiRoutePattern, () => false)\n .exhaustive()\n\n const body = {\n version: PACKAGE_VERSION,\n previewMode: supportsPreviewMode,\n draftMode: supportsDraftMode,\n interactionMode: true,\n clientSideNavigation: false,\n elementFromPoint: false,\n customBreakpoints: true,\n siteVersions: true,\n unstable_siteVersions: true,\n localizedPageSSR: true,\n webhook: supportsWebhook,\n localizedPagesOnlineByDefault: true,\n }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AA0BzB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,WACF,MAC6C;AAChD,QAAM,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI;AAEzB,QAAM,aAAS,yBAAM,IAAI,EACtB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAEd,MAAI,WAAW,QAAQ;AACrB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,eAAe;AAEvC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,0BAAsB,yBAAM,IAAI,EACnC,KAAK,qBAAqB,MAAM,KAAK,EACrC,KAAK,iBAAiB,MAAM,IAAI,EAChC,WAAW;AAEd,QAAM,wBAAoB,yBAAM,IAAI,EACjC,KAAK,qBAAqB,MAAM,IAAI,EACpC,KAAK,iBAAiB,MAAM,KAAK,EACjC,WAAW;AAEd,QAAM,sBAAkB,yBAAM,IAAI,EAC/B,KAAK,qBAAqB,MAAM,IAAI,EACpC,KAAK,iBAAiB,MAAM,KAAK,EACjC,WAAW;AAEd,QAAM,OAAO;AAAA,IACX,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,sBAAsB;AAAA,IACtB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,+BAA+B;AAAA,EACjC;AAEA,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,IAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,IAAI,CAAC,EACjD,WAAW;AAChB;","names":["body"]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var merge_translated_data_exports = {};
20
- __export(merge_translated_data_exports, {
21
- default: () => mergeTranslatedData
22
- });
23
- module.exports = __toCommonJS(merge_translated_data_exports);
24
- var import_server = require("next/server");
25
- var import_ts_pattern = require("ts-pattern");
26
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
27
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
28
- async function mergeTranslatedData(...args) {
29
- const [, , client] = args;
30
- const body = await (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.json()).with(apiRoutePattern, ([req]) => req.body).exhaustive();
31
- const translatedData = body.translatedData;
32
- const elementTree = body.elementTree;
33
- if (translatedData == null) {
34
- const status = 400;
35
- const body2 = { message: "translatedData must be defined" };
36
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
37
- }
38
- if (elementTree == null) {
39
- const status = 400;
40
- const body2 = { message: "elementTree must be defined" };
41
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
42
- }
43
- const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData);
44
- const responseBody = { elementTree: translatedElementTree };
45
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(responseBody)).with(apiRoutePattern, ([, res]) => res.json(responseBody)).exhaustive();
46
- }
47
- //# sourceMappingURL=merge-translated-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Element } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype TranslatedDataResult = { elementTree: Element }\n\ntype TranslatedDataError = { message: string }\n\nexport type TranslatedDataResponse = TranslatedDataResult | TranslatedDataError\n\ntype MergeTranslatedDataHandlerArgs =\n | [request: NextRequest, context: Context, client: Makeswift]\n | [req: NextApiRequest, res: NextApiResponse<TranslatedDataResponse>, client: Makeswift]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function mergeTranslatedData(\n request: NextRequest,\n context: Context,\n client: Makeswift,\n): Promise<NextResponse<TranslatedDataResponse>>\nexport default async function mergeTranslatedData(\n req: NextApiRequest,\n res: NextApiResponse<TranslatedDataResponse>,\n client: Makeswift,\n): Promise<void>\nexport default async function mergeTranslatedData(\n ...args: MergeTranslatedDataHandlerArgs\n): Promise<NextResponse<TranslatedDataResponse> | void> {\n const [, , client] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n\n const translatedData = body.translatedData\n const elementTree = body.elementTree\n\n if (translatedData == null) {\n const status = 400\n const body = { message: 'translatedData must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData)\n\n const responseBody = { elementTree: translatedElementTree }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(responseBody))\n .with(apiRoutePattern, ([, res]) => res.json(responseBody))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAczB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,uBACF,MACmD;AACtD,QAAM,CAAC,EAAE,EAAE,MAAM,IAAI;AAErB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AAEd,QAAM,iBAAiB,KAAK;AAC5B,QAAM,cAAc,KAAK;AAEzB,MAAI,kBAAkB,MAAM;AAC1B,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,iCAAiC;AAEzD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI,eAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,8BAA8B;AAEtD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,wBAAwB,OAAO,oBAAoB,aAAa,cAAc;AAEpF,QAAM,eAAe,EAAE,aAAa,sBAAsB;AAE1D,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,YAAY,CAAC,EAC/D,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,YAAY,CAAC,EACzD,WAAW;AAChB;","names":["body"]}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var revalidate_exports = {};
30
- __export(revalidate_exports, {
31
- revalidate: () => revalidate
32
- });
33
- module.exports = __toCommonJS(revalidate_exports);
34
- var import_isErrorWithMessage = __toESM(require("../../../utils/isErrorWithMessage"));
35
- var import_server = require("next/server");
36
- var import_ts_pattern = require("ts-pattern");
37
- var import_cache = require("next/cache");
38
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
39
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
40
- async function revalidate(...args) {
41
- const [, , { apiKey }] = args;
42
- const secret = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get("secret")).with(apiRoutePattern, ([req]) => req.query.secret).exhaustive();
43
- if (secret !== apiKey) {
44
- const body = { message: "Unauthorized" };
45
- const status = 401;
46
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body)).exhaustive();
47
- }
48
- const path = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get("path")).with(apiRoutePattern, ([req]) => req.query.path).exhaustive();
49
- if (typeof path !== "string") {
50
- const status = 400;
51
- const body = { message: "Bad Request" };
52
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body)).exhaustive();
53
- }
54
- const revalidate2 = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_cache.revalidatePath).with(apiRoutePattern, ([, res]) => res.revalidate).exhaustive();
55
- try {
56
- await revalidate2(path);
57
- const body = { revalidated: true };
58
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body)).with(apiRoutePattern, ([, res]) => res.json(body)).exhaustive();
59
- } catch (error) {
60
- if ((0, import_isErrorWithMessage.default)(error)) {
61
- const status2 = 500;
62
- const body2 = { message: error.message };
63
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status: status2 })).with(apiRoutePattern, ([, res]) => res.status(status2).json(body2)).exhaustive();
64
- }
65
- const status = 500;
66
- const body = { message: "Error Revalidating" };
67
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body)).exhaustive();
68
- }
69
- }
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- revalidate
73
- });
74
- //# sourceMappingURL=revalidate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/revalidate.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport isErrorWithMessage from '../../../utils/isErrorWithMessage'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { revalidatePath } from 'next/cache'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype RevalidationResult = { revalidated: boolean }\n\ntype RevalidationError = { message: string }\n\nexport type RevalidationResponse = RevalidationResult | RevalidationError\n\ntype RevalidateHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RevalidationResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport async function revalidate(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RevalidationResponse>>\nexport async function revalidate(\n req: NextApiRequest,\n res: NextApiResponse<RevalidationResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport async function revalidate(\n ...args: RevalidateHandlerArgs\n): Promise<NextResponse<RevalidationResponse> | void> {\n const [, , { apiKey }] = args\n\n const secret = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n\n if (secret !== apiKey) {\n const body = { message: 'Unauthorized' }\n const status = 401\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const path = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('path'))\n .with(apiRoutePattern, ([req]) => req.query.path)\n .exhaustive()\n\n if (typeof path !== 'string') {\n const status = 400\n const body = { message: 'Bad Request' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const revalidate = match(args)\n .with(routeHandlerPattern, () => revalidatePath)\n .with(apiRoutePattern, ([, res]) => res.revalidate)\n .exhaustive()\n\n try {\n await revalidate(path)\n\n const body = { revalidated: true }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n } catch (error) {\n if (isErrorWithMessage(error)) {\n const status = 500\n const body = { message: error.message }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const status = 500\n const body = { message: 'Error Revalidating' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAA+B;AAC/B,oBAA0C;AAC1C,wBAAyB;AACzB,mBAA+B;AAc/B,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAsB,cACjB,MACiD;AACpD,QAAM,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI;AAEzB,QAAM,aAAS,yBAAM,IAAI,EACtB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAEd,MAAI,WAAW,QAAQ;AACrB,UAAM,OAAO,EAAE,SAAS,eAAe;AACvC,UAAM,SAAS;AAEf,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,WAAO,yBAAM,IAAI,EACpB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,MAAM,CAAC,EACjF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,IAAI,EAC/C,WAAW;AAEd,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,SAAS;AACf,UAAM,OAAO,EAAE,SAAS,cAAc;AAEtC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAMA,kBAAa,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,MAAM,2BAAc,EAC9C,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,UAAU,EACjD,WAAW;AAEd,MAAI;AACF,UAAMA,YAAW,IAAI;AAErB,UAAM,OAAO,EAAE,aAAa,KAAK;AAEjC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,IAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,IAAI,CAAC,EACjD,WAAW;AAAA,EAChB,SAAS,OAAO;AACd,YAAI,0BAAAC,SAAmB,KAAK,GAAG;AAC7B,YAAMC,UAAS;AACf,YAAMC,QAAO,EAAE,SAAS,MAAM,QAAQ;AAEtC,iBAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,QAAAD,QAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAOA,OAAM,EAAE,KAAKC,KAAI,CAAC,EAChE,WAAW;AAAA,IAChB;AAEA,UAAM,SAAS;AACf,UAAM,OAAO,EAAE,SAAS,qBAAqB;AAE7C,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AACF;","names":["revalidate","isErrorWithMessage","status","body"]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var translatable_data_exports = {};
20
- __export(translatable_data_exports, {
21
- default: () => translatableData
22
- });
23
- module.exports = __toCommonJS(translatable_data_exports);
24
- var import_server = require("next/server");
25
- var import_ts_pattern = require("ts-pattern");
26
- const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any, import_ts_pattern.P.any];
27
- const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any, import_ts_pattern.P.any];
28
- async function translatableData(...args) {
29
- const [, , client] = args;
30
- const body = await (0, import_ts_pattern.match)(args).with(routeHandlerPattern, ([request]) => request.json()).with(apiRoutePattern, ([req]) => req.body).exhaustive();
31
- const elementTree = body.elementTree;
32
- if (elementTree == null) {
33
- const status = 400;
34
- const body2 = { message: "elementTree must be defined." };
35
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
36
- }
37
- try {
38
- let translatableData2 = client.getTranslatableData(elementTree);
39
- const body2 = { translatableData: translatableData2 };
40
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2)).with(apiRoutePattern, ([, res]) => res.json(body2)).exhaustive();
41
- } catch (error) {
42
- const status = 500;
43
- const body2 = { message: "Failed to get traslatable data." };
44
- return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => import_server.NextResponse.json(body2, { status })).with(apiRoutePattern, ([, res]) => res.status(status).json(body2)).exhaustive();
45
- }
46
- }
47
- //# sourceMappingURL=translatable-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/next/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Data } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype TranslatableDataResult = { translatableData: Record<string, Data> }\n\ntype TranslatableDataError = { message: string }\n\nexport type TranslatableDataResponse = TranslatableDataResult | TranslatableDataError\n\ntype TranslatableDataHandlerArgs =\n | [request: NextRequest, context: Context, client: Makeswift]\n | [req: NextApiRequest, res: NextApiResponse<TranslatableDataResponse>, client: Makeswift]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function translatableData(\n request: NextRequest,\n context: Context,\n client: Makeswift,\n): Promise<NextResponse<TranslatableDataResponse>>\nexport default async function translatableData(\n req: NextApiRequest,\n res: NextApiResponse<TranslatableDataResponse>,\n client: Makeswift,\n): Promise<void>\nexport default async function translatableData(\n ...args: TranslatableDataHandlerArgs\n): Promise<NextResponse<TranslatableDataResponse> | void> {\n const [, , client] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n const elementTree = body.elementTree\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined.' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n try {\n let translatableData = client.getTranslatableData(elementTree)\n\n const body = { translatableData }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n } catch (error) {\n const status = 500\n const body = { message: 'Failed to get traslatable data.' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAczB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,oBACF,MACqD;AACxD,QAAM,CAAC,EAAE,EAAE,MAAM,IAAI;AAErB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AACd,QAAM,cAAc,KAAK;AAEzB,MAAI,eAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,+BAA+B;AAEvD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI;AACF,QAAIC,oBAAmB,OAAO,oBAAoB,WAAW;AAE7D,UAAMD,QAAO,EAAE,kBAAAC,kBAAiB;AAEhC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKD,KAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAKA,KAAI,CAAC,EACjD,WAAW;AAAA,EAChB,SAAS,OAAO;AACd,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,kCAAkC;AAE1D,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AACF;","names":["body","translatableData"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/next/api-handler/handlers/utils/draft.ts"],"sourcesContent":["export const PRERENDER_BYPASS_COOKIE = '__prerender_bypass'\nexport const PREVIEW_DATA_COOKIE = '__next_preview_data'\n\nexport const MAKESWIFT_DRAFT_DATA_COOKIE = 'x-makeswift-draft-data'\nexport const SET_COOKIE_HEADER = 'set-cookie'\n\nexport const SearchParams = {\n DraftMode: 'x-makeswift-draft-mode',\n PreviewMode: 'x-makeswift-preview-mode',\n} as const\n\nexport const cookieSettingOptions = {\n path: '/',\n sameSite: 'none',\n secure: true,\n httpOnly: true,\n partitioned: true,\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAE5B,MAAM,8BAA8B;AACpC,MAAM,oBAAoB;AAE1B,MAAM,eAAe;AAAA,EAC1B,WAAW;AAAA,EACX,aAAa;AACf;AAEO,MAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,aAAa;AACf;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/next/api-handler/handlers/webhook/index.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { handleSitePublished } from './site-published'\nimport {\n OnPublish,\n sitePublishedWebhookPayloadSchema,\n WebhookEventType,\n WebhookPayloadSchema,\n WebhookResponseBody,\n} from './types'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype WebhookParams = {\n apiKey: string\n events?: { onPublish?: OnPublish }\n}\n\nexport type WebhookHandlerArgs =\n | [request: NextRequest, context: Context, params: WebhookParams]\n | [req: NextApiRequest, res: NextApiResponse<WebhookResponseBody>, params: WebhookParams]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nfunction getSecret(args: WebhookHandlerArgs) {\n return match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n}\n\nfunction getRequestBody(args: WebhookHandlerArgs) {\n return match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n}\n\nfunction respond(args: WebhookHandlerArgs, response: WebhookResponseBody, status?: number) {\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(response, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status ?? 200).json(response))\n .exhaustive()\n}\n\nexport default async function handler(\n request: NextRequest,\n context: Context,\n { apiKey, events }: WebhookParams,\n): Promise<NextResponse<WebhookResponseBody>>\nexport default async function handler(\n req: NextApiRequest,\n res: NextApiResponse<WebhookResponseBody>,\n { apiKey, events }: WebhookParams,\n): Promise<void>\nexport default async function handler(\n ...args: WebhookHandlerArgs\n): Promise<NextResponse<WebhookResponseBody> | void> {\n const [, , { apiKey, events }] = args\n const secret = getSecret(args)\n\n if (secret !== apiKey) return respond(args, { message: 'Unauthorized' }, 401)\n\n let payload: WebhookPayloadSchema\n\n try {\n const body = await getRequestBody(args)\n payload = sitePublishedWebhookPayloadSchema.parse(body)\n } catch (error) {\n console.error(error)\n return respond(args, { message: 'Invalid request body' }, 400)\n }\n\n const result = await match(payload.type)\n .with(WebhookEventType.SITE_PUBLISHED, () =>\n handleSitePublished(payload, { onPublish: events?.onPublish }),\n )\n .exhaustive()\n\n return respond(args, result.body, result.status)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AACzB,4BAAoC;AACpC,mBAMO;AAaP,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAE5C,SAAS,UAAU,MAA0B;AAC3C,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAChB;AAEA,SAAS,eAAe,MAA0B;AAChD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AAChB;AAEA,SAAS,QAAQ,MAA0B,UAA+B,QAAiB;AACzF,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,UAAU,EAAE,OAAO,CAAC,CAAC,EACvE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,UAAU,GAAG,EAAE,KAAK,QAAQ,CAAC,EAC3E,WAAW;AAChB;AAYA,eAAO,WACF,MACgD;AACnD,QAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,OAAO,CAAC,IAAI;AACjC,QAAM,SAAS,UAAU,IAAI;AAE7B,MAAI,WAAW;AAAQ,WAAO,QAAQ,MAAM,EAAE,SAAS,eAAe,GAAG,GAAG;AAE5E,MAAI;AAEJ,MAAI;AACF,UAAM,OAAO,MAAM,eAAe,IAAI;AACtC,cAAU,+CAAkC,MAAM,IAAI;AAAA,EACxD,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO,QAAQ,MAAM,EAAE,SAAS,uBAAuB,GAAG,GAAG;AAAA,EAC/D;AAEA,QAAM,SAAS,UAAM,yBAAM,QAAQ,IAAI,EACpC;AAAA,IAAK,8BAAiB;AAAA,IAAgB,UACrC,2CAAoB,SAAS,EAAE,WAAW,QAAQ,UAAU,CAAC;AAAA,EAC/D,EACC,WAAW;AAEd,SAAO,QAAQ,MAAM,OAAO,MAAM,OAAO,MAAM;AACjD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/next/api-handler/handlers/webhook/site-published.ts"],"sourcesContent":["import { revalidateTag } from 'next/cache'\nimport {\n type OnPublish,\n type SitePublishedWebhookPayload,\n type WebhookHandlerResult,\n} from './types'\n\nimport { MAKESWIFT_CACHE_TAG } from '../../../cache'\n\ntype SitePublishedParams = {\n onPublish?: OnPublish\n}\n\nexport async function handleSitePublished(\n _payload: SitePublishedWebhookPayload,\n { onPublish }: SitePublishedParams,\n): Promise<WebhookHandlerResult> {\n revalidateTag(MAKESWIFT_CACHE_TAG)\n\n try {\n await onPublish?.()\n } catch (error) {\n // log and ignore any error in user-provided onPublish\n console.error(\"Unhandled exception in the 'onPublish' callback:\", error)\n }\n\n return { body: { success: true }, status: 200 }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAO9B,IAAAA,gBAAoC;AAMpC,eAAsB,oBACpB,UACA,EAAE,UAAU,GACmB;AAC/B,kCAAc,iCAAmB;AAEjC,MAAI;AACF,UAAM,YAAY;AAAA,EACpB,SAAS,OAAO;AAEd,YAAQ,MAAM,oDAAoD,KAAK;AAAA,EACzE;AAEA,SAAO,EAAE,MAAM,EAAE,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD;","names":["import_cache"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/next/api-handler/handlers/webhook/types.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const WebhookEventType = {\n SITE_PUBLISHED: 'site.published',\n} as const\n\nexport const sitePublishedWebhookPayloadSchema = z.object({\n type: z.literal(WebhookEventType.SITE_PUBLISHED),\n data: z.object({\n siteId: z.string().uuid(),\n publish: z.object({\n from: z.string().uuid().nullable(),\n to: z.string().uuid(),\n }),\n at: z.number(),\n }),\n})\n\nexport type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>\n\nconst webhookPayloadSchema = sitePublishedWebhookPayloadSchema\n\nexport type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>\n\ntype WebhookSuccessBody = { success: true }\n\ntype WebhookErrorBody = { message: string }\n\nexport type WebhookResponseBody = WebhookSuccessBody | WebhookErrorBody\n\nexport type WebhookHandlerResult = {\n body: WebhookResponseBody\n status: 200\n}\n\nexport type OnPublish = () => void | Promise<void>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAEX,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAClB;AAEO,MAAM,oCAAoC,aAAE,OAAO;AAAA,EACxD,MAAM,aAAE,QAAQ,iBAAiB,cAAc;AAAA,EAC/C,MAAM,aAAE,OAAO;AAAA,IACb,QAAQ,aAAE,OAAO,EAAE,KAAK;AAAA,IACxB,SAAS,aAAE,OAAO;AAAA,MAChB,MAAM,aAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,MACjC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,IACtB,CAAC;AAAA,IACD,IAAI,aAAE,OAAO;AAAA,EACf,CAAC;AACH,CAAC;AAID,MAAM,uBAAuB;","names":[]}