@mintlify/cli 4.0.1804 → 4.0.1806

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.
@@ -123,6 +123,15 @@ describe('claim command', () => {
123
123
  fetchMock.mock.calls.some(([url]) => url.endsWith('/signup') || url.endsWith('/complete'))
124
124
  ).toBe(false);
125
125
  });
126
+ it('explains a claim link refused for too many pending attempts', async () => {
127
+ const respond = fetchMock.getMockImplementation()!;
128
+ fetchMock.mockImplementation(async (url: string) =>
129
+ url.endsWith('/claim') ? response({ error: 'too_many_attempts' }, 429) : respond(url)
130
+ );
131
+ await expect(
132
+ claimDeployment({ apiUrl, directory: '/docs', email: 'person@example.com' })
133
+ ).rejects.toThrow('Too many claim links are still pending');
134
+ });
126
135
  it('fails before network calls when credentials are missing', async () => {
127
136
  vi.mocked(loadAgentCredentials).mockResolvedValue(null);
128
137
  await expect(claimDeployment(options)).rejects.toThrow('No saved agent registration');
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { z } from 'zod';
11
11
  import { agentIdentityAssertionSchema, discoverAgentAuth, exchangeAgentToken, } from './agent-auth.js';
12
12
  import { loadAgentCredentials, saveAgentCredentials, } from './agent-credentials.js';
13
- import { agentRequest, agentResponse } from './agent-http.js';
13
+ import { AgentApiError, agentRequest, agentResponse } from './agent-http.js';
14
14
  import { DASHBOARD_URL } from './constants.js';
15
15
  import { trackEvent } from './telemetry/track.js';
16
16
  const claimAttemptSchema = z.object({ attempt: z.object({ verification_uri: z.url() }) });
@@ -29,7 +29,12 @@ export function createAgentClaimLink(apiUrl, credentials, email) {
29
29
  claim_token: credentials.claimToken,
30
30
  login_hint: loginHint,
31
31
  }),
32
- }), claimAttemptSchema);
32
+ }), claimAttemptSchema).catch((error) => {
33
+ if (error instanceof AgentApiError && error.code === 'too_many_attempts') {
34
+ throw new Error('Too many claim links are still pending. Send the user the last claim link, or wait 5 minutes and retry.');
35
+ }
36
+ throw error;
37
+ });
33
38
  const token = z
34
39
  .string()
35
40
  .min(1)
package/bin/cli.js CHANGED
@@ -250,8 +250,9 @@ export const cli = ({ packageName = 'mint' }) => {
250
250
  process.stderr.write('Creating the claim link...\n');
251
251
  claimUrl = yield createAgentClaimLink(API_URL, result.credentials, argv.email);
252
252
  }
253
- catch (_a) {
254
- process.stderr.write('Warning: Could not create the claim link. Your site is provisioned; retry with --email later.\n');
253
+ catch (error) {
254
+ const reason = error instanceof Error ? ` ${error.message}` : '';
255
+ process.stderr.write(`Warning: Could not create the claim link.${reason} Your site is provisioned; retry with --email later.\n`);
255
256
  }
256
257
  }
257
258
  process.stdout.write(`${deploymentInstructions(result, claimUrl)}\n`);