@xemahq/xema 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +70 -37
  2. package/dist/assets/distribution-assets.manifest.json +1 -2
  3. package/dist/cli.js +2 -2
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/dev.js +1 -0
  6. package/dist/commands/dev.js.map +1 -1
  7. package/dist/commands/down.d.ts.map +1 -1
  8. package/dist/commands/down.js +7 -1
  9. package/dist/commands/down.js.map +1 -1
  10. package/dist/commands/edition.d.ts +3 -0
  11. package/dist/commands/edition.d.ts.map +1 -0
  12. package/dist/commands/edition.js +46 -0
  13. package/dist/commands/edition.js.map +1 -0
  14. package/dist/commands/init.js +2 -2
  15. package/dist/commands/init.js.map +1 -1
  16. package/dist/commands/serve.js +1 -0
  17. package/dist/commands/serve.js.map +1 -1
  18. package/dist/commands/up.js +1 -0
  19. package/dist/commands/up.js.map +1 -1
  20. package/dist/dev/env-defaults.d.ts.map +1 -1
  21. package/dist/dev/env-defaults.js +5 -2
  22. package/dist/dev/env-defaults.js.map +1 -1
  23. package/dist/dev/infra-preflight.d.ts +3 -2
  24. package/dist/dev/infra-preflight.d.ts.map +1 -1
  25. package/dist/dev/infra-preflight.js +18 -8
  26. package/dist/dev/infra-preflight.js.map +1 -1
  27. package/dist/edition/verify-image-evidence.bundle.mjs +54283 -0
  28. package/dist/edition/verify-image-evidence.bundle.provenance.json +2877 -0
  29. package/dist/runtime/config/schema.d.ts +1 -0
  30. package/dist/runtime/config/schema.d.ts.map +1 -1
  31. package/dist/runtime/custody/local-custody.d.ts +12 -0
  32. package/dist/runtime/custody/local-custody.d.ts.map +1 -0
  33. package/dist/runtime/custody/local-custody.js +22 -0
  34. package/dist/runtime/custody/local-custody.js.map +1 -0
  35. package/dist/runtime/custody/openbao-custody-bootstrap.d.ts +18 -0
  36. package/dist/runtime/custody/openbao-custody-bootstrap.d.ts.map +1 -0
  37. package/dist/runtime/custody/openbao-custody-bootstrap.js +50 -0
  38. package/dist/runtime/custody/openbao-custody-bootstrap.js.map +1 -0
  39. package/dist/runtime/custody/openbao-custody-store.d.ts +18 -0
  40. package/dist/runtime/custody/openbao-custody-store.d.ts.map +1 -0
  41. package/dist/runtime/custody/openbao-custody-store.js +55 -0
  42. package/dist/runtime/custody/openbao-custody-store.js.map +1 -0
  43. package/dist/runtime/custody/openbao-http-client.d.ts +34 -0
  44. package/dist/runtime/custody/openbao-http-client.d.ts.map +1 -0
  45. package/dist/runtime/custody/openbao-http-client.js +154 -0
  46. package/dist/runtime/custody/openbao-http-client.js.map +1 -0
  47. package/dist/runtime/custody/openbao-local-constants.d.ts +22 -0
  48. package/dist/runtime/custody/openbao-local-constants.d.ts.map +1 -0
  49. package/dist/runtime/custody/openbao-local-constants.js +48 -0
  50. package/dist/runtime/custody/openbao-local-constants.js.map +1 -0
  51. package/dist/runtime/custody/openbao-local-runner.d.ts +16 -0
  52. package/dist/runtime/custody/openbao-local-runner.d.ts.map +1 -0
  53. package/dist/runtime/custody/openbao-local-runner.js +86 -0
  54. package/dist/runtime/custody/openbao-local-runner.js.map +1 -0
  55. package/dist/runtime/edition/run-entry.d.ts +9 -0
  56. package/dist/runtime/edition/run-entry.d.ts.map +1 -0
  57. package/dist/runtime/edition/run-entry.js +36 -0
  58. package/dist/runtime/edition/run-entry.js.map +1 -0
  59. package/dist/runtime/edition/verb-map.d.ts +60 -0
  60. package/dist/runtime/edition/verb-map.d.ts.map +1 -0
  61. package/dist/runtime/edition/verb-map.js +146 -0
  62. package/dist/runtime/edition/verb-map.js.map +1 -0
  63. package/dist/runtime/env-seeder.d.ts +2 -0
  64. package/dist/runtime/env-seeder.d.ts.map +1 -1
  65. package/dist/runtime/env-seeder.js +18 -3
  66. package/dist/runtime/env-seeder.js.map +1 -1
  67. package/dist/runtime/launch.d.ts +2 -1
  68. package/dist/runtime/launch.d.ts.map +1 -1
  69. package/dist/runtime/launch.js +31 -7
  70. package/dist/runtime/launch.js.map +1 -1
  71. package/dist/runtime/paths.d.ts +1 -2
  72. package/dist/runtime/paths.d.ts.map +1 -1
  73. package/dist/runtime/paths.js +0 -10
  74. package/dist/runtime/paths.js.map +1 -1
  75. package/dist/runtime/runner/chart-local-provenance.d.ts +20 -0
  76. package/dist/runtime/runner/chart-local-provenance.d.ts.map +1 -0
  77. package/dist/runtime/runner/chart-local-provenance.js +114 -0
  78. package/dist/runtime/runner/chart-local-provenance.js.map +1 -0
  79. package/dist/runtime/runner/chart-preflight.d.ts +8 -8
  80. package/dist/runtime/runner/chart-preflight.d.ts.map +1 -1
  81. package/dist/runtime/runner/chart-preflight.js +30 -69
  82. package/dist/runtime/runner/chart-preflight.js.map +1 -1
  83. package/dist/runtime/runner/chart-pull.d.ts +14 -0
  84. package/dist/runtime/runner/chart-pull.d.ts.map +1 -0
  85. package/dist/runtime/runner/chart-pull.js +96 -0
  86. package/dist/runtime/runner/chart-pull.js.map +1 -0
  87. package/dist/runtime/runner/chart-resolver.d.ts +4 -12
  88. package/dist/runtime/runner/chart-resolver.d.ts.map +1 -1
  89. package/dist/runtime/runner/chart-resolver.js +16 -62
  90. package/dist/runtime/runner/chart-resolver.js.map +1 -1
  91. package/dist/runtime/runner/chart-set-lock.d.ts +6 -20
  92. package/dist/runtime/runner/chart-set-lock.d.ts.map +1 -1
  93. package/dist/runtime/runner/chart-set-lock.js +55 -99
  94. package/dist/runtime/runner/chart-set-lock.js.map +1 -1
  95. package/dist/runtime/runner/helm-cli.d.ts +3 -1
  96. package/dist/runtime/runner/helm-cli.d.ts.map +1 -1
  97. package/dist/runtime/runner/helm-cli.js +9 -7
  98. package/dist/runtime/runner/helm-cli.js.map +1 -1
  99. package/dist/runtime/runner/helm-runner.d.ts +4 -4
  100. package/dist/runtime/runner/helm-runner.d.ts.map +1 -1
  101. package/dist/runtime/runner/helm-runner.js +18 -16
  102. package/dist/runtime/runner/helm-runner.js.map +1 -1
  103. package/dist/runtime/sources/kinds/git.d.ts +1 -2
  104. package/dist/runtime/sources/kinds/git.d.ts.map +1 -1
  105. package/dist/runtime/sources/kinds/git.js +8 -5
  106. package/dist/runtime/sources/kinds/git.js.map +1 -1
  107. package/dist/runtime/sources/manifest-walk.d.ts +3 -1
  108. package/dist/runtime/sources/manifest-walk.d.ts.map +1 -1
  109. package/dist/runtime/sources/manifest-walk.js +8 -3
  110. package/dist/runtime/sources/manifest-walk.js.map +1 -1
  111. package/dist/runtime/sources/schema.d.ts +3 -0
  112. package/dist/runtime/sources/schema.d.ts.map +1 -1
  113. package/dist/runtime/sources/schema.js +6 -1
  114. package/dist/runtime/sources/schema.js.map +1 -1
  115. package/dist/runtime/supervisor.d.ts +2 -0
  116. package/dist/runtime/supervisor.d.ts.map +1 -1
  117. package/dist/runtime/supervisor.js +1 -0
  118. package/dist/runtime/supervisor.js.map +1 -1
  119. package/edition/README.md +313 -0
  120. package/edition/assemble-producer-input.mjs +1251 -0
  121. package/edition/authorization-base.mjs +347 -0
  122. package/edition/biome-content.mjs +268 -0
  123. package/edition/build-biome-index.mjs +175 -0
  124. package/edition/build-platform-service-index.mjs +288 -0
  125. package/edition/build-runtime-image-source-index.mjs +821 -0
  126. package/edition/built-verifier.mjs +55 -0
  127. package/edition/catalogue-edition.mjs +49 -0
  128. package/edition/catalogue-fetch.mjs +64 -0
  129. package/edition/catalogue.mjs +135 -0
  130. package/edition/chart-set-source-commit.mjs +92 -0
  131. package/edition/check-committed-image-evidence.mjs +383 -0
  132. package/edition/checkout-indexed-source-repositories.mjs +105 -0
  133. package/edition/comment-blanker.mjs +75 -0
  134. package/edition/connector-source-authority.mjs +60 -0
  135. package/edition/customer-definition.mjs +183 -0
  136. package/edition/customer-flags.mjs +7 -0
  137. package/edition/develop-customer-edition.mjs +99 -0
  138. package/edition/develop-edition-resolve.mjs +65 -0
  139. package/edition/develop-edition.mjs +274 -0
  140. package/edition/develop-freeze.mjs +173 -0
  141. package/edition/develop-image-coordinate.mjs +54 -0
  142. package/edition/develop-seal.mjs +77 -0
  143. package/edition/develop-snapshot-inputs.mjs +104 -0
  144. package/edition/dist-check.mjs +986 -0
  145. package/edition/distribution-evidence-set.mjs +987 -0
  146. package/edition/distribution-paths.mjs +191 -0
  147. package/edition/edition-artifact.mjs +284 -0
  148. package/edition/edition-biome-manifests.mjs +85 -0
  149. package/edition/edition-channel.mjs +6 -0
  150. package/edition/edition-chart-set.mjs +93 -0
  151. package/edition/edition-config.mjs +205 -0
  152. package/edition/edition-constants.mjs +57 -0
  153. package/edition/edition-contract.json +30 -0
  154. package/edition/edition-list.mjs +35 -0
  155. package/edition/edition-locks.mjs +69 -0
  156. package/edition/edition-protocol.mjs +228 -0
  157. package/edition/edition-workspace.mjs +187 -0
  158. package/edition/evidence-checkout.mjs +439 -0
  159. package/edition/evidence-grammars.mjs +16 -0
  160. package/edition/evidence-trust-pin.mjs +304 -0
  161. package/edition/evidence-trust-policy.mjs +294 -0
  162. package/edition/external-source-walk.mjs +463 -0
  163. package/edition/first-party-source-ids.mjs +59 -0
  164. package/edition/fleet-coordinate-finality.mjs +350 -0
  165. package/edition/git-source-auth.mjs +52 -0
  166. package/edition/image-delivery-entitlement-descriptor.mjs +106 -0
  167. package/edition/image-evidence-replay-state.mjs +242 -0
  168. package/edition/image-evidence.mjs +1233 -0
  169. package/edition/kernel-contract-authority.mjs +443 -0
  170. package/edition/lib.mjs +3021 -0
  171. package/edition/no-follow-file.mjs +94 -0
  172. package/edition/oci-evidence-verbs.mjs +392 -0
  173. package/edition/oci-image-source-evidence.mjs +239 -0
  174. package/edition/oras.mjs +648 -0
  175. package/edition/pin-source.mjs +227 -0
  176. package/edition/plan-image-evidence-refresh.mjs +408 -0
  177. package/edition/platform-lock-readability.mjs +892 -0
  178. package/edition/platform-service-class.mjs +18 -0
  179. package/edition/platform-service-source-authority.mjs +105 -0
  180. package/edition/positive-closure.mjs +162 -0
  181. package/edition/produce-distribution-completeness-evidence.mjs +311 -0
  182. package/edition/produce-image-delivery-entitlement-evidence.mjs +294 -0
  183. package/edition/produce-image-source-evidence.mjs +765 -0
  184. package/edition/producer-evidence-bundle.mjs +157 -0
  185. package/edition/registry-credentials.mjs +193 -0
  186. package/edition/release-catalogue.mjs +39 -0
  187. package/edition/release-channel-guard.mjs +109 -0
  188. package/edition/release-edition-artifact.mjs +157 -0
  189. package/edition/remedy-command.mjs +89 -0
  190. package/edition/repin-evidence-trust.mjs +101 -0
  191. package/edition/required-resource-provider.mjs +58 -0
  192. package/edition/resolve-chart-set.mjs +415 -0
  193. package/edition/resolve-customer-edition.mjs +288 -0
  194. package/edition/resolve-distribution.mjs +2318 -0
  195. package/edition/resolve-edition.mjs +186 -0
  196. package/edition/resolve-images.mjs +1606 -0
  197. package/edition/seal-image-digests.mjs +855 -0
  198. package/edition/sealed-evidence-accept.mjs +82 -0
  199. package/edition/source-authority.mjs +725 -0
  200. package/edition/source-closure.mjs +116 -0
  201. package/edition/strict-json.mjs +121 -0
  202. package/edition/string-order.mjs +5 -0
  203. package/edition/trust-policy-arming.mjs +120 -0
  204. package/edition/trusted-executable.mjs +166 -0
  205. package/edition/verifier-binding.mjs +45 -0
  206. package/edition/verifier-files.mjs +8 -0
  207. package/edition/verifier-kernel-schemas.mjs +22 -0
  208. package/edition/verifier-provenance.mjs +64 -0
  209. package/edition/verify-image-evidence.mjs +458 -0
  210. package/edition/verify-image-platforms.mjs +495 -0
  211. package/edition/why.mjs +56 -0
  212. package/edition/workspace-sections.mjs +195 -0
  213. package/examples/06-biome-sources.yaml +1 -0
  214. package/package.json +14 -6
  215. package/dist/commands/dist.d.ts +0 -16
  216. package/dist/commands/dist.d.ts.map +0 -1
  217. package/dist/commands/dist.js +0 -182
  218. package/dist/commands/dist.js.map +0 -1
  219. package/dist/runtime/distribution/available-biome.d.ts +0 -10
  220. package/dist/runtime/distribution/available-biome.d.ts.map +0 -1
  221. package/dist/runtime/distribution/available-biome.js +0 -156
  222. package/dist/runtime/distribution/available-biome.js.map +0 -1
  223. package/dist/runtime/distribution/compose.d.ts +0 -23
  224. package/dist/runtime/distribution/compose.d.ts.map +0 -1
  225. package/dist/runtime/distribution/compose.js +0 -48
  226. package/dist/runtime/distribution/compose.js.map +0 -1
  227. package/dist/runtime/runner/chart-trust.d.ts +0 -57
  228. package/dist/runtime/runner/chart-trust.d.ts.map +0 -1
  229. package/dist/runtime/runner/chart-trust.js +0 -270
  230. package/dist/runtime/runner/chart-trust.js.map +0 -1
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ // resolve-edition — the release lock set of one edition, in the order the
3
+ // distribution plane has always run it: `resolve-distribution <id>` (the
4
+ // distribution, authorization and chart-set locks) and then
5
+ // `resolve-images <id> --trusted-write-v3` (the images lock).
6
+ //
7
+ // node resolve-edition.mjs <root flags> <edition-id> --trusted-write-v3
8
+ // write the whole lock set into the editions root. The flag is the
9
+ // operator's explicit acknowledgement that the images lock is rewritten
10
+ // UNSEALED (a resolve never produces an `imageDigest`; `xema edition seal`
11
+ // writes them afterwards). Without it nothing is written.
12
+ // node resolve-edition.mjs <root flags> <edition-id> --check
13
+ // resolve the whole lock set into a scratch copy of the editions root and
14
+ // compare each lock with the committed one; exit 1 on any difference.
15
+ // Nothing committed is written, and the flag above is refused alongside
16
+ // it. Like is compared with like: the resolve timestamp is normalized out
17
+ // and the committed images lock is read through `withoutSealedDigests`,
18
+ // because a resolve emits no `imageDigest` and a sealed lock differs from
19
+ // a fresh resolve by exactly that field.
20
+
21
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
22
+ import { tmpdir } from 'node:os';
23
+ import { join } from 'node:path';
24
+
25
+ import { AUTHORIZATION_LOCK_FILENAME } from './authorization-base.mjs';
26
+ import { fetchCatalogue } from './catalogue-fetch.mjs';
27
+ import {
28
+ CATALOGUE_FLAG,
29
+ CATALOGUE_TOKEN_ENV_FLAG,
30
+ CATALOGUE_USERNAME_FLAG,
31
+ CHANNEL_FLAG,
32
+ DEFINITION_FLAG,
33
+ SOURCE_IMAGE_FLAG,
34
+ } from './customer-flags.mjs';
35
+ import { assertCanonicalDistributionId } from './distribution-paths.mjs';
36
+ import { EditionChannel, EditionLockFile } from './edition-constants.mjs';
37
+ import {
38
+ WorkspaceRoot,
39
+ configureEditionWorkspace,
40
+ configureEditionWorkspaceFromProcess,
41
+ configuredWorkspace,
42
+ editionsRoot,
43
+ isEntryModule,
44
+ } from './edition-workspace.mjs';
45
+ import { comparableDistributionLock, loadKernelDistributionSchemas } from './lib.mjs';
46
+ import { parseSourceImages, resolveCustomerEdition, writeCustomerEdition } from './resolve-customer-edition.mjs';
47
+ import { writeResolvedDistribution } from './resolve-distribution.mjs';
48
+ import { writeResolvedImages } from './resolve-images.mjs';
49
+ import { withoutSealedDigests } from './seal-image-digests.mjs';
50
+ import { readStrictJsonFile } from './strict-json.mjs';
51
+
52
+ // A customer resolve (`--catalogue`) has no vendor editions root: `--out` IS its
53
+ // editions root, the directory its `<id>/` locks are written under.
54
+ if (isEntryModule(import.meta.url)) {
55
+ if (process.argv.includes(CATALOGUE_FLAG)) {
56
+ const at = process.argv.indexOf('--out');
57
+ if (at < 0 || process.argv[at + 1] === undefined) {throw new Error(`--out <dir> is required with ${CATALOGUE_FLAG}`);}
58
+ mkdirSync(process.argv[at + 1], { recursive: true });
59
+ process.argv.splice(at, 1, '--editions-root');
60
+ configureEditionWorkspaceFromProcess([WorkspaceRoot.Data, WorkspaceRoot.Editions, WorkspaceRoot.Sources, WorkspaceRoot.Kernel, WorkspaceRoot.Cache, WorkspaceRoot.SourceHash]);
61
+ } else {
62
+ configureEditionWorkspaceFromProcess([WorkspaceRoot.Data, WorkspaceRoot.Editions, WorkspaceRoot.Sources, WorkspaceRoot.Kernel, WorkspaceRoot.Cache, WorkspaceRoot.SourceHash]);
63
+ }
64
+ }
65
+
66
+ const CHECK_FLAG = '--check';
67
+ const TRUSTED_WRITE_FLAG = '--trusted-write-v3';
68
+
69
+ /** The locks one resolve writes, and the only files `--check` compares. */
70
+ export const RESOLVED_LOCK_FILES = Object.freeze([
71
+ EditionLockFile.Distribution,
72
+ AUTHORIZATION_LOCK_FILENAME,
73
+ EditionLockFile.ChartSet,
74
+ EditionLockFile.Images,
75
+ ]);
76
+
77
+ /**
78
+ * A lock's comparable text. The resolve timestamp is the one field that changes
79
+ * between identical resolves; the sealed `imageDigest` of the images lock is a
80
+ * fact about what SHIPPED that a resolve never reproduces, so it is subtracted
81
+ * from the committed side (a fresh resolve carries none).
82
+ */
83
+ export function comparableLock(file, text, schemas) {
84
+ const lock = JSON.parse(text);
85
+ if (file === EditionLockFile.Distribution) {return comparableDistributionLock(schemas, lock);}
86
+ const { resolvedAt: _resolvedAt, ...rest } = file === EditionLockFile.Images ? withoutSealedDigests(lock) : lock;
87
+ return JSON.stringify(rest);
88
+ }
89
+
90
+ /** `{ id, check }` from the arguments after the root flags; the write flag is required to write and refused with `--check`. */
91
+ export function parseResolveEditionArgs(args) {
92
+ const [id, ...rest] = args;
93
+ const known = [CHECK_FLAG, TRUSTED_WRITE_FLAG];
94
+ const usage = `usage: resolve-edition.mjs <root flags> <edition-id> (${CHECK_FLAG} | ${TRUSTED_WRITE_FLAG})`;
95
+ if (!id || rest.some((argument) => !known.includes(argument))) {throw new Error(usage);}
96
+ const check = rest.includes(CHECK_FLAG);
97
+ const trustedWrite = rest.includes(TRUSTED_WRITE_FLAG);
98
+ if (check === trustedWrite) {
99
+ throw new Error(
100
+ check
101
+ ? `${CHECK_FLAG} writes nothing committed and does not take ${TRUSTED_WRITE_FLAG}`
102
+ : `refusing to write a lock set without ${TRUSTED_WRITE_FLAG}: the images lock is rewritten unsealed; ${usage}`,
103
+ );
104
+ }
105
+ return { id, check };
106
+ }
107
+
108
+ export async function writeResolvedLockSet(id) {
109
+ await writeResolvedDistribution(id);
110
+ await writeResolvedImages(id, { trustedWriteV3: true });
111
+ }
112
+
113
+ export async function checkResolvedLockSet(id) {
114
+ const committedRoot = editionsRoot();
115
+ const scratch = mkdtempSync(join(tmpdir(), 'xema-edition-check-'));
116
+ try {
117
+ const schemas = await loadKernelDistributionSchemas();
118
+ cpSync(committedRoot, scratch, {
119
+ recursive: true,
120
+ filter: (source) => !/(^|[\\/])(\.git|node_modules)$/.test(source),
121
+ });
122
+ configureEditionWorkspace({ ...configuredWorkspace(), [WorkspaceRoot.Editions]: scratch });
123
+ await writeResolvedLockSet(id);
124
+ const drift = RESOLVED_LOCK_FILES.filter((file) => {
125
+ const committed = join(committedRoot, id, file);
126
+ const fresh = join(scratch, id, file);
127
+ if (!existsSync(committed) || !existsSync(fresh)) {return existsSync(committed) !== existsSync(fresh);}
128
+ return comparableLock(file, readFileSync(committed, 'utf8'), schemas) !== comparableLock(file, readFileSync(fresh, 'utf8'), schemas);
129
+ });
130
+ if (drift.length > 0) {
131
+ throw new Error(`${id}: the committed ${drift.join(', ')} differ from a fresh resolve; resolve the edition and commit the result`);
132
+ }
133
+ } finally {
134
+ rmSync(scratch, { recursive: true, force: true });
135
+ }
136
+ }
137
+
138
+ const CUSTOMER_VALUE_FLAGS = [DEFINITION_FLAG, CATALOGUE_FLAG, CHANNEL_FLAG, CATALOGUE_USERNAME_FLAG, CATALOGUE_TOKEN_ENV_FLAG];
139
+
140
+ /** The arguments of a customer resolve (the root flags and `--out` are already consumed). */
141
+ export function parseCustomerResolveArgs(args) {
142
+ const values = new Map();
143
+ const sourceImages = [];
144
+ for (let i = 0; i < args.length; i += 1) {
145
+ const flag = args[i];
146
+ const value = args[i + 1];
147
+ if (![...CUSTOMER_VALUE_FLAGS, SOURCE_IMAGE_FLAG].includes(flag) || value === undefined || value.startsWith('--')) {
148
+ throw new Error(`unexpected argument ${JSON.stringify(flag)} in a customer resolve (${DEFINITION_FLAG}, ${CATALOGUE_FLAG}, ${CHANNEL_FLAG}, ${SOURCE_IMAGE_FLAG} take a value)`);
149
+ }
150
+ i += 1;
151
+ if (flag === SOURCE_IMAGE_FLAG) {sourceImages.push(value);} else if (values.has(flag)) {throw new Error(`${flag} given twice`);} else {values.set(flag, value);}
152
+ }
153
+ for (const required of [DEFINITION_FLAG, CATALOGUE_FLAG, CHANNEL_FLAG]) {
154
+ if (!values.has(required)) {throw new Error(`a customer resolve requires ${required}`);}
155
+ }
156
+ if (!Object.values(EditionChannel).includes(values.get(CHANNEL_FLAG))) {
157
+ throw new Error(`${CHANNEL_FLAG} must be one of ${Object.values(EditionChannel).join(' | ')}`);
158
+ }
159
+ return { values, sourceImages: parseSourceImages(sourceImages) };
160
+ }
161
+
162
+ async function mainCustomer() {
163
+ const { values, sourceImages } = parseCustomerResolveArgs(process.argv.slice(2));
164
+ const { catalogue, digest } = await fetchCatalogue({
165
+ ref: values.get(CATALOGUE_FLAG),
166
+ username: values.get(CATALOGUE_USERNAME_FLAG),
167
+ tokenEnv: values.get(CATALOGUE_TOKEN_ENV_FLAG),
168
+ });
169
+ const resolved = await resolveCustomerEdition({ rawDefinition: readStrictJsonFile(values.get(DEFINITION_FLAG)), catalogue, catalogueDigest: digest, sourceImages, channel: values.get(CHANNEL_FLAG) });
170
+ const { dir } = writeCustomerEdition(editionsRoot(), resolved);
171
+ console.log(`[edition:resolve] ${resolved.id}: customer edition against catalogue ${catalogue.offeringId} ${digest}, written to ${dir}`);
172
+ }
173
+
174
+ async function main() {
175
+ if (process.argv.includes(CATALOGUE_FLAG)) {return mainCustomer();}
176
+ const { id, check } = parseResolveEditionArgs(process.argv.slice(2));
177
+ assertCanonicalDistributionId(id);
178
+ await (check ? checkResolvedLockSet(id) : writeResolvedLockSet(id));
179
+ }
180
+
181
+ if (isEntryModule(import.meta.url)) {
182
+ main().catch((error) => {
183
+ console.error(`[edition:resolve] ${error.message}`);
184
+ process.exit(1);
185
+ });
186
+ }