@grimoire-rs/indexer 0.3.3 → 0.4.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 (110) hide show
  1. package/README.md +220 -9
  2. package/dist/ci.d.ts +6 -1
  3. package/dist/ci.d.ts.map +1 -1
  4. package/dist/ci.js +32 -1
  5. package/dist/ci.js.map +1 -1
  6. package/dist/cli/build.d.ts.map +1 -1
  7. package/dist/cli/build.js +3 -1
  8. package/dist/cli/build.js.map +1 -1
  9. package/dist/cli/ci.d.ts.map +1 -1
  10. package/dist/cli/ci.js +5 -1
  11. package/dist/cli/ci.js.map +1 -1
  12. package/dist/cli/enrich.d.ts +1 -0
  13. package/dist/cli/enrich.d.ts.map +1 -1
  14. package/dist/cli/enrich.js +38 -0
  15. package/dist/cli/enrich.js.map +1 -1
  16. package/dist/cli/init.d.ts.map +1 -1
  17. package/dist/cli/init.js +17 -3
  18. package/dist/cli/init.js.map +1 -1
  19. package/dist/cli/main.d.ts.map +1 -1
  20. package/dist/cli/main.js +9 -0
  21. package/dist/cli/main.js.map +1 -1
  22. package/dist/cli/ratings.d.ts +3 -0
  23. package/dist/cli/ratings.d.ts.map +1 -0
  24. package/dist/cli/ratings.js +160 -0
  25. package/dist/cli/ratings.js.map +1 -0
  26. package/dist/config.d.ts +19 -0
  27. package/dist/config.d.ts.map +1 -1
  28. package/dist/config.js +47 -1
  29. package/dist/config.js.map +1 -1
  30. package/dist/data/index.d.ts.map +1 -1
  31. package/dist/data/index.js +13 -0
  32. package/dist/data/index.js.map +1 -1
  33. package/dist/enrich/checkpoint.d.ts +53 -0
  34. package/dist/enrich/checkpoint.d.ts.map +1 -0
  35. package/dist/enrich/checkpoint.js +296 -0
  36. package/dist/enrich/checkpoint.js.map +1 -0
  37. package/dist/enrich/index.d.ts +14 -0
  38. package/dist/enrich/index.d.ts.map +1 -1
  39. package/dist/enrich/index.js +77 -4
  40. package/dist/enrich/index.js.map +1 -1
  41. package/dist/ratings/budget.d.ts +16 -0
  42. package/dist/ratings/budget.d.ts.map +1 -0
  43. package/dist/ratings/budget.js +7 -0
  44. package/dist/ratings/budget.js.map +1 -0
  45. package/dist/ratings/config.d.ts +56 -0
  46. package/dist/ratings/config.d.ts.map +1 -0
  47. package/dist/ratings/config.js +86 -0
  48. package/dist/ratings/config.js.map +1 -0
  49. package/dist/ratings/marker.d.ts +105 -0
  50. package/dist/ratings/marker.d.ts.map +1 -0
  51. package/dist/ratings/marker.js +141 -0
  52. package/dist/ratings/marker.js.map +1 -0
  53. package/dist/ratings/paging.d.ts +16 -0
  54. package/dist/ratings/paging.d.ts.map +1 -0
  55. package/dist/ratings/paging.js +36 -0
  56. package/dist/ratings/paging.js.map +1 -0
  57. package/dist/ratings/provider.d.ts +100 -0
  58. package/dist/ratings/provider.d.ts.map +1 -0
  59. package/dist/ratings/provider.js +203 -0
  60. package/dist/ratings/provider.js.map +1 -0
  61. package/dist/ratings/provider_github.d.ts +3 -0
  62. package/dist/ratings/provider_github.d.ts.map +1 -0
  63. package/dist/ratings/provider_github.js +135 -0
  64. package/dist/ratings/provider_github.js.map +1 -0
  65. package/dist/ratings/provider_gitlab.d.ts +3 -0
  66. package/dist/ratings/provider_gitlab.d.ts.map +1 -0
  67. package/dist/ratings/provider_gitlab.js +153 -0
  68. package/dist/ratings/provider_gitlab.js.map +1 -0
  69. package/dist/ratings/provider_memory.d.ts +28 -0
  70. package/dist/ratings/provider_memory.d.ts.map +1 -0
  71. package/dist/ratings/provider_memory.js +49 -0
  72. package/dist/ratings/provider_memory.js.map +1 -0
  73. package/dist/ratings/reconcile.d.ts +47 -0
  74. package/dist/ratings/reconcile.d.ts.map +1 -0
  75. package/dist/ratings/reconcile.js +133 -0
  76. package/dist/ratings/reconcile.js.map +1 -0
  77. package/dist/ratings/seed.d.ts +60 -0
  78. package/dist/ratings/seed.d.ts.map +1 -0
  79. package/dist/ratings/seed.js +132 -0
  80. package/dist/ratings/seed.js.map +1 -0
  81. package/dist/renderer/astro/components/Catalog.d.ts +2 -0
  82. package/dist/renderer/astro/components/Catalog.js +65 -16
  83. package/dist/renderer/astro/components/Catalog.tsx +119 -26
  84. package/dist/renderer/astro/components/CommandField.astro +1 -0
  85. package/dist/renderer/astro/components/VersionMenu.astro +31 -23
  86. package/dist/renderer/astro/layouts/Base.astro +218 -263
  87. package/dist/renderer/astro/lib/catalog.d.ts +25 -0
  88. package/dist/renderer/astro/lib/catalog.js +46 -0
  89. package/dist/renderer/astro/lib/catalog.ts +49 -0
  90. package/dist/renderer/astro/pages/p/[...slug].astro +238 -85
  91. package/dist/renderer/astro/styles/tokens.css +157 -0
  92. package/dist/renderer/index.d.ts.map +1 -1
  93. package/dist/renderer/index.js +101 -2
  94. package/dist/renderer/index.js.map +1 -1
  95. package/dist/renderer/types.d.ts +41 -0
  96. package/dist/renderer/types.d.ts.map +1 -1
  97. package/dist/validate/adapters/http.d.ts +29 -1
  98. package/dist/validate/adapters/http.d.ts.map +1 -1
  99. package/dist/validate/adapters/http.js +17 -2
  100. package/dist/validate/adapters/http.js.map +1 -1
  101. package/package.json +1 -1
  102. package/templates/ci/github-enrich.yml +9 -1
  103. package/templates/ci/github-pages.yml +11 -5
  104. package/templates/ci/github-ratings-seed.yml +88 -0
  105. package/templates/ci/github-ratings.yml +51 -0
  106. package/templates/ci/gitlab-ci.yml +3 -3
  107. package/templates/ci/gitlab-enrich.sh +10 -1
  108. package/templates/ci/gitlab-ratings-seed.sh +83 -0
  109. package/templates/ci/gitlab-ratings.yml +37 -0
  110. package/templates/gitignore +8 -0
@@ -1,7 +1,32 @@
1
+ import type { CatalogPackage } from "../../types.js";
1
2
  export type { CatalogPackage } from "../../types.js";
3
+ /**
4
+ * When a package last moved, for sorting and for the "updated" stamp.
5
+ *
6
+ * `updated` is what `enrich` derived — the artifact's own `created` when it
7
+ * has one, and the first build that saw the current digest when it does not.
8
+ * The fallback to `created` is for a sidecar written before that field
9
+ * existed: those records still date correctly instead of dropping into the
10
+ * unknown bucket on the first build after an upgrade.
11
+ */
12
+ export declare function lastUpdated(p: CatalogPackage): string | undefined;
2
13
  export declare function versionCascade(version: string | undefined, tags: string[]): string[];
3
14
  export declare function compareVersions(a: string, b: string): number;
4
15
  export declare function timeAgo(iso: string): string;
16
+ /**
17
+ * One registry-supplied string as an outbound href, or null.
18
+ *
19
+ * Every URL on a package page — its repository, its home page, its docs, its
20
+ * four support channels — is a string the index was handed by a registry it
21
+ * does not control, and an `href` is not made safe by escaping: `javascript:`
22
+ * is a perfectly well-formed attribute value that runs on click. Only the
23
+ * three schemes a link here can legitimately use survive; everything else
24
+ * renders as no link at all rather than as a live one.
25
+ *
26
+ * The raw string is returned rather than `URL.href`, so a link that was
27
+ * already fine is published exactly as the registry spelled it.
28
+ */
29
+ export declare function externalUrl(raw: unknown): string | null;
5
30
  /** `vscode://<publisher.extension>/open?repo=<ref>`, or null when disabled. */
6
31
  export declare function vscodeUrl(extension: string | null, ref: string): string | null;
7
32
  /**
@@ -1,5 +1,17 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // Copyright 2026 The Grimoire Authors
3
+ /**
4
+ * When a package last moved, for sorting and for the "updated" stamp.
5
+ *
6
+ * `updated` is what `enrich` derived — the artifact's own `created` when it
7
+ * has one, and the first build that saw the current digest when it does not.
8
+ * The fallback to `created` is for a sidecar written before that field
9
+ * existed: those records still date correctly instead of dropping into the
10
+ * unknown bucket on the first build after an upgrade.
11
+ */
12
+ export function lastUpdated(p) {
13
+ return p.updated ?? p.created;
14
+ }
3
15
  // Publishing 0.10.0 also moves the rolling tags 0.10, 0 and latest, so the
4
16
  // full tag list is mostly history. Return just the current release's chain
5
17
  // (latest | 0 | 0.10 | 0.10.0). `tags` must already be sorted newest-first.
@@ -54,6 +66,40 @@ export function timeAgo(iso) {
54
66
  }
55
67
  return RTF.format(Math.round(duration), "years");
56
68
  }
69
+ /** A bare address, which `support.contact` is far more likely to hold than a URL. */
70
+ const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
71
+ /** The only schemes a link on this site may carry. */
72
+ const LINK_SCHEMES = ["https:", "http:", "mailto:"];
73
+ /**
74
+ * One registry-supplied string as an outbound href, or null.
75
+ *
76
+ * Every URL on a package page — its repository, its home page, its docs, its
77
+ * four support channels — is a string the index was handed by a registry it
78
+ * does not control, and an `href` is not made safe by escaping: `javascript:`
79
+ * is a perfectly well-formed attribute value that runs on click. Only the
80
+ * three schemes a link here can legitimately use survive; everything else
81
+ * renders as no link at all rather than as a live one.
82
+ *
83
+ * The raw string is returned rather than `URL.href`, so a link that was
84
+ * already fine is published exactly as the registry spelled it.
85
+ */
86
+ export function externalUrl(raw) {
87
+ if (typeof raw !== "string")
88
+ return null;
89
+ const value = raw.trim();
90
+ if (value === "")
91
+ return null;
92
+ try {
93
+ return LINK_SCHEMES.includes(new URL(value).protocol) ? value : null;
94
+ }
95
+ catch {
96
+ // Not a URL at all. `mailto:` is only added to something that carries no
97
+ // scheme of its own — testing for an address first would read the
98
+ // `mailto:alice@acme.example` a publisher already wrote as a bare
99
+ // address and prefix it a second time.
100
+ return EMAIL.test(value) ? `mailto:${value}` : null;
101
+ }
102
+ }
57
103
  /** `vscode://<publisher.extension>/open?repo=<ref>`, or null when disabled. */
58
104
  export function vscodeUrl(extension, ref) {
59
105
  return extension ? `vscode://${extension}/open?repo=${encodeURIComponent(ref)}` : null;
@@ -5,8 +5,23 @@
5
5
  // client bundle. The build-time payload lives in `./data.ts`; the package
6
6
  // data itself is compiled by `src/data/` into `<outDir>/all.json`, so
7
7
  // nothing here walks the index tree.
8
+ import type { CatalogPackage } from "../../types.js";
9
+
8
10
  export type { CatalogPackage } from "../../types.js";
9
11
 
12
+ /**
13
+ * When a package last moved, for sorting and for the "updated" stamp.
14
+ *
15
+ * `updated` is what `enrich` derived — the artifact's own `created` when it
16
+ * has one, and the first build that saw the current digest when it does not.
17
+ * The fallback to `created` is for a sidecar written before that field
18
+ * existed: those records still date correctly instead of dropping into the
19
+ * unknown bucket on the first build after an upgrade.
20
+ */
21
+ export function lastUpdated(p: CatalogPackage): string | undefined {
22
+ return p.updated ?? p.created;
23
+ }
24
+
10
25
  // Publishing 0.10.0 also moves the rolling tags 0.10, 0 and latest, so the
11
26
  // full tag list is mostly history. Return just the current release's chain
12
27
  // (latest | 0 | 0.10 | 0.10.0). `tags` must already be sorted newest-first.
@@ -63,6 +78,40 @@ export function timeAgo(iso: string): string {
63
78
  return RTF.format(Math.round(duration), "years");
64
79
  }
65
80
 
81
+ /** A bare address, which `support.contact` is far more likely to hold than a URL. */
82
+ const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
83
+
84
+ /** The only schemes a link on this site may carry. */
85
+ const LINK_SCHEMES = ["https:", "http:", "mailto:"];
86
+
87
+ /**
88
+ * One registry-supplied string as an outbound href, or null.
89
+ *
90
+ * Every URL on a package page — its repository, its home page, its docs, its
91
+ * four support channels — is a string the index was handed by a registry it
92
+ * does not control, and an `href` is not made safe by escaping: `javascript:`
93
+ * is a perfectly well-formed attribute value that runs on click. Only the
94
+ * three schemes a link here can legitimately use survive; everything else
95
+ * renders as no link at all rather than as a live one.
96
+ *
97
+ * The raw string is returned rather than `URL.href`, so a link that was
98
+ * already fine is published exactly as the registry spelled it.
99
+ */
100
+ export function externalUrl(raw: unknown): string | null {
101
+ if (typeof raw !== "string") return null;
102
+ const value = raw.trim();
103
+ if (value === "") return null;
104
+ try {
105
+ return LINK_SCHEMES.includes(new URL(value).protocol) ? value : null;
106
+ } catch {
107
+ // Not a URL at all. `mailto:` is only added to something that carries no
108
+ // scheme of its own — testing for an address first would read the
109
+ // `mailto:alice@acme.example` a publisher already wrote as a bare
110
+ // address and prefix it a second time.
111
+ return EMAIL.test(value) ? `mailto:${value}` : null;
112
+ }
113
+ }
114
+
66
115
  /** `vscode://<publisher.extension>/open?repo=<ref>`, or null when disabled. */
67
116
  export function vscodeUrl(extension: string | null, ref: string): string | null {
68
117
  return extension ? `vscode://${extension}/open?repo=${encodeURIComponent(ref)}` : null;