@absolutejs/absolute 0.20.0-beta.111 → 0.20.0-beta.112

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.
@@ -33560,12 +33560,15 @@ var writeAbsoluteMobileReleaseCertification = async (projectRoot, certification,
33560
33560
 
33561
33561
  // src/mobile/ciPromotionAudit.ts
33562
33562
  var ABSOLUTE_MOBILE_CI_PROMOTION_AUDIT_FORMAT = 1;
33563
- var ABSOLUTE_MOBILE_CI_PROMOTION_CONTEXT_FORMAT = 1;
33563
+ var ABSOLUTE_MOBILE_CI_PROMOTION_CONTEXT_FORMAT = 2;
33564
33564
  var MAX_GITHUB_OUTPUT_BYTES = 1048576;
33565
33565
  var MAX_AUDIT_JSON_BYTES = 1048576;
33566
33566
  var MAX_SEARCH_FILES = 20000;
33567
33567
  var RUN_ID_PATTERN = /^[1-9][0-9]*$/u;
33568
33568
  var REPOSITORY_PATTERN2 = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u;
33569
+ var DISPATCH_ID_PATTERN = /^amp_[a-f0-9]{32}$/u;
33570
+ var PROMOTION_DISCOVERY_ATTEMPTS = 60;
33571
+ var PROMOTION_DISCOVERY_INTERVAL_MS = 1000;
33569
33572
  var isRecord13 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
33570
33573
  var requiredString = (value, name) => {
33571
33574
  if (typeof value !== "string" || value.trim() === "")
@@ -33582,6 +33585,26 @@ var runId = (value, name) => {
33582
33585
  throw new TypeError(`${name} is invalid.`);
33583
33586
  return value;
33584
33587
  };
33588
+ var dispatchId = (value) => {
33589
+ if (!DISPATCH_ID_PATTERN.test(value))
33590
+ throw new TypeError("Mobile promotion dispatch ID is invalid.");
33591
+ return value;
33592
+ };
33593
+ var promotionRunTitle = (value) => `AbsoluteJS mobile promotion [${dispatchId(value)}]`;
33594
+ var promotionDiscoveryCommand = (workflow, repository) => [
33595
+ "gh",
33596
+ "run",
33597
+ "list",
33598
+ "--workflow",
33599
+ workflow,
33600
+ "--event",
33601
+ "workflow_dispatch",
33602
+ "--limit",
33603
+ "50",
33604
+ ...repositoryArgs(repository),
33605
+ "--json",
33606
+ "databaseId,displayTitle,event,url"
33607
+ ];
33585
33608
  var repositoryArgs = (repository) => {
33586
33609
  if (repository === undefined)
33587
33610
  return [];
@@ -33629,6 +33652,27 @@ var parseJob = (value) => {
33629
33652
  status: requiredString(value.status, "GitHub job status")
33630
33653
  };
33631
33654
  };
33655
+ var discoverAbsoluteMobilePromotionRun = async (options) => {
33656
+ const requestedDispatchId = dispatchId(options.dispatchId);
33657
+ const attempts = options.attempts ?? PROMOTION_DISCOVERY_ATTEMPTS;
33658
+ if (!Number.isSafeInteger(attempts) || attempts < 1 || attempts > 300)
33659
+ throw new TypeError("Mobile promotion discovery attempts are invalid.");
33660
+ const pollIntervalMs = options.pollIntervalMs ?? PROMOTION_DISCOVERY_INTERVAL_MS;
33661
+ if (!Number.isSafeInteger(pollIntervalMs) || pollIntervalMs < 0 || pollIntervalMs > 1e4)
33662
+ throw new TypeError("Mobile promotion discovery interval is invalid.");
33663
+ const sleep = options.sleep ?? Bun.sleep;
33664
+ const discover = async (attempt) => {
33665
+ const result = await requireCommand(options.run ?? defaultRunner, promotionDiscoveryCommand(options.workflow, options.repository), { cwd: options.projectRoot }, "GitHub promotion run discovery");
33666
+ const discovered = parseAbsoluteMobilePromotionRunList(JSON.parse(result.stdout), requestedDispatchId);
33667
+ if (discovered)
33668
+ return discovered;
33669
+ if (attempt >= attempts)
33670
+ throw new TypeError(`GitHub did not expose promotion dispatch ${requestedDispatchId} within ${attempts} attempts.`);
33671
+ await sleep(pollIntervalMs);
33672
+ return discover(attempt + 1);
33673
+ };
33674
+ return discover(1);
33675
+ };
33632
33676
  var inspectAbsoluteMobileCiRun = async (options) => {
33633
33677
  const requestedRunId = runId(options.runId, "GitHub run ID");
33634
33678
  const result = await requireCommand(options.run ?? defaultRunner, [
@@ -33638,7 +33682,7 @@ var inspectAbsoluteMobileCiRun = async (options) => {
33638
33682
  requestedRunId,
33639
33683
  ...repositoryArgs(options.repository),
33640
33684
  "--json",
33641
- "conclusion,createdAt,databaseId,headBranch,headSha,jobs,startedAt,status,updatedAt,url,workflowName"
33685
+ "conclusion,createdAt,databaseId,displayTitle,headBranch,headSha,jobs,startedAt,status,updatedAt,url,workflowName"
33642
33686
  ], { cwd: options.projectRoot }, "GitHub workflow inspection");
33643
33687
  return parseAbsoluteMobileCiRunStatus(JSON.parse(result.stdout), requestedRunId);
33644
33688
  };
@@ -33651,6 +33695,7 @@ var parseAbsoluteMobileCiRunStatus = (value, requestedRunId) => {
33651
33695
  return {
33652
33696
  conclusion: optionalString(value.conclusion, "GitHub run conclusion"),
33653
33697
  createdAt: requiredString(value.createdAt, "GitHub run createdAt"),
33698
+ displayTitle: requiredString(value.displayTitle, "GitHub run displayTitle"),
33654
33699
  headBranch: requiredString(value.headBranch, "GitHub run headBranch"),
33655
33700
  headSha: requiredString(value.headSha, "GitHub run headSha"),
33656
33701
  jobs: value.jobs.map(parseJob),
@@ -33663,20 +33708,44 @@ var parseAbsoluteMobileCiRunStatus = (value, requestedRunId) => {
33663
33708
  };
33664
33709
  };
33665
33710
  var parseAbsoluteMobilePromotionContext = (value) => {
33666
- if (!isRecord13(value) || value.format !== ABSOLUTE_MOBILE_CI_PROMOTION_CONTEXT_FORMAT || value.platform !== "android" && value.platform !== "ios")
33711
+ if (!isRecord13(value) || value.format !== 1 && value.format !== ABSOLUTE_MOBILE_CI_PROMOTION_CONTEXT_FORMAT || value.platform !== "android" && value.platform !== "ios")
33667
33712
  throw new TypeError("Mobile promotion context is invalid.");
33668
33713
  const { platform: platform3 } = value;
33669
33714
  const sourceArtifact = requiredString(value.sourceArtifact, "promotion source artifact");
33670
33715
  if (sourceArtifact !== `absolute-mobile-${platform3}`)
33671
33716
  throw new TypeError("Mobile promotion source artifact is invalid.");
33672
33717
  return {
33673
- format: ABSOLUTE_MOBILE_CI_PROMOTION_CONTEXT_FORMAT,
33718
+ dispatchId: value.format === 1 ? null : dispatchId(requiredString(value.dispatchId, "promotion dispatch ID")),
33719
+ format: value.format,
33674
33720
  platform: platform3,
33675
33721
  promotionRunId: runId(requiredString(value.promotionRunId, "promotion run ID"), "promotion run ID"),
33676
33722
  sourceArtifact,
33677
33723
  sourceRunId: runId(requiredString(value.sourceRunId, "source run ID"), "source run ID")
33678
33724
  };
33679
33725
  };
33726
+ var parseAbsoluteMobilePromotionRunList = (value, requestedDispatchId) => {
33727
+ if (!Array.isArray(value))
33728
+ throw new TypeError("GitHub workflow run list response is invalid.");
33729
+ const expectedTitle = promotionRunTitle(requestedDispatchId);
33730
+ const matches2 = value.filter((candidate) => isRecord13(candidate) && candidate.displayTitle === expectedTitle);
33731
+ if (matches2.length === 0)
33732
+ return null;
33733
+ if (matches2.length !== 1)
33734
+ throw new TypeError("GitHub returned multiple runs for one promotion dispatch identity.");
33735
+ const [match] = matches2;
33736
+ if (!isRecord13(match) || match.event !== "workflow_dispatch")
33737
+ throw new TypeError("GitHub promotion run identity is invalid.");
33738
+ const databaseId = typeof match.databaseId === "number" || typeof match.databaseId === "string" ? String(match.databaseId) : "";
33739
+ const requestedRunId = runId(databaseId, "GitHub promotion run ID");
33740
+ const url = requiredString(match.url, "GitHub promotion run URL");
33741
+ if (!url.endsWith(`/actions/runs/${requestedRunId}`))
33742
+ throw new TypeError("GitHub promotion run URL does not match its ID.");
33743
+ return {
33744
+ dispatchId: requestedDispatchId,
33745
+ runId: requestedRunId,
33746
+ url
33747
+ };
33748
+ };
33680
33749
  var watchAbsoluteMobileCiRun = async (options) => {
33681
33750
  const requestedRunId = runId(options.runId, "GitHub run ID");
33682
33751
  await requireCommand(options.run ?? defaultRunner, [
@@ -33795,6 +33864,7 @@ var renderAuditMarkdown = (audit) => `# AbsoluteJS mobile promotion audit
33795
33864
  - Artifact SHA-256: \`${audit.release.sha256}\`
33796
33865
  - Source workflow run: ${audit.github.sourceRunId}
33797
33866
  - Promotion workflow run: ${audit.github.promotionRunId}
33867
+ - Dispatch correlation: ${audit.github.dispatchId ?? "legacy workflow (not recorded)"}
33798
33868
  - Workflow: ${audit.github.workflowName}
33799
33869
  - GitHub identity: \`${audit.provenance.repository}/${audit.provenance.workflowPath}@${audit.provenance.ref}\`
33800
33870
  - Certification: \`${audit.certification.certificationId}\` (${audit.certification.strength})
@@ -33844,6 +33914,8 @@ var auditAbsoluteMobileCiPromotion = async (options) => {
33844
33914
  throw new TypeError("Promotion context run identity does not match.");
33845
33915
  if (context && context.platform !== platform3)
33846
33916
  throw new TypeError("Promotion context platform does not match.");
33917
+ if (context?.dispatchId && status.displayTitle !== promotionRunTitle(context.dispatchId))
33918
+ throw new TypeError("Promotion dispatch identity does not match the GitHub run.");
33847
33919
  const sourceRunId = options.sourceRunId ? runId(options.sourceRunId, "GitHub source run ID") : context?.sourceRunId;
33848
33920
  if (!sourceRunId)
33849
33921
  throw new TypeError("Promotion artifact predates source-run context; pass --source-run-id.");
@@ -33912,6 +33984,7 @@ var auditAbsoluteMobileCiPromotion = async (options) => {
33912
33984
  format: ABSOLUTE_MOBILE_CI_PROMOTION_AUDIT_FORMAT,
33913
33985
  github: {
33914
33986
  conclusion: status.conclusion,
33987
+ dispatchId: context?.dispatchId ?? null,
33915
33988
  promotionRunId,
33916
33989
  repository: verification.identity.repository,
33917
33990
  sourceRunId,
@@ -33950,7 +34023,7 @@ var auditAbsoluteMobileCiPromotion = async (options) => {
33950
34023
  import { existsSync as existsSync4 } from "fs";
33951
34024
  import { access as access19, mkdir as mkdir19, readFile as readFile23, writeFile as writeFile19 } from "fs/promises";
33952
34025
  import { dirname as dirname17, extname as extname5, relative as relative18, resolve as resolve20, sep as sep13 } from "path";
33953
- var ABSOLUTE_MOBILE_CI_WORKFLOW_FORMAT = 3;
34026
+ var ABSOLUTE_MOBILE_CI_WORKFLOW_FORMAT = 4;
33954
34027
  var SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
33955
34028
  var CI_ENV_INDENTATION = 6;
33956
34029
  var RESERVED_SECRET_NAMES = new Set([
@@ -34109,6 +34182,10 @@ var publishingInputs = (platforms, includePublishing) => {
34109
34182
  description: Source workflow run ID for promotion without rebuilding
34110
34183
  required: false
34111
34184
  type: string`,
34185
+ ` dispatch_id:
34186
+ description: Unique promotion correlation ID supplied by the AbsoluteJS CLI
34187
+ required: false
34188
+ type: string`,
34112
34189
  ` certification_base64:
34113
34190
  description: AbsoluteJS certification supplied by the promotion CLI
34114
34191
  required: false
@@ -34481,6 +34558,10 @@ var promotionValidationSteps = ` - name: Validate promotion handoff
34481
34558
  echo "Promotion requires a numeric source workflow run ID." >&2
34482
34559
  exit 1
34483
34560
  fi
34561
+ if [[ ! "$ABSOLUTE_PROMOTION_DISPATCH_ID" =~ ^amp_[a-f0-9]{32}$ ]]; then
34562
+ echo "Promotion requires a valid AbsoluteJS dispatch correlation ID." >&2
34563
+ exit 1
34564
+ fi
34484
34565
  if [[ -z "$ABSOLUTE_CERTIFICATION_BASE64" ]]; then
34485
34566
  echo "Promotion requires certification supplied by absolute mobile ci promote." >&2
34486
34567
  exit 1
@@ -34495,7 +34576,7 @@ var promotionSharedSteps = (platform3) => ` - name: Restore exact ${platfor
34495
34576
  - name: Record bounded promotion context
34496
34577
  shell: bash
34497
34578
  run: |
34498
- bun -e 'const sourceRunId = process.env.ABSOLUTE_SOURCE_RUN_ID; const promotionRunId = process.env.GITHUB_RUN_ID; if (!sourceRunId?.match(/^[1-9][0-9]*$/) || !promotionRunId?.match(/^[1-9][0-9]*$/)) throw new Error("Invalid promotion run identity"); await Bun.write(".absolutejs/mobile-ci/promotion-context.json", JSON.stringify({ format: 1, platform: ${JSON.stringify(platform3)}, promotionRunId, sourceArtifact: ${JSON.stringify(`absolute-mobile-${platform3}`)}, sourceRunId }, null, 2) + "\\n");'
34579
+ bun -e 'const dispatchId = process.env.ABSOLUTE_PROMOTION_DISPATCH_ID; const sourceRunId = process.env.ABSOLUTE_SOURCE_RUN_ID; const promotionRunId = process.env.GITHUB_RUN_ID; if (!dispatchId?.match(/^amp_[a-f0-9]{32}$/) || !sourceRunId?.match(/^[1-9][0-9]*$/) || !promotionRunId?.match(/^[1-9][0-9]*$/)) throw new Error("Invalid promotion run identity"); await Bun.write(".absolutejs/mobile-ci/promotion-context.json", JSON.stringify({ dispatchId, format: 2, platform: ${JSON.stringify(platform3)}, promotionRunId, sourceArtifact: ${JSON.stringify(`absolute-mobile-${platform3}`)}, sourceRunId }, null, 2) + "\\n");'
34499
34580
  - name: Import and verify exact certification
34500
34581
  shell: bash
34501
34582
  run: |
@@ -34533,6 +34614,7 @@ var androidPromotionJob = (options) => {
34533
34614
  id-token: write
34534
34615
  env:
34535
34616
  ABSOLUTE_CERTIFICATION_BASE64: \${{ inputs.certification_base64 }}
34617
+ ABSOLUTE_PROMOTION_DISPATCH_ID: \${{ inputs.dispatch_id }}
34536
34618
  ABSOLUTE_RELEASE_CHANNEL: \${{ inputs.channel }}
34537
34619
  ABSOLUTE_SOURCE_RUN_ID: \${{ inputs.source_run_id }}
34538
34620
  ABSOLUTE_PLAY_TRACK: \${{ inputs.play_track }}
@@ -34598,6 +34680,7 @@ var iosPromotionJob = (options) => {
34598
34680
  id-token: write
34599
34681
  env:
34600
34682
  ABSOLUTE_CERTIFICATION_BASE64: \${{ inputs.certification_base64 }}
34683
+ ABSOLUTE_PROMOTION_DISPATCH_ID: \${{ inputs.dispatch_id }}
34601
34684
  ABSOLUTE_RELEASE_CHANNEL: \${{ inputs.channel }}
34602
34685
  ABSOLUTE_SOURCE_RUN_ID: \${{ inputs.source_run_id }}
34603
34686
  ABSOLUTE_TESTFLIGHT_GROUP: \${{ inputs.testflight_group }}
@@ -34688,6 +34771,7 @@ var createAbsoluteMobileGithubWorkflow = (options) => {
34688
34771
  });
34689
34772
  let workflow = `# Generated by AbsoluteJS. Regenerate with: absolute mobile ci github${includePublishing ? " --publish" : ""}
34690
34773
  name: AbsoluteJS Mobile
34774
+ run-name: \${{ inputs.operation == 'promote' && format('AbsoluteJS mobile promotion [{0}]', inputs.dispatch_id) || format('AbsoluteJS mobile {0}', github.event_name) }}
34691
34775
 
34692
34776
  on:
34693
34777
  pull_request:
@@ -34713,6 +34797,7 @@ jobs:
34713
34797
  env:
34714
34798
  ${environment}${includePublishing ? `
34715
34799
  ABSOLUTE_PROMOTION_PLATFORM: \${{ inputs.platform }}
34800
+ ABSOLUTE_PROMOTION_DISPATCH_ID: \${{ inputs.dispatch_id }}
34716
34801
  ABSOLUTE_SOURCE_RUN_ID: \${{ inputs.source_run_id }}
34717
34802
  ABSOLUTE_CERTIFICATION_BASE64: \${{ inputs.certification_base64 }}` : ""}
34718
34803
  steps:
@@ -43829,6 +43914,7 @@ export {
43829
43914
  createAbsoluteRemoteIosDevProject,
43830
43915
  directAbsoluteProjectPackages,
43831
43916
  discoverAbsoluteDeviceCapabilities,
43917
+ discoverAbsoluteMobilePromotionRun,
43832
43918
  discoverAbsoluteSyncSchema,
43833
43919
  disposeAbsoluteMobilePage,
43834
43920
  drainAbsoluteMobileNativeObservability,
@@ -43909,6 +43995,7 @@ export {
43909
43995
  parseAbsoluteMobilePageEnvelope,
43910
43996
  parseAbsoluteMobilePageRequest,
43911
43997
  parseAbsoluteMobilePromotionContext,
43998
+ parseAbsoluteMobilePromotionRunList,
43912
43999
  parseAbsoluteMobileUnsignedUpdateManifest,
43913
44000
  parseAbsoluteMobileUpdateManifest,
43914
44001
  parseAbsoluteMobileUpdateRequest,
@@ -43994,5 +44081,5 @@ export {
43994
44081
  writeAbsoluteMobileUpdateRegistry
43995
44082
  };
43996
44083
 
43997
- //# debugId=1FBA634844700C1464756E2164756E21
44084
+ //# debugId=199363435B745D2564756E2164756E21
43998
44085
  //# sourceMappingURL=index.js.map