@warpgogol/werkstatt-shared 0.2.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.
- package/package.json +352 -0
- package/src/checks/index.ts +24 -0
- package/src/checks/lib/astro-site-url.ts +30 -0
- package/src/checks/lib/i18n.ts +30 -0
- package/src/checks/result-helpers.ts +102 -0
- package/src/checks/suppressions-config.ts +195 -0
- package/src/index.ts +14 -0
- package/src/integration/README.md +38 -0
- package/src/integration/adapters.ts +143 -0
- package/src/integration/crm-buffer.ts +491 -0
- package/src/integration/dispatch.ts +106 -0
- package/src/integration/funnel.ts +379 -0
- package/src/integration/index.ts +56 -0
- package/src/integration/lifecycle.ts +155 -0
- package/src/integration/orchestration.ts +439 -0
- package/src/integration/port-barrel.ts +124 -0
- package/src/integration/port.ts +143 -0
- package/src/integration/qstash.ts +134 -0
- package/src/integration/sharding.ts +133 -0
- package/src/integration/tests/deliver-event.test.ts +52 -0
- package/src/integration/tests/dispatch.test.ts +88 -0
- package/src/integration/tests/funnel-bridge.test.ts +46 -0
- package/src/integration/tests/hub-runtime.test.ts +128 -0
- package/src/integration/tests/lifecycle.test.ts +69 -0
- package/src/integration/tests/qstash.test.ts +83 -0
- package/src/integration/tests/sharding.test.ts +64 -0
- package/src/integration/vitest.config.ts +8 -0
- package/src/integration-adapter-supabase-crm/adapter.ts +437 -0
- package/src/integration-adapter-supabase-crm/client.ts +605 -0
- package/src/integration-adapter-supabase-crm/index.ts +28 -0
- package/src/integration-adapter-supabase-crm/pipedrive-sync-target.ts +482 -0
- package/src/integration-adapter-supabase-crm/supabase-rest.ts +89 -0
- package/src/integration-adapter-supabase-crm/tenant-registry.ts +334 -0
- package/src/integration-adapter-supabase-crm/tests/change-balance.pbt.test.ts +83 -0
- package/src/integration-adapter-supabase-crm/tests/funnel-persistence.test.ts +409 -0
- package/src/integration-adapter-supabase-crm/tests/lifecycle-sync.test.ts +288 -0
- package/src/integration-adapter-supabase-crm/tests/stage-map.test.ts +80 -0
- package/src/integration-adapter-supabase-crm/vitest.config.ts +8 -0
- package/src/integration-adapter-supabase-crm/worker.ts +223 -0
- package/src/observability/conventions.ts +93 -0
- package/src/observability/env-resolver.ts +57 -0
- package/src/observability/index.ts +57 -0
- package/src/observability/metric-registry.ts +184 -0
- package/src/observability/otlp-converter.ts +125 -0
- package/src/observability/otlp-json.ts +135 -0
- package/src/observability/otlp-transport.ts +68 -0
- package/src/observability/pusher.ts +142 -0
- package/src/observability/redact.ts +27 -0
- package/src/observability/tests/conventions.test.ts +100 -0
- package/src/observability/tests/metric-registry.test.ts +117 -0
- package/src/observability/tests/otlp-converter.pbt.test.ts +77 -0
- package/src/observability/tests/otlp-converter.test.ts +157 -0
- package/src/observability/tests/otlp-json.test.ts +120 -0
- package/src/observability/tests/pusher.test.ts +75 -0
- package/src/observability/tests/redact.pbt.test.ts +71 -0
- package/src/observability/tests/redact.test.ts +37 -0
- package/src/observability/typed-refs.ts +137 -0
- package/src/observability/vitest.config.ts +8 -0
- package/src/ontology/analytics/matomo-binding.yaml +172 -0
- package/src/ontology/analytics/matomo-fleet.registry.yaml +26 -0
- package/src/ontology/analytics/messkanon.yaml +151 -0
- package/src/ontology/archetype-registry.ts +61 -0
- package/src/ontology/archetypes/components/brand-label.yaml +19 -0
- package/src/ontology/archetypes/components/copyright.yaml +19 -0
- package/src/ontology/archetypes/components/currency-aware-price-display.yaml +19 -0
- package/src/ontology/archetypes/components/currency-selector.yaml +19 -0
- package/src/ontology/archetypes/components/footer-promo.yaml +19 -0
- package/src/ontology/archetypes/components/lang-switcher.yaml +19 -0
- package/src/ontology/archetypes/components/layout.yaml +19 -0
- package/src/ontology/archetypes/components/live-photo.yaml +20 -0
- package/src/ontology/archetypes/components/material-credit.yaml +20 -0
- package/src/ontology/archetypes/components/media.yaml +21 -0
- package/src/ontology/archetypes/components/nachweis-card.yaml +34 -0
- package/src/ontology/archetypes/components/nachweis-detail.yaml +43 -0
- package/src/ontology/archetypes/components/nachweis-list.yaml +37 -0
- package/src/ontology/archetypes/components/nachweis-verify.yaml +31 -0
- package/src/ontology/archetypes/components/not-found.yaml +22 -0
- package/src/ontology/archetypes/components/offer-capacity.yaml +21 -0
- package/src/ontology/archetypes/components/passport-header.yaml +19 -0
- package/src/ontology/archetypes/components/passport-provenance.yaml +20 -0
- package/src/ontology/archetypes/components/passport-score-grid.yaml +20 -0
- package/src/ontology/archetypes/components/passport-star-map.yaml +20 -0
- package/src/ontology/archetypes/components/person-profile.yaml +20 -0
- package/src/ontology/archetypes/components/pulsar.yaml +20 -0
- package/src/ontology/archetypes/components/responsive-image.yaml +19 -0
- package/src/ontology/archetypes/components/scroll-to-top.yaml +22 -0
- package/src/ontology/archetypes/components/social-meta.yaml +20 -0
- package/src/ontology/archetypes/components/structured-data.yaml +19 -0
- package/src/ontology/archetypes/index.json +1003 -0
- package/src/ontology/archetypes/index.yaml +821 -0
- package/src/ontology/archetypes/sections/approach.yaml +23 -0
- package/src/ontology/archetypes/sections/article-list.yaml +30 -0
- package/src/ontology/archetypes/sections/audience-cards.yaml +30 -0
- package/src/ontology/archetypes/sections/breadcrumbs.yaml +21 -0
- package/src/ontology/archetypes/sections/chat-widget.yaml +37 -0
- package/src/ontology/archetypes/sections/comparison-cards.yaml +31 -0
- package/src/ontology/archetypes/sections/controlled-responsibility-block.yaml +34 -0
- package/src/ontology/archetypes/sections/credits.yaml +29 -0
- package/src/ontology/archetypes/sections/donation-card.yaml +53 -0
- package/src/ontology/archetypes/sections/donation-use.yaml +23 -0
- package/src/ontology/archetypes/sections/dynamic-status-block.yaml +35 -0
- package/src/ontology/archetypes/sections/faq-list.yaml +26 -0
- package/src/ontology/archetypes/sections/final-cta.yaml +53 -0
- package/src/ontology/archetypes/sections/hero-decision-card.yaml +65 -0
- package/src/ontology/archetypes/sections/hero.yaml +50 -0
- package/src/ontology/archetypes/sections/impact.yaml +23 -0
- package/src/ontology/archetypes/sections/markdown.yaml +43 -0
- package/src/ontology/archetypes/sections/mountain-journey.yaml +43 -0
- package/src/ontology/archetypes/sections/navigation.yaml +20 -0
- package/src/ontology/archetypes/sections/notausgang-block.yaml +41 -0
- package/src/ontology/archetypes/sections/open-source-registry.yaml +26 -0
- package/src/ontology/archetypes/sections/ownership-block.yaml +57 -0
- package/src/ontology/archetypes/sections/people.yaml +48 -0
- package/src/ontology/archetypes/sections/price-card.yaml +50 -0
- package/src/ontology/archetypes/sections/problem.yaml +23 -0
- package/src/ontology/archetypes/sections/send-message.yaml +63 -0
- package/src/ontology/archetypes/sections/service-metadata-block.yaml +40 -0
- package/src/ontology/archetypes/sections/social-proof.yaml +27 -0
- package/src/ontology/archetypes/sections/transparency.yaml +32 -0
- package/src/ontology/archetypes/sections/trust-strip.yaml +42 -0
- package/src/ontology/archetypes/sections/video-section.yaml +27 -0
- package/src/ontology/archetypes/sections/women.yaml +29 -0
- package/src/ontology/biome-token-projection.ts +229 -0
- package/src/ontology/biomes/check-concrete-blueprint.yaml +118 -0
- package/src/ontology/biomes/handwerk-material-warm.yaml +135 -0
- package/src/ontology/biomes/nonprofit-trust.yaml +123 -0
- package/src/ontology/blueprints/offer.yaml +39 -0
- package/src/ontology/blueprints/prompts/local-market-signal.md +13 -0
- package/src/ontology/blueprints/prompts/website-local-narrative.md +24 -0
- package/src/ontology/blueprints/ratgeber.yaml +62 -0
- package/src/ontology/blueprints/website-local.yaml +309 -0
- package/src/ontology/blueprints/website-service.yaml +84 -0
- package/src/ontology/capabilities/lead.submit.yaml +44 -0
- package/src/ontology/cosmic/index.ts +48 -0
- package/src/ontology/cosmic/moon-catalog.ts +173 -0
- package/src/ontology/cosmic/planet-catalog.ts +82 -0
- package/src/ontology/cosmic/star-catalog.ts +337 -0
- package/src/ontology/enums.ts +159 -0
- package/src/ontology/external-surfaces/index.ts +158 -0
- package/src/ontology/external-surfaces/jsonld-types.yaml +135 -0
- package/src/ontology/external-surfaces/sitemap-shape.yaml +6 -0
- package/src/ontology/external-surfaces/url-schema.yaml +95 -0
- package/src/ontology/growth/events/contact-email-click.yaml +21 -0
- package/src/ontology/growth/events/contact-form-submit.yaml +25 -0
- package/src/ontology/growth/events/contact-phone-click.yaml +21 -0
- package/src/ontology/growth/events/contact-route-click.yaml +21 -0
- package/src/ontology/growth/events/contact-submit.yaml +28 -0
- package/src/ontology/growth/events/contact-whatsapp-click.yaml +21 -0
- package/src/ontology/growth/events/cta-click.yaml +30 -0
- package/src/ontology/growth/events/donation-confirmed.yaml +32 -0
- package/src/ontology/growth/events/donation-form-start.yaml +21 -0
- package/src/ontology/growth/events/donation-form-submit.yaml +29 -0
- package/src/ontology/growth/events/donation-intent.yaml +29 -0
- package/src/ontology/growth/events/form-error.yaml +27 -0
- package/src/ontology/growth/events/form-start.yaml +21 -0
- package/src/ontology/growth/events/form-submit.yaml +21 -0
- package/src/ontology/growth/events/outbound-click.yaml +25 -0
- package/src/ontology/growth/events/page-view.yaml +24 -0
- package/src/ontology/growth/events/passport-view.yaml +28 -0
- package/src/ontology/growth/events/star-map-navigate.yaml +30 -0
- package/src/ontology/index.ts +165 -0
- package/src/ontology/manifest.ts +344 -0
- package/src/ontology/operations/index.ts +1 -0
- package/src/ontology/schemas/biome.ts +303 -0
- package/src/ontology/schemas/capability.ts +104 -0
- package/src/ontology/schemas/constellation.ts +114 -0
- package/src/ontology/schemas/dns-records.ts +53 -0
- package/src/ontology/schemas/index.ts +95 -0
- package/src/ontology/schemas/manifest-resolver.ts +123 -0
- package/src/ontology/schemas/page-entry.ts +213 -0
- package/src/ontology/schemas/section-archetype.ts +109 -0
- package/src/ontology/schemas/site-family.ts +98 -0
- package/src/ontology/schemas/system/growth.ts +80 -0
- package/src/ontology/schemas/system/integrations.ts +143 -0
- package/src/ontology/schemas/system/manifest.ts +492 -0
- package/src/ontology/schemas/system/page-output.ts +99 -0
- package/src/ontology/schemas/system/release.ts +58 -0
- package/src/ontology/schemas/system/text.ts +58 -0
- package/src/ontology/schemas/system.ts +53 -0
- package/src/ontology/shared-section-props/body-fragments.ts +182 -0
- package/src/ontology/shared-section-props/catalog.ts +195 -0
- package/src/ontology/shared-section-props/common.ts +178 -0
- package/src/ontology/shared-section-props/index.ts +34 -0
- package/src/ontology/shared-section-props/visual-header.ts +163 -0
- package/src/ontology/site-families/charity-donation-trust/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/charity-donation-trust/family.yaml +44 -0
- package/src/ontology/site-families/charity-donation-trust/linguistic-rules.yaml +6 -0
- package/src/ontology/site-families/check-quality-operator/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/check-quality-operator/family.yaml +40 -0
- package/src/ontology/site-families/check-quality-operator/linguistic-rules.yaml +6 -0
- package/src/ontology/site-families/handwerk-trust-engineering/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/handwerk-trust-engineering/family.yaml +53 -0
- package/src/ontology/site-families/handwerk-trust-engineering/linguistic-rules.yaml +6 -0
- package/src/ontology/tests/catalogs.pbt.test.ts +89 -0
- package/src/ontology/tests/enums.test.ts +203 -0
- package/src/ontology/tests/sternsystem-owner.test.ts +63 -0
- package/src/ontology/vitest.config.ts +8 -0
- package/src/passport/dht-sign.test.ts +99 -0
- package/src/passport/dht-sign.ts +73 -0
- package/src/passport/identity-sign.test.ts +134 -0
- package/src/passport/identity-sign.ts +85 -0
- package/src/passport/index.ts +53 -0
- package/src/passport/key-rotate.ts +133 -0
- package/src/passport/schema.ts +198 -0
- package/src/passport/sign.ts +225 -0
- package/src/passport/tests/schema.pbt.test.ts +93 -0
- package/src/passport/tests/schema.test.ts +222 -0
- package/src/passport/vitest.config.ts +8 -0
- package/src/share/agent/api-catalog.ts +77 -0
- package/src/share/agent/capability.ts +68 -0
- package/src/share/agent/dns-aid.test.ts +74 -0
- package/src/share/agent/dns-aid.ts +53 -0
- package/src/share/agent/fleet-catalog.ts +149 -0
- package/src/share/agent/index.ts +29 -0
- package/src/share/agent/knowledge.ts +96 -0
- package/src/share/agent/manifest.ts +126 -0
- package/src/share/agent/mcp-card.ts +63 -0
- package/src/share/agent/omit-empty.ts +77 -0
- package/src/share/agent/openapi.ts +157 -0
- package/src/share/agent/proof.ts +61 -0
- package/src/share/attribution-display.ts +86 -0
- package/src/share/check-hints.ts +38 -0
- package/src/share/content/entity-id.ts +65 -0
- package/src/share/content/index.ts +16 -0
- package/src/share/content/merge.ts +86 -0
- package/src/share/content/resolve-field-path.ts +39 -0
- package/src/share/content/substitute-deep.ts +47 -0
- package/src/share/content-discipline/index.ts +14 -0
- package/src/share/content-discipline/parsers.ts +66 -0
- package/src/share/content-discipline/types.ts +118 -0
- package/src/share/content-reference.ts +333 -0
- package/src/share/counter-utils.ts +75 -0
- package/src/share/css-value-normalize.ts +48 -0
- package/src/share/dev-props-validator.ts +131 -0
- package/src/share/entitlement.ts +172 -0
- package/src/share/env.d.ts +73 -0
- package/src/share/feature-policy.ts +367 -0
- package/src/share/formula-eval.ts +364 -0
- package/src/share/fs/index.ts +96 -0
- package/src/share/i18n/localization.ts +57 -0
- package/src/share/image-provider.ts +314 -0
- package/src/share/index.ts +86 -0
- package/src/share/knowledge/claim.ts +129 -0
- package/src/share/knowledge/derivation.ts +55 -0
- package/src/share/knowledge/freshness.ts +127 -0
- package/src/share/knowledge/index.ts +23 -0
- package/src/share/knowledge/ledger.ts +222 -0
- package/src/share/knowledge/plan.ts +122 -0
- package/src/share/knowledge/source.ts +170 -0
- package/src/share/legal/translation-policy.ts +133 -0
- package/src/share/material-credits.ts +181 -0
- package/src/share/middleware/language-redirect.ts +49 -0
- package/src/share/offer-capacity.ts +149 -0
- package/src/share/onboarding-yaml/index.ts +162 -0
- package/src/share/page.ts +351 -0
- package/src/share/redirects.test.ts +62 -0
- package/src/share/redirects.ts +54 -0
- package/src/share/rfc0042-utils.ts +95 -0
- package/src/share/runtime-context.ts +70 -0
- package/src/share/schemas/claim-records.ts +69 -0
- package/src/share/schemas/claims.ts +150 -0
- package/src/share/schemas/effects.ts +212 -0
- package/src/share/schemas/features.ts +147 -0
- package/src/share/schemas/horizontal-align.ts +22 -0
- package/src/share/schemas/icon-color.ts +27 -0
- package/src/share/schemas/index.ts +43 -0
- package/src/share/schemas/live-photo.ts +53 -0
- package/src/share/schemas/material-credit.ts +292 -0
- package/src/share/schemas/media.ts +220 -0
- package/src/share/schemas/navigation.ts +74 -0
- package/src/share/schemas/page-base.ts +33 -0
- package/src/share/schemas/participant.ts +247 -0
- package/src/share/schemas/person.ts +24 -0
- package/src/share/schemas/print.ts +93 -0
- package/src/share/schemas/section-background.ts +106 -0
- package/src/share/schemas/section-body.ts +138 -0
- package/src/share/schemas/section-cards.ts +37 -0
- package/src/share/schemas/section-cta.ts +74 -0
- package/src/share/schemas/section-header.ts +77 -0
- package/src/share/schemas/section-image.ts +77 -0
- package/src/share/schemas/section-motion.ts +52 -0
- package/src/share/schemas/section-shell.ts +63 -0
- package/src/share/schemas/section-stats.ts +37 -0
- package/src/share/schemas/site-background.ts +78 -0
- package/src/share/schemas/standard-list-item.ts +38 -0
- package/src/share/scripts/external-links.ts +45 -0
- package/src/share/scripts/gsap-counter.ts +168 -0
- package/src/share/scripts/gsap-mountain-journey.ts +236 -0
- package/src/share/scripts/gsap-parallax.ts +50 -0
- package/src/share/scripts/gsap-reveal.ts +65 -0
- package/src/share/scripts/gsap-stagger.ts +54 -0
- package/src/share/scripts/index.ts +25 -0
- package/src/share/scripts/inline-number-animation.ts +120 -0
- package/src/share/scripts/lenis.ts +109 -0
- package/src/share/scripts/live-photos.ts +250 -0
- package/src/share/scripts/lordicon.ts +94 -0
- package/src/share/scripts/orchestrator.ts +138 -0
- package/src/share/scripts/scheduler.ts +53 -0
- package/src/share/scripts/video-player.ts +116 -0
- package/src/share/semantic/ai.ts +140 -0
- package/src/share/semantic/block-extraction.ts +52 -0
- package/src/share/semantic/block-extractors/index.ts +502 -0
- package/src/share/semantic/breadcrumbs.ts +120 -0
- package/src/share/semantic/build-page.ts +309 -0
- package/src/share/semantic/business-projection.ts +278 -0
- package/src/share/semantic/derived-prices-loader.ts +36 -0
- package/src/share/semantic/extract.ts +118 -0
- package/src/share/semantic/feed.ts +124 -0
- package/src/share/semantic/ids.ts +76 -0
- package/src/share/semantic/image-sitemap.ts +153 -0
- package/src/share/semantic/index.ts +36 -0
- package/src/share/semantic/jsonld/article.ts +47 -0
- package/src/share/semantic/jsonld/breadcrumb.ts +47 -0
- package/src/share/semantic/jsonld/collection-list.ts +30 -0
- package/src/share/semantic/jsonld/context.ts +46 -0
- package/src/share/semantic/jsonld/faq.ts +49 -0
- package/src/share/semantic/jsonld/initiative.ts +53 -0
- package/src/share/semantic/jsonld/organization.ts +101 -0
- package/src/share/semantic/jsonld/person.ts +71 -0
- package/src/share/semantic/jsonld/service.ts +80 -0
- package/src/share/semantic/jsonld/shared.ts +31 -0
- package/src/share/semantic/jsonld/types.ts +18 -0
- package/src/share/semantic/jsonld/webpage.ts +98 -0
- package/src/share/semantic/jsonld/website.ts +27 -0
- package/src/share/semantic/jsonld.ts +75 -0
- package/src/share/semantic/llms-policy.ts +74 -0
- package/src/share/semantic/llms.ts +394 -0
- package/src/share/semantic/markdown-hygiene.ts +68 -0
- package/src/share/semantic/markdown-twin-provenance.ts +242 -0
- package/src/share/semantic/models.ts +402 -0
- package/src/share/semantic/organization-profile.ts +160 -0
- package/src/share/semantic/output-projection.ts +131 -0
- package/src/share/semantic/page-builders/markdown-page.ts +84 -0
- package/src/share/semantic/page-markdown.ts +234 -0
- package/src/share/semantic/page-utils.ts +125 -0
- package/src/share/semantic/price-marker-resolver.ts +92 -0
- package/src/share/semantic/robots.ts +127 -0
- package/src/share/semantic/update-stamp.ts +136 -0
- package/src/share/shared-context.ts +177 -0
- package/src/share/string-utils.ts +19 -0
- package/src/share/tests/api-catalog.test.ts +97 -0
- package/src/share/tests/breadcrumbs.test.ts +126 -0
- package/src/share/tests/build-page-price-markers.test.ts +160 -0
- package/src/share/tests/capability.test.ts +107 -0
- package/src/share/tests/claim.test.ts +90 -0
- package/src/share/tests/content-ref-index.test.ts +328 -0
- package/src/share/tests/create-dev-props-validator.test.ts +38 -0
- package/src/share/tests/derivation.test.ts +39 -0
- package/src/share/tests/dev-props-validator.test.ts +88 -0
- package/src/share/tests/fleet-catalog.test.ts +134 -0
- package/src/share/tests/formula-eval.test.ts +619 -0
- package/src/share/tests/freshness.test.ts +60 -0
- package/src/share/tests/hero-section-numbering-parity.test.ts +51 -0
- package/src/share/tests/image-sitemap.test.ts +101 -0
- package/src/share/tests/jsonld-service.test.ts +282 -0
- package/src/share/tests/knowledge.test.ts +86 -0
- package/src/share/tests/ledger.test.ts +125 -0
- package/src/share/tests/llms-0789.test.ts +63 -0
- package/src/share/tests/manifest.test.ts +100 -0
- package/src/share/tests/markdown-twin-provenance.test.ts +108 -0
- package/src/share/tests/mcp-card.test.ts +57 -0
- package/src/share/tests/onboarding-yaml.test.ts +111 -0
- package/src/share/tests/ontology-role-by-cosmic-name.test.ts +28 -0
- package/src/share/tests/openapi.test.ts +116 -0
- package/src/share/tests/organization-jsonld.test.ts +74 -0
- package/src/share/tests/output-projection.test.ts +61 -0
- package/src/share/tests/plan.test.ts +97 -0
- package/src/share/tests/price-marker-resolver.test.ts +141 -0
- package/src/share/tests/proof.test.ts +72 -0
- package/src/share/tests/resolve-field-path.test.ts +52 -0
- package/src/share/tests/source.test.ts +81 -0
- package/src/share/tests/substitute-deep.test.ts +65 -0
- package/src/share/tests/text-normalize.pbt.test.ts +143 -0
- package/src/share/tests/text-normalize.test.ts +285 -0
- package/src/share/tests/twin-path.test.ts +43 -0
- package/src/share/text-normalize.ts +548 -0
- package/src/share/text-position.ts +19 -0
- package/src/share/types/hls-js-light.d.ts +16 -0
- package/src/share/visibility.ts +167 -0
- package/src/share/vitest.config.ts +8 -0
- package/src/share/wrap-inline-numbers.ts +139 -0
- package/src/surface/blueprint-schema.ts +314 -0
- package/src/surface/blueprint-types.ts +256 -0
- package/src/surface/blueprint.ts +300 -0
- package/src/surface/breaker.ts +57 -0
- package/src/surface/decision-composer.ts +156 -0
- package/src/surface/eligibility.ts +372 -0
- package/src/surface/evidence-records.ts +97 -0
- package/src/surface/fleet.ts +60 -0
- package/src/surface/geo.ts +170 -0
- package/src/surface/governance.ts +146 -0
- package/src/surface/index.ts +216 -0
- package/src/surface/io/index.ts +18 -0
- package/src/surface/io/surface-module-context-io.ts +60 -0
- package/src/surface/io/visibility-outcomes-io.ts +46 -0
- package/src/surface/module-context.ts +120 -0
- package/src/surface/substance.ts +161 -0
- package/src/surface/tests/eligibility.pbt.test.ts +137 -0
- package/src/surface/tests/eligibility.test.ts +302 -0
- package/src/surface/types.ts +289 -0
- package/src/surface/visibility.ts +57 -0
- package/src/surface/vitest.config.ts +8 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Unit tests for RFC-0570 formula evaluation module — extractNumeric, scanFormulas, resolveFormula.
|
|
4
|
+
RFC-0729: pipe syntax, formatter registry, money formatter, REF-10 error.</purpose>
|
|
5
|
+
</MODULE_CONTRACT>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect } from "vitest";
|
|
9
|
+
import {
|
|
10
|
+
extractNumeric,
|
|
11
|
+
scanFormulas,
|
|
12
|
+
resolveFormula,
|
|
13
|
+
registerPipeFormatter,
|
|
14
|
+
getPipeFormatter,
|
|
15
|
+
} from "../formula-eval.ts";
|
|
16
|
+
import type { ContentRefIndex, SourceRef } from "../content-reference.ts";
|
|
17
|
+
import { EMPTY_CONTENT_REF_INDEX } from "../content-reference.ts";
|
|
18
|
+
|
|
19
|
+
describe("extractNumeric", () => {
|
|
20
|
+
it("extracts number from string with currency suffix", () => {
|
|
21
|
+
expect(extractNumeric("200 €")).toBe(200);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("extracts number with thin space thousands separator", () => {
|
|
25
|
+
expect(extractNumeric("1\u202f040 €")).toBe(1040);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("extracts number with period thousands separator (German)", () => {
|
|
29
|
+
expect(extractNumeric("1.040 €")).toBe(1040);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("extracts number with comma decimal separator (German)", () => {
|
|
33
|
+
expect(extractNumeric("70,50 €")).toBe(70.5);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("extracts negative number", () => {
|
|
37
|
+
expect(extractNumeric("-200 €")).toBe(-200);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("extracts number with unit suffix", () => {
|
|
41
|
+
expect(extractNumeric("70 €/Monat")).toBe(70);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("extracts plain number string", () => {
|
|
45
|
+
expect(extractNumeric("1040")).toBe(1040);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("extracts number with period decimal separator", () => {
|
|
49
|
+
expect(extractNumeric("70.50")).toBe(70.5);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("extracts number with both period thousands and comma decimal (German)", () => {
|
|
53
|
+
expect(extractNumeric("1.040,50 €")).toBe(1040.5);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("returns null for non-numeric string", () => {
|
|
57
|
+
expect(extractNumeric("no number")).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("returns null for null", () => {
|
|
61
|
+
expect(extractNumeric(null)).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("returns null for undefined", () => {
|
|
65
|
+
expect(extractNumeric(undefined)).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("returns null for boolean", () => {
|
|
69
|
+
expect(extractNumeric(true)).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("returns number for number input", () => {
|
|
73
|
+
expect(extractNumeric(200)).toBe(200);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("returns null for NaN", () => {
|
|
77
|
+
expect(extractNumeric(Number.NaN)).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("returns null for empty string", () => {
|
|
81
|
+
expect(extractNumeric("")).toBeNull();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("scanFormulas", () => {
|
|
86
|
+
it("returns empty array for text without formulas", () => {
|
|
87
|
+
expect(scanFormulas("no formula here")).toEqual([]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("returns empty array for text without =( prefix", () => {
|
|
91
|
+
expect(scanFormulas("(a + b) without prefix")).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("scans simple formula", () => {
|
|
95
|
+
const result = scanFormulas("=(a + b)");
|
|
96
|
+
expect(result).toHaveLength(1);
|
|
97
|
+
expect(result[0].expression).toBe("a + b");
|
|
98
|
+
expect(result[0].start).toBe(0);
|
|
99
|
+
expect(result[0].end).toBe(8);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("scans formula with nested parentheses", () => {
|
|
103
|
+
const result = scanFormulas("=(a + (b * c))");
|
|
104
|
+
expect(result).toHaveLength(1);
|
|
105
|
+
expect(result[0].expression).toBe("a + (b * c)");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("scans multiple formulas in text", () => {
|
|
109
|
+
const result = scanFormulas("text =(a) more =(b) end");
|
|
110
|
+
expect(result).toHaveLength(2);
|
|
111
|
+
expect(result[0].expression).toBe("a");
|
|
112
|
+
expect(result[1].expression).toBe("b");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("scans formula with surrounding text", () => {
|
|
116
|
+
const result = scanFormulas("Total: =(a + b * 12) €");
|
|
117
|
+
expect(result).toHaveLength(1);
|
|
118
|
+
expect(result[0].expression).toBe("a + b * 12");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("handles unbalanced parentheses gracefully", () => {
|
|
122
|
+
const result = scanFormulas("=(a + b");
|
|
123
|
+
expect(result).toEqual([]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("fast path: returns empty array when text lacks =( prefix", () => {
|
|
127
|
+
expect(scanFormulas("just some text without any formula")).toEqual([]);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe("resolveFormula", () => {
|
|
132
|
+
const mockIndex: ContentRefIndex = {
|
|
133
|
+
version: 1,
|
|
134
|
+
generatedAt: "2026-01-01",
|
|
135
|
+
collections: ["business-profile"],
|
|
136
|
+
entries: {
|
|
137
|
+
"business-profile": {
|
|
138
|
+
"offerings/digital-foundation": {
|
|
139
|
+
de: {
|
|
140
|
+
presentation: {
|
|
141
|
+
price: {
|
|
142
|
+
setup: "200 €",
|
|
143
|
+
monthly: "70 €",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
it("resolves formula with two references and arithmetic", () => {
|
|
153
|
+
const result = resolveFormula(
|
|
154
|
+
mockIndex,
|
|
155
|
+
"business-profile.offerings/digital-foundation.presentation.price.setup + business-profile.offerings/digital-foundation.presentation.price.monthly * 12",
|
|
156
|
+
"de",
|
|
157
|
+
"de",
|
|
158
|
+
);
|
|
159
|
+
expect(result.resolved).toBe(true);
|
|
160
|
+
expect(result.value).toBe("1040");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("resolves formula with numeric literal and reference", () => {
|
|
164
|
+
const result = resolveFormula(
|
|
165
|
+
mockIndex,
|
|
166
|
+
"business-profile.offerings/digital-foundation.presentation.price.setup + 100",
|
|
167
|
+
"de",
|
|
168
|
+
"de",
|
|
169
|
+
);
|
|
170
|
+
expect(result.resolved).toBe(true);
|
|
171
|
+
expect(result.value).toBe("300");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("resolves formula with nested parentheses", () => {
|
|
175
|
+
const result = resolveFormula(
|
|
176
|
+
mockIndex,
|
|
177
|
+
"(business-profile.offerings/digital-foundation.presentation.price.setup + business-profile.offerings/digital-foundation.presentation.price.monthly) * 2",
|
|
178
|
+
"de",
|
|
179
|
+
"de",
|
|
180
|
+
);
|
|
181
|
+
expect(result.resolved).toBe(true);
|
|
182
|
+
expect(result.value).toBe("540");
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("returns REF-06 for unresolved reference", () => {
|
|
186
|
+
const result = resolveFormula(
|
|
187
|
+
mockIndex,
|
|
188
|
+
"business-profile.offerings/nonexistent.presentation.price.setup + 100",
|
|
189
|
+
"de",
|
|
190
|
+
"de",
|
|
191
|
+
);
|
|
192
|
+
expect(result.resolved).toBe(false);
|
|
193
|
+
expect(result.error).toContain("REF-06");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("returns REF-07 for non-numeric operand", () => {
|
|
197
|
+
const indexWithNonNumeric: ContentRefIndex = {
|
|
198
|
+
...mockIndex,
|
|
199
|
+
entries: {
|
|
200
|
+
"business-profile": {
|
|
201
|
+
"offerings/digital-foundation": {
|
|
202
|
+
de: {
|
|
203
|
+
presentation: {
|
|
204
|
+
price: {
|
|
205
|
+
setup: "not a number",
|
|
206
|
+
monthly: "70 €",
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
const result = resolveFormula(
|
|
215
|
+
indexWithNonNumeric,
|
|
216
|
+
"business-profile.offerings/digital-foundation.presentation.price.setup + 100",
|
|
217
|
+
"de",
|
|
218
|
+
"de",
|
|
219
|
+
);
|
|
220
|
+
expect(result.resolved).toBe(false);
|
|
221
|
+
expect(result.error).toContain("REF-07");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("returns REF-08 for syntax error", () => {
|
|
225
|
+
const result = resolveFormula(mockIndex, "200 +", "de", "de");
|
|
226
|
+
expect(result.resolved).toBe(false);
|
|
227
|
+
expect(result.error).toContain("REF-08");
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("returns REF-09 for division by zero", () => {
|
|
231
|
+
const result = resolveFormula(mockIndex, "200 / 0", "de", "de");
|
|
232
|
+
expect(result.resolved).toBe(false);
|
|
233
|
+
expect(result.error).toContain("REF-09");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("resolves formula with empty index (no refs, pure arithmetic)", () => {
|
|
237
|
+
const result = resolveFormula(EMPTY_CONTENT_REF_INDEX, "200 + 300", "de", "de");
|
|
238
|
+
expect(result.resolved).toBe(true);
|
|
239
|
+
expect(result.value).toBe("500");
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("RFC-0723: returns string value for single-ref expression with non-numeric value", () => {
|
|
243
|
+
const indexWithStringValue: ContentRefIndex = {
|
|
244
|
+
...mockIndex,
|
|
245
|
+
entries: {
|
|
246
|
+
"business-profile": {
|
|
247
|
+
"offerings/digital-foundation": {
|
|
248
|
+
de: {
|
|
249
|
+
presentation: {
|
|
250
|
+
price: {
|
|
251
|
+
setup: "200 €",
|
|
252
|
+
monthly: "70 €",
|
|
253
|
+
},
|
|
254
|
+
tagline: "Digitales Fundament",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
const result = resolveFormula(
|
|
262
|
+
indexWithStringValue,
|
|
263
|
+
"business-profile.offerings/digital-foundation.presentation.tagline",
|
|
264
|
+
"de",
|
|
265
|
+
"de",
|
|
266
|
+
);
|
|
267
|
+
expect(result.resolved).toBe(true);
|
|
268
|
+
expect(result.value).toBe("Digitales Fundament");
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("RFC-0723: returns full string value for single-ref expression with numeric value", () => {
|
|
272
|
+
const result = resolveFormula(
|
|
273
|
+
mockIndex,
|
|
274
|
+
"business-profile.offerings/digital-foundation.presentation.price.setup",
|
|
275
|
+
"de",
|
|
276
|
+
"de",
|
|
277
|
+
);
|
|
278
|
+
expect(result.resolved).toBe(true);
|
|
279
|
+
expect(result.value).toBe("200 €");
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("RFC-0723: returns REF-07 for multi-ref expression with non-numeric operand", () => {
|
|
283
|
+
const indexWithNonNumeric: ContentRefIndex = {
|
|
284
|
+
...mockIndex,
|
|
285
|
+
entries: {
|
|
286
|
+
"business-profile": {
|
|
287
|
+
"offerings/digital-foundation": {
|
|
288
|
+
de: {
|
|
289
|
+
presentation: {
|
|
290
|
+
price: {
|
|
291
|
+
setup: "not a number",
|
|
292
|
+
monthly: "70 €",
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
const result = resolveFormula(
|
|
301
|
+
indexWithNonNumeric,
|
|
302
|
+
"business-profile.offerings/digital-foundation.presentation.price.setup + business-profile.offerings/digital-foundation.presentation.price.monthly",
|
|
303
|
+
"de",
|
|
304
|
+
"de",
|
|
305
|
+
);
|
|
306
|
+
expect(result.resolved).toBe(false);
|
|
307
|
+
expect(result.error).toContain("REF-07");
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
describe("RFC-0729: pipe syntax", () => {
|
|
312
|
+
const mockIndex: ContentRefIndex = {
|
|
313
|
+
version: 1,
|
|
314
|
+
generatedAt: "2026-01-01",
|
|
315
|
+
collections: ["business-profile"],
|
|
316
|
+
entries: {
|
|
317
|
+
"business-profile": {
|
|
318
|
+
"offerings/digital-foundation": {
|
|
319
|
+
de: {
|
|
320
|
+
presentation: {
|
|
321
|
+
price: {
|
|
322
|
+
setup: "200 €",
|
|
323
|
+
monthly: "70 €",
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
it("formats with money formatter in German locale", () => {
|
|
333
|
+
const result = resolveFormula(
|
|
334
|
+
mockIndex,
|
|
335
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | money currency=EUR locale=de",
|
|
336
|
+
"de",
|
|
337
|
+
"de",
|
|
338
|
+
);
|
|
339
|
+
expect(result.resolved).toBe(true);
|
|
340
|
+
expect(result.value).toBe("70\u00A0€");
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it("formats with money formatter in Ukrainian locale", () => {
|
|
344
|
+
const indexWithUk: ContentRefIndex = {
|
|
345
|
+
...mockIndex,
|
|
346
|
+
entries: {
|
|
347
|
+
"business-profile": {
|
|
348
|
+
"offerings/digital-foundation": {
|
|
349
|
+
de: {
|
|
350
|
+
presentation: {
|
|
351
|
+
price: { setup: "200 €", monthly: "70 €" },
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
uk: {
|
|
355
|
+
presentation: {
|
|
356
|
+
price: { setup: "200 €", monthly: "70 €" },
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
const result = resolveFormula(
|
|
364
|
+
indexWithUk,
|
|
365
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | money currency=EUR locale=uk",
|
|
366
|
+
"uk",
|
|
367
|
+
"uk",
|
|
368
|
+
);
|
|
369
|
+
expect(result.resolved).toBe(true);
|
|
370
|
+
expect(result.value).toBe("70\u00A0€");
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it("formats with currency conversion to UAH in German locale", () => {
|
|
374
|
+
const result = resolveFormula(
|
|
375
|
+
mockIndex,
|
|
376
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | money currency=EUR locale=de targetCurrency=UAH rate=45",
|
|
377
|
+
"de",
|
|
378
|
+
"de",
|
|
379
|
+
);
|
|
380
|
+
expect(result.resolved).toBe(true);
|
|
381
|
+
expect(result.value).toBe("3.150\u00A0₴");
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it("formats arithmetic result with pipe", () => {
|
|
385
|
+
const result = resolveFormula(
|
|
386
|
+
mockIndex,
|
|
387
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly * 12 | money currency=EUR locale=de",
|
|
388
|
+
"de",
|
|
389
|
+
"de",
|
|
390
|
+
);
|
|
391
|
+
expect(result.resolved).toBe(true);
|
|
392
|
+
expect(result.value).toBe("840\u00A0€");
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it("preserves existing behavior for expressions without pipe", () => {
|
|
396
|
+
const result = resolveFormula(
|
|
397
|
+
mockIndex,
|
|
398
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly * 12",
|
|
399
|
+
"de",
|
|
400
|
+
"de",
|
|
401
|
+
);
|
|
402
|
+
expect(result.resolved).toBe(true);
|
|
403
|
+
expect(result.value).toBe("840");
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("preserves RFC-0723 single-ref string return without pipe", () => {
|
|
407
|
+
const indexWithString: ContentRefIndex = {
|
|
408
|
+
...mockIndex,
|
|
409
|
+
entries: {
|
|
410
|
+
"business-profile": {
|
|
411
|
+
"offerings/digital-foundation": {
|
|
412
|
+
de: {
|
|
413
|
+
presentation: {
|
|
414
|
+
price: {
|
|
415
|
+
setup: "200 €",
|
|
416
|
+
monthly: "70 €",
|
|
417
|
+
},
|
|
418
|
+
tagline: "Digitales Fundament",
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
const result = resolveFormula(
|
|
426
|
+
indexWithString,
|
|
427
|
+
"business-profile.offerings/digital-foundation.presentation.tagline",
|
|
428
|
+
"de",
|
|
429
|
+
"de",
|
|
430
|
+
);
|
|
431
|
+
expect(result.resolved).toBe(true);
|
|
432
|
+
expect(result.value).toBe("Digitales Fundament");
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it("uses context.lang as default locale when no locale param", () => {
|
|
436
|
+
const result = resolveFormula(
|
|
437
|
+
mockIndex,
|
|
438
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | money currency=EUR",
|
|
439
|
+
"de",
|
|
440
|
+
"de",
|
|
441
|
+
);
|
|
442
|
+
expect(result.resolved).toBe(true);
|
|
443
|
+
expect(result.value).toBe("70\u00A0€");
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
describe("RFC-0729: formatter registry", () => {
|
|
448
|
+
it("registers and retrieves a custom formatter", () => {
|
|
449
|
+
const customFn = (_value: number, _params: Record<string, string>) => "custom";
|
|
450
|
+
registerPipeFormatter("custom-test", customFn);
|
|
451
|
+
expect(getPipeFormatter("custom-test")).toBe(customFn);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it("returns undefined for unregistered formatter", () => {
|
|
455
|
+
expect(getPipeFormatter("nonexistent-formatter")).toBeUndefined();
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it("money formatter is registered by default", () => {
|
|
459
|
+
expect(getPipeFormatter("money")).toBeDefined();
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
describe("RFC-0729: REF-10 unknown formatter", () => {
|
|
464
|
+
const mockIndex: ContentRefIndex = {
|
|
465
|
+
version: 1,
|
|
466
|
+
generatedAt: "2026-01-01",
|
|
467
|
+
collections: ["business-profile"],
|
|
468
|
+
entries: {
|
|
469
|
+
"business-profile": {
|
|
470
|
+
"offerings/digital-foundation": {
|
|
471
|
+
de: {
|
|
472
|
+
presentation: {
|
|
473
|
+
price: {
|
|
474
|
+
setup: "200 €",
|
|
475
|
+
monthly: "70 €",
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
it("returns REF-10 for unknown formatter name", () => {
|
|
485
|
+
const result = resolveFormula(
|
|
486
|
+
mockIndex,
|
|
487
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | unknownFormatter",
|
|
488
|
+
"de",
|
|
489
|
+
"de",
|
|
490
|
+
);
|
|
491
|
+
expect(result.resolved).toBe(false);
|
|
492
|
+
expect(result.error).toContain("REF-10");
|
|
493
|
+
expect(result.error).toContain("unknownFormatter");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("returns REF-10 for empty formatter name", () => {
|
|
497
|
+
const result = resolveFormula(
|
|
498
|
+
mockIndex,
|
|
499
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly |",
|
|
500
|
+
"de",
|
|
501
|
+
"de",
|
|
502
|
+
);
|
|
503
|
+
expect(result.resolved).toBe(false);
|
|
504
|
+
expect(result.error).toContain("REF-10");
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
describe("RFC-0729: invalid rate param", () => {
|
|
509
|
+
const mockIndex: ContentRefIndex = {
|
|
510
|
+
version: 1,
|
|
511
|
+
generatedAt: "2026-01-01",
|
|
512
|
+
collections: ["business-profile"],
|
|
513
|
+
entries: {
|
|
514
|
+
"business-profile": {
|
|
515
|
+
"offerings/digital-foundation": {
|
|
516
|
+
de: {
|
|
517
|
+
presentation: {
|
|
518
|
+
price: {
|
|
519
|
+
setup: "200 €",
|
|
520
|
+
monthly: "70 €",
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
it("ignores conversion when rate is non-numeric", () => {
|
|
530
|
+
const result = resolveFormula(
|
|
531
|
+
mockIndex,
|
|
532
|
+
"business-profile.offerings/digital-foundation.presentation.price.monthly | money currency=EUR locale=de targetCurrency=UAH rate=abc",
|
|
533
|
+
"de",
|
|
534
|
+
"de",
|
|
535
|
+
);
|
|
536
|
+
expect(result.resolved).toBe(true);
|
|
537
|
+
expect(result.value).toBe("70\u00A0€");
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
describe("RFC-0731: this. self-reference in formulas", () => {
|
|
542
|
+
const mockIndex: ContentRefIndex = {
|
|
543
|
+
version: 1,
|
|
544
|
+
generatedAt: "2026-01-01",
|
|
545
|
+
collections: ["business-profile"],
|
|
546
|
+
entries: {
|
|
547
|
+
"business-profile": {
|
|
548
|
+
"offerings/digital-foundation": {
|
|
549
|
+
de: {
|
|
550
|
+
pricing: {
|
|
551
|
+
charges: {
|
|
552
|
+
monthlySubscription: { amount: { value: "70.00" } },
|
|
553
|
+
setup: { amount: { value: "200.00" } },
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
presentation: {
|
|
557
|
+
price: {
|
|
558
|
+
setup: "200 €",
|
|
559
|
+
monthly: "70 €",
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
const sourceRef: SourceRef = {
|
|
569
|
+
collection: "business-profile",
|
|
570
|
+
file: "offerings/digital-foundation",
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
it("resolves this. in arithmetic formula expression", () => {
|
|
574
|
+
const result = resolveFormula(
|
|
575
|
+
mockIndex,
|
|
576
|
+
"this.pricing.charges.monthlySubscription.amount.value + this.pricing.charges.setup.amount.value",
|
|
577
|
+
"de",
|
|
578
|
+
"de",
|
|
579
|
+
sourceRef,
|
|
580
|
+
);
|
|
581
|
+
expect(result.resolved).toBe(true);
|
|
582
|
+
expect(result.value).toBe("270");
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
it("resolves this. as single-ref string interpolation =(this.field)", () => {
|
|
586
|
+
const result = resolveFormula(
|
|
587
|
+
mockIndex,
|
|
588
|
+
"this.presentation.price.monthly",
|
|
589
|
+
"de",
|
|
590
|
+
"de",
|
|
591
|
+
sourceRef,
|
|
592
|
+
);
|
|
593
|
+
expect(result.resolved).toBe(true);
|
|
594
|
+
expect(result.value).toBe("70 €");
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it("resolves this. with pipe formatter =(this.field | money)", () => {
|
|
598
|
+
const result = resolveFormula(
|
|
599
|
+
mockIndex,
|
|
600
|
+
"this.pricing.charges.monthlySubscription.amount.value | money currency=EUR locale=de",
|
|
601
|
+
"de",
|
|
602
|
+
"de",
|
|
603
|
+
sourceRef,
|
|
604
|
+
);
|
|
605
|
+
expect(result.resolved).toBe(true);
|
|
606
|
+
expect(result.value).toContain("70");
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it("returns REF-12 when this. is used without sourceRef", () => {
|
|
610
|
+
const result = resolveFormula(
|
|
611
|
+
mockIndex,
|
|
612
|
+
"this.pricing.charges.monthlySubscription.amount.value",
|
|
613
|
+
"de",
|
|
614
|
+
"de",
|
|
615
|
+
);
|
|
616
|
+
expect(result.resolved).toBe(false);
|
|
617
|
+
expect(result.error).toContain("REF-12");
|
|
618
|
+
});
|
|
619
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-0213: tests for the freshness state model + ISO duration arithmetic.</purpose>
|
|
4
|
+
<keywords>RFC-0213, CKL, freshness, test</keywords>
|
|
5
|
+
</MODULE_CONTRACT>
|
|
6
|
+
<MODULE_MAP><entry key="tests">addDuration + evaluateFreshness state transitions.</entry></MODULE_MAP>
|
|
7
|
+
<CHANGE_SUMMARY><item>RFC-0213: initial freshness tests.</item></CHANGE_SUMMARY>
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { test, expect } from "vitest";
|
|
11
|
+
import { addDuration, evaluateFreshness } from "../knowledge/freshness.ts";
|
|
12
|
+
|
|
13
|
+
test("addDuration: months and years are calendar-correct", () => {
|
|
14
|
+
expect(addDuration("2026-01-15", "P1Y")).toBe("2027-01-15");
|
|
15
|
+
expect(addDuration("2026-06-01", "P3M")).toBe("2026-09-01");
|
|
16
|
+
expect(addDuration("2026-06-20", "P2W")).toBe("2026-07-04");
|
|
17
|
+
expect(addDuration("2026-12-20", "P1M")).toBe("2027-01-20");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("addDuration: rejects malformed / empty durations", () => {
|
|
21
|
+
expect(addDuration("2026-06-20", "P")).toBe(null);
|
|
22
|
+
expect(addDuration("2026-06-20", "PT")).toBe(null);
|
|
23
|
+
expect(addDuration("not-a-date", "P1Y")).toBe(null);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("evaluateFreshness: fresh when no window pressure", () => {
|
|
27
|
+
const e = evaluateFreshness({ asOf: "2026-06-01", validUntil: "2027-06-01" }, "2026-06-20");
|
|
28
|
+
expect(e.state).toBe("fresh");
|
|
29
|
+
expect(e.daysToExpiry! > 300).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("evaluateFreshness: expiring-soon within the window", () => {
|
|
33
|
+
const e = evaluateFreshness({ asOf: "2026-01-01", validUntil: "2026-07-10" }, "2026-06-20", 30);
|
|
34
|
+
expect(e.state).toBe("expiring-soon");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("evaluateFreshness: expired past validUntil", () => {
|
|
38
|
+
const e = evaluateFreshness({ asOf: "2025-01-01", validUntil: "2026-06-01" }, "2026-06-20");
|
|
39
|
+
expect(e.state).toBe("expired");
|
|
40
|
+
expect(e.daysToExpiry! < 0).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("evaluateFreshness: review-due when cadence lapsed and no expiry pressure", () => {
|
|
44
|
+
const e = evaluateFreshness({ asOf: "2025-01-01", reviewEvery: "P1Y" }, "2026-06-20");
|
|
45
|
+
expect(e.state).toBe("review-due");
|
|
46
|
+
expect(e.reviewDueAt).toBe("2026-01-01");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("evaluateFreshness: expiry takes precedence over review-due", () => {
|
|
50
|
+
const e = evaluateFreshness(
|
|
51
|
+
{ asOf: "2025-01-01", validUntil: "2026-06-01", reviewEvery: "P1M" },
|
|
52
|
+
"2026-06-20",
|
|
53
|
+
);
|
|
54
|
+
expect(e.state).toBe("expired");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("evaluateFreshness: no validUntil and no reviewEvery is always fresh", () => {
|
|
58
|
+
const e = evaluateFreshness({ asOf: "2020-01-01" }, "2026-06-20");
|
|
59
|
+
expect(e.state).toBe("fresh");
|
|
60
|
+
});
|