inferred-types 0.45.0 → 0.45.3
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.
- package/dist/constants/Characters.d.ts +2 -0
- package/dist/constants/Characters.d.ts.map +1 -0
- package/dist/constants/Characters.js +5 -0
- package/dist/constants/NetworkConstants.d.ts.map +1 -1
- package/dist/constants/Phone.d.ts +8 -0
- package/dist/constants/Phone.d.ts.map +1 -0
- package/dist/constants/Phone.js +262 -0
- package/dist/constants/ProxmoxConstants.d.ts +2 -0
- package/dist/constants/ProxmoxConstants.d.ts.map +1 -0
- package/dist/constants/ProxmoxConstants.js +3 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +3 -0
- package/dist/constants/tsconfig.tsbuildinfo +1 -1
- package/dist/inferred-types/index.cjs +1091 -733
- package/dist/inferred-types/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/api/defineApi.d.ts +56 -0
- package/dist/runtime/api/defineApi.d.ts.map +1 -0
- package/dist/runtime/api/defineApi.js +97 -0
- package/dist/runtime/api/handleDoneFn.d.ts.map +1 -0
- package/dist/runtime/api/index.d.ts +3 -0
- package/dist/runtime/api/index.d.ts.map +1 -0
- package/dist/runtime/api/index.js +2 -0
- package/dist/runtime/boolean-logic/ifArrayPartial.d.ts +1 -1
- package/dist/runtime/boolean-logic/ifArrayPartial.d.ts.map +1 -1
- package/dist/runtime/boolean-logic/ifArrayPartial.js +1 -1
- package/dist/runtime/boolean-logic/ifLength.d.ts.map +1 -1
- package/dist/runtime/boolean-logic/ifScalar.d.ts.map +1 -1
- package/dist/runtime/boolean-logic/ifScalar.js +1 -1
- package/dist/runtime/boolean-logic/index.d.ts +0 -1
- package/dist/runtime/boolean-logic/index.d.ts.map +1 -1
- package/dist/runtime/boolean-logic/index.js +0 -1
- package/dist/runtime/dictionary/defineOptions.d.ts +26 -0
- package/dist/runtime/dictionary/defineOptions.d.ts.map +1 -0
- package/dist/runtime/dictionary/defineOptions.js +30 -0
- package/dist/runtime/dictionary/keysOf.d.ts +1 -1
- package/dist/runtime/dictionary/keysOf.d.ts.map +1 -1
- package/dist/runtime/errors/KindError.d.ts +2 -2
- package/dist/runtime/errors/KindError.d.ts.map +1 -1
- package/dist/runtime/functions/index.d.ts +1 -0
- package/dist/runtime/functions/index.d.ts.map +1 -1
- package/dist/runtime/functions/index.js +1 -0
- package/dist/runtime/functions/wrapFn.d.ts +2 -0
- package/dist/runtime/functions/wrapFn.d.ts.map +1 -0
- package/dist/runtime/functions/wrapFn.js +24 -0
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -10
- package/dist/runtime/lists/find.d.ts +1 -1
- package/dist/runtime/lists/find.d.ts.map +1 -1
- package/dist/runtime/lists/intersection.d.ts.map +1 -1
- package/dist/runtime/lists/intersection.js +2 -1
- package/dist/runtime/literals/asPhoneNumber.d.ts +10 -0
- package/dist/runtime/literals/asPhoneNumber.d.ts.map +1 -0
- package/dist/runtime/literals/asPhoneNumber.js +62 -0
- package/dist/runtime/literals/index.d.ts +4 -0
- package/dist/runtime/literals/index.d.ts.map +1 -1
- package/dist/runtime/literals/index.js +4 -0
- package/dist/runtime/literals/retainAfter.d.ts +1 -1
- package/dist/runtime/literals/retainAfter.js +1 -1
- package/dist/runtime/literals/retainChars.d.ts +16 -0
- package/dist/runtime/literals/retainChars.d.ts.map +1 -0
- package/dist/runtime/literals/retainChars.js +17 -0
- package/dist/runtime/literals/retainWhile.d.ts +10 -0
- package/dist/runtime/literals/retainWhile.d.ts.map +1 -0
- package/dist/runtime/literals/retainWhile.js +13 -0
- package/dist/runtime/literals/stripChars.d.ts +10 -0
- package/dist/runtime/literals/stripChars.d.ts.map +1 -0
- package/dist/runtime/literals/stripChars.js +11 -0
- package/dist/runtime/literals/stripLeading.d.ts +3 -3
- package/dist/runtime/literals/stripLeading.d.ts.map +1 -1
- package/dist/runtime/literals/stripLeading.js +5 -5
- package/dist/runtime/literals/stripUntil.d.ts +9 -0
- package/dist/runtime/literals/stripUntil.d.ts.map +1 -0
- package/dist/runtime/literals/stripUntil.js +12 -0
- package/dist/runtime/literals/unset.d.ts +8 -0
- package/dist/runtime/literals/unset.d.ts.map +1 -0
- package/dist/runtime/literals/unset.js +14 -0
- package/dist/runtime/meta/youtube-meta.d.ts +8 -1
- package/dist/runtime/meta/youtube-meta.d.ts.map +1 -1
- package/dist/runtime/meta/youtube-meta.js +50 -2
- package/dist/runtime/runtime-types/dict.d.ts +2 -2
- package/dist/runtime/runtime-types/dict.d.ts.map +1 -1
- package/dist/runtime/runtime-types/ip6Prefix.d.ts +1 -1
- package/dist/runtime/runtime-types/parse.d.ts +1 -1
- package/dist/runtime/runtime-types/shape-helpers/getTokenData.d.ts +1 -1
- package/dist/runtime/runtime-types/shape-helpers/getTokenName.d.ts +1 -1
- package/dist/runtime/runtime-types/shape.d.ts +1 -1
- package/dist/runtime/runtime-types/shape.js +1 -1
- package/dist/runtime/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/type-guards/api-tg.d.ts +33 -0
- package/dist/runtime/type-guards/api-tg.d.ts.map +1 -0
- package/dist/runtime/type-guards/api-tg.js +38 -0
- package/dist/runtime/type-guards/hasWhitespace.d.ts +7 -0
- package/dist/runtime/type-guards/hasWhitespace.d.ts.map +1 -0
- package/dist/runtime/type-guards/hasWhitespace.js +11 -0
- package/dist/runtime/type-guards/index.d.ts +7 -0
- package/dist/runtime/type-guards/index.d.ts.map +1 -1
- package/dist/runtime/type-guards/index.js +7 -0
- package/dist/runtime/type-guards/isConstant.d.ts +6 -0
- package/dist/runtime/type-guards/isConstant.d.ts.map +1 -1
- package/dist/runtime/type-guards/isConstant.js +12 -2
- package/dist/runtime/type-guards/isEmail.d.ts +7 -0
- package/dist/runtime/type-guards/isEmail.d.ts.map +1 -0
- package/dist/runtime/type-guards/isEmail.js +11 -0
- package/dist/runtime/type-guards/isPhoneNumber.d.ts +14 -0
- package/dist/runtime/type-guards/isPhoneNumber.d.ts.map +1 -0
- package/dist/runtime/type-guards/isPhoneNumber.js +26 -0
- package/dist/runtime/type-guards/isSpecificConstant.js +2 -3
- package/dist/runtime/type-guards/isTrimmable.d.ts +7 -0
- package/dist/runtime/type-guards/isTrimmable.d.ts.map +1 -0
- package/dist/runtime/type-guards/isTrimmable.js +9 -0
- package/dist/runtime/type-guards/isUnset.d.ts +18 -0
- package/dist/runtime/type-guards/isUnset.d.ts.map +1 -0
- package/dist/runtime/type-guards/isUnset.js +23 -0
- package/dist/runtime/type-guards/isUrl.d.ts +1 -1
- package/dist/runtime/type-guards/network-tg.d.ts +9 -3
- package/dist/runtime/type-guards/network-tg.d.ts.map +1 -1
- package/dist/runtime/type-guards/network-tg.js +10 -1
- package/dist/runtime/type-guards/repos.d.ts +2 -2
- package/dist/runtime/type-guards/youtube.d.ts +4 -2
- package/dist/runtime/type-guards/youtube.d.ts.map +1 -1
- package/dist/runtime/type-guards/youtube.js +13 -3
- package/dist/types/api/api.d.ts +96 -37
- package/dist/types/api/api.d.ts.map +1 -1
- package/dist/types/base-types/fns/EscapeFunction.d.ts +22 -0
- package/dist/types/base-types/fns/EscapeFunction.d.ts.map +1 -0
- package/dist/types/base-types/fns/OptionalParamFn.d.ts +30 -0
- package/dist/types/base-types/fns/OptionalParamFn.d.ts.map +1 -0
- package/dist/types/base-types/fns/index.d.ts +2 -0
- package/dist/types/base-types/fns/index.d.ts.map +1 -1
- package/dist/types/base-types/fns/index.js +2 -0
- package/dist/types/boolean-logic/branching/If.d.ts +2 -3
- package/dist/types/boolean-logic/branching/If.d.ts.map +1 -1
- package/dist/types/boolean-logic/branching/IfUnset.d.ts +12 -0
- package/dist/types/boolean-logic/branching/IfUnset.d.ts.map +1 -0
- package/dist/types/boolean-logic/branching/OnPass.d.ts +4 -3
- package/dist/types/boolean-logic/branching/OnPass.d.ts.map +1 -1
- package/dist/types/boolean-logic/branching/WhenNever.d.ts +11 -0
- package/dist/types/boolean-logic/branching/WhenNever.d.ts.map +1 -0
- package/dist/types/boolean-logic/branching/WhenNever.js +1 -0
- package/dist/types/boolean-logic/branching/index.d.ts +2 -0
- package/dist/types/boolean-logic/branching/index.d.ts.map +1 -1
- package/dist/types/boolean-logic/branching/index.js +2 -0
- package/dist/types/boolean-logic/combinators/Compare.d.ts +3 -3
- package/dist/types/boolean-logic/combinators/Compare.d.ts.map +1 -1
- package/dist/types/boolean-logic/combinators/Some.d.ts +8 -0
- package/dist/types/boolean-logic/combinators/Some.d.ts.map +1 -0
- package/dist/types/boolean-logic/combinators/Some.js +1 -0
- package/dist/types/boolean-logic/combinators/index.d.ts +1 -0
- package/dist/types/boolean-logic/combinators/index.d.ts.map +1 -1
- package/dist/types/boolean-logic/combinators/index.js +1 -0
- package/dist/types/boolean-logic/narrowing/AsDoneFn.d.ts +2 -2
- package/dist/types/boolean-logic/narrowing/AsDoneFn.d.ts.map +1 -1
- package/dist/types/boolean-logic/operators/ApiOperators.d.ts +11 -0
- package/dist/types/boolean-logic/operators/ApiOperators.d.ts.map +1 -0
- package/dist/types/boolean-logic/operators/ApiOperators.js +1 -0
- package/dist/types/boolean-logic/operators/HasSameValues.d.ts +4 -3
- package/dist/types/boolean-logic/operators/HasSameValues.d.ts.map +1 -1
- package/dist/types/boolean-logic/operators/IsGreaterThan.d.ts +2 -2
- package/dist/types/boolean-logic/operators/IsGreaterThan.d.ts.map +1 -1
- package/dist/types/boolean-logic/operators/IsUnset.d.ts +9 -0
- package/dist/types/boolean-logic/operators/IsUnset.d.ts.map +1 -0
- package/dist/types/boolean-logic/operators/IsUnset.js +1 -0
- package/dist/types/boolean-logic/operators/PhoneOperators.d.ts +33 -0
- package/dist/types/boolean-logic/operators/PhoneOperators.d.ts.map +1 -0
- package/dist/types/boolean-logic/operators/PhoneOperators.js +1 -0
- package/dist/types/boolean-logic/operators/index.d.ts +3 -0
- package/dist/types/boolean-logic/operators/index.d.ts.map +1 -1
- package/dist/types/boolean-logic/operators/index.js +3 -0
- package/dist/types/dictionary/Keys.d.ts +58 -4
- package/dist/types/dictionary/Keys.d.ts.map +1 -1
- package/dist/types/dictionary/KvFn.d.ts +2 -2
- package/dist/types/dictionary/KvFn.d.ts.map +1 -1
- package/dist/types/dictionary/MakeKeysOptional.d.ts +12 -3
- package/dist/types/dictionary/MakeKeysOptional.d.ts.map +1 -1
- package/dist/types/dictionary/MakeKeysRequired.d.ts +14 -0
- package/dist/types/dictionary/MakeKeysRequired.d.ts.map +1 -0
- package/dist/types/dictionary/MakeKeysRequired.js +1 -0
- package/dist/types/dictionary/OptionalKeys.d.ts +19 -4
- package/dist/types/dictionary/OptionalKeys.d.ts.map +1 -1
- package/dist/types/dictionary/OptionalKeys.js +1 -0
- package/dist/types/dictionary/RequiredKeys.d.ts +14 -6
- package/dist/types/dictionary/RequiredKeys.d.ts.map +1 -1
- package/dist/types/dictionary/Values.d.ts +2 -2
- package/dist/types/dictionary/Values.d.ts.map +1 -1
- package/dist/types/dictionary/index.d.ts +1 -2
- package/dist/types/dictionary/index.d.ts.map +1 -1
- package/dist/types/dictionary/index.js +1 -2
- package/dist/types/errors/KindError.d.ts +1 -1
- package/dist/types/errors/KindError.d.ts.map +1 -1
- package/dist/types/functions/FnFrom.d.ts +5 -0
- package/dist/types/functions/FnFrom.d.ts.map +1 -1
- package/dist/types/functions/{Fn.d.ts → FnWithDescription.d.ts} +2 -2
- package/dist/types/functions/FnWithDescription.d.ts.map +1 -0
- package/dist/types/functions/FnWithDescription.js +1 -0
- package/dist/types/functions/WrapperFn.d.ts +23 -0
- package/dist/types/functions/WrapperFn.d.ts.map +1 -0
- package/dist/types/functions/WrapperFn.js +1 -0
- package/dist/types/functions/index.d.ts +2 -1
- package/dist/types/functions/index.d.ts.map +1 -1
- package/dist/types/functions/index.js +2 -1
- package/dist/types/lists/ConvertSet.d.ts +2 -2
- package/dist/types/lists/ConvertSet.d.ts.map +1 -1
- package/dist/types/lists/Find.d.ts +7 -18
- package/dist/types/lists/Find.d.ts.map +1 -1
- package/dist/types/literals/DoneFnTuple.d.ts +3 -3
- package/dist/types/literals/DoneFnTuple.d.ts.map +1 -1
- package/dist/types/literals/Unset.d.ts +13 -0
- package/dist/types/literals/Unset.d.ts.map +1 -0
- package/dist/types/literals/Unset.js +1 -0
- package/dist/types/literals/index.d.ts +1 -0
- package/dist/types/literals/index.d.ts.map +1 -1
- package/dist/types/literals/index.js +1 -0
- package/dist/types/numeric-literals/NumberLike.d.ts +1 -1
- package/dist/types/numeric-literals/NumberLike.d.ts.map +1 -1
- package/dist/types/string-literals/Proxmox.d.ts +7 -0
- package/dist/types/string-literals/Proxmox.d.ts.map +1 -0
- package/dist/types/string-literals/Proxmox.js +1 -0
- package/dist/types/string-literals/StripLeading.d.ts +2 -2
- package/dist/types/string-literals/StripLeading.d.ts.map +1 -1
- package/dist/types/string-literals/StripUntil.d.ts +12 -0
- package/dist/types/string-literals/StripUntil.d.ts.map +1 -1
- package/dist/types/string-literals/character-sets/Whitespace.d.ts +3 -1
- package/dist/types/string-literals/character-sets/Whitespace.d.ts.map +1 -1
- package/dist/types/string-literals/character-sets/index.d.ts +1 -0
- package/dist/types/string-literals/character-sets/index.d.ts.map +1 -1
- package/dist/types/string-literals/character-sets/index.js +1 -0
- package/dist/types/string-literals/character-sets/phone.d.ts +192 -0
- package/dist/types/string-literals/character-sets/phone.d.ts.map +1 -0
- package/dist/types/string-literals/character-sets/phone.js +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/type-conversion/ReduceValues.d.ts +19 -0
- package/dist/types/type-conversion/ReduceValues.d.ts.map +1 -0
- package/dist/types/type-conversion/ReduceValues.js +1 -0
- package/dist/types/type-conversion/ReturnValues.d.ts +10 -6
- package/dist/types/type-conversion/ReturnValues.d.ts.map +1 -1
- package/dist/types/type-conversion/Trim.d.ts +3 -1
- package/dist/types/type-conversion/Trim.d.ts.map +1 -1
- package/dist/types/type-conversion/UnionFilter.d.ts +2 -2
- package/dist/types/type-conversion/UnionFilter.d.ts.map +1 -1
- package/dist/types/type-conversion/form-fields.d.ts +5 -1
- package/dist/types/type-conversion/form-fields.d.ts.map +1 -1
- package/dist/types/type-conversion/index.d.ts +1 -0
- package/dist/types/type-conversion/index.d.ts.map +1 -1
- package/dist/types/type-conversion/index.js +1 -0
- package/package.json +17 -11
- package/dist/runtime/boolean-logic/handleDoneFn.d.ts.map +0 -1
- package/dist/types/dictionary/PrivateKeys.d.ts +0 -17
- package/dist/types/dictionary/PrivateKeys.d.ts.map +0 -1
- package/dist/types/dictionary/PublicKeys.d.ts +0 -10
- package/dist/types/dictionary/PublicKeys.d.ts.map +0 -1
- package/dist/types/functions/Fn.d.ts.map +0 -1
- /package/dist/runtime/{boolean-logic → api}/handleDoneFn.d.ts +0 -0
- /package/dist/runtime/{boolean-logic → api}/handleDoneFn.js +0 -0
- /package/dist/types/{dictionary/PrivateKeys.js → base-types/fns/EscapeFunction.js} +0 -0
- /package/dist/types/{dictionary/PublicKeys.js → base-types/fns/OptionalParamFn.js} +0 -0
- /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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -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[] |
|
|
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;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifLength.d.ts","sourceRoot":"","sources":["../../../src/runtime/boolean-logic/ifLength.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,
|
|
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 +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
|
|
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"}
|
|
@@ -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,
|
|
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> =
|
|
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,
|
|
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 +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"}
|
|
@@ -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";
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
|
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,
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RetainAfter } from "../../types/index";
|
|
2
2
|
/**
|
|
3
|
-
* **
|
|
3
|
+
* **retainAfter**(content, find)
|
|
4
4
|
*
|
|
5
5
|
* Runtime utility which removes all characters in a given string _until_
|
|
6
6
|
* it finds the first instance of a substring defined in **find** variable.
|
|
@@ -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,10 @@
|
|
|
1
|
+
import { RetainWhile, TupleToUnion } from "../../types/index";
|
|
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 declare const retainWhile: <TContent extends string, TRetain extends readonly string[]>(content: TContent, ...retain: TRetain) => RetainWhile<TContent, TupleToUnion<TRetain>>;
|
|
10
|
+
//# 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,YAAY,EAAE,0BAAwB;AAI7D;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,wEAIb,QAAQ,aACN,OAAO,iDAMnB,CAAA"}
|