feedsmith 2.9.1 → 3.0.0-beta.1

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 (166) hide show
  1. package/README.md +3 -9
  2. package/dist/common/config.cjs +2 -1
  3. package/dist/common/config.js +2 -1
  4. package/dist/common/errors.cjs +30 -0
  5. package/dist/common/errors.d.cts +15 -0
  6. package/dist/common/errors.d.ts +15 -0
  7. package/dist/common/errors.js +27 -0
  8. package/dist/common/parse.cjs +2 -1
  9. package/dist/common/parse.d.cts +10 -11
  10. package/dist/common/parse.d.ts +10 -11
  11. package/dist/common/parse.js +2 -1
  12. package/dist/common/types.d.cts +24 -12
  13. package/dist/common/types.d.ts +24 -12
  14. package/dist/common/utils.cjs +65 -34
  15. package/dist/common/utils.js +66 -33
  16. package/dist/feeds/atom/common/types.d.cts +65 -52
  17. package/dist/feeds/atom/common/types.d.ts +65 -52
  18. package/dist/feeds/atom/detect/index.cjs +4 -2
  19. package/dist/feeds/atom/detect/index.js +4 -2
  20. package/dist/feeds/atom/generate/index.cjs +2 -1
  21. package/dist/feeds/atom/generate/index.d.cts +2 -2
  22. package/dist/feeds/atom/generate/index.d.ts +2 -2
  23. package/dist/feeds/atom/generate/index.js +2 -1
  24. package/dist/feeds/atom/generate/utils.cjs +23 -6
  25. package/dist/feeds/atom/generate/utils.js +20 -3
  26. package/dist/feeds/atom/parse/index.cjs +10 -3
  27. package/dist/feeds/atom/parse/index.d.cts +2 -2
  28. package/dist/feeds/atom/parse/index.d.ts +2 -2
  29. package/dist/feeds/atom/parse/index.js +10 -3
  30. package/dist/feeds/atom/parse/utils.cjs +61 -31
  31. package/dist/feeds/atom/parse/utils.js +59 -29
  32. package/dist/feeds/json/common/types.d.cts +19 -19
  33. package/dist/feeds/json/common/types.d.ts +19 -19
  34. package/dist/feeds/json/generate/index.cjs +5 -1
  35. package/dist/feeds/json/generate/index.d.cts +2 -2
  36. package/dist/feeds/json/generate/index.d.ts +2 -2
  37. package/dist/feeds/json/generate/index.js +5 -1
  38. package/dist/feeds/json/generate/utils.cjs +7 -2
  39. package/dist/feeds/json/generate/utils.js +8 -3
  40. package/dist/feeds/json/parse/index.cjs +3 -2
  41. package/dist/feeds/json/parse/index.d.cts +2 -2
  42. package/dist/feeds/json/parse/index.d.ts +2 -2
  43. package/dist/feeds/json/parse/index.js +3 -2
  44. package/dist/feeds/json/parse/utils.cjs +4 -4
  45. package/dist/feeds/json/parse/utils.js +4 -4
  46. package/dist/feeds/rdf/common/types.d.cts +31 -28
  47. package/dist/feeds/rdf/common/types.d.ts +31 -28
  48. package/dist/feeds/rdf/detect/index.cjs +4 -2
  49. package/dist/feeds/rdf/detect/index.js +4 -2
  50. package/dist/feeds/rdf/parse/index.cjs +10 -3
  51. package/dist/feeds/rdf/parse/index.d.cts +2 -2
  52. package/dist/feeds/rdf/parse/index.d.ts +2 -2
  53. package/dist/feeds/rdf/parse/index.js +10 -3
  54. package/dist/feeds/rdf/parse/utils.cjs +23 -20
  55. package/dist/feeds/rdf/parse/utils.js +15 -12
  56. package/dist/feeds/rss/common/types.d.cts +76 -74
  57. package/dist/feeds/rss/common/types.d.ts +76 -74
  58. package/dist/feeds/rss/detect/index.cjs +6 -3
  59. package/dist/feeds/rss/detect/index.js +6 -3
  60. package/dist/feeds/rss/generate/index.cjs +2 -1
  61. package/dist/feeds/rss/generate/index.d.cts +2 -2
  62. package/dist/feeds/rss/generate/index.d.ts +2 -2
  63. package/dist/feeds/rss/generate/index.js +2 -1
  64. package/dist/feeds/rss/generate/utils.cjs +36 -36
  65. package/dist/feeds/rss/generate/utils.js +10 -10
  66. package/dist/feeds/rss/parse/index.cjs +10 -3
  67. package/dist/feeds/rss/parse/index.d.cts +2 -2
  68. package/dist/feeds/rss/parse/index.d.ts +2 -2
  69. package/dist/feeds/rss/parse/index.js +10 -3
  70. package/dist/feeds/rss/parse/utils.cjs +138 -38
  71. package/dist/feeds/rss/parse/utils.js +119 -19
  72. package/dist/index.cjs +5 -0
  73. package/dist/index.d.cts +37 -16
  74. package/dist/index.d.ts +37 -16
  75. package/dist/index.js +2 -1
  76. package/dist/namespaces/app/common/types.d.cts +1 -3
  77. package/dist/namespaces/app/common/types.d.ts +1 -3
  78. package/dist/namespaces/app/parse/utils.cjs +2 -2
  79. package/dist/namespaces/app/parse/utils.js +2 -2
  80. package/dist/namespaces/atom/common/types.d.cts +3 -3
  81. package/dist/namespaces/atom/common/types.d.ts +3 -3
  82. package/dist/namespaces/atom/parse/utils.cjs +4 -2
  83. package/dist/namespaces/atom/parse/utils.js +4 -2
  84. package/dist/namespaces/dc/common/types.d.cts +4 -19
  85. package/dist/namespaces/dc/common/types.d.ts +4 -19
  86. package/dist/namespaces/dc/generate/utils.cjs +15 -15
  87. package/dist/namespaces/dc/generate/utils.js +16 -16
  88. package/dist/namespaces/dc/parse/utils.cjs +4 -17
  89. package/dist/namespaces/dc/parse/utils.js +5 -18
  90. package/dist/namespaces/dcterms/common/types.d.cts +23 -59
  91. package/dist/namespaces/dcterms/common/types.d.ts +23 -59
  92. package/dist/namespaces/dcterms/generate/utils.cjs +55 -55
  93. package/dist/namespaces/dcterms/generate/utils.js +56 -56
  94. package/dist/namespaces/dcterms/parse/utils.cjs +23 -57
  95. package/dist/namespaces/dcterms/parse/utils.js +24 -58
  96. package/dist/namespaces/georss/common/types.d.cts +21 -19
  97. package/dist/namespaces/georss/common/types.d.ts +21 -19
  98. package/dist/namespaces/georss/generate/utils.cjs +2 -2
  99. package/dist/namespaces/georss/generate/utils.js +2 -2
  100. package/dist/namespaces/georss/parse/utils.cjs +2 -1
  101. package/dist/namespaces/georss/parse/utils.js +2 -1
  102. package/dist/namespaces/googleplay/common/types.d.cts +9 -7
  103. package/dist/namespaces/googleplay/common/types.d.ts +9 -7
  104. package/dist/namespaces/itunes/common/types.d.cts +9 -5
  105. package/dist/namespaces/itunes/common/types.d.ts +9 -5
  106. package/dist/namespaces/itunes/parse/utils.cjs +3 -2
  107. package/dist/namespaces/itunes/parse/utils.js +3 -2
  108. package/dist/namespaces/media/common/types.d.cts +85 -84
  109. package/dist/namespaces/media/common/types.d.ts +85 -84
  110. package/dist/namespaces/media/generate/utils.cjs +1 -1
  111. package/dist/namespaces/media/generate/utils.js +2 -2
  112. package/dist/namespaces/media/parse/utils.cjs +1 -2
  113. package/dist/namespaces/media/parse/utils.js +1 -2
  114. package/dist/namespaces/opensearch/common/types.d.cts +7 -5
  115. package/dist/namespaces/opensearch/common/types.d.ts +7 -5
  116. package/dist/namespaces/podcast/common/types.d.cts +136 -142
  117. package/dist/namespaces/podcast/common/types.d.ts +136 -142
  118. package/dist/namespaces/podcast/generate/utils.cjs +6 -6
  119. package/dist/namespaces/podcast/generate/utils.js +7 -7
  120. package/dist/namespaces/podcast/parse/utils.cjs +17 -21
  121. package/dist/namespaces/podcast/parse/utils.js +17 -21
  122. package/dist/namespaces/prism/common/types.d.cts +2 -4
  123. package/dist/namespaces/prism/common/types.d.ts +2 -4
  124. package/dist/namespaces/prism/parse/utils.cjs +19 -19
  125. package/dist/namespaces/prism/parse/utils.js +19 -19
  126. package/dist/namespaces/psc/common/types.d.cts +8 -6
  127. package/dist/namespaces/psc/common/types.d.ts +8 -6
  128. package/dist/namespaces/rawvoice/common/types.d.cts +24 -24
  129. package/dist/namespaces/rawvoice/common/types.d.ts +24 -24
  130. package/dist/namespaces/rawvoice/parse/utils.cjs +8 -8
  131. package/dist/namespaces/rawvoice/parse/utils.js +8 -8
  132. package/dist/namespaces/source/common/types.d.cts +20 -18
  133. package/dist/namespaces/source/common/types.d.ts +20 -18
  134. package/dist/namespaces/spotify/common/types.d.cts +22 -20
  135. package/dist/namespaces/spotify/common/types.d.ts +22 -20
  136. package/dist/namespaces/sy/common/types.d.cts +1 -3
  137. package/dist/namespaces/sy/common/types.d.ts +1 -3
  138. package/dist/namespaces/sy/parse/utils.cjs +2 -2
  139. package/dist/namespaces/sy/parse/utils.js +2 -2
  140. package/dist/namespaces/thr/common/types.d.cts +7 -7
  141. package/dist/namespaces/thr/common/types.d.ts +7 -7
  142. package/dist/namespaces/thr/parse/utils.cjs +2 -2
  143. package/dist/namespaces/thr/parse/utils.js +2 -2
  144. package/dist/namespaces/xml/common/types.d.cts +11 -0
  145. package/dist/namespaces/xml/common/types.d.ts +11 -0
  146. package/dist/namespaces/xml/generate/utils.cjs +13 -0
  147. package/dist/namespaces/xml/generate/utils.js +13 -0
  148. package/dist/namespaces/xml/parse/utils.cjs +13 -0
  149. package/dist/namespaces/xml/parse/utils.js +13 -0
  150. package/dist/opml/common/types.d.cts +18 -13
  151. package/dist/opml/common/types.d.ts +18 -13
  152. package/dist/opml/generate/index.cjs +2 -1
  153. package/dist/opml/generate/index.d.cts +3 -3
  154. package/dist/opml/generate/index.d.ts +3 -3
  155. package/dist/opml/generate/index.js +2 -1
  156. package/dist/opml/parse/index.cjs +9 -2
  157. package/dist/opml/parse/index.d.cts +2 -3
  158. package/dist/opml/parse/index.d.ts +2 -3
  159. package/dist/opml/parse/index.js +9 -2
  160. package/dist/opml/parse/utils.cjs +5 -5
  161. package/dist/opml/parse/utils.js +5 -5
  162. package/package.json +7 -24
  163. package/dist/types.cjs +0 -0
  164. package/dist/types.d.cts +0 -7
  165. package/dist/types.d.ts +0 -7
  166. package/dist/types.js +0 -1
@@ -26,13 +26,19 @@ const retrieveRdfResourceOrText = (value, parse) => {
26
26
  return parse(retrieveText(value));
27
27
  };
28
28
  const trimObject = (object) => {
29
- let result;
29
+ let hasPresent = false;
30
+ let hasAbsent = false;
31
+ for (const key in object) {
32
+ if (isPresent(object[key])) hasPresent = true;
33
+ else hasAbsent = true;
34
+ if (hasPresent && hasAbsent) break;
35
+ }
36
+ if (!hasPresent) return;
37
+ if (!hasAbsent) return object;
38
+ const result = {};
30
39
  for (const key in object) {
31
40
  const value = object[key];
32
- if (isPresent(value)) {
33
- if (!result) result = {};
34
- result[key] = value;
35
- }
41
+ if (isPresent(value)) result[key] = value;
36
42
  }
37
43
  return result;
38
44
  };
@@ -40,31 +46,23 @@ const trimArray = (value, parse) => {
40
46
  if (!Array.isArray(value) || value.length === 0) return;
41
47
  if (!parse) {
42
48
  let needsTrimming = false;
43
- for (let i = 0; i < value.length; i++) if (!isPresent(value[i])) {
49
+ for (const item of value) if (!isPresent(item)) {
44
50
  needsTrimming = true;
45
51
  break;
46
52
  }
47
53
  if (!needsTrimming) return value;
48
54
  }
49
55
  const result = [];
50
- for (let i = 0; i < value.length; i++) {
51
- const item = parse ? parse(value[i]) : value[i];
56
+ for (const element of value) {
57
+ const item = parse ? parse(element) : element;
52
58
  if (isPresent(item)) result.push(item);
53
59
  }
54
60
  return result.length > 0 ? result : void 0;
55
61
  };
56
- const generateArrayOrSingular = (pluralValues, singularValue, generator) => {
57
- if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
58
- if (isPresent(singularValue)) return generator(singularValue);
59
- };
60
- const generateSingularOrArray = (singularValue, pluralValues, generator) => {
61
- if (isPresent(singularValue)) return generator(singularValue);
62
- if (isPresent(pluralValues)) return trimArray(pluralValues.map(generator));
63
- };
64
- const commentStartTag = "<!--";
65
- const commentEndTag = "-->";
66
62
  const cdataStartTag = "<![CDATA[";
67
63
  const cdataEndTag = "]]>";
64
+ const commentStartTag = "<!--";
65
+ const commentEndTag = "-->";
68
66
  const hasEntities = (text) => {
69
67
  const ampIndex = text.indexOf("&");
70
68
  return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
@@ -75,13 +73,13 @@ const stripComments = (text) => {
75
73
  let result = "";
76
74
  let lastIndex = 0;
77
75
  while (currentIndex !== -1) {
78
- result += text.substring(lastIndex, currentIndex);
76
+ result += text.slice(lastIndex, currentIndex);
79
77
  const endIndex = text.indexOf(commentEndTag, currentIndex + 4);
80
78
  if (endIndex === -1) return text;
81
79
  lastIndex = endIndex + 3;
82
80
  currentIndex = text.indexOf(commentStartTag, lastIndex);
83
81
  }
84
- result += text.substring(lastIndex);
82
+ result += text.slice(lastIndex);
85
83
  return result;
86
84
  };
87
85
  const decodeWithCdata = (text) => {
@@ -90,15 +88,15 @@ const decodeWithCdata = (text) => {
90
88
  let result = "";
91
89
  let lastIndex = 0;
92
90
  while (currentIndex !== -1) {
93
- const textBefore = text.substring(lastIndex, currentIndex);
91
+ const textBefore = text.slice(lastIndex, currentIndex);
94
92
  result += hasEntities(textBefore) ? decodeHTML(textBefore) : textBefore;
95
93
  const endIndex = text.indexOf(cdataEndTag, currentIndex + 9);
96
94
  if (endIndex === -1) return hasEntities(text) ? decodeHTML(text) : text;
97
- result += text.substring(currentIndex + 9, endIndex);
95
+ result += text.slice(currentIndex + 9, endIndex);
98
96
  lastIndex = endIndex + 3;
99
97
  currentIndex = text.indexOf(cdataStartTag, lastIndex);
100
98
  }
101
- const textAfter = text.substring(lastIndex);
99
+ const textAfter = text.slice(lastIndex);
102
100
  result += hasEntities(textAfter) ? decodeHTML(textAfter) : textAfter;
103
101
  return result;
104
102
  };
@@ -131,8 +129,10 @@ const parseYesNoBoolean = (value) => {
131
129
  if (boolean !== void 0) return boolean;
132
130
  if (isNonEmptyString(value)) return yesRegex.test(value);
133
131
  };
134
- const parseDate = (value) => {
135
- return parseString(value);
132
+ const parseDate = (value, parseDateFn) => {
133
+ const raw = parseString(value);
134
+ if (raw === void 0) return;
135
+ return parseDateFn ? parseDateFn(raw) : raw;
136
136
  };
137
137
  const parseArray = (value) => {
138
138
  if (Array.isArray(value)) return value;
@@ -300,7 +300,7 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
300
300
  if (isObject(element)) {
301
301
  for (const key in element) if (key === "@xmlns") declarations[""] = normalizeNamespaceUri(element[key]);
302
302
  else if (key.indexOf("@xmlns:") === 0) {
303
- const prefix = key.substring(7);
303
+ const prefix = key.slice(7);
304
304
  declarations[prefix] = normalizeNamespaceUri(element[key]);
305
305
  }
306
306
  }
@@ -312,14 +312,14 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
312
312
  if (useDefault && context[""]) return resolveNamespacePrefix(context[""], name, name);
313
313
  return name;
314
314
  }
315
- const prefix = name.substring(0, colonIndex);
316
- const unprefixedName = name.substring(colonIndex + 1);
315
+ const prefix = name.slice(0, colonIndex);
316
+ const unprefixedName = name.slice(colonIndex + 1);
317
317
  const uri = context[prefix];
318
318
  if (uri) return resolveNamespacePrefix(uri, unprefixedName, name);
319
319
  return name;
320
320
  };
321
321
  const normalizeKey = (key, context) => {
322
- if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.substring(1), context, false)}`;
322
+ if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.slice(1), context, false)}`;
323
323
  return normalizeWithContext(key, context, true);
324
324
  };
325
325
  const traverseAndNormalize = (object, parentContext = {}) => {
@@ -352,9 +352,40 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
352
352
  }
353
353
  return normalizedObject;
354
354
  };
355
+ const needsNormalization = (object) => {
356
+ const check = (value) => {
357
+ if (Array.isArray(value)) {
358
+ for (const item of value) if (check(item)) return true;
359
+ return false;
360
+ }
361
+ if (!isObject(value)) return false;
362
+ for (const key in value) {
363
+ if (key[0] === "@") {
364
+ if (key === "@xmlns") {
365
+ const normalizedUri = normalizeNamespaceUri(value[key]);
366
+ if (primaryNamespaceUris?.includes(normalizedUri)) continue;
367
+ if (namespacePrefixes[normalizedUri]) return true;
368
+ } else if (key.startsWith("@xmlns:")) {
369
+ const prefix = key.slice(7);
370
+ const normalizedUri = normalizeNamespaceUri(value[key]);
371
+ const standardPrefix = namespacePrefixes[normalizedUri];
372
+ if (standardPrefix) {
373
+ if (primaryNamespaceUris?.includes(normalizedUri)) return true;
374
+ if (standardPrefix !== prefix) return true;
375
+ }
376
+ }
377
+ continue;
378
+ }
379
+ if (key[0] === "#") continue;
380
+ if (check(value[key])) return true;
381
+ }
382
+ return false;
383
+ };
384
+ return check(object);
385
+ };
355
386
  const normalizeRoot = (object) => {
356
387
  if (!isObject(object)) return object;
357
- if (Array.isArray(object)) return object.map(normalizeRoot);
388
+ if (!needsNormalization(object)) return object;
358
389
  const normalizedObject = {};
359
390
  for (const key in object) {
360
391
  const value = object[key];
@@ -366,15 +397,17 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
366
397
  };
367
398
  return normalizeRoot;
368
399
  };
400
+ const startsWithBraceRegex = /^\s*\{/;
401
+ const endsWithBraceRegex = /\}\s*$/;
369
402
  const parseJsonObject = (value) => {
370
403
  if (isObject(value)) return value;
371
404
  if (!isNonEmptyString(value) || value.length < 2) return;
372
- const startsWithBrace = value.charAt(0) === "{" || /^\s*\{/.test(value);
373
- const endsWithBrace = value.charAt(value.length - 1) === "}" || /\}\s*$/.test(value);
405
+ const startsWithBrace = value.charAt(0) === "{" || startsWithBraceRegex.test(value);
406
+ const endsWithBrace = value.charAt(value.length - 1) === "}" || endsWithBraceRegex.test(value);
374
407
  if (!startsWithBrace || !endsWithBrace) return;
375
408
  try {
376
409
  return JSON.parse(value);
377
410
  } catch {}
378
411
  };
379
412
  //#endregion
380
- export { createNamespaceNormalizator, detectNamespaces, generateArrayOrSingular, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRdfResource, generateRfc3339Date, generateRfc822Date, generateSingularOrArray, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseJsonObject, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveRdfResourceOrText, retrieveText, trimArray, trimObject };
413
+ export { createNamespaceNormalizator, detectNamespaces, generateBoolean, generateCdataString, generateCsvOf, generateNamespaceAttrs, generateNumber, generatePlainString, generateRdfResource, generateRfc3339Date, generateRfc822Date, generateTextOrCdataString, generateXml, generateYesNoBoolean, isNonEmptyString, isNonEmptyStringOrNumber, isObject, isPresent, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseJsonObject, parseNumber, parseSingular, parseSingularOf, parseString, parseYesNoBoolean, retrieveRdfResourceOrText, retrieveText, trimArray, trimObject };
@@ -1,4 +1,4 @@
1
- import { DateLike } from "../../../common/types.cjs";
1
+ import { Requirable, Strict } from "../../../common/types.cjs";
2
2
  import { AdminNs } from "../../../namespaces/admin/common/types.cjs";
3
3
  import { AppNs } from "../../../namespaces/app/common/types.cjs";
4
4
  import { ArxivNs } from "../../../namespaces/arxiv/common/types.cjs";
@@ -19,111 +19,124 @@ import { SyNs } from "../../../namespaces/sy/common/types.cjs";
19
19
  import { ThrNs } from "../../../namespaces/thr/common/types.cjs";
20
20
  import { TrackbackNs } from "../../../namespaces/trackback/common/types.cjs";
21
21
  import { WfwNs } from "../../../namespaces/wfw/common/types.cjs";
22
+ import { XmlNs } from "../../../namespaces/xml/common/types.cjs";
22
23
  import { YtNs } from "../../../namespaces/yt/common/types.cjs";
23
24
 
24
25
  //#region src/feeds/atom/common/types.d.ts
25
26
  declare namespace Atom {
26
- type Text = string;
27
- type Link<TDate extends DateLike> = {
28
- href: string;
27
+ type Text = {
28
+ value: string;
29
+ type?: string;
30
+ xml?: XmlNs.ItemOrFeed;
31
+ };
32
+ type Content = {
33
+ value?: string;
34
+ type?: string;
35
+ src?: string;
36
+ xml?: XmlNs.ItemOrFeed;
37
+ };
38
+ type Link<TDate, TStrict extends boolean = false> = Strict<{
39
+ href: Requirable<string>;
29
40
  rel?: string;
30
41
  type?: string;
31
42
  hreflang?: string;
32
43
  title?: string;
33
44
  length?: number;
34
45
  thr?: ThrNs.Link<TDate>;
35
- };
36
- type Person = {
37
- name: string;
46
+ }, TStrict>;
47
+ type Person<TStrict extends boolean = false> = Strict<{
48
+ name: Requirable<string>;
38
49
  uri?: string;
39
50
  email?: string;
40
51
  arxiv?: ArxivNs.Author;
41
- };
42
- type Category = {
43
- term: string;
52
+ }, TStrict>;
53
+ type Category<TStrict extends boolean = false> = Strict<{
54
+ term: Requirable<string>;
44
55
  scheme?: string;
45
56
  label?: string;
46
- };
47
- type Generator = {
48
- text: string;
57
+ }, TStrict>;
58
+ type Generator<TStrict extends boolean = false> = Strict<{
59
+ text: Requirable<string>;
49
60
  uri?: string;
50
61
  version?: string;
51
- };
52
- type Source<TDate extends DateLike> = {
53
- authors?: Array<Person>;
54
- categories?: Array<Category>;
55
- contributors?: Array<Person>;
56
- generator?: Generator;
62
+ }, TStrict>;
63
+ type Source<TDate, TStrict extends boolean = false> = {
64
+ authors?: Array<Person<TStrict>>;
65
+ categories?: Array<Category<TStrict>>;
66
+ contributors?: Array<Person<TStrict>>;
67
+ generator?: Generator<TStrict>;
57
68
  icon?: string;
58
69
  id?: string;
59
- links?: Array<Link<TDate>>;
70
+ links?: Array<Link<TDate, TStrict>>;
60
71
  logo?: string;
61
72
  rights?: Text;
62
73
  subtitle?: Text;
63
74
  title?: Text;
64
75
  updated?: TDate;
65
76
  };
66
- type Entry<TDate extends DateLike> = {
67
- authors?: Array<Person>;
68
- categories?: Array<Category>;
69
- content?: Text;
70
- contributors?: Array<Person>;
71
- id: string;
72
- links?: Array<Link<TDate>>;
77
+ type Entry<TDate, TStrict extends boolean = false> = Strict<{
78
+ authors?: Array<Person<TStrict>>;
79
+ categories?: Array<Category<TStrict>>;
80
+ content?: Content;
81
+ contributors?: Array<Person<TStrict>>;
82
+ id: Requirable<string>;
83
+ links?: Array<Link<TDate, TStrict>>;
73
84
  published?: TDate;
74
85
  rights?: Text;
75
- source?: Source<TDate>;
86
+ source?: Source<TDate, TStrict>;
76
87
  summary?: Text;
77
- title: Text;
78
- updated: TDate;
88
+ title: Requirable<Text>;
89
+ updated: Requirable<TDate>;
79
90
  app?: AppNs.Entry<TDate>;
80
91
  arxiv?: ArxivNs.Entry;
81
92
  cc?: CcNs.ItemOrFeed;
82
93
  dc?: DcNs.ItemOrFeed<TDate>;
83
94
  slash?: SlashNs.Item;
84
95
  itunes?: ItunesNs.Item;
85
- googleplay?: GooglePlayNs.Item;
86
- psc?: PscNs.Item;
87
- media?: MediaNs.ItemOrFeed;
88
- georss?: GeoRssNs.ItemOrFeed;
96
+ googleplay?: GooglePlayNs.Item<TStrict>;
97
+ psc?: PscNs.Item<TStrict>;
98
+ media?: MediaNs.ItemOrFeed<TStrict>;
99
+ georss?: GeoRssNs.ItemOrFeed<TStrict>;
89
100
  geo?: GeoNs.ItemOrFeed;
90
- thr?: ThrNs.Item;
101
+ thr?: ThrNs.Item<TStrict>;
91
102
  dcterms?: DcTermsNs.ItemOrFeed<TDate>;
92
103
  creativeCommons?: CreativeCommonsNs.ItemOrFeed;
93
104
  wfw?: WfwNs.Item;
94
105
  yt?: YtNs.Item;
95
106
  pingback?: PingbackNs.Item;
96
107
  trackback?: TrackbackNs.Item;
97
- };
98
- type Feed<TDate extends DateLike> = {
99
- authors?: Array<Person>;
100
- categories?: Array<Category>;
101
- contributors?: Array<Person>;
102
- generator?: Generator;
108
+ xml?: XmlNs.ItemOrFeed;
109
+ }, TStrict>;
110
+ type Feed<TDate, TStrict extends boolean = false> = Strict<{
111
+ authors?: Array<Person<TStrict>>;
112
+ categories?: Array<Category<TStrict>>;
113
+ contributors?: Array<Person<TStrict>>;
114
+ generator?: Generator<TStrict>;
103
115
  icon?: string;
104
- id: string;
105
- links?: Array<Link<TDate>>;
116
+ id: Requirable<string>;
117
+ links?: Array<Link<TDate, TStrict>>;
106
118
  logo?: string;
107
119
  rights?: Text;
108
120
  subtitle?: Text;
109
- title: Text;
110
- updated: TDate;
111
- entries?: Array<Entry<TDate>>;
121
+ title: Requirable<Text>;
122
+ updated: Requirable<TDate>;
123
+ entries?: Array<Entry<TDate, TStrict>>;
112
124
  cc?: CcNs.ItemOrFeed;
113
125
  dc?: DcNs.ItemOrFeed<TDate>;
114
126
  sy?: SyNs.Feed<TDate>;
115
- itunes?: ItunesNs.Feed;
116
- googleplay?: GooglePlayNs.Feed;
117
- media?: MediaNs.ItemOrFeed;
118
- georss?: GeoRssNs.ItemOrFeed;
127
+ itunes?: ItunesNs.Feed<TStrict>;
128
+ googleplay?: GooglePlayNs.Feed<TStrict>;
129
+ media?: MediaNs.ItemOrFeed<TStrict>;
130
+ georss?: GeoRssNs.ItemOrFeed<TStrict>;
119
131
  geo?: GeoNs.ItemOrFeed;
120
132
  dcterms?: DcTermsNs.ItemOrFeed<TDate>;
121
133
  creativeCommons?: CreativeCommonsNs.ItemOrFeed;
122
- opensearch?: OpenSearchNs.Feed;
134
+ opensearch?: OpenSearchNs.Feed<TStrict>;
123
135
  yt?: YtNs.Feed;
124
136
  admin?: AdminNs.Feed;
125
137
  pingback?: PingbackNs.Feed;
126
- };
138
+ xml?: XmlNs.ItemOrFeed;
139
+ }, TStrict>;
127
140
  }
128
141
  //#endregion
129
142
  export { Atom };
@@ -1,4 +1,4 @@
1
- import { DateLike } from "../../../common/types.js";
1
+ import { Requirable, Strict } from "../../../common/types.js";
2
2
  import { AdminNs } from "../../../namespaces/admin/common/types.js";
3
3
  import { AppNs } from "../../../namespaces/app/common/types.js";
4
4
  import { ArxivNs } from "../../../namespaces/arxiv/common/types.js";
@@ -19,111 +19,124 @@ import { SyNs } from "../../../namespaces/sy/common/types.js";
19
19
  import { ThrNs } from "../../../namespaces/thr/common/types.js";
20
20
  import { TrackbackNs } from "../../../namespaces/trackback/common/types.js";
21
21
  import { WfwNs } from "../../../namespaces/wfw/common/types.js";
22
+ import { XmlNs } from "../../../namespaces/xml/common/types.js";
22
23
  import { YtNs } from "../../../namespaces/yt/common/types.js";
23
24
 
24
25
  //#region src/feeds/atom/common/types.d.ts
25
26
  declare namespace Atom {
26
- type Text = string;
27
- type Link<TDate extends DateLike> = {
28
- href: string;
27
+ type Text = {
28
+ value: string;
29
+ type?: string;
30
+ xml?: XmlNs.ItemOrFeed;
31
+ };
32
+ type Content = {
33
+ value?: string;
34
+ type?: string;
35
+ src?: string;
36
+ xml?: XmlNs.ItemOrFeed;
37
+ };
38
+ type Link<TDate, TStrict extends boolean = false> = Strict<{
39
+ href: Requirable<string>;
29
40
  rel?: string;
30
41
  type?: string;
31
42
  hreflang?: string;
32
43
  title?: string;
33
44
  length?: number;
34
45
  thr?: ThrNs.Link<TDate>;
35
- };
36
- type Person = {
37
- name: string;
46
+ }, TStrict>;
47
+ type Person<TStrict extends boolean = false> = Strict<{
48
+ name: Requirable<string>;
38
49
  uri?: string;
39
50
  email?: string;
40
51
  arxiv?: ArxivNs.Author;
41
- };
42
- type Category = {
43
- term: string;
52
+ }, TStrict>;
53
+ type Category<TStrict extends boolean = false> = Strict<{
54
+ term: Requirable<string>;
44
55
  scheme?: string;
45
56
  label?: string;
46
- };
47
- type Generator = {
48
- text: string;
57
+ }, TStrict>;
58
+ type Generator<TStrict extends boolean = false> = Strict<{
59
+ text: Requirable<string>;
49
60
  uri?: string;
50
61
  version?: string;
51
- };
52
- type Source<TDate extends DateLike> = {
53
- authors?: Array<Person>;
54
- categories?: Array<Category>;
55
- contributors?: Array<Person>;
56
- generator?: Generator;
62
+ }, TStrict>;
63
+ type Source<TDate, TStrict extends boolean = false> = {
64
+ authors?: Array<Person<TStrict>>;
65
+ categories?: Array<Category<TStrict>>;
66
+ contributors?: Array<Person<TStrict>>;
67
+ generator?: Generator<TStrict>;
57
68
  icon?: string;
58
69
  id?: string;
59
- links?: Array<Link<TDate>>;
70
+ links?: Array<Link<TDate, TStrict>>;
60
71
  logo?: string;
61
72
  rights?: Text;
62
73
  subtitle?: Text;
63
74
  title?: Text;
64
75
  updated?: TDate;
65
76
  };
66
- type Entry<TDate extends DateLike> = {
67
- authors?: Array<Person>;
68
- categories?: Array<Category>;
69
- content?: Text;
70
- contributors?: Array<Person>;
71
- id: string;
72
- links?: Array<Link<TDate>>;
77
+ type Entry<TDate, TStrict extends boolean = false> = Strict<{
78
+ authors?: Array<Person<TStrict>>;
79
+ categories?: Array<Category<TStrict>>;
80
+ content?: Content;
81
+ contributors?: Array<Person<TStrict>>;
82
+ id: Requirable<string>;
83
+ links?: Array<Link<TDate, TStrict>>;
73
84
  published?: TDate;
74
85
  rights?: Text;
75
- source?: Source<TDate>;
86
+ source?: Source<TDate, TStrict>;
76
87
  summary?: Text;
77
- title: Text;
78
- updated: TDate;
88
+ title: Requirable<Text>;
89
+ updated: Requirable<TDate>;
79
90
  app?: AppNs.Entry<TDate>;
80
91
  arxiv?: ArxivNs.Entry;
81
92
  cc?: CcNs.ItemOrFeed;
82
93
  dc?: DcNs.ItemOrFeed<TDate>;
83
94
  slash?: SlashNs.Item;
84
95
  itunes?: ItunesNs.Item;
85
- googleplay?: GooglePlayNs.Item;
86
- psc?: PscNs.Item;
87
- media?: MediaNs.ItemOrFeed;
88
- georss?: GeoRssNs.ItemOrFeed;
96
+ googleplay?: GooglePlayNs.Item<TStrict>;
97
+ psc?: PscNs.Item<TStrict>;
98
+ media?: MediaNs.ItemOrFeed<TStrict>;
99
+ georss?: GeoRssNs.ItemOrFeed<TStrict>;
89
100
  geo?: GeoNs.ItemOrFeed;
90
- thr?: ThrNs.Item;
101
+ thr?: ThrNs.Item<TStrict>;
91
102
  dcterms?: DcTermsNs.ItemOrFeed<TDate>;
92
103
  creativeCommons?: CreativeCommonsNs.ItemOrFeed;
93
104
  wfw?: WfwNs.Item;
94
105
  yt?: YtNs.Item;
95
106
  pingback?: PingbackNs.Item;
96
107
  trackback?: TrackbackNs.Item;
97
- };
98
- type Feed<TDate extends DateLike> = {
99
- authors?: Array<Person>;
100
- categories?: Array<Category>;
101
- contributors?: Array<Person>;
102
- generator?: Generator;
108
+ xml?: XmlNs.ItemOrFeed;
109
+ }, TStrict>;
110
+ type Feed<TDate, TStrict extends boolean = false> = Strict<{
111
+ authors?: Array<Person<TStrict>>;
112
+ categories?: Array<Category<TStrict>>;
113
+ contributors?: Array<Person<TStrict>>;
114
+ generator?: Generator<TStrict>;
103
115
  icon?: string;
104
- id: string;
105
- links?: Array<Link<TDate>>;
116
+ id: Requirable<string>;
117
+ links?: Array<Link<TDate, TStrict>>;
106
118
  logo?: string;
107
119
  rights?: Text;
108
120
  subtitle?: Text;
109
- title: Text;
110
- updated: TDate;
111
- entries?: Array<Entry<TDate>>;
121
+ title: Requirable<Text>;
122
+ updated: Requirable<TDate>;
123
+ entries?: Array<Entry<TDate, TStrict>>;
112
124
  cc?: CcNs.ItemOrFeed;
113
125
  dc?: DcNs.ItemOrFeed<TDate>;
114
126
  sy?: SyNs.Feed<TDate>;
115
- itunes?: ItunesNs.Feed;
116
- googleplay?: GooglePlayNs.Feed;
117
- media?: MediaNs.ItemOrFeed;
118
- georss?: GeoRssNs.ItemOrFeed;
127
+ itunes?: ItunesNs.Feed<TStrict>;
128
+ googleplay?: GooglePlayNs.Feed<TStrict>;
129
+ media?: MediaNs.ItemOrFeed<TStrict>;
130
+ georss?: GeoRssNs.ItemOrFeed<TStrict>;
119
131
  geo?: GeoNs.ItemOrFeed;
120
132
  dcterms?: DcTermsNs.ItemOrFeed<TDate>;
121
133
  creativeCommons?: CreativeCommonsNs.ItemOrFeed;
122
- opensearch?: OpenSearchNs.Feed;
134
+ opensearch?: OpenSearchNs.Feed<TStrict>;
123
135
  yt?: YtNs.Feed;
124
136
  admin?: AdminNs.Feed;
125
137
  pingback?: PingbackNs.Feed;
126
- };
138
+ xml?: XmlNs.ItemOrFeed;
139
+ }, TStrict>;
127
140
  }
128
141
  //#endregion
129
142
  export { Atom };
@@ -1,11 +1,13 @@
1
1
  const require_config = require("../../../common/config.cjs");
2
2
  const require_utils = require("../../../common/utils.cjs");
3
3
  //#region src/feeds/atom/detect/index.ts
4
+ const feedElementRegex = /(?:^|[\s>])<(?:\w+:)?feed[\s>]/im;
5
+ const atomElementsRegex = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i;
4
6
  const detect = (value) => {
5
7
  if (!require_utils.isNonEmptyString(value)) return false;
6
- if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
8
+ if (!feedElementRegex.test(value)) return false;
7
9
  const hasAtomNamespace = require_config.namespaceUris.atom.some((uri) => value.includes(uri));
8
- const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
10
+ const hasAtomElements = atomElementsRegex.test(value);
9
11
  return hasAtomNamespace || hasAtomElements;
10
12
  };
11
13
  //#endregion
@@ -1,11 +1,13 @@
1
1
  import { namespaceUris } from "../../../common/config.js";
2
2
  import { isNonEmptyString } from "../../../common/utils.js";
3
3
  //#region src/feeds/atom/detect/index.ts
4
+ const feedElementRegex = /(?:^|[\s>])<(?:\w+:)?feed[\s>]/im;
5
+ const atomElementsRegex = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i;
4
6
  const detect = (value) => {
5
7
  if (!isNonEmptyString(value)) return false;
6
- if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
8
+ if (!feedElementRegex.test(value)) return false;
7
9
  const hasAtomNamespace = namespaceUris.atom.some((uri) => value.includes(uri));
8
- const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
10
+ const hasAtomElements = atomElementsRegex.test(value);
9
11
  return hasAtomNamespace || hasAtomElements;
10
12
  };
11
13
  //#endregion
@@ -1,3 +1,4 @@
1
+ const require_errors = require("../../../common/errors.cjs");
1
2
  const require_config = require("../../../common/config.cjs");
2
3
  const require_utils = require("../../../common/utils.cjs");
3
4
  const require_config$1 = require("./config.cjs");
@@ -5,7 +6,7 @@ const require_utils$1 = require("./utils.cjs");
5
6
  //#region src/feeds/atom/generate/index.ts
6
7
  const generate = (value, options) => {
7
8
  const generated = require_utils$1.generateFeed(value);
8
- if (!generated) throw new Error(require_config.locales.invalidInputAtom);
9
+ if (!generated) throw new require_errors.GenerateError(require_config.locales.invalidInputAtom);
9
10
  return require_utils.generateXml(require_config$1.builder, generated, options);
10
11
  };
11
12
  //#endregion
@@ -1,7 +1,7 @@
1
- import { DateLike, DeepPartial, XmlGenerateMain } from "../../../common/types.cjs";
1
+ import { DateLike, GenerateMainXml } from "../../../common/types.cjs";
2
2
  import { Atom } from "../common/types.cjs";
3
3
 
4
4
  //#region src/feeds/atom/generate/index.d.ts
5
- declare const generate: XmlGenerateMain<Atom.Feed<Date>, DeepPartial<Atom.Feed<DateLike>>>;
5
+ declare const generate: GenerateMainXml<Atom.Feed<DateLike>, Atom.Feed<Date, true>>;
6
6
  //#endregion
7
7
  export { generate };
@@ -1,7 +1,7 @@
1
- import { DateLike, DeepPartial, XmlGenerateMain } from "../../../common/types.js";
1
+ import { DateLike, GenerateMainXml } from "../../../common/types.js";
2
2
  import { Atom } from "../common/types.js";
3
3
 
4
4
  //#region src/feeds/atom/generate/index.d.ts
5
- declare const generate: XmlGenerateMain<Atom.Feed<Date>, DeepPartial<Atom.Feed<DateLike>>>;
5
+ declare const generate: GenerateMainXml<Atom.Feed<DateLike>, Atom.Feed<Date, true>>;
6
6
  //#endregion
7
7
  export { generate };
@@ -1,3 +1,4 @@
1
+ import { GenerateError } from "../../../common/errors.js";
1
2
  import { locales } from "../../../common/config.js";
2
3
  import { generateXml } from "../../../common/utils.js";
3
4
  import { builder } from "./config.js";
@@ -5,7 +6,7 @@ import { generateFeed } from "./utils.js";
5
6
  //#region src/feeds/atom/generate/index.ts
6
7
  const generate = (value, options) => {
7
8
  const generated = generateFeed(value);
8
- if (!generated) throw new Error(locales.invalidInputAtom);
9
+ if (!generated) throw new GenerateError(locales.invalidInputAtom);
9
10
  return generateXml(builder, generated, options);
10
11
  };
11
12
  //#endregion