@svta/cml-structured-field-values 0.19.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 (277) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +36 -0
  3. package/dist/SfBareItem.d.ts +9 -0
  4. package/dist/SfBareItem.d.ts.map +1 -0
  5. package/dist/SfBareItem.js +2 -0
  6. package/dist/SfBareItem.js.map +1 -0
  7. package/dist/SfDecodeOptions.d.ts +13 -0
  8. package/dist/SfDecodeOptions.d.ts.map +1 -0
  9. package/dist/SfDecodeOptions.js +2 -0
  10. package/dist/SfDecodeOptions.js.map +1 -0
  11. package/dist/SfDictionary.d.ts +9 -0
  12. package/dist/SfDictionary.d.ts.map +1 -0
  13. package/dist/SfDictionary.js +2 -0
  14. package/dist/SfDictionary.js.map +1 -0
  15. package/dist/SfEncodeOptions.d.ts +13 -0
  16. package/dist/SfEncodeOptions.d.ts.map +1 -0
  17. package/dist/SfEncodeOptions.js +2 -0
  18. package/dist/SfEncodeOptions.js.map +1 -0
  19. package/dist/SfInnerList.d.ts +14 -0
  20. package/dist/SfInnerList.d.ts.map +1 -0
  21. package/dist/SfInnerList.js +2 -0
  22. package/dist/SfInnerList.js.map +1 -0
  23. package/dist/SfItem.d.ts +14 -0
  24. package/dist/SfItem.d.ts.map +1 -0
  25. package/dist/SfItem.js +16 -0
  26. package/dist/SfItem.js.map +1 -0
  27. package/dist/SfMember.d.ts +11 -0
  28. package/dist/SfMember.d.ts.map +1 -0
  29. package/dist/SfMember.js +2 -0
  30. package/dist/SfMember.js.map +1 -0
  31. package/dist/SfParameters.d.ts +8 -0
  32. package/dist/SfParameters.d.ts.map +1 -0
  33. package/dist/SfParameters.js +2 -0
  34. package/dist/SfParameters.js.map +1 -0
  35. package/dist/SfToken.d.ts +11 -0
  36. package/dist/SfToken.d.ts.map +1 -0
  37. package/dist/SfToken.js +12 -0
  38. package/dist/SfToken.js.map +1 -0
  39. package/dist/decodeSfDict.d.ts +13 -0
  40. package/dist/decodeSfDict.d.ts.map +1 -0
  41. package/dist/decodeSfDict.js +25 -0
  42. package/dist/decodeSfDict.js.map +1 -0
  43. package/dist/decodeSfItem.d.ts +13 -0
  44. package/dist/decodeSfItem.d.ts.map +1 -0
  45. package/dist/decodeSfItem.js +46 -0
  46. package/dist/decodeSfItem.js.map +1 -0
  47. package/dist/decodeSfList.d.ts +13 -0
  48. package/dist/decodeSfList.d.ts.map +1 -0
  49. package/dist/decodeSfList.js +25 -0
  50. package/dist/decodeSfList.js.map +1 -0
  51. package/dist/encodeSfDict.d.ts +14 -0
  52. package/dist/encodeSfDict.d.ts.map +1 -0
  53. package/dist/encodeSfDict.js +16 -0
  54. package/dist/encodeSfDict.js.map +1 -0
  55. package/dist/encodeSfItem.d.ts +26 -0
  56. package/dist/encodeSfItem.d.ts.map +1 -0
  57. package/dist/encodeSfItem.js +9 -0
  58. package/dist/encodeSfItem.js.map +1 -0
  59. package/dist/encodeSfList.d.ts +15 -0
  60. package/dist/encodeSfList.d.ts.map +1 -0
  61. package/dist/encodeSfList.js +16 -0
  62. package/dist/encodeSfList.js.map +1 -0
  63. package/dist/index.d.ts +22 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +15 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/parse/ParsedValue.d.ts +6 -0
  68. package/dist/parse/ParsedValue.d.ts.map +1 -0
  69. package/dist/parse/ParsedValue.js +4 -0
  70. package/dist/parse/ParsedValue.js.map +1 -0
  71. package/dist/parse/index.d.ts +22 -0
  72. package/dist/parse/index.d.ts.map +1 -0
  73. package/dist/parse/index.js +21 -0
  74. package/dist/parse/index.js.map +1 -0
  75. package/dist/parse/parseBareItem.d.ts +5 -0
  76. package/dist/parse/parseBareItem.d.ts.map +1 -0
  77. package/dist/parse/parseBareItem.js +59 -0
  78. package/dist/parse/parseBareItem.js.map +1 -0
  79. package/dist/parse/parseBoolean.d.ts +3 -0
  80. package/dist/parse/parseBoolean.d.ts.map +1 -0
  81. package/dist/parse/parseBoolean.js +34 -0
  82. package/dist/parse/parseBoolean.js.map +1 -0
  83. package/dist/parse/parseByteSequence.d.ts +3 -0
  84. package/dist/parse/parseByteSequence.d.ts.map +1 -0
  85. package/dist/parse/parseByteSequence.js +59 -0
  86. package/dist/parse/parseByteSequence.js.map +1 -0
  87. package/dist/parse/parseDate.d.ts +3 -0
  88. package/dist/parse/parseDate.d.ts.map +1 -0
  89. package/dist/parse/parseDate.js +32 -0
  90. package/dist/parse/parseDate.js.map +1 -0
  91. package/dist/parse/parseDict.d.ts +5 -0
  92. package/dist/parse/parseDict.d.ts.map +1 -0
  93. package/dist/parse/parseDict.js +90 -0
  94. package/dist/parse/parseDict.js.map +1 -0
  95. package/dist/parse/parseError.d.ts +2 -0
  96. package/dist/parse/parseError.d.ts.map +1 -0
  97. package/dist/parse/parseError.js +5 -0
  98. package/dist/parse/parseError.js.map +1 -0
  99. package/dist/parse/parseInnerList.d.ts +5 -0
  100. package/dist/parse/parseInnerList.d.ts.map +1 -0
  101. package/dist/parse/parseInnerList.js +62 -0
  102. package/dist/parse/parseInnerList.js.map +1 -0
  103. package/dist/parse/parseIntegerOrDecimal.d.ts +3 -0
  104. package/dist/parse/parseIntegerOrDecimal.d.ts.map +1 -0
  105. package/dist/parse/parseIntegerOrDecimal.js +123 -0
  106. package/dist/parse/parseIntegerOrDecimal.js.map +1 -0
  107. package/dist/parse/parseItem.d.ts +5 -0
  108. package/dist/parse/parseItem.d.ts.map +1 -0
  109. package/dist/parse/parseItem.js +25 -0
  110. package/dist/parse/parseItem.js.map +1 -0
  111. package/dist/parse/parseItemOrInnerList.d.ts +6 -0
  112. package/dist/parse/parseItemOrInnerList.d.ts.map +1 -0
  113. package/dist/parse/parseItemOrInnerList.js +22 -0
  114. package/dist/parse/parseItemOrInnerList.js.map +1 -0
  115. package/dist/parse/parseKey.d.ts +3 -0
  116. package/dist/parse/parseKey.d.ts.map +1 -0
  117. package/dist/parse/parseKey.js +40 -0
  118. package/dist/parse/parseKey.js.map +1 -0
  119. package/dist/parse/parseList.d.ts +5 -0
  120. package/dist/parse/parseList.d.ts.map +1 -0
  121. package/dist/parse/parseList.js +51 -0
  122. package/dist/parse/parseList.js.map +1 -0
  123. package/dist/parse/parseParameters.d.ts +5 -0
  124. package/dist/parse/parseParameters.d.ts.map +1 -0
  125. package/dist/parse/parseParameters.js +68 -0
  126. package/dist/parse/parseParameters.js.map +1 -0
  127. package/dist/parse/parseString.d.ts +3 -0
  128. package/dist/parse/parseString.d.ts.map +1 -0
  129. package/dist/parse/parseString.js +73 -0
  130. package/dist/parse/parseString.js.map +1 -0
  131. package/dist/parse/parseToken.d.ts +5 -0
  132. package/dist/parse/parseToken.d.ts.map +1 -0
  133. package/dist/parse/parseToken.js +35 -0
  134. package/dist/parse/parseToken.js.map +1 -0
  135. package/dist/serialize/index.d.ts +21 -0
  136. package/dist/serialize/index.d.ts.map +1 -0
  137. package/dist/serialize/index.js +21 -0
  138. package/dist/serialize/index.js.map +1 -0
  139. package/dist/serialize/serializeBareItem.d.ts +2 -0
  140. package/dist/serialize/serializeBareItem.d.ts.map +1 -0
  141. package/dist/serialize/serializeBareItem.js +69 -0
  142. package/dist/serialize/serializeBareItem.js.map +1 -0
  143. package/dist/serialize/serializeBoolean.d.ts +2 -0
  144. package/dist/serialize/serializeBoolean.d.ts.map +1 -0
  145. package/dist/serialize/serializeBoolean.js +25 -0
  146. package/dist/serialize/serializeBoolean.js.map +1 -0
  147. package/dist/serialize/serializeByteSequence.d.ts +2 -0
  148. package/dist/serialize/serializeByteSequence.d.ts.map +1 -0
  149. package/dist/serialize/serializeByteSequence.js +34 -0
  150. package/dist/serialize/serializeByteSequence.js.map +1 -0
  151. package/dist/serialize/serializeDate.d.ts +2 -0
  152. package/dist/serialize/serializeDate.d.ts.map +1 -0
  153. package/dist/serialize/serializeDate.js +13 -0
  154. package/dist/serialize/serializeDate.js.map +1 -0
  155. package/dist/serialize/serializeDecimal.d.ts +2 -0
  156. package/dist/serialize/serializeDecimal.d.ts.map +1 -0
  157. package/dist/serialize/serializeDecimal.js +46 -0
  158. package/dist/serialize/serializeDecimal.js.map +1 -0
  159. package/dist/serialize/serializeDict.d.ts +3 -0
  160. package/dist/serialize/serializeDict.d.ts.map +1 -0
  161. package/dist/serialize/serializeDict.js +74 -0
  162. package/dist/serialize/serializeDict.js.map +1 -0
  163. package/dist/serialize/serializeError.d.ts +2 -0
  164. package/dist/serialize/serializeError.d.ts.map +1 -0
  165. package/dist/serialize/serializeError.js +5 -0
  166. package/dist/serialize/serializeError.js.map +1 -0
  167. package/dist/serialize/serializeInnerList.d.ts +3 -0
  168. package/dist/serialize/serializeInnerList.d.ts.map +1 -0
  169. package/dist/serialize/serializeInnerList.js +28 -0
  170. package/dist/serialize/serializeInnerList.js.map +1 -0
  171. package/dist/serialize/serializeInteger.d.ts +2 -0
  172. package/dist/serialize/serializeInteger.d.ts.map +1 -0
  173. package/dist/serialize/serializeInteger.js +28 -0
  174. package/dist/serialize/serializeInteger.js.map +1 -0
  175. package/dist/serialize/serializeItem.d.ts +4 -0
  176. package/dist/serialize/serializeItem.d.ts.map +1 -0
  177. package/dist/serialize/serializeItem.js +26 -0
  178. package/dist/serialize/serializeItem.js.map +1 -0
  179. package/dist/serialize/serializeKey.d.ts +2 -0
  180. package/dist/serialize/serializeKey.d.ts.map +1 -0
  181. package/dist/serialize/serializeKey.js +28 -0
  182. package/dist/serialize/serializeKey.js.map +1 -0
  183. package/dist/serialize/serializeList.d.ts +4 -0
  184. package/dist/serialize/serializeList.d.ts.map +1 -0
  185. package/dist/serialize/serializeList.js +48 -0
  186. package/dist/serialize/serializeList.js.map +1 -0
  187. package/dist/serialize/serializeParams.d.ts +2 -0
  188. package/dist/serialize/serializeParams.d.ts.map +1 -0
  189. package/dist/serialize/serializeParams.js +40 -0
  190. package/dist/serialize/serializeParams.js.map +1 -0
  191. package/dist/serialize/serializeString.d.ts +2 -0
  192. package/dist/serialize/serializeString.d.ts.map +1 -0
  193. package/dist/serialize/serializeString.js +34 -0
  194. package/dist/serialize/serializeString.js.map +1 -0
  195. package/dist/serialize/serializeToken.d.ts +4 -0
  196. package/dist/serialize/serializeToken.d.ts.map +1 -0
  197. package/dist/serialize/serializeToken.js +11 -0
  198. package/dist/serialize/serializeToken.js.map +1 -0
  199. package/dist/tsconfig.tsbuildinfo +1 -0
  200. package/dist/tsdoc-metadata.json +11 -0
  201. package/dist/utils/BARE_ITEM.d.ts +2 -0
  202. package/dist/utils/BARE_ITEM.d.ts.map +1 -0
  203. package/dist/utils/BARE_ITEM.js +2 -0
  204. package/dist/utils/BARE_ITEM.js.map +1 -0
  205. package/dist/utils/BOOLEAN.d.ts +2 -0
  206. package/dist/utils/BOOLEAN.d.ts.map +1 -0
  207. package/dist/utils/BOOLEAN.js +2 -0
  208. package/dist/utils/BOOLEAN.js.map +1 -0
  209. package/dist/utils/BYTES.d.ts +2 -0
  210. package/dist/utils/BYTES.d.ts.map +1 -0
  211. package/dist/utils/BYTES.js +2 -0
  212. package/dist/utils/BYTES.js.map +1 -0
  213. package/dist/utils/DATE.d.ts +2 -0
  214. package/dist/utils/DATE.d.ts.map +1 -0
  215. package/dist/utils/DATE.js +2 -0
  216. package/dist/utils/DATE.js.map +1 -0
  217. package/dist/utils/DECIMAL.d.ts +2 -0
  218. package/dist/utils/DECIMAL.d.ts.map +1 -0
  219. package/dist/utils/DECIMAL.js +2 -0
  220. package/dist/utils/DECIMAL.js.map +1 -0
  221. package/dist/utils/DICT.d.ts +2 -0
  222. package/dist/utils/DICT.d.ts.map +1 -0
  223. package/dist/utils/DICT.js +2 -0
  224. package/dist/utils/DICT.js.map +1 -0
  225. package/dist/utils/INNER.d.ts +2 -0
  226. package/dist/utils/INNER.d.ts.map +1 -0
  227. package/dist/utils/INNER.js +2 -0
  228. package/dist/utils/INNER.js.map +1 -0
  229. package/dist/utils/INTEGER.d.ts +2 -0
  230. package/dist/utils/INTEGER.d.ts.map +1 -0
  231. package/dist/utils/INTEGER.js +2 -0
  232. package/dist/utils/INTEGER.js.map +1 -0
  233. package/dist/utils/INTEGER_DECIMAL.d.ts +2 -0
  234. package/dist/utils/INTEGER_DECIMAL.d.ts.map +1 -0
  235. package/dist/utils/INTEGER_DECIMAL.js +4 -0
  236. package/dist/utils/INTEGER_DECIMAL.js.map +1 -0
  237. package/dist/utils/ITEM.d.ts +2 -0
  238. package/dist/utils/ITEM.d.ts.map +1 -0
  239. package/dist/utils/ITEM.js +2 -0
  240. package/dist/utils/ITEM.js.map +1 -0
  241. package/dist/utils/KEY.d.ts +2 -0
  242. package/dist/utils/KEY.d.ts.map +1 -0
  243. package/dist/utils/KEY.js +2 -0
  244. package/dist/utils/KEY.js.map +1 -0
  245. package/dist/utils/LIST.d.ts +2 -0
  246. package/dist/utils/LIST.d.ts.map +1 -0
  247. package/dist/utils/LIST.js +2 -0
  248. package/dist/utils/LIST.js.map +1 -0
  249. package/dist/utils/STRING.d.ts +2 -0
  250. package/dist/utils/STRING.d.ts.map +1 -0
  251. package/dist/utils/STRING.js +2 -0
  252. package/dist/utils/STRING.js.map +1 -0
  253. package/dist/utils/STRING_REGEX.d.ts +2 -0
  254. package/dist/utils/STRING_REGEX.d.ts.map +1 -0
  255. package/dist/utils/STRING_REGEX.js +2 -0
  256. package/dist/utils/STRING_REGEX.js.map +1 -0
  257. package/dist/utils/TOKEN.d.ts +2 -0
  258. package/dist/utils/TOKEN.d.ts.map +1 -0
  259. package/dist/utils/TOKEN.js +2 -0
  260. package/dist/utils/TOKEN.js.map +1 -0
  261. package/dist/utils/index.d.ts +10 -0
  262. package/dist/utils/index.d.ts.map +1 -0
  263. package/dist/utils/index.js +10 -0
  264. package/dist/utils/index.js.map +1 -0
  265. package/dist/utils/isInvalidInt.d.ts +2 -0
  266. package/dist/utils/isInvalidInt.d.ts.map +1 -0
  267. package/dist/utils/isInvalidInt.js +4 -0
  268. package/dist/utils/isInvalidInt.js.map +1 -0
  269. package/dist/utils/symbolToStr.d.ts +13 -0
  270. package/dist/utils/symbolToStr.d.ts.map +1 -0
  271. package/dist/utils/symbolToStr.js +14 -0
  272. package/dist/utils/symbolToStr.js.map +1 -0
  273. package/dist/utils/throwError.d.ts +2 -0
  274. package/dist/utils/throwError.d.ts.map +1 -0
  275. package/dist/utils/throwError.js +19 -0
  276. package/dist/utils/throwError.js.map +1 -0
  277. package/package.json +75 -0
@@ -0,0 +1,25 @@
1
+ import { parseError } from './parse/parseError.js';
2
+ import { parseList } from './parse/parseList.js';
3
+ import { LIST } from './utils/LIST.js';
4
+ /**
5
+ * Decode a structured field string into a structured field list
6
+ *
7
+ * @param input - The structured field string to decode
8
+ * @returns The structured field list
9
+ *
10
+ *
11
+ * @beta
12
+ */
13
+ export function decodeSfList(input, options) {
14
+ try {
15
+ const { src, value } = parseList(input.trim(), options);
16
+ if (src !== '') {
17
+ throw parseError(src, LIST);
18
+ }
19
+ return value;
20
+ }
21
+ catch (cause) {
22
+ throw parseError(input, LIST, cause);
23
+ }
24
+ }
25
+ //# sourceMappingURL=decodeSfList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeSfList.js","sourceRoot":"","sources":["../src/decodeSfList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,OAAyB;IACpE,IAAI,CAAC;QACJ,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;YAChB,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACd,MAAM,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;AACF,CAAC","sourcesContent":["import type { SfDecodeOptions } from './SfDecodeOptions.js';\nimport type { SfMember } from './SfMember.js';\nimport { parseError } from './parse/parseError.js';\nimport { parseList } from './parse/parseList.js';\nimport { LIST } from './utils/LIST.js';\n\n/**\n * Decode a structured field string into a structured field list\n *\n * @param input - The structured field string to decode\n * @returns The structured field list\n *\n *\n * @beta\n */\nexport function decodeSfList(input: string, options?: SfDecodeOptions): SfMember[] {\n\ttry {\n\t\tconst { src, value } = parseList(input.trim(), options);\n\t\tif (src !== '') {\n\t\t\tthrow parseError(src, LIST);\n\t\t}\n\t\treturn value;\n\t}\n\tcatch (cause) {\n\t\tthrow parseError(input, LIST, cause);\n\t}\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { SfEncodeOptions } from './SfEncodeOptions.js';
2
+ /**
3
+ * Encode an object into a structured field dictionary
4
+ *
5
+ * @param value - The structured field dictionary to encode
6
+ * @param options - Encoding options
7
+ *
8
+ * @returns The structured field string
9
+ *
10
+ *
11
+ * @beta
12
+ */
13
+ export declare function encodeSfDict(value: Record<string, any> | Map<string, any>, options?: SfEncodeOptions): string;
14
+ //# sourceMappingURL=encodeSfDict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfDict.d.ts","sourceRoot":"","sources":["../src/encodeSfDict.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CAE7G"}
@@ -0,0 +1,16 @@
1
+ import { serializeDict } from './serialize/serializeDict.js';
2
+ /**
3
+ * Encode an object into a structured field dictionary
4
+ *
5
+ * @param value - The structured field dictionary to encode
6
+ * @param options - Encoding options
7
+ *
8
+ * @returns The structured field string
9
+ *
10
+ *
11
+ * @beta
12
+ */
13
+ export function encodeSfDict(value, options) {
14
+ return serializeDict(value, options);
15
+ }
16
+ //# sourceMappingURL=encodeSfDict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfDict.js","sourceRoot":"","sources":["../src/encodeSfDict.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAA6C,EAAE,OAAyB;IACpG,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { SfEncodeOptions } from './SfEncodeOptions.js';\nimport { serializeDict } from './serialize/serializeDict.js';\n\n/**\n * Encode an object into a structured field dictionary\n *\n * @param value - The structured field dictionary to encode\n * @param options - Encoding options\n *\n * @returns The structured field string\n *\n *\n * @beta\n */\nexport function encodeSfDict(value: Record<string, any> | Map<string, any>, options?: SfEncodeOptions): string {\n\treturn serializeDict(value, options);\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { SfBareItem } from './SfBareItem.js';
2
+ import { SfItem } from './SfItem.js';
3
+ import type { SfParameters } from './SfParameters.js';
4
+ /**
5
+ * Encode a structured field item to a string
6
+ *
7
+ * @param value - The structured field item to encode
8
+ *
9
+ * @returns The structured field string
10
+ *
11
+ *
12
+ * @beta
13
+ */
14
+ export declare function encodeSfItem(value: SfItem): string;
15
+ /**
16
+ * Encode a structured field value to a string with optional parameters.
17
+ *
18
+ * @param value - The structured field value to encode
19
+ * @param params - The structured field parameters
20
+ *
21
+ * @returns The structured field string
22
+ *
23
+ * @beta
24
+ */
25
+ export declare function encodeSfItem(value: SfBareItem, params?: SfParameters): string;
26
+ //# sourceMappingURL=encodeSfItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfItem.d.ts","sourceRoot":"","sources":["../src/encodeSfItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { SfItem } from './SfItem.js';
2
+ import { serializeItem } from './serialize/serializeItem.js';
3
+ export function encodeSfItem(value, params) {
4
+ if (!(value instanceof SfItem)) {
5
+ value = new SfItem(value, params);
6
+ }
7
+ return serializeItem(value);
8
+ }
9
+ //# sourceMappingURL=encodeSfItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfItem.js","sourceRoot":"","sources":["../src/encodeSfItem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AA0B7D,MAAM,UAAU,YAAY,CAAC,KAA0B,EAAE,MAAqB;IAC7E,IAAI,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC,EAAE,CAAC;QAChC,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import type { SfBareItem } from './SfBareItem.js';\nimport { SfItem } from './SfItem.js';\nimport type { SfParameters } from './SfParameters.js';\nimport { serializeItem } from './serialize/serializeItem.js';\n\n/**\n * Encode a structured field item to a string\n *\n * @param value - The structured field item to encode\n *\n * @returns The structured field string\n *\n *\n * @beta\n */\nexport function encodeSfItem(value: SfItem): string;\n\n/**\n * Encode a structured field value to a string with optional parameters.\n *\n * @param value - The structured field value to encode\n * @param params - The structured field parameters\n *\n * @returns The structured field string\n *\n * @beta\n */\nexport function encodeSfItem(value: SfBareItem, params?: SfParameters): string;\n\nexport function encodeSfItem(value: SfItem | SfBareItem, params?: SfParameters) {\n\tif (!(value instanceof SfItem)) {\n\t\tvalue = new SfItem(value, params);\n\t}\n\n\treturn serializeItem(value);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { SfEncodeOptions } from './SfEncodeOptions.js';
2
+ import type { SfMember } from './SfMember.js';
3
+ /**
4
+ * Encode a list into a structured field dictionary
5
+ *
6
+ * @param value - The structured field list to encode
7
+ * @param options - Encoding options
8
+ *
9
+ * @returns The structured field string
10
+ *
11
+ *
12
+ * @beta
13
+ */
14
+ export declare function encodeSfList(value: SfMember[], options?: SfEncodeOptions): string;
15
+ //# sourceMappingURL=encodeSfList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfList.d.ts","sourceRoot":"","sources":["../src/encodeSfList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CAEjF"}
@@ -0,0 +1,16 @@
1
+ import { serializeList } from './serialize/serializeList.js';
2
+ /**
3
+ * Encode a list into a structured field dictionary
4
+ *
5
+ * @param value - The structured field list to encode
6
+ * @param options - Encoding options
7
+ *
8
+ * @returns The structured field string
9
+ *
10
+ *
11
+ * @beta
12
+ */
13
+ export function encodeSfList(value, options) {
14
+ return serializeList(value, options);
15
+ }
16
+ //# sourceMappingURL=encodeSfList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeSfList.js","sourceRoot":"","sources":["../src/encodeSfList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiB,EAAE,OAAyB;IACxE,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { SfEncodeOptions } from './SfEncodeOptions.js';\nimport type { SfMember } from './SfMember.js';\nimport { serializeList } from './serialize/serializeList.js';\n\n/**\n * Encode a list into a structured field dictionary\n *\n * @param value - The structured field list to encode\n * @param options - Encoding options\n *\n * @returns The structured field string\n *\n *\n * @beta\n */\nexport function encodeSfList(value: SfMember[], options?: SfEncodeOptions): string {\n\treturn serializeList(value, options);\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A collection of tools for working with structured fields.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export * from './decodeSfDict.js';
7
+ export * from './decodeSfItem.js';
8
+ export * from './decodeSfList.js';
9
+ export * from './encodeSfDict.js';
10
+ export * from './encodeSfItem.js';
11
+ export * from './encodeSfList.js';
12
+ export type * from './SfBareItem.js';
13
+ export type * from './SfDecodeOptions.js';
14
+ export type * from './SfDictionary.js';
15
+ export type * from './SfEncodeOptions.js';
16
+ export type * from './SfInnerList.js';
17
+ export * from './SfItem.js';
18
+ export type * from './SfMember.js';
19
+ export type * from './SfParameters.js';
20
+ export * from './SfToken.js';
21
+ export * from './utils/symbolToStr.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,kBAAkB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A collection of tools for working with structured fields.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export * from './decodeSfDict.js';
7
+ export * from './decodeSfItem.js';
8
+ export * from './decodeSfList.js';
9
+ export * from './encodeSfDict.js';
10
+ export * from './encodeSfItem.js';
11
+ export * from './encodeSfList.js';
12
+ export * from './SfItem.js';
13
+ export * from './SfToken.js';
14
+ export * from './utils/symbolToStr.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAMlC,cAAc,aAAa,CAAC;AAG5B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC","sourcesContent":["/**\n * A collection of tools for working with structured fields.\n *\n * @packageDocumentation\n */\nexport * from './decodeSfDict.js';\nexport * from './decodeSfItem.js';\nexport * from './decodeSfList.js';\nexport * from './encodeSfDict.js';\nexport * from './encodeSfItem.js';\nexport * from './encodeSfList.js';\nexport type * from './SfBareItem.js';\nexport type * from './SfDecodeOptions.js';\nexport type * from './SfDictionary.js';\nexport type * from './SfEncodeOptions.js';\nexport type * from './SfInnerList.js';\nexport * from './SfItem.js';\nexport type * from './SfMember.js';\nexport type * from './SfParameters.js';\nexport * from './SfToken.js';\nexport * from './utils/symbolToStr.js';\n"]}
@@ -0,0 +1,6 @@
1
+ export type ParsedValue<T> = {
2
+ value: T;
3
+ src: string;
4
+ };
5
+ export declare function parsedValue<T>(value: T, src: string): ParsedValue<T>;
6
+ //# sourceMappingURL=ParsedValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParsedValue.d.ts","sourceRoot":"","sources":["../../src/parse/ParsedValue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAEpE"}
@@ -0,0 +1,4 @@
1
+ export function parsedValue(value, src) {
2
+ return { value, src };
3
+ }
4
+ //# sourceMappingURL=ParsedValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParsedValue.js","sourceRoot":"","sources":["../../src/parse/ParsedValue.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,WAAW,CAAI,KAAQ,EAAE,GAAW;IACnD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACvB,CAAC","sourcesContent":["export type ParsedValue<T> = {\n\tvalue: T;\n\tsrc: string;\n};\n\nexport function parsedValue<T>(value: T, src: string): ParsedValue<T> {\n\treturn { value, src };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Parsing utilities for structured fields.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export * from './parseBareItem.js';
7
+ export * from './parseBoolean.js';
8
+ export * from './parseByteSequence.js';
9
+ export * from './parseDate.js';
10
+ export * from './parseDict.js';
11
+ export type { ParsedValue } from './ParsedValue.js';
12
+ export * from './parseError.js';
13
+ export * from './parseInnerList.js';
14
+ export * from './parseIntegerOrDecimal.js';
15
+ export * from './parseItem.js';
16
+ export * from './parseItemOrInnerList.js';
17
+ export * from './parseKey.js';
18
+ export * from './parseList.js';
19
+ export * from './parseParameters.js';
20
+ export * from './parseString.js';
21
+ export * from './parseToken.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Parsing utilities for structured fields.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export * from './parseBareItem.js';
7
+ export * from './parseBoolean.js';
8
+ export * from './parseByteSequence.js';
9
+ export * from './parseDate.js';
10
+ export * from './parseDict.js';
11
+ export * from './parseError.js';
12
+ export * from './parseInnerList.js';
13
+ export * from './parseIntegerOrDecimal.js';
14
+ export * from './parseItem.js';
15
+ export * from './parseItemOrInnerList.js';
16
+ export * from './parseKey.js';
17
+ export * from './parseList.js';
18
+ export * from './parseParameters.js';
19
+ export * from './parseString.js';
20
+ export * from './parseToken.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * Parsing utilities for structured fields.\n *\n * @packageDocumentation\n */\nexport * from './parseBareItem.js';\nexport * from './parseBoolean.js';\nexport * from './parseByteSequence.js';\nexport * from './parseDate.js';\nexport * from './parseDict.js';\nexport type { ParsedValue } from './ParsedValue.js';\nexport * from './parseError.js';\nexport * from './parseInnerList.js';\nexport * from './parseIntegerOrDecimal.js';\nexport * from './parseItem.js';\nexport * from './parseItemOrInnerList.js';\nexport * from './parseKey.js';\nexport * from './parseList.js';\nexport * from './parseParameters.js';\nexport * from './parseString.js';\nexport * from './parseToken.js';\n\n"]}
@@ -0,0 +1,5 @@
1
+ import type { SfBareItem } from '../SfBareItem.js';
2
+ import type { SfDecodeOptions } from '../SfDecodeOptions.js';
3
+ import type { ParsedValue } from './ParsedValue.js';
4
+ export declare function parseBareItem(src: string, options?: SfDecodeOptions): ParsedValue<SfBareItem>;
5
+ //# sourceMappingURL=parseBareItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBareItem.d.ts","sourceRoot":"","sources":["../../src/parse/parseBareItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqCpD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC,CAqB7F"}
@@ -0,0 +1,59 @@
1
+ import { BARE_ITEM } from '../utils/BARE_ITEM.js';
2
+ import { parseBoolean } from './parseBoolean.js';
3
+ import { parseByteSequence } from './parseByteSequence.js';
4
+ import { parseDate } from './parseDate.js';
5
+ import { parseError } from './parseError.js';
6
+ import { parseIntegerOrDecimal } from './parseIntegerOrDecimal.js';
7
+ import { parseString } from './parseString.js';
8
+ import { parseToken } from './parseToken.js';
9
+ // 4.2.3.1. Parsing a Bare Item
10
+ //
11
+ // Given an ASCII string as input_string, return a bare Item.
12
+ // input_string is modified to remove the parsed value.
13
+ //
14
+ // 1. If the first character of input_string is a "-" or a DIGIT,
15
+ // return the result of running Parsing an Integer or Decimal
16
+ // (Section 4.2.4) with input_string.
17
+ //
18
+ // 2. If the first character of input_string is a DQUOTE, return the
19
+ // result of running Parsing a String (Section 4.2.5) with
20
+ // input_string.
21
+ //
22
+ // 3. If the first character of input_string is ":", return the result
23
+ // of running Parsing a Byte Sequence (Section 4.2.7) with
24
+ // input_string.
25
+ //
26
+ // 4. If the first character of input_string is "?", return the result
27
+ // of running Parsing a Boolean (Section 4.2.8) with input_string.
28
+ //
29
+ // 5. If the first character of input_string is an ALPHA or "*", return
30
+ // the result of running Parsing a Token (Section 4.2.6) with
31
+ // input_string.
32
+ //
33
+ // 6. If the first character of input_string is "@", return the result
34
+ // of running Parsing a Date (Section 4.2.9) with input_string.
35
+ //
36
+ // 7. Otherwise, the item type is unrecognized; fail parsing.
37
+ export function parseBareItem(src, options) {
38
+ const first = src[0];
39
+ if (first === `"`) {
40
+ return parseString(src);
41
+ }
42
+ if (/^[-0-9]/.test(first)) {
43
+ return parseIntegerOrDecimal(src);
44
+ }
45
+ if (first === `?`) {
46
+ return parseBoolean(src);
47
+ }
48
+ if (first === `:`) {
49
+ return parseByteSequence(src);
50
+ }
51
+ if (/^[a-zA-Z*]/.test(first)) {
52
+ return parseToken(src, options);
53
+ }
54
+ if (first === `@`) {
55
+ return parseDate(src);
56
+ }
57
+ throw parseError(src, BARE_ITEM);
58
+ }
59
+ //# sourceMappingURL=parseBareItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBareItem.js","sourceRoot":"","sources":["../../src/parse/parseBareItem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,gCAAgC;AAChC,EAAE;AACF,6DAA6D;AAC7D,uDAAuD;AACvD,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,yCAAyC;AACzC,EAAE;AACF,qEAAqE;AACrE,8DAA8D;AAC9D,oBAAoB;AACpB,EAAE;AACF,uEAAuE;AACvE,8DAA8D;AAC9D,oBAAoB;AACpB,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,EAAE;AACF,wEAAwE;AACxE,iEAAiE;AACjE,oBAAoB;AACpB,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,EAAE;AACF,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,OAAyB;IACnE,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,MAAM,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { SfBareItem } from '../SfBareItem.js';\nimport type { SfDecodeOptions } from '../SfDecodeOptions.js';\nimport { BARE_ITEM } from '../utils/BARE_ITEM.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parseBoolean } from './parseBoolean.js';\nimport { parseByteSequence } from './parseByteSequence.js';\nimport { parseDate } from './parseDate.js';\nimport { parseError } from './parseError.js';\nimport { parseIntegerOrDecimal } from './parseIntegerOrDecimal.js';\nimport { parseString } from './parseString.js';\nimport { parseToken } from './parseToken.js';\n\n// 4.2.3.1. Parsing a Bare Item\n//\n// Given an ASCII string as input_string, return a bare Item.\n// input_string is modified to remove the parsed value.\n//\n// 1. If the first character of input_string is a \"-\" or a DIGIT,\n// return the result of running Parsing an Integer or Decimal\n// (Section 4.2.4) with input_string.\n//\n// 2. If the first character of input_string is a DQUOTE, return the\n// result of running Parsing a String (Section 4.2.5) with\n// input_string.\n//\n// 3. If the first character of input_string is \":\", return the result\n// of running Parsing a Byte Sequence (Section 4.2.7) with\n// input_string.\n//\n// 4. If the first character of input_string is \"?\", return the result\n// of running Parsing a Boolean (Section 4.2.8) with input_string.\n//\n// 5. If the first character of input_string is an ALPHA or \"*\", return\n// the result of running Parsing a Token (Section 4.2.6) with\n// input_string.\n//\n// 6. If the first character of input_string is \"@\", return the result\n// of running Parsing a Date (Section 4.2.9) with input_string.\n//\n// 7. Otherwise, the item type is unrecognized; fail parsing.\nexport function parseBareItem(src: string, options?: SfDecodeOptions): ParsedValue<SfBareItem> {\n\tconst first = src[0];\n\tif (first === `\"`) {\n\t\treturn parseString(src);\n\t}\n\tif (/^[-0-9]/.test(first)) {\n\t\treturn parseIntegerOrDecimal(src);\n\t}\n\tif (first === `?`) {\n\t\treturn parseBoolean(src);\n\t}\n\tif (first === `:`) {\n\t\treturn parseByteSequence(src);\n\t}\n\tif (/^[a-zA-Z*]/.test(first)) {\n\t\treturn parseToken(src, options);\n\t}\n\tif (first === `@`) {\n\t\treturn parseDate(src);\n\t}\n\tthrow parseError(src, BARE_ITEM);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ParsedValue } from './ParsedValue.js';
2
+ export declare function parseBoolean(src: string): ParsedValue<boolean>;
3
+ //# sourceMappingURL=parseBoolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBoolean.d.ts","sourceRoot":"","sources":["../../src/parse/parseBoolean.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoBpD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAiB9D"}
@@ -0,0 +1,34 @@
1
+ import { BOOLEAN } from '../utils/BOOLEAN.js';
2
+ import { parsedValue } from './ParsedValue.js';
3
+ import { parseError } from './parseError.js';
4
+ // 4.2.8. Parsing a Boolean
5
+ //
6
+ // Given an ASCII string as input_string, return a Boolean. input_string
7
+ // is modified to remove the parsed value.
8
+ //
9
+ // 1. If the first character of input_string is not "?", fail parsing.
10
+ //
11
+ // 2. Discard the first character of input_string.
12
+ //
13
+ // 3. If the first character of input_string matches "1", discard the
14
+ // first character, and return true.
15
+ //
16
+ // 4. If the first character of input_string matches "0", discard the
17
+ // first character, and return false.
18
+ //
19
+ // 5. No value has matched; fail parsing.
20
+ export function parseBoolean(src) {
21
+ let i = 0;
22
+ if (src[i] !== '?') {
23
+ throw parseError(src, BOOLEAN);
24
+ }
25
+ i++;
26
+ if (src[i] === '1') {
27
+ return parsedValue(true, src.substring(++i));
28
+ }
29
+ if (src[i] === '0') {
30
+ return parsedValue(false, src.substring(++i));
31
+ }
32
+ throw parseError(src, BOOLEAN);
33
+ }
34
+ //# sourceMappingURL=parseBoolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBoolean.js","sourceRoot":"","sources":["../../src/parse/parseBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,4BAA4B;AAC5B,EAAE;AACF,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,sEAAsE;AACtE,wCAAwC;AACxC,EAAE;AACF,sEAAsE;AACtE,yCAAyC;AACzC,EAAE;AACF,0CAA0C;AAC1C,MAAM,UAAU,YAAY,CAAC,GAAW;IACvC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,MAAM,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,CAAC,EAAE,CAAC;IAEJ,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { BOOLEAN } from '../utils/BOOLEAN.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseError } from './parseError.js';\n\n// 4.2.8. Parsing a Boolean\n//\n// Given an ASCII string as input_string, return a Boolean. input_string\n// is modified to remove the parsed value.\n//\n// 1. If the first character of input_string is not \"?\", fail parsing.\n//\n// 2. Discard the first character of input_string.\n//\n// 3. If the first character of input_string matches \"1\", discard the\n// first character, and return true.\n//\n// 4. If the first character of input_string matches \"0\", discard the\n// first character, and return false.\n//\n// 5. No value has matched; fail parsing.\nexport function parseBoolean(src: string): ParsedValue<boolean> {\n\tlet i = 0;\n\tif (src[i] !== '?') {\n\t\tthrow parseError(src, BOOLEAN);\n\t}\n\n\ti++;\n\n\tif (src[i] === '1') {\n\t\treturn parsedValue(true, src.substring(++i));\n\t}\n\n\tif (src[i] === '0') {\n\t\treturn parsedValue(false, src.substring(++i));\n\t}\n\n\tthrow parseError(src, BOOLEAN);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ParsedValue } from './ParsedValue.js';
2
+ export declare function parseByteSequence(src: string): ParsedValue<Uint8Array>;
3
+ //# sourceMappingURL=parseByteSequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseByteSequence.d.ts","sourceRoot":"","sources":["../../src/parse/parseByteSequence.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA4CpD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAmBtE"}
@@ -0,0 +1,59 @@
1
+ import { decodeBase64 } from '@svta/cml-utils/decodeBase64.js';
2
+ import { BYTES } from '../utils/BYTES.js';
3
+ import { parsedValue } from './ParsedValue.js';
4
+ import { parseError } from './parseError.js';
5
+ // 4.2.7. Parsing a Byte Sequence
6
+ //
7
+ // Given an ASCII string as input_string, return a Byte Sequence.
8
+ // input_string is modified to remove the parsed value.
9
+ //
10
+ // 1. If the first character of input_string is not ":", fail parsing.
11
+ //
12
+ // 2. Discard the first character of input_string.
13
+ //
14
+ // 3. If there is not a ":" character before the end of input_string,
15
+ // fail parsing.
16
+ //
17
+ // 4. Let b64_content be the result of consuming content of
18
+ // input_string up to but not including the first instance of the
19
+ // character ":".
20
+ //
21
+ // 5. Consume the ":" character at the beginning of input_string.
22
+ //
23
+ // 6. If b64_content contains a character not included in ALPHA, DIGIT,
24
+ // "+", "/" and "=", fail parsing.
25
+ //
26
+ // 7. Let binary_content be the result of Base 64 Decoding [RFC4648]
27
+ // b64_content, synthesizing padding if necessary (note the
28
+ // requirements about recipient behavior below).
29
+ //
30
+ // 8. Return binary_content.
31
+ //
32
+ // Because some implementations of base64 do not allow rejection of
33
+ // encoded data that is not properly "=" padded (see [RFC4648],
34
+ // Section 3.2), parsers SHOULD NOT fail when "=" padding is not
35
+ // present, unless they cannot be configured to do so.
36
+ //
37
+ // Because some implementations of base64 do not allow rejection of
38
+ // encoded data that has non-zero pad bits (see [RFC4648], Section 3.5),
39
+ // parsers SHOULD NOT fail when non-zero pad bits are present, unless
40
+ // they cannot be configured to do so.
41
+ //
42
+ // This specification does not relax the requirements in [RFC4648],
43
+ // Section 3.1 and 3.3; therefore, parsers MUST fail on characters
44
+ // outside the base64 alphabet, and on line feeds in encoded data.
45
+ export function parseByteSequence(src) {
46
+ if (src[0] !== ':') {
47
+ throw parseError(src, BYTES);
48
+ }
49
+ src = src.substring(1);
50
+ if (src.includes(':') === false) {
51
+ throw parseError(src, BYTES);
52
+ }
53
+ const re = /(^.*?)(:)/g;
54
+ const b64_content = re.exec(src)[1];
55
+ src = src.substring(re.lastIndex);
56
+ // pass b64_content char check step 6
57
+ return parsedValue(decodeBase64(b64_content), src);
58
+ }
59
+ //# sourceMappingURL=parseByteSequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseByteSequence.js","sourceRoot":"","sources":["../../src/parse/parseByteSequence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,kCAAkC;AAClC,EAAE;AACF,iEAAiE;AACjE,uDAAuD;AACvD,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,sEAAsE;AACtE,oBAAoB;AACpB,EAAE;AACF,4DAA4D;AAC5D,qEAAqE;AACrE,qBAAqB;AACrB,EAAE;AACF,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,sCAAsC;AACtC,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,oDAAoD;AACpD,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,mEAAmE;AACnE,+DAA+D;AAC/D,gEAAgE;AAChE,sDAAsD;AACtD,EAAE;AACF,mEAAmE;AACnE,wEAAwE;AACxE,qEAAqE;AACrE,sCAAsC;AACtC,EAAE;AACF,mEAAmE;AACnE,kEAAkE;AAClE,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC5C,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,MAAM,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;QACjC,MAAM,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,EAAE,GAAG,YAAY,CAAC;IACxB,MAAM,WAAW,GAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAS,CAAC,CAAC,CAAC,CAAC;IAC7C,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAElC,qCAAqC;IACrC,OAAO,WAAW,CACjB,YAAY,CAAC,WAAW,CAAC,EACzB,GAAG,CACH,CAAC;AACH,CAAC","sourcesContent":["import { decodeBase64 } from '@svta/cml-utils/decodeBase64.js';\nimport { BYTES } from '../utils/BYTES.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseError } from './parseError.js';\n\n// 4.2.7. Parsing a Byte Sequence\n//\n// Given an ASCII string as input_string, return a Byte Sequence.\n// input_string is modified to remove the parsed value.\n//\n// 1. If the first character of input_string is not \":\", fail parsing.\n//\n// 2. Discard the first character of input_string.\n//\n// 3. If there is not a \":\" character before the end of input_string,\n// fail parsing.\n//\n// 4. Let b64_content be the result of consuming content of\n// input_string up to but not including the first instance of the\n// character \":\".\n//\n// 5. Consume the \":\" character at the beginning of input_string.\n//\n// 6. If b64_content contains a character not included in ALPHA, DIGIT,\n// \"+\", \"/\" and \"=\", fail parsing.\n//\n// 7. Let binary_content be the result of Base 64 Decoding [RFC4648]\n// b64_content, synthesizing padding if necessary (note the\n// requirements about recipient behavior below).\n//\n// 8. Return binary_content.\n//\n// Because some implementations of base64 do not allow rejection of\n// encoded data that is not properly \"=\" padded (see [RFC4648],\n// Section 3.2), parsers SHOULD NOT fail when \"=\" padding is not\n// present, unless they cannot be configured to do so.\n//\n// Because some implementations of base64 do not allow rejection of\n// encoded data that has non-zero pad bits (see [RFC4648], Section 3.5),\n// parsers SHOULD NOT fail when non-zero pad bits are present, unless\n// they cannot be configured to do so.\n//\n// This specification does not relax the requirements in [RFC4648],\n// Section 3.1 and 3.3; therefore, parsers MUST fail on characters\n// outside the base64 alphabet, and on line feeds in encoded data.\nexport function parseByteSequence(src: string): ParsedValue<Uint8Array> {\n\tif (src[0] !== ':') {\n\t\tthrow parseError(src, BYTES);\n\t}\n\n\tsrc = src.substring(1);\n\tif (src.includes(':') === false) {\n\t\tthrow parseError(src, BYTES);\n\t}\n\n\tconst re = /(^.*?)(:)/g;\n\tconst b64_content = (re.exec(src) as any)[1];\n\tsrc = src.substring(re.lastIndex);\n\n\t// pass b64_content char check step 6\n\treturn parsedValue(\n\t\tdecodeBase64(b64_content),\n\t\tsrc,\n\t);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ParsedValue } from './ParsedValue.js';
2
+ export declare function parseDate(src: string): ParsedValue<Date>;
3
+ //# sourceMappingURL=parseDate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDate.d.ts","sourceRoot":"","sources":["../../src/parse/parseDate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoBpD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAiBxD"}
@@ -0,0 +1,32 @@
1
+ import { DATE } from '../utils/DATE.js';
2
+ import { parsedValue } from './ParsedValue.js';
3
+ import { parseError } from './parseError.js';
4
+ import { parseIntegerOrDecimal } from './parseIntegerOrDecimal.js';
5
+ // 4.2.9. Parsing a Date
6
+ //
7
+ // Given an ASCII string as input_string, return a Date. input_string is
8
+ // modified to remove the parsed value.
9
+ //
10
+ // 1. If the first character of input_string is not "@", fail parsing.
11
+ //
12
+ // 2. Discard the first character of input_string.
13
+ //
14
+ // 3. Let output_date be the result of running Parsing an Integer or
15
+ // Decimal (Section 4.2.4) with input_string.
16
+ //
17
+ // 4. If output_date is a Decimal, fail parsing.
18
+ //
19
+ // 5. Return output_date.
20
+ export function parseDate(src) {
21
+ let i = 0;
22
+ if (src[i] !== '@') {
23
+ throw parseError(src, DATE);
24
+ }
25
+ i++;
26
+ const date = parseIntegerOrDecimal(src.substring(i));
27
+ if (Number.isInteger(date.value) === false) {
28
+ throw parseError(src, DATE);
29
+ }
30
+ return parsedValue(new Date(date.value * 1000), date.src);
31
+ }
32
+ //# sourceMappingURL=parseDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDate.js","sourceRoot":"","sources":["../../src/parse/parseDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,yBAAyB;AACzB,EAAE;AACF,wEAAwE;AACxE,uCAAuC;AACvC,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,qEAAqE;AACrE,iDAAiD;AACjD,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,0BAA0B;AAC1B,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,CAAC,EAAE,CAAC;IACJ,MAAM,IAAI,GAAG,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;QAC5C,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,WAAW,CACjB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,EAC3B,IAAI,CAAC,GAAG,CACR,CAAC;AACH,CAAC","sourcesContent":["import { DATE } from '../utils/DATE.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseError } from './parseError.js';\nimport { parseIntegerOrDecimal } from './parseIntegerOrDecimal.js';\n\n// 4.2.9. Parsing a Date\n//\n// Given an ASCII string as input_string, return a Date. input_string is\n// modified to remove the parsed value.\n//\n// 1. If the first character of input_string is not \"@\", fail parsing.\n//\n// 2. Discard the first character of input_string.\n//\n// 3. Let output_date be the result of running Parsing an Integer or\n// Decimal (Section 4.2.4) with input_string.\n//\n// 4. If output_date is a Decimal, fail parsing.\n//\n// 5. Return output_date.\nexport function parseDate(src: string): ParsedValue<Date> {\n\tlet i = 0;\n\tif (src[i] !== '@') {\n\t\tthrow parseError(src, DATE);\n\t}\n\n\ti++;\n\tconst date = parseIntegerOrDecimal(src.substring(i));\n\n\tif (Number.isInteger(date.value) === false) {\n\t\tthrow parseError(src, DATE);\n\t}\n\n\treturn parsedValue(\n\t\tnew Date(date.value * 1000),\n\t\tdate.src,\n\t);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { SfDecodeOptions } from '../SfDecodeOptions.js';
2
+ import type { SfDictionary } from '../SfDictionary.js';
3
+ import type { ParsedValue } from './ParsedValue.js';
4
+ export declare function parseDict(src: string, options?: SfDecodeOptions): ParsedValue<SfDictionary>;
5
+ //# sourceMappingURL=parseDict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDict.d.ts","sourceRoot":"","sources":["../../src/parse/parseDict.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyDpD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC,YAAY,CAAC,CAsC3F"}