@40rty/ams-sdk 0.1.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/dist/index.js +11918 -0
- package/dist/types/ecommerce/src/attribute-buckets.d.ts +79 -0
- package/dist/types/ecommerce/src/base-attributes.d.ts +42 -0
- package/dist/types/ecommerce/src/bucket-labels.d.ts +37 -0
- package/dist/types/ecommerce/src/cart-line-selections.d.ts +24 -0
- package/dist/types/ecommerce/src/commerce-schemas.d.ts +1813 -0
- package/dist/types/ecommerce/src/format-variant-value.d.ts +1 -0
- package/dist/types/ecommerce/src/index.d.ts +13 -0
- package/dist/types/ecommerce/src/locale.d.ts +31 -0
- package/dist/types/ecommerce/src/optimistic-cart-line.d.ts +38 -0
- package/dist/types/ecommerce/src/pdp-companions.d.ts +21 -0
- package/dist/types/ecommerce/src/pick-product-card-action.d.ts +38 -0
- package/dist/types/ecommerce/src/product-lookup.d.ts +34 -0
- package/dist/types/ecommerce/src/projection-spec.d.ts +38 -0
- package/dist/types/ecommerce/src/review-schemas.d.ts +425 -0
- package/dist/types/sdk/src/analytics/consent.d.ts +52 -0
- package/dist/types/sdk/src/analytics/drops.d.ts +98 -0
- package/dist/types/sdk/src/analytics/emitting-scope.d.ts +2 -0
- package/dist/types/sdk/src/analytics/index.d.ts +12 -0
- package/dist/types/sdk/src/analytics/inert-scope.d.ts +2 -0
- package/dist/types/sdk/src/analytics/notify.d.ts +41 -0
- package/dist/types/sdk/src/analytics/outbox.d.ts +118 -0
- package/dist/types/sdk/src/analytics/scope-context.d.ts +24 -0
- package/dist/types/sdk/src/analytics/scope.d.ts +149 -0
- package/dist/types/sdk/src/analytics/surface.d.ts +77 -0
- package/dist/types/sdk/src/analytics/transport.d.ts +91 -0
- package/dist/types/sdk/src/animation/index.d.ts +2 -0
- package/dist/types/sdk/src/animation/useListTransition.d.ts +16 -0
- package/dist/types/sdk/src/animation/useUpdateTransition.d.ts +16 -0
- package/dist/types/sdk/src/canvas/ElementIdContext.d.ts +13 -0
- package/dist/types/sdk/src/canvas/GenerationStyleContext.d.ts +13 -0
- package/dist/types/sdk/src/canvas/ShimmerSweep.d.ts +18 -0
- package/dist/types/sdk/src/canvas/TransitionContext.d.ts +52 -0
- package/dist/types/sdk/src/canvas/canvas-arrangement.d.ts +20 -0
- package/dist/types/sdk/src/canvas/canvas-motion-style.d.ts +18 -0
- package/dist/types/sdk/src/canvas/canvas-outlet.d.ts +14 -0
- package/dist/types/sdk/src/canvas/canvas-tail.d.ts +31 -0
- package/dist/types/sdk/src/canvas/dom-targets.d.ts +140 -0
- package/dist/types/sdk/src/canvas/generation-entrance.d.ts +26 -0
- package/dist/types/sdk/src/canvas/generation-style.d.ts +62 -0
- package/dist/types/sdk/src/canvas/index.d.ts +21 -0
- package/dist/types/sdk/src/canvas/item-motion/ItemTransitionGroup.d.ts +72 -0
- package/dist/types/sdk/src/canvas/item-motion/classify-items.d.ts +24 -0
- package/dist/types/sdk/src/canvas/item-motion/index.d.ts +5 -0
- package/dist/types/sdk/src/canvas/item-motion/plugins/wipe.d.ts +11 -0
- package/dist/types/sdk/src/canvas/item-motion/profile.d.ts +77 -0
- package/dist/types/sdk/src/canvas/item-motion/wipe.d.ts +57 -0
- package/dist/types/sdk/src/canvas/nav-direction.d.ts +22 -0
- package/dist/types/sdk/src/canvas/runtime-context.d.ts +15 -0
- package/dist/types/sdk/src/canvas/runtime-hooks.d.ts +106 -0
- package/dist/types/sdk/src/canvas/runtime-types.d.ts +183 -0
- package/dist/types/sdk/src/canvas/scroll-event-target.d.ts +21 -0
- package/dist/types/sdk/src/canvas/turn-change-anchor.d.ts +34 -0
- package/dist/types/sdk/src/canvas/turn-edit.d.ts +8 -0
- package/dist/types/sdk/src/canvas/use-canvas-actions.d.ts +41 -0
- package/dist/types/sdk/src/canvas/use-fourty-layout.d.ts +19 -0
- package/dist/types/sdk/src/catalog/CatalogContext.d.ts +7 -0
- package/dist/types/sdk/src/catalog/DebugContext.d.ts +5 -0
- package/dist/types/sdk/src/catalog/HydrationStateContext.d.ts +45 -0
- package/dist/types/sdk/src/catalog/HydratorContext.d.ts +7 -0
- package/dist/types/sdk/src/catalog/component-library.d.ts +32 -0
- package/dist/types/sdk/src/catalog/define.d.ts +149 -0
- package/dist/types/sdk/src/catalog/hydrator-registry.d.ts +91 -0
- package/dist/types/sdk/src/catalog/index.d.ts +14 -0
- package/dist/types/sdk/src/catalog/interaction-contract.d.ts +78 -0
- package/dist/types/sdk/src/catalog/normalize-components.d.ts +17 -0
- package/dist/types/sdk/src/catalog/prose-value.d.ts +22 -0
- package/dist/types/sdk/src/catalog/registration/index.d.ts +4 -0
- package/dist/types/sdk/src/catalog/registration/register-component.d.ts +35 -0
- package/dist/types/sdk/src/catalog/registration/registry.d.ts +27 -0
- package/dist/types/sdk/src/catalog/registration/types.d.ts +83 -0
- package/dist/types/sdk/src/catalog/registry.d.ts +22 -0
- package/dist/types/sdk/src/catalog/render-inline.d.ts +39 -0
- package/dist/types/sdk/src/catalog/resolve-hydrators.d.ts +27 -0
- package/dist/types/sdk/src/chat/chat-context.d.ts +40 -0
- package/dist/types/sdk/src/chat/index.d.ts +1 -0
- package/dist/types/sdk/src/client-state/index.d.ts +2 -0
- package/dist/types/sdk/src/client-state/server-store.d.ts +38 -0
- package/dist/types/sdk/src/client-state/store.d.ts +20 -0
- package/dist/types/sdk/src/commerce/commerce-context.d.ts +62 -0
- package/dist/types/sdk/src/commerce/commerce-shapes.d.ts +170 -0
- package/dist/types/sdk/src/commerce/ecommerce/agentic-overlay.d.ts +27 -0
- package/dist/types/sdk/src/commerce/ecommerce/buy-now-exit.d.ts +36 -0
- package/dist/types/sdk/src/commerce/ecommerce/cart-action-failures.d.ts +54 -0
- package/dist/types/sdk/src/commerce/ecommerce/cart-drawer-store.d.ts +18 -0
- package/dist/types/sdk/src/commerce/ecommerce/checkout-handoff-reasons.d.ts +54 -0
- package/dist/types/sdk/src/commerce/ecommerce/checkout-handoff-shape.d.ts +73 -0
- package/dist/types/sdk/src/commerce/ecommerce/checkout-handoff-store.d.ts +39 -0
- package/dist/types/sdk/src/commerce/ecommerce/comparison-rows.d.ts +30 -0
- package/dist/types/sdk/src/commerce/ecommerce/index.d.ts +21 -0
- package/dist/types/sdk/src/commerce/ecommerce/normalize-collection.d.ts +17 -0
- package/dist/types/sdk/src/commerce/ecommerce/preselect-from-facts.d.ts +25 -0
- package/dist/types/sdk/src/commerce/ecommerce/product-filters.d.ts +40 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-buy-now.d.ts +33 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-cart-drawer.d.ts +35 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-cart-line-row.d.ts +30 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-comparison-table.d.ts +22 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-look-card.d.ts +80 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-product-card.d.ts +62 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-product-carousel-scroll.d.ts +13 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-product-detail.d.ts +48 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-product-grid-filter.d.ts +17 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-selected-variants-state.d.ts +8 -0
- package/dist/types/sdk/src/commerce/ecommerce/use-wishlist-drawer.d.ts +34 -0
- package/dist/types/sdk/src/commerce/ecommerce/variant-option-axes.d.ts +56 -0
- package/dist/types/sdk/src/commerce/ecommerce/variant-resolution.d.ts +83 -0
- package/dist/types/sdk/src/commerce/ecommerce/variant-selection.d.ts +22 -0
- package/dist/types/sdk/src/commerce/external-navigation.d.ts +41 -0
- package/dist/types/sdk/src/commerce/index.d.ts +9 -0
- package/dist/types/sdk/src/commerce/option-selection-store.d.ts +8 -0
- package/dist/types/sdk/src/commerce/pending-variant-choice-store.d.ts +20 -0
- package/dist/types/sdk/src/commerce/variant-selection-store.d.ts +7 -0
- package/dist/types/sdk/src/content/index.d.ts +2 -0
- package/dist/types/sdk/src/content/use-faq-accordion.d.ts +11 -0
- package/dist/types/sdk/src/content/use-newsletter-form.d.ts +16 -0
- package/dist/types/sdk/src/host/Spacefront.d.ts +11 -0
- package/dist/types/sdk/src/host/engine-loader.d.ts +14 -0
- package/dist/types/sdk/src/host/host-modules.d.ts +5833 -0
- package/dist/types/sdk/src/host/index.d.ts +4 -0
- package/dist/types/sdk/src/host/types.d.ts +52 -0
- package/dist/types/sdk/src/index.d.ts +21 -0
- package/dist/types/sdk/src/interaction/haptics.d.ts +8 -0
- package/dist/types/sdk/src/interaction/index.d.ts +3 -0
- package/dist/types/sdk/src/interaction/normalize-signals.d.ts +8 -0
- package/dist/types/sdk/src/interaction/withInteractionTracking.d.ts +48 -0
- package/dist/types/sdk/src/npm.d.ts +3 -0
- package/dist/types/sdk/src/projection/ProjectionSignalBridge.d.ts +5 -0
- package/dist/types/sdk/src/projection/index.d.ts +1 -0
- package/dist/types/sdk/src/projection/preferences.d.ts +12 -0
- package/dist/types/sdk/src/projection/transform.d.ts +7 -0
- package/dist/types/sdk/src/provider/AgentAsk.d.ts +16 -0
- package/dist/types/sdk/src/provider/index.d.ts +4 -0
- package/dist/types/sdk/src/provider/providers/handler-registry.d.ts +11 -0
- package/dist/types/sdk/src/provider/use-clamp-toggle.d.ts +22 -0
- package/dist/types/sdk/src/provider/use-timed-flag.d.ts +16 -0
- package/dist/types/sdk/src/rendering/index.d.ts +1 -0
- package/dist/types/sdk/src/rendering/post-hydration.d.ts +37 -0
- package/dist/types/sdk/src/session/FourtySessionContext.d.ts +228 -0
- package/dist/types/sdk/src/session/clear-registry.d.ts +6 -0
- package/dist/types/sdk/src/session/index.d.ts +4 -0
- package/dist/types/sdk/src/session/use-action.d.ts +25 -0
- package/dist/types/sdk/src/session/visitor-locale.d.ts +2 -0
- package/dist/types/sdk/src/shared/index.d.ts +2 -0
- package/dist/types/sdk/src/shared/use-expandable.d.ts +9 -0
- package/dist/types/sdk/src/shared/use-image-hover.d.ts +13 -0
- package/dist/types/sdk/src/shell/ScrollContainerContext.d.ts +25 -0
- package/dist/types/sdk/src/shell/ShellRegistry.d.ts +25 -0
- package/dist/types/sdk/src/shell/ShellRootContext.d.ts +15 -0
- package/dist/types/sdk/src/shell/dock-persistence.d.ts +49 -0
- package/dist/types/sdk/src/shell/exclusive-overlay.d.ts +16 -0
- package/dist/types/sdk/src/shell/index.d.ts +12 -0
- package/dist/types/sdk/src/shell/thread-scroll/ThreadHeadroom.d.ts +11 -0
- package/dist/types/sdk/src/shell/thread-scroll/headroom.d.ts +4 -0
- package/dist/types/sdk/src/shell/thread-scroll/index.d.ts +6 -0
- package/dist/types/sdk/src/shell/thread-scroll/pin-turn-head.d.ts +12 -0
- package/dist/types/sdk/src/shell/thread-scroll/settle-thread-row.d.ts +23 -0
- package/dist/types/sdk/src/shell/thread-scroll/thread-geometry.d.ts +27 -0
- package/dist/types/sdk/src/shell/thread-scroll/thread-row-attr.d.ts +4 -0
- package/dist/types/sdk/src/shell/thread-scroll/use-pin-turn-to-top.d.ts +22 -0
- package/dist/types/sdk/src/shell/thread-scroll/use-scroll-has-more-below.d.ts +19 -0
- package/dist/types/sdk/src/shell/thread-scroll/use-thread-jump-marks.d.ts +28 -0
- package/dist/types/sdk/src/shell/thread-scroll/use-thread-landing.d.ts +1 -0
- package/dist/types/sdk/src/shell/use-composer-chip-select.d.ts +21 -0
- package/dist/types/sdk/src/shell/use-go-home.d.ts +11 -0
- package/dist/types/sdk/src/shell/use-hydrated.d.ts +19 -0
- package/dist/types/sdk/src/shell/use-menu-item-select.d.ts +13 -0
- package/dist/types/sdk/src/shell/use-overridable-toggle.d.ts +24 -0
- package/dist/types/sdk/src/shell/use-thread-rows.d.ts +41 -0
- package/dist/types/sdk/src/social/index.d.ts +2 -0
- package/dist/types/sdk/src/social/use-review-helpful.d.ts +10 -0
- package/dist/types/sdk/src/social/use-testimonials-carousel.d.ts +15 -0
- package/dist/types/sdk/src/utils/core-utils/format-distance.d.ts +6 -0
- package/dist/types/sdk/src/utils/core-utils/format-price.d.ts +7 -0
- package/dist/types/sdk/src/utils/core-utils/index.d.ts +10 -0
- package/dist/types/sdk/src/utils/core-utils/inject-google-fonts.d.ts +17 -0
- package/dist/types/sdk/src/utils/core-utils/is-on-sale.d.ts +6 -0
- package/dist/types/sdk/src/utils/core-utils/is-video-url.d.ts +6 -0
- package/dist/types/sdk/src/utils/core-utils/maps-directions-url.d.ts +5 -0
- package/dist/types/sdk/src/utils/core-utils/mint-id.d.ts +10 -0
- package/dist/types/sdk/src/utils/core-utils/resolve-swatch-color.d.ts +2 -0
- package/dist/types/sdk/src/utils/core-utils/validate-all.d.ts +13 -0
- package/dist/types/sdk/src/utils/index.d.ts +10 -0
- package/dist/types/sdk/src/utils/storage.d.ts +9 -0
- package/dist/types/sdk/src/utils/use-document-visible.d.ts +9 -0
- package/dist/types/sdk/src/utils/use-form-factor.d.ts +24 -0
- package/dist/types/sdk/src/utils/use-inline-completion.d.ts +48 -0
- package/dist/types/sdk/src/utils/use-interval.d.ts +7 -0
- package/dist/types/sdk/src/utils/use-success-flash.d.ts +35 -0
- package/dist/types/sdk/src/utils/use-wake-lock.d.ts +15 -0
- package/dist/types/sdk/src/utils/viewport-window.d.ts +39 -0
- package/dist/types/sdk/src/voice/index.d.ts +2 -0
- package/dist/types/sdk/src/voice/use-dictation.d.ts +80 -0
- package/dist/types/sdk/src/voice/use-voice-capture.d.ts +65 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/fact-form-registry.d.ts +43 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/fact-shape.d.ts +70 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/form-registry.d.ts +28 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/knowledge.d.ts +18 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/presence-restore.d.ts +13 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/presence-stream.d.ts +64 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/source-form-registry.d.ts +129 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/standing-signal-store.d.ts +19 -0
- package/dist/types/sdk/src/widgets/presence/flows/flow-store.d.ts +22 -0
- package/dist/types/sdk/src/widgets/presence/index.d.ts +17 -0
- package/dist/types/sdk/src/widgets/presence/runtime-context.d.ts +109 -0
- package/dist/types/sdk/src/widgets/presence/use-layout-entity-ids.d.ts +12 -0
- package/dist/types/sdk/src/widgets/presence/use-optimistic-facts.d.ts +43 -0
- package/dist/types/sdk/src/widgets/presence/use-optimistic-flow-set.d.ts +24 -0
- package/dist/types/sdk/src/widgets/presence/use-presence-notch.d.ts +75 -0
- package/dist/types/sdk/src/widgets/presence/use-presence.d.ts +45 -0
- package/dist/types/sdk/src/widgets/presence/use-standing-signal.d.ts +12 -0
- package/dist/types/spacestation/src/analytics/catalog.d.ts +89 -0
- package/dist/types/spacestation/src/analytics/ecommerce/events.d.ts +183 -0
- package/dist/types/spacestation/src/analytics/ecommerce/funnel.d.ts +22 -0
- package/dist/types/spacestation/src/analytics/ecommerce/index.d.ts +14 -0
- package/dist/types/spacestation/src/analytics/ecommerce/surfacing.d.ts +42 -0
- package/dist/types/spacestation/src/analytics/envelope.d.ts +222 -0
- package/dist/types/spacestation/src/analytics/index.d.ts +28 -0
- package/dist/types/spacestation/src/analytics/kind.d.ts +155 -0
- package/dist/types/spacestation/src/analytics/session.d.ts +35 -0
- package/dist/types/spacestation/src/attachment/attachment.d.ts +83 -0
- package/dist/types/spacestation/src/catalog/attribute-registry.d.ts +148 -0
- package/dist/types/spacestation/src/catalog/attribute-scope.d.ts +41 -0
- package/dist/types/spacestation/src/catalog/canvas-arrangement.d.ts +43 -0
- package/dist/types/spacestation/src/catalog/catalog-schemas.d.ts +264 -0
- package/dist/types/spacestation/src/catalog/config.d.ts +13 -0
- package/dist/types/spacestation/src/catalog/derive-props-doc.d.ts +11 -0
- package/dist/types/spacestation/src/catalog/element-filled.d.ts +77 -0
- package/dist/types/spacestation/src/catalog/entity-refs.d.ts +14 -0
- package/dist/types/spacestation/src/catalog/function-props.d.ts +23 -0
- package/dist/types/spacestation/src/catalog/hydration-paths.d.ts +19 -0
- package/dist/types/spacestation/src/catalog/prose.d.ts +60 -0
- package/dist/types/spacestation/src/catalog/ref-sites.d.ts +45 -0
- package/dist/types/spacestation/src/catalog/required-props.d.ts +31 -0
- package/dist/types/spacestation/src/catalog/resolved.d.ts +145 -0
- package/dist/types/spacestation/src/catalog/structural-baseline.d.ts +7 -0
- package/dist/types/spacestation/src/catalog/wire/catalog-wire.d.ts +191 -0
- package/dist/types/spacestation/src/catalog/wire/index.d.ts +5 -0
- package/dist/types/spacestation/src/catalog/wire/package-release.d.ts +351 -0
- package/dist/types/spacestation/src/catalog/wire/schema-from-wire.d.ts +7 -0
- package/dist/types/spacestation/src/catalog/wire/schema-to-wire.d.ts +8 -0
- package/dist/types/spacestation/src/catalog/wire/wire-schema.d.ts +78 -0
- package/dist/types/spacestation/src/commerce/cart-add-signal.d.ts +125 -0
- package/dist/types/spacestation/src/commerce/cart-state.d.ts +87 -0
- package/dist/types/spacestation/src/commerce/cart-verb-signals.d.ts +80 -0
- package/dist/types/spacestation/src/commerce/page-kinds.d.ts +40 -0
- package/dist/types/spacestation/src/commerce/selection-signal.d.ts +25 -0
- package/dist/types/spacestation/src/contracts/entry-context.d.ts +35 -0
- package/dist/types/spacestation/src/contracts/knowledge/index.d.ts +12 -0
- package/dist/types/spacestation/src/contracts/knowledge/types.d.ts +238 -0
- package/dist/types/spacestation/src/contracts/retrieval/core/knowledge-source.d.ts +36 -0
- package/dist/types/spacestation/src/contracts/retrieval/core/platform-connector.d.ts +49 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/articles/source.d.ts +3 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/articles/types.d.ts +29 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/client.d.ts +238 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/collections/source.d.ts +3 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/collections/types.d.ts +23 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/connector.d.ts +11 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/domains.d.ts +27 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/faq/source.d.ts +3 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/faq/types.d.ts +21 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/option-values.d.ts +71 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/policies/source.d.ts +3 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/policies/types.d.ts +18 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/products/source.d.ts +5 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/products/types.d.ts +47 -0
- package/dist/types/spacestation/src/contracts/retrieval/index.d.ts +25 -0
- package/dist/types/spacestation/src/contracts/session-arrival-params.d.ts +32 -0
- package/dist/types/spacestation/src/contracts/session-arrival.d.ts +215 -0
- package/dist/types/spacestation/src/contracts/tools/definitions.d.ts +139 -0
- package/dist/types/spacestation/src/contracts/tools/execution-context.d.ts +135 -0
- package/dist/types/spacestation/src/contracts/tools/index.d.ts +9 -0
- package/dist/types/spacestation/src/contracts/tools/types.d.ts +163 -0
- package/dist/types/spacestation/src/focus/focus.d.ts +12 -0
- package/dist/types/spacestation/src/hydration/hydration.d.ts +46 -0
- package/dist/types/spacestation/src/index.d.ts +71 -0
- package/dist/types/spacestation/src/layout/apply-patch.d.ts +17 -0
- package/dist/types/spacestation/src/layout/conversation.d.ts +136 -0
- package/dist/types/spacestation/src/layout/layout-diff.d.ts +17 -0
- package/dist/types/spacestation/src/layout/layout.d.ts +275 -0
- package/dist/types/spacestation/src/layout/page.d.ts +244 -0
- package/dist/types/spacestation/src/layout/patch.d.ts +92 -0
- package/dist/types/spacestation/src/layout/reduce-patch.d.ts +19 -0
- package/dist/types/spacestation/src/layout/reserved-ids.d.ts +13 -0
- package/dist/types/spacestation/src/projection/projection.d.ts +249 -0
- package/dist/types/spacestation/src/shell/shell.d.ts +109 -0
- package/dist/types/spacestation/src/signal/agent-signals.d.ts +539 -0
- package/dist/types/spacestation/src/space/connector.d.ts +61 -0
- package/dist/types/spacestation/src/space/generation-job.d.ts +4 -0
- package/dist/types/spacestation/src/space/hosting.d.ts +36 -0
- package/dist/types/spacestation/src/space/manifest.d.ts +8 -0
- package/dist/types/spacestation/src/space/package-version.d.ts +18 -0
- package/dist/types/spacestation/src/space/package.d.ts +35 -0
- package/dist/types/spacestation/src/space/prompt-config.d.ts +17 -0
- package/dist/types/spacestation/src/space/session-activity.d.ts +71 -0
- package/dist/types/spacestation/src/space/session-queue.d.ts +2147 -0
- package/dist/types/spacestation/src/space/space-config.d.ts +96 -0
- package/dist/types/spacestation/src/space/space-otp.d.ts +18 -0
- package/dist/types/spacestation/src/space/space.d.ts +104 -0
- package/dist/types/spacestation/src/space/tool-manifest.d.ts +8 -0
- package/dist/types/spacestation/src/space/trace.d.ts +555 -0
- package/dist/types/spacestation/src/space/workspace-catalog.d.ts +112 -0
- package/dist/types/spacestation/src/tool-compression/compress.d.ts +88 -0
- package/dist/types/spacestation/src/tool-compression/index.d.ts +11 -0
- package/dist/types/spacestation/src/tool-compression/scoring.d.ts +38 -0
- package/dist/types/spacestation/src/tool-compression/tokenize.d.ts +29 -0
- package/dist/types/spacestation/src/trace/trace-data.d.ts +126 -0
- package/dist/types/spacestation/src/trace/trace-diagnostics.d.ts +224 -0
- package/dist/types/spacestation/src/trace/trace-envelopes.d.ts +144 -0
- package/dist/types/spacestation/src/trace/trace-events.d.ts +450 -0
- package/dist/types/spacestation/src/types.d.ts +253 -0
- package/dist/types/spacestation/src/view/continuation.d.ts +45 -0
- package/dist/types/spacestation/src/widgets/presence/element.d.ts +241 -0
- package/dist/types/spacestation/src/widgets/presence/frame.d.ts +56 -0
- package/dist/types/spacestation/src/widgets/presence/index.d.ts +4 -0
- package/dist/types/spacestation/src/widgets/presence/profile.d.ts +75 -0
- package/dist/types/spacestation/src/widgets/presence/scan.d.ts +45 -0
- package/package.json +43 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the visitor's analytics consent DOES to an emit.
|
|
3
|
+
*
|
|
4
|
+
* The vocabulary (`ANALYTICS_CONSENTS`, `AnalyticsConsent`) is wire, and lives
|
|
5
|
+
* in `@fourty/spacestation/analytics`; the behaviour is here, in the same
|
|
6
|
+
* exhaustive-by-type shape as `surface.ts`.
|
|
7
|
+
*
|
|
8
|
+
* ── NOTHING IN THIS REPO READS CONSENT TODAY, AND THAT IS WHY THIS EXISTS ──
|
|
9
|
+
*
|
|
10
|
+
* There is no consent UI on the platform, and both emitting mounts pass
|
|
11
|
+
* `granted` in v1 with that reason written at the mount site. Under
|
|
12
|
+
* GDPR/ePrivacy the COLLECTION is the regulated act, so the machinery has to
|
|
13
|
+
* exist before the UI does — otherwise turning consent on later means editing
|
|
14
|
+
* every emit site instead of one value per host. This is the field an earlier
|
|
15
|
+
* design declared and never filled; filling it is the difference.
|
|
16
|
+
*
|
|
17
|
+
* ── `pending` HAS A REAL EXIT ──────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* An earlier draft froze `consent` in a `useState` initializer and exposed no
|
|
20
|
+
* mutator, which made `hold` a state nothing could leave — worse than an absent
|
|
21
|
+
* one, because it looks like a feature. `AnalyticsScope.setConsent` is the exit:
|
|
22
|
+
* `granted` releases the held rows with their ORIGINAL emit timestamps,
|
|
23
|
+
* `withheld` drops them counted. Consent does not un-resolve, so returning to
|
|
24
|
+
* `pending` from a resolved state throws.
|
|
25
|
+
*/
|
|
26
|
+
import type { AnalyticsConsent } from '../../../spacestation/src/analytics/index';
|
|
27
|
+
export type ConsentDisposition =
|
|
28
|
+
/** Emit and deliver. */
|
|
29
|
+
{
|
|
30
|
+
readonly mode: 'emit';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* HOLD in a buffer of its own, deliverable only if consent later resolves to
|
|
34
|
+
* `granted`. Deliberately a SEPARATE buffer from the pre-session holding
|
|
35
|
+
* area: the two are independent axes — a row can be both consent-held and
|
|
36
|
+
* session-unattributed — and collapsing them would make "release on grant"
|
|
37
|
+
* indistinguishable from "attribute on bind".
|
|
38
|
+
*/
|
|
39
|
+
| {
|
|
40
|
+
readonly mode: 'hold';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Refuse at COLLECTION, counted. NEVER buffered: a buffer that a later
|
|
44
|
+
* `granted` could flush is collection, and collection is the regulated act.
|
|
45
|
+
*/
|
|
46
|
+
| {
|
|
47
|
+
readonly mode: 'refuse';
|
|
48
|
+
readonly because: string;
|
|
49
|
+
};
|
|
50
|
+
/** Exhaustive by type — a fourth consent value with no decision is TS2741. */
|
|
51
|
+
export declare const CONSENT_DISPOSITION: Record<AnalyticsConsent, ConsentDisposition>;
|
|
52
|
+
export declare function consentDisposition(consent: AnalyticsConsent): ConsentDisposition;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why an event was not kept, and the ledger that makes "never silently" true.
|
|
3
|
+
*
|
|
4
|
+
* ── THE FAILURE THIS FILE PREVENTS ─────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* `packages/sdk/src/client-state/server-store.ts:41` says, verbatim, "Callers
|
|
7
|
+
* can log the drop; the store stays silent about it" — and its one non-test
|
|
8
|
+
* caller (`packages/react/src/provider/internal/use-agent-event-router.ts:211`)
|
|
9
|
+
* throws the boolean away. That is a drop nobody can see, in a module whose
|
|
10
|
+
* whole product is a count. A number a merchant reads is only as trustworthy as
|
|
11
|
+
* the count of rows that never reached it, so every refusal here increments a
|
|
12
|
+
* NAMED counter and reaches a REQUIRED `onDrop`.
|
|
13
|
+
*
|
|
14
|
+
* Two properties, kept apart on purpose:
|
|
15
|
+
*
|
|
16
|
+
* THE COUNTER IS EXACT. Every dropped event increments its reason, always,
|
|
17
|
+
* with no sampling and no rate limit. The totals ride out on every batch
|
|
18
|
+
* envelope (`AnalyticsDropCountsSchema`) as monotone lifetime totals, so the
|
|
19
|
+
* accounting survives the tab that made it.
|
|
20
|
+
*
|
|
21
|
+
* THE NOTICE IS RATE-LIMITED. Only the `onDrop` call is scheduled (see
|
|
22
|
+
* `notify.ts`), because a stuck outbox must be visible without becoming its
|
|
23
|
+
* own log flood — `apps/api/src/lib/llm-usage-sink.ts:117-129` is the
|
|
24
|
+
* reference for that split.
|
|
25
|
+
*/
|
|
26
|
+
import type { AnalyticsSurface } from '../../../spacestation/src/analytics/index';
|
|
27
|
+
/**
|
|
28
|
+
* The six ways an event fails to become a row.
|
|
29
|
+
*
|
|
30
|
+
* - `capacity` — the outbox was at `maxQueued`; the OLDEST row
|
|
31
|
+
* was evicted to make room for the newest.
|
|
32
|
+
* - `pre-session-abandoned` — boot never produced a session id, or a session
|
|
33
|
+
* ended while these rows were still unattributed.
|
|
34
|
+
* A row that survived a whole session boundary
|
|
35
|
+
* cannot be honestly attributed to either side.
|
|
36
|
+
* - `scope-closed` — the scope was closed before the batch left, or
|
|
37
|
+
* an emit arrived between a close and its paired
|
|
38
|
+
* open.
|
|
39
|
+
* - `surface-suppressed` — the mount's surface does not emit (replay, lab,
|
|
40
|
+
* the eval canvas, the previews, the operator's
|
|
41
|
+
* own view of a live space).
|
|
42
|
+
* - `consent-withheld` — consent was withheld, or resolved to withheld
|
|
43
|
+
* while rows were still consent-held.
|
|
44
|
+
* - `emit-threw` — `emit()` itself threw. Counted and CONTAINED,
|
|
45
|
+
* never propagated into the visitor code path that
|
|
46
|
+
* called it. This reason existing is the whole
|
|
47
|
+
* difference between "analytics failed" and "the
|
|
48
|
+
* add-to-cart button broke".
|
|
49
|
+
*
|
|
50
|
+
* The WIRE deliberately does not close this set (`AnalyticsDropCountsSchema` is
|
|
51
|
+
* an open record): a tab holding yesterday's bundle must not lose its whole
|
|
52
|
+
* batch over a reason name it has never heard of. The PRODUCER is closed, here.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DROP_REASONS: readonly ["capacity", "pre-session-abandoned", "scope-closed", "surface-suppressed", "consent-withheld", "emit-threw"];
|
|
55
|
+
export type DropReason = (typeof DROP_REASONS)[number];
|
|
56
|
+
/**
|
|
57
|
+
* Per-reason totals for one scope's whole life.
|
|
58
|
+
*
|
|
59
|
+
* Exhaustive BY TYPE: a new `DropReason` with no counter is a compile error
|
|
60
|
+
* (TS2741) at `emptyDropCounts`, so a reason can never be added and then go
|
|
61
|
+
* uncounted. That is the one guarantee a `Record<string, number>` would lose.
|
|
62
|
+
*/
|
|
63
|
+
export type DropCounts = Record<DropReason, number>;
|
|
64
|
+
export declare function emptyDropCounts(): DropCounts;
|
|
65
|
+
/** One reported drop. Carries the scope it happened on, because a host with two
|
|
66
|
+
* mounts must be able to tell whose events went missing. */
|
|
67
|
+
export interface DropNotice {
|
|
68
|
+
readonly scopeId: string;
|
|
69
|
+
readonly surface: AnalyticsSurface;
|
|
70
|
+
readonly reason: DropReason;
|
|
71
|
+
/** How many events THIS notice accounts for. */
|
|
72
|
+
readonly count: number;
|
|
73
|
+
/** Monotone total for this reason on this scope, across the scope's life. */
|
|
74
|
+
readonly totalForReason: number;
|
|
75
|
+
/** Human-readable WHY — the surface's or consent's `because`, the thrown
|
|
76
|
+
* error's message, the ceiling that was hit. A reason without a detail is a
|
|
77
|
+
* number nobody can act on. */
|
|
78
|
+
readonly detail: string;
|
|
79
|
+
}
|
|
80
|
+
export interface DropLedgerConfig {
|
|
81
|
+
readonly scopeId: string;
|
|
82
|
+
readonly surface: AnalyticsSurface;
|
|
83
|
+
/** REQUIRED. There is no constructor that leaves a drop unreported. */
|
|
84
|
+
readonly onDrop: (notice: DropNotice) => void;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The one place a drop is counted. Every buffer in this module records through
|
|
88
|
+
* it, so "was this counted?" has exactly one answer to read.
|
|
89
|
+
*/
|
|
90
|
+
export interface DropLedger {
|
|
91
|
+
/** Count `count` events dropped for `reason`, and notify on the schedule. */
|
|
92
|
+
record(reason: DropReason, count: number, detail: string): void;
|
|
93
|
+
totalFor(reason: DropReason): number;
|
|
94
|
+
/** Monotone lifetime totals, never deltas — a batch lost in flight must lose
|
|
95
|
+
* no accounting, which is what lets the server take `max()` per scope. */
|
|
96
|
+
snapshot(): DropCounts;
|
|
97
|
+
}
|
|
98
|
+
export declare function createDropLedger(config: DropLedgerConfig): DropLedger;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createAnalyticsScope } from './scope';
|
|
2
|
+
export type { AnalyticsScope, AnalyticsScopeConfig, AnalyticsScopeStats, AnalyticsSink, SinkGuard, } from './scope';
|
|
3
|
+
export { AnalyticsSinkProvider, useAnalyticsSink, useOptionalAnalyticsSink } from './scope-context';
|
|
4
|
+
export { SURFACE_DISPOSITION, surfaceEmits, surfaceSuppressionReason } from './surface';
|
|
5
|
+
export type { SurfaceDisposition } from './surface';
|
|
6
|
+
export { CONSENT_DISPOSITION, consentDisposition } from './consent';
|
|
7
|
+
export type { ConsentDisposition } from './consent';
|
|
8
|
+
export { DROP_REASONS, emptyDropCounts } from './drops';
|
|
9
|
+
export type { DropCounts, DropNotice, DropReason } from './drops';
|
|
10
|
+
export type { AnalyticsTransport, DeliveryResult } from './transport';
|
|
11
|
+
export { ANALYTICS_CONSENTS, ANALYTICS_MAX_QUEUED, ANALYTICS_SURFACES, defineEventKind } from '../../../spacestation/src/analytics/index';
|
|
12
|
+
export type { AnalyticsBatch, AnalyticsConsent, AnalyticsSurface, AnalyticsWireEvent, ClientEventKind, EventKind, EventTrust, Identical, PayloadGuard, PayloadOf, } from '../../../spacestation/src/analytics/index';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a drop becomes a NOTICE.
|
|
3
|
+
*
|
|
4
|
+
* The counter in `drops.ts` is exact and unconditional. This schedule governs
|
|
5
|
+
* only how often the required `onDrop` handler hears about a reason, so a stuck
|
|
6
|
+
* outbox is visible without becoming its own log flood.
|
|
7
|
+
*
|
|
8
|
+
* ── THE PROTOTYPE THIS REPLACES WAS MEASURED WRONG. DO NOT RE-DERIVE IT ────
|
|
9
|
+
*
|
|
10
|
+
* The design's prototype read:
|
|
11
|
+
*
|
|
12
|
+
* const before = totalForReason - count;
|
|
13
|
+
* if (before === totalForReason) return before === 0; // ← always true
|
|
14
|
+
* return Math.floor(before / 100) !== Math.floor(totalForReason / 100);
|
|
15
|
+
*
|
|
16
|
+
* With `count === 1` — which is EVERY `scope-closed`, every
|
|
17
|
+
* `surface-suppressed`, every `consent-withheld` and every single-row capacity
|
|
18
|
+
* eviction — `before` is `totalForReason - 1`, so that first clause compares a
|
|
19
|
+
* value to itself and only the very first drop survives it. Measured over 250
|
|
20
|
+
* iterations it fired at `[1]` and never again: the counter stayed exact, so
|
|
21
|
+
* nothing was lost, but `onDrop` — the structural no-silent-drop guarantee —
|
|
22
|
+
* went mute after the first drop and the test that asserted "the counter is
|
|
23
|
+
* exact" passed the whole time. `notify.test.ts` asserts the CADENCE, not just
|
|
24
|
+
* the total, because that is the assertion the bug survived.
|
|
25
|
+
*
|
|
26
|
+
* The reference implementation, `apps/api/src/lib/llm-usage-sink.ts:123`, is
|
|
27
|
+
* `dropped % 100 === 1` (fires at 1, 101, 201) and is correct only for single
|
|
28
|
+
* increments. This version compares DECADES of the running total instead, so a
|
|
29
|
+
* multi-event drop — an eviction of three, a batch discarded on close — cannot
|
|
30
|
+
* step over a boundary silently.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* At most one notice per 100 drops of a reason, ALWAYS including the first.
|
|
34
|
+
*
|
|
35
|
+
* Fires at totals 1, 100, 200, 300 for `count = 1`; at 3, 102, 201 for
|
|
36
|
+
* `count = 3`.
|
|
37
|
+
*
|
|
38
|
+
* @param totalForReason the reason's monotone total INCLUDING this drop
|
|
39
|
+
* @param count how many events this drop accounts for
|
|
40
|
+
*/
|
|
41
|
+
export declare function shouldNotify(totalForReason: number, count: number): boolean;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bounded, append-only outbox — arrival order in, arrival order out.
|
|
3
|
+
*
|
|
4
|
+
* Modelled on `packages/sdk/src/widgets/presence/core-presence/presence-stream.ts:31-32`
|
|
5
|
+
* ("Every element currently held, in arrival order") with the eviction
|
|
6
|
+
* discipline of `apps/api/src/lib/llm-usage-sink.ts:117-129`.
|
|
7
|
+
*
|
|
8
|
+
* ── `client-state/store.ts` IS EXPLICITLY NOT THE TEMPLATE ─────────────────
|
|
9
|
+
*
|
|
10
|
+
* It is the closest-looking file in the SDK and it would be exactly wrong here.
|
|
11
|
+
* It is slot-keyed (`entries.set(namespace, …)`) and content-deduped
|
|
12
|
+
* (`const key = JSON.stringify(payload)` with an early return), so two identical
|
|
13
|
+
* `cart_line_added` events collapse into one — and the dedup exists PRECISELY so
|
|
14
|
+
* repeats are free, while repeats are the data a count is made of. What is
|
|
15
|
+
* borrowed from it is only the outer shape: no React, no timers, no I/O.
|
|
16
|
+
*
|
|
17
|
+
* ── TWO ROW STATES, ONE ARRAY ──────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* A row is HELD while its `sessionId` is null and ATTRIBUTED once it is not.
|
|
20
|
+
* They share one array because they share one order: a session id arriving in
|
|
21
|
+
* the middle of a page's life must not reorder what came before it. Only
|
|
22
|
+
* attributed rows can leave — `takeAttributed()` is the only exit that produces
|
|
23
|
+
* wire events — which is what makes "never sent unattributed" structural rather
|
|
24
|
+
* than a check someone remembers to write.
|
|
25
|
+
*/
|
|
26
|
+
import type { AnalyticsWireEvent } from '../../../spacestation/src/analytics/index';
|
|
27
|
+
import type { DropLedger, DropReason } from './drops';
|
|
28
|
+
/**
|
|
29
|
+
* One recorded transition, before it is deliverable.
|
|
30
|
+
*
|
|
31
|
+
* `eventId` and `occurredAt` are stamped at EMIT and never at flush: a row can
|
|
32
|
+
* sit here for the session boot's whole retry budget (`reconnect.ts:22-31` calls
|
|
33
|
+
* it "≈ 94s of patience"), and a flush-time timestamp would be that far wrong.
|
|
34
|
+
*/
|
|
35
|
+
export interface HeldEvent {
|
|
36
|
+
readonly eventId: string;
|
|
37
|
+
readonly occurredAt: number;
|
|
38
|
+
readonly kind: string;
|
|
39
|
+
readonly payload: Record<string, unknown>;
|
|
40
|
+
/** `null` until `attributeHeld` stamps it. Never re-stamped once set. */
|
|
41
|
+
readonly sessionId: string | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Is this value shaped like a wire payload?
|
|
45
|
+
*
|
|
46
|
+
* The emit API's `payload` parameter is `PayloadOf<Kind>`, which degrades to
|
|
47
|
+
* `unknown` for the wide `ClientEventKind` type and is opaque to the compiler
|
|
48
|
+
* while `Kind` is still generic — so at THIS boundary the value's shape is
|
|
49
|
+
* genuinely unproven, and `as` is not available (and would be a lie anyway).
|
|
50
|
+
* This is a real runtime check with a declared narrowing: a non-object payload
|
|
51
|
+
* throws inside `emit`, where the throw is contained and counted as
|
|
52
|
+
* `emit-threw` rather than reaching the cart write that called it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isWirePayload(value: unknown): value is Record<string, unknown>;
|
|
55
|
+
export interface OutboxConfig {
|
|
56
|
+
/** Hard ceiling on rows held at once. */
|
|
57
|
+
readonly maxQueued: number;
|
|
58
|
+
/** Where every eviction is counted. Shared with the scope's other buffer, so
|
|
59
|
+
* "how many did we lose" has one answer and not two. */
|
|
60
|
+
readonly ledger: DropLedger;
|
|
61
|
+
/** Names this buffer in eviction details ("outbox", "consent hold"). */
|
|
62
|
+
readonly label: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The buffer itself. No timers, no listeners, no React, no I/O — everything
|
|
66
|
+
* that decides WHEN to drain lives in the scope, and everything that decides
|
|
67
|
+
* HOW to deliver lives in the transport.
|
|
68
|
+
*/
|
|
69
|
+
export declare class Outbox {
|
|
70
|
+
private readonly rows;
|
|
71
|
+
private readonly maxQueued;
|
|
72
|
+
private readonly ledger;
|
|
73
|
+
private readonly label;
|
|
74
|
+
constructor(config: OutboxConfig);
|
|
75
|
+
/**
|
|
76
|
+
* Append one row, evicting the OLDEST if the ceiling is reached.
|
|
77
|
+
*
|
|
78
|
+
* Drop-oldest, deliberately: the newest events are the ones a partial batch
|
|
79
|
+
* can still explain, and a visitor whose tab has been open for an hour is
|
|
80
|
+
* better described by the last 500 things they did than the first.
|
|
81
|
+
*/
|
|
82
|
+
append(row: HeldEvent): void;
|
|
83
|
+
/**
|
|
84
|
+
* Put a batch the transport could not deliver back at the FRONT.
|
|
85
|
+
*
|
|
86
|
+
* Front, because these rows are older than anything appended since; and the
|
|
87
|
+
* re-eviction takes from the BACK under the same ceiling, so a retry loop
|
|
88
|
+
* against an unreachable server cannot grow the buffer without bound.
|
|
89
|
+
*/
|
|
90
|
+
restoreFront(events: readonly AnalyticsWireEvent[]): void;
|
|
91
|
+
/**
|
|
92
|
+
* Stamp the session id onto rows that do not have one.
|
|
93
|
+
*
|
|
94
|
+
* ONLY rows whose `sessionId` is still null. A row that already carries one is
|
|
95
|
+
* never re-stamped — re-stamping is exactly how a pre-session event ends up
|
|
96
|
+
* attributed to the next visitor.
|
|
97
|
+
*/
|
|
98
|
+
attributeHeld(sessionId: string): number;
|
|
99
|
+
/** Remove and return every attributed row, in arrival order. Held rows stay
|
|
100
|
+
* exactly where they are. */
|
|
101
|
+
takeAttributed(): AnalyticsWireEvent[];
|
|
102
|
+
/**
|
|
103
|
+
* Remove and return EVERY row, attributed or not, in arrival order.
|
|
104
|
+
*
|
|
105
|
+
* The consent hold's release path: rows leave one buffer and are appended to
|
|
106
|
+
* the other, so nothing here counts a drop — the receiving buffer's ceiling
|
|
107
|
+
* does, if it has to.
|
|
108
|
+
*/
|
|
109
|
+
drainRows(): HeldEvent[];
|
|
110
|
+
/** Drop every still-unattributed row, counted. */
|
|
111
|
+
discardHeld(reason: DropReason, detail: string): number;
|
|
112
|
+
/** Drop everything, counted. */
|
|
113
|
+
discardAll(reason: DropReason, detail: string): number;
|
|
114
|
+
/** Rows held right now, attributed or not. */
|
|
115
|
+
count(): number;
|
|
116
|
+
/** Rows still waiting for a session id. */
|
|
117
|
+
heldCount(): number;
|
|
118
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AnalyticsSink } from './scope';
|
|
2
|
+
/** Filled by `@fourty/react`'s `AnalyticsScopeMount`, once per mount. */
|
|
3
|
+
export declare const AnalyticsSinkProvider: import("react").Provider<AnalyticsSink | null>;
|
|
4
|
+
/**
|
|
5
|
+
* The sink for THIS mount. THROWS when no mount is upstream.
|
|
6
|
+
*
|
|
7
|
+
* For ENGINE and BRAND code: a brand component only ever renders inside a
|
|
8
|
+
* mounted `FourtyProvider`, so a missing provider there is a wiring bug and not
|
|
9
|
+
* a tolerated state — the same posture as `useFourtyRuntime`
|
|
10
|
+
* (`canvas/runtime-context.tsx:24-30`) and `usePresenceRuntime`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAnalyticsSink(): AnalyticsSink;
|
|
13
|
+
/**
|
|
14
|
+
* Non-throwing variant — `null` when no mount is upstream, with one warning.
|
|
15
|
+
*
|
|
16
|
+
* THE ONE `@fourty/ui` USES. Shared UI renders in preview and storybook
|
|
17
|
+
* contexts with no provider at all, which is exactly why that package already
|
|
18
|
+
* ships `use-safe-cart`, `use-safe-facts` and `use-safe-fourty-session`. A
|
|
19
|
+
* caller receiving `null` passes it on explicitly (`AnalyticsSink | null` is the
|
|
20
|
+
* one tolerated null in this module: the store parameter stays REQUIRED, so an
|
|
21
|
+
* un-threaded call site is still TS2554, while a preview render says "there is
|
|
22
|
+
* no mount here" out loud).
|
|
23
|
+
*/
|
|
24
|
+
export declare function useOptionalAnalyticsSink(): AnalyticsSink | null;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { AnalyticsBatch, AnalyticsConsent, AnalyticsSurface, ClientEventKind, Identical, PayloadOf } from '../../../spacestation/src/analytics/index';
|
|
2
|
+
import { type DropCounts, type DropLedger, type DropNotice } from './drops';
|
|
3
|
+
/**
|
|
4
|
+
* The proof obligation on `emit`'s kind parameter, EXPORTED so it can be
|
|
5
|
+
* asserted rather than merely believed (the same posture as the wire contract's
|
|
6
|
+
* `PayloadGuard`).
|
|
7
|
+
*
|
|
8
|
+
* `PayloadOf<Kind>` collapses to `unknown` when `Kind` is the WIDE
|
|
9
|
+
* `ClientEventKind` type — which is what a forwarding helper, a batching
|
|
10
|
+
* wrapper, a test double or a `readonly ClientEventKind[]` loop instantiates it
|
|
11
|
+
* as. Without this guard those call sites lose payload checking ENTIRELY, with
|
|
12
|
+
* no `as` and no `any` anywhere for a grep to find. Measured on this repo's
|
|
13
|
+
* tsc: `declare const k: ClientEventKind; sink.emit(k, 42)` compiled clean
|
|
14
|
+
* before the guard and fails TS2554 after it, while a concrete token still
|
|
15
|
+
* fails TS2322 on a wrong payload.
|
|
16
|
+
*/
|
|
17
|
+
export type SinkGuard<Kind extends ClientEventKind> = Identical<PayloadOf<Kind>, unknown> extends true ? [error: 'emit requires a concrete event kind token, not the wide ClientEventKind type'] : [];
|
|
18
|
+
/**
|
|
19
|
+
* What an EMIT SITE receives. Deliberately ONE method wide.
|
|
20
|
+
*
|
|
21
|
+
* A store mutator can record that a transition happened and can do NOTHING
|
|
22
|
+
* else: it cannot flush, rebind, close, or read the queue. A store handed the
|
|
23
|
+
* whole scope would eventually flush from inside a cart write.
|
|
24
|
+
*
|
|
25
|
+
* What the call site passes: the kind TOKEN and a payload object literal.
|
|
26
|
+
* What it never passes: a name, an event id, a timestamp, a session id, a space
|
|
27
|
+
* id, a surface, a visitor id, a consent flag or a source. Those are the
|
|
28
|
+
* envelope, the envelope is the scope's job, and an emit site that could set
|
|
29
|
+
* them could get them wrong.
|
|
30
|
+
*/
|
|
31
|
+
export interface AnalyticsSink {
|
|
32
|
+
emit<Kind extends ClientEventKind>(kind: Kind, payload: PayloadOf<Kind>, ...guard: SinkGuard<Kind>): void;
|
|
33
|
+
}
|
|
34
|
+
/** What the mount can see without draining anything. */
|
|
35
|
+
export interface AnalyticsScopeStats {
|
|
36
|
+
/** Rows in the outbox, attributed or not. */
|
|
37
|
+
readonly queued: number;
|
|
38
|
+
/** Rows in the outbox still waiting for a session id. */
|
|
39
|
+
readonly held: number;
|
|
40
|
+
/** Rows waiting for consent to resolve. */
|
|
41
|
+
readonly consentHeld: number;
|
|
42
|
+
/** Monotone lifetime drop totals for this scope. */
|
|
43
|
+
readonly drops: DropCounts;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What the MOUNT and the TRANSPORT hold. Everything past `emit` is a boundary
|
|
47
|
+
* call, never a visitor path — which is why the methods below keep their loud
|
|
48
|
+
* throws while `emit` is total.
|
|
49
|
+
*/
|
|
50
|
+
export interface AnalyticsScope extends AnalyticsSink {
|
|
51
|
+
readonly scopeId: string;
|
|
52
|
+
readonly surface: AnalyticsSurface;
|
|
53
|
+
readonly spaceSlug: string;
|
|
54
|
+
/**
|
|
55
|
+
* The session id finally exists. Stamps every row still holding `null` and
|
|
56
|
+
* leaves the rest untouched.
|
|
57
|
+
*
|
|
58
|
+
* Binding a DIFFERENT session without `unbindSession()` first THROWS: silent
|
|
59
|
+
* rebinding is the misattribution path, and this is a mount call, not a
|
|
60
|
+
* visitor one. Re-binding the SAME id is a no-op, because React's double
|
|
61
|
+
* invoke will do exactly that.
|
|
62
|
+
*/
|
|
63
|
+
bindSession(sessionId: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* A session ended. Returns the outstanding batch stamped with the OUTGOING
|
|
66
|
+
* session id, and DROPS still-held rows as `pre-session-abandoned`: a row
|
|
67
|
+
* emitted before any session existed that survived a whole session boundary
|
|
68
|
+
* cannot be honestly attributed to either side of it. Holding it for the next
|
|
69
|
+
* session would silently re-date the event.
|
|
70
|
+
*/
|
|
71
|
+
unbindSession(): AnalyticsBatch;
|
|
72
|
+
/**
|
|
73
|
+
* Boot never produced a session id at all — the three terminal branches in
|
|
74
|
+
* `session-lifecycle.ts` (restore unreachable, unparseable restore body,
|
|
75
|
+
* create failure) leave it null for the whole page life. Drops the holding
|
|
76
|
+
* area, counted.
|
|
77
|
+
*
|
|
78
|
+
* A buffer that only ever flushes leaks on every failed boot; that is the
|
|
79
|
+
* exact defect in `apps/platform/lib/analytics/posthog-client.ts:19-21`,
|
|
80
|
+
* whose module-global `pending` array has no path for "never loaded".
|
|
81
|
+
*/
|
|
82
|
+
abandonPreSession(detail: string): void;
|
|
83
|
+
/** Consent resolved. See `consent.ts`; returning to `pending` throws. */
|
|
84
|
+
setConsent(next: AnalyticsConsent): void;
|
|
85
|
+
/** Take everything deliverable. An empty `events` array means there was
|
|
86
|
+
* nothing to send — the wire refuses a zero-event batch, so the transport
|
|
87
|
+
* must check before posting. */
|
|
88
|
+
drain(): AnalyticsBatch;
|
|
89
|
+
/**
|
|
90
|
+
* Put an undelivered batch back at the front. THROWS on a batch whose
|
|
91
|
+
* `scopeId` is not this scope's, rather than absorbing it — absorbing is the
|
|
92
|
+
* cross-mount leak this whole module exists to stop.
|
|
93
|
+
*/
|
|
94
|
+
restore(batch: AnalyticsBatch): void;
|
|
95
|
+
/** Revive a closed scope. Idempotent; a no-op when already open. */
|
|
96
|
+
open(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Close, and RETURN the attributed rows. Never discard the return value: the
|
|
99
|
+
* rows leave the outbox uncounted, so a dropped batch is a silent loss.
|
|
100
|
+
* Idempotent — a second close returns an empty batch.
|
|
101
|
+
*/
|
|
102
|
+
close(): AnalyticsBatch;
|
|
103
|
+
stats(): AnalyticsScopeStats;
|
|
104
|
+
}
|
|
105
|
+
export interface AnalyticsScopeConfig {
|
|
106
|
+
/** REQUIRED, no default. Naming the mount IS the emit-vs-silence decision. */
|
|
107
|
+
readonly surface: AnalyticsSurface;
|
|
108
|
+
/** REQUIRED, no default. Live afterwards through `setConsent`. */
|
|
109
|
+
readonly consent: AnalyticsConsent;
|
|
110
|
+
/** A SLUG, never a space id: `spaceKey` is polymorphic across mounts, and a
|
|
111
|
+
* space id asserted on a public endpoint is attacker-supplied anyway. */
|
|
112
|
+
readonly spaceSlug: string;
|
|
113
|
+
/**
|
|
114
|
+
* The outbox ceiling. Must not exceed `ANALYTICS_MAX_QUEUED`, which is BOTH
|
|
115
|
+
* this ceiling and the wire's per-batch maximum — one number on purpose, so a
|
|
116
|
+
* drain of a full outbox always fits in one batch. A larger buffer would mean
|
|
117
|
+
* the first flush after a long offline stretch is refused WHOLESALE by the
|
|
118
|
+
* ingest route, losing exactly the rows the buffer existed to save.
|
|
119
|
+
*/
|
|
120
|
+
readonly maxQueued: number;
|
|
121
|
+
/** Injected so the core is deterministic under test. Wall-clock, because the
|
|
122
|
+
* value must be joinable against server rows. */
|
|
123
|
+
readonly now: () => number;
|
|
124
|
+
/** `mintId('scope')` in production — never a bare `crypto.randomUUID()`,
|
|
125
|
+
* which does not exist outside a secure context and the embed runs on
|
|
126
|
+
* merchant pages. */
|
|
127
|
+
readonly newScopeId: () => string;
|
|
128
|
+
/** `mintId('evt')`. The idempotency key, byte-identical on retry. */
|
|
129
|
+
readonly newEventId: () => string;
|
|
130
|
+
/** REQUIRED. There is no constructor that leaves a drop unreported. */
|
|
131
|
+
readonly onDrop: (notice: DropNotice) => void;
|
|
132
|
+
}
|
|
133
|
+
/** What both implementations are built from — one scope id, one ledger. */
|
|
134
|
+
export interface ScopeFoundation {
|
|
135
|
+
readonly scopeId: string;
|
|
136
|
+
readonly ledger: DropLedger;
|
|
137
|
+
readonly config: AnalyticsScopeConfig;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build the scope for one mount.
|
|
141
|
+
*
|
|
142
|
+
* The dispatch is on the SURFACE, which is structural and cannot change for the
|
|
143
|
+
* life of a mount: a non-emitting surface gets a scope with no event buffer at
|
|
144
|
+
* ALL, so a replay or a preview does not merely refrain from sending — it has
|
|
145
|
+
* nowhere to put an event in the first place. Consent is the other axis and is
|
|
146
|
+
* handled INSIDE the emitting scope, because unlike a surface it resolves while
|
|
147
|
+
* the mount is alive.
|
|
148
|
+
*/
|
|
149
|
+
export declare function createAnalyticsScope(config: AnalyticsScopeConfig): AnalyticsScope;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each mount surface DOES with an event — the emit gate.
|
|
3
|
+
*
|
|
4
|
+
* The vocabulary itself (`ANALYTICS_SURFACES`, `AnalyticsSurface`) lives in
|
|
5
|
+
* `@fourty/spacestation/analytics`, because the ingest route validates against
|
|
6
|
+
* the same closed set and `apps/api` cannot import `@fourty/sdk`. What lives
|
|
7
|
+
* HERE is the behaviour: which surfaces emit, and — when one does not — the
|
|
8
|
+
* sentence that says why, so a suppressed emit is counted and explained rather
|
|
9
|
+
* than vanishing.
|
|
10
|
+
*
|
|
11
|
+
* ── WHY THIS IS A REQUIRED PROP AND NOT AN INFERENCE ───────────────────────
|
|
12
|
+
*
|
|
13
|
+
* The SDK cannot tell where it is running, and every adjacent signal is the
|
|
14
|
+
* wrong axis. `offline` gates a socket, not a visitor (the storefront embed is
|
|
15
|
+
* live and MUST emit; the public spacefront under `?embed=1` is live and must
|
|
16
|
+
* NOT). `spaceKey` is polymorphic — a slug on the two emitting mounts, a real
|
|
17
|
+
* space UUID on replay/lab/static-canvas, and the literal
|
|
18
|
+
* `'admin-packages-preview'` in the ui-packages preview. `SpaceHosting` says
|
|
19
|
+
* where a space MAY render, not where this mount IS. `process.env` is
|
|
20
|
+
* unreadable from a package. So the mount DECLARES it, once, visibly, and the
|
|
21
|
+
* `Record<AnalyticsSurface, …>` below makes a new surface with no decision a
|
|
22
|
+
* compile error (TS2741) instead of a silent default into the emitting bucket.
|
|
23
|
+
*
|
|
24
|
+
* ── THE MOUNT THAT MAKES THIS URGENT ───────────────────────────────────────
|
|
25
|
+
*
|
|
26
|
+
* `apps/platform/components/sessions/SessionReplay.tsx:130` replays ARCHIVED
|
|
27
|
+
* TRACES through the real component stack against a REAL space UUID. An
|
|
28
|
+
* operator clicking through a replay would manufacture fresh engagement for
|
|
29
|
+
* actions a visitor took months ago, inside that space owner's numbers. It is
|
|
30
|
+
* one of six `<FourtyProvider>` mounts in this repo, four of which must be
|
|
31
|
+
* silent, and no amount of care at the emit site can tell them apart.
|
|
32
|
+
*
|
|
33
|
+
* ── THIS IS NOT THE `surface` A METRIC FILTERS ON ──────────────────────────
|
|
34
|
+
*
|
|
35
|
+
* That is `sessions.surface` — five values, server-derived at session creation
|
|
36
|
+
* and never client-asserted (`@fourty/spacestation`'s `SURFACES`). This one has
|
|
37
|
+
* exactly two jobs: it is the emit gate, and it is an input the ingest route may
|
|
38
|
+
* cross-check against `Origin`/`Referer`. A session-grain RATE whose numerator
|
|
39
|
+
* filters on one column and whose denominator filters on the other is not a
|
|
40
|
+
* rate, and the two vocabularies are deliberately different sizes so that
|
|
41
|
+
* mistake cannot be made quietly.
|
|
42
|
+
*/
|
|
43
|
+
import type { AnalyticsSurface } from '../../../spacestation/src/analytics/index';
|
|
44
|
+
/**
|
|
45
|
+
* What a surface does, and — when it is silent — WHY.
|
|
46
|
+
*
|
|
47
|
+
* The `because` string is not decoration: it is what `onDrop` reports as the
|
|
48
|
+
* notice's `detail`, so "these events went nowhere" always arrives with the
|
|
49
|
+
* sentence that explains it.
|
|
50
|
+
*/
|
|
51
|
+
export type SurfaceDisposition = {
|
|
52
|
+
readonly emits: true;
|
|
53
|
+
} | {
|
|
54
|
+
readonly emits: false;
|
|
55
|
+
readonly because: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* THE SINGLE SOURCE OF TRUTH, exhaustive BY TYPE.
|
|
59
|
+
*
|
|
60
|
+
* `Record<AnalyticsSurface, SurfaceDisposition>` means adding a surface to the
|
|
61
|
+
* wire vocabulary without deciding what it does here fails the build. That is
|
|
62
|
+
* the structural half of the guarantee; the reviewable half is that every
|
|
63
|
+
* `<FourtyProvider>` must type a `surface` prop with no default, at six call
|
|
64
|
+
* sites a diff can show.
|
|
65
|
+
*/
|
|
66
|
+
export declare const SURFACE_DISPOSITION: Record<AnalyticsSurface, SurfaceDisposition>;
|
|
67
|
+
/** Whether this surface records anything at all. The one predicate
|
|
68
|
+
* `createAnalyticsScope` dispatches on. */
|
|
69
|
+
export declare function surfaceEmits(surface: AnalyticsSurface): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The sentence a suppressed surface reports, or `null` when the surface emits.
|
|
72
|
+
*
|
|
73
|
+
* Split out so the scope never has to narrow the union at a call site that has
|
|
74
|
+
* already decided — and so a future surface cannot be added with an empty
|
|
75
|
+
* excuse and have it read as "no reason given".
|
|
76
|
+
*/
|
|
77
|
+
export declare function surfaceSuppressionReason(surface: AnalyticsSurface): string | null;
|