Repository navigation
Record each submission with Reactiv after reactiv app submit publishes it
#17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@reactivapp/cli': minor | ||
| --- | ||
|
|
||
| `reactiv app submit` now records the published version with Reactiv and shows where to follow it. | ||
|
|
||
| After the publish, the CLI sends the version to Reactiv, which records it as a submission. The receipt keeps its seven lines and adds two: `submission <id>` and `dashboard <link>`, the submission's page in the Reactiv Dashboard; the link is printed once more on a line of its own so it can be opened in one piece. A network or server error is tried three times in all; a refusal is not retried. | ||
|
|
||
| If the version cannot be recorded, it stays published and the CLI does not publish it again: it prints why, the version and `reactiv app submit --record <version>` on a line of its own, and exits with an error. The new `--record <version>` flag checks that it was given a draft version and then sends only that record call, with no checks, pack or publish, so it can be run once the cause is fixed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Wire types of POST /v1/submissions; responses are wrapped in {data}. Update | ||
| // this copy in the same change as the service's published submissions contract. | ||
|
|
||
| export interface SubmitRequest { | ||
| version: string | ||
| } | ||
|
|
||
| export interface SubmitResponse { | ||
| submissionId: string | ||
| status: string | ||
| dashboardUrl: string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import type {SubmitResponse} from './auth/contract/submit' | ||
| import {AuthError, sanitizeForOutput} from './auth/errors' | ||
| import {withRequestId} from './auth/messages' | ||
| import {type AuthContext, resolveIdentity, vendingFailure} from './auth/token' | ||
| import {VendingError} from './auth/vending-client' | ||
|
|
||
| export const recordSubmission = async (ctx: AuthContext, version: string): Promise<SubmitResponse> => { | ||
| const identity = await resolveIdentity(ctx) | ||
| return (await ctx.vending.submit(identity.apiKey, {version})).data | ||
| } | ||
|
|
||
| // The submissions route answered 404, or answered 2xx without a submission. | ||
| const isUnservedRecord = (error: VendingError): boolean => | ||
| error.kind === 'api' && (error.code === 'not_found' || error.status === 404 || (error.status !== undefined && error.status < 300)) | ||
|
|
||
| /** True when running the same record call again later can succeed. */ | ||
| export const isRetryable = (error: unknown): boolean => | ||
| error instanceof VendingError && (error.kind === 'unreachable' || error.kind === 'rate_limited' || isUnservedRecord(error)) | ||
|
|
||
| /** | ||
| * The reason to print for a failed record call. Key and store refusals get the | ||
| * same text and stored-login cleanup as every other call. The cases where that | ||
| * text would speak of the token service, the token cache or updating the CLI | ||
| * have their own sentence here. | ||
| */ | ||
| export const describeRecordFailure = async (ctx: AuthContext, error: unknown): Promise<string> => { | ||
| if (error instanceof VendingError && error.kind === 'rate_limited') { | ||
| return withRequestId('Too many submissions — try again later.', error.requestId) | ||
| } | ||
| if (error instanceof VendingError && error.kind === 'unreachable') { | ||
| return withRequestId('Reactiv could not be reached to record the submission.', error.requestId) | ||
| } | ||
| if (error instanceof VendingError && isUnservedRecord(error)) { | ||
| const sentence = | ||
| error.status === 404 || error.code === 'not_found' | ||
| ? 'Reactiv could not find the submissions service (HTTP 404). Contact Reactiv if this continues.' | ||
| : `Reactiv's answer did not contain the submission (HTTP ${error.status}). Contact Reactiv if this continues.` | ||
| return withRequestId(sentence, error.requestId) | ||
| } | ||
| try { | ||
| await vendingFailure(ctx, ctx.memo?.identity, error) | ||
| } catch (failure) { | ||
| if (failure instanceof AuthError) return failure.message | ||
| if (failure instanceof Error) return `The submission could not be recorded: ${sanitizeForOutput(failure.message)}` | ||
| } | ||
| return 'The submission could not be recorded.' | ||
| } | ||
|
|
||
| export const recordCommand = (version: string): string => `reactiv app submit --record ${sanitizeForOutput(version)}` | ||
|
|
||
| export const publishedNotRecorded = (version: string): string => | ||
| `Version ${sanitizeForOutput(version)} is published but not recorded. Once the cause is fixed, record it without publishing again:` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.