@rakun-kit/core 1.1.0 → 1.1.1
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/cjs/api/routes/manager/media/finalizeUpload.js +42 -0
- package/dist/cjs/api/routes/manager/media/finalizeUpload.js.map +1 -1
- package/dist/cjs/api/routes/manager/media/prepareUpload.js +26 -1
- package/dist/cjs/api/routes/manager/media/prepareUpload.js.map +1 -1
- package/dist/cjs/api/routes/manager/media/uploadBinary.js +40 -0
- package/dist/cjs/api/routes/manager/media/uploadBinary.js.map +1 -1
- package/dist/esm/api/context.d.ts +1 -1
- package/dist/esm/api/context.js +2 -2
- package/dist/esm/api/operations/custom.d.ts +1 -1
- package/dist/esm/api/operations/custom.js +1 -1
- package/dist/esm/api/operations/index.d.ts +41 -41
- package/dist/esm/api/operations/index.js +7 -7
- package/dist/esm/api/operations/manager-contract.d.ts +30 -30
- package/dist/esm/api/operations/manager-contract.js +4 -4
- package/dist/esm/api/operations/manager.d.ts +31 -31
- package/dist/esm/api/operations/manager.js +35 -35
- package/dist/esm/api/operations/types.d.ts +1 -1
- package/dist/esm/api/operations/web-contract.d.ts +3 -3
- package/dist/esm/api/operations/web-contract.js +3 -3
- package/dist/esm/api/operations/web.d.ts +4 -4
- package/dist/esm/api/operations/web.js +5 -5
- package/dist/esm/api/proxies/context.d.ts +2 -2
- package/dist/esm/api/proxies/index.d.ts +4 -4
- package/dist/esm/api/proxies/index.js +1 -1
- package/dist/esm/api/routes/manager/auth/accountInfo.d.ts +2 -2
- package/dist/esm/api/routes/manager/auth/accountInfo.js +3 -3
- package/dist/esm/api/routes/manager/auth/deleteSession.d.ts +2 -2
- package/dist/esm/api/routes/manager/auth/deleteSession.js +3 -3
- package/dist/esm/api/routes/manager/auth/login.d.ts +1 -1
- package/dist/esm/api/routes/manager/auth/login.js +4 -4
- package/dist/esm/api/routes/manager/auth/logout.d.ts +1 -1
- package/dist/esm/api/routes/manager/auth/logout.js +3 -3
- package/dist/esm/api/routes/manager/auth/totp/confirmTotp.d.ts +2 -2
- package/dist/esm/api/routes/manager/auth/totp/confirmTotp.js +2 -2
- package/dist/esm/api/routes/manager/auth/totp/enrollTotp.d.ts +1 -1
- package/dist/esm/api/routes/manager/auth/totp/enrollTotp.js +3 -3
- package/dist/esm/api/routes/manager/auth/totp/verifyTotp.d.ts +1 -1
- package/dist/esm/api/routes/manager/auth/totp/verifyTotp.js +3 -3
- package/dist/esm/api/routes/manager/auth/updatePassword.d.ts +2 -2
- package/dist/esm/api/routes/manager/auth/updatePassword.js +3 -3
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnAuthOptions.js +4 -4
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnAuthVerify.js +4 -4
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnRegisterOptions.d.ts +2 -2
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnRegisterOptions.js +3 -3
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnRegisterVerify.d.ts +1 -1
- package/dist/esm/api/routes/manager/auth/webauthn/webauthnRegisterVerify.js +4 -4
- package/dist/esm/api/routes/manager/create.d.ts +2 -2
- package/dist/esm/api/routes/manager/create.js +8 -8
- package/dist/esm/api/routes/manager/delete.d.ts +2 -2
- package/dist/esm/api/routes/manager/delete.js +8 -8
- package/dist/esm/api/routes/manager/get.d.ts +2 -2
- package/dist/esm/api/routes/manager/get.js +6 -6
- package/dist/esm/api/routes/manager/list.d.ts +2 -2
- package/dist/esm/api/routes/manager/list.js +8 -8
- package/dist/esm/api/routes/manager/literals/list.d.ts +2 -2
- package/dist/esm/api/routes/manager/literals/list.js +5 -5
- package/dist/esm/api/routes/manager/literals/upsert.d.ts +2 -2
- package/dist/esm/api/routes/manager/literals/upsert.js +6 -6
- package/dist/esm/api/routes/manager/media/createFolder.d.ts +2 -2
- package/dist/esm/api/routes/manager/media/createFolder.js +7 -7
- package/dist/esm/api/routes/manager/media/finalizeUpload.d.ts +2 -2
- package/dist/esm/api/routes/manager/media/finalizeUpload.d.ts.map +1 -1
- package/dist/esm/api/routes/manager/media/finalizeUpload.js +50 -8
- package/dist/esm/api/routes/manager/media/finalizeUpload.js.map +1 -1
- package/dist/esm/api/routes/manager/media/getMediaUrl.d.ts +2 -2
- package/dist/esm/api/routes/manager/media/getMediaUrl.js +3 -3
- package/dist/esm/api/routes/manager/media/listFolders.d.ts +2 -2
- package/dist/esm/api/routes/manager/media/listFolders.js +4 -4
- package/dist/esm/api/routes/manager/media/prepareUpload.d.ts +2 -2
- package/dist/esm/api/routes/manager/media/prepareUpload.d.ts.map +1 -1
- package/dist/esm/api/routes/manager/media/prepareUpload.js +29 -4
- package/dist/esm/api/routes/manager/media/prepareUpload.js.map +1 -1
- package/dist/esm/api/routes/manager/media/uploadBinary.d.ts +1 -1
- package/dist/esm/api/routes/manager/media/uploadBinary.d.ts.map +1 -1
- package/dist/esm/api/routes/manager/media/uploadBinary.js +45 -5
- package/dist/esm/api/routes/manager/media/uploadBinary.js.map +1 -1
- package/dist/esm/api/routes/manager/setDefaultLanguage.d.ts +2 -2
- package/dist/esm/api/routes/manager/setDefaultLanguage.js +4 -4
- package/dist/esm/api/routes/manager/update.d.ts +2 -2
- package/dist/esm/api/routes/manager/update.js +8 -8
- package/dist/esm/api/routes/web/page.d.ts +1 -1
- package/dist/esm/api/routes/web/page.js +13 -13
- package/dist/esm/api/sessionCookie.d.ts +1 -1
- package/dist/esm/api/utils/checkFailureCase.d.ts +1 -1
- package/dist/esm/api/utils/checkFailureCase.js +1 -1
- package/dist/esm/api/utils/checkOwnership.d.ts +2 -2
- package/dist/esm/api/utils/checkOwnership.js +3 -3
- package/dist/esm/api/utils/checkPermissions.d.ts +2 -2
- package/dist/esm/api/utils/checkPermissions.js +2 -2
- package/dist/esm/api/utils/getLanguages.js +2 -2
- package/dist/esm/api/utils/getLink.d.ts +2 -2
- package/dist/esm/api/utils/getLink.js +4 -4
- package/dist/esm/api/utils/getUser.d.ts +1 -1
- package/dist/esm/api/utils/getUser.js +4 -4
- package/dist/esm/api/utils/parseId.d.ts +1 -1
- package/dist/esm/api/utils/parseId.js +1 -1
- package/dist/esm/api/utils/passwords.js +1 -1
- package/dist/esm/api/utils/populates/populateLinks.d.ts +2 -2
- package/dist/esm/api/utils/populates/populateLinks.js +4 -4
- package/dist/esm/api/utils/populates/populateRelations.d.ts +2 -2
- package/dist/esm/api/utils/populates/populateRelations.js +6 -6
- package/dist/esm/api/utils/redirects/resolveRedirect.js +2 -2
- package/dist/esm/api/utils/routes/revalidatePath.js +5 -5
- package/dist/esm/api/utils/routes/routeDefinitions.d.ts +1 -1
- package/dist/esm/api/utils/routes/routeMapHelpers.d.ts +3 -3
- package/dist/esm/api/utils/routes/routeMapHelpers.js +6 -6
- package/dist/esm/api/utils/routes/syncConfiguredRoutes.d.ts +2 -2
- package/dist/esm/api/utils/routes/syncConfiguredRoutes.js +5 -5
- package/dist/esm/api/utils/routes/updateRoutesMap.d.ts +2 -2
- package/dist/esm/api/utils/routes/updateRoutesMap.js +4 -4
- package/dist/esm/api/utils/transformObjectIdsToStrings.js +1 -1
- package/dist/esm/api/utils/transformStringToObjectIds.js +1 -1
- package/dist/esm/api/utils/translate.d.ts +1 -1
- package/dist/esm/api/utils/translate.js +3 -3
- package/dist/esm/api/utils/validateModule.d.ts +1 -1
- package/dist/esm/api/utils/validateModule.js +2 -2
- package/dist/esm/bootstrapState.d.ts +8 -8
- package/dist/esm/client.d.ts +34 -34
- package/dist/esm/client.js +25 -25
- package/dist/esm/contracts.d.ts +26 -26
- package/dist/esm/contracts.js +26 -26
- package/dist/esm/index.d.ts +43 -43
- package/dist/esm/index.js +39 -39
- package/dist/esm/internal-content-types/HelloWorld.d.ts +3 -3
- package/dist/esm/internal-content-types/HelloWorld.js +2 -2
- package/dist/esm/internal-content-types/Language.d.ts +6 -6
- package/dist/esm/internal-content-types/Language.js +2 -2
- package/dist/esm/internal-content-types/LiteralTranslation.d.ts +5 -5
- package/dist/esm/internal-content-types/LiteralTranslation.js +2 -2
- package/dist/esm/internal-content-types/ManagerRole.d.ts +4 -4
- package/dist/esm/internal-content-types/ManagerRole.js +3 -3
- package/dist/esm/internal-content-types/ManagerUser.d.ts +9 -9
- package/dist/esm/internal-content-types/ManagerUser.js +3 -3
- package/dist/esm/internal-content-types/Media.d.ts +29 -29
- package/dist/esm/internal-content-types/Media.js +3 -3
- package/dist/esm/internal-content-types/MediaFolder.d.ts +7 -7
- package/dist/esm/internal-content-types/MediaFolder.js +2 -2
- package/dist/esm/internal-content-types/MfaChallenge.d.ts +16 -16
- package/dist/esm/internal-content-types/MfaChallenge.js +3 -3
- package/dist/esm/internal-content-types/Page.d.ts +5 -5
- package/dist/esm/internal-content-types/Page.js +3 -3
- package/dist/esm/internal-content-types/Redirect.d.ts +14 -14
- package/dist/esm/internal-content-types/Redirect.js +2 -2
- package/dist/esm/internal-content-types/Route.d.ts +11 -11
- package/dist/esm/internal-content-types/Route.js +2 -2
- package/dist/esm/internal-content-types/RouteLayoutModule.d.ts +9 -9
- package/dist/esm/internal-content-types/RouteLayoutModule.js +2 -2
- package/dist/esm/internal-content-types/RouteLayoutModuleOverride.d.ts +8 -8
- package/dist/esm/internal-content-types/RouteLayoutModuleOverride.js +2 -2
- package/dist/esm/internal-content-types/RouteMap.d.ts +7 -7
- package/dist/esm/internal-content-types/RouteMap.js +2 -2
- package/dist/esm/internal-content-types/RouteSettings.d.ts +8 -8
- package/dist/esm/internal-content-types/RouteSettings.js +3 -3
- package/dist/esm/internal-content-types/Seo.d.ts +4 -4
- package/dist/esm/internal-content-types/Seo.js +2 -2
- package/dist/esm/internal-content-types/Session.d.ts +12 -12
- package/dist/esm/internal-content-types/Session.js +3 -3
- package/dist/esm/internal-content-types/UserMfa.d.ts +15 -15
- package/dist/esm/internal-content-types/UserMfa.js +3 -3
- package/dist/esm/internal-content-types/WebAuthnCredential.d.ts +15 -15
- package/dist/esm/internal-content-types/WebAuthnCredential.js +3 -3
- package/dist/esm/internal-content-types/WebAuthnRegChallenge.d.ts +14 -14
- package/dist/esm/internal-content-types/WebAuthnRegChallenge.js +3 -3
- package/dist/esm/internal-content-types/index.d.ts +20 -20
- package/dist/esm/internal-content-types/index.js +20 -20
- package/dist/esm/lib/ContentType.d.ts +3 -3
- package/dist/esm/lib/ContentType.js +4 -4
- package/dist/esm/lib/Permissions.d.ts +1 -1
- package/dist/esm/lib/Registry.d.ts +2 -2
- package/dist/esm/lib/Registry.js +4 -4
- package/dist/esm/lib/errors/AppError.d.ts +1 -1
- package/dist/esm/lib/errors/AppError.js +1 -1
- package/dist/esm/lib/errors/index.d.ts +4 -4
- package/dist/esm/lib/errors/index.js +3 -3
- package/dist/esm/lib/errors/throwAppError.d.ts +1 -1
- package/dist/esm/lib/errors/throwAppError.js +3 -3
- package/dist/esm/lib/fields/Boolean.d.ts +3 -3
- package/dist/esm/lib/fields/Boolean.js +1 -1
- package/dist/esm/lib/fields/ContentReference.d.ts +5 -5
- package/dist/esm/lib/fields/ContentReference.js +2 -2
- package/dist/esm/lib/fields/Date.d.ts +3 -3
- package/dist/esm/lib/fields/Date.js +1 -1
- package/dist/esm/lib/fields/Field.d.ts +19 -19
- package/dist/esm/lib/fields/Field.js +1 -1
- package/dist/esm/lib/fields/File.d.ts +3 -3
- package/dist/esm/lib/fields/File.js +3 -3
- package/dist/esm/lib/fields/Iterator.d.ts +4 -4
- package/dist/esm/lib/fields/Iterator.js +2 -2
- package/dist/esm/lib/fields/Link.d.ts +4 -4
- package/dist/esm/lib/fields/Link.js +3 -3
- package/dist/esm/lib/fields/List.d.ts +3 -3
- package/dist/esm/lib/fields/List.js +1 -1
- package/dist/esm/lib/fields/Number.d.ts +3 -3
- package/dist/esm/lib/fields/Number.js +1 -1
- package/dist/esm/lib/fields/Relation.d.ts +6 -6
- package/dist/esm/lib/fields/Relation.js +5 -5
- package/dist/esm/lib/fields/Select.d.ts +3 -3
- package/dist/esm/lib/fields/Select.js +1 -1
- package/dist/esm/lib/fields/SelfRelation.d.ts +4 -4
- package/dist/esm/lib/fields/SelfRelation.js +2 -2
- package/dist/esm/lib/fields/SimpleList.d.ts +4 -4
- package/dist/esm/lib/fields/SimpleList.js +2 -2
- package/dist/esm/lib/fields/String.d.ts +3 -3
- package/dist/esm/lib/fields/String.js +3 -3
- package/dist/esm/lib/fields/index.d.ts +19 -19
- package/dist/esm/lib/fields/index.js +13 -13
- package/dist/esm/lib/types/index.d.ts +2 -2
- package/dist/esm/lib/utils/getListField.d.ts +1 -1
- package/dist/esm/lib/utils/getSchemas.d.ts +1 -1
- package/dist/esm/lib/utils/getTranslation.d.ts +2 -2
- package/dist/esm/lib/utils/getTranslation.js +1 -1
- package/dist/esm/lib/utils/isTranslatableObject.d.ts +1 -1
- package/dist/esm/lib/utils/translateObject.d.ts +2 -2
- package/dist/esm/lib/utils/translateObject.js +3 -3
- package/dist/esm/literals/definitions.d.ts +1 -1
- package/dist/esm/literals/definitions.js +1 -1
- package/dist/esm/literals/index.d.ts +3 -3
- package/dist/esm/literals/index.js +3 -3
- package/dist/esm/literals/manager.d.ts +1 -1
- package/dist/esm/literals/manager.js +1 -1
- package/dist/esm/manager.d.ts +124 -124
- package/dist/esm/manager.js +2 -2
- package/dist/esm/media/imageOptimization.d.ts +1 -1
- package/dist/esm/media/imageOptimization.js +2 -2
- package/dist/esm/media/index.d.ts +4 -4
- package/dist/esm/media/index.js +3 -3
- package/dist/esm/media/mediaService.d.ts +1 -1
- package/dist/esm/orm/createIndexes.js +1 -1
- package/dist/esm/orm/database.js +3 -3
- package/dist/esm/orm/dbService.d.ts +3 -3
- package/dist/esm/orm/index.d.ts +2 -2
- package/dist/esm/orm/index.js +12 -12
- package/dist/esm/orm/mongodbPeer.js +1 -1
- package/dist/esm/orm/operations/clear.d.ts +1 -1
- package/dist/esm/orm/operations/clear.js +1 -1
- package/dist/esm/orm/operations/create.d.ts +2 -2
- package/dist/esm/orm/operations/create.js +4 -4
- package/dist/esm/orm/operations/delete.d.ts +2 -2
- package/dist/esm/orm/operations/delete.js +2 -2
- package/dist/esm/orm/operations/find.d.ts +2 -2
- package/dist/esm/orm/operations/find.js +3 -3
- package/dist/esm/orm/operations/findDependencies.d.ts +2 -2
- package/dist/esm/orm/operations/findDependencies.js +4 -4
- package/dist/esm/orm/operations/get.d.ts +3 -3
- package/dist/esm/orm/operations/get.js +3 -3
- package/dist/esm/orm/operations/getAll.d.ts +2 -2
- package/dist/esm/orm/operations/getAll.js +2 -2
- package/dist/esm/orm/operations/list.d.ts +2 -2
- package/dist/esm/orm/operations/list.js +3 -3
- package/dist/esm/orm/operations/update.d.ts +3 -3
- package/dist/esm/orm/operations/update.js +5 -5
- package/dist/esm/orm/operations/updateMany.d.ts +2 -2
- package/dist/esm/orm/operations/updateMany.js +3 -3
- package/dist/esm/orm/operations/upsert.d.ts +2 -2
- package/dist/esm/orm/operations/upsert.js +4 -4
- package/dist/esm/orm/utils/deepDeleteNulls.js +1 -1
- package/dist/esm/orm/utils/parseId.d.ts +1 -1
- package/dist/esm/orm/utils/parseId.js +1 -1
- package/dist/esm/orm/utils/transformObjectIdsToStrings.js +1 -1
- package/dist/esm/orm/utils/transformStringToObjectIds.js +1 -1
- package/dist/esm/schemas/manager/literals/upsert.js +1 -1
- package/dist/esm/schemas/manager/media/finalizeUpload.js +1 -1
- package/dist/esm/schemas/manager/media/getMediaUrl.js +1 -1
- package/dist/esm/schemas/manager/media/listFolders.js +1 -1
- package/dist/esm/schemas/web/page.js +1 -1
- package/dist/esm/web/index.d.ts +1 -1
- package/dist/esm/web/index.js +1 -1
- package/dist/esm/web/page.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ContentType from "../../lib/ContentType";
|
|
2
|
-
import { DataInput, DataPopulatedWithoutApiOnly, DataFront, DataPopulated } from "../../lib/types";
|
|
1
|
+
import ContentType from "../../lib/ContentType.js";
|
|
2
|
+
import { DataInput, DataPopulatedWithoutApiOnly, DataFront, DataPopulated } from "../../lib/types/index.js";
|
|
3
3
|
export type InputProxy<T extends ContentType> = (data: Partial<DataInput<T>>) => Partial<DataInput<T>> | Promise<Partial<DataInput<T>>>;
|
|
4
4
|
export type OutputProxy<T extends ContentType> = (data: DataPopulatedWithoutApiOnly<T>) => DataFront<T> | Promise<DataFront<T>>;
|
|
5
5
|
export type ApiProxies = {
|
|
@@ -9,8 +9,8 @@ export type ApiProxies = {
|
|
|
9
9
|
export declare const getInputProxy: (contentTypeName: string) => InputProxy<ContentType> | undefined;
|
|
10
10
|
export declare const getOutputProxy: (contentTypeName: string) => OutputProxy<ContentType> | undefined;
|
|
11
11
|
export declare const getProxies: () => {
|
|
12
|
-
input: Record<string, InputProxy<ContentType<Record<string, import("
|
|
13
|
-
output: Record<string, OutputProxy<ContentType<Record<string, import("
|
|
12
|
+
input: Record<string, InputProxy<ContentType<Record<string, import("../../index.js").Field<any, any, any, any, any, any>>, string>>>;
|
|
13
|
+
output: Record<string, OutputProxy<ContentType<Record<string, import("../../index.js").Field<any, any, any, any, any, any>>, string>>>;
|
|
14
14
|
};
|
|
15
15
|
export declare const ProxyOutput: (item: DataPopulated<ContentType>) => {
|
|
16
16
|
[x: string]: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { AccountInfoOutput } from "../../../../schemas/manager/auth/accountInfo";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { AccountInfoOutput } from "../../../../schemas/manager/auth/accountInfo.js";
|
|
3
3
|
export declare const accountInfoHandler: ({ ctx, }: {
|
|
4
4
|
ctx: RakunRequestContext;
|
|
5
5
|
}) => Promise<AccountInfoOutput>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Session, UserMfa } from "../../../../internal-content-types";
|
|
2
|
-
import { getMongoService } from "../../../../orm";
|
|
3
|
-
import { getSessionCookie } from "../../../sessionCookie";
|
|
1
|
+
import { Session, UserMfa } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
3
|
+
import { getSessionCookie } from "../../../sessionCookie.js";
|
|
4
4
|
export const accountInfoHandler = async ({ ctx, }) => {
|
|
5
5
|
const user = ctx.getUser();
|
|
6
6
|
const db = await getMongoService();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { DeleteSessionInput } from "../../../../schemas/manager/auth/deleteSession";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { DeleteSessionInput } from "../../../../schemas/manager/auth/deleteSession.js";
|
|
3
3
|
export declare const deleteSessionHandler: ({ input, ctx, }: {
|
|
4
4
|
input: DeleteSessionInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Session } from "../../../../internal-content-types";
|
|
2
|
-
import { throwAppError } from "../../../../lib/errors";
|
|
3
|
-
import { getMongoService } from "../../../../orm";
|
|
1
|
+
import { Session } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { throwAppError } from "../../../../lib/errors/index.js";
|
|
3
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
4
4
|
export const deleteSessionHandler = async ({ input, ctx, }) => {
|
|
5
5
|
const user = ctx.getUser();
|
|
6
6
|
const db = await getMongoService();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomBytes } from "crypto";
|
|
2
|
-
import { ManagerUser, UserMfa, MfaChallenge, Session, } from "../../../../internal-content-types";
|
|
3
|
-
import { throwAppError } from "../../../../lib/errors";
|
|
4
|
-
import { getMongoService } from "../../../../orm";
|
|
5
|
-
import { verifyPassword } from "../../../utils/passwords";
|
|
2
|
+
import { ManagerUser, UserMfa, MfaChallenge, Session, } from "../../../../internal-content-types/index.js";
|
|
3
|
+
import { throwAppError } from "../../../../lib/errors/index.js";
|
|
4
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
5
|
+
import { verifyPassword } from "../../../utils/passwords.js";
|
|
6
6
|
export const loginHandler = async ({ input, }) => {
|
|
7
7
|
const { username, password } = input;
|
|
8
8
|
const db = await getMongoService();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Session } from "../../../../internal-content-types";
|
|
2
|
-
import { getMongoService } from "../../../../orm";
|
|
3
|
-
import { getSessionCookie } from "../../../sessionCookie";
|
|
1
|
+
import { Session } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
3
|
+
import { getSessionCookie } from "../../../sessionCookie.js";
|
|
4
4
|
const emptyToken = { token: "" };
|
|
5
5
|
export const logoutHandler = async ({ ctx }) => {
|
|
6
6
|
if (!ctx?.req?.cookies)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../../context";
|
|
2
|
-
import { ConfirmTotpInput } from "../../../../../schemas/manager/auth/totp/confirmTotp";
|
|
1
|
+
import { RakunRequestContext } from "../../../../context.js";
|
|
2
|
+
import { ConfirmTotpInput } from "../../../../../schemas/manager/auth/totp/confirmTotp.js";
|
|
3
3
|
export declare const confirmTotpHandler: ({ input, ctx, }: {
|
|
4
4
|
input: ConfirmTotpInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserMfa, ManagerUser } from "../../../../../internal-content-types";
|
|
2
|
-
import { getMongoService } from "../../../../../orm";
|
|
1
|
+
import { UserMfa, ManagerUser } from "../../../../../internal-content-types/index.js";
|
|
2
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
3
3
|
import * as OTPAuth from "otpauth";
|
|
4
4
|
export const confirmTotpHandler = async ({ input, ctx, }) => {
|
|
5
5
|
const db = await getMongoService();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { randomBytes } from "crypto";
|
|
2
2
|
import * as OTPAuth from "otpauth";
|
|
3
3
|
import QRCode from "qrcode";
|
|
4
|
-
import { UserMfa, ManagerUser } from "../../../../../internal-content-types";
|
|
5
|
-
import { throwAppError } from "../../../../../lib/errors";
|
|
6
|
-
import { getMongoService } from "../../../../../orm";
|
|
4
|
+
import { UserMfa, ManagerUser } from "../../../../../internal-content-types/index.js";
|
|
5
|
+
import { throwAppError } from "../../../../../lib/errors/index.js";
|
|
6
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
7
7
|
export const enrollTotpHandler = async ({ ctx, }) => {
|
|
8
8
|
const db = await getMongoService();
|
|
9
9
|
const user = ctx.getUser();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VerifyTotpInput } from "../../../../../schemas/manager/auth/totp/verifyTotp";
|
|
1
|
+
import { VerifyTotpInput } from "../../../../../schemas/manager/auth/totp/verifyTotp.js";
|
|
2
2
|
export declare const verifyTotpHandler: ({ input, }: {
|
|
3
3
|
input: VerifyTotpInput;
|
|
4
4
|
}) => Promise<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as OTPAuth from "otpauth";
|
|
2
|
-
import { MfaChallenge, ManagerUser, UserMfa, Session, } from "../../../../../internal-content-types";
|
|
3
|
-
import { throwAppError } from "../../../../../lib/errors";
|
|
4
|
-
import { getMongoService } from "../../../../../orm";
|
|
2
|
+
import { MfaChallenge, ManagerUser, UserMfa, Session, } from "../../../../../internal-content-types/index.js";
|
|
3
|
+
import { throwAppError } from "../../../../../lib/errors/index.js";
|
|
4
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
5
5
|
export const verifyTotpHandler = async ({ input, }) => {
|
|
6
6
|
const db = await getMongoService();
|
|
7
7
|
const { challenge, code } = input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { UpdatePasswordInput } from "../../../../schemas/manager/updatePassword";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { UpdatePasswordInput } from "../../../../schemas/manager/updatePassword.js";
|
|
3
3
|
export declare const updatePasswordHandler: ({ input, ctx, }: {
|
|
4
4
|
input: UpdatePasswordInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ManagerUser } from "../../../../internal-content-types";
|
|
2
|
-
import { getMongoService } from "../../../../orm";
|
|
3
|
-
import { verifyPassword, hashPassword } from "../../../utils/passwords";
|
|
1
|
+
import { ManagerUser } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
3
|
+
import { verifyPassword, hashPassword } from "../../../utils/passwords.js";
|
|
4
4
|
export const updatePasswordHandler = async ({ input, ctx, }) => {
|
|
5
5
|
const db = await getMongoService();
|
|
6
6
|
const user = ctx.getUser();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { generateAuthenticationOptions } from "@simplewebauthn/server";
|
|
2
|
-
import { MfaChallenge, WebAuthnCredential, } from "../../../../../internal-content-types";
|
|
3
|
-
import { throwAppError } from "../../../../../lib/errors";
|
|
4
|
-
import { getMongoService } from "../../../../../orm";
|
|
5
|
-
import { RP_ID, toBase64URL } from "./share";
|
|
2
|
+
import { MfaChallenge, WebAuthnCredential, } from "../../../../../internal-content-types/index.js";
|
|
3
|
+
import { throwAppError } from "../../../../../lib/errors/index.js";
|
|
4
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
5
|
+
import { RP_ID, toBase64URL } from "./share.js";
|
|
6
6
|
export const webauthnAuthOptionsHandler = async ({ input, }) => {
|
|
7
7
|
const db = await getMongoService();
|
|
8
8
|
const ch = await db.find(MfaChallenge, { token: input.challengeToken });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { verifyAuthenticationResponse, } from "@simplewebauthn/server";
|
|
2
|
-
import { ORIGIN, RP_ID, toBase64URL } from "./share";
|
|
3
|
-
import { MfaChallenge, WebAuthnCredential, ManagerUser, Session, } from "../../../../../internal-content-types";
|
|
4
|
-
import { throwAppError } from "../../../../../lib/errors";
|
|
5
|
-
import { getMongoService } from "../../../../../orm";
|
|
2
|
+
import { ORIGIN, RP_ID, toBase64URL } from "./share.js";
|
|
3
|
+
import { MfaChallenge, WebAuthnCredential, ManagerUser, Session, } from "../../../../../internal-content-types/index.js";
|
|
4
|
+
import { throwAppError } from "../../../../../lib/errors/index.js";
|
|
5
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
6
6
|
export const webauthnAuthVerifyHandler = async ({ input, }) => {
|
|
7
7
|
const db = await getMongoService();
|
|
8
8
|
const ch = await db.find(MfaChallenge, { token: input.challengeToken });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../../context";
|
|
2
|
-
import { WebauthnRegisterOptionsInput } from "../../../../../schemas/manager/auth/webauthn/webauthnRegisterOptions";
|
|
1
|
+
import { RakunRequestContext } from "../../../../context.js";
|
|
2
|
+
import { WebauthnRegisterOptionsInput } from "../../../../../schemas/manager/auth/webauthn/webauthnRegisterOptions.js";
|
|
3
3
|
export declare const webauthnRegisterOptionsHandler: ({ ctx, input, }: {
|
|
4
4
|
ctx: RakunRequestContext;
|
|
5
5
|
input: WebauthnRegisterOptionsInput;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomBytes } from "crypto";
|
|
2
2
|
import { generateRegistrationOptions } from "@simplewebauthn/server";
|
|
3
|
-
import { RP_ID, toBase64URL } from "./share";
|
|
4
|
-
import { WebAuthnCredential, WebAuthnRegChallenge, ManagerUser, } from "../../../../../internal-content-types";
|
|
5
|
-
import { getMongoService } from "../../../../../orm";
|
|
3
|
+
import { RP_ID, toBase64URL } from "./share.js";
|
|
4
|
+
import { WebAuthnCredential, WebAuthnRegChallenge, ManagerUser, } from "../../../../../internal-content-types/index.js";
|
|
5
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
6
6
|
const RP_NAME = "CMS";
|
|
7
7
|
export const webauthnRegisterOptionsHandler = async ({ ctx, input, }) => {
|
|
8
8
|
const db = await getMongoService();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RegistrationResponseJSON } from "@simplewebauthn/server";
|
|
2
|
-
import { RakunRequestContext } from "../../../../context";
|
|
2
|
+
import { RakunRequestContext } from "../../../../context.js";
|
|
3
3
|
export declare const webauthnRegisterVerifyHandler: ({ ctx, input, }: {
|
|
4
4
|
ctx: RakunRequestContext;
|
|
5
5
|
input: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { verifyRegistrationResponse, } from "@simplewebauthn/server";
|
|
2
|
-
import { ORIGIN, RP_ID, toB64 } from "./share";
|
|
3
|
-
import { WebAuthnRegChallenge, WebAuthnCredential, ManagerUser, UserMfa, } from "../../../../../internal-content-types";
|
|
4
|
-
import { throwAppError } from "../../../../../lib/errors";
|
|
5
|
-
import { getMongoService } from "../../../../../orm";
|
|
2
|
+
import { ORIGIN, RP_ID, toB64 } from "./share.js";
|
|
3
|
+
import { WebAuthnRegChallenge, WebAuthnCredential, ManagerUser, UserMfa, } from "../../../../../internal-content-types/index.js";
|
|
4
|
+
import { throwAppError } from "../../../../../lib/errors/index.js";
|
|
5
|
+
import { getMongoService } from "../../../../../orm/index.js";
|
|
6
6
|
const toBase64URL = (buf) => buf.toString("base64url");
|
|
7
7
|
export const webauthnRegisterVerifyHandler = async ({ ctx, input, }) => {
|
|
8
8
|
const db = await getMongoService();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../context";
|
|
2
|
-
import { CreateInput } from "../../../schemas/manager/create";
|
|
1
|
+
import { RakunRequestContext } from "../../context.js";
|
|
2
|
+
import { CreateInput } from "../../../schemas/manager/create.js";
|
|
3
3
|
export declare const createHandler: ({ input, ctx, }: {
|
|
4
4
|
input: CreateInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { throwAppError } from "../../../lib/errors";
|
|
3
|
-
import { Logger } from "../../../lib/Logger";
|
|
4
|
-
import { getContentTypeByName } from "../../../lib/Registry";
|
|
5
|
-
import { getMongoService } from "../../../orm";
|
|
6
|
-
import { DbErrorInvalidData, DbErrorConflict } from "../../../orm/dbService";
|
|
7
|
-
import { checkPermissions } from "../../utils/checkPermissions";
|
|
8
|
-
import { checkRevalidatePath } from "../../utils/routes/revalidatePath";
|
|
9
|
-
import { getInputProxy } from "../../proxies";
|
|
2
|
+
import { throwAppError } from "../../../lib/errors/index.js";
|
|
3
|
+
import { Logger } from "../../../lib/Logger.js";
|
|
4
|
+
import { getContentTypeByName } from "../../../lib/Registry.js";
|
|
5
|
+
import { getMongoService } from "../../../orm/index.js";
|
|
6
|
+
import { DbErrorInvalidData, DbErrorConflict } from "../../../orm/dbService.js";
|
|
7
|
+
import { checkPermissions } from "../../utils/checkPermissions.js";
|
|
8
|
+
import { checkRevalidatePath } from "../../utils/routes/revalidatePath.js";
|
|
9
|
+
import { getInputProxy } from "../../proxies/index.js";
|
|
10
10
|
export const createHandler = async ({ input, ctx, }) => {
|
|
11
11
|
Logger.addTrace("manager.create: handler start", {
|
|
12
12
|
contentType: input.contentType,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../context";
|
|
2
|
-
import { DeleteInput } from "../../../schemas/manager/delete";
|
|
1
|
+
import { RakunRequestContext } from "../../context.js";
|
|
2
|
+
import { DeleteInput } from "../../../schemas/manager/delete.js";
|
|
3
3
|
export declare const deleteHandler: ({ input, ctx, }: {
|
|
4
4
|
input: DeleteInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Media } from "../../../internal-content-types";
|
|
2
|
-
import { throwAppError } from "../../../lib/errors";
|
|
3
|
-
import { Logger } from "../../../lib/Logger";
|
|
4
|
-
import { getContentTypeByName } from "../../../lib/Registry";
|
|
5
|
-
import { getMediaService } from "../../../media";
|
|
6
|
-
import { getMongoService } from "../../../orm";
|
|
7
|
-
import { checkOwnership } from "../../utils/checkOwnership";
|
|
8
|
-
import { checkRevalidatePath } from "../../utils/routes/revalidatePath";
|
|
1
|
+
import { Media } from "../../../internal-content-types/index.js";
|
|
2
|
+
import { throwAppError } from "../../../lib/errors/index.js";
|
|
3
|
+
import { Logger } from "../../../lib/Logger.js";
|
|
4
|
+
import { getContentTypeByName } from "../../../lib/Registry.js";
|
|
5
|
+
import { getMediaService } from "../../../media/index.js";
|
|
6
|
+
import { getMongoService } from "../../../orm/index.js";
|
|
7
|
+
import { checkOwnership } from "../../utils/checkOwnership.js";
|
|
8
|
+
import { checkRevalidatePath } from "../../utils/routes/revalidatePath.js";
|
|
9
9
|
export const deleteHandler = async ({ input, ctx, }) => {
|
|
10
10
|
Logger.addTrace("manager.delete: handler start", {
|
|
11
11
|
contentType: input.contentType,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../context";
|
|
2
|
-
import { GetInput } from "../../../schemas/manager/get";
|
|
1
|
+
import { RakunRequestContext } from "../../context.js";
|
|
2
|
+
import { GetInput } from "../../../schemas/manager/get.js";
|
|
3
3
|
export declare const getHandler: ({ input, ctx, }: {
|
|
4
4
|
input: GetInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { throwAppError } from "../../../lib/errors";
|
|
2
|
-
import { Logger } from "../../../lib/Logger";
|
|
3
|
-
import { getContentTypeByName } from "../../../lib/Registry";
|
|
4
|
-
import { getMongoService } from "../../../orm";
|
|
5
|
-
import { checkOwnership } from "../../utils/checkOwnership";
|
|
6
|
-
import { syncConfiguredRoutes } from "../../utils/routes/syncConfiguredRoutes";
|
|
1
|
+
import { throwAppError } from "../../../lib/errors/index.js";
|
|
2
|
+
import { Logger } from "../../../lib/Logger.js";
|
|
3
|
+
import { getContentTypeByName } from "../../../lib/Registry.js";
|
|
4
|
+
import { getMongoService } from "../../../orm/index.js";
|
|
5
|
+
import { checkOwnership } from "../../utils/checkOwnership.js";
|
|
6
|
+
import { syncConfiguredRoutes } from "../../utils/routes/syncConfiguredRoutes.js";
|
|
7
7
|
export const getHandler = async ({ input, ctx, }) => {
|
|
8
8
|
Logger.addTrace("manager.get: handler start", {
|
|
9
9
|
contentType: input.contentType,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../context";
|
|
2
|
-
import { ListInput } from "../../../schemas/manager/list";
|
|
1
|
+
import { RakunRequestContext } from "../../context.js";
|
|
2
|
+
import { ListInput } from "../../../schemas/manager/list.js";
|
|
3
3
|
export declare const listHandler: ({ input, ctx, }: {
|
|
4
4
|
input: ListInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { throwAppError } from "../../../lib/errors";
|
|
2
|
-
import { Logger } from "../../../lib/Logger";
|
|
3
|
-
import { hasPermissions } from "../../../lib/Permissions";
|
|
4
|
-
import { getContentTypeByName } from "../../../lib/Registry";
|
|
5
|
-
import { getMongoService } from "../../../orm";
|
|
6
|
-
import { checkAnyPermissions } from "../../utils/checkPermissions";
|
|
7
|
-
import { populateRelations } from "../../utils/populates/populateRelations";
|
|
8
|
-
import { syncConfiguredRoutes } from "../../utils/routes/syncConfiguredRoutes";
|
|
1
|
+
import { throwAppError } from "../../../lib/errors/index.js";
|
|
2
|
+
import { Logger } from "../../../lib/Logger.js";
|
|
3
|
+
import { hasPermissions } from "../../../lib/Permissions.js";
|
|
4
|
+
import { getContentTypeByName } from "../../../lib/Registry.js";
|
|
5
|
+
import { getMongoService } from "../../../orm/index.js";
|
|
6
|
+
import { checkAnyPermissions } from "../../utils/checkPermissions.js";
|
|
7
|
+
import { populateRelations } from "../../utils/populates/populateRelations.js";
|
|
8
|
+
import { syncConfiguredRoutes } from "../../utils/routes/syncConfiguredRoutes.js";
|
|
9
9
|
export const listHandler = async ({ input, ctx, }) => {
|
|
10
10
|
Logger.addTrace("manager.list: handler start", {
|
|
11
11
|
contentType: input.contentType,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { ListLiteralsInput, ListLiteralsOutput } from "../../../../schemas/manager/literals/list";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { ListLiteralsInput, ListLiteralsOutput } from "../../../../schemas/manager/literals/list.js";
|
|
3
3
|
export declare const listLiteralsHandler: ({ input, ctx, }: {
|
|
4
4
|
input: ListLiteralsInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Language, LiteralTranslation, } from "../../../../internal-content-types";
|
|
2
|
-
import { Logger } from "../../../../lib/Logger";
|
|
3
|
-
import { getLiteralDefinitions, validateIcuVariables, } from "../../../../literals";
|
|
4
|
-
import { getMongoService } from "../../../../orm";
|
|
5
|
-
import { checkAnyPermissions } from "../../../utils/checkPermissions";
|
|
1
|
+
import { Language, LiteralTranslation, } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { Logger } from "../../../../lib/Logger.js";
|
|
3
|
+
import { getLiteralDefinitions, validateIcuVariables, } from "../../../../literals/index.js";
|
|
4
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
5
|
+
import { checkAnyPermissions } from "../../../utils/checkPermissions.js";
|
|
6
6
|
const emptyValidation = {
|
|
7
7
|
isValid: true,
|
|
8
8
|
missing: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { UpsertLiteralInput, UpsertLiteralOutput } from "../../../../schemas/manager/literals/upsert";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { UpsertLiteralInput, UpsertLiteralOutput } from "../../../../schemas/manager/literals/upsert.js";
|
|
3
3
|
export declare const upsertLiteralHandler: ({ input, ctx, }: {
|
|
4
4
|
input: UpsertLiteralInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LiteralTranslation } from "../../../../internal-content-types";
|
|
2
|
-
import { throwAppError } from "../../../../lib/errors";
|
|
3
|
-
import { Logger } from "../../../../lib/Logger";
|
|
4
|
-
import { getLiteralDefinition, validateIcuVariables, } from "../../../../literals";
|
|
5
|
-
import { getMongoService } from "../../../../orm";
|
|
6
|
-
import { checkPermissions } from "../../../utils/checkPermissions";
|
|
1
|
+
import { LiteralTranslation } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { throwAppError } from "../../../../lib/errors/index.js";
|
|
3
|
+
import { Logger } from "../../../../lib/Logger.js";
|
|
4
|
+
import { getLiteralDefinition, validateIcuVariables, } from "../../../../literals/index.js";
|
|
5
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
6
|
+
import { checkPermissions } from "../../../utils/checkPermissions.js";
|
|
7
7
|
export const upsertLiteralHandler = async ({ input, ctx, }) => {
|
|
8
8
|
Logger.addTrace("manager.literals.upsert: handler start", {
|
|
9
9
|
key: input.key,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { CreateFolderInput, CreateFolderOutput } from "../../../../schemas/manager/media/createFolder";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { CreateFolderInput, CreateFolderOutput } from "../../../../schemas/manager/media/createFolder.js";
|
|
3
3
|
export declare const createFolderHandler: ({ input, ctx, }: {
|
|
4
4
|
input: CreateFolderInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { MediaFolder } from "../../../../internal-content-types";
|
|
2
|
-
import { throwAppError } from "../../../../lib/errors";
|
|
3
|
-
import { hasPermissions } from "../../../../lib/Permissions";
|
|
4
|
-
import { slugify } from "../../../../lib/utils/slugify";
|
|
5
|
-
import { getMongoService } from "../../../../orm";
|
|
6
|
-
import { DbErrorInvalidData, DbErrorConflict, } from "../../../../orm/dbService";
|
|
7
|
-
import { checkPermissions } from "../../../utils/checkPermissions";
|
|
1
|
+
import { MediaFolder } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { throwAppError } from "../../../../lib/errors/index.js";
|
|
3
|
+
import { hasPermissions } from "../../../../lib/Permissions.js";
|
|
4
|
+
import { slugify } from "../../../../lib/utils/slugify.js";
|
|
5
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
6
|
+
import { DbErrorInvalidData, DbErrorConflict, } from "../../../../orm/dbService.js";
|
|
7
|
+
import { checkPermissions } from "../../../utils/checkPermissions.js";
|
|
8
8
|
const normalizePath = (value) => value
|
|
9
9
|
.trim()
|
|
10
10
|
.replace(/\\/g, "/")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RakunRequestContext } from "../../../context";
|
|
2
|
-
import { FinalizeUploadInput, FinalizeUploadOutput } from "../../../../schemas/manager/media/finalizeUpload";
|
|
1
|
+
import { RakunRequestContext } from "../../../context.js";
|
|
2
|
+
import { FinalizeUploadInput, FinalizeUploadOutput } from "../../../../schemas/manager/media/finalizeUpload.js";
|
|
3
3
|
export declare const finalizeUploadHandler: ({ input, ctx, }: {
|
|
4
4
|
input: FinalizeUploadInput;
|
|
5
5
|
ctx: RakunRequestContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalizeUpload.d.ts","sourceRoot":"","sources":["../../../../../../src/api/routes/manager/media/finalizeUpload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"finalizeUpload.d.ts","sourceRoot":"","sources":["../../../../../../src/api/routes/manager/media/finalizeUpload.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kDAAkD,CAAC;AAwJ1D,eAAO,MAAM,qBAAqB,GAAU,iBAGzC;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,GAAG,EAAE,mBAAmB,CAAC;CAC1B,KAAG,OAAO,CAAC,oBAAoB,CAuK/B,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { MediaFolder, Media } from "../../../../internal-content-types";
|
|
2
|
-
import { isAppError, throwAppError } from "../../../../lib/errors";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { MediaFolder, Media } from "../../../../internal-content-types/index.js";
|
|
2
|
+
import { isAppError, throwAppError } from "../../../../lib/errors/index.js";
|
|
3
|
+
import { Logger } from "../../../../lib/Logger.js";
|
|
4
|
+
import { hasPermissions } from "../../../../lib/Permissions.js";
|
|
5
|
+
import { MediaError, MediaErrorInvalidData, MediaErrorNotFound, getMediaService, } from "../../../../media/index.js";
|
|
6
|
+
import { getMongoService } from "../../../../orm/index.js";
|
|
7
|
+
import { DbErrorConflict, DbErrorInvalidData, } from "../../../../orm/dbService.js";
|
|
8
|
+
import { checkPermissions } from "../../../utils/checkPermissions.js";
|
|
9
|
+
import { slugify } from "../../../../lib/utils/slugify.js";
|
|
9
10
|
const normalizePath = (value) => value
|
|
10
11
|
.trim()
|
|
11
12
|
.replace(/\\/g, "/")
|
|
@@ -104,6 +105,10 @@ const ensureFolderByPath = async ({ folderPath, userId, canReadAny, }) => {
|
|
|
104
105
|
return lastFolder;
|
|
105
106
|
};
|
|
106
107
|
const mapMediaError = (error) => {
|
|
108
|
+
Logger.error("manager.media.finalizeUpload failed", {
|
|
109
|
+
error: error instanceof Error ? error.message : String(error),
|
|
110
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
111
|
+
});
|
|
107
112
|
if (error instanceof MediaErrorInvalidData) {
|
|
108
113
|
throwAppError("VALIDATION", {
|
|
109
114
|
errors: [{ message: error.message }],
|
|
@@ -119,13 +124,36 @@ const mapMediaError = (error) => {
|
|
|
119
124
|
});
|
|
120
125
|
};
|
|
121
126
|
export const finalizeUploadHandler = async ({ input, ctx, }) => {
|
|
127
|
+
Logger.addTrace("manager.media.finalizeUpload: handler start", {
|
|
128
|
+
key: input.key,
|
|
129
|
+
access: input.access,
|
|
130
|
+
folderId: input.folderId,
|
|
131
|
+
folderPath: input.folderPath,
|
|
132
|
+
previewKey: input.previewKey,
|
|
133
|
+
});
|
|
122
134
|
const user = ctx.getUser();
|
|
123
135
|
try {
|
|
136
|
+
Logger.addTrace("manager.media.finalizeUpload: user resolved", {
|
|
137
|
+
userId: user._id,
|
|
138
|
+
});
|
|
124
139
|
checkPermissions(user, ["content.Media.own"]);
|
|
140
|
+
Logger.addTrace("manager.media.finalizeUpload: permissions checked");
|
|
125
141
|
const canReadAny = hasPermissions(user, ["content.Media.readAny"]);
|
|
142
|
+
Logger.addTrace("manager.media.finalizeUpload: ownership scope resolved", {
|
|
143
|
+
canReadAny,
|
|
144
|
+
});
|
|
126
145
|
const media = getMediaService();
|
|
146
|
+
Logger.addTrace("manager.media.finalizeUpload: media service ready");
|
|
127
147
|
const finalized = await media.finalizeUpload(input);
|
|
148
|
+
Logger.addTrace("manager.media.finalizeUpload: storage finalized", {
|
|
149
|
+
key: finalized.key,
|
|
150
|
+
access: finalized.access,
|
|
151
|
+
size: finalized.size,
|
|
152
|
+
mime: finalized.mime,
|
|
153
|
+
hasPublicUrl: Boolean(finalized.publicUrl),
|
|
154
|
+
});
|
|
128
155
|
const db = await getMongoService();
|
|
156
|
+
Logger.addTrace("manager.media.finalizeUpload: mongo service ready");
|
|
129
157
|
let folder;
|
|
130
158
|
if (input.folderId) {
|
|
131
159
|
const existingFolder = await db.find(MediaFolder, {
|
|
@@ -143,6 +171,10 @@ export const finalizeUploadHandler = async ({ input, ctx, }) => {
|
|
|
143
171
|
slug: existingFolder.slug,
|
|
144
172
|
path: existingFolder.path,
|
|
145
173
|
};
|
|
174
|
+
Logger.addTrace("manager.media.finalizeUpload: folder loaded", {
|
|
175
|
+
folderId: folder._id,
|
|
176
|
+
path: folder.path,
|
|
177
|
+
});
|
|
146
178
|
}
|
|
147
179
|
else if (input.folderPath) {
|
|
148
180
|
folder = await ensureFolderByPath({
|
|
@@ -150,6 +182,10 @@ export const finalizeUploadHandler = async ({ input, ctx, }) => {
|
|
|
150
182
|
userId: user._id,
|
|
151
183
|
canReadAny,
|
|
152
184
|
});
|
|
185
|
+
Logger.addTrace("manager.media.finalizeUpload: folder path resolved", {
|
|
186
|
+
folderId: folder?._id,
|
|
187
|
+
path: folder?.path,
|
|
188
|
+
});
|
|
153
189
|
}
|
|
154
190
|
const resolvedOriginalName = input.fileName || fileNameFromKey(finalized.key);
|
|
155
191
|
const resolvedMime = input.mime || finalized.mime || "application/octet-stream";
|
|
@@ -194,6 +230,11 @@ export const finalizeUploadHandler = async ({ input, ctx, }) => {
|
|
|
194
230
|
createdBy: user._id,
|
|
195
231
|
updatedBy: user._id,
|
|
196
232
|
});
|
|
233
|
+
Logger.addTrace("manager.media.finalizeUpload: media record created", {
|
|
234
|
+
id: createdMedia._id,
|
|
235
|
+
key: createdMedia.key,
|
|
236
|
+
folderId: folder?._id,
|
|
237
|
+
});
|
|
197
238
|
const mediaOutput = {
|
|
198
239
|
...createdMedia,
|
|
199
240
|
folder: createdMedia.folder
|
|
@@ -213,6 +254,7 @@ export const finalizeUploadHandler = async ({ input, ctx, }) => {
|
|
|
213
254
|
};
|
|
214
255
|
}
|
|
215
256
|
catch (error) {
|
|
257
|
+
Logger.addTrace("manager.media.finalizeUpload: handler failed");
|
|
216
258
|
if (isAppError(error)) {
|
|
217
259
|
throw error;
|
|
218
260
|
}
|