feat(profile): add the manual candidate profile contract and storage
This commit is contained in:
1 parent
d21fd49a42
commit
e52ffe7bcb
97 files changed
+20442
-63
No files matched your search
@@ -21,6 +21,7 @@ var regexMap = map[string]ogenregex.Regexp{
|
||||
"^(/([^~/]|~[01])*)*$": ogenregex.MustCompile("^(/([^~/]|~[01])*)*$"),
|
||||
"^@[A-Za-z0-9_]{5,32}$": ogenregex.MustCompile("^@[A-Za-z0-9_]{5,32}$"),
|
||||
"^SC-[0-9]{4}-[0-9]{6,10}$": ogenregex.MustCompile("^SC-[0-9]{4}-[0-9]{6,10}$"),
|
||||
"^[0-9]{4}-(0[1-9]|1[0-2])$": ogenregex.MustCompile("^[0-9]{4}-(0[1-9]|1[0-2])$"),
|
||||
"^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"),
|
||||
"^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"),
|
||||
"^[A-Za-z0-9_-]+$": ogenregex.MustCompile("^[A-Za-z0-9_-]+$"),
|
||||
|
||||
@@ -4239,6 +4239,208 @@ func (s *Server) handleGetMyInvitationRequest(args [1]string, argsEscaped bool,
|
||||
}
|
||||
}
|
||||
|
||||
// handleGetMyProfileRequest handles GetMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
// a request parameter. A candidate who has not saved the profile yet gets 200 with version 0, every
|
||||
// single field `unknown`, and empty lists rather than 404, so the client reads the version for the
|
||||
// first save in the same way as for later ones and a missing profile is not an error state.
|
||||
//
|
||||
// The profile is personal data that only its owner reads: full name, contacts, work history, and the
|
||||
// lowest salary. It is a private resource and never an organization-visible one; organizations see a
|
||||
// candidate through the anonymous card and, after an accepted invitation, through the contact grant,
|
||||
// and no organization contract refers to this schema. The response is `Cache-Control: no-store`, and
|
||||
// the server never writes its values to logs, metrics, URLs, or events.
|
||||
//
|
||||
// Every value carries its confirmation state and provenance, and every claim has trust level 0. The
|
||||
// self-assessed grade of a role is separate from `confirmed_categories`, which only assessment results
|
||||
// establish and which no request writes. The profile needs no file, no ML extraction, and no FSP
|
||||
// account.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/profile
|
||||
func (s *Server) handleGetMyProfileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("GetMyProfile"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/me/profile"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), GetMyProfileOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Add Labeler to context.
|
||||
labeler := &Labeler{attrs: otelAttrs}
|
||||
ctx = contextWithLabeler(ctx, labeler)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
code := statusWriter.status
|
||||
if code != 0 {
|
||||
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||
attrs = append(attrs, codeAttr)
|
||||
span.SetAttributes(attrs...)
|
||||
}
|
||||
attrOpt := metric.WithAttributes(attrs...)
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, attrOpt)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||
}()
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
|
||||
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
if code != 0 {
|
||||
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||
}
|
||||
|
||||
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: GetMyProfileOperation,
|
||||
ID: "GetMyProfile",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCookie(ctx, GetMyProfileOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCookie",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCookie", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 0
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
|
||||
if ok := func() bool {
|
||||
nextRequirement:
|
||||
for _, requirement := range []bitset{
|
||||
{0b00000001},
|
||||
} {
|
||||
for i, mask := range requirement {
|
||||
if satisfied[i]&mask != mask {
|
||||
continue nextRequirement
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}(); !ok {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var rawBody []byte
|
||||
|
||||
var response GetMyProfileRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: GetMyProfileOperation,
|
||||
OperationSummary: "Read the private profile of the current candidate.",
|
||||
OperationID: "GetMyProfile",
|
||||
Body: nil,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = struct{}
|
||||
Response = GetMyProfileRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
nil,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.GetMyProfile(ctx)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.GetMyProfile(ctx)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
|
||||
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ht.ErrNotImplemented) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeGetMyProfileResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleGetMyQuestionnaireRequest handles GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -8055,6 +8257,269 @@ func (s *Server) handleResendEmailVerificationRequest(args [0]string, argsEscape
|
||||
}
|
||||
}
|
||||
|
||||
// handleSaveMyProfileRequest handles SaveMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new state of every field and list; see
|
||||
// CandidateProfileUpdate for the decisions that it carries. It replaces the stored profile as a whole.
|
||||
//
|
||||
// Every field is optional in substance: a profile can be saved with any subset filled and the rest
|
||||
// null or empty, so no value requires a resume, the ML service, an FSP account, or any other file or
|
||||
// link. Which fields are needed to leave the onboarding step candidate_profile is an open product
|
||||
// question that this contract does not decide; a save on that step advancing the account to
|
||||
// candidate_questionnaire is planned.
|
||||
//
|
||||
// Provenance is the server's: a value typed in the form is `manual`, confirming a stored suggestion
|
||||
// keeps its origin, and every claim keeps trust level 0. The body has no origin, trust level,
|
||||
// confirmation time, confirmed grade, or category, and unknown fields are rejected. A self-assessed
|
||||
// grade never becomes a confirmed grade or a category.
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read,
|
||||
// 0 for the first save. If it is not the current version, the server answers 412 version_conflict and
|
||||
// changes nothing, and the client reads the profile again and reapplies its edits, so a concurrent
|
||||
// edit from another tab or device is never lost silently. The version travels in the body rather than
|
||||
// in If-Match because the generated client cannot read the ETag response header yet, as for the
|
||||
// questionnaire; the status and code are the same as for a failed If-Match.
|
||||
//
|
||||
// The operation needs no Idempotency-Key: it replaces the whole state and is idempotent. A body whose
|
||||
// values equal the stored ones, with the same decisions, changes nothing, keeps the version, and
|
||||
// answers 200 with the current profile even when `expected_version` is older, so a retry after a lost
|
||||
// response of a successful save succeeds instead of failing with 412. A version above the current one
|
||||
// never existed and always answers 412 version_conflict, even for an unchanged body.
|
||||
//
|
||||
// The save replaces the stored claims as a whole. A suggestion that an import stored and that the
|
||||
// client did not render and send back with the decision `extracted` is dropped by the save; a client
|
||||
// therefore sends every suggestion that it received, and a client that read an older version gets 412
|
||||
// instead of silently dropping a suggestion it never saw.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), domain
|
||||
// rules that depend on the body alone (400), then the rules that depend on the stored claims against
|
||||
// the version: a decision `extracted` for a value that is not a stored suggestion answers 412 when
|
||||
// `expected_version` is stale, because another save may have confirmed that value, and 400 when it is
|
||||
// current; an unchanged body (200); any other change over a stale version (412). The schema rejects an
|
||||
// unknown field, an unknown specialization or grade, a phone number outside E.164, a Telegram username
|
||||
// without the leading @, an email that is not an address, a month outside `YYYY-MM`, a salary that is
|
||||
// not a positive multiple of 1000, and more items than a list allows. The server also rejects a
|
||||
// repeated tag, skill, or role specialization, a period that ends before it starts or lies in the
|
||||
// future, and a decision `extracted` for a value that is not a stored suggestion, with 400
|
||||
// validation_failed and pointers to the items, for example `/roles/1/specialization` or
|
||||
// `/stack/1/status`. Error bodies never repeat a submitted value.
|
||||
//
|
||||
// PUT /api/v1/me/profile
|
||||
func (s *Server) handleSaveMyProfileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("SaveMyProfile"),
|
||||
semconv.HTTPRequestMethodKey.String("PUT"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/me/profile"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), SaveMyProfileOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Add Labeler to context.
|
||||
labeler := &Labeler{attrs: otelAttrs}
|
||||
ctx = contextWithLabeler(ctx, labeler)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
code := statusWriter.status
|
||||
if code != 0 {
|
||||
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||
attrs = append(attrs, codeAttr)
|
||||
span.SetAttributes(attrs...)
|
||||
}
|
||||
attrOpt := metric.WithAttributes(attrs...)
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, attrOpt)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||
}()
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
|
||||
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
if code != 0 {
|
||||
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||
}
|
||||
|
||||
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: SaveMyProfileOperation,
|
||||
ID: "SaveMyProfile",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCookie(ctx, SaveMyProfileOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCookie",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCookie", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 0
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCsrf(ctx, SaveMyProfileOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCsrf",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCsrf", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 1
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
|
||||
if ok := func() bool {
|
||||
nextRequirement:
|
||||
for _, requirement := range []bitset{
|
||||
{0b00000011},
|
||||
} {
|
||||
for i, mask := range requirement {
|
||||
if satisfied[i]&mask != mask {
|
||||
continue nextRequirement
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}(); !ok {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var rawBody []byte
|
||||
request, rawBody, close, err := s.decodeSaveMyProfileRequest(r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeRequestError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
defer recordError("DecodeRequest", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := close(); err != nil {
|
||||
recordError("CloseRequest", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var response SaveMyProfileRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: SaveMyProfileOperation,
|
||||
OperationSummary: "Replace the private profile of the current candidate.",
|
||||
OperationID: "SaveMyProfile",
|
||||
Body: request,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = *CandidateProfileUpdate
|
||||
Params = struct{}
|
||||
Response = SaveMyProfileRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
nil,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.SaveMyProfile(ctx, request)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.SaveMyProfile(ctx, request)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
|
||||
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ht.ErrNotImplemented) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeSaveMyProfileResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleSaveMyQuestionnaireRequest handles SaveMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
|
||||
@@ -69,6 +69,10 @@ type GetMyInvitationRes interface {
|
||||
getMyInvitationRes()
|
||||
}
|
||||
|
||||
type GetMyProfileRes interface {
|
||||
getMyProfileRes()
|
||||
}
|
||||
|
||||
type GetMyQuestionnaireRes interface {
|
||||
getMyQuestionnaireRes()
|
||||
}
|
||||
@@ -137,6 +141,10 @@ type ResendEmailVerificationRes interface {
|
||||
resendEmailVerificationRes()
|
||||
}
|
||||
|
||||
type SaveMyProfileRes interface {
|
||||
saveMyProfileRes()
|
||||
}
|
||||
|
||||
type SaveMyQuestionnaireRes interface {
|
||||
saveMyQuestionnaireRes()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -24,6 +24,7 @@ const (
|
||||
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
|
||||
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
|
||||
GetMyInvitationOperation OperationName = "GetMyInvitation"
|
||||
GetMyProfileOperation OperationName = "GetMyProfile"
|
||||
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
|
||||
GetMySupportCaseOperation OperationName = "GetMySupportCase"
|
||||
GetOrganizationOperation OperationName = "GetOrganization"
|
||||
@@ -42,6 +43,7 @@ const (
|
||||
RaiseOrganizationInvitationSalaryOperation OperationName = "RaiseOrganizationInvitationSalary"
|
||||
RegisterAccountOperation OperationName = "RegisterAccount"
|
||||
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
|
||||
SaveMyProfileOperation OperationName = "SaveMyProfile"
|
||||
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
|
||||
SendOrganizationInvitationOperation OperationName = "SendOrganizationInvitation"
|
||||
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
|
||||
|
||||
@@ -1120,6 +1120,85 @@ func (s *Server) decodeResendEmailVerificationRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSaveMyProfileRequest(r *http.Request) (
|
||||
req *CandidateProfileUpdate,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request CandidateProfileUpdate
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSaveMyQuestionnaireRequest(r *http.Request) (
|
||||
req *CandidateQuestionnaireUpdate,
|
||||
rawBody []byte,
|
||||
|
||||
@@ -1766,6 +1766,65 @@ func encodeGetMyInvitationResponse(response GetMyInvitationRes, w http.ResponseW
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyProfileResponse(response GetMyProfileRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateProfileHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyProfileUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyProfileForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyQuestionnaireResponse(response GetMyQuestionnaireRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateQuestionnaireHeaders:
|
||||
@@ -3178,6 +3237,89 @@ func encodeResendEmailVerificationResponse(response ResendEmailVerificationRes,
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSaveMyProfileResponse(response SaveMyProfileRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateProfileHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SaveMyProfileBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SaveMyProfileUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SaveMyProfileForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SaveMyProfilePreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSaveMyQuestionnaireResponse(response SaveMyQuestionnaireRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateQuestionnaireHeaders:
|
||||
|
||||
@@ -11,16 +11,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
rn48AllowedHeaders = map[string]string{
|
||||
rn49AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn7AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn46AllowedHeaders = map[string]string{
|
||||
rn47AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key",
|
||||
}
|
||||
rn43AllowedHeaders = map[string]string{
|
||||
rn44AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn25AllowedHeaders = map[string]string{
|
||||
@@ -29,7 +29,7 @@ var (
|
||||
rn9AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn51AllowedHeaders = map[string]string{
|
||||
rn52AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn20AllowedHeaders = map[string]string{
|
||||
@@ -44,12 +44,15 @@ var (
|
||||
rn17AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn52AllowedHeaders = map[string]string{
|
||||
rn53AllowedHeaders = map[string]string{
|
||||
"POST": "X-Csrf-Token",
|
||||
}
|
||||
rn31AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn32AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn10AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
@@ -62,22 +65,22 @@ var (
|
||||
rn14AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn35AllowedHeaders = map[string]string{
|
||||
rn36AllowedHeaders = map[string]string{
|
||||
"PATCH": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn45AllowedHeaders = map[string]string{
|
||||
rn46AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn50AllowedHeaders = map[string]string{
|
||||
rn51AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn53AllowedHeaders = map[string]string{
|
||||
rn54AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn16AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn38AllowedHeaders = map[string]string{
|
||||
rn39AllowedHeaders = map[string]string{
|
||||
"PATCH": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
)
|
||||
@@ -234,7 +237,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn48AllowedHeaders,
|
||||
allowedHeaders: rn49AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -311,7 +314,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn46AllowedHeaders,
|
||||
allowedHeaders: rn47AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -335,7 +338,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn43AllowedHeaders,
|
||||
allowedHeaders: rn44AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -488,7 +491,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn51AllowedHeaders,
|
||||
allowedHeaders: rn52AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -779,7 +782,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn52AllowedHeaders,
|
||||
allowedHeaders: rn53AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -819,6 +822,33 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "profile"
|
||||
|
||||
if l := len("profile"); len(elem) >= l && elem[0:l] == "profile" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleSaveMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn31AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
|
||||
if l := len("questionnaire"); len(elem) >= l && elem[0:l] == "questionnaire" {
|
||||
@@ -837,7 +867,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn31AllowedHeaders,
|
||||
allowedHeaders: rn32AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1049,7 +1079,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PATCH",
|
||||
allowedHeaders: rn35AllowedHeaders,
|
||||
allowedHeaders: rn36AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "application/json",
|
||||
})
|
||||
@@ -1129,7 +1159,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn45AllowedHeaders,
|
||||
allowedHeaders: rn46AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1157,7 +1187,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn50AllowedHeaders,
|
||||
allowedHeaders: rn51AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1187,7 +1217,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn53AllowedHeaders,
|
||||
allowedHeaders: rn54AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1265,7 +1295,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PATCH",
|
||||
allowedHeaders: rn38AllowedHeaders,
|
||||
allowedHeaders: rn39AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "application/json",
|
||||
})
|
||||
@@ -2080,6 +2110,40 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "profile"
|
||||
|
||||
if l := len("profile"); len(elem) >= l && elem[0:l] == "profile" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyProfileOperation
|
||||
r.summary = "Read the private profile of the current candidate."
|
||||
r.operationID = "GetMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = SaveMyProfileOperation
|
||||
r.summary = "Replace the private profile of the current candidate."
|
||||
r.operationID = "SaveMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
|
||||
if l := len("questionnaire"); len(elem) >= l && elem[0:l] == "questionnaire" {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -71,6 +71,7 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
GetMyAssessmentAvailabilityOperation: []string{},
|
||||
GetMyAssessmentResultOperation: []string{},
|
||||
GetMyInvitationOperation: []string{},
|
||||
GetMyProfileOperation: []string{},
|
||||
GetMyQuestionnaireOperation: []string{},
|
||||
GetMySupportCaseOperation: []string{},
|
||||
GetOrganizationOperation: []string{},
|
||||
@@ -85,6 +86,7 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
ListOrganizationNeedsOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
RaiseOrganizationInvitationSalaryOperation: []string{},
|
||||
SaveMyProfileOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
@@ -129,6 +131,7 @@ var operationRolesSessionCsrf = map[string][]string{
|
||||
FinalizeMyAssessmentAttemptOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
RaiseOrganizationInvitationSalaryOperation: []string{},
|
||||
SaveMyProfileOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
|
||||
@@ -603,6 +603,29 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/me/invitations/{invitation_id}
|
||||
GetMyInvitation(ctx context.Context, params GetMyInvitationParams) (GetMyInvitationRes, error)
|
||||
// GetMyProfile implements GetMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
// a request parameter. A candidate who has not saved the profile yet gets 200 with version 0, every
|
||||
// single field `unknown`, and empty lists rather than 404, so the client reads the version for the
|
||||
// first save in the same way as for later ones and a missing profile is not an error state.
|
||||
//
|
||||
// The profile is personal data that only its owner reads: full name, contacts, work history, and the
|
||||
// lowest salary. It is a private resource and never an organization-visible one; organizations see a
|
||||
// candidate through the anonymous card and, after an accepted invitation, through the contact grant,
|
||||
// and no organization contract refers to this schema. The response is `Cache-Control: no-store`, and
|
||||
// the server never writes its values to logs, metrics, URLs, or events.
|
||||
//
|
||||
// Every value carries its confirmation state and provenance, and every claim has trust level 0. The
|
||||
// self-assessed grade of a role is separate from `confirmed_categories`, which only assessment results
|
||||
// establish and which no request writes. The profile needs no file, no ML extraction, and no FSP
|
||||
// account.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/profile
|
||||
GetMyProfile(ctx context.Context) (GetMyProfileRes, error)
|
||||
// GetMyQuestionnaire implements GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -1038,6 +1061,57 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/identity/email-verification-requests
|
||||
ResendEmailVerification(ctx context.Context, req *EmailVerificationResendRequest) (ResendEmailVerificationRes, error)
|
||||
// SaveMyProfile implements SaveMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new state of every field and list; see
|
||||
// CandidateProfileUpdate for the decisions that it carries. It replaces the stored profile as a whole.
|
||||
//
|
||||
// Every field is optional in substance: a profile can be saved with any subset filled and the rest
|
||||
// null or empty, so no value requires a resume, the ML service, an FSP account, or any other file or
|
||||
// link. Which fields are needed to leave the onboarding step candidate_profile is an open product
|
||||
// question that this contract does not decide; a save on that step advancing the account to
|
||||
// candidate_questionnaire is planned.
|
||||
//
|
||||
// Provenance is the server's: a value typed in the form is `manual`, confirming a stored suggestion
|
||||
// keeps its origin, and every claim keeps trust level 0. The body has no origin, trust level,
|
||||
// confirmation time, confirmed grade, or category, and unknown fields are rejected. A self-assessed
|
||||
// grade never becomes a confirmed grade or a category.
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read,
|
||||
// 0 for the first save. If it is not the current version, the server answers 412 version_conflict and
|
||||
// changes nothing, and the client reads the profile again and reapplies its edits, so a concurrent
|
||||
// edit from another tab or device is never lost silently. The version travels in the body rather than
|
||||
// in If-Match because the generated client cannot read the ETag response header yet, as for the
|
||||
// questionnaire; the status and code are the same as for a failed If-Match.
|
||||
//
|
||||
// The operation needs no Idempotency-Key: it replaces the whole state and is idempotent. A body whose
|
||||
// values equal the stored ones, with the same decisions, changes nothing, keeps the version, and
|
||||
// answers 200 with the current profile even when `expected_version` is older, so a retry after a lost
|
||||
// response of a successful save succeeds instead of failing with 412. A version above the current one
|
||||
// never existed and always answers 412 version_conflict, even for an unchanged body.
|
||||
//
|
||||
// The save replaces the stored claims as a whole. A suggestion that an import stored and that the
|
||||
// client did not render and send back with the decision `extracted` is dropped by the save; a client
|
||||
// therefore sends every suggestion that it received, and a client that read an older version gets 412
|
||||
// instead of silently dropping a suggestion it never saw.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), domain
|
||||
// rules that depend on the body alone (400), then the rules that depend on the stored claims against
|
||||
// the version: a decision `extracted` for a value that is not a stored suggestion answers 412 when
|
||||
// `expected_version` is stale, because another save may have confirmed that value, and 400 when it is
|
||||
// current; an unchanged body (200); any other change over a stale version (412). The schema rejects an
|
||||
// unknown field, an unknown specialization or grade, a phone number outside E.164, a Telegram username
|
||||
// without the leading @, an email that is not an address, a month outside `YYYY-MM`, a salary that is
|
||||
// not a positive multiple of 1000, and more items than a list allows. The server also rejects a
|
||||
// repeated tag, skill, or role specialization, a period that ends before it starts or lies in the
|
||||
// future, and a decision `extracted` for a value that is not a stored suggestion, with 400
|
||||
// validation_failed and pointers to the items, for example `/roles/1/specialization` or
|
||||
// `/stack/1/status`. Error bodies never repeat a submitted value.
|
||||
//
|
||||
// PUT /api/v1/me/profile
|
||||
SaveMyProfile(ctx context.Context, req *CandidateProfileUpdate) (SaveMyProfileRes, error)
|
||||
// SaveMyQuestionnaire implements SaveMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
|
||||
@@ -662,6 +662,32 @@ func (UnimplementedHandler) GetMyInvitation(ctx context.Context, params GetMyInv
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyProfile implements GetMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
// a request parameter. A candidate who has not saved the profile yet gets 200 with version 0, every
|
||||
// single field `unknown`, and empty lists rather than 404, so the client reads the version for the
|
||||
// first save in the same way as for later ones and a missing profile is not an error state.
|
||||
//
|
||||
// The profile is personal data that only its owner reads: full name, contacts, work history, and the
|
||||
// lowest salary. It is a private resource and never an organization-visible one; organizations see a
|
||||
// candidate through the anonymous card and, after an accepted invitation, through the contact grant,
|
||||
// and no organization contract refers to this schema. The response is `Cache-Control: no-store`, and
|
||||
// the server never writes its values to logs, metrics, URLs, or events.
|
||||
//
|
||||
// Every value carries its confirmation state and provenance, and every claim has trust level 0. The
|
||||
// self-assessed grade of a role is separate from `confirmed_categories`, which only assessment results
|
||||
// establish and which no request writes. The profile needs no file, no ML extraction, and no FSP
|
||||
// account.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/profile
|
||||
func (UnimplementedHandler) GetMyProfile(ctx context.Context) (r GetMyProfileRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyQuestionnaire implements GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -1151,6 +1177,60 @@ func (UnimplementedHandler) ResendEmailVerification(ctx context.Context, req *Em
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SaveMyProfile implements SaveMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new state of every field and list; see
|
||||
// CandidateProfileUpdate for the decisions that it carries. It replaces the stored profile as a whole.
|
||||
//
|
||||
// Every field is optional in substance: a profile can be saved with any subset filled and the rest
|
||||
// null or empty, so no value requires a resume, the ML service, an FSP account, or any other file or
|
||||
// link. Which fields are needed to leave the onboarding step candidate_profile is an open product
|
||||
// question that this contract does not decide; a save on that step advancing the account to
|
||||
// candidate_questionnaire is planned.
|
||||
//
|
||||
// Provenance is the server's: a value typed in the form is `manual`, confirming a stored suggestion
|
||||
// keeps its origin, and every claim keeps trust level 0. The body has no origin, trust level,
|
||||
// confirmation time, confirmed grade, or category, and unknown fields are rejected. A self-assessed
|
||||
// grade never becomes a confirmed grade or a category.
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read,
|
||||
// 0 for the first save. If it is not the current version, the server answers 412 version_conflict and
|
||||
// changes nothing, and the client reads the profile again and reapplies its edits, so a concurrent
|
||||
// edit from another tab or device is never lost silently. The version travels in the body rather than
|
||||
// in If-Match because the generated client cannot read the ETag response header yet, as for the
|
||||
// questionnaire; the status and code are the same as for a failed If-Match.
|
||||
//
|
||||
// The operation needs no Idempotency-Key: it replaces the whole state and is idempotent. A body whose
|
||||
// values equal the stored ones, with the same decisions, changes nothing, keeps the version, and
|
||||
// answers 200 with the current profile even when `expected_version` is older, so a retry after a lost
|
||||
// response of a successful save succeeds instead of failing with 412. A version above the current one
|
||||
// never existed and always answers 412 version_conflict, even for an unchanged body.
|
||||
//
|
||||
// The save replaces the stored claims as a whole. A suggestion that an import stored and that the
|
||||
// client did not render and send back with the decision `extracted` is dropped by the save; a client
|
||||
// therefore sends every suggestion that it received, and a client that read an older version gets 412
|
||||
// instead of silently dropping a suggestion it never saw.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), domain
|
||||
// rules that depend on the body alone (400), then the rules that depend on the stored claims against
|
||||
// the version: a decision `extracted` for a value that is not a stored suggestion answers 412 when
|
||||
// `expected_version` is stale, because another save may have confirmed that value, and 400 when it is
|
||||
// current; an unchanged body (200); any other change over a stale version (412). The schema rejects an
|
||||
// unknown field, an unknown specialization or grade, a phone number outside E.164, a Telegram username
|
||||
// without the leading @, an email that is not an address, a month outside `YYYY-MM`, a salary that is
|
||||
// not a positive multiple of 1000, and more items than a list allows. The server also rejects a
|
||||
// repeated tag, skill, or role specialization, a period that ends before it starts or lies in the
|
||||
// future, and a decision `extracted` for a value that is not a stored suggestion, with 400
|
||||
// validation_failed and pointers to the items, for example `/roles/1/specialization` or
|
||||
// `/stack/1/status`. Error bodies never repeat a submitted value.
|
||||
//
|
||||
// PUT /api/v1/me/profile
|
||||
func (UnimplementedHandler) SaveMyProfile(ctx context.Context, req *CandidateProfileUpdate) (r SaveMyProfileRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SaveMyQuestionnaire implements SaveMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user