@yimingliao/cms 0.0.124 → 0.0.126
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/{chunk-VPRGHVG3.js → chunk-PXWRSEQ7.js} +9 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/{create-reset-password-action-C-B3uh5m.d.ts → create-reset-password-action-yWaJxg8W.d.ts} +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +54 -6
- package/dist/server/index.js +118 -141
- package/package.json +3 -1
|
@@ -222,4 +222,12 @@ var CACHE_KEYS = {
|
|
|
222
222
|
var NEW_TAB_TARGET = "_blank";
|
|
223
223
|
var NEW_TAB_REL = "noopener noreferrer";
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
// src/constants/redirect-paths.ts
|
|
226
|
+
var PROTECTED_PATHS = [PATHS.main.dashboard.path];
|
|
227
|
+
var LOGGED_IN_SKIP_PATHS = [
|
|
228
|
+
PATHS.auth.signIn.path,
|
|
229
|
+
PATHS.auth.forgotPassword.path,
|
|
230
|
+
PATHS.auth.resetPassword.path
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
export { CACHE_KEYS, KEYS, LOGGED_IN_SKIP_PATHS, NEW_TAB_REL, NEW_TAB_TARGET, PATHS, PROTECTED_PATHS };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
7
7
|
import { ThemeProvider as ThemeProvider$1 } from 'next-themes';
|
|
8
8
|
import * as React$1 from 'react';
|
|
9
9
|
import { HTMLAttributes, ReactNode, JSX, Dispatch, SetStateAction, ComponentProps, InputHTMLAttributes } from 'react';
|
|
10
|
-
import { c as createVerifyAction, a as createSignOutAction, b as createSignInAction, d as createVerifyEmailAction, e as createEmailUnverifiedAction, f as createForgotPasswordAction, g as createResetPasswordAction, h as createChangePasswordAction } from '../create-reset-password-action-
|
|
10
|
+
import { c as createVerifyAction, a as createSignOutAction, b as createSignInAction, d as createVerifyEmailAction, e as createEmailUnverifiedAction, f as createForgotPasswordAction, g as createResetPasswordAction, h as createChangePasswordAction } from '../create-reset-password-action-yWaJxg8W.js';
|
|
11
11
|
import { LucideIcon } from 'lucide-react';
|
|
12
12
|
import { B as ButtonProps$1, L as LabelProps } from '../sidebar-CBC8_O5A.js';
|
|
13
13
|
export { S as Sidebar, a as SidebarContent, b as SidebarInset, c as SidebarProvider, u as useSidebar } from '../sidebar-CBC8_O5A.js';
|
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PATHS } from '../chunk-
|
|
1
|
+
import { PATHS } from '../chunk-PXWRSEQ7.js';
|
|
2
2
|
import { cn, useSidebar, Sidebar, Skeleton, SidebarInset, SIDEBAR_WIDTH, SidebarGroup, SidebarMenu, Collapsible, SidebarMenuItem, SidebarMenuButton, Separator, CollapsibleTrigger, SidebarMenuAction, CollapsibleContent, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, Button, Spinner, useParentPathname, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, PAGE_HEADER_HEIGHT, InputGroup, InputGroupAddon, Textarea, InputGroupInput, InputGroupButton, Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, Label, FORM_MIDDLE_GAP_WIDTH, FORM_SIDE_FIELDS_WIDTH, Card, useDeviceInfo, CardHeader, CardTitle, CardContent, useCountdown, CardDescription, NAVBAR_HEIGHT, isConfirm, Avatar, AvatarImage, AvatarFallback, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, Pagination, PaginationContent, PaginationItem, PaginationPrevious, PaginationLink, PaginationEllipsis, PaginationNext } from '../chunk-YLFBYJTE.js';
|
|
3
3
|
export { NAVBAR_HEIGHT, PAGE_HEADER_HEIGHT, SIDEBAR_WIDTH, Sidebar, SidebarContent, SidebarInset, SidebarProvider, cn, getControlMeta, isConfirm, useDeviceInfo, usePickItems, useSidebar } from '../chunk-YLFBYJTE.js';
|
|
4
4
|
import { ensureArray, findTranslation, joinUrl } from '../chunk-YYDELEHA.js';
|
|
@@ -927,4 +927,4 @@ declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }:
|
|
|
927
927
|
formData: ResetPasswordFormData;
|
|
928
928
|
}) => Promise<Result<void>>;
|
|
929
929
|
|
|
930
|
-
export { type ActionContext as A,
|
|
930
|
+
export { type ActionContext as A, createFileQueryRepository as B, createFolderCommandRepository as C, createFolderQueryRepository as D, createForgotPasswordEmail as E, createIpRateLimiter as F, createJwtService as G, createPostCommandRepository as H, createPostQueryRepository as I, createRenderEmailTemplate as J, createSendEmail as K, createSeoMetadataCommandRepository as L, createUnique as M, createVerifyAccessToken as N, createVerifyRefreshToken as O, normalizeCacheKey as P, type RateLimiterOptions as R, createSignOutAction as a, createSignInAction as b, createVerifyAction as c, createVerifyEmailAction as d, createEmailUnverifiedAction as e, createForgotPasswordAction as f, createResetPasswordAction as g, createChangePasswordAction as h, createZod as i, createSchemas as j, createTocItemSchema as k, createCryptoService as l, createAuthMiddleware as m, type RawCacheKey as n, createAdminCommandRepository as o, createAdminQueryRepository as p, createAdminRefreshTokenCommandRepository as q, createAdminRefreshTokenQueryRepository as r, createArgon2Service as s, createAuthUseCases as t, createCacheResult as u, createCookieService as v, createEmailVerificationEmail as w, createExecuteAction as x, createExist as y, createFileCommandRepository as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -326,6 +326,9 @@ declare const CACHE_KEYS: {
|
|
|
326
326
|
declare const NEW_TAB_TARGET = "_blank";
|
|
327
327
|
declare const NEW_TAB_REL = "noopener noreferrer";
|
|
328
328
|
|
|
329
|
+
declare const PROTECTED_PATHS: "/cms/dashboard"[];
|
|
330
|
+
declare const LOGGED_IN_SKIP_PATHS: ("/cms/sign-in" | "/cms/forgot-password" | "/cms/reset-password")[];
|
|
331
|
+
|
|
329
332
|
declare const mimeToExtension: (mimeType?: string) => string;
|
|
330
333
|
|
|
331
334
|
declare const classifyFileType: (mimeType?: string, extension?: string) => "IMAGE" | "AUDIO" | "VIDEO" | "DOCUMENT" | "ARCHIVE" | "OTHER";
|
|
@@ -422,4 +425,4 @@ declare const SIZE: {
|
|
|
422
425
|
};
|
|
423
426
|
type SizeUnit = keyof typeof SIZE;
|
|
424
427
|
|
|
425
|
-
export { ADMIN_ROLE_ARRAY, ADMIN_ROLE_I18N_MAP, BaseTranslation, CACHE_KEYS, ErrorDetail, ErrorResult, type ErrorResultParams, FileCard, FileFull, Folder, FolderFull, KEYS, NEW_TAB_REL, NEW_TAB_TARGET, OG_TYPE_ARRAY, type OgType, PATHS, PostFull, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, SIZE, type SizeUnit, SuccessResult, type SuccessResultParams, TWITTER_CARD_ARRAY, type TwitterCard, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, datetimeToDb, datetimeToUi, ensureArray, fileManagerDoubleClick, findTranslation, formatDateTime, formatFileSize, getMediaInfo, isFileLocked, isFolderLocked, joinUrl, jsonArrayToDb, jsonArrayToUi, mimeToExtension, normalizeFolderKey, result, serializeJsonLd };
|
|
428
|
+
export { ADMIN_ROLE_ARRAY, ADMIN_ROLE_I18N_MAP, BaseTranslation, CACHE_KEYS, ErrorDetail, ErrorResult, type ErrorResultParams, FileCard, FileFull, Folder, FolderFull, KEYS, LOGGED_IN_SKIP_PATHS, NEW_TAB_REL, NEW_TAB_TARGET, OG_TYPE_ARRAY, type OgType, PATHS, PROTECTED_PATHS, PostFull, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, SIZE, type SizeUnit, SuccessResult, type SuccessResultParams, TWITTER_CARD_ARRAY, type TwitterCard, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, datetimeToDb, datetimeToUi, ensureArray, fileManagerDoubleClick, findTranslation, formatDateTime, formatFileSize, getMediaInfo, isFileLocked, isFolderLocked, joinUrl, jsonArrayToDb, jsonArrayToUi, mimeToExtension, normalizeFolderKey, result, serializeJsonLd };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CACHE_KEYS, KEYS, NEW_TAB_REL, NEW_TAB_TARGET, PATHS } from './chunk-
|
|
1
|
+
export { CACHE_KEYS, KEYS, LOGGED_IN_SKIP_PATHS, NEW_TAB_REL, NEW_TAB_TARGET, PATHS, PROTECTED_PATHS } from './chunk-PXWRSEQ7.js';
|
|
2
2
|
export { ADMIN_ROLES, ADMIN_ROLE_ARRAY, ADMIN_ROLE_I18N_MAP, POST_TYPES, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, fileManagerDoubleClick, isFileLocked, isFolderLocked, normalizeFolderKey } from './chunk-5LKI7KHR.js';
|
|
3
3
|
export { FILE_TYPES, OG_TYPE_ARRAY, SIZE, TWITTER_CARD_ARRAY, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, datetimeToDb, datetimeToUi, ensureArray, findTranslation, formatDateTime, formatFileSize, getMediaInfo, joinUrl, jsonArrayToDb, jsonArrayToUi, mimeToExtension, result, serializeJsonLd } from './chunk-YYDELEHA.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as createZod, j as createSchemas, A as ActionContext, k as createTocItemSchema } from '../create-reset-password-action-
|
|
2
|
-
export {
|
|
1
|
+
import { i as createZod, j as createSchemas, A as ActionContext, k as createTocItemSchema, l as createCryptoService, m as createAuthMiddleware, R as RateLimiterOptions } from '../create-reset-password-action-yWaJxg8W.js';
|
|
2
|
+
export { n as RawCacheKey, o as createAdminCommandRepository, p as createAdminQueryRepository, q as createAdminRefreshTokenCommandRepository, r as createAdminRefreshTokenQueryRepository, s as createArgon2Service, t as createAuthUseCases, u as createCacheResult, h as createChangePasswordAction, v as createCookieService, e as createEmailUnverifiedAction, w as createEmailVerificationEmail, x as createExecuteAction, y as createExist, z as createFileCommandRepository, B as createFileQueryRepository, C as createFolderCommandRepository, D as createFolderQueryRepository, f as createForgotPasswordAction, E as createForgotPasswordEmail, F as createIpRateLimiter, G as createJwtService, H as createPostCommandRepository, I as createPostQueryRepository, J as createRenderEmailTemplate, g as createResetPasswordAction, K as createSendEmail, L as createSeoMetadataCommandRepository, b as createSignInAction, a as createSignOutAction, M as createUnique, N as createVerifyAccessToken, c as createVerifyAction, d as createVerifyEmailAction, O as createVerifyRefreshToken, P as normalizeCacheKey } from '../create-reset-password-action-yWaJxg8W.js';
|
|
3
3
|
import Keyv from 'keyv';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import zod__default from 'zod';
|
|
@@ -8,10 +8,10 @@ import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
|
|
|
8
8
|
import nodemailer from 'nodemailer';
|
|
9
9
|
import { BaseTranslator, LocaleMessages } from 'intor';
|
|
10
10
|
import { Logger } from 'logry';
|
|
11
|
-
import { NextResponse } from 'next/server';
|
|
12
|
-
import { R as Result, e as Admin, g as AdminFull, h as AdminRefreshToken, a as Folder, b as FileFull, p as File$1, r as FileType, F as FolderFull, T as TocItem, f as AdminCard, u as PostListCard, c as FileCard, t as Post, w as PostType, v as PostTranslation, P as PostFull } from '../types-BGsFazJr.js';
|
|
11
|
+
import { NextResponse, NextRequest } from 'next/server';
|
|
12
|
+
import { R as Result, e as Admin, g as AdminFull, h as AdminRefreshToken, a as Folder, b as FileFull, p as File$1, r as FileType, F as FolderFull, T as TocItem, f as AdminCard, u as PostListCard, c as FileCard, t as Post, w as PostType, v as PostTranslation, P as PostFull, y as SingleItem } from '../types-BGsFazJr.js';
|
|
13
13
|
import * as zod_v4_core from 'zod/v4/core';
|
|
14
|
-
import '../types-J25u1G6t.js';
|
|
14
|
+
import { S as StorageService } from '../types-J25u1G6t.js';
|
|
15
15
|
import 'jsonwebtoken';
|
|
16
16
|
import 'node:crypto';
|
|
17
17
|
import 'next/headers';
|
|
@@ -1532,6 +1532,54 @@ declare function createSeoMetadataUpsertAction(ctx: ActionContext): ({ formData,
|
|
|
1532
1532
|
formData: SeoMetadataUpsertFormData;
|
|
1533
1533
|
}) => Promise<Result<void>>;
|
|
1534
1534
|
|
|
1535
|
+
interface ApiContext {
|
|
1536
|
+
services: {
|
|
1537
|
+
cryptoService: ReturnType<typeof createCryptoService>;
|
|
1538
|
+
storageService: StorageService;
|
|
1539
|
+
};
|
|
1540
|
+
middlewares: {
|
|
1541
|
+
authMiddleware: ReturnType<typeof createAuthMiddleware>;
|
|
1542
|
+
};
|
|
1543
|
+
api: {
|
|
1544
|
+
executeApi: ReturnType<typeof createExecuteApi>;
|
|
1545
|
+
ipRateLimiter: (options: RateLimiterOptions) => Promise<void>;
|
|
1546
|
+
};
|
|
1547
|
+
schemas: {
|
|
1548
|
+
schemas: ReturnType<typeof createSchemas>;
|
|
1549
|
+
fileSchema: ReturnType<typeof createFileSchema>;
|
|
1550
|
+
multiFilesSchema: ReturnType<typeof createMultiFileSchema>;
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
interface FileUploadRequestDto extends Pick<FileCreateFormData, "folder" | "folderKey"> {
|
|
1555
|
+
blobFile?: BlobFile | null;
|
|
1556
|
+
}
|
|
1557
|
+
interface FileUploadResponseDto {
|
|
1558
|
+
key: string;
|
|
1559
|
+
checksum: string;
|
|
1560
|
+
}
|
|
1561
|
+
declare function createFileUploadApi(ctx: ApiContext): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
1562
|
+
|
|
1563
|
+
interface MultiFilesUploadRequestDto {
|
|
1564
|
+
blobFiles?: BlobFile[];
|
|
1565
|
+
folder?: SingleItem;
|
|
1566
|
+
}
|
|
1567
|
+
interface MultiFilesUploadResponseDto {
|
|
1568
|
+
uploadResults: {
|
|
1569
|
+
checksum: string;
|
|
1570
|
+
key: string;
|
|
1571
|
+
fileMeta: {
|
|
1572
|
+
name: string;
|
|
1573
|
+
size: number;
|
|
1574
|
+
type: string;
|
|
1575
|
+
};
|
|
1576
|
+
width: number | null;
|
|
1577
|
+
height: number | null;
|
|
1578
|
+
duration: number | null;
|
|
1579
|
+
}[];
|
|
1580
|
+
}
|
|
1581
|
+
declare function createMultiFilesUploadApi(ctx: ApiContext): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
1582
|
+
|
|
1535
1583
|
declare class ServerError extends Error {
|
|
1536
1584
|
readonly i18nKey?: string;
|
|
1537
1585
|
readonly statusCode?: number;
|
|
@@ -1550,4 +1598,4 @@ declare class ServerError extends Error {
|
|
|
1550
1598
|
static internalServerError(): ServerError;
|
|
1551
1599
|
}
|
|
1552
1600
|
|
|
1553
|
-
export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createRunAction, createSchemas, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createZod };
|
|
1601
|
+
export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type ApiContext, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FileUploadRequestDto, type FileUploadResponseDto, type FolderCreateFormData, type FolderUpdateFormData, type MultiFilesUploadRequestDto, type MultiFilesUploadResponseDto, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createAuthMiddleware, createCache, createCryptoService, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFileUploadApi, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createMultiFilesUploadApi, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createRunAction, createSchemas, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createZod };
|
package/dist/server/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import path from 'path';
|
|
|
12
12
|
import { ulid } from 'ulid';
|
|
13
13
|
import { NextResponse } from 'next/server';
|
|
14
14
|
import path2 from 'path/posix';
|
|
15
|
+
import pLimit from 'p-limit';
|
|
16
|
+
import { BodyParser } from 'next-body-parser';
|
|
15
17
|
|
|
16
18
|
function createJwtService({
|
|
17
19
|
defaultSecret,
|
|
@@ -2936,146 +2938,6 @@ function createFileUpdateAction(ctx) {
|
|
|
2936
2938
|
};
|
|
2937
2939
|
}
|
|
2938
2940
|
|
|
2939
|
-
// node_modules/yocto-queue/index.js
|
|
2940
|
-
var Node = class {
|
|
2941
|
-
value;
|
|
2942
|
-
next;
|
|
2943
|
-
constructor(value) {
|
|
2944
|
-
this.value = value;
|
|
2945
|
-
}
|
|
2946
|
-
};
|
|
2947
|
-
var Queue = class {
|
|
2948
|
-
#head;
|
|
2949
|
-
#tail;
|
|
2950
|
-
#size;
|
|
2951
|
-
constructor() {
|
|
2952
|
-
this.clear();
|
|
2953
|
-
}
|
|
2954
|
-
enqueue(value) {
|
|
2955
|
-
const node = new Node(value);
|
|
2956
|
-
if (this.#head) {
|
|
2957
|
-
this.#tail.next = node;
|
|
2958
|
-
this.#tail = node;
|
|
2959
|
-
} else {
|
|
2960
|
-
this.#head = node;
|
|
2961
|
-
this.#tail = node;
|
|
2962
|
-
}
|
|
2963
|
-
this.#size++;
|
|
2964
|
-
}
|
|
2965
|
-
dequeue() {
|
|
2966
|
-
const current = this.#head;
|
|
2967
|
-
if (!current) {
|
|
2968
|
-
return;
|
|
2969
|
-
}
|
|
2970
|
-
this.#head = this.#head.next;
|
|
2971
|
-
this.#size--;
|
|
2972
|
-
if (!this.#head) {
|
|
2973
|
-
this.#tail = void 0;
|
|
2974
|
-
}
|
|
2975
|
-
return current.value;
|
|
2976
|
-
}
|
|
2977
|
-
peek() {
|
|
2978
|
-
if (!this.#head) {
|
|
2979
|
-
return;
|
|
2980
|
-
}
|
|
2981
|
-
return this.#head.value;
|
|
2982
|
-
}
|
|
2983
|
-
clear() {
|
|
2984
|
-
this.#head = void 0;
|
|
2985
|
-
this.#tail = void 0;
|
|
2986
|
-
this.#size = 0;
|
|
2987
|
-
}
|
|
2988
|
-
get size() {
|
|
2989
|
-
return this.#size;
|
|
2990
|
-
}
|
|
2991
|
-
*[Symbol.iterator]() {
|
|
2992
|
-
let current = this.#head;
|
|
2993
|
-
while (current) {
|
|
2994
|
-
yield current.value;
|
|
2995
|
-
current = current.next;
|
|
2996
|
-
}
|
|
2997
|
-
}
|
|
2998
|
-
*drain() {
|
|
2999
|
-
while (this.#head) {
|
|
3000
|
-
yield this.dequeue();
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
};
|
|
3004
|
-
|
|
3005
|
-
// node_modules/p-limit/index.js
|
|
3006
|
-
function pLimit(concurrency) {
|
|
3007
|
-
validateConcurrency(concurrency);
|
|
3008
|
-
const queue = new Queue();
|
|
3009
|
-
let activeCount = 0;
|
|
3010
|
-
const resumeNext = () => {
|
|
3011
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
3012
|
-
activeCount++;
|
|
3013
|
-
queue.dequeue()();
|
|
3014
|
-
}
|
|
3015
|
-
};
|
|
3016
|
-
const next = () => {
|
|
3017
|
-
activeCount--;
|
|
3018
|
-
resumeNext();
|
|
3019
|
-
};
|
|
3020
|
-
const run = async (function_, resolve, arguments_) => {
|
|
3021
|
-
const result2 = (async () => function_(...arguments_))();
|
|
3022
|
-
resolve(result2);
|
|
3023
|
-
try {
|
|
3024
|
-
await result2;
|
|
3025
|
-
} catch {
|
|
3026
|
-
}
|
|
3027
|
-
next();
|
|
3028
|
-
};
|
|
3029
|
-
const enqueue = (function_, resolve, arguments_) => {
|
|
3030
|
-
new Promise((internalResolve) => {
|
|
3031
|
-
queue.enqueue(internalResolve);
|
|
3032
|
-
}).then(run.bind(void 0, function_, resolve, arguments_));
|
|
3033
|
-
if (activeCount < concurrency) {
|
|
3034
|
-
resumeNext();
|
|
3035
|
-
}
|
|
3036
|
-
};
|
|
3037
|
-
const generator = (function_, ...arguments_) => new Promise((resolve) => {
|
|
3038
|
-
enqueue(function_, resolve, arguments_);
|
|
3039
|
-
});
|
|
3040
|
-
Object.defineProperties(generator, {
|
|
3041
|
-
activeCount: {
|
|
3042
|
-
get: () => activeCount
|
|
3043
|
-
},
|
|
3044
|
-
pendingCount: {
|
|
3045
|
-
get: () => queue.size
|
|
3046
|
-
},
|
|
3047
|
-
clearQueue: {
|
|
3048
|
-
value() {
|
|
3049
|
-
queue.clear();
|
|
3050
|
-
}
|
|
3051
|
-
},
|
|
3052
|
-
concurrency: {
|
|
3053
|
-
get: () => concurrency,
|
|
3054
|
-
set(newConcurrency) {
|
|
3055
|
-
validateConcurrency(newConcurrency);
|
|
3056
|
-
concurrency = newConcurrency;
|
|
3057
|
-
queueMicrotask(() => {
|
|
3058
|
-
while (activeCount < concurrency && queue.size > 0) {
|
|
3059
|
-
resumeNext();
|
|
3060
|
-
}
|
|
3061
|
-
});
|
|
3062
|
-
}
|
|
3063
|
-
},
|
|
3064
|
-
map: {
|
|
3065
|
-
async value(iterable, function_) {
|
|
3066
|
-
const promises = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
3067
|
-
return Promise.all(promises);
|
|
3068
|
-
}
|
|
3069
|
-
}
|
|
3070
|
-
});
|
|
3071
|
-
return generator;
|
|
3072
|
-
}
|
|
3073
|
-
function validateConcurrency(concurrency) {
|
|
3074
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
3075
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
2941
|
// src/server/interfaces/actions/resources/file/commands/create-many/file-create-many-validator.ts
|
|
3080
2942
|
var fileCreateManyValidator = (schemas) => schemas.z.object({
|
|
3081
2943
|
uploadResults: schemas.array(
|
|
@@ -4204,6 +4066,121 @@ function createSeoMetadataUpsertAction(ctx) {
|
|
|
4204
4066
|
};
|
|
4205
4067
|
}
|
|
4206
4068
|
|
|
4069
|
+
// src/server/interfaces/apis/file-upload/validator.ts
|
|
4070
|
+
var fileUploadValidator = (schemas) => schemas.z.object({
|
|
4071
|
+
folder: schemas.z.object({ id: schemas.id().exist({ table: "folders", column: "id" }) }).optional(),
|
|
4072
|
+
folderKey: schemas.key().exist({ table: "folders", column: "key" }).optional(),
|
|
4073
|
+
//====== Translations ======
|
|
4074
|
+
translations: schemas.array(
|
|
4075
|
+
schemas.z.object({
|
|
4076
|
+
locale: schemas.locale(),
|
|
4077
|
+
name: schemas.text().nullable(),
|
|
4078
|
+
alt: schemas.text().nullable()
|
|
4079
|
+
})
|
|
4080
|
+
).optional()
|
|
4081
|
+
// Can be optional when use in Simple Upload
|
|
4082
|
+
});
|
|
4083
|
+
|
|
4084
|
+
// src/server/interfaces/apis/file-upload/file-upload-api.ts
|
|
4085
|
+
function createFileUploadApi(ctx) {
|
|
4086
|
+
return function fileUploadApi(request) {
|
|
4087
|
+
const {
|
|
4088
|
+
services: { cryptoService, storageService },
|
|
4089
|
+
middlewares: { authMiddleware },
|
|
4090
|
+
api: { executeApi, ipRateLimiter },
|
|
4091
|
+
schemas: { schemas, fileSchema }
|
|
4092
|
+
} = ctx;
|
|
4093
|
+
return executeApi(async () => {
|
|
4094
|
+
await ipRateLimiter({ key: ["file-upload"], maxAttempts: 60 });
|
|
4095
|
+
await authMiddleware.authenticate();
|
|
4096
|
+
const payload = BodyParser.parse(await request.formData());
|
|
4097
|
+
const { folderKey } = await fileUploadValidator(schemas).parseAsync(payload);
|
|
4098
|
+
const blobFile = await fileSchema().parseAsync(payload["blobFile"]);
|
|
4099
|
+
const checksum = cryptoService.hash(
|
|
4100
|
+
Buffer.from(await blobFile.arrayBuffer())
|
|
4101
|
+
);
|
|
4102
|
+
const resolvedFolderKey = payload["folder"] ? payload["folder"].key : folderKey;
|
|
4103
|
+
const key = await storageService.upload({
|
|
4104
|
+
blobFile,
|
|
4105
|
+
...resolvedFolderKey ? { folderKey: resolvedFolderKey } : {}
|
|
4106
|
+
});
|
|
4107
|
+
return NextResponse.json(
|
|
4108
|
+
result.success({
|
|
4109
|
+
data: { key, checksum }
|
|
4110
|
+
})
|
|
4111
|
+
);
|
|
4112
|
+
});
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// src/server/interfaces/apis/multi-files-upload/validator.ts
|
|
4117
|
+
var multiFilesUploadValidator = (schemas) => schemas.z.object({
|
|
4118
|
+
folder: schemas.z.object({ id: schemas.id().exist({ table: "folders", column: "id" }) }).optional(),
|
|
4119
|
+
folderKey: schemas.key().exist({ table: "folders", column: "key" }).optional(),
|
|
4120
|
+
blobFileInfos: schemas.array(
|
|
4121
|
+
schemas.z.object({
|
|
4122
|
+
width: schemas.positiveNumber().nullable(),
|
|
4123
|
+
height: schemas.positiveNumber().nullable(),
|
|
4124
|
+
duration: schemas.positiveNumber().nullable()
|
|
4125
|
+
})
|
|
4126
|
+
)
|
|
4127
|
+
});
|
|
4128
|
+
|
|
4129
|
+
// src/server/interfaces/apis/multi-files-upload/multi-files-upload-api.ts
|
|
4130
|
+
function createMultiFilesUploadApi(ctx) {
|
|
4131
|
+
return function multiFilesUploadApi(request) {
|
|
4132
|
+
const {
|
|
4133
|
+
services: { cryptoService, storageService },
|
|
4134
|
+
middlewares: { authMiddleware },
|
|
4135
|
+
api: { executeApi, ipRateLimiter },
|
|
4136
|
+
schemas: { schemas, multiFilesSchema }
|
|
4137
|
+
} = ctx;
|
|
4138
|
+
return executeApi(async () => {
|
|
4139
|
+
await ipRateLimiter({
|
|
4140
|
+
key: ["multi-files-upload"],
|
|
4141
|
+
maxAttempts: 60,
|
|
4142
|
+
timeWindow: 60
|
|
4143
|
+
});
|
|
4144
|
+
await authMiddleware.authenticate();
|
|
4145
|
+
const payload = BodyParser.parse(await request.formData());
|
|
4146
|
+
const { folderKey, blobFileInfos } = await multiFilesUploadValidator(schemas).parseAsync(payload);
|
|
4147
|
+
const blobFiles = await multiFilesSchema().parseAsync(
|
|
4148
|
+
payload["blobFiles"]
|
|
4149
|
+
);
|
|
4150
|
+
const limit = pLimit(5);
|
|
4151
|
+
const uploadResults = await Promise.all(
|
|
4152
|
+
blobFiles.map(
|
|
4153
|
+
(blobFile, index) => limit(async () => {
|
|
4154
|
+
const checksum = cryptoService.hash(
|
|
4155
|
+
Buffer.from(await blobFile.arrayBuffer())
|
|
4156
|
+
);
|
|
4157
|
+
const resolvedFolderKey = payload["folder"] ? payload["folder"].key : folderKey;
|
|
4158
|
+
const key = await storageService.upload({
|
|
4159
|
+
blobFile,
|
|
4160
|
+
...resolvedFolderKey ? { folderKey: resolvedFolderKey } : {}
|
|
4161
|
+
});
|
|
4162
|
+
const { name, size, type } = blobFile;
|
|
4163
|
+
const { width, height, duration } = blobFileInfos[index] ?? {};
|
|
4164
|
+
return {
|
|
4165
|
+
checksum,
|
|
4166
|
+
key,
|
|
4167
|
+
fileMeta: { name, size, type },
|
|
4168
|
+
width: width ?? null,
|
|
4169
|
+
height: height ?? null,
|
|
4170
|
+
duration: duration ?? null
|
|
4171
|
+
};
|
|
4172
|
+
})
|
|
4173
|
+
)
|
|
4174
|
+
);
|
|
4175
|
+
return NextResponse.json(
|
|
4176
|
+
result.success({
|
|
4177
|
+
data: { uploadResults }
|
|
4178
|
+
})
|
|
4179
|
+
);
|
|
4180
|
+
});
|
|
4181
|
+
};
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4207
4184
|
// src/server/applications/auth/create-auth-use-cases.ts
|
|
4208
4185
|
function createAuthUseCases({
|
|
4209
4186
|
prisma,
|
|
@@ -4382,4 +4359,4 @@ function createForgotPasswordEmail({
|
|
|
4382
4359
|
};
|
|
4383
4360
|
}
|
|
4384
4361
|
|
|
4385
|
-
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createResetPasswordAction, createRunAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSeoMetadataUpsertAction, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
|
|
4362
|
+
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFileUploadApi, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createMultiFilesUploadApi, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createResetPasswordAction, createRunAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSeoMetadataUpsertAction, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yimingliao/cms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.126",
|
|
4
4
|
"author": "Yiming Liao",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,8 +65,10 @@
|
|
|
65
65
|
"logry": "^2.1.6",
|
|
66
66
|
"lucide-react": "^0.577.0",
|
|
67
67
|
"mime-types": "^3.0.2",
|
|
68
|
+
"next-body-parser": "^1.0.0",
|
|
68
69
|
"next-themes": "^0.4.6",
|
|
69
70
|
"nodemailer": "^8.0.1",
|
|
71
|
+
"p-limit": "^7.3.0",
|
|
70
72
|
"sonner": "^2.0.7",
|
|
71
73
|
"ua-parser-js": "^2.0.9",
|
|
72
74
|
"ulid": "^3.0.2"
|