diff --git a/fern/apis/fdr/definition/commons.yml b/fern/apis/fdr/definition/commons.yml index 0a356df49f..a980cac2fc 100644 --- a/fern/apis/fdr/definition/commons.yml +++ b/fern/apis/fdr/definition/commons.yml @@ -50,9 +50,11 @@ errors: UserNotInOrgError: status-code: 403 + type: string DomainBelongsToAnotherOrgError: status-code: 403 + type: string InternalError: status-code: 500 diff --git a/packages/fdr-sdk/src/client/generated/api/resources/api/resources/v1/resources/register/client/registerApiDefinition.ts b/packages/fdr-sdk/src/client/generated/api/resources/api/resources/v1/resources/register/client/registerApiDefinition.ts index cfcb90bf10..03a41aba13 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/api/resources/v1/resources/register/client/registerApiDefinition.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/api/resources/v1/resources/register/client/registerApiDefinition.ts @@ -18,6 +18,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface _Unknown { @@ -27,7 +28,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; _other: (value: core.Fetcher.Error) => _Result; } } @@ -40,8 +41,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.api.v1.register.registerApiDefinition.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.api.v1.register.registerApiDefinition.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -61,7 +63,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); default: return visitor._other(value as any); } diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/finishDocsRegister.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/finishDocsRegister.ts index ff5f533e53..959842e63b 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/finishDocsRegister.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/finishDocsRegister.ts @@ -19,6 +19,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface DocsRegistrationIdNotFound { @@ -32,7 +33,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; docsRegistrationIdNotFound: () => _Result; _other: (value: core.Fetcher.Error) => _Result; } @@ -46,8 +47,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.docs.v1.write.finishDocsRegister.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.docs.v1.write.finishDocsRegister.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -73,7 +75,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "DocsRegistrationIdNotFound": return visitor.docsRegistrationIdNotFound(); default: diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/finishDocsRegister.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/finishDocsRegister.ts index 4dfaabb38b..3160f4f7b3 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/finishDocsRegister.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/finishDocsRegister.ts @@ -19,6 +19,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface DocsRegistrationIdNotFound { @@ -32,7 +33,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; docsRegistrationIdNotFound: () => _Result; _other: (value: core.Fetcher.Error) => _Result; } @@ -46,8 +47,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.docs.v2.write.finishDocsRegister.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.docs.v2.write.finishDocsRegister.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -73,7 +75,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "DocsRegistrationIdNotFound": return visitor.docsRegistrationIdNotFound(); default: diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsPreviewRegister.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsPreviewRegister.ts index 3ba39c6c8d..46cc9c6794 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsPreviewRegister.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsPreviewRegister.ts @@ -25,6 +25,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface InvalidDomainError { @@ -39,7 +40,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; unavailableError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; invalidDomainError: () => _Result; _other: (value: core.Fetcher.Error) => _Result; } @@ -60,8 +61,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.docs.v2.write.startDocsPreviewRegister.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.docs.v2.write.startDocsPreviewRegister.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -91,7 +93,7 @@ export const Error = { case "UnavailableError": return visitor.unavailableError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "InvalidDomainError": return visitor.invalidDomainError(); default: diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsRegister.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsRegister.ts index 0ac590b409..681024fec6 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsRegister.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/startDocsRegister.ts @@ -27,6 +27,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface InvalidDomainError { @@ -39,6 +40,7 @@ export declare namespace Error { interface DomainBelongsToAnotherOrgError { error: "DomainBelongsToAnotherOrgError"; + content: string; } interface _Unknown { @@ -49,10 +51,10 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; unavailableError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; invalidDomainError: () => _Result; invalidCustomDomainError: () => _Result; - domainBelongsToAnotherOrgError: () => _Result; + domainBelongsToAnotherOrgError: (value: string) => _Result; _other: (value: core.Fetcher.Error) => _Result; } } @@ -72,8 +74,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.docs.v2.write.startDocsRegister.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.docs.v2.write.startDocsRegister.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -90,12 +93,14 @@ export const Error = { }; }, - domainBelongsToAnotherOrgError: - (): FernRegistry.docs.v2.write.startDocsRegister.Error.DomainBelongsToAnotherOrgError => { - return { - error: "DomainBelongsToAnotherOrgError", - }; - }, + domainBelongsToAnotherOrgError: ( + value: string + ): FernRegistry.docs.v2.write.startDocsRegister.Error.DomainBelongsToAnotherOrgError => { + return { + content: value, + error: "DomainBelongsToAnotherOrgError", + }; + }, _unknown: (fetcherError: core.Fetcher.Error): FernRegistry.docs.v2.write.startDocsRegister.Error._Unknown => { return { @@ -114,13 +119,13 @@ export const Error = { case "UnavailableError": return visitor.unavailableError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "InvalidDomainError": return visitor.invalidDomainError(); case "InvalidCustomDomainError": return visitor.invalidCustomDomainError(); case "DomainBelongsToAnotherOrgError": - return visitor.domainBelongsToAnotherOrgError(); + return visitor.domainBelongsToAnotherOrgError(value.content); default: return visitor._other(value as any); } diff --git a/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/get.ts b/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/get.ts index 2a28ce111c..49fea55f33 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/get.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/get.ts @@ -25,6 +25,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface UnavailableError { @@ -69,7 +70,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; unavailableError: (value: string) => _Result; apiIdRequiredError: (value: string) => _Result; orgIdRequiredError: (value: string) => _Result; @@ -89,8 +90,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.snippets.get.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.snippets.get.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -159,7 +161,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "UnavailableError": return visitor.unavailableError(value.content); case "ApiIdRequiredError": diff --git a/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/load.ts b/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/load.ts index ea34cea929..b5a6fd1d04 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/load.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/snippets/client/load.ts @@ -25,6 +25,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface UnavailableError { @@ -69,7 +70,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; unavailableError: (value: string) => _Result; invalidPageError: (value: string) => _Result; apiIdRequiredError: (value: string) => _Result; @@ -89,8 +90,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.snippets.load.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.snippets.load.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -159,7 +161,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "UnavailableError": return visitor.unavailableError(value.content); case "InvalidPageError": diff --git a/packages/fdr-sdk/src/client/generated/api/resources/snippetsFactory/client/createSnippetsForSdk.ts b/packages/fdr-sdk/src/client/generated/api/resources/snippetsFactory/client/createSnippetsForSdk.ts index 59b01d54f2..72ee6830ae 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/snippetsFactory/client/createSnippetsForSdk.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/snippetsFactory/client/createSnippetsForSdk.ts @@ -20,6 +20,7 @@ export declare namespace Error { interface UserNotInOrgError { error: "UserNotInOrgError"; + content: string; } interface OrgIdNotFound { @@ -39,7 +40,7 @@ export declare namespace Error { interface _Visitor<_Result> { unauthorizedError: (value: string) => _Result; - userNotInOrgError: () => _Result; + userNotInOrgError: (value: string) => _Result; orgIdNotFound: (value: string) => _Result; sdkNotFound: (value: string) => _Result; _other: (value: core.Fetcher.Error) => _Result; @@ -54,8 +55,9 @@ export const Error = { }; }, - userNotInOrgError: (): FernRegistry.snippetsFactory.createSnippetsForSdk.Error.UserNotInOrgError => { + userNotInOrgError: (value: string): FernRegistry.snippetsFactory.createSnippetsForSdk.Error.UserNotInOrgError => { return { + content: value, error: "UserNotInOrgError", }; }, @@ -89,7 +91,7 @@ export const Error = { case "UnauthorizedError": return visitor.unauthorizedError(value.content); case "UserNotInOrgError": - return visitor.userNotInOrgError(); + return visitor.userNotInOrgError(value.content); case "OrgIdNotFound": return visitor.orgIdNotFound(value.content); case "SDKNotFound": diff --git a/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.d.ts b/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.d.ts index f7ee862178..399ce3eac0 100644 --- a/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.d.ts +++ b/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.d.ts @@ -4,6 +4,7 @@ import * as errors from "../../../../errors"; import express from "express"; export declare class DomainBelongsToAnotherOrgError extends errors.FernRegistryError { - constructor(); + private readonly body; + constructor(body: string); send(res: express.Response): Promise; } diff --git a/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.js b/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.js index 7239b257d9..f5e809d7ff 100644 --- a/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.js +++ b/servers/fdr/src/api/generated/api/resources/commons/errors/DomainBelongsToAnotherOrgError.js @@ -12,13 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; import * as errors from "../../../../errors"; export class DomainBelongsToAnotherOrgError extends errors.FernRegistryError { - constructor() { + constructor(body) { super("DomainBelongsToAnotherOrgError"); + this.body = body; Object.setPrototypeOf(this, DomainBelongsToAnotherOrgError.prototype); } send(res) { return __awaiter(this, void 0, void 0, function* () { - res.sendStatus(403); + res.status(403).json(this.body); }); } } diff --git a/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.d.ts b/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.d.ts index cefda7ff37..413a8cb616 100644 --- a/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.d.ts +++ b/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.d.ts @@ -4,6 +4,7 @@ import * as errors from "../../../../errors"; import express from "express"; export declare class UserNotInOrgError extends errors.FernRegistryError { - constructor(); + private readonly body; + constructor(body: string); send(res: express.Response): Promise; } diff --git a/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.js b/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.js index 1ce87b8308..1400fd16e4 100644 --- a/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.js +++ b/servers/fdr/src/api/generated/api/resources/commons/errors/UserNotInOrgError.js @@ -12,13 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; import * as errors from "../../../../errors"; export class UserNotInOrgError extends errors.FernRegistryError { - constructor() { + constructor(body) { super("UserNotInOrgError"); + this.body = body; Object.setPrototypeOf(this, UserNotInOrgError.prototype); } send(res) { return __awaiter(this, void 0, void 0, function* () { - res.sendStatus(403); + res.status(403).json(this.body); }); } } diff --git a/servers/fdr/src/controllers/docs/v2/getDocsWriteV2Service.ts b/servers/fdr/src/controllers/docs/v2/getDocsWriteV2Service.ts index 0d87f20c1d..74daa85981 100644 --- a/servers/fdr/src/controllers/docs/v2/getDocsWriteV2Service.ts +++ b/servers/fdr/src/controllers/docs/v2/getDocsWriteV2Service.ts @@ -52,7 +52,7 @@ export function getDocsWriteV2Service(app: FdrApplication): DocsV2WriteService { req.body.orgId, ); if (!hasOwnership) { - throw new FdrAPI.DomainBelongsToAnotherOrgError(); + throw new FdrAPI.DomainBelongsToAnotherOrgError("Domain belongs to another org"); } const docsRegistrationId = uuidv4(); diff --git a/servers/fdr/src/services/auth/AuthService.ts b/servers/fdr/src/services/auth/AuthService.ts index a2456566f8..1508d80bb2 100644 --- a/servers/fdr/src/services/auth/AuthService.ts +++ b/servers/fdr/src/services/auth/AuthService.ts @@ -96,7 +96,7 @@ export class AuthServiceImpl implements AuthService { } const belongsToOrg = response.body; if (!belongsToOrg) { - throw new FdrAPI.UserNotInOrgError(); + throw new FdrAPI.UserNotInOrgError("User does not belong to organization"); } }