soma-core 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +42 -0
  2. package/app/SomaPageClient.tsx +39 -2
  3. package/app/[...path]/page.tsx +7 -6
  4. package/app/api/[...path]/route.ts +3 -3
  5. package/app/api/soma-registry/[...path]/route.ts +67 -0
  6. package/app/components/SomaHostPage.tsx +3 -8
  7. package/app/components/SomaPageClientBoundary.tsx +13 -0
  8. package/app/layout.tsx +6 -1
  9. package/app/page.tsx +3 -3
  10. package/app/soma/manifest/route.ts +1 -0
  11. package/app/soma/page-object/route.ts +1 -1
  12. package/core/build/compiler/full-manifest-builder.ts +6 -1
  13. package/core/build/compiler/rollup-plugin-soma.ts +6 -0
  14. package/core/build/compiler/soma-manifest-webpack-plugin.js +4 -0
  15. package/core/build/compiler/soma-precompile.js +3507 -2387
  16. package/core/build/compiler/soma-precompile.ts +31 -2
  17. package/core/build/compiler/soma-rspack-yaml-loader.js +3 -0
  18. package/core/build/compiler/soma-webpack-loader.js +7 -1
  19. package/core/build/compiler/vite-plugin-soma.ts +11 -1
  20. package/core/build/component/package-loader.ts +135 -0
  21. package/core/build/eject/apply-eject.ts +133 -0
  22. package/core/build/eject/plan-eject.ts +139 -0
  23. package/core/client/adaptive/flush-scheduler.ts +96 -0
  24. package/core/client/adaptive/hysteresis.ts +56 -0
  25. package/core/client/adaptive/index.ts +23 -0
  26. package/core/client/adaptive/observer-pool.ts +90 -0
  27. package/core/client/base/SomaPageRootBase.ts +50 -0
  28. package/core/client/compiler/adaptive-compile.ts +136 -0
  29. package/core/client/compiler/manifest-compiler.ts +155 -27
  30. package/core/client/component/ai-catalog.ts +262 -0
  31. package/core/client/component/component-definition.types.ts +65 -0
  32. package/core/client/component/component-expander.ts +119 -0
  33. package/core/client/component/component-manager.ts +933 -0
  34. package/core/client/component/component-pack.ts +271 -0
  35. package/core/client/component/component-registry.ts +71 -0
  36. package/core/client/component/pack-styles.ts +94 -0
  37. package/core/client/component/scoped-adapter.ts +85 -0
  38. package/core/client/component/verify-pack.ts +247 -0
  39. package/core/client/container/MiniProgramContainerAdapter.ts +15 -1
  40. package/core/client/container/ReactNativeContainerAdapter.ts +15 -1
  41. package/core/client/container/SomaContainerAdapter.ts +186 -180
  42. package/core/client/data/data-object-resolver.ts +417 -0
  43. package/core/client/diagnostics/SomaDiagnostics.ts +187 -186
  44. package/core/client/diagnostics/boot-timings.ts +152 -0
  45. package/core/client/engine/asset-resolver.ts +12 -2
  46. package/core/client/engine/dom-renderer.ts +235 -16
  47. package/core/client/engine/emit-event.ts +21 -0
  48. package/core/client/engine/event-engine.ts +34 -4
  49. package/core/client/engine/on-change-engine.ts +1 -1
  50. package/core/client/engine/property-watcher.ts +1 -1
  51. package/core/client/engine/reactive-proxy.ts +3 -3
  52. package/core/client/engine/render-engine.ts +43 -4
  53. package/core/client/engine/runtime-builder.ts +23 -0
  54. package/core/client/engine/soma-bootstrap.ts +389 -5
  55. package/core/client/engine/style-binder.ts +47 -1
  56. package/core/client/host-bridge/empty-host/data/README.md +17 -0
  57. package/core/client/infra/http/SomaHttpService.ts +5 -0
  58. package/core/client/observability/error-reporter.ts +173 -0
  59. package/core/client/parser/adaptive-parser.ts +264 -0
  60. package/core/client/parser/data-config-parser.ts +396 -0
  61. package/core/client/parser/pipeline-parser.ts +15 -3
  62. package/core/client/parser/style-config-parser.ts +65 -2
  63. package/core/client/parser/ui-config-parser.ts +52 -3
  64. package/core/client/pipes/pipe-registry.ts +249 -0
  65. package/core/client/quality/SomaQualityRegistry.ts +3 -0
  66. package/core/client/registry/declaration-renderer.ts +159 -0
  67. package/core/client/registry/index.ts +28 -0
  68. package/core/client/registry/page-lifecycle.ts +171 -0
  69. package/core/client/registry/remote-page.ts +139 -0
  70. package/core/client/runtime/SomaRuntimeServices.ts +24 -0
  71. package/core/client/scheduler/SomaScheduler.ts +29 -1
  72. package/core/client/security/attribute-presence.ts +70 -0
  73. package/core/client/security/html-sanitizer.ts +113 -0
  74. package/core/client/security/url-guard.ts +0 -0
  75. package/core/client/theme/theme-engine.ts +936 -0
  76. package/core/client/typography/typography-base.ts +34 -0
  77. package/core/client/validation/contract-validator.ts +48 -5
  78. package/core/index.ts +190 -2
  79. package/core/server/api/IService.ts +18 -6
  80. package/core/server/api/load-host-service.ts +3 -3
  81. package/core/server/host/content-security-policy.ts +190 -0
  82. package/core/server/host/csp-nonce-metadata.ts +75 -0
  83. package/core/server/host/resolve-host-request-hook.ts +5 -0
  84. package/core/server/host/server-page-assets.ts +10 -0
  85. package/core/server/index.ts +30 -1
  86. package/core/server/infra/cache/ServerFileCache.ts +1 -1
  87. package/core/server/mock/node/cli.mjs +2 -2
  88. package/core/server/registry/api-registry-store.ts +518 -0
  89. package/core/server/registry/conditional-object-store.ts +29 -0
  90. package/core/server/registry/declaration-precompiler.ts +129 -0
  91. package/core/server/registry/in-memory-conditional-object-store.ts +43 -0
  92. package/core/server/registry/index.ts +142 -0
  93. package/core/server/registry/page-registry-repository.ts +373 -0
  94. package/core/server/registry/page-registry-store.ts +903 -0
  95. package/core/server/registry/registry-error.ts +17 -0
  96. package/core/server/registry/registry-file-lock.ts +173 -0
  97. package/core/server/registry/registry-response.ts +71 -0
  98. package/core/server/registry/registry-subjects.ts +194 -0
  99. package/core/server/registry/registry-write-pipeline.ts +240 -0
  100. package/core/server/registry/request-body-limit.ts +99 -0
  101. package/core/server/registry/services/apis/Get.ts +25 -0
  102. package/core/server/registry/services/apis/List.ts +41 -0
  103. package/core/server/registry/services/apis/Register.ts +39 -0
  104. package/core/server/registry/services/apis/Unregister.ts +24 -0
  105. package/core/server/registry/services/index.ts +40 -0
  106. package/core/server/registry/services/pages/Get.ts +86 -0
  107. package/core/server/registry/services/pages/List.ts +53 -0
  108. package/core/server/registry/services/pages/Register.ts +49 -0
  109. package/core/server/registry/services/pages/Rollback.ts +36 -0
  110. package/core/server/registry/services/pages/Unregister.ts +23 -0
  111. package/core/server/registry/services/service-utils.ts +21 -0
  112. package/core/server/registry/validation/compile-gate.ts +71 -0
  113. package/core/server/registry/validation/component-existence.ts +55 -0
  114. package/core/server/registry/validation/credential-ban.ts +86 -0
  115. package/core/server/registry/validation/cross-check.ts +77 -0
  116. package/core/server/registry/validation/declaration-safety-scan.ts +102 -0
  117. package/core/shared/types/adaptive.types.ts +109 -0
  118. package/core/shared/types/component-contract.types.ts +110 -0
  119. package/core/shared/types/data-config.types.ts +105 -0
  120. package/core/shared/types/domain.types.ts +6 -0
  121. package/core/shared/types/engine.types.ts +41 -35
  122. package/core/shared/types/manifest.types.ts +55 -32
  123. package/core/shared/types/scope-manifest.types.ts +96 -0
  124. package/core/shared/types/style-config.types.ts +9 -0
  125. package/core/shared/types/ui-config.types.ts +118 -98
  126. package/dist/cli/soma.js +20 -5
  127. package/dist/core/index.cjs +5388 -888
  128. package/dist/types/build/compiler/full-manifest-builder.d.ts +4 -0
  129. package/dist/types/build/compiler/rollup-plugin-soma.d.ts +1 -0
  130. package/dist/types/build/compiler/soma-precompile.d.ts +9 -0
  131. package/dist/types/build/compiler/vite-plugin-soma.d.ts +3 -0
  132. package/dist/types/build/component/package-loader.d.ts +9 -0
  133. package/dist/types/build/eject/apply-eject.d.ts +22 -0
  134. package/dist/types/build/eject/plan-eject.d.ts +32 -0
  135. package/dist/types/client/adaptive/flush-scheduler.d.ts +13 -0
  136. package/dist/types/client/adaptive/hysteresis.d.ts +16 -0
  137. package/dist/types/client/adaptive/index.d.ts +5 -0
  138. package/dist/types/client/adaptive/observer-pool.d.ts +15 -0
  139. package/dist/types/client/base/SomaPageRootBase.d.ts +33 -0
  140. package/dist/types/client/compiler/adaptive-compile.d.ts +26 -0
  141. package/dist/types/client/compiler/manifest-compiler.d.ts +13 -2
  142. package/dist/types/client/component/ai-catalog.d.ts +73 -0
  143. package/dist/types/client/component/component-definition.types.d.ts +54 -0
  144. package/dist/types/client/component/component-expander.d.ts +25 -0
  145. package/dist/types/client/component/component-manager.d.ts +160 -0
  146. package/dist/types/client/component/component-pack.d.ts +90 -0
  147. package/dist/types/client/component/component-registry.d.ts +12 -0
  148. package/dist/types/client/component/pack-styles.d.ts +22 -0
  149. package/dist/types/client/component/scoped-adapter.d.ts +18 -0
  150. package/dist/types/client/component/verify-pack.d.ts +14 -0
  151. package/dist/types/client/data/data-object-resolver.d.ts +71 -0
  152. package/dist/types/client/diagnostics/SomaDiagnostics.d.ts +2 -1
  153. package/dist/types/client/diagnostics/boot-timings.d.ts +30 -0
  154. package/dist/types/client/engine/asset-resolver.d.ts +7 -1
  155. package/dist/types/client/engine/dom-renderer.d.ts +49 -1
  156. package/dist/types/client/engine/emit-event.d.ts +6 -0
  157. package/dist/types/client/engine/event-engine.d.ts +6 -0
  158. package/dist/types/client/engine/render-engine.d.ts +26 -1
  159. package/dist/types/client/engine/runtime-builder.d.ts +7 -0
  160. package/dist/types/client/engine/soma-bootstrap.d.ts +122 -0
  161. package/dist/types/client/infra/http/SomaHttpService.d.ts +2 -0
  162. package/dist/types/client/observability/error-reporter.d.ts +51 -0
  163. package/dist/types/client/parser/adaptive-parser.d.ts +28 -0
  164. package/dist/types/client/parser/data-config-parser.d.ts +34 -0
  165. package/dist/types/client/parser/pipeline-parser.d.ts +2 -0
  166. package/dist/types/client/parser/style-config-parser.d.ts +5 -3
  167. package/dist/types/client/parser/ui-config-parser.d.ts +22 -1
  168. package/dist/types/client/pipes/pipe-registry.d.ts +38 -0
  169. package/dist/types/client/registry/declaration-renderer.d.ts +51 -0
  170. package/dist/types/client/registry/index.d.ts +10 -0
  171. package/dist/types/client/registry/page-lifecycle.d.ts +61 -0
  172. package/dist/types/client/registry/remote-page.d.ts +52 -0
  173. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +16 -0
  174. package/dist/types/client/scheduler/SomaScheduler.d.ts +8 -0
  175. package/dist/types/client/security/attribute-presence.d.ts +7 -0
  176. package/dist/types/client/security/html-sanitizer.d.ts +37 -0
  177. package/dist/types/client/security/url-guard.d.ts +11 -0
  178. package/dist/types/client/theme/theme-engine.d.ts +49 -0
  179. package/dist/types/client/typography/typography-base.d.ts +15 -0
  180. package/dist/types/client/validation/contract-validator.d.ts +2 -0
  181. package/dist/types/index.d.ts +36 -2
  182. package/dist/types/server/api/IService.d.ts +18 -6
  183. package/dist/types/server/host/content-security-policy.d.ts +53 -0
  184. package/dist/types/server/host/csp-nonce-metadata.d.ts +32 -0
  185. package/dist/types/server/host/resolve-host-request-hook.d.ts +5 -0
  186. package/dist/types/server/host/server-page-assets.d.ts +5 -0
  187. package/dist/types/server/index.d.ts +4 -1
  188. package/dist/types/server/registry/api-registry-store.d.ts +141 -0
  189. package/dist/types/server/registry/conditional-object-store.d.ts +27 -0
  190. package/dist/types/server/registry/declaration-precompiler.d.ts +30 -0
  191. package/dist/types/server/registry/in-memory-conditional-object-store.d.ts +8 -0
  192. package/dist/types/server/registry/index.d.ts +29 -0
  193. package/dist/types/server/registry/page-registry-repository.d.ts +58 -0
  194. package/dist/types/server/registry/page-registry-store.d.ts +259 -0
  195. package/dist/types/server/registry/registry-error.d.ts +12 -0
  196. package/dist/types/server/registry/registry-file-lock.d.ts +20 -0
  197. package/dist/types/server/registry/registry-response.d.ts +18 -0
  198. package/dist/types/server/registry/registry-subjects.d.ts +59 -0
  199. package/dist/types/server/registry/registry-write-pipeline.d.ts +48 -0
  200. package/dist/types/server/registry/request-body-limit.d.ts +31 -0
  201. package/dist/types/server/registry/services/apis/Get.d.ts +10 -0
  202. package/dist/types/server/registry/services/apis/List.d.ts +10 -0
  203. package/dist/types/server/registry/services/apis/Register.d.ts +13 -0
  204. package/dist/types/server/registry/services/apis/Unregister.d.ts +12 -0
  205. package/dist/types/server/registry/services/index.d.ts +3 -0
  206. package/dist/types/server/registry/services/pages/Get.d.ts +10 -0
  207. package/dist/types/server/registry/services/pages/List.d.ts +13 -0
  208. package/dist/types/server/registry/services/pages/Register.d.ts +11 -0
  209. package/dist/types/server/registry/services/pages/Rollback.d.ts +9 -0
  210. package/dist/types/server/registry/services/pages/Unregister.d.ts +9 -0
  211. package/dist/types/server/registry/services/service-utils.d.ts +10 -0
  212. package/dist/types/server/registry/validation/compile-gate.d.ts +10 -0
  213. package/dist/types/server/registry/validation/component-existence.d.ts +14 -0
  214. package/dist/types/server/registry/validation/credential-ban.d.ts +15 -0
  215. package/dist/types/server/registry/validation/cross-check.d.ts +16 -0
  216. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +15 -0
  217. package/dist/types/shared/types/adaptive.types.d.ts +88 -0
  218. package/dist/types/shared/types/component-contract.types.d.ts +68 -0
  219. package/dist/types/shared/types/data-config.types.d.ts +81 -0
  220. package/dist/types/shared/types/domain.types.d.ts +6 -0
  221. package/dist/types/shared/types/engine.types.d.ts +6 -0
  222. package/dist/types/shared/types/manifest.types.d.ts +23 -0
  223. package/dist/types/shared/types/scope-manifest.types.d.ts +82 -0
  224. package/dist/types/shared/types/style-config.types.d.ts +8 -0
  225. package/dist/types/shared/types/ui-config.types.d.ts +20 -0
  226. package/global.d.ts +12 -0
  227. package/next.config.js +76 -1
  228. package/package.json +32 -11
  229. package/proxy.ts +62 -0
  230. package/core/client/engine/theme-variables.ts +0 -37
  231. package/dist/tsconfig.types.tsbuildinfo +0 -1
  232. package/dist/types/client/engine/theme-variables.d.ts +0 -3
  233. package/middleware.ts +0 -33
@@ -3,12 +3,40 @@
3
3
  */
4
4
  export * from './client/base/index';
5
5
  export type { SomaAppConfig, SomaPageRoot } from './shared/types/domain.types';
6
- export type { IService } from './server/api/IService';
6
+ export type { IService, SomaServiceRequest } from './server/api/IService';
7
7
  export { SomaBootstrap } from './client/engine/soma-bootstrap';
8
- export type { SomaPageAssets, SomaBootstrapOptions } from './client/engine/soma-bootstrap';
8
+ export type { SomaPageAssets, SomaBootstrapOptions, SomaBootstrapErrorReporting, } from './client/engine/soma-bootstrap';
9
+ export { SomaComponentRegistry } from './client/component/component-registry';
10
+ export { SomaComponentManager } from './client/component/component-manager';
11
+ export { generateAiCatalog, buildCatalogEntry } from './client/component/ai-catalog';
12
+ export type { SomaAiCatalog, SomaAiCatalogEntry, GenerateAiCatalogOptions, } from './client/component/ai-catalog';
13
+ export { SomaPipeRegistry, defaultPipeRegistry } from './client/pipes/pipe-registry';
14
+ export type { SomaPipeFn, SomaPipeContext } from './client/pipes/pipe-registry';
15
+ export { SomaDataObjectResolver, SomaDataCycleError, isSomaMockEnabled, } from './client/data/data-object-resolver';
16
+ export type { SomaDataHttpLike, SomaDataResolverOptions, SomaDataResolveResult, } from './client/data/data-object-resolver';
17
+ export { parseDataConfig, parseDataYaml, parseDataRef, normalizeDataPipeValue, SomaDataConfigError, } from './client/parser/data-config-parser';
18
+ export type { SomaDataRef } from './client/parser/data-config-parser';
19
+ export type { SomaDataConfig, SomaDataObjectConfig, SomaDataSourceConfig, SomaDataFieldConfig, SomaDataFieldRule, SomaDataFieldOption, SomaDataFieldType, SomaDataFieldPermission, SomaDataDicts, } from './shared/types/data-config.types';
20
+ export { deriveTheme, applyTheme, contrastRatio, THEME_SWITCHING_CLASS, } from './client/theme/theme-engine';
21
+ export type { SomaThemeInput, SomaDerivedTheme } from './client/theme/theme-engine';
22
+ export { TYPOGRAPHY_BASE_CSS } from './client/typography/typography-base';
23
+ export { parseAdaptiveConfig, createAdaptiveVocabulary, SomaAdaptiveConfigError, } from './client/parser/adaptive-parser';
24
+ export { compileAdaptive, applyCompiledAdaptive, SOMA_ADAPTIVE_PROFILE_ATTR, } from './client/compiler/adaptive-compile';
25
+ export { SOMA_ADAPTIVE_PROFILES, SOMA_ADAPTIVE_MAX_LADDER, } from './shared/types/adaptive.types';
26
+ export type { SomaAdaptiveProfile, SomaAdaptiveConfig, SomaAdaptiveLevel, SomaAdaptiveLevelKind, SomaAdaptiveLevelDefinition, SomaAdaptiveVocabulary, SomaAdaptiveScopeClass, SomaAdaptiveExecutorConfig, SomaCompiledAdaptive, } from './shared/types/adaptive.types';
27
+ export { createAdaptiveObserverPool, scheduleAdaptiveFlush, resolveTierWithHysteresis, SOMA_DEFAULT_HYSTERESIS, } from './client/adaptive/index';
28
+ export type { SomaAdaptiveObserverPool, SomaAdaptiveSize, SomaAdaptiveSizeCallback, SomaAdaptiveTask, } from './client/adaptive/index';
29
+ export type { SomaComponentDefinition, SomaComponentControllerContext, SomaComponentControllerFactory, } from './client/component/component-definition.types';
30
+ export type { SomaComponentContract, SomaComponentLayer, SomaGeometryFamily, SomaContractProp, SomaContractEmit, SomaContractSlot, } from './shared/types/component-contract.types';
31
+ export { findNestedMutableContractDefault } from './shared/types/component-contract.types';
9
32
  export { createDefaultRuntimeServices } from './client/runtime/SomaRuntimeServices';
10
33
  export type { SomaRuntimeServices } from './client/runtime/SomaRuntimeServices';
11
34
  export { SomaDiagnostics } from './client/diagnostics/SomaDiagnostics';
35
+ export { installSomaErrorReporter } from './client/observability/error-reporter';
36
+ export type { SomaErrorEvent, SomaPageIdentity, SomaErrorReporterOptions, SomaErrorReporterHandle, } from './client/observability/error-reporter';
37
+ export { sanitizeAttributeWrite, hasBlockedScheme, isEventHandlerAttribute } from './client/security/url-guard';
38
+ export { setSomaHtmlSanitizer, resolveSomaHtmlSanitizer, sanitizeSomaHtml, escapeSomaHtml, SOMA_PURIFY_PROFILE, } from './client/security/html-sanitizer';
39
+ export type { SomaHtmlSanitizer, SomaHtmlSanitizeResult } from './client/security/html-sanitizer';
12
40
  export type { SomaDiagnosticsSnapshot } from './client/diagnostics/SomaDiagnostics';
13
41
  export { matchGlobPath } from './client/engine/property-watcher';
14
42
  export { extractConfigFromDomainClass } from './client/parser/annotation-extractor';
@@ -19,6 +47,8 @@ export type { AsyncStateHost } from './client/base/runAsync';
19
47
  export { SomaQualityRegistry } from './client/quality/SomaQualityRegistry';
20
48
  export { SomaTelemetry } from './client/diagnostics/SomaTelemetry';
21
49
  export { setActiveTelemetry, recordMetric } from './client/diagnostics/telemetry-context';
50
+ export { startBootTimings, maybeStartBootTimings, markBootPhase, readBootTimings, resetBootTimings, isBootTimingsEnabled, } from './client/diagnostics/boot-timings';
51
+ export type { SomaBootTimings, SomaBootPhase } from './client/diagnostics/boot-timings';
22
52
  export type { IContainerAdapter, SomaAnchorStats } from './client/container/IContainerAdapter';
23
53
  export { SomaContainerAdapter } from './client/container/SomaContainerAdapter';
24
54
  export { ReactNativeContainerAdapter } from './client/container/ReactNativeContainerAdapter';
@@ -36,3 +66,7 @@ export { resolveHostBootstrapOptions } from './client/host-bridge/resolve-host-b
36
66
  export type { SomaHostRequestContext, SomaHostRequestKind, SomaRequestHook, } from './server/host/resolve-host-request-hook';
37
67
  export type { SomaDomainLoadContext, SomaDomainLoader, SomaDomainLoaderMap, SomaDomainLoaderModule, SomaDomainModule, SomaDomainModuleResolver, } from './client/host-bridge/soma-domain-loaders';
38
68
  export { createSomaDomainLoaderKey, findSomaDomainLoader, loadSomaDomainModuleFromRegistry, } from './client/host-bridge/soma-domain-loaders';
69
+ export { createGeneratedPagePreview, createSomaPageLifecycle, renderPublishedPage, SomaPageLifecycle, type GeneratedPageDeclarations, type GeneratedPagePreviewOptions, type PrecompiledDeclarationAssets, type PreviewHandle, type PreviewObservabilityOptions, type MountedPageInfo, type PublishedPageHandle, type PublishedPageRecord, type RegisterDeclarationOptions, type RenderPublishedPageOptions, type SomaPageLifecycleOptions, } from './client/registry/index';
70
+ export { composeComponentPacks, generatePackCatalog, ComponentPackError, PACK_NAME_PATTERN, type ComposedComponentPacks, type ComposePacksOptions, type SomaComponentPack, type SomaComponentPackStyles, } from './client/component/component-pack';
71
+ export { verifyComponentPack, type VerifyPackOptions } from './client/component/verify-pack';
72
+ export { attachPackStyles, ensurePackBaseStyles, resetPackStyleInjection, type PackStyleOptions, } from './client/component/pack-styles';
@@ -1,4 +1,16 @@
1
- import { NextRequest } from 'next/server';
1
+ /**
2
+ * The service boundary deliberately uses the Web Request surface instead of a
3
+ * concrete NextRequest class. Hosts can resolve soma-core and Next.js through
4
+ * different workspace copies (for example a published AI package may use
5
+ * Next 14 while the host runs Next 16); those classes are structurally the
6
+ * same request at this boundary but are nominally incompatible in TypeScript.
7
+ */
8
+ export interface SomaServiceRequest {
9
+ readonly headers: Headers;
10
+ readonly signal: AbortSignal;
11
+ readonly method: string;
12
+ readonly url: string;
13
+ }
2
14
  /**
3
15
  * SOMA 后端服务接口 —— 宿主项目 `api/service/` 下的服务类可实现此接口。
4
16
  *
@@ -20,9 +32,9 @@ import { NextRequest } from 'next/server';
20
32
  * ```
21
33
  */
22
34
  export interface IService {
23
- get?(req: NextRequest): Promise<Response>;
24
- post?(req: NextRequest): Promise<Response>;
25
- put?(req: NextRequest): Promise<Response>;
26
- patch?(req: NextRequest): Promise<Response>;
27
- delete?(req: NextRequest): Promise<Response>;
35
+ get?(req: SomaServiceRequest): Promise<Response>;
36
+ post?(req: SomaServiceRequest): Promise<Response>;
37
+ put?(req: SomaServiceRequest): Promise<Response>;
38
+ patch?(req: SomaServiceRequest): Promise<Response>;
39
+ delete?(req: SomaServiceRequest): Promise<Response>;
28
40
  }
@@ -0,0 +1,53 @@
1
+ /** 策略档位:off 不发头 / report-only 只上报 / enforce 强制拦截 */
2
+ export type SomaCspMode = 'off' | 'report-only' | 'enforce';
3
+ /** 开关与调参的环境变量(Host 的 .env 里配) */
4
+ export declare const SOMA_CSP_MODE_ENV = "SOMA_CSP";
5
+ export declare const SOMA_CSP_CONNECT_SRC_ENV = "SOMA_CSP_CONNECT_SRC";
6
+ export declare const SOMA_CSP_IMG_SRC_ENV = "SOMA_CSP_IMG_SRC";
7
+ export declare const SOMA_CSP_FRAME_SRC_ENV = "SOMA_CSP_FRAME_SRC";
8
+ export declare const SOMA_CSP_REPORT_URI_ENV = "SOMA_CSP_REPORT_URI";
9
+ /**
10
+ * 中间件把本轮 nonce 放在这个请求头上,页面/组件侧要给动态注入的 `<style>` 打 nonce 时取用。
11
+ * (Next 自身的内联脚本由框架依据**请求上的 CSP 头**自动打 nonce,不需要这个头。)
12
+ */
13
+ export declare const SOMA_CSP_NONCE_HEADER = "x-soma-csp-nonce";
14
+ export interface SomaCspOptions {
15
+ mode: SomaCspMode;
16
+ /** 本轮请求的 nonce;缺省表示不启用 nonce(dev 档用 'unsafe-inline' 顶替) */
17
+ nonce?: string;
18
+ /** dev 档:Next 的 React Refresh 需要 eval 与内联脚本,HMR 需要 ws: */
19
+ dev?: boolean;
20
+ /** 业务追加的 connect-src 源(AI 上游域、埋点域) */
21
+ connectSrc?: string[];
22
+ /** 业务追加的 img-src 源(CDN 图床) */
23
+ imgSrc?: string[];
24
+ /** 允许宿主 iframe 加载的 frame-src 源;缺省为空,策略保持 'none'。 */
25
+ frameSrc?: string[];
26
+ /** 违规上报端点 */
27
+ reportUri?: string;
28
+ }
29
+ /** 生成一次性 nonce(Web Crypto,Edge 与 Node 18+ 都有,不引 node:crypto 以便跑在 Edge 运行时) */
30
+ export declare function createSomaCspNonce(): string;
31
+ /** 环境变量取值归一化:只认三个档位,别的写法一律当 off(配错不该悄悄半开) */
32
+ export declare function resolveSomaCspMode(raw: string | undefined): SomaCspMode;
33
+ /** 从进程环境解析出完整选项(dev 档由 NODE_ENV 判定,不额外开关) */
34
+ export declare function resolveSomaCspOptionsFromEnv(env: Record<string, string | undefined>): SomaCspOptions;
35
+ /**
36
+ * 指令表(有序):key 为指令名,value 为源列表(空数组表示无值指令,如 upgrade-insecure-requests)。
37
+ * 单独导出便于宿主做差异化覆盖与测试逐条断言。
38
+ */
39
+ export declare function buildSomaCspDirectives(options: SomaCspOptions): Array<[string, string[]]>;
40
+ /** 指令表序列化为响应头值 */
41
+ export declare function buildSomaCspHeaderValue(options: SomaCspOptions): string;
42
+ /** 档位对应的响应头名 */
43
+ export declare function somaCspHeaderName(mode: Exclude<SomaCspMode, 'off'>): string;
44
+ export interface SomaCspHeader {
45
+ name: string;
46
+ value: string;
47
+ /** 本轮 nonce(dev 档与 off 档为 undefined) */
48
+ nonce?: string;
49
+ }
50
+ /**
51
+ * 中间件接线点:返回应写的响应头;off 档返回 null(调用方原样放行,零副作用)。
52
+ */
53
+ export declare function createSomaCspHeader(options: SomaCspOptions): SomaCspHeader | null;
@@ -0,0 +1,32 @@
1
+ /** Next `headers()` 的返回形状(只用到 get);单测据此做替身,不必拉起整个框架 */
2
+ export interface SomaCspHeaderBag {
3
+ get(name: string): string | null;
4
+ }
5
+ /**
6
+ * 读取本轮请求的 CSP nonce;CSP 未开或取不到时返回 null。
7
+ *
8
+ * `readHeaders` 由调用方传入(官方 layout 传 `() => headers()`)。做成参数而不是在这里
9
+ * `import { headers } from 'next/headers'`,是为了让这个模块不绑死 Next:中间件与 CSP 策略
10
+ * 模块都能跑在 Edge 运行时,这里也不该成为唯一的框架耦合点。
11
+ *
12
+ * 为什么先判档位再调 readHeaders:Next 的 `headers()` 一被调用,整棵路由树就掉出静态渲染。
13
+ * CSP 缺省是关的(`SOMA_CSP` 未设 = off),绝大多数宿主永远用不到这个 nonce,
14
+ * 不能让他们为一个不会渲染的 meta 丢掉静态化。
15
+ */
16
+ export declare function readSomaCspNonce(readHeaders: () => SomaCspHeaderBag, env?: Record<string, string | undefined>): string | null;
17
+ /**
18
+ * 供 Next `generateMetadata()` 展开的片段:CSP 开且拿到 nonce 时产出
19
+ * `{ other: { 'csp-nonce': '<r>' } }`(渲染为 `<meta name="csp-nonce" content="<r>">`),
20
+ * 否则产出空对象(缺省行为一字不变)。
21
+ *
22
+ * 走 Metadata API 的 `other` 而不是在 layout 里手写 `<head><meta/></head>`:
23
+ * Next App Router 要求根布局的头部标签由 Metadata API 产出,手写 `<head>` 会与框架
24
+ * 自己的头部注入打架。
25
+ */
26
+ export declare function somaCspNonceMetadata(readHeaders: () => SomaCspHeaderBag, env?: Record<string, string | undefined>): {
27
+ other?: Record<string, string>;
28
+ };
29
+ /** Next 15+ 的 `headers()` 为异步 API;CSP 关闭时仍不触发请求态读取。 */
30
+ export declare function somaCspNonceMetadataAsync(readHeaders: () => Promise<SomaCspHeaderBag>, env?: Record<string, string | undefined>): Promise<{
31
+ other?: Record<string, string>;
32
+ }>;
@@ -7,6 +7,11 @@ export interface SomaHostRequestContext {
7
7
  /**
8
8
  * Generic server ingress extension. soma-core does not know authentication,
9
9
  * authorization, Admin, or any business application.
10
+ *
11
+ * The hook receives the same Request object later dispatched to the Host
12
+ * service. A Host may therefore normalize or add server-only request headers
13
+ * before returning undefined. Returning a Response still short-circuits the
14
+ * request. Secrets must never be copied into a response or client config.
10
15
  */
11
16
  export type SomaRequestHook = (request: Request, context: SomaHostRequestContext) => Response | undefined | Promise<Response | undefined>;
12
17
  export interface SomaRequestHookModule {
@@ -8,6 +8,11 @@ export interface SomaServerPageAssets {
8
8
  ui: string;
9
9
  event: string;
10
10
  styleYaml: string;
11
+ /**
12
+ * 数据对象层声明(*_data.yaml,五件套可选件)。
13
+ * 按约定发现 data/<page>_data.yaml(回退 ui/ 同目录);无文件时该字段缺省,零影响。
14
+ */
15
+ dataYaml?: string;
11
16
  localeYaml: string;
12
17
  appConfigYaml: string;
13
18
  includes?: Record<string, string>;
@@ -10,12 +10,15 @@
10
10
  import 'server-only';
11
11
  export { ServerFileCache } from './infra/cache/ServerFileCache';
12
12
  export { withSomaServerRequestContext, type SomaServerRequestContextOptions, } from './infra/http/soma-server-request-context';
13
- export type { IService } from './api/IService';
13
+ export type { IService, SomaServiceRequest } from './api/IService';
14
14
  export { loadHostService } from './api/load-host-service';
15
15
  export { resolveServiceFilePath, toPascalCase } from './api/service-path';
16
16
  export { invokeHostRequestHook } from './host/invoke-host-request-hook';
17
17
  export { resolveHostRequestHook, type SomaHostRequestContext, type SomaHostRequestKind, type SomaRequestHook, } from './host/resolve-host-request-hook';
18
+ export { createSomaCspHeader, createSomaCspNonce, buildSomaCspDirectives, buildSomaCspHeaderValue, resolveSomaCspMode, resolveSomaCspOptionsFromEnv, somaCspHeaderName, SOMA_CSP_MODE_ENV, SOMA_CSP_CONNECT_SRC_ENV, SOMA_CSP_IMG_SRC_ENV, SOMA_CSP_FRAME_SRC_ENV, SOMA_CSP_REPORT_URI_ENV, SOMA_CSP_NONCE_HEADER, type SomaCspMode, type SomaCspOptions, type SomaCspHeader, } from './host/content-security-policy';
19
+ export { readSomaCspNonce, somaCspNonceMetadata, type SomaCspHeaderBag, } from './host/csp-nonce-metadata';
18
20
  export { loadSomaServerPageAssets, SomaPageAssetError, type SomaServerPageAssets, type SomaPageAssetLoadProfile, } from './host/server-page-assets';
21
+ export { loadComponentPackage, loadComponentPackages, SomaComponentPackageError, } from '../build/component/package-loader';
19
22
  export { setSomaDb, getSomaDb, resetSomaDb, createSomaDbSingleton, registerSomaDbProvider, disconnectSomaDb, withSomaDb, type ISomaDbProvider, } from './infra/db/soma-db';
20
23
  export { SomaQuery } from './infra/db/query/SomaQuery';
21
24
  export type { SomaBaseMapper } from './infra/db/mapper/SomaBaseMapper';
@@ -0,0 +1,141 @@
1
+ import type { SomaDataFieldConfig } from '../../shared/types/data-config.types';
2
+ import { RegistryError } from './registry-error';
3
+ /** 注册名约束:与页面名同形(可直接用作文件名与 URL 片段) */
4
+ export declare const API_NAME_PATTERN: RegExp;
5
+ /** 应用命名空间约束:与页面表同形 */
6
+ export declare const API_APP_PATTERN: RegExp;
7
+ /** 允许登记的 HTTP 方法(白名单;登记不是代理,方法只用于描述与自查) */
8
+ export declare const API_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
9
+ export type ApiMethod = (typeof API_METHODS)[number];
10
+ /** 单条 API 记录的体积上限:字典再大也不该有 64KB */
11
+ export declare const API_RECORD_MAX_BYTES: number;
12
+ export declare const ApiRegistryErrorCodes: {
13
+ /** 注册名非法 */
14
+ readonly API_NAME_INVALID: 4531;
15
+ /** 记录缺必填字段 / 字段类型不对 / 体积超限 */
16
+ readonly API_RECORD_INVALID: 4532;
17
+ /** 接口不存在 */
18
+ readonly API_NOT_FOUND: 4533;
19
+ /** 登记内容里出现凭据类字段(鉴权归宿主运行时,注册表不许持有) */
20
+ readonly API_CREDENTIAL_FORBIDDEN: 4534;
21
+ };
22
+ export type ApiRegistryErrorCode = (typeof ApiRegistryErrorCodes)[keyof typeof ApiRegistryErrorCodes];
23
+ export declare class ApiRegistryError extends RegistryError {
24
+ readonly code: ApiRegistryErrorCode;
25
+ constructor(code: ApiRegistryErrorCode, message: string);
26
+ }
27
+ /** 存储单元:一个接口的当下描述 */
28
+ export interface ApiRecord {
29
+ /** 注册名(页面与人引用它的稳定标识) */
30
+ name: string;
31
+ /** HTTP 方法 */
32
+ method: ApiMethod;
33
+ /** 后端接口路径——**交叉校验的匹配键**,必须以 / 开头 */
34
+ path: string;
35
+ /** 一句话说明这个接口给什么 */
36
+ description?: string;
37
+ /** 字段字典(字段名 → 条目),复用数据对象层词汇;生成链据此绑字段 */
38
+ fields?: Record<string, SomaDataFieldConfig>;
39
+ /** 应用命名空间(缺省 'default') */
40
+ app: string;
41
+ /** 标签(目录化 / 过滤) */
42
+ tags: string[];
43
+ createdAt: number;
44
+ updatedAt: number;
45
+ /** 操作者标识(可选) */
46
+ operator?: string;
47
+ }
48
+ export interface ApiRegisterInput {
49
+ method?: unknown;
50
+ path?: unknown;
51
+ description?: unknown;
52
+ fields?: unknown;
53
+ app?: unknown;
54
+ tags?: unknown;
55
+ operator?: unknown;
56
+ }
57
+ export interface ApiRegistryListOptions {
58
+ /** 只看某应用命名空间 */
59
+ app?: string;
60
+ /** 关键词:命中注册名 / 路径 / 描述(不区分大小写) */
61
+ keyword?: string;
62
+ offset?: number;
63
+ limit?: number;
64
+ }
65
+ export interface ApiRegistryListItem {
66
+ name: string;
67
+ method: ApiMethod;
68
+ path: string;
69
+ app: string;
70
+ tags: string[];
71
+ description?: string;
72
+ /** 字段字典条数(清单不返回字典本体,取详情再拿) */
73
+ fieldCount: number;
74
+ updatedAt: number;
75
+ }
76
+ export interface ApiRegistryListResult {
77
+ apis: ApiRegistryListItem[];
78
+ total: number;
79
+ }
80
+ export interface ApiRegistryStoreOptions {
81
+ /** 持久化目录(每接口一个 <name>.json),默认 data/soma-runtime/apis */
82
+ baseDir?: string;
83
+ /** 时钟注入点,默认 Date.now;测试传确定性时钟 */
84
+ now?: () => number;
85
+ }
86
+ export declare class ApiRegistryStore {
87
+ private readonly baseDir;
88
+ private readonly now;
89
+ /** 读缓存:注册名 → { 记录, 落盘指纹 }。指纹变了就重读(与页面表同口径) */
90
+ private readonly cache;
91
+ constructor(options?: ApiRegistryStoreOptions);
92
+ storageDirectory(): string;
93
+ /** 注册(upsert):名字已存在即更新描述,返回记录与 created 位 */
94
+ register(name: string, input: ApiRegisterInput): {
95
+ record: ApiRecord;
96
+ created: boolean;
97
+ };
98
+ /** 取一条;不存在报 API_NOT_FOUND */
99
+ get(name: string): ApiRecord;
100
+ /** 注销:删掉记录(接口描述不是可回滚资产,不留墓碑);不存在报 API_NOT_FOUND */
101
+ unregister(name: string): ApiRecord;
102
+ /** 清单(按注册名排序,分页协议 { apis, total }) */
103
+ list(options?: ApiRegistryListOptions): ApiRegistryListResult;
104
+ /**
105
+ * 已注册的接口路径集合——交叉校验的判据来源。
106
+ * 路径是匹配键而非注册名:页面声明里写的是路径。
107
+ *
108
+ * 成本:每次调用扫一遍目录并 stat 每条记录(内容没变就命中缓存,不重复解析)。
109
+ * 刻意不给这个集合再加一层缓存——它只在**页面注册**这条低频路径上被调用,
110
+ * 而一层"目录级"缓存必须靠目录 mtime 失效,那在原地改写某条记录时不会变,
111
+ * 会把白名单卡在旧值上:判据宁可每次重算,也不能有可能是错的。
112
+ */
113
+ registeredPaths(): ReadonlySet<string>;
114
+ private names;
115
+ private read;
116
+ private save;
117
+ /** 缓存上限:一条记录很小,但仓库可以很大——不留无上限的 Map(2GB 机器纪律) */
118
+ private trimCache;
119
+ private stampOf;
120
+ private fileOf;
121
+ }
122
+ export declare function assertApiName(name: unknown): string;
123
+ interface NormalizedApiInput {
124
+ method: ApiMethod;
125
+ path: string;
126
+ description?: string;
127
+ fields?: Record<string, SomaDataFieldConfig>;
128
+ app: string;
129
+ tags: string[];
130
+ operator?: string;
131
+ }
132
+ /** 结构校验 + 凭据禁令:两道一起过,拒绝时点名违规项 */
133
+ export declare function normalizeApiInput(input: ApiRegisterInput): NormalizedApiInput;
134
+ /** 存量记录归一化:补 app/tags 缺省值,名字以文件名为准 */
135
+ export declare function normalizeStoredApiRecord(raw: Record<string, unknown>, name: string): ApiRecord;
136
+ export declare function cloneApiRecord(record: ApiRecord): ApiRecord;
137
+ /** 共享实例:baseDir 可用环境变量 SOMA_API_REGISTRY_DIR 覆盖(默认 data/soma-runtime/apis) */
138
+ export declare function getApiRegistryStore(): ApiRegistryStore;
139
+ /** 替换 / 复位共享实例(测试用;不传参即清空,下次访问按当前环境重建) */
140
+ export declare function resetApiRegistryStore(store?: ApiRegistryStore): void;
141
+ export {};
@@ -0,0 +1,27 @@
1
+ export type ObjectRevision = string;
2
+ export interface ObjectSnapshot {
3
+ readonly key: string;
4
+ readonly text: string;
5
+ readonly revision: ObjectRevision;
6
+ }
7
+ export type WriteCondition = {
8
+ readonly kind: 'absent';
9
+ } | {
10
+ readonly kind: 'revision';
11
+ readonly revision: ObjectRevision;
12
+ };
13
+ export type ConditionalWriteResult = {
14
+ readonly committed: true;
15
+ readonly revision: ObjectRevision;
16
+ } | {
17
+ readonly committed: false;
18
+ };
19
+ /**
20
+ * 对象存储最小一致性契约:点读必须 read-after-write,revision/ETag 是不透明值。
21
+ * S3 对应 If-None-Match:* / If-Match:<etag>;数据库对应版本列条件 UPDATE。
22
+ */
23
+ export interface ConditionalObjectStore {
24
+ read(key: string): Promise<ObjectSnapshot | null>;
25
+ list(prefix: string): Promise<readonly string[]>;
26
+ compareAndSet(key: string, expected: WriteCondition, text: string): Promise<ConditionalWriteResult>;
27
+ }
@@ -0,0 +1,30 @@
1
+ import type { PageRegistryDeclaration } from './page-registry-store';
2
+ /**
3
+ * 编译器版本。与 soma-core 的包版本对齐——语义变更必然伴随版本号变化,
4
+ * 拿它当"这份缓存还能不能用"的判据,比自己再造一套指纹可靠。
5
+ *
6
+ * 读不到版本时**故意返回一个永不相等的值**(带进程随机后缀),而不是回落成 '0'。
7
+ * 回落成固定值会让版本闸恒真——库里的旧产物照样被采用,那正是这道闸要防的事。
8
+ * 失败方向必须是"不用缓存",不是"照用"。
9
+ */
10
+ export declare const DECLARATION_COMPILER_VERSION: string;
11
+ /** 落库的预编译产物(全部可选:哪一段编译不出来就不带哪一段) */
12
+ export interface CompiledDeclaration {
13
+ compilerVersion: string;
14
+ uiConfig?: unknown;
15
+ eventConfig?: unknown;
16
+ triggerConfig?: unknown;
17
+ timerConfig?: unknown;
18
+ styleConfig?: unknown;
19
+ dataConfig?: unknown;
20
+ }
21
+ /**
22
+ * 把声明编译成运行时可直接消费的配置对象。
23
+ * 任何一段失败都只是少一段缓存,不抛。
24
+ */
25
+ export declare function precompileDeclaration(declaration: PageRegistryDeclaration): CompiledDeclaration | null;
26
+ /**
27
+ * 消费端的版本闸:编译器版本对不上就整份丢弃。
28
+ * 这是"缓存不是真理"那条纪律的执行点。
29
+ */
30
+ export declare function isCompiledUsable(compiled: CompiledDeclaration | null | undefined, runtimeVersion?: string): boolean;
@@ -0,0 +1,8 @@
1
+ import type { ConditionalObjectStore, ConditionalWriteResult, ObjectSnapshot, WriteCondition } from './conditional-object-store';
2
+ /** 可运行参考与测试后端;单进程内串行比较并交换,语义等同远端原子条件写。 */
3
+ export declare class InMemoryConditionalObjectStore implements ConditionalObjectStore {
4
+ private readonly objects;
5
+ read(key: string): Promise<ObjectSnapshot | null>;
6
+ list(prefix: string): Promise<readonly string[]>;
7
+ compareAndSet(key: string, expected: WriteCondition, text: string): Promise<ConditionalWriteResult>;
8
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 运行时注册中心(服务端桶)。
3
+ *
4
+ * REQ-002:注册/校验/存储/生命周期归 soma-core(能力),谁可注册、注册什么、
5
+ * 挂在哪归业务应用(组织)。soma-ai 只是本模块的一个普通调用方。
6
+ * HTTP 端点(/api/soma-registry/*)由 Host 内置路由直接分发,宿主零接线。
7
+ *
8
+ * 刻意不 import 'server-only':本桶会被宿主服务加载器(jiti)与单测在纯 Node
9
+ * 语境加载,server-only 在那里解析不了(soma-ai HttpGuards 同款实弹教训)。
10
+ * 客户端不引本桶由 eslint 客户端边界规则看守。
11
+ */
12
+ export { PageRegistryStore, PageRegistryError, PageRegistryErrorCodes, PAGE_NAME_PATTERN, PAGE_APP_PATTERN, PAGE_DECLARATION_MAX_BYTES, declarationByteSize, getPageRegistryStore, resetPageRegistryStore, } from './page-registry-store';
13
+ export type { PageRegistryDeclaration, PageRegistryErrorCode, PageRegistryListItem, PageRegistryListOptions, PageRegistryListResult, PageRegistryMeta, PageRegistryPublishOptions, PageRegistryStatus, PageRegistryStoreOptions, PageRegistryWriteOptions, PageVersionRecord, } from './page-registry-store';
14
+ export { ConditionalPageRegistryRepository, FilePageRegistryRepository, getPageRegistryRepository, InMemoryConditionalObjectStore, setPageRegistryRepository, useConditionalPageRegistryStore, type PageRegistryRepository, type PublishResult, type RollbackResult, } from './page-registry-repository';
15
+ export type { ConditionalObjectStore, ConditionalWriteResult, ObjectRevision, ObjectSnapshot, WriteCondition, } from './conditional-object-store';
16
+ export { pageRegistryErrorResponse, pageRegistrySuccessResponse, createRegistryResponseBody, PAGE_REGISTRY_SCHEMA_VERSION, type RegistryResponseBody, } from './registry-response';
17
+ export { authorizePageRegistryWrite, isRegistryReadPrivileged, resolveWriteSubject, runPageRegistryWrite, resetRegistryWriteRateLimit, REGISTRY_OPERATOR_HEADER, type PageRegistryWriteContext, type RegistryWriteRequestLike, } from './registry-write-pipeline';
18
+ export { hasConfiguredCredentials, isRegistryDemoOpenDoor, looksLikeProduction, parseRegistryCredentials, resetRegistrySubjectCache, resolveRegistrySubject, subjectHasScope, timingSafeStringEqual, REGISTRY_OPEN_ENV, REGISTRY_TOKEN_ENV, REGISTRY_TOKENS_ENV, type RegistryScope, type RegistrySubject, type SubjectRequestLike, } from './registry-subjects';
19
+ export { setRegistryLockBackend, withRegistryLock, writeFileAtomic, type RegistryLockBackend, } from './registry-file-lock';
20
+ export { readJsonWithLimit, RequestBodyTooLargeError, REGISTRY_WRITE_MAX_BYTES, type BodyLimitedRequest, } from './request-body-limit';
21
+ export { precompileDeclaration, isCompiledUsable, DECLARATION_COMPILER_VERSION, type CompiledDeclaration, } from './declaration-precompiler';
22
+ export { scanDeclarationSafety, type ScannableDeclaration } from './validation/declaration-safety-scan';
23
+ export { RegistryError } from './registry-error';
24
+ export { ApiRegistryStore, ApiRegistryError, ApiRegistryErrorCodes, API_NAME_PATTERN, API_APP_PATTERN, API_METHODS, API_RECORD_MAX_BYTES, getApiRegistryStore, resetApiRegistryStore, type ApiMethod, type ApiRecord, type ApiRegisterInput, type ApiRegistryErrorCode, type ApiRegistryListItem, type ApiRegistryListOptions, type ApiRegistryListResult, type ApiRegistryStoreOptions, } from './api-registry-store';
25
+ export { scanCredentialLeak, type CredentialScannable } from './validation/credential-ban';
26
+ export { dryRunCompile, type CompilableDeclaration } from './validation/compile-gate';
27
+ export { collectReferencedComponents, scanUnknownComponents, setKnownComponentsResolver, type KnownComponentsResolver, } from './validation/component-existence';
28
+ export { collectDeclaredApiPaths, crossCheckDeclaredApis, normalizeApiPath, setRegisteredPathsResolver, type RegisteredPathsResolver, } from './validation/cross-check';
29
+ export { resolveRegistryService } from './services/index';
@@ -0,0 +1,58 @@
1
+ import { type PageRegistryDeclaration, type PageRegistryListOptions, type PageRegistryListResult, type PageRegistryMeta, type PageRegistryPublishOptions, type PageRegistryStatus, type PageRegistryWriteOptions, type PageVersionRecord } from './page-registry-store';
2
+ import { type PageRegistryStore } from './page-registry-store';
3
+ import type { ConditionalObjectStore } from './conditional-object-store';
4
+ export interface PublishResult {
5
+ record: PageVersionRecord;
6
+ }
7
+ export interface RollbackResult {
8
+ record: PageVersionRecord;
9
+ }
10
+ /** API 的唯一仓储门面;全部方法异步,后端可为共享文件系统或对象存储 CAS。 */
11
+ export interface PageRegistryRepository {
12
+ publish(name: string, declaration: unknown, options?: PageRegistryStatus | PageRegistryPublishOptions): Promise<PublishResult>;
13
+ get(name: string, version?: number): Promise<PageVersionRecord>;
14
+ list(options?: PageRegistryListOptions): Promise<PageRegistryListResult>;
15
+ rollback(name: string, version: number, options?: PageRegistryWriteOptions): Promise<RollbackResult>;
16
+ archive(name: string, options?: PageRegistryWriteOptions): Promise<PageVersionRecord>;
17
+ }
18
+ /**
19
+ * 默认共享 FS 适配器。所有写动作共用一把页面级 hardlink 锁,
20
+ * 跨文件的业务判断与提交不会互相穿透。
21
+ */
22
+ export declare class FilePageRegistryRepository implements PageRegistryRepository {
23
+ private readonly injectedPages?;
24
+ constructor(injectedPages?: PageRegistryStore | undefined);
25
+ publish(name: string, declaration: unknown, options?: PageRegistryStatus | PageRegistryPublishOptions): Promise<PublishResult>;
26
+ get(name: string, version?: number): Promise<PageVersionRecord>;
27
+ list(options?: PageRegistryListOptions): Promise<PageRegistryListResult>;
28
+ rollback(name: string, version: number, options?: PageRegistryWriteOptions): Promise<RollbackResult>;
29
+ archive(name: string, options?: PageRegistryWriteOptions): Promise<PageVersionRecord>;
30
+ private pages;
31
+ private assertSharedDirectory;
32
+ }
33
+ /** 单页聚合 CAS:整页版本数组在同一个对象中提交,消除跨键检查—写入竞态。 */
34
+ export declare class ConditionalPageRegistryRepository implements PageRegistryRepository {
35
+ private readonly objects;
36
+ private readonly options;
37
+ constructor(objects: ConditionalObjectStore, options?: {
38
+ prefix?: string;
39
+ now?: () => number;
40
+ maxAttempts?: number;
41
+ });
42
+ publish(name: string, declaration: unknown, options?: PageRegistryStatus | PageRegistryPublishOptions): Promise<PublishResult>;
43
+ get(name: string, version?: number): Promise<PageVersionRecord>;
44
+ list(options?: PageRegistryListOptions): Promise<PageRegistryListResult>;
45
+ rollback(name: string, version: number, options?: PageRegistryWriteOptions): Promise<RollbackResult>;
46
+ archive(name: string, options?: PageRegistryWriteOptions): Promise<PageVersionRecord>;
47
+ private mutate;
48
+ private readAggregate;
49
+ private keyOf;
50
+ private prefix;
51
+ private now;
52
+ }
53
+ export declare function getPageRegistryRepository(): PageRegistryRepository;
54
+ export declare function setPageRegistryRepository(repository: PageRegistryRepository | null): void;
55
+ export declare function useConditionalPageRegistryStore(store: ConditionalObjectStore, options?: ConstructorParameters<typeof ConditionalPageRegistryRepository>[1]): ConditionalPageRegistryRepository;
56
+ export type { ConditionalObjectStore } from './conditional-object-store';
57
+ export { InMemoryConditionalObjectStore } from './in-memory-conditional-object-store';
58
+ export type { PageRegistryDeclaration, PageRegistryMeta };