polen 0.11.0-next.16 → 0.11.0-next.17

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 (93) hide show
  1. package/build/api/examples/diagnostic/diagnostic.d.ts +4 -4
  2. package/build/api/examples/diagnostic/missing-versions.d.ts +5 -4
  3. package/build/api/examples/diagnostic/missing-versions.d.ts.map +1 -1
  4. package/build/api/examples/diagnostic/missing-versions.js +3 -2
  5. package/build/api/examples/diagnostic/missing-versions.js.map +1 -1
  6. package/build/api/examples/diagnostic/unknown-version.d.ts +5 -4
  7. package/build/api/examples/diagnostic/unknown-version.d.ts.map +1 -1
  8. package/build/api/examples/diagnostic/unknown-version.js +3 -2
  9. package/build/api/examples/diagnostic/unknown-version.js.map +1 -1
  10. package/build/api/examples/diagnostic/validator.d.ts.map +1 -1
  11. package/build/api/examples/diagnostic/validator.js +7 -8
  12. package/build/api/examples/diagnostic/validator.js.map +1 -1
  13. package/build/api/examples/scanner.d.ts.map +1 -1
  14. package/build/api/examples/scanner.js +20 -16
  15. package/build/api/examples/scanner.js.map +1 -1
  16. package/build/api/examples/type-usage-indexer.d.ts.map +1 -1
  17. package/build/api/examples/type-usage-indexer.js +4 -5
  18. package/build/api/examples/type-usage-indexer.js.map +1 -1
  19. package/build/api/schema/input-sources/versioned-directory.d.ts +3 -3
  20. package/build/api/schema/input-sources/versioned-directory.d.ts.map +1 -1
  21. package/build/api/schema/input-sources/versioned-directory.js +4 -2
  22. package/build/api/schema/input-sources/versioned-directory.js.map +1 -1
  23. package/build/api/schema/load.js +1 -1
  24. package/build/api/schema/load.js.map +1 -1
  25. package/build/cli/commands/hero-image.js +1 -1
  26. package/build/cli/commands/hero-image.js.map +1 -1
  27. package/build/lib/catalog/catalog.d.ts +24 -23
  28. package/build/lib/catalog/catalog.d.ts.map +1 -1
  29. package/build/lib/catalog/catalog.js +7 -13
  30. package/build/lib/catalog/catalog.js.map +1 -1
  31. package/build/lib/catalog/versioned.d.ts +36 -26
  32. package/build/lib/catalog/versioned.d.ts.map +1 -1
  33. package/build/lib/catalog/versioned.js +25 -6
  34. package/build/lib/catalog/versioned.js.map +1 -1
  35. package/build/lib/catalog-statistics/analyze-catalog.js +3 -3
  36. package/build/lib/catalog-statistics/analyze-catalog.js.map +1 -1
  37. package/build/lib/lifecycles/lifecycles.js +1 -1
  38. package/build/lib/lifecycles/lifecycles.js.map +1 -1
  39. package/build/template/components/Changelog/Changelog.d.ts.map +1 -1
  40. package/build/template/components/Changelog/Changelog.js +7 -7
  41. package/build/template/components/Changelog/Changelog.js.map +1 -1
  42. package/build/template/components/GraphQLDocument.js +6 -5
  43. package/build/template/components/GraphQLDocument.js.map +1 -1
  44. package/build/template/components/VersionPicker.d.ts.map +1 -1
  45. package/build/template/components/VersionPicker.js +5 -2
  46. package/build/template/components/VersionPicker.js.map +1 -1
  47. package/build/template/components/home/FeaturesGrid.js +1 -1
  48. package/build/template/components/home/FeaturesGrid.js.map +1 -1
  49. package/build/template/components/home/HeroSection.js +1 -1
  50. package/build/template/components/home/HeroSection.js.map +1 -1
  51. package/build/template/components/home/RecentChanges.d.ts.map +1 -1
  52. package/build/template/components/home/RecentChanges.js +2 -1
  53. package/build/template/components/home/RecentChanges.js.map +1 -1
  54. package/build/template/routes/changelog.d.ts +1 -1
  55. package/build/template/routes/changelog.d.ts.map +1 -1
  56. package/build/template/routes/changelog.js +7 -4
  57. package/build/template/routes/changelog.js.map +1 -1
  58. package/build/template/routes/examples/_index.js +1 -1
  59. package/build/template/routes/examples/_index.js.map +1 -1
  60. package/build/template/routes/reference.js +6 -6
  61. package/build/template/routes/reference.js.map +1 -1
  62. package/build/vite/plugins/navbar.js +1 -1
  63. package/build/vite/plugins/navbar.js.map +1 -1
  64. package/build/vite/plugins/routes-manifest.js +1 -1
  65. package/build/vite/plugins/routes-manifest.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/api/examples/diagnostic/missing-versions.ts +3 -2
  68. package/src/api/examples/diagnostic/unknown-version.ts +3 -2
  69. package/src/api/examples/diagnostic/validator.test.ts +70 -55
  70. package/src/api/examples/diagnostic/validator.ts +7 -9
  71. package/src/api/examples/scanner.ts +25 -20
  72. package/src/api/examples/type-usage-indexer.test.ts +44 -33
  73. package/src/api/examples/type-usage-indexer.ts +4 -7
  74. package/src/api/schema/$.test.ts +2 -2
  75. package/src/api/schema/input-sources/versioned-directory.ts +7 -2
  76. package/src/api/schema/load.ts +1 -1
  77. package/src/cli/commands/hero-image.ts +1 -1
  78. package/src/lib/catalog/catalog.ts +7 -13
  79. package/src/lib/catalog/versioned.ts +35 -6
  80. package/src/lib/catalog-statistics/$.test.ts +22 -12
  81. package/src/lib/catalog-statistics/analyze-catalog.ts +3 -3
  82. package/src/lib/lifecycles/lifecycles.ts +1 -1
  83. package/src/template/components/Changelog/Changelog.tsx +10 -6
  84. package/src/template/components/GraphQLDocument.tsx +6 -5
  85. package/src/template/components/VersionPicker.tsx +9 -2
  86. package/src/template/components/home/FeaturesGrid.tsx +1 -1
  87. package/src/template/components/home/HeroSection.tsx +1 -1
  88. package/src/template/components/home/RecentChanges.tsx +3 -1
  89. package/src/template/routes/changelog.tsx +10 -4
  90. package/src/template/routes/examples/_index.tsx +1 -1
  91. package/src/template/routes/reference.tsx +6 -6
  92. package/src/vite/plugins/navbar.ts +1 -1
  93. package/src/vite/plugins/routes-manifest.ts +1 -1
@@ -1,6 +1,8 @@
1
1
  import { Api } from '#api/iso'
2
2
  import type { React } from '#dep/react/index'
3
+ import { Catalog } from '#lib/catalog/$'
3
4
  import { Version } from '#lib/version/$'
5
+ import { HashMap, Option } from 'effect'
4
6
  import { useNavigate } from 'react-router'
5
7
  import { schemasCatalog } from 'virtual:polen/project/schemas'
6
8
  import { useReferencePath } from '../hooks/useReferencePath.js'
@@ -33,12 +35,17 @@ export const VersionPicker: React.FC<Props> = ({ data, current }) => {
33
35
 
34
36
  // Find the schema for the target version
35
37
  // Note: newVersion is a string that we need to parse
36
- const targetSchema = catalog.entries.find(schema => Version.encodeSync(schema.version) === newVersion)
38
+ const targetSchemaOption = Option.map(
39
+ HashMap.findFirst(catalog.entries, (_, key) => Version.encodeSync(key) === newVersion),
40
+ ([, value]) => value,
41
+ )
37
42
 
38
- if (!targetSchema) {
43
+ if (Option.isNone(targetSchemaOption)) {
39
44
  throw new Error(`Version ${newVersion} not found`)
40
45
  }
41
46
 
47
+ const targetSchema = Option.getOrThrow(targetSchemaOption)
48
+
42
49
  // Find fallback path if needed
43
50
  const fallbackPath = Api.Schema.Validation.findFallbackPath(targetSchema.definition, currentPath)
44
51
  // Get redirect description if path changed
@@ -80,7 +80,7 @@ function getDefaultFeatures(): Feature[] {
80
80
  if (schemasCatalog) {
81
81
  try {
82
82
  // Get the latest schema from the catalog
83
- const latestSchema = Catalog.getLatestSchema(schemasCatalog)
83
+ const latestSchema = Catalog.getLatest(schemasCatalog)
84
84
 
85
85
  if (latestSchema && latestSchema.definition) {
86
86
  // Build stats from the schema definition
@@ -84,7 +84,7 @@ export const Hero: React.FC<HeroProps> = ({
84
84
  let schemaStats = null
85
85
  if (schemasCatalog) {
86
86
  try {
87
- const latestSchema = Catalog.getLatestSchema(schemasCatalog)
87
+ const latestSchema = Catalog.getLatest(schemasCatalog)
88
88
  if (latestSchema && latestSchema.definition) {
89
89
  const versionStats = CatalogStatistics.analyzeSchema(latestSchema.definition, 'current')
90
90
  schemaStats = {
@@ -3,6 +3,8 @@ import * as React from 'react'
3
3
  import { Link } from 'react-router'
4
4
  import { schemasCatalog } from 'virtual:polen/project/schemas'
5
5
 
6
+ import { Catalog } from '#lib/catalog'
7
+
6
8
  interface RecentChangesProps {
7
9
  limit?: number
8
10
  showVersions?: boolean
@@ -30,7 +32,7 @@ export const RecentChangesSection: React.FC<RecentChangesProps> = ({
30
32
 
31
33
  // For versioned catalogs, we look at entries
32
34
  if (schemasCatalog._tag === 'CatalogVersioned') {
33
- const entries = schemasCatalog.entries || []
35
+ const entries = Catalog.Versioned.getAll(schemasCatalog)
34
36
  const recentEntries = entries.slice(0, limit)
35
37
 
36
38
  return recentEntries.flatMap(entry =>
@@ -6,7 +6,7 @@ import { Revision } from '#lib/revision'
6
6
  import { Swiss } from '#lib/swiss'
7
7
  import { Version } from '#lib/version'
8
8
  import { Box, Flex, Text } from '@radix-ui/themes'
9
- import { Effect } from 'effect'
9
+ import { Effect, HashMap, Option } from 'effect'
10
10
  import React, { useEffect, useMemo, useState } from 'react'
11
11
  import { useParams } from 'react-router'
12
12
  import { schemasCatalog } from 'virtual:polen/project/schemas'
@@ -136,7 +136,7 @@ const Component = () => {
136
136
  // Get available versions if catalog is versioned
137
137
  const availableVersions = useMemo(() => {
138
138
  if (Catalog.Versioned.is(catalog)) {
139
- return catalog.entries.map(entry => Version.encodeSync(entry.version))
139
+ return Catalog.Versioned.getVersions(catalog).map(Version.encodeSync)
140
140
  }
141
141
  return []
142
142
  }, [catalog])
@@ -148,8 +148,14 @@ const Component = () => {
148
148
  } else {
149
149
  // For versioned catalogs, show only current version's revisions
150
150
  if (urlVersion) {
151
- const entry = catalog.entries.find(e => Version.encodeSync(e.version) === urlVersion)
152
- return entry ? entry.revisions : []
151
+ const entryOption = Option.map(
152
+ HashMap.findFirst(catalog.entries, (_, key) => Version.encodeSync(key) === urlVersion),
153
+ ([, value]) => value,
154
+ )
155
+ return Option.match(entryOption, {
156
+ onNone: () => [],
157
+ onSome: (entry) => entry.revisions,
158
+ })
153
159
  }
154
160
  // No revisions if no version selected (will redirect)
155
161
  return []
@@ -36,7 +36,7 @@ export const loader = async () => {
36
36
 
37
37
  const Component = () => {
38
38
  const examplesCatalog = useLoaderData(IndexSchema)
39
- const schema = schemasCatalog && Catalog.getLatestSchema(schemasCatalog).definition
39
+ const schema = schemasCatalog && Catalog.getLatest(schemasCatalog).definition
40
40
  const hasExamples = examplesCatalog && examplesCatalog.examples.length > 0
41
41
 
42
42
  // TODO: This should become a proper diagnostic viewer component that displays
@@ -6,10 +6,10 @@ import { S } from '#lib/kit-temp/effect'
6
6
  import { Lifecycles } from '#lib/lifecycles/$'
7
7
  import { route, useLoaderData } from '#lib/react-router-effect/react-router-effect'
8
8
  import { Schema } from '#lib/schema/$'
9
- import { Swiss } from '#lib/swiss'
10
9
  import { Version } from '#lib/version/$'
11
10
  import { Flex } from '@radix-ui/themes'
12
11
  import { neverCase } from '@wollybeard/kit/language'
12
+ import { HashMap, Option } from 'effect'
13
13
  import { Effect, Match } from 'effect'
14
14
  import React from 'react'
15
15
  import { useParams } from 'react-router'
@@ -49,15 +49,15 @@ const referenceLoader = ({ params }: any) => {
49
49
  // If version param provided, find that specific version
50
50
  if (params.version) {
51
51
  const requestedVersion = Version.decodeSync(params.version)
52
- const found = c.entries.find(s => Version.equivalence(requestedVersion, s.version))
53
- if (!found) {
52
+ const foundOption = HashMap.get(c.entries, requestedVersion)
53
+ if (Option.isNone(foundOption)) {
54
54
  // TODO: Return 404 error
55
55
  throw new Error(`Version ${params.version} not found`)
56
56
  }
57
- return found
57
+ return Option.getOrThrow(foundOption)
58
58
  }
59
59
  // No version param means "latest" - use the last entry
60
- const latest = c.entries[c.entries.length - 1]
60
+ const latest = Catalog.Versioned.getLatestOrThrow(c)
61
61
  if (!latest) {
62
62
  throw new Error('No schemas available in versioned catalog')
63
63
  }
@@ -161,7 +161,7 @@ const ReferenceView = () => {
161
161
  return catalog._tag === 'CatalogVersioned' && version
162
162
  ? (
163
163
  <VersionPicker
164
- data={catalog.entries.map(entry => entry.version)}
164
+ data={Catalog.Versioned.getVersions(catalog)}
165
165
  current={version}
166
166
  />
167
167
  )
@@ -59,7 +59,7 @@ export const Navbar = ({
59
59
  const hasMultipleRevisions = Catalog.fold(
60
60
  (versioned) => {
61
61
  // For versioned catalogs, count total revisions across all entries
62
- const totalRevisions = versioned.entries.reduce(
62
+ const totalRevisions = Catalog.Versioned.getAll(versioned).reduce(
63
63
  (sum: number, entry) => sum + entry.revisions.length,
64
64
  0,
65
65
  )
@@ -100,7 +100,7 @@ function processVersionedCatalog(
100
100
  catalog: Catalog.Versioned.Versioned,
101
101
  routes: string[],
102
102
  ): void {
103
- for (const schema of catalog.entries) {
103
+ for (const schema of Catalog.Versioned.getAll(catalog)) {
104
104
  const version = schema.version
105
105
  routes.push(`/reference/version/${version}`)
106
106