@parischap/conversions 0.1.0

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 (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1304 -0
  3. package/cjs/BigDecimal.js +16 -0
  4. package/cjs/BigDecimal.js.map +1 -0
  5. package/cjs/BigInt.js +34 -0
  6. package/cjs/BigInt.js.map +1 -0
  7. package/cjs/DateTime.js +2202 -0
  8. package/cjs/DateTime.js.map +1 -0
  9. package/cjs/DateTimeFormat.js +269 -0
  10. package/cjs/DateTimeFormat.js.map +1 -0
  11. package/cjs/DateTimeFormatContext.js +327 -0
  12. package/cjs/DateTimeFormatContext.js.map +1 -0
  13. package/cjs/Email.js +73 -0
  14. package/cjs/Email.js.map +1 -0
  15. package/cjs/Integer.js +155 -0
  16. package/cjs/Integer.js.map +1 -0
  17. package/cjs/NumberBase10Format.js +759 -0
  18. package/cjs/NumberBase10Format.js.map +1 -0
  19. package/cjs/PositiveInteger.js +191 -0
  20. package/cjs/PositiveInteger.js.map +1 -0
  21. package/cjs/PositiveReal.js +162 -0
  22. package/cjs/PositiveReal.js.map +1 -0
  23. package/cjs/Real.js +113 -0
  24. package/cjs/Real.js.map +1 -0
  25. package/cjs/RoundingMode.js +86 -0
  26. package/cjs/RoundingMode.js.map +1 -0
  27. package/cjs/RoundingOption.js +152 -0
  28. package/cjs/RoundingOption.js.map +1 -0
  29. package/cjs/Schema.js +218 -0
  30. package/cjs/Schema.js.map +1 -0
  31. package/cjs/SemVer.js +73 -0
  32. package/cjs/SemVer.js.map +1 -0
  33. package/cjs/Template.js +189 -0
  34. package/cjs/Template.js.map +1 -0
  35. package/cjs/TemplatePart.js +51 -0
  36. package/cjs/TemplatePart.js.map +1 -0
  37. package/cjs/TemplateParts.js +46 -0
  38. package/cjs/TemplateParts.js.map +1 -0
  39. package/cjs/TemplatePlaceholder.js +381 -0
  40. package/cjs/TemplatePlaceholder.js.map +1 -0
  41. package/cjs/TemplateSeparator.js +116 -0
  42. package/cjs/TemplateSeparator.js.map +1 -0
  43. package/cjs/index.js +67 -0
  44. package/cjs/index.js.map +1 -0
  45. package/cjs/internal/Int.js +50 -0
  46. package/cjs/internal/Int.js.map +1 -0
  47. package/cjs/internal/Positive.js +50 -0
  48. package/cjs/internal/Positive.js.map +1 -0
  49. package/dts/BigDecimal.d.ts +11 -0
  50. package/dts/BigDecimal.d.ts.map +1 -0
  51. package/dts/BigInt.d.ts +30 -0
  52. package/dts/BigInt.d.ts.map +1 -0
  53. package/dts/DateTime.d.ts +1421 -0
  54. package/dts/DateTime.d.ts.map +1 -0
  55. package/dts/DateTimeFormat.d.ts +257 -0
  56. package/dts/DateTimeFormat.d.ts.map +1 -0
  57. package/dts/DateTimeFormatContext.d.ts +112 -0
  58. package/dts/DateTimeFormatContext.d.ts.map +1 -0
  59. package/dts/Email.d.ts +61 -0
  60. package/dts/Email.d.ts.map +1 -0
  61. package/dts/Integer.d.ts +123 -0
  62. package/dts/Integer.d.ts.map +1 -0
  63. package/dts/NumberBase10Format.d.ts +641 -0
  64. package/dts/NumberBase10Format.d.ts.map +1 -0
  65. package/dts/PositiveInteger.d.ts +161 -0
  66. package/dts/PositiveInteger.d.ts.map +1 -0
  67. package/dts/PositiveReal.d.ts +130 -0
  68. package/dts/PositiveReal.d.ts.map +1 -0
  69. package/dts/Real.d.ts +102 -0
  70. package/dts/Real.d.ts.map +1 -0
  71. package/dts/RoundingMode.d.ts +72 -0
  72. package/dts/RoundingMode.d.ts.map +1 -0
  73. package/dts/RoundingOption.d.ts +79 -0
  74. package/dts/RoundingOption.d.ts.map +1 -0
  75. package/dts/Schema.d.ts +159 -0
  76. package/dts/Schema.d.ts.map +1 -0
  77. package/dts/SemVer.d.ts +61 -0
  78. package/dts/SemVer.d.ts.map +1 -0
  79. package/dts/Template.d.ts +113 -0
  80. package/dts/Template.d.ts.map +1 -0
  81. package/dts/TemplatePart.d.ts +28 -0
  82. package/dts/TemplatePart.d.ts.map +1 -0
  83. package/dts/TemplateParts.d.ts +23 -0
  84. package/dts/TemplateParts.d.ts.map +1 -0
  85. package/dts/TemplatePlaceholder.d.ts +274 -0
  86. package/dts/TemplatePlaceholder.d.ts.map +1 -0
  87. package/dts/TemplateSeparator.d.ts +130 -0
  88. package/dts/TemplateSeparator.d.ts.map +1 -0
  89. package/dts/index.d.ts +21 -0
  90. package/dts/index.d.ts.map +1 -0
  91. package/dts/internal/Int.d.ts +6 -0
  92. package/dts/internal/Int.d.ts.map +1 -0
  93. package/dts/internal/Positive.d.ts +6 -0
  94. package/dts/internal/Positive.d.ts.map +1 -0
  95. package/esm/BigDecimal.js +9 -0
  96. package/esm/BigDecimal.js.map +1 -0
  97. package/esm/BigInt.js +27 -0
  98. package/esm/BigInt.js.map +1 -0
  99. package/esm/DateTime.js +2130 -0
  100. package/esm/DateTime.js.map +1 -0
  101. package/esm/DateTimeFormat.js +238 -0
  102. package/esm/DateTimeFormat.js.map +1 -0
  103. package/esm/DateTimeFormatContext.js +296 -0
  104. package/esm/DateTimeFormatContext.js.map +1 -0
  105. package/esm/Email.js +65 -0
  106. package/esm/Email.js.map +1 -0
  107. package/esm/Integer.js +128 -0
  108. package/esm/Integer.js.map +1 -0
  109. package/esm/NumberBase10Format.js +717 -0
  110. package/esm/NumberBase10Format.js.map +1 -0
  111. package/esm/PositiveInteger.js +164 -0
  112. package/esm/PositiveInteger.js.map +1 -0
  113. package/esm/PositiveReal.js +135 -0
  114. package/esm/PositiveReal.js.map +1 -0
  115. package/esm/Real.js +106 -0
  116. package/esm/Real.js.map +1 -0
  117. package/esm/RoundingMode.js +79 -0
  118. package/esm/RoundingMode.js.map +1 -0
  119. package/esm/RoundingOption.js +120 -0
  120. package/esm/RoundingOption.js.map +1 -0
  121. package/esm/Schema.js +203 -0
  122. package/esm/Schema.js.map +1 -0
  123. package/esm/SemVer.js +65 -0
  124. package/esm/SemVer.js.map +1 -0
  125. package/esm/Template.js +158 -0
  126. package/esm/Template.js.map +1 -0
  127. package/esm/TemplatePart.js +22 -0
  128. package/esm/TemplatePart.js.map +1 -0
  129. package/esm/TemplateParts.js +19 -0
  130. package/esm/TemplateParts.js.map +1 -0
  131. package/esm/TemplatePlaceholder.js +342 -0
  132. package/esm/TemplatePlaceholder.js.map +1 -0
  133. package/esm/TemplateSeparator.js +107 -0
  134. package/esm/TemplateSeparator.js.map +1 -0
  135. package/esm/index.js +21 -0
  136. package/esm/index.js.map +1 -0
  137. package/esm/internal/Int.js +43 -0
  138. package/esm/internal/Int.js.map +1 -0
  139. package/esm/internal/Positive.js +43 -0
  140. package/esm/internal/Positive.js.map +1 -0
  141. package/esm/package.json +3 -0
  142. package/package.json +49 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * An extension to the Effect Schema module that adds Schema instances for data conversion like
3
+ * number and date formatting and parsing
4
+ */
5
+ import { MTypes } from '@parischap/effect-lib';
6
+ import { BigDecimal, DateTime, Schema } from 'effect';
7
+ import * as CVDateTime from './DateTime.js';
8
+ import * as CVDateTimeFormat from './DateTimeFormat.js';
9
+ import * as CVEmail from './Email.js';
10
+ import * as CVInteger from './Integer.js';
11
+ import * as CVNumberBase10Format from './NumberBase10Format.js';
12
+ import * as CVPositiveInteger from './PositiveInteger.js';
13
+ import * as CVPositiveReal from './PositiveReal.js';
14
+ import * as CVReal from './Real.js';
15
+ import * as CVSemVer from './SemVer.js';
16
+ import * as CVTemplate from './Template.js';
17
+ import * as CVTemplateParts from './TemplateParts.js';
18
+ import * as CVTemplatePlaceholder from './TemplatePlaceholder.js';
19
+ /**
20
+ * A Schema that transforms a string into a CVBrand.Email.Type
21
+ *
22
+ * @category Schema transformations
23
+ */
24
+ export declare const Email: Schema.Schema<CVEmail.Type, string>;
25
+ /**
26
+ * A Schema that represents a CVBrand.Email.Type
27
+ *
28
+ * @category Schema instances
29
+ */
30
+ export declare const EmailFromSelf: Schema.Schema<CVEmail.Type>;
31
+ /**
32
+ * A Schema that transforms a string into an CVBrand.SemVer.Type
33
+ *
34
+ * @category Schema transformations
35
+ */
36
+ export declare const SemVer: Schema.Schema<CVSemVer.Type, string>;
37
+ /**
38
+ * A Schema that represents a CVBrand.SemVer.Type
39
+ *
40
+ * @category Schema instances
41
+ */
42
+ export declare const SemVerFromSelf: Schema.Schema<CVSemVer.Type>;
43
+ /**
44
+ * A Schema that transforms a number into an CVReal.Type
45
+ *
46
+ * @category Schema transformations
47
+ */
48
+ export declare const RealFromNumber: Schema.Schema<CVReal.Type, number>;
49
+ /**
50
+ * A Schema that represents a CVReal.Type
51
+ *
52
+ * @category Schema instances
53
+ */
54
+ export declare const RealFromSelf: Schema.Schema<CVReal.Type>;
55
+ /**
56
+ * A Schema that transforms a string into a Real according to the CVNumberBase10Format `format`.
57
+ * Read documentation of CVNumberBase10Format.toRealParser and
58
+ * CVNumberBase10Format.toNumberFormatter for more details
59
+ *
60
+ * @category Schema transformations
61
+ */
62
+ export declare const Real: (format: CVNumberBase10Format.Type) => Schema.Schema<CVReal.Type, string>;
63
+ /**
64
+ * A Schema that transforms a number into a CVInteger.Type
65
+ *
66
+ * @category Schema transformations
67
+ */
68
+ export declare const IntegerFromNumber: Schema.Schema<CVInteger.Type, number>;
69
+ /**
70
+ * A Schema that represents a CVInteger.Type
71
+ *
72
+ * @category Schema instances
73
+ */
74
+ export declare const IntegerFromSelf: Schema.Schema<CVInteger.Type>;
75
+ /**
76
+ * A Schema that transforms a number into a CVPositiveInteger.Type
77
+ *
78
+ * @category Schema transformations
79
+ */
80
+ export declare const PositiveIntegerFromNumber: Schema.Schema<CVPositiveInteger.Type, number>;
81
+ /**
82
+ * A Schema that represents a CVPositiveInteger.Type
83
+ *
84
+ * @category Schema instances
85
+ */
86
+ export declare const PositiveIntegerFromSelf: Schema.Schema<CVPositiveInteger.Type>;
87
+ /**
88
+ * A Schema that transforms a number into a CVPositiveReal.Type
89
+ *
90
+ * @category Schema transformations
91
+ */
92
+ export declare const PositiveRealFromNumber: Schema.Schema<CVPositiveReal.Type, number>;
93
+ /**
94
+ * A Schema that represents a CVPositiveReal.Type
95
+ *
96
+ * @category Schema instances
97
+ */
98
+ export declare const PositiveRealFromSelf: Schema.Schema<CVPositiveReal.Type>;
99
+ declare const BigDecimalFromString: (format: CVNumberBase10Format.Type) => Schema.Schema<BigDecimal.BigDecimal, string>;
100
+ export {
101
+ /**
102
+ * A Schema that transforms a string into a BigDecimal according to the CVNumberBase10Format
103
+ * `format`. Read documentation of CVNumberBase10Format.toBigDecimalParser and
104
+ * CVNumberBase10Format.toNumberFormatter for more details
105
+ *
106
+ * @category Schema transformations
107
+ */
108
+ BigDecimalFromString as BigDecimal };
109
+ /**
110
+ * A Schema that represents a CVDateTime
111
+ *
112
+ * @category Schema instances
113
+ */
114
+ export declare const DateTimeFromSelf: Schema.declare<CVDateTime.Type, CVDateTime.Type, readonly [], never>;
115
+ /**
116
+ * A Schema that transforms a CVDateTime into a Date. The CVDateTime object is created with the
117
+ * default timeZoneOffset of the machine this code is running on
118
+ *
119
+ * @category Schema instances
120
+ */
121
+ export declare const DateFromDateTime: Schema.Schema<Date, CVDateTime.Type>;
122
+ /**
123
+ * A Schema that transforms a CVDateTime into an Effect DateTime.Zoned. Both objects share the same
124
+ * time zone offset.
125
+ *
126
+ * @category Schema instances
127
+ */
128
+ export declare const DateTimeZonedFromDateTime: Schema.Schema<DateTime.Zoned, CVDateTime.Type>;
129
+ declare const DateTimeFromString: (format: CVDateTimeFormat.Type) => Schema.Schema<CVDateTime.Type, string>;
130
+ export {
131
+ /**
132
+ * A Schema that transforms a string into a CVDateTime according to the CVDateTimeFormat `format`.
133
+ * Read documentation of CVDateTimeFormat.toParser and CVDateTimeFormat.toFormatter for more
134
+ * details
135
+ *
136
+ * @category Schema transformations
137
+ */
138
+ DateTimeFromString as DateTime };
139
+ /**
140
+ * A Schema that transforms a string into a Date according to the CVDateTimeFormat `format`. Read
141
+ * documentation of CVDateTimeFormat.toParser and CVDateTimeFormat.toFormatter for more details
142
+ *
143
+ * @category Schema transformations
144
+ */
145
+ export declare const Date: (format: CVDateTimeFormat.Type) => Schema.Schema<Date, string>;
146
+ /**
147
+ * A Schema that transforms a string into a Date according to the CVDateTimeFormat `format`. Read
148
+ * documentation of CVDateTimeFormat.toParser and CVDateTimeFormat.toFormatter for more details
149
+ *
150
+ * @category Schema transformations
151
+ */
152
+ export declare const DateTimeZoned: (format: CVDateTimeFormat.Type) => Schema.Schema<DateTime.Zoned, string>;
153
+ /**
154
+ * A Schema that transforms a string into an object according to a CVTemplate (see Template.ts)
155
+ *
156
+ * @category Schema transformations
157
+ */
158
+ export declare const Template: <const PS extends CVTemplateParts.Type>(template: CVTemplate.Type<PS>) => Schema.Schema<{ readonly [k in keyof MTypes.ArrayKeys<PS> as PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractName<PS[k]> : never]: PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractType<PS[k]> : never; }, string>;
159
+ //# sourceMappingURL=Schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../esm/Schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAkB,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAEN,UAAU,EACV,QAAQ,EAOR,MAAM,EACN,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,oBAAoB,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,aAAa,CAA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Aa,GACzB,QAAQ,gBAAgB,CAAC,IAAI,KAC3B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAC+B,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,CAAC,EAAE,SAAS,eAAe,CAAC,IAAI,EAC7D,UAAU,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAC3B,MAAM,CAAC,MAAM,CACf,EACC,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GACnF,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GACvC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GAAG,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAC1F,KAAK,GACP,EACD,MAAM,CA2CN,CAAC"}
@@ -0,0 +1,61 @@
1
+ /** A module that implements a SemVer brand */
2
+ import { MTypes } from '@parischap/effect-lib';
3
+ import { Brand, Either, Option } from 'effect';
4
+ /**
5
+ * Module tag
6
+ *
7
+ * @category Module markers
8
+ */
9
+ export declare const moduleTag = "@parischap/conversions/SemVer/";
10
+ /**
11
+ * Module TypeId
12
+ *
13
+ * @category Module markers
14
+ */
15
+ export declare const TypeId: unique symbol;
16
+ type _TypeId = typeof TypeId;
17
+ /**
18
+ * SemVer type
19
+ *
20
+ * @category Models
21
+ */
22
+ export type Type = Brand.Branded<string, _TypeId>;
23
+ /**
24
+ * Constructs a SemVer without any verifications
25
+ *
26
+ * @category Constructors
27
+ */
28
+ export declare const unsafeFromString: Brand.Brand.Constructor<Type>;
29
+ /**
30
+ * Constructs a SemVer from a string. Throws an error if the provided string does not represent a
31
+ * SemVer
32
+ *
33
+ * @category Constructors
34
+ */
35
+ export declare const constructor: Brand.Brand.Constructor<Type>;
36
+ /**
37
+ * Constructs an Option of a SemVer from a string.
38
+ *
39
+ * @category Constructors
40
+ */
41
+ export declare const fromStringOption: MTypes.OneArgFunction<string, Option.Option<Type>>;
42
+ /**
43
+ * Constructs an Either of a SemVer from a string.
44
+ *
45
+ * @category Constructors
46
+ */
47
+ export declare const fromString: MTypes.OneArgFunction<string, Either.Either<Type, Brand.Brand.BrandErrors>>;
48
+ /**
49
+ * Constructs a SemVer or throws.
50
+ *
51
+ * @category Constructors
52
+ */
53
+ export declare const fromStringOrThrow: MTypes.OneArgFunction<string, Type>;
54
+ /**
55
+ * Checks if a string is a semver
56
+ *
57
+ * @category Refinement
58
+ */
59
+ export declare const has: (input: string) => input is Type;
60
+ export {};
61
+ //# sourceMappingURL=SemVer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemVer.d.ts","sourceRoot":"","sources":["../../esm/SemVer.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAE9C,OAAO,EAAW,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,SAAS,mCAAmC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAyC,CAAC;AACtE,KAAK,OAAO,GAAG,OAAO,MAAM,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,+BAAwB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+BAEvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,CACnD,MAAM,EACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACoB,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,cAAc,CAC7C,MAAM,EACN,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CACL,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAe,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,IAA+B,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * A template is a model of a text that has always the same structure. In such a text, there are
3
+ * immutable and mutable parts. Let's take the following two texts as an example:
4
+ *
5
+ * - Text1 = "John is a 47-year old man."
6
+ * - Text2 = "Jehnny is a 5-year old girl."
7
+ *
8
+ * These two texts obviously share the same structure which is the template:
9
+ *
10
+ * Placeholder1 is a Placeholder2-year old Placeholder3.
11
+ *
12
+ * Placeholder1, Placeholder2 and Placeholder3 are the mutable parts of the template. They contain
13
+ * valuable information. We call them `TemplatePlaceholder`'s.
14
+ *
15
+ * " is a " and "-year old " are the immutable parts of the template. We call them
16
+ * `TemplateSeperator`'s.
17
+ *
18
+ * From a text with the above structure, we can extract the values of Placeholder1, Placeholder2,
19
+ * and Placeholder3. In the present case:
20
+ *
21
+ * - For text1: Placeholder1 = 'John', Placeholder2 = '47', Placeholder3 = 'man'
22
+ * - For text2: Placeholder1 = 'Jehnny', Placeholder2 = '5', Placeholder3 = 'girl'
23
+ *
24
+ * Extracting the values of placeholders from a text according to a template is called parsing.
25
+ *
26
+ * Inversely, given a template and the values of the placeholders that compose it, we can generate a
27
+ * text. This is called formatting. In the present case, with:
28
+ *
29
+ * Placeholder1 = 'Tom', Placeholder2 = '15', Placeholder3 = 'boy'
30
+ *
31
+ * We will obtain the text: "Tom is a 15-year old boy."
32
+ *
33
+ * A TemplatePart is either a TemplateSeparator or a TemplatePlaceholder. This module implements a
34
+ * Template which is composed of a series of TemplatePart's. Note that Effect does provide the
35
+ * Schema.TemplateLiteralParser API which partly addresses the same problem. But there are some
36
+ * limitations to that API. For instance, template literal types cannot represent a fixed-length
37
+ * string or a string composed only of capital letters... It is for instance impossible to represent
38
+ * a date in the form YYYYMMDD with the TemplateLiteralParser. A schema in the form:
39
+ *
40
+ * `const schema = Schema.TemplateLiteralParser(Schema.NumberFromString,Schema.NumberFromString,
41
+ * Schema.NumberFromString)`
42
+ *
43
+ * Would not work as the first NumberFromString combinator would read the whole date.
44
+ */
45
+ import { MInputError, MInspectable, MTypes } from '@parischap/effect-lib';
46
+ import { Either, Pipeable } from 'effect';
47
+ import * as CVTemplatePart from './TemplatePart.js';
48
+ import * as CVTemplateParts from './TemplateParts.js';
49
+ import * as CVTemplatePlaceholder from './TemplatePlaceholder.js';
50
+ /**
51
+ * Module tag
52
+ *
53
+ * @category Module markers
54
+ */
55
+ export declare const moduleTag = "@parischap/conversions/Template/";
56
+ /**
57
+ * Type that represents a Template
58
+ *
59
+ * @category Models
60
+ */
61
+ export interface Type<out PS extends CVTemplateParts.Type> extends MInspectable.Type, Pipeable.Pipeable {
62
+ /** Array of the TemplatePart's composing this template */
63
+ readonly templateParts: PS;
64
+ }
65
+ /**
66
+ * Type guard
67
+ *
68
+ * @category Guards
69
+ */
70
+ export declare const has: (u: unknown) => u is Type<ReadonlyArray<CVTemplatePart.Type<string, unknown>>>;
71
+ /**
72
+ * Constructor
73
+ *
74
+ * @category Constructors
75
+ */
76
+ export declare const make: <const PS extends CVTemplateParts.Type>(...templateParts: PS) => Type<PS>;
77
+ /**
78
+ * Returns the `templateParts` property of `self`
79
+ *
80
+ * @category Destructors
81
+ */
82
+ export declare const templateParts: <const PS extends CVTemplateParts.Type>(self: Type<PS>) => PS;
83
+ /**
84
+ * Returns a function that parses a text into a record according to 'self' .
85
+ *
86
+ * @category Parsing
87
+ */
88
+ export declare const toParser: <const PS extends CVTemplateParts.Type>(self: Type<PS>) => MTypes.OneArgFunction<string, Either.Either<{ readonly [k in keyof MTypes.ArrayKeys<PS> as PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractName<PS[k]> : never]: PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractType<PS[k]> : never; }, MInputError.Type>>;
89
+ /**
90
+ * Same as toParser but the returned parser throws in case of error
91
+ *
92
+ * @category Parsing
93
+ */
94
+ export declare const toThrowingParser: <const PS extends CVTemplateParts.Type>(self: Type<PS>) => MTypes.OneArgFunction<string, {
95
+ readonly [k in keyof MTypes.ArrayKeys<PS> as PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractName<PS[k]> : never]: PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractType<PS[k]> : never;
96
+ }>;
97
+ /**
98
+ * Returns a function that formats an object into the template represented by 'self' . When
99
+ * strictMode is false, the formatter function of the templatepart's is replaced by the Either.right
100
+ * function, i.e. no checks are carried out when encoding
101
+ *
102
+ * @category Formatting
103
+ */
104
+ export declare const toFormatter: <const PS extends CVTemplateParts.Type>(self: Type<PS>) => MTypes.OneArgFunction<{ readonly [k in keyof MTypes.ArrayKeys<PS> as PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractName<PS[k]> : never]: PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractType<PS[k]> : never; }, Either.Either<string, MInputError.Type>>;
105
+ /**
106
+ * Same as toFormatter but the returned formatter throws in case of error
107
+ *
108
+ * @category Formatting
109
+ */
110
+ export declare const toThrowingFormatter: <const PS extends CVTemplateParts.Type>(self: Type<PS>) => MTypes.OneArgFunction<{
111
+ readonly [k in keyof MTypes.ArrayKeys<PS> as PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractName<PS[k]> : never]: PS[k] extends CVTemplatePlaceholder.All ? CVTemplatePlaceholder.ExtractType<PS[k]> : never;
112
+ }, string>;
113
+ //# sourceMappingURL=Template.d.ts.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AC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GACnF,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GACvC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GAAG,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAC1F,KAAK,GACP,EACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CA2BvC,CAAC;AAEF;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,eAAe,CAAC,IAAI,EACvE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,KACV,MAAM,CAAC,cAAc,CACzB;IACC,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GACnF,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GACvC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAAC,GAAG,GAAG,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAC1F,KAAK;CACP,EACD,MAAM,CACmF,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This module implements a TemplatePart type. TemplatePart's are the constituents of Template's
3
+ * (see Template.ts).
4
+ *
5
+ * There are two kinds of TemplateParts: TemplateSeparator's (see TemplateSeparator.ts) and
6
+ * TemplatePlaceholder's (see TemplatePlaceholder.ts)
7
+ */
8
+ import * as CVTemplatePlaceholder from './TemplatePlaceholder.js';
9
+ import * as CVTemplateSeparator from './TemplateSeparator.js';
10
+ /**
11
+ * Type of a TemplatePart
12
+ *
13
+ * @category Models
14
+ */
15
+ export type Type<N extends string, T> = CVTemplateSeparator.Type | CVTemplatePlaceholder.Type<N, T>;
16
+ /**
17
+ * Type guard
18
+ *
19
+ * @category Guards
20
+ */
21
+ export declare const isPlaceholder: <const N extends string, T>(u: Type<N, T>) => u is CVTemplatePlaceholder.Type<N, T>;
22
+ /**
23
+ * Type guard
24
+ *
25
+ * @category Guards
26
+ */
27
+ export declare const isSeparator: <const N extends string, T>(u: Type<N, T>) => u is CVTemplateSeparator.Type;
28
+ //# sourceMappingURL=TemplatePart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplatePart.d.ts","sourceRoot":"","sources":["../../esm/TemplatePart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,mBAAmB,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACtD,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KACX,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAiC,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACpD,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KACX,CAAC,IAAI,mBAAmB,CAAC,IAAkC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** This module implements an array of TemplatePart's (see TemplatePart.ts) */
2
+ import { MTypes } from '@parischap/effect-lib';
3
+ import * as CVTemplatePart from './TemplatePart.js';
4
+ /**
5
+ * Type of a TemplateParts
6
+ *
7
+ * @category Models
8
+ */
9
+ export interface Type<T = any> extends ReadonlyArray<CVTemplatePart.Type<string, T>> {
10
+ }
11
+ /**
12
+ * Shows a synthetic description of `self`, e.g.' #name is a #age-year-old #kind.'
13
+ *
14
+ * @category Destructors
15
+ */
16
+ export declare const getSyntheticDescription: MTypes.OneArgFunction<Type, string>;
17
+ /**
18
+ * Shows a description of the placeholders of `self`, e.g.' #name is a #age-year-old #kind.'
19
+ *
20
+ * @category Destructors
21
+ */
22
+ export declare const getPlaceholderDescription: MTypes.OneArgFunction<Type, string>;
23
+ //# sourceMappingURL=TemplateParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateParts.d.ts","sourceRoot":"","sources":["../../esm/TemplateParts.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAU,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AAIpD;;;;GAIG;AAEH,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAAG;AAEvF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAUvE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAazE,CAAC"}