paperclip-github-plugin 0.8.8 → 0.8.9

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.
package/dist/worker.js CHANGED
@@ -782,15 +782,15 @@ var PaperclipLabelSyncError = class extends Error {
782
782
  const location = params.paperclipApiBaseUrl ? ` at ${params.paperclipApiBaseUrl}` : "";
783
783
  let message;
784
784
  if (failure?.requiresAuthentication) {
785
- message = `Could not map ${labelSubject} because the worker reached an authenticated Paperclip API response${location} instead of JSON. Connect Paperclip board access in plugin settings, set \`PAPERCLIP_API_URL\` to a worker-accessible Paperclip API origin, or expose the local Paperclip API to the worker without browser-session auth.`;
785
+ message = `Could not map ${labelSubject} because the worker reached an authenticated Paperclip API response${location} instead of JSON. Connect Paperclip board access in plugin settings, set Worker Paperclip API URL to a worker-accessible Paperclip API origin, or expose the local Paperclip API to the worker without browser-session auth.`;
786
786
  } else if (failure?.status === 404 || failure?.status === 405) {
787
- message = `Could not map ${labelSubject} because the Paperclip label API${location} is not available to the worker. Set \`PAPERCLIP_API_URL\` to a worker-accessible Paperclip API origin, then retry sync.`;
787
+ message = `Could not map ${labelSubject} because the Paperclip label API${location} is not available to the worker. Set Worker Paperclip API URL to a worker-accessible Paperclip API origin, then retry sync.`;
788
788
  } else if (failure?.errorMessage) {
789
789
  message = `Could not map ${labelSubject} because the Paperclip label API${location} failed: ${failure.errorMessage}`;
790
790
  } else if (params.paperclipApiBaseUrl) {
791
791
  message = `Could not map ${labelSubject} because the Paperclip label API at ${params.paperclipApiBaseUrl} is unavailable to the worker.`;
792
792
  } else {
793
- message = `Could not map ${labelSubject} because no worker-accessible Paperclip label API is configured. Set \`PAPERCLIP_API_URL\` to a worker-accessible Paperclip API origin, then retry sync.`;
793
+ message = `Could not map ${labelSubject} because no worker-accessible Paperclip label API is configured. Set Worker Paperclip API URL to a worker-accessible Paperclip API origin, then retry sync.`;
794
794
  }
795
795
  super(message);
796
796
  this.status = failure?.status;
@@ -1514,6 +1514,39 @@ function getErrorMessage(error) {
1514
1514
  }
1515
1515
  return String(error);
1516
1516
  }
1517
+ function getErrorCause(error) {
1518
+ if (!error || typeof error !== "object" || !("cause" in error)) {
1519
+ return void 0;
1520
+ }
1521
+ return error.cause;
1522
+ }
1523
+ function getErrorCode(error) {
1524
+ if (!error || typeof error !== "object" || !("code" in error)) {
1525
+ return void 0;
1526
+ }
1527
+ const code = error.code;
1528
+ return typeof code === "string" && code.trim() ? code.trim() : void 0;
1529
+ }
1530
+ function getErrorDiagnosticMessage(error) {
1531
+ const primaryMessage = getErrorMessage(error).trim();
1532
+ const cause = getErrorCause(error);
1533
+ const causeMessage = cause ? getErrorMessage(cause).trim() : "";
1534
+ const errorCode = getErrorCode(error);
1535
+ const causeCode = cause ? getErrorCode(cause) : void 0;
1536
+ const code = errorCode ?? causeCode;
1537
+ const parts = [primaryMessage || String(error)];
1538
+ if (causeMessage && causeMessage !== primaryMessage) {
1539
+ parts.push(`cause: ${causeMessage}`);
1540
+ }
1541
+ if (code) {
1542
+ parts.push(`code: ${code}`);
1543
+ }
1544
+ return parts.join(" | ");
1545
+ }
1546
+ function formatPaperclipApiFetchErrorMessage(error, url, init) {
1547
+ const method = typeof init?.method === "string" && init.method.trim() ? init.method.trim().toUpperCase() : "GET";
1548
+ return `Paperclip API fetch failed (${method} ${url}): ${getErrorDiagnosticMessage(error)}`;
1549
+ }
1517
1550
  function isPaperclipLabelSyncError(error) {
1518
1551
  return error instanceof PaperclipLabelSyncError;
1519
1552
  }
@@ -2135,12 +2168,12 @@ function getSyncFailureSuggestedAction(error, context) {
2135
2168
  }
2136
2169
  if (isPaperclipLabelSyncError(error)) {
2137
2170
  if (error.requiresAuthentication || error.status === 401 || error.status === 403) {
2138
- return "The worker could not reuse the board login session for the Paperclip label API. Connect Paperclip board access in settings, or set `PAPERCLIP_API_URL` to a worker-accessible Paperclip API origin, then retry sync.";
2171
+ return "The worker could not reuse the board login session for the Paperclip label API. Connect Paperclip board access in settings, or set Worker Paperclip API URL to a worker-accessible Paperclip API origin, then retry sync.";
2139
2172
  }
2140
2173
  if (error.paperclipApiBaseUrl) {
2141
2174
  return `Confirm that the Paperclip label API at ${error.paperclipApiBaseUrl} is reachable from the plugin worker and returns JSON, then retry sync.`;
2142
2175
  }
2143
- return "Set `PAPERCLIP_API_URL` to a worker-accessible Paperclip API origin, then retry sync.";
2176
+ return "Set Worker Paperclip API URL to a worker-accessible Paperclip API origin, then retry sync.";
2144
2177
  }
2145
2178
  const rawMessage = getErrorMessage(error).trim().toLowerCase();
2146
2179
  if (rawMessage.includes("could not resolve to a pullrequest")) {
@@ -3955,17 +3988,7 @@ function normalizePaperclipApiBaseUrlByCompanyId(value) {
3955
3988
  }).filter((entry) => entry !== null);
3956
3989
  return entries.length > 0 ? Object.fromEntries(entries) : void 0;
3957
3990
  }
3958
- function getRuntimePaperclipApiBaseUrl() {
3959
- if (typeof process === "undefined" || !process?.env) {
3960
- return void 0;
3961
- }
3962
- return normalizePaperclipApiBaseUrl(process.env.PAPERCLIP_API_URL);
3963
- }
3964
3991
  function resolvePaperclipApiBaseUrl(...values) {
3965
- const runtimePaperclipApiBaseUrl = getRuntimePaperclipApiBaseUrl();
3966
- if (runtimePaperclipApiBaseUrl) {
3967
- return runtimePaperclipApiBaseUrl;
3968
- }
3969
3992
  for (const value of values) {
3970
3993
  const normalizedValue = normalizePaperclipApiBaseUrl(value);
3971
3994
  if (normalizedValue) {
@@ -3983,10 +4006,6 @@ function getConfiguredPaperclipApiBaseUrl(settings, config, companyId) {
3983
4006
  ) : resolvePaperclipApiBaseUrl(config?.paperclipApiBaseUrl, settings?.paperclipApiBaseUrl);
3984
4007
  }
3985
4008
  function resolveTrustedPaperclipApiBaseUrlInput(value, settings, config, companyId) {
3986
- const runtimePaperclipApiBaseUrl = getRuntimePaperclipApiBaseUrl();
3987
- if (runtimePaperclipApiBaseUrl) {
3988
- return runtimePaperclipApiBaseUrl;
3989
- }
3990
4009
  const requestedPaperclipApiBaseUrl = normalizePaperclipApiBaseUrl(value);
3991
4010
  const configuredPaperclipApiBaseUrl = normalizePaperclipApiBaseUrl(config?.paperclipApiBaseUrl);
3992
4011
  const normalizedCompanyId = normalizeCompanyId(companyId);
@@ -5637,9 +5656,6 @@ function resolvePaperclipIssueStatus(params) {
5637
5656
  }
5638
5657
  function resolvePaperclipPullRequestIssueStatus(params) {
5639
5658
  const { currentStatus, pullRequest, hasExecutorHandoffTarget } = params;
5640
- if (currentStatus === "done" || currentStatus === "cancelled") {
5641
- return currentStatus;
5642
- }
5643
5659
  if (shouldPreserveBlockedExternalPullRequestWait({
5644
5660
  currentStatus,
5645
5661
  linkedPullRequests: [pullRequest]
@@ -5648,7 +5664,7 @@ function resolvePaperclipPullRequestIssueStatus(params) {
5648
5664
  }
5649
5665
  return resolvePaperclipStatusFromLinkedPullRequests([pullRequest], {
5650
5666
  preferInProgress: hasExecutorHandoffTarget,
5651
- preserveTransientUnknownMergeabilityWait: currentStatus === "in_review"
5667
+ preserveTransientUnknownMergeabilityWait: currentStatus === "done" || currentStatus === "in_review"
5652
5668
  });
5653
5669
  }
5654
5670
  async function listLinkedPullRequestsForIssue(octokit, repository, issueNumber) {
@@ -7828,7 +7844,14 @@ function applyPaperclipApiAuthentication(init, companyId) {
7828
7844
  };
7829
7845
  }
7830
7846
  async function fetchPaperclipApi(url, init, options) {
7831
- return fetch(url, applyPaperclipApiAuthentication(init, options?.companyId));
7847
+ const authenticatedInit = applyPaperclipApiAuthentication(init, options?.companyId);
7848
+ try {
7849
+ return await fetch(url, authenticatedInit);
7850
+ } catch (error) {
7851
+ throw new Error(formatPaperclipApiFetchErrorMessage(error, url, authenticatedInit), {
7852
+ cause: error
7853
+ });
7854
+ }
7832
7855
  }
7833
7856
  async function detectPaperclipBoardAccessRequirement(paperclipApiBaseUrl) {
7834
7857
  if (!paperclipApiBaseUrl) {
@@ -15113,6 +15136,7 @@ function shouldStartWorkerHost(moduleUrl, entry = process.argv[1]) {
15113
15136
  var __testing = {
15114
15137
  buildSyncFallbackExecutionStatePatch,
15115
15138
  createGitHubToolOctokit,
15139
+ formatPaperclipApiFetchErrorMessage,
15116
15140
  hasUnresolvedPaperclipIssueBlocker,
15117
15141
  isHealthyMaintainerWaitTransition,
15118
15142
  resolveSyncTransitionAssignee
@@ -15148,6 +15172,7 @@ var plugin = definePlugin({
15148
15172
  ...getPublicSettingsForScope(settingsForResponse, requestedCompanyId),
15149
15173
  ...includeAssignees ? { availableAssignees } : {},
15150
15174
  totalSyncedIssuesCount: countImportedIssuesForMappings(importRegistry, scopedMappings),
15175
+ paperclipApiBaseUrlConfigured: Boolean(normalizePaperclipApiBaseUrl(config.paperclipApiBaseUrl)),
15151
15176
  githubTokenConfigured,
15152
15177
  paperclipBoardAccessConfigured: requestedCompanyId ? hasConfiguredPaperclipBoardAccess(settingsForResponse, config, requestedCompanyId) : hasConfiguredPaperclipBoardAccessForMappings(settingsForResponse, config, scopedMappings),
15153
15178
  ...savedBoardTokenRef ? { paperclipBoardAccessConfigSyncRef: savedBoardTokenRef } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",