@bleedingdev/modern-js-utils 3.5.0-ultramodern.10 → 3.5.0-ultramodern.101

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 (57) hide show
  1. package/dist/cjs/cli/modulePath.js +12 -3
  2. package/dist/cjs/universal/backend-federation-contract/build-artifact.js +185 -0
  3. package/dist/cjs/universal/backend-federation-contract/constants.js +92 -0
  4. package/dist/cjs/universal/backend-federation-contract/delivery-unit.js +130 -0
  5. package/dist/cjs/universal/backend-federation-contract/index.js +137 -0
  6. package/dist/cjs/universal/backend-federation-contract/metadata.js +133 -0
  7. package/dist/cjs/universal/backend-federation-contract/types.js +18 -0
  8. package/dist/cjs/universal/backend-federation-contract/validation-core.js +85 -0
  9. package/dist/cjs/universal/index.js +51 -6
  10. package/dist/cjs/universal/surface-resolution/env-static-provider.js +318 -0
  11. package/dist/cjs/universal/surface-resolution/index.js +69 -0
  12. package/dist/cjs/universal/surface-resolution/surface-ref.js +132 -0
  13. package/dist/cjs/universal/surface-resolution/types.js +18 -0
  14. package/dist/cjs/universal/surface-resolution/validation.js +202 -0
  15. package/dist/esm/cli/modulePath.mjs +12 -3
  16. package/dist/esm/universal/backend-federation-contract/build-artifact.mjs +135 -0
  17. package/dist/esm/universal/backend-federation-contract/constants.mjs +18 -0
  18. package/dist/esm/universal/backend-federation-contract/delivery-unit.mjs +74 -0
  19. package/dist/esm/universal/backend-federation-contract/index.mjs +5 -0
  20. package/dist/esm/universal/backend-federation-contract/metadata.mjs +80 -0
  21. package/dist/esm/universal/backend-federation-contract/types.mjs +0 -0
  22. package/dist/esm/universal/backend-federation-contract/validation-core.mjs +29 -0
  23. package/dist/esm/universal/index.mjs +2 -0
  24. package/dist/esm/universal/surface-resolution/env-static-provider.mjs +274 -0
  25. package/dist/esm/universal/surface-resolution/index.mjs +3 -0
  26. package/dist/esm/universal/surface-resolution/surface-ref.mjs +88 -0
  27. package/dist/esm/universal/surface-resolution/types.mjs +0 -0
  28. package/dist/esm/universal/surface-resolution/validation.mjs +155 -0
  29. package/dist/esm-node/cli/modulePath.mjs +12 -3
  30. package/dist/esm-node/universal/backend-federation-contract/build-artifact.mjs +136 -0
  31. package/dist/esm-node/universal/backend-federation-contract/constants.mjs +19 -0
  32. package/dist/esm-node/universal/backend-federation-contract/delivery-unit.mjs +75 -0
  33. package/dist/esm-node/universal/backend-federation-contract/index.mjs +6 -0
  34. package/dist/esm-node/universal/backend-federation-contract/metadata.mjs +81 -0
  35. package/dist/esm-node/universal/backend-federation-contract/types.mjs +1 -0
  36. package/dist/esm-node/universal/backend-federation-contract/validation-core.mjs +30 -0
  37. package/dist/esm-node/universal/index.mjs +2 -0
  38. package/dist/esm-node/universal/surface-resolution/env-static-provider.mjs +275 -0
  39. package/dist/esm-node/universal/surface-resolution/index.mjs +4 -0
  40. package/dist/esm-node/universal/surface-resolution/surface-ref.mjs +89 -0
  41. package/dist/esm-node/universal/surface-resolution/types.mjs +1 -0
  42. package/dist/esm-node/universal/surface-resolution/validation.mjs +156 -0
  43. package/dist/types/import.d.ts +1 -1
  44. package/dist/types/universal/backend-federation-contract/build-artifact.d.ts +9 -0
  45. package/dist/types/universal/backend-federation-contract/constants.d.ts +14 -0
  46. package/dist/types/universal/backend-federation-contract/delivery-unit.d.ts +9 -0
  47. package/dist/types/universal/backend-federation-contract/index.d.ts +7 -0
  48. package/dist/types/universal/backend-federation-contract/metadata.d.ts +7 -0
  49. package/dist/types/universal/backend-federation-contract/types.d.ts +60 -0
  50. package/dist/types/universal/backend-federation-contract/validation-core.d.ts +8 -0
  51. package/dist/types/universal/index.d.ts +2 -0
  52. package/dist/types/universal/surface-resolution/env-static-provider.d.ts +107 -0
  53. package/dist/types/universal/surface-resolution/index.d.ts +4 -0
  54. package/dist/types/universal/surface-resolution/surface-ref.d.ts +72 -0
  55. package/dist/types/universal/surface-resolution/types.d.ts +102 -0
  56. package/dist/types/universal/surface-resolution/validation.d.ts +53 -0
  57. package/package.json +8 -9
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Surface-resolution record + provider SPI (MV-G25b/c).
3
+ *
4
+ * Contract: `docs/super-app-rfc-adr/RESOLUTION-0001-surface-discovery-record.md`.
5
+ * Discovery answers a SurfaceRef with exactly ONE {@link ResolvedDeliveryUnit}
6
+ * — never a bare URL, never a partial set of locations — or a typed
7
+ * {@link DiscoveryError} (§2.4: discovery errors are expected states, not
8
+ * exceptions).
9
+ *
10
+ * Atomicity invariant (ADR-0019): `buildMarker` / `sourceRevision` /
11
+ * `baselineCohortId` live once on the record; a {@link ResolvedSurface}
12
+ * carries no marker of its own, so mixing locations from two build markers is
13
+ * structurally unrepresentable.
14
+ */
15
+ import type { DeliveryUnitIdentity } from '../backend-federation-contract/types';
16
+ import type { ParsedSurfaceRef } from './surface-ref';
17
+ export type ResolvedSurfaceLocationPlatform = 'browser-mf-manifest' | 'node-mf-manifest' | 'http-api' | 'cloudflare-service-binding';
18
+ /**
19
+ * One platform address for a surface, discriminated on `platform` so each
20
+ * platform carries only the address shape its execution adapter can load.
21
+ */
22
+ export type ResolvedSurfaceLocation = {
23
+ platform: 'browser-mf-manifest';
24
+ manifestUrl: string;
25
+ } | {
26
+ /** Backend `backend-mf-manifest.json` URL or filesystem path. */
27
+ platform: 'node-mf-manifest';
28
+ manifestRef: string;
29
+ } | {
30
+ platform: 'http-api';
31
+ baseUrl: string;
32
+ prefix: string;
33
+ } | {
34
+ platform: 'cloudflare-service-binding';
35
+ serviceBinding: string;
36
+ dispatchNamespace?: string;
37
+ };
38
+ export type ResolvedSurfaceKind = 'component' | 'route' | 'api' | 'backend';
39
+ /**
40
+ * A resolved surface. It carries NO build marker of its own: the marker lives
41
+ * once on the {@link ResolvedDeliveryUnit} (ADR-0019 structural atomicity).
42
+ */
43
+ export type ResolvedSurface = {
44
+ surfaceId: string;
45
+ kind: ResolvedSurfaceKind;
46
+ locations: ResolvedSurfaceLocation[];
47
+ /**
48
+ * The external major (ADR-0020) this materialization serves. Present exactly
49
+ * when the record answers a versioned SurfaceRef (`…@vN`): the locations are
50
+ * the major-specific materialization, never the unversioned addresses.
51
+ */
52
+ servedMajor?: number;
53
+ };
54
+ export type CompatibilityStatus = 'compatible' | 'incompatible' | 'degraded';
55
+ /** The resolver's verdict, not the consumer's guess (RESOLUTION-0001 §2.1). */
56
+ export type CompatibilityVerdict = {
57
+ status: CompatibilityStatus;
58
+ /** Baseline cohort id the verdict was computed against. */
59
+ baselineCohortId: string;
60
+ reason?: string;
61
+ };
62
+ /**
63
+ * Atomic resolution result: every platform location for the unit, resolved
64
+ * together against ONE `buildMarker` / `sourceRevision`. There is no partial
65
+ * variant; a resolver returns this whole record or a {@link DiscoveryError}.
66
+ */
67
+ export type ResolvedDeliveryUnit = DeliveryUnitIdentity & {
68
+ baselineCohortId: string;
69
+ surfaces: ResolvedSurface[];
70
+ compatibility: CompatibilityVerdict;
71
+ };
72
+ export type DiscoveryErrorCode = 'unknown-unit' | 'unknown-surface' | 'major-not-published' | 'identity-mismatch' | 'stale-record' | 'provider-unavailable';
73
+ export type DiscoveryError = {
74
+ code: DiscoveryErrorCode;
75
+ /** Canonical string form of the SurfaceRef being resolved. */
76
+ ref: string;
77
+ message: string;
78
+ details?: Record<string, unknown>;
79
+ };
80
+ export type DiscoveryResult = {
81
+ ok: true;
82
+ unit: ResolvedDeliveryUnit;
83
+ } | {
84
+ ok: false;
85
+ error: DiscoveryError;
86
+ };
87
+ /**
88
+ * Environment identity. Providers are selected per environment, not per
89
+ * surface: one environment resolves all surfaces of a unit through the same
90
+ * provider chain.
91
+ */
92
+ export type EnvironmentId = string;
93
+ export type SurfaceResolutionProvider = {
94
+ /** Stable provider name (e.g. `env-static`), used in error details. */
95
+ name: string;
96
+ /**
97
+ * Resolve a SurfaceRef in an environment to one complete record or one
98
+ * typed error. Must never return a partial record and must never mix
99
+ * locations from different build markers.
100
+ */
101
+ resolve(ref: ParsedSurfaceRef, env: EnvironmentId): DiscoveryResult | Promise<DiscoveryResult>;
102
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Identity / compatibility validation helpers for resolved delivery units
3
+ * (MV-G25c). Runtime checks for records that crossed a serialization boundary;
4
+ * within TypeScript the atomicity invariant is already structural.
5
+ */
6
+ import { type ParsedSurfaceRef } from './surface-ref';
7
+ import type { DiscoveryError, DiscoveryErrorCode, ResolvedDeliveryUnit, ResolvedSurface } from './types';
8
+ export type ResolvedDeliveryUnitIssue = {
9
+ path: string;
10
+ message: string;
11
+ };
12
+ export type ResolvedDeliveryUnitValidationResult = {
13
+ ok: boolean;
14
+ issues: ResolvedDeliveryUnitIssue[];
15
+ };
16
+ /** Build a typed {@link DiscoveryError} for a reference. */
17
+ export declare function createDiscoveryError(code: DiscoveryErrorCode, ref: ParsedSurfaceRef | string, message: string, details?: Record<string, unknown>): DiscoveryError;
18
+ /**
19
+ * Validate the structural invariants of a {@link ResolvedDeliveryUnit}:
20
+ * non-empty identity root, a well-formed compatibility verdict (valid status,
21
+ * computed against the record-level baseline cohort), and per-surface
22
+ * completeness (valid unique surface ids, valid kind, at least one location,
23
+ * no duplicate platform entries, and every discriminant + required address
24
+ * field per location platform). There is no partial-success shape: any issue
25
+ * means the record is not a valid resolution.
26
+ *
27
+ * Total: never throws, even for records that crossed a serialization boundary
28
+ * with missing or malformed nested objects — every defect is a typed issue.
29
+ */
30
+ export declare function validateResolvedDeliveryUnit(unit: ResolvedDeliveryUnit): ResolvedDeliveryUnitValidationResult;
31
+ /**
32
+ * Select the surface a {@link ParsedSurfaceRef} points at within one record.
33
+ * `unknown-unit` when the record is for a different unit, `unknown-surface`
34
+ * when the unit does not publish the surface.
35
+ */
36
+ export declare function selectResolvedSurface(unit: ResolvedDeliveryUnit, ref: ParsedSurfaceRef): {
37
+ ok: true;
38
+ surface: ResolvedSurface;
39
+ } | {
40
+ ok: false;
41
+ error: DiscoveryError;
42
+ };
43
+ export type ExpectedDeliveryUnitIdentity = {
44
+ unitId: string;
45
+ buildMarker: string;
46
+ };
47
+ /**
48
+ * Compare a consumer's expected delivery-unit identity against a resolved
49
+ * record. Execution adapters must pass the record's `unitId` + `buildMarker`
50
+ * through to identity validation (RESOLUTION-0001 §2.3); a mismatch is the
51
+ * typed `identity-mismatch` discovery error.
52
+ */
53
+ export declare function matchDeliveryUnitIdentity(expected: ExpectedDeliveryUnitIdentity, unit: Pick<ResolvedDeliveryUnit, 'unitId' | 'buildMarker'>, ref: ParsedSurfaceRef | string): DiscoveryError | undefined;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.5.0-ultramodern.10",
20
+ "version": "3.5.0-ultramodern.101",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "module": "./dist/esm/index.mjs",
@@ -118,7 +118,6 @@
118
118
  }
119
119
  },
120
120
  "publishConfig": {
121
- "registry": "https://registry.npmjs.org/",
122
121
  "access": "public"
123
122
  },
124
123
  "typesVersions": {
@@ -181,19 +180,19 @@
181
180
  },
182
181
  "dependencies": {
183
182
  "@swc/helpers": "^0.5.23",
184
- "caniuse-lite": "^1.0.30001799",
183
+ "caniuse-lite": "^1.0.30001803",
185
184
  "import-meta-resolve": "^4.2.0",
186
185
  "lodash": "^4.18.1",
187
186
  "lodash-es": "^4.18.1",
188
187
  "rslog": "^2.1.3"
189
188
  },
190
189
  "devDependencies": {
191
- "@rslib/core": "0.23.1",
192
- "@types/node": "^26.0.1",
193
- "@typescript/native-preview": "7.0.0-dev.20260628.1",
194
- "happy-dom": "^20.10.6",
195
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.10",
196
- "@scripts/rstest-config": "2.66.0"
190
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.101",
191
+ "@rslib/core": "0.23.2",
192
+ "@scripts/rstest-config": "2.66.0",
193
+ "@types/node": "^26.1.1",
194
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
195
+ "happy-dom": "^20.10.6"
197
196
  },
198
197
  "peerDependencies": {
199
198
  "react": "^19.2.7",