@nascentdigital/funnel-core 4.4.4

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 (368) hide show
  1. package/dist/app/AppConfig.d.ts +41 -0
  2. package/dist/app/AppConfig.js +93 -0
  3. package/dist/app/BrandConfig.d.ts +13 -0
  4. package/dist/app/BrandConfig.js +2 -0
  5. package/dist/app/FeaturesConfig.d.ts +6 -0
  6. package/dist/app/FeaturesConfig.js +2 -0
  7. package/dist/app/RegionsConfig.d.ts +43 -0
  8. package/dist/app/RegionsConfig.js +113 -0
  9. package/dist/app/UIConfig.d.ts +4 -0
  10. package/dist/app/UIConfig.js +2 -0
  11. package/dist/app/index.d.ts +5 -0
  12. package/dist/app/index.js +21 -0
  13. package/dist/consent/ConsentCategory.d.ts +12 -0
  14. package/dist/consent/ConsentCategory.js +28 -0
  15. package/dist/consent/ConsentService.d.ts +15 -0
  16. package/dist/consent/ConsentService.js +37 -0
  17. package/dist/consent/index.d.ts +2 -0
  18. package/dist/consent/index.js +18 -0
  19. package/dist/errors/IsometricError.d.ts +19 -0
  20. package/dist/errors/IsometricError.js +30 -0
  21. package/dist/errors/IsometricErrorModule.d.ts +11 -0
  22. package/dist/errors/IsometricErrorModule.js +2 -0
  23. package/dist/errors/IsometricErrorUtils.d.ts +9 -0
  24. package/dist/errors/IsometricErrorUtils.js +85 -0
  25. package/dist/errors/SerializedIsometricError.d.ts +10 -0
  26. package/dist/errors/SerializedIsometricError.js +15 -0
  27. package/dist/errors/api/ApiError.d.ts +15 -0
  28. package/dist/errors/api/ApiError.js +23 -0
  29. package/dist/errors/api/ApiErrors.d.ts +7 -0
  30. package/dist/errors/api/ApiErrors.js +67 -0
  31. package/dist/errors/api/ArgumentError.d.ts +7 -0
  32. package/dist/errors/api/ArgumentError.js +18 -0
  33. package/dist/errors/api/ConcurrencyError.d.ts +4 -0
  34. package/dist/errors/api/ConcurrencyError.js +11 -0
  35. package/dist/errors/api/ConflictError.d.ts +4 -0
  36. package/dist/errors/api/ConflictError.js +11 -0
  37. package/dist/errors/api/DependencyError.d.ts +4 -0
  38. package/dist/errors/api/DependencyError.js +11 -0
  39. package/dist/errors/api/IllegalStateError.d.ts +4 -0
  40. package/dist/errors/api/IllegalStateError.js +11 -0
  41. package/dist/errors/api/InvalidOperationError.d.ts +4 -0
  42. package/dist/errors/api/InvalidOperationError.js +11 -0
  43. package/dist/errors/api/NotAuthenticatedError.d.ts +4 -0
  44. package/dist/errors/api/NotAuthenticatedError.js +11 -0
  45. package/dist/errors/api/NotAuthorizedError.d.ts +4 -0
  46. package/dist/errors/api/NotAuthorizedError.js +11 -0
  47. package/dist/errors/api/NotAvailableError.d.ts +4 -0
  48. package/dist/errors/api/NotAvailableError.js +11 -0
  49. package/dist/errors/api/NotFoundError.d.ts +4 -0
  50. package/dist/errors/api/NotFoundError.js +11 -0
  51. package/dist/errors/api/NotImplementedError.d.ts +4 -0
  52. package/dist/errors/api/NotImplementedError.js +11 -0
  53. package/dist/errors/api/OfflineError.d.ts +4 -0
  54. package/dist/errors/api/OfflineError.js +11 -0
  55. package/dist/errors/api/RangeError.d.ts +4 -0
  56. package/dist/errors/api/RangeError.js +11 -0
  57. package/dist/errors/api/ServerError.d.ts +4 -0
  58. package/dist/errors/api/ServerError.js +11 -0
  59. package/dist/errors/api/TimeoutError.d.ts +4 -0
  60. package/dist/errors/api/TimeoutError.js +11 -0
  61. package/dist/errors/api/index.d.ts +16 -0
  62. package/dist/errors/api/index.js +32 -0
  63. package/dist/errors/index.d.ts +5 -0
  64. package/dist/errors/index.js +26 -0
  65. package/dist/forms/FormModel.d.ts +47 -0
  66. package/dist/forms/FormModel.js +149 -0
  67. package/dist/forms/Forms.d.ts +15 -0
  68. package/dist/forms/Forms.js +35 -0
  69. package/dist/forms/IFormService.d.ts +6 -0
  70. package/dist/forms/IFormService.js +2 -0
  71. package/dist/forms/TranslateSchema.d.ts +8 -0
  72. package/dist/forms/TranslateSchema.js +2 -0
  73. package/dist/forms/index.d.ts +4 -0
  74. package/dist/forms/index.js +20 -0
  75. package/dist/index.d.ts +10 -0
  76. package/dist/index.js +49 -0
  77. package/dist/regionalization/Country.d.ts +266 -0
  78. package/dist/regionalization/Country.js +338 -0
  79. package/dist/regionalization/Language.d.ts +199 -0
  80. package/dist/regionalization/Language.js +237 -0
  81. package/dist/regionalization/Locale.d.ts +28 -0
  82. package/dist/regionalization/Locale.js +49 -0
  83. package/dist/regionalization/Localized.d.ts +10 -0
  84. package/dist/regionalization/Localized.js +36 -0
  85. package/dist/regionalization/LocalizedCopy.d.ts +9 -0
  86. package/dist/regionalization/LocalizedCopy.js +26 -0
  87. package/dist/regionalization/Regionalization.d.ts +50 -0
  88. package/dist/regionalization/Regionalization.js +260 -0
  89. package/dist/regionalization/Regions.d.ts +2 -0
  90. package/dist/regionalization/Regions.js +2 -0
  91. package/dist/regionalization/index.d.ts +7 -0
  92. package/dist/regionalization/index.js +23 -0
  93. package/dist/schema/Asset.d.ts +23 -0
  94. package/dist/schema/Asset.js +36 -0
  95. package/dist/schema/AssetScope.d.ts +75 -0
  96. package/dist/schema/AssetScope.js +146 -0
  97. package/dist/schema/Block.d.ts +105 -0
  98. package/dist/schema/Block.js +122 -0
  99. package/dist/schema/ChangeSet.d.ts +108 -0
  100. package/dist/schema/ChangeSet.js +187 -0
  101. package/dist/schema/Collection.d.ts +197 -0
  102. package/dist/schema/Collection.js +165 -0
  103. package/dist/schema/CollectionModel.d.ts +30 -0
  104. package/dist/schema/CollectionModel.js +383 -0
  105. package/dist/schema/CollectionSnapshot.d.ts +11 -0
  106. package/dist/schema/CollectionSnapshot.js +12 -0
  107. package/dist/schema/Fields.d.ts +31 -0
  108. package/dist/schema/Fields.js +21 -0
  109. package/dist/schema/Form.d.ts +31 -0
  110. package/dist/schema/Form.js +23 -0
  111. package/dist/schema/LinkedCollectionModel.d.ts +9 -0
  112. package/dist/schema/LinkedCollectionModel.js +19 -0
  113. package/dist/schema/LinkedData.d.ts +44 -0
  114. package/dist/schema/LinkedData.js +288 -0
  115. package/dist/schema/LinkedPageModel.d.ts +11 -0
  116. package/dist/schema/LinkedPageModel.js +26 -0
  117. package/dist/schema/Optional.d.ts +23 -0
  118. package/dist/schema/Optional.js +34 -0
  119. package/dist/schema/Page.d.ts +299 -0
  120. package/dist/schema/Page.js +244 -0
  121. package/dist/schema/PageModel.d.ts +58 -0
  122. package/dist/schema/PageModel.js +881 -0
  123. package/dist/schema/PageQuery.d.ts +60 -0
  124. package/dist/schema/PageQuery.js +116 -0
  125. package/dist/schema/PageRoute.d.ts +7 -0
  126. package/dist/schema/PageRoute.js +48 -0
  127. package/dist/schema/PageSnapshot.d.ts +11 -0
  128. package/dist/schema/PageSnapshot.js +12 -0
  129. package/dist/schema/Section.d.ts +71 -0
  130. package/dist/schema/Section.js +35 -0
  131. package/dist/schema/Seo.d.ts +13 -0
  132. package/dist/schema/Seo.js +25 -0
  133. package/dist/schema/Site.d.ts +40 -0
  134. package/dist/schema/Site.js +87 -0
  135. package/dist/schema/SiteModel.d.ts +5 -0
  136. package/dist/schema/SiteModel.js +10 -0
  137. package/dist/schema/Tag.d.ts +28 -0
  138. package/dist/schema/Tag.js +59 -0
  139. package/dist/schema/TagGroup.d.ts +26 -0
  140. package/dist/schema/TagGroup.js +64 -0
  141. package/dist/schema/field/Field.d.ts +179 -0
  142. package/dist/schema/field/Field.js +309 -0
  143. package/dist/schema/field/base/AssetField.d.ts +148 -0
  144. package/dist/schema/field/base/AssetField.js +206 -0
  145. package/dist/schema/field/base/BooleanField.d.ts +21 -0
  146. package/dist/schema/field/base/BooleanField.js +38 -0
  147. package/dist/schema/field/base/CollectionField.d.ts +34 -0
  148. package/dist/schema/field/base/CollectionField.js +85 -0
  149. package/dist/schema/field/base/DateField.d.ts +21 -0
  150. package/dist/schema/field/base/DateField.js +37 -0
  151. package/dist/schema/field/base/DynamicPagesField.d.ts +36 -0
  152. package/dist/schema/field/base/DynamicPagesField.js +50 -0
  153. package/dist/schema/field/base/EmbeddedVideoField.d.ts +45 -0
  154. package/dist/schema/field/base/EmbeddedVideoField.js +176 -0
  155. package/dist/schema/field/base/EnumField.d.ts +40 -0
  156. package/dist/schema/field/base/EnumField.js +131 -0
  157. package/dist/schema/field/base/FormField.d.ts +25 -0
  158. package/dist/schema/field/base/FormField.js +48 -0
  159. package/dist/schema/field/base/LinkField.d.ts +103 -0
  160. package/dist/schema/field/base/LinkField.js +201 -0
  161. package/dist/schema/field/base/PageField.d.ts +46 -0
  162. package/dist/schema/field/base/PageField.js +83 -0
  163. package/dist/schema/field/base/RichTextField.d.ts +71 -0
  164. package/dist/schema/field/base/RichTextField.js +196 -0
  165. package/dist/schema/field/base/TextField.d.ts +33 -0
  166. package/dist/schema/field/base/TextField.js +86 -0
  167. package/dist/schema/field/base/TimestampField.d.ts +25 -0
  168. package/dist/schema/field/base/TimestampField.js +41 -0
  169. package/dist/schema/field/base/index.d.ts +13 -0
  170. package/dist/schema/field/base/index.js +29 -0
  171. package/dist/schema/field/composite/ListField.d.ts +47 -0
  172. package/dist/schema/field/composite/ListField.js +107 -0
  173. package/dist/schema/field/composite/ObjectField.d.ts +56 -0
  174. package/dist/schema/field/composite/ObjectField.js +19 -0
  175. package/dist/schema/field/composite/index.d.ts +2 -0
  176. package/dist/schema/field/composite/index.js +18 -0
  177. package/dist/schema/field/index.d.ts +3 -0
  178. package/dist/schema/field/index.js +19 -0
  179. package/dist/schema/index.d.ts +25 -0
  180. package/dist/schema/index.js +41 -0
  181. package/dist/services/EventBus.d.ts +17 -0
  182. package/dist/services/EventBus.js +37 -0
  183. package/dist/services/humanVerification/IHumanVerification.d.ts +8 -0
  184. package/dist/services/humanVerification/IHumanVerification.js +2 -0
  185. package/dist/services/humanVerification/index.d.ts +1 -0
  186. package/dist/services/humanVerification/index.js +17 -0
  187. package/dist/services/index.d.ts +3 -0
  188. package/dist/services/index.js +19 -0
  189. package/dist/services/leadGen/Contact.d.ts +40 -0
  190. package/dist/services/leadGen/Contact.js +38 -0
  191. package/dist/services/leadGen/ILeadGen.d.ts +16 -0
  192. package/dist/services/leadGen/ILeadGen.js +2 -0
  193. package/dist/services/leadGen/index.d.ts +2 -0
  194. package/dist/services/leadGen/index.js +18 -0
  195. package/dist/types/BoxedValue.d.ts +3 -0
  196. package/dist/types/BoxedValue.js +2 -0
  197. package/dist/types/Callback.d.ts +9 -0
  198. package/dist/types/Callback.js +2 -0
  199. package/dist/types/DateString.d.ts +35 -0
  200. package/dist/types/DateString.js +172 -0
  201. package/dist/types/FilterConditionally.d.ts +3 -0
  202. package/dist/types/FilterConditionally.js +2 -0
  203. package/dist/types/MaybeConditionalValue.d.ts +8 -0
  204. package/dist/types/MaybeConditionalValue.js +12 -0
  205. package/dist/types/Ordinal.d.ts +17 -0
  206. package/dist/types/Ordinal.js +38 -0
  207. package/dist/types/OverridableStringUnion.d.ts +2 -0
  208. package/dist/types/OverridableStringUnion.js +2 -0
  209. package/dist/types/PartialBy.d.ts +1 -0
  210. package/dist/types/PartialBy.js +2 -0
  211. package/dist/types/PickData.d.ts +6 -0
  212. package/dist/types/PickData.js +2 -0
  213. package/dist/types/Provider.d.ts +4 -0
  214. package/dist/types/Provider.js +2 -0
  215. package/dist/types/RequiredBy.d.ts +1 -0
  216. package/dist/types/RequiredBy.js +2 -0
  217. package/dist/types/Result.d.ts +16 -0
  218. package/dist/types/Result.js +2 -0
  219. package/dist/types/Timestamp.d.ts +17 -0
  220. package/dist/types/Timestamp.js +57 -0
  221. package/dist/types/Transform.d.ts +4 -0
  222. package/dist/types/Transform.js +2 -0
  223. package/dist/types/index.d.ts +14 -0
  224. package/dist/types/index.js +30 -0
  225. package/dist/ui/Accessible.d.ts +5 -0
  226. package/dist/ui/Accessible.js +15 -0
  227. package/dist/ui/BlockThemes.d.ts +19 -0
  228. package/dist/ui/BlockThemes.js +29 -0
  229. package/dist/ui/ColorMode.d.ts +12 -0
  230. package/dist/ui/ColorMode.js +49 -0
  231. package/dist/ui/File.d.ts +43 -0
  232. package/dist/ui/File.js +55 -0
  233. package/dist/ui/FileType.d.ts +8 -0
  234. package/dist/ui/FileType.js +48 -0
  235. package/dist/ui/ImageSource.d.ts +12 -0
  236. package/dist/ui/ImageSource.js +48 -0
  237. package/dist/ui/MimeType.d.ts +28 -0
  238. package/dist/ui/MimeType.js +110 -0
  239. package/dist/ui/Placement.d.ts +21 -0
  240. package/dist/ui/Placement.js +135 -0
  241. package/dist/ui/Position.d.ts +6 -0
  242. package/dist/ui/Position.js +42 -0
  243. package/dist/ui/Selector.d.ts +6 -0
  244. package/dist/ui/Selector.js +23 -0
  245. package/dist/ui/SemanticColor.d.ts +8 -0
  246. package/dist/ui/SemanticColor.js +237 -0
  247. package/dist/ui/Visual.d.ts +24 -0
  248. package/dist/ui/Visual.js +66 -0
  249. package/dist/ui/block-layout/BlockLayout.d.ts +99 -0
  250. package/dist/ui/block-layout/BlockLayout.js +286 -0
  251. package/dist/ui/block-layout/index.d.ts +1 -0
  252. package/dist/ui/block-layout/index.js +17 -0
  253. package/dist/ui/browser/BlurHasher.d.ts +13 -0
  254. package/dist/ui/browser/BlurHasher.js +76 -0
  255. package/dist/ui/browser/Browser.d.ts +107 -0
  256. package/dist/ui/browser/Browser.js +313 -0
  257. package/dist/ui/browser/ImageProxy.d.ts +30 -0
  258. package/dist/ui/browser/ImageProxy.js +132 -0
  259. package/dist/ui/browser/InputEvent.d.ts +13 -0
  260. package/dist/ui/browser/InputEvent.js +2 -0
  261. package/dist/ui/browser/SVGProxy.d.ts +9 -0
  262. package/dist/ui/browser/SVGProxy.js +59 -0
  263. package/dist/ui/browser/VideoProxy.d.ts +42 -0
  264. package/dist/ui/browser/VideoProxy.js +235 -0
  265. package/dist/ui/browser/index.d.ts +6 -0
  266. package/dist/ui/browser/index.js +22 -0
  267. package/dist/ui/fields/Field.d.ts +80 -0
  268. package/dist/ui/fields/Field.js +298 -0
  269. package/dist/ui/fields/FieldList.d.ts +80 -0
  270. package/dist/ui/fields/FieldList.js +421 -0
  271. package/dist/ui/fields/FieldListValidator.d.ts +9 -0
  272. package/dist/ui/fields/FieldListValidator.js +37 -0
  273. package/dist/ui/fields/FieldModel.d.ts +15 -0
  274. package/dist/ui/fields/FieldModel.js +28 -0
  275. package/dist/ui/fields/FieldSerializer.d.ts +13 -0
  276. package/dist/ui/fields/FieldSerializer.js +71 -0
  277. package/dist/ui/fields/FieldValidator.d.ts +19 -0
  278. package/dist/ui/fields/FieldValidator.js +98 -0
  279. package/dist/ui/fields/ObjectField.d.ts +75 -0
  280. package/dist/ui/fields/ObjectField.js +288 -0
  281. package/dist/ui/fields/errors.json +44 -0
  282. package/dist/ui/fields/index.d.ts +7 -0
  283. package/dist/ui/fields/index.js +23 -0
  284. package/dist/ui/fields/validators/AssetValidator.d.ts +9 -0
  285. package/dist/ui/fields/validators/AssetValidator.js +25 -0
  286. package/dist/ui/fields/validators/DateValidator.d.ts +9 -0
  287. package/dist/ui/fields/validators/DateValidator.js +41 -0
  288. package/dist/ui/fields/validators/EnumValidator.d.ts +10 -0
  289. package/dist/ui/fields/validators/EnumValidator.js +77 -0
  290. package/dist/ui/fields/validators/GenericValidator.d.ts +6 -0
  291. package/dist/ui/fields/validators/GenericValidator.js +22 -0
  292. package/dist/ui/fields/validators/LinkValidator.d.ts +9 -0
  293. package/dist/ui/fields/validators/LinkValidator.js +146 -0
  294. package/dist/ui/fields/validators/RichTextValidator.d.ts +6 -0
  295. package/dist/ui/fields/validators/RichTextValidator.js +35 -0
  296. package/dist/ui/fields/validators/TextValidator.d.ts +10 -0
  297. package/dist/ui/fields/validators/TextValidator.js +138 -0
  298. package/dist/ui/fields/validators/TimestampValidator.d.ts +9 -0
  299. package/dist/ui/fields/validators/TimestampValidator.js +41 -0
  300. package/dist/ui/fields/validators/ValidatorHelper.d.ts +23 -0
  301. package/dist/ui/fields/validators/ValidatorHelper.js +55 -0
  302. package/dist/ui/fields/validators/index.d.ts +8 -0
  303. package/dist/ui/fields/validators/index.js +24 -0
  304. package/dist/ui/geometry/AspectRatio.d.ts +27 -0
  305. package/dist/ui/geometry/AspectRatio.js +77 -0
  306. package/dist/ui/geometry/Bounds.d.ts +4 -0
  307. package/dist/ui/geometry/Bounds.js +11 -0
  308. package/dist/ui/geometry/Frame.d.ts +3 -0
  309. package/dist/ui/geometry/Frame.js +2 -0
  310. package/dist/ui/geometry/Insets.d.ts +14 -0
  311. package/dist/ui/geometry/Insets.js +14 -0
  312. package/dist/ui/geometry/PixelSize.d.ts +1 -0
  313. package/dist/ui/geometry/PixelSize.js +2 -0
  314. package/dist/ui/geometry/Point.d.ts +7 -0
  315. package/dist/ui/geometry/Point.js +15 -0
  316. package/dist/ui/geometry/Rect.d.ts +19 -0
  317. package/dist/ui/geometry/Rect.js +68 -0
  318. package/dist/ui/geometry/ScreenSize.d.ts +1 -0
  319. package/dist/ui/geometry/ScreenSize.js +2 -0
  320. package/dist/ui/geometry/Size.d.ts +7 -0
  321. package/dist/ui/geometry/Size.js +9 -0
  322. package/dist/ui/geometry/index.d.ts +9 -0
  323. package/dist/ui/geometry/index.js +25 -0
  324. package/dist/ui/index.d.ts +18 -0
  325. package/dist/ui/index.js +34 -0
  326. package/dist/ui/responsive/Breakpoint.d.ts +8 -0
  327. package/dist/ui/responsive/Breakpoint.js +24 -0
  328. package/dist/ui/responsive/BreakpointObserver.d.ts +16 -0
  329. package/dist/ui/responsive/BreakpointObserver.js +104 -0
  330. package/dist/ui/responsive/Breakpoints.d.ts +5 -0
  331. package/dist/ui/responsive/Breakpoints.js +15 -0
  332. package/dist/ui/responsive/ResponsiveValue.d.ts +7 -0
  333. package/dist/ui/responsive/ResponsiveValue.js +26 -0
  334. package/dist/ui/responsive/index.d.ts +4 -0
  335. package/dist/ui/responsive/index.js +20 -0
  336. package/dist/ui/richtext/LexicalUtils.d.ts +31 -0
  337. package/dist/ui/richtext/LexicalUtils.js +314 -0
  338. package/dist/ui/richtext/StyledTextNode.d.ts +33 -0
  339. package/dist/ui/richtext/StyledTextNode.js +101 -0
  340. package/dist/ui/richtext/index.d.ts +2 -0
  341. package/dist/ui/richtext/index.js +18 -0
  342. package/dist/utils/ArrayUtils.d.ts +17 -0
  343. package/dist/utils/ArrayUtils.js +66 -0
  344. package/dist/utils/ByteSize.d.ts +19 -0
  345. package/dist/utils/ByteSize.js +33 -0
  346. package/dist/utils/DateUtils.d.ts +15 -0
  347. package/dist/utils/DateUtils.js +100 -0
  348. package/dist/utils/Deferral.d.ts +28 -0
  349. package/dist/utils/Deferral.js +107 -0
  350. package/dist/utils/Duration.d.ts +7 -0
  351. package/dist/utils/Duration.js +35 -0
  352. package/dist/utils/Fn.d.ts +14 -0
  353. package/dist/utils/Fn.js +52 -0
  354. package/dist/utils/ObjectUtils.d.ts +89 -0
  355. package/dist/utils/ObjectUtils.js +159 -0
  356. package/dist/utils/Random.d.ts +15 -0
  357. package/dist/utils/Random.js +72 -0
  358. package/dist/utils/StringUtils.d.ts +10 -0
  359. package/dist/utils/StringUtils.js +51 -0
  360. package/dist/utils/UrlUtils.d.ts +22 -0
  361. package/dist/utils/UrlUtils.js +119 -0
  362. package/dist/utils/Value.d.ts +23 -0
  363. package/dist/utils/Value.js +122 -0
  364. package/dist/utils/index.d.ts +12 -0
  365. package/dist/utils/index.js +28 -0
  366. package/dist/utils/isDefined.d.ts +1 -0
  367. package/dist/utils/isDefined.js +6 -0
  368. package/package.json +64 -0
@@ -0,0 +1,41 @@
1
+ import { type Page } from '../schema/Page';
2
+ import { PartialBy, Timestamp } from '../types';
3
+ import { BrandConfig } from './BrandConfig';
4
+ import { UIConfig } from './UIConfig';
5
+ export type AppConfig<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string> = {
6
+ private: boolean;
7
+ baseUrl: string;
8
+ timezone: Timestamp.Timezone;
9
+ /**
10
+ * Determines the types of pages that will be fetched when pulling content (either `published` or
11
+ * `draft` - where `published` is the default).
12
+ */
13
+ version: Exclude<Page.State, 'unpublished'>;
14
+ brands: Record<TBrand, BrandConfig<TBrandType, TRegion>>;
15
+ recaptcha: AppConfig.RecaptchaConfig;
16
+ sso: AppConfig.SsoConfig;
17
+ ui: UIConfig;
18
+ accessible: boolean;
19
+ nativeYoutube?: boolean;
20
+ };
21
+ export declare namespace AppConfig {
22
+ type RecaptchaConfig = {
23
+ siteKey: string;
24
+ };
25
+ type SsoConfig = {
26
+ mode: SsoConfig.Mode;
27
+ googleClientId: string;
28
+ };
29
+ namespace SsoConfig {
30
+ type Mode = 'email' | 'google';
31
+ namespace Mode {
32
+ function coerce(value: string | undefined, fallback: Mode): SsoConfig.Mode;
33
+ }
34
+ }
35
+ function get<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(): Readonly<AppConfig<TBrand, TBrandType, TRegion>>;
36
+ function set<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(value: PartialBy<AppConfig<TBrand, TBrandType, TRegion>, 'private' | 'accessible'>): void;
37
+ function brand<TBrand extends string = string>(): TBrand;
38
+ function brandConfig<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(): Readonly<BrandConfig<TBrandType, TRegion>>;
39
+ function ssoConfig(): SsoConfig;
40
+ function uiConfig(): UIConfig;
41
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppConfig = void 0;
4
+ const errors_1 = require("../errors");
5
+ // extension
6
+ var AppConfig;
7
+ (function (AppConfig) {
8
+ let SsoConfig;
9
+ (function (SsoConfig) {
10
+ let Mode;
11
+ (function (Mode) {
12
+ // helpers
13
+ function coerce(value, fallback) {
14
+ var _a;
15
+ const normalizedValue = (_a = value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
16
+ switch (normalizedValue) {
17
+ case 'email':
18
+ case 'google':
19
+ return normalizedValue;
20
+ default:
21
+ return fallback;
22
+ }
23
+ }
24
+ Mode.coerce = coerce;
25
+ })(Mode = SsoConfig.Mode || (SsoConfig.Mode = {}));
26
+ })(SsoConfig = AppConfig.SsoConfig || (AppConfig.SsoConfig = {}));
27
+ // methods
28
+ function get() {
29
+ // throw if config isn't bound
30
+ if (!config) {
31
+ throw new errors_1.IllegalStateError('Attempt to access AppConfig before first call to AppConfig.set()');
32
+ }
33
+ return config;
34
+ }
35
+ AppConfig.get = get;
36
+ function set(value) {
37
+ const defaults = {
38
+ private: false,
39
+ version: 'published',
40
+ accessible: true
41
+ };
42
+ config = Object.assign(Object.assign(Object.assign({}, defaults), (config !== null && config !== void 0 ? config : {})), value);
43
+ }
44
+ AppConfig.set = set;
45
+ function brand() {
46
+ // throw if the brand isn't defined
47
+ const brand = process.env.FUNNEL_BRAND || process.env.NEXT_PUBLIC_BRAND;
48
+ if (!brand) {
49
+ throw new errors_1.IllegalStateError('Unable to resolve $FUNNEL_BRAND');
50
+ }
51
+ // return brand
52
+ return brand;
53
+ }
54
+ AppConfig.brand = brand;
55
+ function brandConfig() {
56
+ // throw if brands are missing
57
+ const { brands } = get();
58
+ if (!brands) {
59
+ throw new errors_1.IllegalStateError('No brands defined in AppConfig');
60
+ }
61
+ // throw if config is missing
62
+ const brandId = brand();
63
+ const brandConfig = brands[brandId];
64
+ if (!brandConfig) {
65
+ throw new errors_1.IllegalStateError(`No BrandConfig set for brand "${brandId}"`);
66
+ }
67
+ // return config
68
+ return brandConfig;
69
+ }
70
+ AppConfig.brandConfig = brandConfig;
71
+ function ssoConfig() {
72
+ // get config
73
+ const { sso } = get();
74
+ if (!sso) {
75
+ throw new errors_1.IllegalStateError('No SsoConfig is defined for this site');
76
+ }
77
+ // return config
78
+ return sso;
79
+ }
80
+ AppConfig.ssoConfig = ssoConfig;
81
+ function uiConfig() {
82
+ // get config
83
+ const { ui } = get();
84
+ if (!ui) {
85
+ throw new errors_1.IllegalStateError('No UIConfig is defined for this site');
86
+ }
87
+ // return config
88
+ return ui;
89
+ }
90
+ AppConfig.uiConfig = uiConfig;
91
+ })(AppConfig || (exports.AppConfig = AppConfig = {}));
92
+ // global context
93
+ let config = undefined;
@@ -0,0 +1,13 @@
1
+ import { FeaturesConfig } from './FeaturesConfig';
2
+ import { RegionsConfig } from './RegionsConfig';
3
+ export type BrandConfig<TBrandType extends string = string, TRegion extends string = string> = {
4
+ type: TBrandType;
5
+ name: string;
6
+ regionalization: RegionsConfig<TRegion>;
7
+ features?: FeaturesConfig;
8
+ };
9
+ export declare namespace BrandConfig {
10
+ type WithId<TBrandType extends string = string, TRegion extends string = string> = BrandConfig<TBrandType, TRegion> & {
11
+ id: string;
12
+ };
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export type FeaturesConfig = {
2
+ [F in FeaturesConfig.Features]?: string | boolean | number;
3
+ };
4
+ export declare namespace FeaturesConfig {
5
+ type Features = 'mobileContactCTAVisible';
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import { Language, Locale } from '../regionalization';
2
+ export type RegionsConfig<TRegion extends string = string> = {
3
+ regions: Record<TRegion, RegionsConfig.RegionConfig>;
4
+ fallback: TRegion;
5
+ urlTruncation: RegionsConfig.UrlTruncation;
6
+ mergedRoutes?: boolean;
7
+ };
8
+ export declare namespace RegionsConfig {
9
+ type RegionConfig = {
10
+ name: string;
11
+ languages: Language[];
12
+ defaultLanguage?: Language;
13
+ };
14
+ namespace RegionConfig {
15
+ type WithId<TRegion extends string = string> = RegionConfig & {
16
+ id: TRegion;
17
+ };
18
+ }
19
+ type UrlTruncation = 'none' | 'full' | 'partial';
20
+ type Type = 'language-only' | 'region-only' | 'locale-composite' | 'locale-split';
21
+ function getRegions<TRegion extends string = string>(config: RegionsConfig<TRegion>): RegionConfig.WithId<TRegion>[];
22
+ function getType(regionalization: RegionsConfig): Type;
23
+ function tryParse<TRegion extends string = string>(regionalization: RegionsConfig, value: string | undefined): TRegion | undefined;
24
+ function parse<TRegion extends string = string>(regionalization: RegionsConfig, value: string | undefined): TRegion;
25
+ function getRegionConfig<TRegion extends string = string>(regionalization: RegionsConfig, region: TRegion): RegionConfig;
26
+ function getLocales<TRegion extends string = string>(regionalization: RegionsConfig): [TRegion, Language][];
27
+ function getLanguages(regionalization: RegionsConfig): Language[];
28
+ /**
29
+ * Given a config for all regions, return the default region. If the default region is set through cookies, we use
30
+ * that. Otherwise, we use the fallback.
31
+ */
32
+ function getDefaultRegion(regionalization: RegionsConfig, inferredLocale?: Partial<Locale>): string;
33
+ /**
34
+ * Given a config for a specific region, return the default language for that region. If the default language
35
+ * is set through cookies, we use hat. Otherwise, if set we use the default language for that region. Otherwise,
36
+ * we use the first language available.
37
+ */
38
+ function getDefaultLanguageForRegion(config: RegionConfig, inferredLocale: Partial<Locale>): Language;
39
+ /**
40
+ * Given the config for all regions, return the default language for the default region.
41
+ */
42
+ function getDefaultLanguage(regionalization: RegionsConfig, inferredLocale?: Partial<Locale>): Language;
43
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegionsConfig = void 0;
4
+ const errors_1 = require("../errors");
5
+ const utils_1 = require("../utils");
6
+ // extension
7
+ var RegionsConfig;
8
+ (function (RegionsConfig) {
9
+ // methods
10
+ function getRegions(config) {
11
+ return Object.entries(config.regions).map(([id, config]) => (Object.assign({ id: id }, config)));
12
+ }
13
+ RegionsConfig.getRegions = getRegions;
14
+ function getType(regionalization) {
15
+ const regions = Object.entries(regionalization.regions);
16
+ if (regions.length === 0) {
17
+ throw new errors_1.IllegalStateError('RegionsConfig must have at least one region');
18
+ }
19
+ // handle case where there is just a single region (languages only)
20
+ if (regions.length === 1) {
21
+ return 'language-only';
22
+ }
23
+ // or, route by regions only if there's just a single language
24
+ const languages = RegionsConfig.getLanguages(regionalization);
25
+ if (languages.length === 1) {
26
+ return 'region-only';
27
+ }
28
+ // or create composite local if specified
29
+ else if (regionalization.mergedRoutes) {
30
+ return 'locale-composite';
31
+ }
32
+ // otherwise, use split locale
33
+ else {
34
+ return 'locale-split';
35
+ }
36
+ }
37
+ RegionsConfig.getType = getType;
38
+ function tryParse(regionalization, value) {
39
+ // skip if there's no value
40
+ if (!value) {
41
+ return undefined;
42
+ }
43
+ // search for match
44
+ const normalizedValue = value.trim().toLowerCase();
45
+ return Object.keys(regionalization.regions)
46
+ .find(region => region.toLowerCase() === normalizedValue);
47
+ }
48
+ RegionsConfig.tryParse = tryParse;
49
+ function parse(regionalization, value) {
50
+ // throw if the value can't be parsed
51
+ const region = tryParse(regionalization, value);
52
+ if (!region) {
53
+ throw new errors_1.ArgumentError(`Invalid region: ${region}`, 'region');
54
+ }
55
+ // return region
56
+ return region;
57
+ }
58
+ RegionsConfig.parse = parse;
59
+ function getRegionConfig(regionalization, region) {
60
+ // get region config (or throw)
61
+ const config = regionalization.regions[region];
62
+ if (!config) {
63
+ throw new errors_1.InvalidOperationError(`Attempt to use unconfigured region: ${region}`);
64
+ }
65
+ // return config
66
+ return config;
67
+ }
68
+ RegionsConfig.getRegionConfig = getRegionConfig;
69
+ function getLocales(regionalization) {
70
+ return Object.entries(regionalization.regions)
71
+ .flatMap(([region, config]) => config === null || config === void 0 ? void 0 : config.languages.map(language => ([region, language])))
72
+ .filter(utils_1.Value.isDefined);
73
+ }
74
+ RegionsConfig.getLocales = getLocales;
75
+ function getLanguages(regionalization) {
76
+ return Object.values(regionalization.regions).reduce((languages, regionConfig) => {
77
+ // add missing languages
78
+ if (regionConfig) {
79
+ languages.push(...regionConfig.languages.filter((l) => !languages.includes(l)));
80
+ }
81
+ // keep reducing
82
+ return languages;
83
+ }, []);
84
+ }
85
+ RegionsConfig.getLanguages = getLanguages;
86
+ /**
87
+ * Given a config for all regions, return the default region. If the default region is set through cookies, we use
88
+ * that. Otherwise, we use the fallback.
89
+ */
90
+ function getDefaultRegion(regionalization, inferredLocale = {}) {
91
+ var _a;
92
+ return (_a = inferredLocale.region) !== null && _a !== void 0 ? _a : regionalization.fallback;
93
+ }
94
+ RegionsConfig.getDefaultRegion = getDefaultRegion;
95
+ /**
96
+ * Given a config for a specific region, return the default language for that region. If the default language
97
+ * is set through cookies, we use hat. Otherwise, if set we use the default language for that region. Otherwise,
98
+ * we use the first language available.
99
+ */
100
+ function getDefaultLanguageForRegion(config, inferredLocale) {
101
+ var _a, _b;
102
+ return (_b = (_a = inferredLocale.language) !== null && _a !== void 0 ? _a : config.defaultLanguage) !== null && _b !== void 0 ? _b : config.languages[0];
103
+ }
104
+ RegionsConfig.getDefaultLanguageForRegion = getDefaultLanguageForRegion;
105
+ /**
106
+ * Given the config for all regions, return the default language for the default region.
107
+ */
108
+ function getDefaultLanguage(regionalization, inferredLocale = {}) {
109
+ const config = getRegionConfig(regionalization, regionalization.fallback);
110
+ return getDefaultLanguageForRegion(config, inferredLocale);
111
+ }
112
+ RegionsConfig.getDefaultLanguage = getDefaultLanguage;
113
+ })(RegionsConfig || (exports.RegionsConfig = RegionsConfig = {}));
@@ -0,0 +1,4 @@
1
+ import { Duration } from '../utils';
2
+ export type UIConfig = {
3
+ carouselInterval?: Duration;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export * from './AppConfig';
2
+ export * from './BrandConfig';
3
+ export * from './RegionsConfig';
4
+ export * from './UIConfig';
5
+ export * from './FeaturesConfig';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AppConfig"), exports);
18
+ __exportStar(require("./BrandConfig"), exports);
19
+ __exportStar(require("./RegionsConfig"), exports);
20
+ __exportStar(require("./UIConfig"), exports);
21
+ __exportStar(require("./FeaturesConfig"), exports);
@@ -0,0 +1,12 @@
1
+ export type ConsentCategory = 'necessary' | 'functionality' | 'security' | 'analytics' | 'advertisement';
2
+ export declare namespace ConsentCategory {
3
+ const values: ReadonlyArray<ConsentCategory>;
4
+ function filter(value: any): value is ConsentCategory;
5
+ type Choice = {
6
+ category: ConsentCategory;
7
+ accepted: boolean;
8
+ };
9
+ namespace Choice {
10
+ function filter(value: any): value is Choice;
11
+ }
12
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsentCategory = void 0;
4
+ // extension
5
+ var ConsentCategory;
6
+ (function (ConsentCategory) {
7
+ // values
8
+ ConsentCategory.values = [
9
+ 'necessary', 'functionality', 'security', 'analytics', 'advertisement'
10
+ ];
11
+ // helpers
12
+ function filter(value) {
13
+ return !!value
14
+ && typeof value === 'string'
15
+ && ConsentCategory.values.includes(value);
16
+ }
17
+ ConsentCategory.filter = filter;
18
+ let Choice;
19
+ (function (Choice) {
20
+ function filter(value) {
21
+ return !!value
22
+ && typeof value === 'object'
23
+ && 'category' in value && ConsentCategory.filter(value.category)
24
+ && 'accepted' in value && typeof value.accepted === 'boolean';
25
+ }
26
+ Choice.filter = filter;
27
+ })(Choice = ConsentCategory.Choice || (ConsentCategory.Choice = {}));
28
+ })(ConsentCategory || (exports.ConsentCategory = ConsentCategory = {}));
@@ -0,0 +1,15 @@
1
+ import { ConsentCategory } from './ConsentCategory';
2
+ export type ConsentService = 'functionality_storage' | 'personalization_storage' | 'security_storage' | 'analytics_storage' | 'ad_storage' | 'ad_user_data' | 'ad_personalization';
3
+ export declare namespace ConsentService {
4
+ const groupedValues: Readonly<Record<ConsentCategory, ReadonlyArray<ConsentService>>>;
5
+ const values: ReadonlyArray<ConsentService>;
6
+ function filter(value: any): value is ConsentService;
7
+ type Choice = {
8
+ category: ConsentCategory;
9
+ service: ConsentService;
10
+ accepted: boolean;
11
+ };
12
+ namespace Choice {
13
+ function filter(value: any): value is Choice;
14
+ }
15
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsentService = void 0;
4
+ const ConsentCategory_1 = require("./ConsentCategory");
5
+ // extension
6
+ var ConsentService;
7
+ (function (ConsentService) {
8
+ // values
9
+ ConsentService.groupedValues = {
10
+ necessary: [],
11
+ functionality: ['functionality_storage', 'personalization_storage'],
12
+ security: ['security_storage'],
13
+ analytics: ['analytics_storage'],
14
+ advertisement: ['ad_storage', 'ad_user_data', 'ad_personalization']
15
+ };
16
+ ConsentService.values = [
17
+ 'functionality_storage', 'personalization_storage',
18
+ 'security_storage',
19
+ 'analytics_storage',
20
+ 'ad_storage', 'ad_user_data', 'ad_personalization'
21
+ ];
22
+ // helpers
23
+ function filter(value) {
24
+ return !!value
25
+ && typeof value === 'string'
26
+ && ConsentService.values.includes(value);
27
+ }
28
+ ConsentService.filter = filter;
29
+ let Choice;
30
+ (function (Choice) {
31
+ function filter(value) {
32
+ return ConsentCategory_1.ConsentCategory.Choice.filter(value)
33
+ && 'service' in value && ConsentService.filter(value.service);
34
+ }
35
+ Choice.filter = filter;
36
+ })(Choice = ConsentService.Choice || (ConsentService.Choice = {}));
37
+ })(ConsentService || (exports.ConsentService = ConsentService = {}));
@@ -0,0 +1,2 @@
1
+ export * from './ConsentCategory';
2
+ export * from './ConsentService';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ConsentCategory"), exports);
18
+ __exportStar(require("./ConsentService"), exports);
@@ -0,0 +1,19 @@
1
+ import { IsometricErrorModule } from './IsometricErrorModule';
2
+ import { SerializedIsometricError } from './SerializedIsometricError';
3
+ export declare class IsometricError extends Error {
4
+ readonly moduleId: IsometricErrorModule.Id;
5
+ readonly cause?: Error | undefined;
6
+ constructor(args: IsometricError.ConstructorArgs);
7
+ serialize(): SerializedIsometricError;
8
+ }
9
+ export declare namespace IsometricError {
10
+ type ConstructorArgs = {
11
+ moduleId: IsometricErrorModule.Id;
12
+ message: string;
13
+ cause?: Error | undefined;
14
+ trace?: ((...args: any) => any) | undefined;
15
+ };
16
+ namespace ConstructorArgs {
17
+ type WithoutModuleId = Omit<ConstructorArgs, 'moduleId'>;
18
+ }
19
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsometricError = void 0;
4
+ // class
5
+ class IsometricError extends Error {
6
+ constructor(args) {
7
+ // construct base
8
+ super(args.message);
9
+ // link prototype chain
10
+ Object.setPrototypeOf(this, new.target.prototype);
11
+ // bind properties
12
+ const object = this;
13
+ this.name = object.constructor.name;
14
+ this.moduleId = args.moduleId;
15
+ this.cause = args.cause;
16
+ // bind stack trace (if provided)
17
+ if (args.trace) {
18
+ Error.captureStackTrace(this, args.trace);
19
+ }
20
+ }
21
+ serialize() {
22
+ const { moduleId, name, message } = this;
23
+ return {
24
+ moduleId,
25
+ name,
26
+ message
27
+ };
28
+ }
29
+ }
30
+ exports.IsometricError = IsometricError;
@@ -0,0 +1,11 @@
1
+ import { Tagged } from 'type-fest';
2
+ import { IsometricError } from './IsometricError';
3
+ import { SerializedIsometricError } from './SerializedIsometricError';
4
+ export interface IsometricErrorModule {
5
+ readonly id: IsometricErrorModule.Id;
6
+ deserialize(data: SerializedIsometricError): IsometricError | undefined;
7
+ }
8
+ export declare namespace IsometricErrorModule {
9
+ type Id = Tagged<string, 'nascent.IsometricErrorModule.Id'>;
10
+ type Constructor = new () => IsometricErrorModule;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import type { Callback } from '../types';
2
+ import { IsometricError } from './IsometricError';
3
+ import { IsometricErrorModule } from './IsometricErrorModule';
4
+ export declare namespace IsometricErrorUtils {
5
+ function registerModule(ModuleClass: IsometricErrorModule.Constructor): void;
6
+ function coerceError(error: any): IsometricError;
7
+ function deserializeError(data: any): IsometricError | undefined;
8
+ function checkResponse(response: Response, onError?: Callback<IsometricError>): Promise<void>;
9
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsometricErrorUtils = void 0;
4
+ const Value_1 = require("../utils/Value");
5
+ const api_1 = require("./api");
6
+ const IsometricError_1 = require("./IsometricError");
7
+ const SerializedIsometricError_1 = require("./SerializedIsometricError");
8
+ // namespace
9
+ var IsometricErrorUtils;
10
+ (function (IsometricErrorUtils) {
11
+ // constants
12
+ const modules = new Map();
13
+ // methods
14
+ function registerModule(ModuleClass) {
15
+ const module = new ModuleClass();
16
+ modules.set(module.id, module);
17
+ }
18
+ IsometricErrorUtils.registerModule = registerModule;
19
+ function coerceError(error) {
20
+ // skip if already isometric
21
+ if (error instanceof IsometricError_1.IsometricError) {
22
+ return error;
23
+ }
24
+ // or wrap error
25
+ else if (error instanceof Error) {
26
+ return new api_1.ServerError(error.message);
27
+ }
28
+ // or create generic error
29
+ else {
30
+ return new api_1.ServerError();
31
+ }
32
+ }
33
+ IsometricErrorUtils.coerceError = coerceError;
34
+ function deserializeError(data) {
35
+ // skip if it's not isometric
36
+ if (!SerializedIsometricError_1.SerializedIsometricError.filter(data)) {
37
+ console.debug('[IsometricErrorUtils/deserialize] data is not an error', data);
38
+ return undefined;
39
+ }
40
+ // or skip if there's no registered module
41
+ const module = modules.get(data.moduleId);
42
+ if (!module) {
43
+ console.debug('[IsometricErrorUtils/deserialize] module not found', data.moduleId);
44
+ return undefined;
45
+ }
46
+ const error = module.deserialize(data);
47
+ console.debug('[IsometricErrorUtils/deserialize] parsed error', { module, error });
48
+ // deserialize
49
+ return error;
50
+ }
51
+ IsometricErrorUtils.deserializeError = deserializeError;
52
+ async function checkResponse(response, onError) {
53
+ var _a;
54
+ // skip if response is good
55
+ if (response.ok) {
56
+ return;
57
+ }
58
+ const { bodyUsed, headers, type } = response;
59
+ console.debug('[IsometricErrorUtils] handling error', { type, bodyUsed, headers });
60
+ // throw network error if the request didn't even go through
61
+ let error;
62
+ if (response.type === 'error') {
63
+ error = new api_1.OfflineError();
64
+ }
65
+ // or try to extract from json
66
+ else {
67
+ const json = await response.json();
68
+ console.debug('[IsometricErrorUtils] transforming error', {
69
+ json,
70
+ isIso: SerializedIsometricError_1.SerializedIsometricError.filter(json.error)
71
+ });
72
+ const { error: errorData } = Value_1.Value.typeOf(json) === 'object'
73
+ ? json
74
+ : {};
75
+ error = (_a = deserializeError(errorData)) !== null && _a !== void 0 ? _a : new api_1.ServerError();
76
+ }
77
+ // perform callback (if any)
78
+ if (onError) {
79
+ onError(error);
80
+ }
81
+ // throw error
82
+ throw error;
83
+ }
84
+ IsometricErrorUtils.checkResponse = checkResponse;
85
+ })(IsometricErrorUtils || (exports.IsometricErrorUtils = IsometricErrorUtils = {}));
@@ -0,0 +1,10 @@
1
+ import { JsonObject } from 'type-fest';
2
+ import { IsometricErrorModule } from './IsometricErrorModule';
3
+ export type SerializedIsometricError = JsonObject & {
4
+ moduleId: IsometricErrorModule.Id;
5
+ name: string;
6
+ message: string;
7
+ };
8
+ export declare namespace SerializedIsometricError {
9
+ function filter(value: any): value is SerializedIsometricError;
10
+ }