@bleedingdev/modern-js-utils 3.5.0-ultramodern.8 → 3.5.0-ultramodern.80

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 (54) hide show
  1. package/dist/cjs/universal/backend-federation-contract/build-artifact.js +185 -0
  2. package/dist/cjs/universal/backend-federation-contract/constants.js +92 -0
  3. package/dist/cjs/universal/backend-federation-contract/delivery-unit.js +130 -0
  4. package/dist/cjs/universal/backend-federation-contract/index.js +137 -0
  5. package/dist/cjs/universal/backend-federation-contract/metadata.js +133 -0
  6. package/dist/cjs/universal/backend-federation-contract/types.js +18 -0
  7. package/dist/cjs/universal/backend-federation-contract/validation-core.js +85 -0
  8. package/dist/cjs/universal/index.js +51 -6
  9. package/dist/cjs/universal/surface-resolution/env-static-provider.js +318 -0
  10. package/dist/cjs/universal/surface-resolution/index.js +69 -0
  11. package/dist/cjs/universal/surface-resolution/surface-ref.js +132 -0
  12. package/dist/cjs/universal/surface-resolution/types.js +18 -0
  13. package/dist/cjs/universal/surface-resolution/validation.js +202 -0
  14. package/dist/esm/universal/backend-federation-contract/build-artifact.mjs +135 -0
  15. package/dist/esm/universal/backend-federation-contract/constants.mjs +18 -0
  16. package/dist/esm/universal/backend-federation-contract/delivery-unit.mjs +74 -0
  17. package/dist/esm/universal/backend-federation-contract/index.mjs +5 -0
  18. package/dist/esm/universal/backend-federation-contract/metadata.mjs +80 -0
  19. package/dist/esm/universal/backend-federation-contract/types.mjs +0 -0
  20. package/dist/esm/universal/backend-federation-contract/validation-core.mjs +29 -0
  21. package/dist/esm/universal/index.mjs +2 -0
  22. package/dist/esm/universal/surface-resolution/env-static-provider.mjs +274 -0
  23. package/dist/esm/universal/surface-resolution/index.mjs +3 -0
  24. package/dist/esm/universal/surface-resolution/surface-ref.mjs +88 -0
  25. package/dist/esm/universal/surface-resolution/types.mjs +0 -0
  26. package/dist/esm/universal/surface-resolution/validation.mjs +155 -0
  27. package/dist/esm-node/universal/backend-federation-contract/build-artifact.mjs +136 -0
  28. package/dist/esm-node/universal/backend-federation-contract/constants.mjs +19 -0
  29. package/dist/esm-node/universal/backend-federation-contract/delivery-unit.mjs +75 -0
  30. package/dist/esm-node/universal/backend-federation-contract/index.mjs +6 -0
  31. package/dist/esm-node/universal/backend-federation-contract/metadata.mjs +81 -0
  32. package/dist/esm-node/universal/backend-federation-contract/types.mjs +1 -0
  33. package/dist/esm-node/universal/backend-federation-contract/validation-core.mjs +30 -0
  34. package/dist/esm-node/universal/index.mjs +2 -0
  35. package/dist/esm-node/universal/surface-resolution/env-static-provider.mjs +275 -0
  36. package/dist/esm-node/universal/surface-resolution/index.mjs +4 -0
  37. package/dist/esm-node/universal/surface-resolution/surface-ref.mjs +89 -0
  38. package/dist/esm-node/universal/surface-resolution/types.mjs +1 -0
  39. package/dist/esm-node/universal/surface-resolution/validation.mjs +156 -0
  40. package/dist/types/import.d.ts +1 -1
  41. package/dist/types/universal/backend-federation-contract/build-artifact.d.ts +9 -0
  42. package/dist/types/universal/backend-federation-contract/constants.d.ts +14 -0
  43. package/dist/types/universal/backend-federation-contract/delivery-unit.d.ts +9 -0
  44. package/dist/types/universal/backend-federation-contract/index.d.ts +7 -0
  45. package/dist/types/universal/backend-federation-contract/metadata.d.ts +7 -0
  46. package/dist/types/universal/backend-federation-contract/types.d.ts +60 -0
  47. package/dist/types/universal/backend-federation-contract/validation-core.d.ts +8 -0
  48. package/dist/types/universal/index.d.ts +2 -0
  49. package/dist/types/universal/surface-resolution/env-static-provider.d.ts +107 -0
  50. package/dist/types/universal/surface-resolution/index.d.ts +4 -0
  51. package/dist/types/universal/surface-resolution/surface-ref.d.ts +72 -0
  52. package/dist/types/universal/surface-resolution/types.d.ts +102 -0
  53. package/dist/types/universal/surface-resolution/validation.d.ts +53 -0
  54. package/package.json +8 -9
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ DEFAULT_LOCAL_ENVIRONMENTS: ()=>external_env_static_provider_js_namespaceObject.DEFAULT_LOCAL_ENVIRONMENTS,
32
+ ENV_STATIC_PROVIDER_NAME: ()=>external_env_static_provider_js_namespaceObject.ENV_STATIC_PROVIDER_NAME,
33
+ createDiscoveryError: ()=>external_validation_js_namespaceObject.createDiscoveryError,
34
+ createEnvStaticSurfaceResolutionProvider: ()=>external_env_static_provider_js_namespaceObject.createEnvStaticSurfaceResolutionProvider,
35
+ formatSurfaceRef: ()=>external_surface_ref_js_namespaceObject.formatSurfaceRef,
36
+ matchDeliveryUnitIdentity: ()=>external_validation_js_namespaceObject.matchDeliveryUnitIdentity,
37
+ parseSurfaceRef: ()=>external_surface_ref_js_namespaceObject.parseSurfaceRef,
38
+ selectResolvedSurface: ()=>external_validation_js_namespaceObject.selectResolvedSurface,
39
+ validateResolvedDeliveryUnit: ()=>external_validation_js_namespaceObject.validateResolvedDeliveryUnit,
40
+ validateSurfaceRef: ()=>external_surface_ref_js_namespaceObject.validateSurfaceRef
41
+ });
42
+ const external_env_static_provider_js_namespaceObject = require("./env-static-provider.js");
43
+ const external_surface_ref_js_namespaceObject = require("./surface-ref.js");
44
+ const external_validation_js_namespaceObject = require("./validation.js");
45
+ exports.DEFAULT_LOCAL_ENVIRONMENTS = __webpack_exports__.DEFAULT_LOCAL_ENVIRONMENTS;
46
+ exports.ENV_STATIC_PROVIDER_NAME = __webpack_exports__.ENV_STATIC_PROVIDER_NAME;
47
+ exports.createDiscoveryError = __webpack_exports__.createDiscoveryError;
48
+ exports.createEnvStaticSurfaceResolutionProvider = __webpack_exports__.createEnvStaticSurfaceResolutionProvider;
49
+ exports.formatSurfaceRef = __webpack_exports__.formatSurfaceRef;
50
+ exports.matchDeliveryUnitIdentity = __webpack_exports__.matchDeliveryUnitIdentity;
51
+ exports.parseSurfaceRef = __webpack_exports__.parseSurfaceRef;
52
+ exports.selectResolvedSurface = __webpack_exports__.selectResolvedSurface;
53
+ exports.validateResolvedDeliveryUnit = __webpack_exports__.validateResolvedDeliveryUnit;
54
+ exports.validateSurfaceRef = __webpack_exports__.validateSurfaceRef;
55
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
56
+ "DEFAULT_LOCAL_ENVIRONMENTS",
57
+ "ENV_STATIC_PROVIDER_NAME",
58
+ "createDiscoveryError",
59
+ "createEnvStaticSurfaceResolutionProvider",
60
+ "formatSurfaceRef",
61
+ "matchDeliveryUnitIdentity",
62
+ "parseSurfaceRef",
63
+ "selectResolvedSurface",
64
+ "validateResolvedDeliveryUnit",
65
+ "validateSurfaceRef"
66
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
67
+ Object.defineProperty(exports, '__esModule', {
68
+ value: true
69
+ });
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ const SEGMENT_PATTERN = /^[A-Za-z0-9._-]+$/;
31
+ const MAJOR_PATTERN = /^v[1-9][0-9]*$/;
32
+ function parseSurfaceRef(input) {
33
+ if ('' === input) return {
34
+ ok: false,
35
+ error: {
36
+ code: 'empty'
37
+ }
38
+ };
39
+ const hashCount = countChar(input, '#');
40
+ if (0 === hashCount) return {
41
+ ok: false,
42
+ error: {
43
+ code: 'missing-surface-separator'
44
+ }
45
+ };
46
+ if (hashCount > 1) return {
47
+ ok: false,
48
+ error: {
49
+ code: 'multiple-surface-separators'
50
+ }
51
+ };
52
+ const hashIndex = input.indexOf('#');
53
+ const unitPart = input.slice(0, hashIndex);
54
+ const rest = input.slice(hashIndex + 1);
55
+ const atIndex = rest.indexOf('@');
56
+ const surfaceId = -1 === atIndex ? rest : rest.slice(0, atIndex);
57
+ const ref = {
58
+ unitId: unitPart,
59
+ surfaceId
60
+ };
61
+ if (-1 !== atIndex) {
62
+ const majorPart = rest.slice(atIndex + 1);
63
+ if ('' === majorPart) return {
64
+ ok: false,
65
+ error: {
66
+ code: 'empty-major'
67
+ }
68
+ };
69
+ if (!MAJOR_PATTERN.test(majorPart)) return {
70
+ ok: false,
71
+ error: {
72
+ code: 'invalid-major',
73
+ value: majorPart
74
+ }
75
+ };
76
+ ref.major = Number(majorPart.slice(1));
77
+ }
78
+ const error = validateSurfaceRef(ref);
79
+ return void 0 === error ? {
80
+ ok: true,
81
+ ref
82
+ } : {
83
+ ok: false,
84
+ error
85
+ };
86
+ }
87
+ function formatSurfaceRef(ref) {
88
+ const error = validateSurfaceRef(ref);
89
+ if (void 0 !== error) throw new TypeError(`Cannot format invalid SurfaceRef: ${error.code}.`);
90
+ const base = `${ref.unitId}#${ref.surfaceId}`;
91
+ return void 0 === ref.major ? base : `${base}@v${ref.major}`;
92
+ }
93
+ function validateSurfaceRef(ref) {
94
+ if ('' === ref.unitId) return {
95
+ code: 'empty-unit-id'
96
+ };
97
+ for (const segment of ref.unitId.split('/'))if (!SEGMENT_PATTERN.test(segment)) return {
98
+ code: 'invalid-unit-id',
99
+ segment
100
+ };
101
+ if ('' === ref.surfaceId) return {
102
+ code: 'empty-surface-id'
103
+ };
104
+ if (!SEGMENT_PATTERN.test(ref.surfaceId)) return {
105
+ code: 'invalid-surface-id'
106
+ };
107
+ if (void 0 !== ref.major && (!Number.isSafeInteger(ref.major) || ref.major < 1)) return {
108
+ code: 'invalid-major',
109
+ value: String(ref.major)
110
+ };
111
+ }
112
+ function countChar(input, char) {
113
+ let count = 0;
114
+ for (const current of input)if (current === char) count += 1;
115
+ return count;
116
+ }
117
+ __webpack_require__.d(__webpack_exports__, {
118
+ formatSurfaceRef: ()=>formatSurfaceRef,
119
+ parseSurfaceRef: ()=>parseSurfaceRef,
120
+ validateSurfaceRef: ()=>validateSurfaceRef
121
+ });
122
+ exports.formatSurfaceRef = __webpack_exports__.formatSurfaceRef;
123
+ exports.parseSurfaceRef = __webpack_exports__.parseSurfaceRef;
124
+ exports.validateSurfaceRef = __webpack_exports__.validateSurfaceRef;
125
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
126
+ "formatSurfaceRef",
127
+ "parseSurfaceRef",
128
+ "validateSurfaceRef"
129
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
130
+ Object.defineProperty(exports, '__esModule', {
131
+ value: true
132
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ createDiscoveryError: ()=>createDiscoveryError,
32
+ matchDeliveryUnitIdentity: ()=>matchDeliveryUnitIdentity,
33
+ selectResolvedSurface: ()=>selectResolvedSurface,
34
+ validateResolvedDeliveryUnit: ()=>validateResolvedDeliveryUnit
35
+ });
36
+ const external_surface_ref_js_namespaceObject = require("./surface-ref.js");
37
+ const SEGMENT_PATTERN = /^[A-Za-z0-9._-]+$/;
38
+ function createDiscoveryError(code, ref, message, details) {
39
+ const refString = 'string' == typeof ref ? ref : (0, external_surface_ref_js_namespaceObject.formatSurfaceRef)(ref);
40
+ return void 0 === details ? {
41
+ code,
42
+ ref: refString,
43
+ message
44
+ } : {
45
+ code,
46
+ ref: refString,
47
+ message,
48
+ details
49
+ };
50
+ }
51
+ function isNonEmptyString(value) {
52
+ return 'string' == typeof value && value.length > 0;
53
+ }
54
+ function isValidUnitId(unitId) {
55
+ return unitId.split('/').every((segment)=>SEGMENT_PATTERN.test(segment));
56
+ }
57
+ function isRecord(value) {
58
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
59
+ }
60
+ const COMPATIBILITY_STATUSES = [
61
+ 'compatible',
62
+ 'incompatible',
63
+ 'degraded'
64
+ ];
65
+ const SURFACE_KINDS = [
66
+ 'component',
67
+ 'route',
68
+ 'api',
69
+ 'backend'
70
+ ];
71
+ const LOCATION_PLATFORMS = [
72
+ 'browser-mf-manifest',
73
+ 'node-mf-manifest',
74
+ 'http-api',
75
+ 'cloudflare-service-binding'
76
+ ];
77
+ const LOCATION_REQUIRED_FIELDS = {
78
+ 'browser-mf-manifest': [
79
+ 'manifestUrl'
80
+ ],
81
+ 'node-mf-manifest': [
82
+ 'manifestRef'
83
+ ],
84
+ 'http-api': [
85
+ 'baseUrl',
86
+ 'prefix'
87
+ ],
88
+ 'cloudflare-service-binding': [
89
+ 'serviceBinding'
90
+ ]
91
+ };
92
+ function validateLocation(location, path, seenPlatforms, push) {
93
+ if (!isRecord(location)) return void push(path, 'must be an object');
94
+ const platform = location.platform;
95
+ if ('string' != typeof platform || !LOCATION_PLATFORMS.includes(platform)) return void push(`${path}.platform`, `must be one of ${LOCATION_PLATFORMS.join(', ')}`);
96
+ if (seenPlatforms.has(platform)) push(`${path}.platform`, `duplicate platform ${platform} within one surface`);
97
+ seenPlatforms.add(platform);
98
+ for (const field of LOCATION_REQUIRED_FIELDS[platform] ?? [])if (!isNonEmptyString(location[field])) push(`${path}.${field}`, 'must be a non-empty string');
99
+ if ('cloudflare-service-binding' === platform && void 0 !== location.dispatchNamespace && !isNonEmptyString(location.dispatchNamespace)) push(`${path}.dispatchNamespace`, 'must be a non-empty string when present');
100
+ }
101
+ function validateSurface(surface, path, seenSurfaceIds, push) {
102
+ if (!isRecord(surface)) return void push(path, 'must be an object');
103
+ if (isNonEmptyString(surface.surfaceId)) if (SEGMENT_PATTERN.test(surface.surfaceId)) if (seenSurfaceIds.has(surface.surfaceId)) push(`${path}.surfaceId`, 'must be unique within the record');
104
+ else seenSurfaceIds.add(surface.surfaceId);
105
+ else push(`${path}.surfaceId`, 'must match the SurfaceRef SurfaceId grammar');
106
+ else push(`${path}.surfaceId`, 'must be a non-empty string');
107
+ if ('string' != typeof surface.kind || !SURFACE_KINDS.includes(surface.kind)) push(`${path}.kind`, `must be one of ${SURFACE_KINDS.join(', ')}`);
108
+ if (void 0 !== surface.servedMajor && (!Number.isSafeInteger(surface.servedMajor) || surface.servedMajor < 1)) push(`${path}.servedMajor`, 'must be a positive safe integer when present');
109
+ if (!Array.isArray(surface.locations)) return void push(`${path}.locations`, 'must be an array of locations');
110
+ if (0 === surface.locations.length) push(`${path}.locations`, 'must contain at least one location (no partial records)');
111
+ const seenPlatforms = new Set();
112
+ surface.locations.forEach((location, locationIndex)=>{
113
+ validateLocation(location, `${path}.locations[${locationIndex}]`, seenPlatforms, push);
114
+ });
115
+ }
116
+ function validateResolvedDeliveryUnit(unit) {
117
+ const issues = [];
118
+ const push = (path, message)=>{
119
+ issues.push({
120
+ path,
121
+ message
122
+ });
123
+ };
124
+ if (!isRecord(unit)) {
125
+ push('', 'must be an object');
126
+ return {
127
+ ok: false,
128
+ issues
129
+ };
130
+ }
131
+ const raw = unit;
132
+ if (isNonEmptyString(raw.unitId)) {
133
+ if (!isValidUnitId(raw.unitId)) push('unitId', 'must match the SurfaceRef UnitId grammar');
134
+ } else push('unitId', 'must be a non-empty string');
135
+ if (!isNonEmptyString(raw.buildMarker)) push('buildMarker', 'must be a non-empty string');
136
+ if (!isNonEmptyString(raw.sourceRevision)) push('sourceRevision', 'must be a non-empty string');
137
+ if (!isNonEmptyString(raw.baselineCohortId)) push('baselineCohortId', 'must be a non-empty string');
138
+ const compatibility = raw.compatibility;
139
+ if (isRecord(compatibility)) {
140
+ if ('string' != typeof compatibility.status || !COMPATIBILITY_STATUSES.includes(compatibility.status)) push('compatibility.status', `must be one of ${COMPATIBILITY_STATUSES.join(', ')}`);
141
+ if (compatibility.baselineCohortId !== raw.baselineCohortId) push('compatibility.baselineCohortId', 'must equal the record-level baselineCohortId (one verdict per record)');
142
+ if (void 0 !== compatibility.reason && !isNonEmptyString(compatibility.reason)) push('compatibility.reason', 'must be a non-empty string when present');
143
+ } else push('compatibility', 'must be an object');
144
+ if (!Array.isArray(raw.surfaces)) {
145
+ push('surfaces', 'must be an array of surfaces');
146
+ return {
147
+ ok: false,
148
+ issues
149
+ };
150
+ }
151
+ if (0 === raw.surfaces.length) push('surfaces', 'must contain at least one surface');
152
+ const seenSurfaceIds = new Set();
153
+ raw.surfaces.forEach((surface, surfaceIndex)=>{
154
+ validateSurface(surface, `surfaces[${surfaceIndex}]`, seenSurfaceIds, push);
155
+ });
156
+ return {
157
+ ok: 0 === issues.length,
158
+ issues
159
+ };
160
+ }
161
+ function selectResolvedSurface(unit, ref) {
162
+ if (unit.unitId !== ref.unitId) return {
163
+ ok: false,
164
+ error: createDiscoveryError('unknown-unit', ref, `Resolved record is for unit ${unit.unitId}, not ${ref.unitId}.`, {
165
+ recordUnitId: unit.unitId
166
+ })
167
+ };
168
+ const surface = unit.surfaces.find((candidate)=>candidate.surfaceId === ref.surfaceId);
169
+ if (void 0 === surface) return {
170
+ ok: false,
171
+ error: createDiscoveryError('unknown-surface', ref, `Unit ${unit.unitId} (buildMarker ${unit.buildMarker}) does not publish surface ${ref.surfaceId}.`, {
172
+ availableSurfaces: unit.surfaces.map((entry)=>entry.surfaceId)
173
+ })
174
+ };
175
+ return {
176
+ ok: true,
177
+ surface
178
+ };
179
+ }
180
+ function matchDeliveryUnitIdentity(expected, unit, ref) {
181
+ if (expected.unitId === unit.unitId && expected.buildMarker === unit.buildMarker) return;
182
+ return createDiscoveryError('identity-mismatch', ref, `Delivery-unit identity mismatch: expected ${expected.unitId}@${expected.buildMarker}, resolved ${unit.unitId}@${unit.buildMarker}.`, {
183
+ expected,
184
+ resolved: {
185
+ unitId: unit.unitId,
186
+ buildMarker: unit.buildMarker
187
+ }
188
+ });
189
+ }
190
+ exports.createDiscoveryError = __webpack_exports__.createDiscoveryError;
191
+ exports.matchDeliveryUnitIdentity = __webpack_exports__.matchDeliveryUnitIdentity;
192
+ exports.selectResolvedSurface = __webpack_exports__.selectResolvedSurface;
193
+ exports.validateResolvedDeliveryUnit = __webpack_exports__.validateResolvedDeliveryUnit;
194
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
195
+ "createDiscoveryError",
196
+ "matchDeliveryUnitIdentity",
197
+ "selectResolvedSurface",
198
+ "validateResolvedDeliveryUnit"
199
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
200
+ Object.defineProperty(exports, '__esModule', {
201
+ value: true
202
+ });
@@ -0,0 +1,135 @@
1
+ import { DELIVERY_UNIT_IDENTITY_FIELDS, DELIVERY_UNIT_SCHEMA_VERSION } from "./constants.mjs";
2
+ import { deliveryUnitIdentityFieldValue, validateDeliveryUnitRecord } from "./delivery-unit.mjs";
3
+ import { addError, isRecord, nonEmptyString, recordField, validationResult } from "./validation-core.mjs";
4
+ const createUltramodernBuildArtifact = (record)=>{
5
+ const deliveryUnit = {
6
+ appId: record.appId,
7
+ build: record.buildMarker,
8
+ buildMarker: record.buildMarker,
9
+ deployProfile: record.deployProfile,
10
+ kind: record.kind,
11
+ packageName: record.packageName,
12
+ schemaVersion: record.schemaVersion,
13
+ sourceRevision: record.sourceRevision,
14
+ unitId: record.unitId,
15
+ version: record.version
16
+ };
17
+ const api = {
18
+ appId: deliveryUnit.appId,
19
+ build: deliveryUnit.build,
20
+ buildMarker: deliveryUnit.buildMarker,
21
+ deployProfile: deliveryUnit.deployProfile,
22
+ kind: deliveryUnit.kind,
23
+ packageName: deliveryUnit.packageName,
24
+ schemaVersion: deliveryUnit.schemaVersion,
25
+ sourceRevision: deliveryUnit.sourceRevision,
26
+ surface: 'api',
27
+ unitId: deliveryUnit.unitId,
28
+ version: deliveryUnit.version
29
+ };
30
+ const ui = {
31
+ appId: deliveryUnit.appId,
32
+ build: deliveryUnit.build,
33
+ buildMarker: deliveryUnit.buildMarker,
34
+ deployProfile: deliveryUnit.deployProfile,
35
+ kind: deliveryUnit.kind,
36
+ packageName: deliveryUnit.packageName,
37
+ schemaVersion: deliveryUnit.schemaVersion,
38
+ sourceRevision: deliveryUnit.sourceRevision,
39
+ surface: 'ui',
40
+ unitId: deliveryUnit.unitId,
41
+ version: deliveryUnit.version
42
+ };
43
+ return {
44
+ deliveryUnit,
45
+ kind: 'ultramodern-build-artifact',
46
+ schemaVersion: DELIVERY_UNIT_SCHEMA_VERSION,
47
+ surfaces: {
48
+ api,
49
+ ui
50
+ }
51
+ };
52
+ };
53
+ const validateUltramodernBuildArtifact = (value, path = 'artifact')=>{
54
+ const errors = [];
55
+ if (!isRecord(value)) {
56
+ addError(errors, path, 'must be an object.');
57
+ return validationResult(errors);
58
+ }
59
+ if (value.schemaVersion !== DELIVERY_UNIT_SCHEMA_VERSION) addError(errors, `${path}.schemaVersion`, `must be ${DELIVERY_UNIT_SCHEMA_VERSION}.`);
60
+ if ('ultramodern-build-artifact' !== value.kind) addError(errors, `${path}.kind`, 'must be "ultramodern-build-artifact".');
61
+ const deliveryUnit = value.deliveryUnit;
62
+ errors.push(...validateDeliveryUnitRecord(deliveryUnit, {
63
+ path: `${path}.deliveryUnit`,
64
+ allowBuildAlias: true
65
+ }).errors);
66
+ if (isRecord(deliveryUnit)) {
67
+ const build = nonEmptyString(deliveryUnit.build);
68
+ const buildMarker = nonEmptyString(deliveryUnit.buildMarker);
69
+ if (build) {
70
+ if (buildMarker && build !== buildMarker) addError(errors, `${path}.deliveryUnit.build`, 'must match deliveryUnit.buildMarker.');
71
+ } else addError(errors, `${path}.deliveryUnit.build`, 'must be a non-empty string.');
72
+ }
73
+ const surfaces = recordField(value, 'surfaces');
74
+ if (!surfaces) {
75
+ addError(errors, `${path}.surfaces`, 'must be an object.');
76
+ return validationResult(errors);
77
+ }
78
+ for (const surface of [
79
+ 'ui',
80
+ 'api'
81
+ ]){
82
+ const marker = surfaces[surface];
83
+ const markerPath = `${path}.surfaces.${surface}`;
84
+ errors.push(...validateDeliveryUnitRecord(marker, {
85
+ path: markerPath,
86
+ allowBuildAlias: true
87
+ }).errors);
88
+ if (!isRecord(marker)) continue;
89
+ const markerBuild = nonEmptyString(marker.build);
90
+ const markerBuildMarker = nonEmptyString(marker.buildMarker);
91
+ if (markerBuild) {
92
+ if (markerBuildMarker && markerBuild !== markerBuildMarker) addError(errors, `${markerPath}.build`, 'must match buildMarker.');
93
+ } else addError(errors, `${markerPath}.build`, 'must be non-empty string.');
94
+ if (marker.surface !== surface) addError(errors, `${markerPath}.surface`, `must be "${surface}".`);
95
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
96
+ const deliveryUnitValue = deliveryUnitIdentityFieldValue(deliveryUnit, field, {
97
+ allowBuildAlias: true
98
+ });
99
+ const markerValue = deliveryUnitIdentityFieldValue(marker, field, {
100
+ allowBuildAlias: true
101
+ });
102
+ if (void 0 !== deliveryUnitValue && void 0 !== markerValue && deliveryUnitValue !== markerValue) addError(errors, `${markerPath}.${field}`, `must match ${path}.deliveryUnit.${field}.`);
103
+ }
104
+ }
105
+ return validationResult(errors);
106
+ };
107
+ const isUltramodernBuildArtifact = (value)=>validateUltramodernBuildArtifact(value).ok;
108
+ const stampUltramodernBuildArtifactIdentity = (artifact, identity)=>({
109
+ ...artifact,
110
+ deliveryUnit: {
111
+ ...artifact.deliveryUnit,
112
+ build: identity.buildMarker,
113
+ buildMarker: identity.buildMarker,
114
+ sourceRevision: identity.sourceRevision
115
+ },
116
+ surfaces: {
117
+ ui: {
118
+ ...artifact.surfaces.ui,
119
+ build: identity.buildMarker,
120
+ buildMarker: identity.buildMarker,
121
+ sourceRevision: identity.sourceRevision
122
+ },
123
+ api: {
124
+ ...artifact.surfaces.api,
125
+ build: identity.buildMarker,
126
+ buildMarker: identity.buildMarker,
127
+ sourceRevision: identity.sourceRevision
128
+ }
129
+ }
130
+ });
131
+ const stampUltramodernBuildArtifactSourceRevision = (artifact, sourceRevision)=>stampUltramodernBuildArtifactIdentity(artifact, {
132
+ buildMarker: artifact.deliveryUnit.buildMarker,
133
+ sourceRevision
134
+ });
135
+ export { createUltramodernBuildArtifact, isUltramodernBuildArtifact, stampUltramodernBuildArtifactIdentity, stampUltramodernBuildArtifactSourceRevision, validateUltramodernBuildArtifact };
@@ -0,0 +1,18 @@
1
+ const BACKEND_FEDERATION_EFFECT_EXPOSE = './effect-api';
2
+ const BACKEND_FEDERATION_MANIFEST_FILE = 'backend-mf-manifest.json';
3
+ const BACKEND_FEDERATION_REMOTE_ENTRY_FILE = 'backendRemoteEntry.cjs';
4
+ const BACKEND_FEDERATION_CONTRACT_VERSION = 'microvertical-server-effect-v1';
5
+ const BACKEND_FEDERATION_NODE_ADAPTER_VERSION = 'backend-mf-effect-v1';
6
+ const DELIVERY_UNIT_SCHEMA_VERSION = 1;
7
+ const DELIVERY_UNIT_KIND = 'microvertical-delivery-unit';
8
+ const DELIVERY_UNIT_DEPLOY_PROFILE = 'cloudflare-ssr-mf-effect-v1';
9
+ const DELIVERY_UNIT_IDENTITY_FIELDS = [
10
+ 'unitId',
11
+ 'buildMarker',
12
+ 'sourceRevision'
13
+ ];
14
+ const ULTRAMODERN_BUILD_ARTIFACT_FILE = 'ultramodern-build.json';
15
+ const ULTRAMODERN_BUILD_ARTIFACT_PATH = `shared/${ULTRAMODERN_BUILD_ARTIFACT_FILE}`;
16
+ const ULTRAMODERN_BUILD_MODULE_FILE = 'ultramodern-build.ts';
17
+ const ULTRAMODERN_BUILD_MODULE_PATH = `shared/${ULTRAMODERN_BUILD_MODULE_FILE}`;
18
+ export { BACKEND_FEDERATION_CONTRACT_VERSION, BACKEND_FEDERATION_EFFECT_EXPOSE, BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_NODE_ADAPTER_VERSION, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_IDENTITY_FIELDS, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_FILE, ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_FILE, ULTRAMODERN_BUILD_MODULE_PATH };
@@ -0,0 +1,74 @@
1
+ import { DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_IDENTITY_FIELDS, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION } from "./constants.mjs";
2
+ import { addError, isRecord, nonEmptyString, validationResult } from "./validation-core.mjs";
3
+ const deliveryUnitIdentityFieldValue = (value, field, options = {})=>{
4
+ if (!isRecord(value)) return;
5
+ if ('buildMarker' === field && options.allowBuildAlias) return nonEmptyString(value.buildMarker) ?? nonEmptyString(value.build);
6
+ return nonEmptyString(value[field]);
7
+ };
8
+ const validateDeliveryUnitIdentity = (value, options = {})=>{
9
+ const path = options.path ?? 'deliveryUnit';
10
+ const errors = [];
11
+ if (!isRecord(value)) {
12
+ addError(errors, path, 'must be an object.');
13
+ return validationResult(errors);
14
+ }
15
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)if (!deliveryUnitIdentityFieldValue(value, field, options)) addError(errors, `${path}.${field}`, 'must be a non-empty string.');
16
+ return validationResult(errors);
17
+ };
18
+ const validateDeliveryUnitContractBlock = (value, options = {})=>{
19
+ const path = options.path ?? 'deliveryUnit';
20
+ const errors = [
21
+ ...validateDeliveryUnitIdentity(value, options).errors
22
+ ];
23
+ if (!isRecord(value)) return validationResult(errors);
24
+ if (value.schemaVersion !== DELIVERY_UNIT_SCHEMA_VERSION) addError(errors, `${path}.schemaVersion`, `must be ${DELIVERY_UNIT_SCHEMA_VERSION}.`);
25
+ if (value.kind !== DELIVERY_UNIT_KIND) addError(errors, `${path}.kind`, `must be "${DELIVERY_UNIT_KIND}".`);
26
+ if (!nonEmptyString(value.packageName)) addError(errors, `${path}.packageName`, 'must be a non-empty string.');
27
+ if (!nonEmptyString(value.version)) addError(errors, `${path}.version`, 'must be a non-empty string.');
28
+ return validationResult(errors);
29
+ };
30
+ const validateDeliveryUnitRecord = (value, options = {})=>{
31
+ const path = options.path ?? 'deliveryUnit';
32
+ const errors = [
33
+ ...validateDeliveryUnitContractBlock(value, {
34
+ ...options,
35
+ path
36
+ }).errors
37
+ ];
38
+ if (!isRecord(value)) return validationResult(errors);
39
+ if (!nonEmptyString(value.appId)) addError(errors, `${path}.appId`, 'must be a non-empty string.');
40
+ if (value.deployProfile !== DELIVERY_UNIT_DEPLOY_PROFILE) addError(errors, `${path}.deployProfile`, `must be "${DELIVERY_UNIT_DEPLOY_PROFILE}".`);
41
+ return validationResult(errors);
42
+ };
43
+ const validateDeliveryUnitBoundaryIdentity = (value, path)=>{
44
+ const errors = [];
45
+ if (!isRecord(value)) {
46
+ addError(errors, path, 'must be an object.');
47
+ return errors;
48
+ }
49
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)if (!deliveryUnitIdentityFieldValue(value, field)) addError(errors, `${path}.${field}`, 'must be a non-empty string.');
50
+ return errors;
51
+ };
52
+ const deliveryUnitContractBlock = (record)=>({
53
+ schemaVersion: record.schemaVersion,
54
+ kind: record.kind,
55
+ unitId: record.unitId,
56
+ packageName: record.packageName,
57
+ version: record.version,
58
+ buildMarker: record.buildMarker,
59
+ sourceRevision: record.sourceRevision
60
+ });
61
+ const toDeliveryUnitIdentity = (value)=>{
62
+ const unitId = deliveryUnitIdentityFieldValue(value, 'unitId');
63
+ const buildMarker = deliveryUnitIdentityFieldValue(value, 'buildMarker', {
64
+ allowBuildAlias: true
65
+ });
66
+ const sourceRevision = deliveryUnitIdentityFieldValue(value, 'sourceRevision');
67
+ if (!unitId || !buildMarker || !sourceRevision) return;
68
+ return {
69
+ unitId,
70
+ buildMarker,
71
+ sourceRevision
72
+ };
73
+ };
74
+ export { deliveryUnitContractBlock, deliveryUnitIdentityFieldValue, toDeliveryUnitIdentity, validateDeliveryUnitBoundaryIdentity, validateDeliveryUnitContractBlock, validateDeliveryUnitIdentity, validateDeliveryUnitRecord };
@@ -0,0 +1,5 @@
1
+ export { createUltramodernBuildArtifact, isUltramodernBuildArtifact, stampUltramodernBuildArtifactIdentity, stampUltramodernBuildArtifactSourceRevision, validateUltramodernBuildArtifact } from "./build-artifact.mjs";
2
+ export { BACKEND_FEDERATION_CONTRACT_VERSION, BACKEND_FEDERATION_EFFECT_EXPOSE, BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_NODE_ADAPTER_VERSION, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_IDENTITY_FIELDS, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_FILE, ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_FILE, ULTRAMODERN_BUILD_MODULE_PATH } from "./constants.mjs";
3
+ export { deliveryUnitContractBlock, deliveryUnitIdentityFieldValue, toDeliveryUnitIdentity, validateDeliveryUnitContractBlock, validateDeliveryUnitIdentity, validateDeliveryUnitRecord } from "./delivery-unit.mjs";
4
+ export { backendFederationExposeNames, backendFederationMetadata, backendFederationVersionBoundary, toBackendFederationExposeNames, validateBackendFederationManifest, validateBackendFederationMetadata } from "./metadata.mjs";
5
+ export { formatBackendFederationValidationErrors, nonEmptyString } from "./validation-core.mjs";