inferred-types 0.45.0 → 0.45.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 (253) hide show
  1. package/dist/constants/Characters.d.ts +2 -0
  2. package/dist/constants/Characters.d.ts.map +1 -0
  3. package/dist/constants/Characters.js +5 -0
  4. package/dist/constants/NetworkConstants.d.ts.map +1 -1
  5. package/dist/constants/Phone.d.ts +8 -0
  6. package/dist/constants/Phone.d.ts.map +1 -0
  7. package/dist/constants/Phone.js +262 -0
  8. package/dist/constants/ProxmoxConstants.d.ts +2 -0
  9. package/dist/constants/ProxmoxConstants.d.ts.map +1 -0
  10. package/dist/constants/ProxmoxConstants.js +3 -0
  11. package/dist/constants/index.d.ts +3 -0
  12. package/dist/constants/index.d.ts.map +1 -1
  13. package/dist/constants/index.js +3 -0
  14. package/dist/constants/tsconfig.tsbuildinfo +1 -1
  15. package/dist/inferred-types/index.cjs +1091 -733
  16. package/dist/inferred-types/tsconfig.tsbuildinfo +1 -1
  17. package/dist/runtime/api/defineApi.d.ts +56 -0
  18. package/dist/runtime/api/defineApi.d.ts.map +1 -0
  19. package/dist/runtime/api/defineApi.js +97 -0
  20. package/dist/runtime/api/handleDoneFn.d.ts.map +1 -0
  21. package/dist/runtime/api/index.d.ts +3 -0
  22. package/dist/runtime/api/index.d.ts.map +1 -0
  23. package/dist/runtime/api/index.js +2 -0
  24. package/dist/runtime/boolean-logic/ifArrayPartial.d.ts +1 -1
  25. package/dist/runtime/boolean-logic/ifArrayPartial.d.ts.map +1 -1
  26. package/dist/runtime/boolean-logic/ifArrayPartial.js +1 -1
  27. package/dist/runtime/boolean-logic/ifLength.d.ts.map +1 -1
  28. package/dist/runtime/boolean-logic/ifScalar.d.ts.map +1 -1
  29. package/dist/runtime/boolean-logic/ifScalar.js +1 -1
  30. package/dist/runtime/boolean-logic/index.d.ts +0 -1
  31. package/dist/runtime/boolean-logic/index.d.ts.map +1 -1
  32. package/dist/runtime/boolean-logic/index.js +0 -1
  33. package/dist/runtime/dictionary/defineOptions.d.ts +26 -0
  34. package/dist/runtime/dictionary/defineOptions.d.ts.map +1 -0
  35. package/dist/runtime/dictionary/defineOptions.js +30 -0
  36. package/dist/runtime/dictionary/keysOf.d.ts +1 -1
  37. package/dist/runtime/dictionary/keysOf.d.ts.map +1 -1
  38. package/dist/runtime/errors/KindError.d.ts +2 -2
  39. package/dist/runtime/errors/KindError.d.ts.map +1 -1
  40. package/dist/runtime/functions/index.d.ts +1 -0
  41. package/dist/runtime/functions/index.d.ts.map +1 -1
  42. package/dist/runtime/functions/index.js +1 -0
  43. package/dist/runtime/functions/wrapFn.d.ts +2 -0
  44. package/dist/runtime/functions/wrapFn.d.ts.map +1 -0
  45. package/dist/runtime/functions/wrapFn.js +24 -0
  46. package/dist/runtime/index.d.ts +1 -1
  47. package/dist/runtime/index.d.ts.map +1 -1
  48. package/dist/runtime/index.js +1 -10
  49. package/dist/runtime/lists/find.d.ts +1 -1
  50. package/dist/runtime/lists/find.d.ts.map +1 -1
  51. package/dist/runtime/lists/intersection.d.ts.map +1 -1
  52. package/dist/runtime/lists/intersection.js +2 -1
  53. package/dist/runtime/literals/asPhoneNumber.d.ts +10 -0
  54. package/dist/runtime/literals/asPhoneNumber.d.ts.map +1 -0
  55. package/dist/runtime/literals/asPhoneNumber.js +62 -0
  56. package/dist/runtime/literals/index.d.ts +4 -0
  57. package/dist/runtime/literals/index.d.ts.map +1 -1
  58. package/dist/runtime/literals/index.js +4 -0
  59. package/dist/runtime/literals/retainChars.d.ts +16 -0
  60. package/dist/runtime/literals/retainChars.d.ts.map +1 -0
  61. package/dist/runtime/literals/retainChars.js +17 -0
  62. package/dist/runtime/literals/retainWhile.d.ts +11 -0
  63. package/dist/runtime/literals/retainWhile.d.ts.map +1 -0
  64. package/dist/runtime/literals/retainWhile.js +12 -0
  65. package/dist/runtime/literals/stripChars.d.ts +10 -0
  66. package/dist/runtime/literals/stripChars.d.ts.map +1 -0
  67. package/dist/runtime/literals/stripChars.js +11 -0
  68. package/dist/runtime/literals/stripLeading.d.ts +3 -3
  69. package/dist/runtime/literals/stripLeading.d.ts.map +1 -1
  70. package/dist/runtime/literals/stripLeading.js +5 -5
  71. package/dist/runtime/literals/unset.d.ts +8 -0
  72. package/dist/runtime/literals/unset.d.ts.map +1 -0
  73. package/dist/runtime/literals/unset.js +14 -0
  74. package/dist/runtime/meta/youtube-meta.d.ts +8 -1
  75. package/dist/runtime/meta/youtube-meta.d.ts.map +1 -1
  76. package/dist/runtime/meta/youtube-meta.js +50 -2
  77. package/dist/runtime/runtime-types/dict.d.ts +2 -2
  78. package/dist/runtime/runtime-types/dict.d.ts.map +1 -1
  79. package/dist/runtime/runtime-types/ip6Prefix.d.ts +1 -1
  80. package/dist/runtime/runtime-types/parse.d.ts +1 -1
  81. package/dist/runtime/runtime-types/shape-helpers/getTokenData.d.ts +1 -1
  82. package/dist/runtime/runtime-types/shape-helpers/getTokenName.d.ts +1 -1
  83. package/dist/runtime/runtime-types/shape.d.ts +1 -1
  84. package/dist/runtime/runtime-types/shape.js +1 -1
  85. package/dist/runtime/tsconfig.tsbuildinfo +1 -1
  86. package/dist/runtime/type-guards/api-tg.d.ts +33 -0
  87. package/dist/runtime/type-guards/api-tg.d.ts.map +1 -0
  88. package/dist/runtime/type-guards/api-tg.js +38 -0
  89. package/dist/runtime/type-guards/hasWhitespace.d.ts +7 -0
  90. package/dist/runtime/type-guards/hasWhitespace.d.ts.map +1 -0
  91. package/dist/runtime/type-guards/hasWhitespace.js +11 -0
  92. package/dist/runtime/type-guards/index.d.ts +7 -0
  93. package/dist/runtime/type-guards/index.d.ts.map +1 -1
  94. package/dist/runtime/type-guards/index.js +7 -0
  95. package/dist/runtime/type-guards/isConstant.d.ts +6 -0
  96. package/dist/runtime/type-guards/isConstant.d.ts.map +1 -1
  97. package/dist/runtime/type-guards/isConstant.js +12 -2
  98. package/dist/runtime/type-guards/isEmail.d.ts +7 -0
  99. package/dist/runtime/type-guards/isEmail.d.ts.map +1 -0
  100. package/dist/runtime/type-guards/isEmail.js +11 -0
  101. package/dist/runtime/type-guards/isPhoneNumber.d.ts +14 -0
  102. package/dist/runtime/type-guards/isPhoneNumber.d.ts.map +1 -0
  103. package/dist/runtime/type-guards/isPhoneNumber.js +26 -0
  104. package/dist/runtime/type-guards/isSpecificConstant.js +2 -3
  105. package/dist/runtime/type-guards/isTrimmable.d.ts +7 -0
  106. package/dist/runtime/type-guards/isTrimmable.d.ts.map +1 -0
  107. package/dist/runtime/type-guards/isTrimmable.js +9 -0
  108. package/dist/runtime/type-guards/isUnset.d.ts +18 -0
  109. package/dist/runtime/type-guards/isUnset.d.ts.map +1 -0
  110. package/dist/runtime/type-guards/isUnset.js +23 -0
  111. package/dist/runtime/type-guards/isUrl.d.ts +1 -1
  112. package/dist/runtime/type-guards/network-tg.d.ts +9 -3
  113. package/dist/runtime/type-guards/network-tg.d.ts.map +1 -1
  114. package/dist/runtime/type-guards/network-tg.js +10 -1
  115. package/dist/runtime/type-guards/repos.d.ts +2 -2
  116. package/dist/runtime/type-guards/youtube.d.ts +4 -2
  117. package/dist/runtime/type-guards/youtube.d.ts.map +1 -1
  118. package/dist/runtime/type-guards/youtube.js +13 -3
  119. package/dist/types/api/api.d.ts +96 -37
  120. package/dist/types/api/api.d.ts.map +1 -1
  121. package/dist/types/base-types/fns/EscapeFunction.d.ts +22 -0
  122. package/dist/types/base-types/fns/EscapeFunction.d.ts.map +1 -0
  123. package/dist/types/base-types/fns/OptionalParamFn.d.ts +30 -0
  124. package/dist/types/base-types/fns/OptionalParamFn.d.ts.map +1 -0
  125. package/dist/types/base-types/fns/index.d.ts +2 -0
  126. package/dist/types/base-types/fns/index.d.ts.map +1 -1
  127. package/dist/types/base-types/fns/index.js +2 -0
  128. package/dist/types/boolean-logic/branching/If.d.ts +2 -3
  129. package/dist/types/boolean-logic/branching/If.d.ts.map +1 -1
  130. package/dist/types/boolean-logic/branching/IfUnset.d.ts +12 -0
  131. package/dist/types/boolean-logic/branching/IfUnset.d.ts.map +1 -0
  132. package/dist/types/boolean-logic/branching/OnPass.d.ts +4 -3
  133. package/dist/types/boolean-logic/branching/OnPass.d.ts.map +1 -1
  134. package/dist/types/boolean-logic/branching/WhenNever.d.ts +11 -0
  135. package/dist/types/boolean-logic/branching/WhenNever.d.ts.map +1 -0
  136. package/dist/types/boolean-logic/branching/WhenNever.js +1 -0
  137. package/dist/types/boolean-logic/branching/index.d.ts +2 -0
  138. package/dist/types/boolean-logic/branching/index.d.ts.map +1 -1
  139. package/dist/types/boolean-logic/branching/index.js +2 -0
  140. package/dist/types/boolean-logic/combinators/Compare.d.ts +3 -3
  141. package/dist/types/boolean-logic/combinators/Compare.d.ts.map +1 -1
  142. package/dist/types/boolean-logic/combinators/Some.d.ts +8 -0
  143. package/dist/types/boolean-logic/combinators/Some.d.ts.map +1 -0
  144. package/dist/types/boolean-logic/combinators/Some.js +1 -0
  145. package/dist/types/boolean-logic/combinators/index.d.ts +1 -0
  146. package/dist/types/boolean-logic/combinators/index.d.ts.map +1 -1
  147. package/dist/types/boolean-logic/combinators/index.js +1 -0
  148. package/dist/types/boolean-logic/narrowing/AsDoneFn.d.ts +2 -2
  149. package/dist/types/boolean-logic/narrowing/AsDoneFn.d.ts.map +1 -1
  150. package/dist/types/boolean-logic/operators/ApiOperators.d.ts +11 -0
  151. package/dist/types/boolean-logic/operators/ApiOperators.d.ts.map +1 -0
  152. package/dist/types/boolean-logic/operators/ApiOperators.js +1 -0
  153. package/dist/types/boolean-logic/operators/HasSameValues.d.ts +4 -3
  154. package/dist/types/boolean-logic/operators/HasSameValues.d.ts.map +1 -1
  155. package/dist/types/boolean-logic/operators/IsGreaterThan.d.ts +2 -2
  156. package/dist/types/boolean-logic/operators/IsGreaterThan.d.ts.map +1 -1
  157. package/dist/types/boolean-logic/operators/IsUnset.d.ts +9 -0
  158. package/dist/types/boolean-logic/operators/IsUnset.d.ts.map +1 -0
  159. package/dist/types/boolean-logic/operators/IsUnset.js +1 -0
  160. package/dist/types/boolean-logic/operators/PhoneOperators.d.ts +33 -0
  161. package/dist/types/boolean-logic/operators/PhoneOperators.d.ts.map +1 -0
  162. package/dist/types/boolean-logic/operators/PhoneOperators.js +1 -0
  163. package/dist/types/boolean-logic/operators/index.d.ts +3 -0
  164. package/dist/types/boolean-logic/operators/index.d.ts.map +1 -1
  165. package/dist/types/boolean-logic/operators/index.js +3 -0
  166. package/dist/types/dictionary/Keys.d.ts +58 -4
  167. package/dist/types/dictionary/Keys.d.ts.map +1 -1
  168. package/dist/types/dictionary/KvFn.d.ts +2 -2
  169. package/dist/types/dictionary/KvFn.d.ts.map +1 -1
  170. package/dist/types/dictionary/MakeKeysOptional.d.ts +12 -3
  171. package/dist/types/dictionary/MakeKeysOptional.d.ts.map +1 -1
  172. package/dist/types/dictionary/MakeKeysRequired.d.ts +14 -0
  173. package/dist/types/dictionary/MakeKeysRequired.d.ts.map +1 -0
  174. package/dist/types/dictionary/MakeKeysRequired.js +1 -0
  175. package/dist/types/dictionary/OptionalKeys.d.ts +19 -4
  176. package/dist/types/dictionary/OptionalKeys.d.ts.map +1 -1
  177. package/dist/types/dictionary/OptionalKeys.js +1 -0
  178. package/dist/types/dictionary/RequiredKeys.d.ts +14 -6
  179. package/dist/types/dictionary/RequiredKeys.d.ts.map +1 -1
  180. package/dist/types/dictionary/Values.d.ts +2 -2
  181. package/dist/types/dictionary/Values.d.ts.map +1 -1
  182. package/dist/types/dictionary/index.d.ts +1 -2
  183. package/dist/types/dictionary/index.d.ts.map +1 -1
  184. package/dist/types/dictionary/index.js +1 -2
  185. package/dist/types/errors/KindError.d.ts +1 -1
  186. package/dist/types/errors/KindError.d.ts.map +1 -1
  187. package/dist/types/functions/FnFrom.d.ts +5 -0
  188. package/dist/types/functions/FnFrom.d.ts.map +1 -1
  189. package/dist/types/functions/{Fn.d.ts → FnWithDescription.d.ts} +2 -2
  190. package/dist/types/functions/FnWithDescription.d.ts.map +1 -0
  191. package/dist/types/functions/FnWithDescription.js +1 -0
  192. package/dist/types/functions/WrapperFn.d.ts +23 -0
  193. package/dist/types/functions/WrapperFn.d.ts.map +1 -0
  194. package/dist/types/functions/WrapperFn.js +1 -0
  195. package/dist/types/functions/index.d.ts +2 -1
  196. package/dist/types/functions/index.d.ts.map +1 -1
  197. package/dist/types/functions/index.js +2 -1
  198. package/dist/types/lists/ConvertSet.d.ts +2 -2
  199. package/dist/types/lists/ConvertSet.d.ts.map +1 -1
  200. package/dist/types/lists/Find.d.ts +7 -18
  201. package/dist/types/lists/Find.d.ts.map +1 -1
  202. package/dist/types/literals/DoneFnTuple.d.ts +3 -3
  203. package/dist/types/literals/DoneFnTuple.d.ts.map +1 -1
  204. package/dist/types/literals/Unset.d.ts +13 -0
  205. package/dist/types/literals/Unset.d.ts.map +1 -0
  206. package/dist/types/literals/Unset.js +1 -0
  207. package/dist/types/literals/index.d.ts +1 -0
  208. package/dist/types/literals/index.d.ts.map +1 -1
  209. package/dist/types/literals/index.js +1 -0
  210. package/dist/types/numeric-literals/NumberLike.d.ts +1 -1
  211. package/dist/types/numeric-literals/NumberLike.d.ts.map +1 -1
  212. package/dist/types/string-literals/Proxmox.d.ts +7 -0
  213. package/dist/types/string-literals/Proxmox.d.ts.map +1 -0
  214. package/dist/types/string-literals/Proxmox.js +1 -0
  215. package/dist/types/string-literals/StripLeading.d.ts +2 -2
  216. package/dist/types/string-literals/StripLeading.d.ts.map +1 -1
  217. package/dist/types/string-literals/StripUntil.d.ts +12 -0
  218. package/dist/types/string-literals/StripUntil.d.ts.map +1 -1
  219. package/dist/types/string-literals/character-sets/Whitespace.d.ts +3 -1
  220. package/dist/types/string-literals/character-sets/Whitespace.d.ts.map +1 -1
  221. package/dist/types/string-literals/character-sets/index.d.ts +1 -0
  222. package/dist/types/string-literals/character-sets/index.d.ts.map +1 -1
  223. package/dist/types/string-literals/character-sets/index.js +1 -0
  224. package/dist/types/string-literals/character-sets/phone.d.ts +192 -0
  225. package/dist/types/string-literals/character-sets/phone.d.ts.map +1 -0
  226. package/dist/types/string-literals/character-sets/phone.js +1 -0
  227. package/dist/types/tsconfig.tsbuildinfo +1 -1
  228. package/dist/types/type-conversion/ReduceValues.d.ts +19 -0
  229. package/dist/types/type-conversion/ReduceValues.d.ts.map +1 -0
  230. package/dist/types/type-conversion/ReduceValues.js +1 -0
  231. package/dist/types/type-conversion/ReturnValues.d.ts +10 -6
  232. package/dist/types/type-conversion/ReturnValues.d.ts.map +1 -1
  233. package/dist/types/type-conversion/Trim.d.ts +3 -1
  234. package/dist/types/type-conversion/Trim.d.ts.map +1 -1
  235. package/dist/types/type-conversion/UnionFilter.d.ts +2 -2
  236. package/dist/types/type-conversion/UnionFilter.d.ts.map +1 -1
  237. package/dist/types/type-conversion/form-fields.d.ts +5 -1
  238. package/dist/types/type-conversion/form-fields.d.ts.map +1 -1
  239. package/dist/types/type-conversion/index.d.ts +1 -0
  240. package/dist/types/type-conversion/index.d.ts.map +1 -1
  241. package/dist/types/type-conversion/index.js +1 -0
  242. package/package.json +17 -11
  243. package/dist/runtime/boolean-logic/handleDoneFn.d.ts.map +0 -1
  244. package/dist/types/dictionary/PrivateKeys.d.ts +0 -17
  245. package/dist/types/dictionary/PrivateKeys.d.ts.map +0 -1
  246. package/dist/types/dictionary/PublicKeys.d.ts +0 -10
  247. package/dist/types/dictionary/PublicKeys.d.ts.map +0 -1
  248. package/dist/types/functions/Fn.d.ts.map +0 -1
  249. /package/dist/runtime/{boolean-logic → api}/handleDoneFn.d.ts +0 -0
  250. /package/dist/runtime/{boolean-logic → api}/handleDoneFn.js +0 -0
  251. /package/dist/types/{dictionary/PrivateKeys.js → base-types/fns/EscapeFunction.js} +0 -0
  252. /package/dist/types/{dictionary/PublicKeys.js → base-types/fns/OptionalParamFn.js} +0 -0
  253. /package/dist/types/{functions/Fn.js → boolean-logic/branching/IfUnset.js} +0 -0
@@ -0,0 +1,56 @@
1
+ import { Api, ApiCallback, ApiEscape, AsApi, AsEscapeFunction, AsOptionalParamFn, Dictionary, Narrowable, OnPass, TypedFunction } from "../../types/index";
2
+ /**
3
+ * **asEscapeFunction**`(fn)`
4
+ *
5
+ * Accepts a zero-parameter function as an escape function.
6
+ */
7
+ export declare const asEscapeFunction: <TFn extends () => Narrowable>(fn: TFn) => AsEscapeFunction<TFn>;
8
+ /**
9
+ * **asOptionalParamFunction**`(fn)`
10
+ *
11
+ * Marks a function as being optionally callable with _no parameters_.
12
+ */
13
+ export declare const asOptionalParamFunction: <TFn extends (() => any) | ((p1?: any, p2?: any, p3?: any, p4?: any) => any)>(fn: TFn) => AsOptionalParamFn<TFn>;
14
+ /**
15
+ * **asApi**`(surface)`
16
+ *
17
+ * Validates an API surface as a stateless API and returns it as `Api<Surface>` if
18
+ * it qualifies, otherwise results in an ErrorCondition.
19
+ */
20
+ export declare const asApi: <T extends Dictionary | TypedFunction>(api: T) => OnPass<AsApi<T>, Api<T>>;
21
+ /**
22
+ * **asCallbackProp**`(cb)`
23
+ *
24
+ * Defines a callback _type_ for a property in a function.
25
+ *
26
+ * **Note:** you will often _extend_ this type to understand the return type
27
+ */
28
+ export declare const asCallbackProp: <TParams extends readonly Narrowable[]>(...args: TParams) => unknown;
29
+ /**
30
+ * **getEscapeFunction**`(api)`
31
+ *
32
+ * Get's the escape function from a properly validated `Api<S>` (which
33
+ * is known to have an escape function).
34
+ */
35
+ export declare const getEscapeFunction: <TApi extends Api>(api: TApi) => ApiEscape<TApi> & (() => unknown);
36
+ /**
37
+ * **asApiCallback**`(api)`
38
+ *
39
+ * Converts a defined `Api` into a callback function which receives the API as an
40
+ * input to be used for a response.
41
+ */
42
+ export declare const asApiCallback: <TApi extends Api>(api: TApi) => ApiCallback<TApi>;
43
+ /**
44
+ * **asHandledApiCallback**`(api)`
45
+ *
46
+ * Takes an `Api` definition and converts it into a callback with a ApiHandler used.
47
+ *
48
+ * - if no handler is explicitly provided then the _default handler_ will be used
49
+ * - the default handler is responsible for:
50
+ * - ensuring that if an uncalled part of the API is returned using the **escape function**
51
+ * to provide a more meaningful response
52
+ * - if a function which is marked as being an `OptionalParamFn` is returned then it will
53
+ * be _called_ rather than leaving it as a function
54
+ */
55
+ export declare const asHandledApiCallback: <T extends Api>(api: T, handler?: TypedFunction) => void;
56
+ //# sourceMappingURL=defineApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineApi.d.ts","sourceRoot":"","sources":["../../../src/runtime/api/defineApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,WAAW,EACX,SAAS,EAET,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACd,0BAAwB;AAczB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,qBACT,UAAU,MACxB,GAAG,0BAA8E,CAAC;AAGxF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,sBACf,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,OAAM,GAAG,KAAK,GAAG,OACrE,GAAG,2BAAuF,CAAC;AAEjG;;;;;GAKG;AACH,eAAO,MAAM,KAAK,8CAA+C,CAAC,KAAG,OAAO,MAAM,CAAC,CAAC,EAAC,IAAI,CAAC,CAAC,CAMlD,CAAC;AAK1C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mDAEhB,OAAO,YAAoB,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,0BAGvB,IAAI,8BAYgC,OAAO,CACjD,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0BAEnB,IAAI,sBAAY,CAAC;AAGxB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,uBAG1B,CAAC,YACI,aAAa,SAKxB,CAAA"}
@@ -0,0 +1,97 @@
1
+ import { isApiSurface, isEscapeFunction, isFunction, isObject, } from "../index.js";
2
+ import { isApi, createErrorCondition, createFnWithProps } from "../index.js";
3
+ import { Never } from "../../constants/Never.js";
4
+ /**
5
+ * **asEscapeFunction**`(fn)`
6
+ *
7
+ * Accepts a zero-parameter function as an escape function.
8
+ */
9
+ export const asEscapeFunction = (fn) => createFnWithProps(fn, { escape: true });
10
+ /**
11
+ * **asOptionalParamFunction**`(fn)`
12
+ *
13
+ * Marks a function as being optionally callable with _no parameters_.
14
+ */
15
+ export const asOptionalParamFunction = (fn) => createFnWithProps(fn, { optionalParams: true });
16
+ /**
17
+ * **asApi**`(surface)`
18
+ *
19
+ * Validates an API surface as a stateless API and returns it as `Api<Surface>` if
20
+ * it qualifies, otherwise results in an ErrorCondition.
21
+ */
22
+ export const asApi = (api) => (isApi(api)
23
+ ? api
24
+ : isApiSurface(api)
25
+ ? { _kind: "api", surface: api }
26
+ : createErrorCondition("invalid-api"));
27
+ // TODO: not implemented
28
+ /**
29
+ * **asCallbackProp**`(cb)`
30
+ *
31
+ * Defines a callback _type_ for a property in a function.
32
+ *
33
+ * **Note:** you will often _extend_ this type to understand the return type
34
+ */
35
+ export const asCallbackProp = (...args) => args;
36
+ /**
37
+ * **getEscapeFunction**`(api)`
38
+ *
39
+ * Get's the escape function from a properly validated `Api<S>` (which
40
+ * is known to have an escape function).
41
+ */
42
+ export const getEscapeFunction = (api) => {
43
+ const surface = api.surface;
44
+ return (isFunction(surface) && "escape" in surface && surface.escape === true
45
+ ? surface
46
+ : isObject(surface)
47
+ ? surface[Object.keys(surface).find(k => isEscapeFunction(surface[k]))]
48
+ : Never);
49
+ };
50
+ /**
51
+ * **defaultApiHandler**
52
+ *
53
+ * A handler which will automatically call:
54
+ *
55
+ * - a **optional parameter function** when the function is returned by user without a call to it
56
+ * - the **escape function** when an Api Surface is returned instead of value from the API
57
+ *
58
+ * All other user values are returned "as is" including a function which is not an
59
+ * _optional parameter function_ or an _escape function_.
60
+ */
61
+ const defaultApiHandler = (_api) => {
62
+ // const esc = getEscapeFunction(api);
63
+ return (_result) => {
64
+ };
65
+ };
66
+ /** API callback */
67
+ const cb = (api) => (cb) => {
68
+ try {
69
+ return cb(api.surface);
70
+ }
71
+ catch (e) {
72
+ throw new Error("oops");
73
+ }
74
+ };
75
+ /**
76
+ * **asApiCallback**`(api)`
77
+ *
78
+ * Converts a defined `Api` into a callback function which receives the API as an
79
+ * input to be used for a response.
80
+ */
81
+ export const asApiCallback = (api) => cb(api);
82
+ /**
83
+ * **asHandledApiCallback**`(api)`
84
+ *
85
+ * Takes an `Api` definition and converts it into a callback with a ApiHandler used.
86
+ *
87
+ * - if no handler is explicitly provided then the _default handler_ will be used
88
+ * - the default handler is responsible for:
89
+ * - ensuring that if an uncalled part of the API is returned using the **escape function**
90
+ * to provide a more meaningful response
91
+ * - if a function which is marked as being an `OptionalParamFn` is returned then it will
92
+ * be _called_ rather than leaving it as a function
93
+ */
94
+ export const asHandledApiCallback = (api, handler) => {
95
+ let _h = handler ? handler : defaultApiHandler;
96
+ let _cb = asApiCallback(api);
97
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleDoneFn.d.ts","sourceRoot":"","sources":["../../../src/runtime/api/handleDoneFn.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,uCAIlB,IAAI,iBACK,OAAO,QAWtB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './defineApi';
2
+ export * from "./handleDoneFn";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./defineApi.js";
2
+ export * from "./handleDoneFn.js";
@@ -1,3 +1,3 @@
1
1
  import { Narrowable } from "../../types/index";
2
- export declare function ifArrayPartial<T extends Narrowable>(): <IF extends Narrowable, ELSE extends Narrowable>(isAnArray: <N extends T & readonly unknown[]>(arr: N) => IF, isNotAnArray: <N_1 extends Exclude<T, unknown[] | readonly unknown[]>>(nonArr: N_1) => ELSE) => <V extends T>(val: V) => import("../../types/index").IsArray<V> extends true ? IF : ELSE;
2
+ export declare function ifArrayPartial<T extends Narrowable>(): <IF extends Narrowable, ELSE extends Narrowable>(isAnArray: <N extends T & readonly unknown[]>(arr: N) => IF, isNotAnArray: <N_1 extends Exclude<T, readonly unknown[] | unknown[]>>(nonArr: N_1) => ELSE) => <V extends T>(val: V) => import("../../types/index").IsArray<V> extends true ? IF : ELSE;
3
3
  //# sourceMappingURL=ifArrayPartial.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ifArrayPartial.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifArrayPartial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,0BAAwB;AAI7C,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,+GAEU,EAAE,yFACwB,IAAI,wBAE7D,CAAC,qEAE9B"}
1
+ {"version":3,"file":"ifArrayPartial.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifArrayPartial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,0BAAwB;AAK7C,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,+GAEU,EAAE,yFACwB,IAAI,wBAE7D,CAAC,qEAE9B"}
@@ -1,4 +1,4 @@
1
- import { ifArray } from "../index.js";
1
+ import { ifArray } from "./ifArray.js";
2
2
  export function ifArrayPartial() {
3
3
  return (isAnArray, isNotAnArray) => {
4
4
  return (val) => ifArray(val, isAnArray, isNotAnArray);
@@ -1 +1 @@
1
- {"version":3,"file":"ifLength.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,0BAAwB;AAEpF;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,KAAK,SAAS,SAAS,OAAO,EAAE,EAChC,IAAI,SAAS,MAAM,EACnB,EAAE,SAAS,UAAU,GAAG,KAAK,EAC7B,IAAI,SAAS,UAAU,GAAG,KAAK,EAE/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EACzE,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAC,CAAC,KAAK,IAAI,mCAQnF"}
1
+ {"version":3,"file":"ifLength.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifLength.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,KAAK,EACN,0BAAwB;AAEzB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,KAAK,SAAS,SAAS,OAAO,EAAE,EAChC,IAAI,SAAS,MAAM,EACnB,EAAE,SAAS,UAAU,GAAG,KAAK,EAC7B,IAAI,SAAS,UAAU,GAAG,KAAK,EAE/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EACzE,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAC,CAAC,KAAK,IAAI,mCAQnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ifScalar.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifScalar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,0BAAwB;AAI/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,UAAU,EACpB,GAAG,SAAS,UAAU,EACtB,KAAK,SAAS,UAAU,EAExB,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,CACV,CAAC,SAAS,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,EAAE,CAAC,EACxD,CAAC,EAAE,CAAC,KAAK,GAAG,EACd,WAAW,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,+CAQ3D"}
1
+ {"version":3,"file":"ifScalar.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifScalar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,EAAE,EACF,QAAQ,EACR,UAAU,EACV,MAAM,EACP,0BAAwB;AAKzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,UAAU,EACpB,GAAG,SAAS,UAAU,EACtB,KAAK,SAAS,UAAU,EAExB,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,CACV,CAAC,SAAS,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,EAAE,CAAC,EACxD,CAAC,EAAE,CAAC,KAAK,GAAG,EACd,WAAW,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,+CAQ3D"}
@@ -1,4 +1,4 @@
1
- import { isScalar } from "../index.js";
1
+ import { isScalar } from "../type-guards/isScalar.js";
2
2
  /**
3
3
  * **ifScalar**(value, ifCallback, notCallback)
4
4
  *
@@ -16,5 +16,4 @@ export * from "./ifFalse";
16
16
  export * from "./ifChar";
17
17
  export * from "./ifUndefined";
18
18
  export * from "./ifArrayPartial";
19
- export * from "./handleDoneFn";
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
@@ -16,4 +16,3 @@ export * from "./ifFalse.js";
16
16
  export * from "./ifChar.js";
17
17
  export * from "./ifUndefined.js";
18
18
  export * from "./ifArrayPartial.js";
19
- export * from "./handleDoneFn.js";
@@ -0,0 +1,26 @@
1
+ import { Dictionary, MakeKeysRequired, RequiredKeys } from "../../types/index";
2
+ export type UserOptions<TDefn extends Dictionary, TReq extends ((string | symbol) & keyof TDefn)> = TReq extends "" ? <T extends Partial<TDefn>, R extends TDefn>(opt?: T) => R & {
3
+ param: MakeKeysRequired<Partial<TDefn>, TReq>;
4
+ } : TReq extends readonly (keyof TDefn)[] ? <T extends MakeKeysRequired<Partial<TDefn>, TReq>, R extends TDefn>(opt: T) => R & {
5
+ param: MakeKeysRequired<Partial<TDefn>, TReq>;
6
+ } : never;
7
+ export type AsUserOptions<TDefn extends Dictionary, _TDefaults extends Partial<TDefn>> = UserOptions<TDefn, RequiredKeys<TDefn>>;
8
+ /**
9
+ * **defineOptions**`<T>(def_values?: () => { .. }) → UserOptions<T, TReq>`
10
+ *
11
+ * Defines:
12
+ * 1. a set of options,
13
+ * 2. allows default values to be assigned,
14
+ * 3. then provides
15
+ * a type for user input which makes all properties that were optional or have
16
+ * a default value be optional while also providing a type-strong merge function
17
+ * to merge in their results.
18
+ * ```ts
19
+ * // {
20
+ * // userOptions: {width?: number; height: number}},
21
+ * // merge<U>(user: U) => T
22
+ * // }
23
+ * const opts = defineOptions<{width: number; height: number}() => ({width: 640});
24
+ * ```
25
+ */
26
+ //# sourceMappingURL=defineOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineOptions.d.ts","sourceRoot":"","sources":["../../../src/runtime/dictionary/defineOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGV,gBAAgB,EAChB,YAAY,EACb,0BAAuB;AAMxB,MAAM,MAAM,WAAW,CACrB,KAAK,SAAS,UAAU,EACxB,IAAI,SAAS,CAAC,CAAC,MAAM,GAAC,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,IAC1C,IAAI,SAAS,EAAE,GACjB,CACE,CAAC,SAAS,OAAO,CAAC,KAAK,CAAC,EACxB,CAAC,SAAS,KAAK,EACf,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;CAAE,GACnE,IAAI,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GACrC,CACE,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAChD,CAAC,SAAS,KAAK,EACf,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;CAAE,GAClE,KAAK,CAAC;AAGR,MAAM,MAAM,aAAa,CACvB,KAAK,SAAS,UAAU,EACxB,UAAU,SAAS,OAAO,CAAC,KAAK,CAAC,IAC/B,WAAW,CACf,KAAK,EACL,YAAY,CAAC,KAAK,CAAC,CAClB,CAAC;AAiBF;;;;;;;;;;;;;;;;;GAiBG"}
@@ -0,0 +1,30 @@
1
+ import { createFnWithProps, } from "../index.js";
2
+ const _userOptions = (def_values) => createFnWithProps((opt) => {
3
+ return {
4
+ ...def_values,
5
+ opt
6
+ };
7
+ }, { param: null });
8
+ /**
9
+ * **defineOptions**`<T>(def_values?: () => { .. }) → UserOptions<T, TReq>`
10
+ *
11
+ * Defines:
12
+ * 1. a set of options,
13
+ * 2. allows default values to be assigned,
14
+ * 3. then provides
15
+ * a type for user input which makes all properties that were optional or have
16
+ * a default value be optional while also providing a type-strong merge function
17
+ * to merge in their results.
18
+ * ```ts
19
+ * // {
20
+ * // userOptions: {width?: number; height: number}},
21
+ * // merge<U>(user: U) => T
22
+ * // }
23
+ * const opts = defineOptions<{width: number; height: number}() => ({width: 640});
24
+ * ```
25
+ */
26
+ // export const defineOptions = <
27
+ // T extends Dictionary
28
+ // >(a: ({defaults: (<D extends Partial<T>>() => D)): void) => {
29
+ // return userOptions(cb());
30
+ // };
@@ -8,5 +8,5 @@ import type { Container, Keys } from "../../types/index";
8
8
  * `readonly ["value"]` as the keys array when detected rather than reporting
9
9
  * on props like `__v_isRef`, etc.
10
10
  */
11
- export declare function keysOf<TContainer extends Container>(container: TContainer): Keys<TContainer>;
11
+ export declare function keysOf<TContainer extends Container>(container: TContainer): Keys<TContainer> & readonly (keyof TContainer)[];
12
12
  //# sourceMappingURL=keysOf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keysOf.d.ts","sourceRoot":"","sources":["../../../src/runtime/dictionary/keysOf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,0BAAwB;AAIvD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,UAAU,SAAS,SAAS,EACjD,SAAS,EAAE,UAAU,oBAatB"}
1
+ {"version":3,"file":"keysOf.d.ts","sourceRoot":"","sources":["../../../src/runtime/dictionary/keysOf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,0BAAwB;AAIvD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,UAAU,SAAS,SAAS,EACjD,SAAS,EAAE,UAAU,oDAatB"}
@@ -1,4 +1,4 @@
1
- import { KindErrorDefn } from "../../types/index";
1
+ import { KindErrorDefn, Unset } from "../../types/index";
2
2
  /**
3
3
  * **KindError**
4
4
  *
@@ -23,5 +23,5 @@ import { KindErrorDefn } from "../../types/index";
23
23
  * BadJuju("oh my god!", { flavor: "strawberry"})
24
24
  * ```
25
25
  */
26
- export declare const kindError: <K extends string, C extends Record<string, unknown> = {}>(kind: K, _defineContext?: C) => KindErrorDefn<K, C>;
26
+ export declare const kindError: <K extends string, C extends Record<string, unknown> | Unset = Unset>(kind: K, _defineContext?: C) => KindErrorDefn<K, C>;
27
27
  //# sourceMappingURL=KindError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KindError.d.ts","sourceRoot":"","sources":["../../../src/runtime/errors/KindError.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,aAAa,EAAE,0BAAwB;AAGzF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,mEAId,CAAC,mBACU,CAAC,KACjB,cAAc,CAAC,EAAC,CAAC,CAkBnB,CAAA"}
1
+ {"version":3,"file":"KindError.d.ts","sourceRoot":"","sources":["../../../src/runtime/errors/KindError.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EACb,KAAK,EACN,0BAAwB;AAGzB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,8EAId,CAAC,mBACU,CAAC,KACjB,cAAc,CAAC,EAAC,CAAC,CAkBnB,CAAA"}
@@ -1,2 +1,3 @@
1
1
  export * from "./fnMeta";
2
+ export * from "./wrapFn";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from "./fnMeta.js";
2
+ export * from "./wrapFn.js";
@@ -0,0 +1,2 @@
1
+ export declare const wrapFn: "NOT IMPLEMENTED";
2
+ //# sourceMappingURL=wrapFn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapFn.d.ts","sourceRoot":"","sources":["../../../src/runtime/functions/wrapFn.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,MAAM,mBAA6B,CAAC"}
@@ -0,0 +1,24 @@
1
+ // import { FnFrom } from "src/types/index";
2
+ // import { identity } from "../literals";
3
+ // export const wrapFn = <
4
+ // TInteriorFn extends TypedFunction,
5
+ // >(fn: TInteriorFn) => {
6
+ // return <
7
+ // TWrap extends <I extends ReturnType<TInteriorFn>>(input: I) => unknown
8
+ // >(wrap: TWrap) => <F extends Parameters<TInteriorFn>>(...input: F) => {
9
+ // const interior = fn(input) as ReturnType<TInteriorFn>;
10
+ // return wrap(interior) as ReturnType<TWrap>
11
+ // }
12
+ // };
13
+ // export const wrapFn = <
14
+ // TWrap extends FnFrom<[any]>,
15
+ // >(wrap: TWrap) => {
16
+ // return <TInterior extends (...args: any[]) => Parameters<TWrap>[0]>(fn: TInterior) => {
17
+ // return <TFn extends Parameters<TInterior>>(...args: TFn) => {
18
+ // const interior = identity(fn(...args) as ReturnType<TInterior>) as ()=>ReturnType<TInterior>;
19
+ // const wrapped = wrap(interior()) as ReturnType<TWrap>;
20
+ // return wrapped;
21
+ // }
22
+ // }
23
+ // };
24
+ export const wrapFn = "NOT IMPLEMENTED";
@@ -1,4 +1,4 @@
1
- export * from "./boolean-logic/index";
1
+ export * from "./api/index";
2
2
  export * from "./combinators/index";
3
3
  export * from "./dictionary/index";
4
4
  export * from "./errors/index";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AASA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAA"}
@@ -1,10 +1,4 @@
1
- // #autoindex
2
- // #region auto-indexed files
3
- // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
4
- // hash-code: 9dd9ac96
5
- // file exports
6
- // directory exports
7
- export * from "./boolean-logic/index.js";
1
+ export * from "./api/index.js";
8
2
  export * from "./combinators/index.js";
9
3
  export * from "./dictionary/index.js";
10
4
  export * from "./errors/index.js";
@@ -19,6 +13,3 @@ export * from "./sets/index.js";
19
13
  export * from "./type-conversion/index.js";
20
14
  export * from "./type-guards/index.js";
21
15
  export * from "./vuejs/index.js";
22
- // #endregion auto-indexed files
23
- // see https://github.com/inocan-group/do-devops/docs/autoindex.md
24
- // for more info
@@ -4,7 +4,7 @@ import { Find, FromDefn, Narrowable, ShapeCallback, Tuple } from "../../types/in
4
4
  *
5
5
  * A configured utility designed to find elements in a list.
6
6
  */
7
- export type Finder<TList extends Tuple, TDeref extends string | number | null> = <TExtends extends Narrowable | ShapeCallback>(value: TExtends) => Find<TList, FromDefn<TExtends>, TDeref>;
7
+ export type Finder<TList extends Tuple, TDeref extends string | number | null> = <TExtends extends Narrowable | ShapeCallback>(value: TExtends) => Find<TList, "equals", FromDefn<TExtends>, TDeref>;
8
8
  /**
9
9
  * **find**(list, [deref]) => (value) => el | undefined
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/runtime/lists/find.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,KAAK,EACN,0BAAwB;AAIzB;;;;GAIG;AACH,MAAM,MAAM,MAAM,CAChB,KAAK,SAAS,KAAK,EACnB,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,IACnC,CAAC,QAAQ,SAAS,UAAU,GAAG,aAAa,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CACxE,KAAK,EACL,QAAQ,CAAC,QAAQ,CAAC,EAClB,MAAM,CACP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,yFAIT,KAAK,UACJ,MAAM,KACZ,OAAO,KAAK,EAAE,MAAM,CAYtB,CAAC"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/runtime/lists/find.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,KAAK,EACN,0BAAwB;AAIzB;;;;GAIG;AACH,MAAM,MAAM,MAAM,CAChB,KAAK,SAAS,KAAK,EACnB,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,IACnC,CAAC,QAAQ,SAAS,UAAU,GAAG,aAAa,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CACxE,KAAK,EACL,QAAQ,EACR,QAAQ,CAAC,QAAQ,CAAC,EAClB,MAAM,CACP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,yFAIT,KAAK,UACJ,MAAM,KACZ,OAAO,KAAK,EAAE,MAAM,CAYtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../../src/runtime/lists/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,YAAY,EAAG,0BAAwB;AA2ChE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,uGAKpB,CAAC,KACD,CAAC,UACG,MAAM,KACZ,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM,CAM3B,CAAC"}
1
+ {"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../../src/runtime/lists/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,YAAY,EAAG,0BAAwB;AA4ChE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,uGAKpB,CAAC,KACD,CAAC,UACG,MAAM,KACZ,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM,CAM3B,CAAC"}
@@ -1,4 +1,5 @@
1
- import { isIndexable, getEach, ifNotNull, get } from "../index.js";
1
+ import { isIndexable, getEach, get } from "../index.js";
2
+ import { ifNotNull } from "../boolean-logic/ifNotNull.js";
2
3
  function intersectWithOffset(a, b, deref) {
3
4
  const aIndexable = a.every(i => isIndexable(i));
4
5
  const bIndexable = b.every(i => isIndexable(i));
@@ -0,0 +1,10 @@
1
+ import { RemovePhoneCountryCode, GetPhoneCountryCode, PhoneNumber, ToPhoneFormat } from "../../types/index";
2
+ export declare const getPhoneCountryCode: <T extends string>(phone: T) => GetPhoneCountryCode<T>;
3
+ export declare const removePhoneCountryCode: <T extends string>(phone: T) => RemovePhoneCountryCode<T>;
4
+ /**
5
+ * **asPhoneNumber**`(phone, format)`
6
+ *
7
+ * Receives a phone number and returns it as a well formatted version.
8
+ */
9
+ export declare const asPhoneNumber: <T extends string, F extends "Dashed (e.g., 456-555-1212)" | "Dotted (e.g., 456.555.1212)" | "ParaSpaced (e.g., (456) 555 1212)" | "ParaDashed (e.g., (456) 555-1212)">(phone: T & PhoneNumber<T>, format?: F) => ToPhoneFormat<T, F>;
10
+ //# sourceMappingURL=asPhoneNumber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asPhoneNumber.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/asPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAe,WAAW,EAAE,aAAa,EAAE,0BAAwB;AAKvH,eAAO,MAAM,mBAAmB,4BACvB,CAAC,2BAUT,CAAA;AAED,eAAO,MAAM,sBAAsB,4BAE1B,CAAC,8BAUT,CAAA;AA2BD;;;;GAIG;AACH,eAAO,MAAM,aAAa,iLAIjB,CAAC,GAAG,YAAY,CAAC,CAAC,WACjB,CAAC,wBAyBV,CAAA"}
@@ -0,0 +1,62 @@
1
+ import { asChars, isPhoneNumber, retainWhile, stripChars, stripLeading } from "../index.js";
2
+ import { NUMERIC_CHAR } from "../../constants/NumericChar.js";
3
+ export const getPhoneCountryCode = (phone) => {
4
+ return (phone.trim().startsWith("+") || phone.trim().startsWith("00")
5
+ ? retainWhile(stripLeading(stripLeading(phone.trim(), "+"), "00"), ...NUMERIC_CHAR)
6
+ : "");
7
+ };
8
+ export const removePhoneCountryCode = (phone) => {
9
+ const countryCode = getPhoneCountryCode(phone);
10
+ return (countryCode !== ""
11
+ ? stripLeading(stripLeading(phone.trim(), "+", "00"), countryCode).trim()
12
+ : phone.trim());
13
+ };
14
+ const convert = (countryCode, phone, delimiter, para) => {
15
+ const parts = stripChars(phone, "(", ")").trim().split(/[-. ]/);
16
+ const isRegional = parts.length === 2 ? true : false;
17
+ const isCountry = parts.length === 3 ? true : false;
18
+ const isShortCode = parts.length === 1 && asChars(phone).length < 7 ? true : false;
19
+ const replacement = isShortCode
20
+ ? phone
21
+ : isRegional
22
+ ? parts.join(delimiter)
23
+ : isCountry && para
24
+ ? `(${parts[0]}) ${parts.slice(1).join(delimiter)}`
25
+ : isCountry
26
+ ? parts.join(delimiter)
27
+ : undefined;
28
+ if (!replacement) {
29
+ throw new Error(`invalid phone number: ${phone}. Unable to parse!`);
30
+ }
31
+ return countryCode === ""
32
+ ? replacement
33
+ : `+${countryCode} ${replacement}`;
34
+ };
35
+ /**
36
+ * **asPhoneNumber**`(phone, format)`
37
+ *
38
+ * Receives a phone number and returns it as a well formatted version.
39
+ */
40
+ export const asPhoneNumber = (phone, format = "Dotted (e.g., 456.555.1212)") => {
41
+ if (!isPhoneNumber(phone)) {
42
+ throw new Error(`Invalid phone number presented to asPhoneNumber(phone,format)!`);
43
+ }
44
+ const countryCode = getPhoneCountryCode(phone);
45
+ const remaining = removePhoneCountryCode(phone);
46
+ let result;
47
+ switch (format) {
48
+ case "Dashed (e.g., 456-555-1212)":
49
+ result = convert(countryCode, remaining, "-", false);
50
+ break;
51
+ case "Dotted (e.g., 456.555.1212)":
52
+ result = convert(countryCode, remaining, ".", false);
53
+ break;
54
+ case "ParaDashed (e.g., (456) 555-1212)":
55
+ result = convert(countryCode, remaining, "-", true);
56
+ break;
57
+ case "ParaSpaced (e.g., (456) 555 1212)":
58
+ result = convert(countryCode, remaining, " ", true);
59
+ break;
60
+ }
61
+ return result;
62
+ };
@@ -32,4 +32,8 @@ export * from "./toUppercase";
32
32
  export * from "./toNumericArray";
33
33
  export * from "./truncate";
34
34
  export * from "./takeNumericCharacters";
35
+ export * from "./retainChars";
36
+ export * from "./stripChars";
37
+ export * from "./retainWhile";
38
+ export * from "./asPhoneNumber";
35
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/index.ts"],"names":[],"mappings":"AAMA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/index.ts"],"names":[],"mappings":"AAMA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
@@ -37,6 +37,10 @@ export * from "./toUppercase.js";
37
37
  export * from "./toNumericArray.js";
38
38
  export * from "./truncate.js";
39
39
  export * from "./takeNumericCharacters.js";
40
+ export * from "./retainChars.js";
41
+ export * from "./stripChars.js";
42
+ export * from "./retainWhile.js";
43
+ export * from "./asPhoneNumber.js";
40
44
  // #endregion auto-indexed files
41
45
  // see https://github.com/inocan-group/do-devops/docs/autoindex.md
42
46
  // for more info
@@ -0,0 +1,16 @@
1
+ import { RetainChars, TupleToUnion } from "../../types/type-conversion";
2
+ /**
3
+ * **retainChars**`(content, ...retain)`
4
+ *
5
+ * Retains the characters from `retain[]` which are
6
+ * found in `content` while discarding the rest.
7
+ *
8
+ * ```ts
9
+ * // "42"
10
+ * const num = retainChars("4foobar2", ...NUMERIC_CHAR);
11
+ * ```
12
+ *
13
+ * **Related:** `stripChars()`, `retainWhile()`, `retainUntil()`
14
+ */
15
+ export declare const retainChars: <TContent extends string, TRetain extends readonly string[]>(content: TContent, ...retain: TRetain) => RetainChars<TContent, TupleToUnion<TRetain>>;
16
+ //# sourceMappingURL=retainChars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retainChars.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/retainChars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,oCAAkC;AAGtE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,wEAIb,QAAQ,aACN,OAAO,KACjB,YAAY,QAAQ,EAAE,aAAa,OAAO,CAAC,CAE7C,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { asChars } from "../type-conversion/asChars.js";
2
+ /**
3
+ * **retainChars**`(content, ...retain)`
4
+ *
5
+ * Retains the characters from `retain[]` which are
6
+ * found in `content` while discarding the rest.
7
+ *
8
+ * ```ts
9
+ * // "42"
10
+ * const num = retainChars("4foobar2", ...NUMERIC_CHAR);
11
+ * ```
12
+ *
13
+ * **Related:** `stripChars()`, `retainWhile()`, `retainUntil()`
14
+ */
15
+ export const retainChars = (content, ...retain) => {
16
+ return asChars(content).filter(c => retain.includes(c)).join("");
17
+ };
@@ -0,0 +1,11 @@
1
+ import { RetainWhile } from "../../types/string-literals";
2
+ import { TupleToUnion } from "../../types/type-conversion";
3
+ /**
4
+ * **retainWhile**`(content, ...retain)`
5
+ *
6
+ * Retains the characters at the start of the string
7
+ * so long as they are part of the character values
8
+ * passed in for `retain[]`
9
+ */
10
+ export declare const retainWhile: <TContent extends string, TRetain extends readonly string[]>(content: TContent, ...retain: TRetain) => RetainWhile<TContent, TupleToUnion<TRetain>>;
11
+ //# sourceMappingURL=retainWhile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retainWhile.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/retainWhile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,WAAW,EAAE,oCAAkC;AAEzD,OAAO,EAAE,YAAY,EAAE,oCAAkC;AAGzD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,wEAIb,QAAQ,aACN,OAAO,iDAInB,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { asChars } from "../type-conversion/index.js";
2
+ /**
3
+ * **retainWhile**`(content, ...retain)`
4
+ *
5
+ * Retains the characters at the start of the string
6
+ * so long as they are part of the character values
7
+ * passed in for `retain[]`
8
+ */
9
+ export const retainWhile = (content, ...retain) => {
10
+ const stopIdx = asChars(content).findIndex(c => !retain.includes(c));
11
+ return content.slice(0, stopIdx);
12
+ };