@sitecore-content-sdk/core 1.3.0-canary.9 → 1.4.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 (342) hide show
  1. package/README.md +7 -7
  2. package/dist/cjs/cache-client.js +55 -54
  3. package/dist/cjs/client/constants.js +7 -7
  4. package/dist/cjs/client/edge-proxy.js +24 -22
  5. package/dist/cjs/client/index.js +15 -15
  6. package/dist/cjs/client/models.js +2 -2
  7. package/dist/cjs/client/sitecore-client.js +421 -419
  8. package/dist/cjs/client/utils.js +47 -46
  9. package/dist/cjs/config/define-config.js +194 -193
  10. package/dist/cjs/config/index.js +7 -7
  11. package/dist/cjs/config/models.js +12 -11
  12. package/dist/cjs/config-cli/define-cli-config.js +23 -22
  13. package/dist/cjs/config-cli/index.js +7 -7
  14. package/dist/cjs/config-cli/models.js +8 -7
  15. package/dist/cjs/constants.js +49 -17
  16. package/dist/cjs/debug.js +48 -46
  17. package/dist/cjs/editing/codegen/index.js +14 -9
  18. package/dist/cjs/editing/codegen/preview.js +277 -193
  19. package/dist/cjs/editing/component-layout-service.js +62 -61
  20. package/dist/cjs/editing/design-library.js +183 -126
  21. package/dist/cjs/editing/editing-service.js +75 -74
  22. package/dist/cjs/editing/index.js +33 -27
  23. package/dist/cjs/editing/metadata.js +42 -42
  24. package/dist/cjs/editing/models.js +44 -38
  25. package/dist/cjs/editing/utils.js +108 -90
  26. package/dist/cjs/form/form.js +81 -78
  27. package/dist/cjs/form/index.js +7 -7
  28. package/dist/cjs/graphql-request-client.js +108 -107
  29. package/dist/cjs/i18n/dictionary-service.js +122 -121
  30. package/dist/cjs/i18n/index.js +7 -7
  31. package/dist/cjs/i18n/utils.js +16 -15
  32. package/dist/cjs/index.js +60 -60
  33. package/dist/cjs/layout/content-styles.js +72 -71
  34. package/dist/cjs/layout/index.js +24 -24
  35. package/dist/cjs/layout/layout-service.js +62 -57
  36. package/dist/cjs/layout/models.js +39 -34
  37. package/dist/cjs/layout/themes.js +76 -75
  38. package/dist/cjs/layout/utils.js +117 -110
  39. package/dist/cjs/media/index.js +38 -38
  40. package/dist/cjs/media/media-api.js +100 -96
  41. package/dist/cjs/models.js +2 -2
  42. package/dist/cjs/native-fetcher.js +194 -179
  43. package/dist/cjs/personalize/index.js +15 -15
  44. package/dist/cjs/personalize/layout-personalizer.js +98 -97
  45. package/dist/cjs/personalize/personalize-service.js +98 -94
  46. package/dist/cjs/personalize/utils.js +143 -136
  47. package/dist/cjs/retries.js +43 -42
  48. package/dist/cjs/site/error-pages-service.js +65 -64
  49. package/dist/cjs/site/index.js +26 -26
  50. package/dist/cjs/site/models.js +2 -2
  51. package/dist/cjs/site/redirects-service.js +94 -81
  52. package/dist/cjs/site/robots-service.js +66 -65
  53. package/dist/cjs/site/site-resolver.js +73 -72
  54. package/dist/cjs/site/siteinfo-service.js +84 -80
  55. package/dist/cjs/site/sitemap-xml-service.js +84 -83
  56. package/dist/cjs/site/sitepath-service.js +165 -164
  57. package/dist/cjs/site/utils.js +55 -47
  58. package/dist/cjs/sitecore-service-base.js +36 -36
  59. package/dist/cjs/tools/auth/flow.js +65 -64
  60. package/dist/cjs/tools/auth/index.js +5 -5
  61. package/dist/cjs/tools/auth/models.js +2 -2
  62. package/dist/cjs/tools/auth/tenant-store.js +38 -38
  63. package/dist/cjs/tools/codegen/component-generation.js +52 -50
  64. package/dist/cjs/tools/codegen/extract-files.js +105 -107
  65. package/dist/cjs/tools/codegen/import-map.js +401 -349
  66. package/dist/cjs/tools/codegen/utils.js +418 -418
  67. package/dist/cjs/tools/generate-map.js +2 -2
  68. package/dist/cjs/tools/generateMetadata.js +36 -35
  69. package/dist/cjs/tools/generateSites.js +59 -58
  70. package/dist/cjs/tools/index.js +75 -73
  71. package/dist/cjs/tools/scaffold.js +60 -59
  72. package/dist/cjs/tools/templating/components.js +96 -266
  73. package/dist/cjs/tools/templating/index.js +11 -14
  74. package/dist/cjs/tools/templating/plugins.js +80 -78
  75. package/dist/cjs/tools/templating/utils.js +67 -66
  76. package/dist/cjs/utils/ensurePath.js +20 -20
  77. package/dist/cjs/utils/env.js +28 -27
  78. package/dist/cjs/utils/globalCache.js +55 -0
  79. package/dist/cjs/utils/index.js +26 -21
  80. package/dist/cjs/utils/is-server.js +11 -10
  81. package/dist/cjs/utils/normalize-url.js +5 -5
  82. package/dist/cjs/utils/timeout-promise.js +31 -31
  83. package/dist/cjs/utils/utils.js +254 -229
  84. package/dist/esm/cache-client.js +51 -50
  85. package/dist/esm/client/constants.js +4 -4
  86. package/dist/esm/client/edge-proxy.js +19 -17
  87. package/dist/esm/client/index.js +5 -5
  88. package/dist/esm/client/models.js +1 -1
  89. package/dist/esm/client/sitecore-client.js +414 -412
  90. package/dist/esm/client/utils.js +43 -42
  91. package/dist/esm/config/define-config.js +188 -187
  92. package/dist/esm/config/index.js +2 -2
  93. package/dist/esm/config/models.js +9 -8
  94. package/dist/esm/config-cli/define-cli-config.js +19 -18
  95. package/dist/esm/config-cli/index.js +2 -2
  96. package/dist/esm/config-cli/models.js +5 -4
  97. package/dist/esm/constants.js +46 -14
  98. package/dist/esm/debug.js +41 -39
  99. package/dist/esm/editing/codegen/index.js +1 -1
  100. package/dist/esm/editing/codegen/preview.js +263 -185
  101. package/dist/esm/editing/component-layout-service.js +55 -54
  102. package/dist/esm/editing/design-library.js +171 -117
  103. package/dist/esm/editing/editing-service.js +68 -67
  104. package/dist/esm/editing/index.js +6 -5
  105. package/dist/esm/editing/metadata.js +39 -39
  106. package/dist/esm/editing/models.js +41 -35
  107. package/dist/esm/editing/utils.js +98 -80
  108. package/dist/esm/form/form.js +72 -69
  109. package/dist/esm/form/index.js +1 -1
  110. package/dist/esm/graphql-request-client.js +101 -100
  111. package/dist/esm/i18n/dictionary-service.js +115 -114
  112. package/dist/esm/i18n/index.js +2 -2
  113. package/dist/esm/i18n/utils.js +13 -12
  114. package/dist/esm/index.js +13 -13
  115. package/dist/esm/layout/content-styles.js +64 -63
  116. package/dist/esm/layout/index.js +6 -6
  117. package/dist/esm/layout/layout-service.js +55 -50
  118. package/dist/esm/layout/models.js +36 -31
  119. package/dist/esm/layout/themes.js +71 -70
  120. package/dist/esm/layout/utils.js +109 -102
  121. package/dist/esm/media/index.js +2 -2
  122. package/dist/esm/media/media-api.js +90 -86
  123. package/dist/esm/models.js +1 -1
  124. package/dist/esm/native-fetcher.js +187 -172
  125. package/dist/esm/personalize/index.js +3 -3
  126. package/dist/esm/personalize/layout-personalizer.js +93 -92
  127. package/dist/esm/personalize/personalize-service.js +91 -87
  128. package/dist/esm/personalize/utils.js +135 -128
  129. package/dist/esm/retries.js +39 -38
  130. package/dist/esm/site/error-pages-service.js +58 -57
  131. package/dist/esm/site/index.js +8 -8
  132. package/dist/esm/site/models.js +1 -1
  133. package/dist/esm/site/redirects-service.js +87 -74
  134. package/dist/esm/site/robots-service.js +59 -58
  135. package/dist/esm/site/site-resolver.js +69 -68
  136. package/dist/esm/site/siteinfo-service.js +77 -73
  137. package/dist/esm/site/sitemap-xml-service.js +77 -76
  138. package/dist/esm/site/sitepath-service.js +157 -156
  139. package/dist/esm/site/utils.js +49 -41
  140. package/dist/esm/sitecore-service-base.js +29 -29
  141. package/dist/esm/tools/auth/flow.js +62 -61
  142. package/dist/esm/tools/auth/index.js +1 -1
  143. package/dist/esm/tools/auth/models.js +1 -1
  144. package/dist/esm/tools/auth/tenant-store.js +35 -35
  145. package/dist/esm/tools/codegen/component-generation.js +44 -42
  146. package/dist/esm/tools/codegen/extract-files.js +99 -101
  147. package/dist/esm/tools/codegen/import-map.js +358 -306
  148. package/dist/esm/tools/codegen/utils.js +373 -373
  149. package/dist/esm/tools/generate-map.js +1 -1
  150. package/dist/esm/tools/generateMetadata.js +29 -28
  151. package/dist/esm/tools/generateSites.js +52 -51
  152. package/dist/esm/tools/index.js +28 -27
  153. package/dist/esm/tools/scaffold.js +52 -51
  154. package/dist/esm/tools/templating/components.js +59 -223
  155. package/dist/esm/tools/templating/index.js +3 -3
  156. package/dist/esm/tools/templating/plugins.js +72 -70
  157. package/dist/esm/tools/templating/utils.js +59 -58
  158. package/dist/esm/utils/ensurePath.js +13 -13
  159. package/dist/esm/utils/env.js +24 -23
  160. package/dist/esm/utils/globalCache.js +49 -0
  161. package/dist/esm/utils/index.js +4 -3
  162. package/dist/esm/utils/is-server.js +9 -8
  163. package/dist/esm/utils/normalize-url.js +1 -1
  164. package/dist/esm/utils/timeout-promise.js +28 -28
  165. package/dist/esm/utils/utils.js +238 -213
  166. package/package.json +73 -5
  167. package/types/cache-client.d.ts +68 -64
  168. package/types/cache-client.d.ts.map +1 -0
  169. package/types/client/constants.d.ts +5 -4
  170. package/types/client/constants.d.ts.map +1 -0
  171. package/types/client/edge-proxy.d.ts +18 -15
  172. package/types/client/edge-proxy.d.ts.map +1 -0
  173. package/types/client/index.d.ts +8 -7
  174. package/types/client/index.d.ts.map +1 -0
  175. package/types/client/models.d.ts +21 -19
  176. package/types/client/models.d.ts.map +1 -0
  177. package/types/client/sitecore-client.d.ts +338 -327
  178. package/types/client/sitecore-client.d.ts.map +1 -0
  179. package/types/client/utils.d.ts +15 -9
  180. package/types/client/utils.d.ts.map +1 -0
  181. package/types/config/define-config.d.ts +20 -18
  182. package/types/config/define-config.d.ts.map +1 -0
  183. package/types/config/index.d.ts +3 -2
  184. package/types/config/index.d.ts.map +1 -0
  185. package/types/config/models.d.ts +287 -268
  186. package/types/config/models.d.ts.map +1 -0
  187. package/types/config-cli/define-cli-config.d.ts +9 -7
  188. package/types/config-cli/define-cli-config.d.ts.map +1 -0
  189. package/types/config-cli/index.d.ts +3 -2
  190. package/types/config-cli/index.d.ts.map +1 -0
  191. package/types/config-cli/models.d.ts +6 -4
  192. package/types/config-cli/models.d.ts.map +1 -0
  193. package/types/constants.d.ts +44 -11
  194. package/types/constants.d.ts.map +1 -0
  195. package/types/debug.d.ts +35 -28
  196. package/types/debug.d.ts.map +1 -0
  197. package/types/editing/codegen/index.d.ts +2 -1
  198. package/types/editing/codegen/index.d.ts.map +1 -0
  199. package/types/editing/codegen/preview.d.ts +256 -195
  200. package/types/editing/codegen/preview.d.ts.map +1 -0
  201. package/types/editing/component-layout-service.d.ts +84 -80
  202. package/types/editing/component-layout-service.d.ts.map +1 -0
  203. package/types/editing/design-library.d.ts +111 -63
  204. package/types/editing/design-library.d.ts.map +1 -0
  205. package/types/editing/editing-service.d.ts +72 -62
  206. package/types/editing/editing-service.d.ts.map +1 -0
  207. package/types/editing/index.d.ts +7 -6
  208. package/types/editing/index.d.ts.map +1 -0
  209. package/types/editing/metadata.d.ts +8 -7
  210. package/types/editing/metadata.d.ts.map +1 -0
  211. package/types/editing/models.d.ts +103 -92
  212. package/types/editing/models.d.ts.map +1 -0
  213. package/types/editing/utils.d.ts +91 -74
  214. package/types/editing/utils.d.ts.map +1 -0
  215. package/types/form/form.d.ts +25 -21
  216. package/types/form/form.d.ts.map +1 -0
  217. package/types/form/index.d.ts +2 -1
  218. package/types/form/index.d.ts.map +1 -0
  219. package/types/graphql-request-client.d.ts +112 -105
  220. package/types/graphql-request-client.d.ts.map +1 -0
  221. package/types/i18n/dictionary-service.d.ts +135 -131
  222. package/types/i18n/dictionary-service.d.ts.map +1 -0
  223. package/types/i18n/index.d.ts +3 -2
  224. package/types/i18n/index.d.ts.map +1 -0
  225. package/types/i18n/utils.d.ts +9 -7
  226. package/types/i18n/utils.d.ts.map +1 -0
  227. package/types/index.d.ts +13 -12
  228. package/types/index.d.ts.map +1 -0
  229. package/types/layout/content-styles.d.ts +20 -18
  230. package/types/layout/content-styles.d.ts.map +1 -0
  231. package/types/layout/index.d.ts +6 -5
  232. package/types/layout/index.d.ts.map +1 -0
  233. package/types/layout/layout-service.d.ts +45 -35
  234. package/types/layout/layout-service.d.ts.map +1 -0
  235. package/types/layout/models.d.ts +174 -151
  236. package/types/layout/models.d.ts.map +1 -0
  237. package/types/layout/themes.d.ts +13 -11
  238. package/types/layout/themes.d.ts.map +1 -0
  239. package/types/layout/utils.d.ts +56 -41
  240. package/types/layout/utils.d.ts.map +1 -0
  241. package/types/media/index.d.ts +3 -2
  242. package/types/media/index.d.ts.map +1 -0
  243. package/types/media/media-api.d.ts +60 -55
  244. package/types/media/media-api.d.ts.map +1 -0
  245. package/types/models.d.ts +94 -84
  246. package/types/models.d.ts.map +1 -0
  247. package/types/native-fetcher.d.ts +124 -114
  248. package/types/native-fetcher.d.ts.map +1 -0
  249. package/types/personalize/index.d.ts +4 -3
  250. package/types/personalize/index.d.ts.map +1 -0
  251. package/types/personalize/layout-personalizer.d.ts +29 -27
  252. package/types/personalize/layout-personalizer.d.ts.map +1 -0
  253. package/types/personalize/personalize-service.d.ts +90 -80
  254. package/types/personalize/personalize-service.d.ts.map +1 -0
  255. package/types/personalize/utils.d.ts +78 -69
  256. package/types/personalize/utils.d.ts.map +1 -0
  257. package/types/retries.d.ts +26 -24
  258. package/types/retries.d.ts.map +1 -0
  259. package/types/site/error-pages-service.d.ts +64 -57
  260. package/types/site/error-pages-service.d.ts.map +1 -0
  261. package/types/site/index.d.ts +10 -9
  262. package/types/site/index.d.ts.map +1 -0
  263. package/types/site/models.d.ts +23 -18
  264. package/types/site/models.d.ts.map +1 -0
  265. package/types/site/redirects-service.d.ts +92 -69
  266. package/types/site/redirects-service.d.ts.map +1 -0
  267. package/types/site/robots-service.d.ts +57 -50
  268. package/types/site/robots-service.d.ts.map +1 -0
  269. package/types/site/site-resolver.d.ts +28 -26
  270. package/types/site/site-resolver.d.ts.map +1 -0
  271. package/types/site/siteinfo-service.d.ts +65 -52
  272. package/types/site/siteinfo-service.d.ts.map +1 -0
  273. package/types/site/sitemap-xml-service.d.ts +63 -56
  274. package/types/site/sitemap-xml-service.d.ts.map +1 -0
  275. package/types/site/sitepath-service.d.ts +137 -134
  276. package/types/site/sitepath-service.d.ts.map +1 -0
  277. package/types/site/utils.d.ts +41 -28
  278. package/types/site/utils.d.ts.map +1 -0
  279. package/types/sitecore-service-base.d.ts +31 -30
  280. package/types/sitecore-service-base.d.ts.map +1 -0
  281. package/types/tools/auth/flow.d.ts +29 -27
  282. package/types/tools/auth/flow.d.ts.map +1 -0
  283. package/types/tools/auth/index.d.ts +2 -1
  284. package/types/tools/auth/index.d.ts.map +1 -0
  285. package/types/tools/auth/models.d.ts +35 -33
  286. package/types/tools/auth/models.d.ts.map +1 -0
  287. package/types/tools/auth/tenant-store.d.ts +12 -11
  288. package/types/tools/auth/tenant-store.d.ts.map +1 -0
  289. package/types/tools/codegen/component-generation.d.ts +50 -47
  290. package/types/tools/codegen/component-generation.d.ts.map +1 -0
  291. package/types/tools/codegen/extract-files.d.ts +24 -22
  292. package/types/tools/codegen/extract-files.d.ts.map +1 -0
  293. package/types/tools/codegen/import-map.d.ts +103 -70
  294. package/types/tools/codegen/import-map.d.ts.map +1 -0
  295. package/types/tools/codegen/utils.d.ts +76 -75
  296. package/types/tools/codegen/utils.d.ts.map +1 -0
  297. package/types/tools/generate-map.d.ts +36 -26
  298. package/types/tools/generate-map.d.ts.map +1 -0
  299. package/types/tools/generateMetadata.d.ts +24 -22
  300. package/types/tools/generateMetadata.d.ts.map +1 -0
  301. package/types/tools/generateSites.d.ts +25 -22
  302. package/types/tools/generateSites.d.ts.map +1 -0
  303. package/types/tools/index.d.ts +22 -20
  304. package/types/tools/index.d.ts.map +1 -0
  305. package/types/tools/scaffold.d.ts +27 -25
  306. package/types/tools/scaffold.d.ts.map +1 -0
  307. package/types/tools/templating/components.d.ts +104 -103
  308. package/types/tools/templating/components.d.ts.map +1 -0
  309. package/types/tools/templating/index.d.ts +4 -3
  310. package/types/tools/templating/index.d.ts.map +1 -0
  311. package/types/tools/templating/plugins.d.ts +71 -67
  312. package/types/tools/templating/plugins.d.ts.map +1 -0
  313. package/types/tools/templating/utils.d.ts +42 -40
  314. package/types/tools/templating/utils.d.ts.map +1 -0
  315. package/types/utils/ensurePath.d.ts +7 -6
  316. package/types/utils/ensurePath.d.ts.map +1 -0
  317. package/types/utils/env.d.ts +9 -7
  318. package/types/utils/env.d.ts.map +1 -0
  319. package/types/utils/globalCache.d.ts +37 -0
  320. package/types/utils/globalCache.d.ts.map +1 -0
  321. package/types/utils/index.d.ts +5 -3
  322. package/types/utils/index.d.ts.map +1 -0
  323. package/types/utils/is-server.d.ts +8 -6
  324. package/types/utils/is-server.d.ts.map +1 -0
  325. package/types/utils/normalize-url.d.ts +2 -1
  326. package/types/utils/normalize-url.d.ts.map +1 -0
  327. package/types/utils/timeout-promise.d.ts +18 -17
  328. package/types/utils/timeout-promise.d.ts.map +1 -0
  329. package/types/utils/utils.d.ts +104 -79
  330. package/types/utils/utils.d.ts.map +1 -0
  331. package/client.js +0 -1
  332. package/codegen.js +0 -1
  333. package/config-cli.js +0 -1
  334. package/config.js +0 -1
  335. package/editing.js +0 -1
  336. package/i18n.js +0 -1
  337. package/layout.js +0 -1
  338. package/media.js +0 -1
  339. package/personalize.js +0 -1
  340. package/site.js +0 -1
  341. package/tools.js +0 -1
  342. package/utils.js +0 -1
@@ -1,66 +1,67 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.matchPath = void 0;
7
- exports.getItems = getItems;
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- /**
11
- * Compares two paths to determine if they match.
12
- * @param {string} itemPath base path to compare against, can be absolute or relative
13
- * @param {string} compare comparer, can be relate, absolute or regex string
14
- * @returns true if paths match, false otherwise
15
- */
16
- const matchPath = (itemPath, compare) => {
17
- if (compare === itemPath ||
18
- path_1.default.join(process.cwd(), itemPath) === compare ||
19
- itemPath === path_1.default.join(process.cwd(), compare) ||
20
- new RegExp(compare).test(itemPath)) {
21
- return true;
22
- }
23
- return false;
24
- };
25
- exports.matchPath = matchPath;
26
- /**
27
- * Using @var path find all files and generate output using @var resolveItem function for each file
28
- * Can be used to generate list of components, templates, etc.
29
- * @param {GetItemsSettings} settings
30
- * @returns {Item[]} list of items
31
- */
32
- function getItems(settings) {
33
- const { recursive = true, path, resolveItem, cb, fileFormat = new RegExp(/(.+)(?<!\.d)\.[jt]sx?$/), exclude, } = settings;
34
- const items = [];
35
- const folders = [];
36
- if (!fs_1.default.existsSync(path))
37
- return [];
38
- if (exclude) {
39
- for (const exclusion of exclude) {
40
- if ((0, exports.matchPath)(path, exclusion))
41
- return [];
42
- }
43
- }
44
- fs_1.default.readdirSync(path, { withFileTypes: true }).forEach((item) => {
45
- if (item.isDirectory()) {
46
- folders.push(item);
47
- }
48
- if (fileFormat.test(item.name)) {
49
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50
- const name = item.name.match(fileFormat)[1];
51
- items.push(resolveItem(path, name));
52
- cb && cb(name);
53
- }
54
- });
55
- for (const folder of folders) {
56
- recursive
57
- ? items.push(...getItems({
58
- path: `${path}/${folder.name}`,
59
- resolveItem,
60
- cb,
61
- fileFormat,
62
- }))
63
- : items.push(resolveItem(`${path}/${folder.name}`, folder.name));
64
- }
65
- return items;
66
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.matchPath = void 0;
7
+ exports.getItems = getItems;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ /**
11
+ * Compares two paths to determine if they match.
12
+ * @param {string} itemPath base path to compare against, can be absolute or relative
13
+ * @param {string} compare comparer, can be relate, absolute or regex string
14
+ * @returns true if paths match, false otherwise
15
+ * @public
16
+ */
17
+ const matchPath = (itemPath, compare) => {
18
+ if (compare === itemPath ||
19
+ path_1.default.join(process.cwd(), itemPath) === compare ||
20
+ itemPath === path_1.default.join(process.cwd(), compare) ||
21
+ new RegExp(compare).test(itemPath)) {
22
+ return true;
23
+ }
24
+ return false;
25
+ };
26
+ exports.matchPath = matchPath;
27
+ /**
28
+ * Using @var path find all files and generate output using @var resolveItem function for each file
29
+ * Can be used to generate list of components, templates, etc.
30
+ * @param {GetItemsSettings} settings
31
+ * @returns {Item[]} list of items
32
+ */
33
+ function getItems(settings) {
34
+ const { recursive = true, path, resolveItem, cb, fileFormat = new RegExp(/(.+)(?<!\.d)\.[jt]sx?$/), exclude, } = settings;
35
+ const items = [];
36
+ const folders = [];
37
+ if (!fs_1.default.existsSync(path))
38
+ return [];
39
+ if (exclude) {
40
+ for (const exclusion of exclude) {
41
+ if ((0, exports.matchPath)(path, exclusion))
42
+ return [];
43
+ }
44
+ }
45
+ fs_1.default.readdirSync(path, { withFileTypes: true }).forEach((item) => {
46
+ if (item.isDirectory()) {
47
+ folders.push(item);
48
+ }
49
+ if (fileFormat.test(item.name)) {
50
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
+ const name = item.name.match(fileFormat)[1];
52
+ items.push(resolveItem(path, name));
53
+ cb && cb(name);
54
+ }
55
+ });
56
+ for (const folder of folders) {
57
+ recursive
58
+ ? items.push(...getItems({
59
+ path: `${path}/${folder.name}`,
60
+ resolveItem,
61
+ cb,
62
+ fileFormat,
63
+ }))
64
+ : items.push(resolveItem(`${path}/${folder.name}`, folder.name));
65
+ }
66
+ return items;
67
+ }
@@ -1,20 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ensurePathExists = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- /**
10
- * Ensures that the directory path for the given file path exists.
11
- * If the directory does not exist, it will be created recursively.
12
- * @param {string} filePath - The file path for which to ensure the directory exists.
13
- */
14
- const ensurePathExists = (filePath) => {
15
- const outputDir = path_1.default.dirname(filePath);
16
- if (!fs_1.default.existsSync(outputDir)) {
17
- fs_1.default.mkdirSync(outputDir, { recursive: true });
18
- }
19
- };
20
- exports.ensurePathExists = ensurePathExists;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ensurePathExists = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ /**
10
+ * Ensures that the directory path for the given file path exists.
11
+ * If the directory does not exist, it will be created recursively.
12
+ * @param {string} filePath - The file path for which to ensure the directory exists.
13
+ */
14
+ const ensurePathExists = (filePath) => {
15
+ const outputDir = path_1.default.dirname(filePath);
16
+ if (!fs_1.default.existsSync(outputDir)) {
17
+ fs_1.default.mkdirSync(outputDir, { recursive: true });
18
+ }
19
+ };
20
+ exports.ensurePathExists = ensurePathExists;
@@ -1,27 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryParseEnvValue = void 0;
4
- /**
5
- * Method to parse JSON-formatted environment variables
6
- * @param {string} envValue - can be undefined when providing values via process.env
7
- * @param {T} defaultValue - default value
8
- * @returns {T | string} parsed value
9
- */
10
- const tryParseEnvValue = (envValue, defaultValue) => {
11
- if (!envValue) {
12
- return defaultValue;
13
- }
14
- if (envValue.startsWith('{') && envValue.endsWith('}')) {
15
- try {
16
- return JSON.parse(envValue);
17
- // eslint-disable-next-line no-unused-vars
18
- }
19
- catch (error) {
20
- console.warn('Parsing of env variable failed');
21
- console.warn(`Attempted to parse ${envValue}`);
22
- return defaultValue;
23
- }
24
- }
25
- return defaultValue;
26
- };
27
- exports.tryParseEnvValue = tryParseEnvValue;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryParseEnvValue = void 0;
4
+ /**
5
+ * Method to parse JSON-formatted environment variables
6
+ * @param {string} envValue - can be undefined when providing values via process.env
7
+ * @param {T} defaultValue - default value
8
+ * @returns {T | string} parsed value
9
+ * @public
10
+ */
11
+ const tryParseEnvValue = (envValue, defaultValue) => {
12
+ if (!envValue) {
13
+ return defaultValue;
14
+ }
15
+ if (envValue.startsWith('{') && envValue.endsWith('}')) {
16
+ try {
17
+ return JSON.parse(envValue);
18
+ // eslint-disable-next-line no-unused-vars
19
+ }
20
+ catch (error) {
21
+ console.warn('Parsing of env variable failed');
22
+ console.warn(`Attempted to parse ${envValue}`);
23
+ return defaultValue;
24
+ }
25
+ }
26
+ return defaultValue;
27
+ };
28
+ exports.tryParseEnvValue = tryParseEnvValue;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setCache = setCache;
4
+ exports.getCache = getCache;
5
+ exports.getCacheAndClean = getCacheAndClean;
6
+ exports.hasCache = hasCache;
7
+ /**
8
+ * Stores a value in the global cache under the specified key.
9
+ * - Initializes the cache object on `globalThis` if it does not exist.
10
+ * - Overwrites any existing value for the given key.
11
+ * @param {string} key - The cache key to set.
12
+ * @param {unknown} data - The value to store in the cache.
13
+ * @internal
14
+ */
15
+ function setCache(key, data) {
16
+ if (!globalThis.__dlCache) {
17
+ globalThis.__dlCache = {};
18
+ }
19
+ globalThis.__dlCache[key] = data;
20
+ }
21
+ /**
22
+ * Retrieves a value from the global cache by key.
23
+ * - The cache is stored on `globalThis`
24
+ * @param {string} key - The cache key to retrieve and remove.
25
+ * @returns {T} - The cached value if present, otherwise undefined.
26
+ * @internal
27
+ */
28
+ function getCache(key) {
29
+ const cache = globalThis.__dlCache;
30
+ return cache === null || cache === void 0 ? void 0 : cache[key];
31
+ }
32
+ /**
33
+ * Retrieves a value from the global cache by key and removes it from the cache.
34
+ * - The cache is stored on `globalThis`
35
+ * @param {string} key - The cache key to retrieve and remove.
36
+ * @returns {T} - The cached value if present, otherwise undefined.
37
+ * @internal
38
+ */
39
+ function getCacheAndClean(key) {
40
+ const cache = globalThis.__dlCache;
41
+ const data = cache === null || cache === void 0 ? void 0 : cache[key];
42
+ cache === null || cache === void 0 ? true : delete cache[key];
43
+ return data;
44
+ }
45
+ /**
46
+ * Determines whether a cached value exists for the provided key
47
+ * - The cache is stored on `globalThis`
48
+ * @param {string} key - The cache key to test for existence.
49
+ * @returns {boolean} - true if a value is present for the given key; otherwise false.
50
+ * @internal
51
+ */
52
+ function hasCache(key) {
53
+ const cache = globalThis.__dlCache;
54
+ return (cache === null || cache === void 0 ? void 0 : cache[key]) !== undefined;
55
+ }
@@ -1,21 +1,26 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.tryParseEnvValue = exports.mergeURLSearchParams = exports.escapeNonSpecialQuestionMarks = exports.areURLSearchParamsEqual = exports.isRegexOrUrl = exports.getAllowedOriginsFromEnv = exports.getEnforcedCorsHeaders = exports.enforceCors = exports.isTimeoutError = exports.isAbsoluteUrl = exports.resolveUrl = exports.isServer = void 0;
7
- var is_server_1 = require("./is-server");
8
- Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return __importDefault(is_server_1).default; } });
9
- var utils_1 = require("./utils");
10
- Object.defineProperty(exports, "resolveUrl", { enumerable: true, get: function () { return utils_1.resolveUrl; } });
11
- Object.defineProperty(exports, "isAbsoluteUrl", { enumerable: true, get: function () { return utils_1.isAbsoluteUrl; } });
12
- Object.defineProperty(exports, "isTimeoutError", { enumerable: true, get: function () { return utils_1.isTimeoutError; } });
13
- Object.defineProperty(exports, "enforceCors", { enumerable: true, get: function () { return utils_1.enforceCors; } });
14
- Object.defineProperty(exports, "getEnforcedCorsHeaders", { enumerable: true, get: function () { return utils_1.getEnforcedCorsHeaders; } });
15
- Object.defineProperty(exports, "getAllowedOriginsFromEnv", { enumerable: true, get: function () { return utils_1.getAllowedOriginsFromEnv; } });
16
- Object.defineProperty(exports, "isRegexOrUrl", { enumerable: true, get: function () { return utils_1.isRegexOrUrl; } });
17
- Object.defineProperty(exports, "areURLSearchParamsEqual", { enumerable: true, get: function () { return utils_1.areURLSearchParamsEqual; } });
18
- Object.defineProperty(exports, "escapeNonSpecialQuestionMarks", { enumerable: true, get: function () { return utils_1.escapeNonSpecialQuestionMarks; } });
19
- Object.defineProperty(exports, "mergeURLSearchParams", { enumerable: true, get: function () { return utils_1.mergeURLSearchParams; } });
20
- var env_1 = require("./env");
21
- Object.defineProperty(exports, "tryParseEnvValue", { enumerable: true, get: function () { return env_1.tryParseEnvValue; } });
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.tryParseEnvValue = exports.setCache = exports.getCacheAndClean = exports.getCache = exports.hasCache = exports.mergeURLSearchParams = exports.escapeNonSpecialQuestionMarks = exports.areURLSearchParamsEqual = exports.isRegexOrUrl = exports.getAllowedOriginsFromEnv = exports.getEnforcedCorsHeaders = exports.enforceCors = exports.isTimeoutError = exports.isAbsoluteUrl = exports.resolveUrl = exports.isServer = void 0;
7
+ var is_server_1 = require("./is-server");
8
+ Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return __importDefault(is_server_1).default; } });
9
+ var utils_1 = require("./utils");
10
+ Object.defineProperty(exports, "resolveUrl", { enumerable: true, get: function () { return utils_1.resolveUrl; } });
11
+ Object.defineProperty(exports, "isAbsoluteUrl", { enumerable: true, get: function () { return utils_1.isAbsoluteUrl; } });
12
+ Object.defineProperty(exports, "isTimeoutError", { enumerable: true, get: function () { return utils_1.isTimeoutError; } });
13
+ Object.defineProperty(exports, "enforceCors", { enumerable: true, get: function () { return utils_1.enforceCors; } });
14
+ Object.defineProperty(exports, "getEnforcedCorsHeaders", { enumerable: true, get: function () { return utils_1.getEnforcedCorsHeaders; } });
15
+ Object.defineProperty(exports, "getAllowedOriginsFromEnv", { enumerable: true, get: function () { return utils_1.getAllowedOriginsFromEnv; } });
16
+ Object.defineProperty(exports, "isRegexOrUrl", { enumerable: true, get: function () { return utils_1.isRegexOrUrl; } });
17
+ Object.defineProperty(exports, "areURLSearchParamsEqual", { enumerable: true, get: function () { return utils_1.areURLSearchParamsEqual; } });
18
+ Object.defineProperty(exports, "escapeNonSpecialQuestionMarks", { enumerable: true, get: function () { return utils_1.escapeNonSpecialQuestionMarks; } });
19
+ Object.defineProperty(exports, "mergeURLSearchParams", { enumerable: true, get: function () { return utils_1.mergeURLSearchParams; } });
20
+ var globalCache_1 = require("./globalCache");
21
+ Object.defineProperty(exports, "hasCache", { enumerable: true, get: function () { return globalCache_1.hasCache; } });
22
+ Object.defineProperty(exports, "getCache", { enumerable: true, get: function () { return globalCache_1.getCache; } });
23
+ Object.defineProperty(exports, "getCacheAndClean", { enumerable: true, get: function () { return globalCache_1.getCacheAndClean; } });
24
+ Object.defineProperty(exports, "setCache", { enumerable: true, get: function () { return globalCache_1.setCache; } });
25
+ var env_1 = require("./env");
26
+ Object.defineProperty(exports, "tryParseEnvValue", { enumerable: true, get: function () { return env_1.tryParseEnvValue; } });
@@ -1,10 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Determines whether the current execution context is server-side
5
- * @returns true if executing server-side
6
- */
7
- function isServer() {
8
- return !(typeof window !== 'undefined' && window.document);
9
- }
10
- exports.default = isServer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Determines whether the current execution context is server-side
5
+ * @returns true if executing server-side
6
+ * @public
7
+ */
8
+ function isServer() {
9
+ return !(typeof window !== 'undefined' && window.document);
10
+ }
11
+ exports.default = isServer;
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeUrl = void 0;
4
- const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
5
- exports.normalizeUrl = normalizeUrl;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeUrl = void 0;
4
+ const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
5
+ exports.normalizeUrl = normalizeUrl;
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * A helper to assign timeouts to fetch or other promises
5
- * Useful in nextjs middleware until fetch.signal is fully supported by Vercel edge functions
6
- */
7
- class TimeoutPromise {
8
- constructor(timeout) {
9
- this.timeout = timeout;
10
- this.timeoutId = undefined;
11
- }
12
- /**
13
- * Creates a timeout promise
14
- */
15
- get start() {
16
- return new Promise((_, reject) => {
17
- this.timeoutId = setTimeout(() => {
18
- const abortError = new Error(`Request timed out, timeout of ${this.timeout}ms is exceeded`);
19
- abortError.name = 'AbortError';
20
- reject(abortError);
21
- }, this.timeout);
22
- });
23
- }
24
- /**
25
- * Clears the timeout from timeout promise
26
- */
27
- clear() {
28
- this.timeoutId && clearTimeout(this.timeoutId);
29
- }
30
- }
31
- exports.default = TimeoutPromise;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * A helper to assign timeouts to fetch or other promises
5
+ * Useful in nextjs middleware until fetch.signal is fully supported by Vercel edge functions
6
+ */
7
+ class TimeoutPromise {
8
+ constructor(timeout) {
9
+ this.timeout = timeout;
10
+ this.timeoutId = undefined;
11
+ }
12
+ /**
13
+ * Creates a timeout promise
14
+ */
15
+ get start() {
16
+ return new Promise((_, reject) => {
17
+ this.timeoutId = setTimeout(() => {
18
+ const abortError = new Error(`Request timed out, timeout of ${this.timeout}ms is exceeded`);
19
+ abortError.name = 'AbortError';
20
+ reject(abortError);
21
+ }, this.timeout);
22
+ });
23
+ }
24
+ /**
25
+ * Clears the timeout from timeout promise
26
+ */
27
+ clear() {
28
+ this.timeoutId && clearTimeout(this.timeoutId);
29
+ }
30
+ }
31
+ exports.default = TimeoutPromise;