@hywax/cms 0.0.3 → 0.0.5
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/.nuxt/cms/autocomplete-select.ts +5 -0
- package/.nuxt/cms/button-copy.ts +5 -0
- package/.nuxt/cms/button-delete.ts +5 -0
- package/.nuxt/cms/form-panel-aside-section.ts +9 -0
- package/.nuxt/cms/form-panel-section.ts +8 -0
- package/.nuxt/cms/form-panel.ts +15 -0
- package/.nuxt/cms/http-codes.ts +8 -0
- package/.nuxt/cms/index.ts +16 -0
- package/.nuxt/cms/input-seo.ts +5 -0
- package/.nuxt/cms/input-slug.ts +5 -0
- package/.nuxt/cms/modal-confirm.ts +5 -0
- package/.nuxt/cms/table-cell-preview.ts +9 -0
- package/.nuxt/cms/table-cell-seo.ts +5 -0
- package/.nuxt/cms/table-cell-user.ts +5 -0
- package/.nuxt/cms/table-panel-column-sorting.ts +5 -0
- package/.nuxt/cms/table-panel-column-visibility.ts +5 -0
- package/.nuxt/cms/table-panel-filters.ts +5 -0
- package/.nuxt/cms/table-panel.ts +8 -0
- package/cli/templates.mjs +3 -2
- package/dist/module.d.mts +22 -13
- package/dist/module.json +1 -1
- package/dist/module.mjs +261 -35
- package/dist/runtime/components/AutocompleteSelect.vue +170 -0
- package/dist/runtime/components/AutocompleteSelect.vue.d.ts +42 -0
- package/dist/runtime/components/ButtonCopy.vue +40 -0
- package/dist/runtime/components/ButtonCopy.vue.d.ts +23 -0
- package/dist/runtime/components/ButtonDelete.vue +52 -0
- package/dist/runtime/components/ButtonDelete.vue.d.ts +28 -0
- package/dist/runtime/components/FormPanel.vue +70 -0
- package/dist/runtime/components/FormPanel.vue.d.ts +41 -0
- package/dist/runtime/components/FormPanelAsideSection.vue +41 -0
- package/dist/runtime/components/FormPanelAsideSection.vue.d.ts +23 -0
- package/dist/runtime/components/FormPanelSection.vue +31 -0
- package/dist/runtime/components/FormPanelSection.vue.d.ts +20 -0
- package/dist/runtime/components/InputSeo.vue +73 -0
- package/dist/runtime/components/InputSeo.vue.d.ts +19 -0
- package/dist/runtime/components/InputSlug.vue +70 -0
- package/dist/runtime/components/InputSlug.vue.d.ts +29 -0
- package/dist/runtime/components/ModalConfirm.vue +91 -0
- package/dist/runtime/components/ModalConfirm.vue.d.ts +26 -0
- package/dist/runtime/components/TableCellPreview.vue +40 -0
- package/dist/runtime/components/TableCellPreview.vue.d.ts +18 -0
- package/dist/runtime/components/TableCellSeo.vue +34 -0
- package/dist/runtime/components/TableCellSeo.vue.d.ts +13 -0
- package/dist/runtime/components/TableCellUser.vue +33 -0
- package/dist/runtime/components/TableCellUser.vue.d.ts +15 -0
- package/dist/runtime/components/TablePanel.vue +153 -0
- package/dist/runtime/components/TablePanel.vue.d.ts +50 -0
- package/dist/runtime/components/TablePanelColumnSorting.vue +72 -0
- package/dist/runtime/components/TablePanelColumnSorting.vue.d.ts +20 -0
- package/dist/runtime/components/TablePanelColumnVisibility.vue +49 -0
- package/dist/runtime/components/TablePanelColumnVisibility.vue.d.ts +20 -0
- package/dist/runtime/components/TablePanelFilters.vue +79 -0
- package/dist/runtime/components/TablePanelFilters.vue.d.ts +34 -0
- package/dist/runtime/components/prose/UploraImage.vue +8 -3
- package/dist/runtime/composables/useDeleteConfirm.d.ts +15 -0
- package/dist/runtime/composables/useDeleteConfirm.js +29 -0
- package/dist/runtime/composables/useSeoStats.d.ts +2 -2
- package/dist/runtime/composables/useSeoStats.js +1 -1
- package/dist/runtime/composables/useTable.d.ts +19 -0
- package/dist/runtime/composables/useTable.js +90 -0
- package/dist/runtime/editor/markdown/index.d.ts +3 -0
- package/dist/runtime/editor/markdown/index.js +47 -0
- package/dist/runtime/editor/markdown/nodes/callout.d.ts +2 -0
- package/dist/runtime/editor/markdown/nodes/callout.js +21 -0
- package/dist/runtime/editor/markdown/nodes/uploraImage.d.ts +2 -0
- package/dist/runtime/editor/markdown/nodes/uploraImage.js +31 -0
- package/dist/runtime/plugins/api.js +1 -4
- package/dist/runtime/server/errors/InternalHttpError.d.ts +4 -0
- package/dist/runtime/server/errors/InternalHttpError.js +6 -0
- package/dist/runtime/server/errors/TimeoutError.d.ts +2 -0
- package/dist/runtime/server/errors/TimeoutError.js +2 -0
- package/dist/runtime/server/errors/index.d.ts +2 -0
- package/dist/runtime/server/errors/index.js +2 -0
- package/dist/runtime/server/types/errors.d.ts +8 -0
- package/dist/runtime/server/types/errors.js +0 -0
- package/dist/runtime/server/types/index.d.ts +1 -0
- package/dist/runtime/server/types/index.js +1 -0
- package/dist/runtime/server/utils/errors.d.ts +8 -0
- package/dist/runtime/server/utils/errors.js +57 -0
- package/dist/runtime/server/utils/httpHandler.d.ts +10 -0
- package/dist/runtime/server/utils/httpHandler.js +15 -0
- package/dist/runtime/server/utils/pagination.d.ts +11 -0
- package/dist/runtime/server/utils/pagination.js +12 -0
- package/dist/runtime/server/utils/timeout.d.ts +7 -0
- package/dist/runtime/server/utils/timeout.js +9 -0
- package/dist/runtime/server/utils/validation.d.ts +3 -0
- package/dist/runtime/server/utils/validation.js +26 -0
- package/dist/runtime/types/index.d.ts +17 -0
- package/dist/runtime/types/index.js +17 -0
- package/dist/runtime/types/query.d.ts +22 -0
- package/dist/runtime/types/query.js +0 -0
- package/dist/runtime/types/utils.d.ts +4 -1
- package/dist/runtime/utils/avatar.d.ts +1 -0
- package/dist/runtime/utils/avatar.js +9 -0
- package/dist/runtime/utils/dictionaries.d.ts +4 -0
- package/dist/runtime/utils/dictionaries.js +6 -0
- package/dist/runtime/utils/image.js +1 -1
- package/dist/runtime/utils/index.d.ts +3 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/slugify.d.ts +1 -0
- package/dist/runtime/utils/slugify.js +12 -0
- package/dist/types.d.mts +6 -2
- package/package.json +12 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EventHandler, EventHandlerRequest, EventHandlerResponse } from 'h3';
|
|
2
|
+
import type { ErrorMapCodes } from '../types';
|
|
3
|
+
export interface EventHandlerOptions {
|
|
4
|
+
errorMap?: ErrorMapCodes;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Функция для определения обработчика HTTP-запросов.
|
|
8
|
+
* Обрабатывает, H3-обработчик и ловит, обрабатывает ошибки.
|
|
9
|
+
*/
|
|
10
|
+
export declare function defineHttpHandler<Request extends EventHandlerRequest, Response extends EventHandlerResponse>(handler: EventHandler<Request, Response | Promise<Response>>, options?: EventHandlerOptions): EventHandler<Request, Promise<Response>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { eventHandler } from "h3";
|
|
2
|
+
import { errorServerResolver } from "./errors.js";
|
|
3
|
+
export function defineHttpHandler(handler, options) {
|
|
4
|
+
return eventHandler(async (event) => {
|
|
5
|
+
try {
|
|
6
|
+
return await handler(event);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
let error = e;
|
|
9
|
+
if (error.cause?.data instanceof Error) {
|
|
10
|
+
error = error.cause?.data;
|
|
11
|
+
}
|
|
12
|
+
throw errorServerResolver(error, options?.errorMap);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KeysMatching, Pagination } from '../../types';
|
|
2
|
+
export declare function extractPaginationData<T extends {
|
|
3
|
+
total: number;
|
|
4
|
+
}>(data: T[]): {
|
|
5
|
+
items: Omit<T, 'total'>[];
|
|
6
|
+
pagination: Pagination;
|
|
7
|
+
};
|
|
8
|
+
export declare function extractPaginationData<T extends object, K extends KeysMatching<T, number>>(data: T[], key: K): {
|
|
9
|
+
items: Omit<T, K>[];
|
|
10
|
+
pagination: Pagination;
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function extractPaginationData(data, key) {
|
|
2
|
+
if (!data.length) {
|
|
3
|
+
return { items: [], pagination: { total: 0 } };
|
|
4
|
+
}
|
|
5
|
+
const totalKey = key ?? "total";
|
|
6
|
+
const total = Number(data[0]?.[totalKey]) || 0;
|
|
7
|
+
const items = data.map(({ [totalKey]: _, ...item }) => item);
|
|
8
|
+
return {
|
|
9
|
+
items,
|
|
10
|
+
pagination: { total }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TimeoutError } from '../errors/TimeoutError';
|
|
2
|
+
interface TryWithTimeoutOptions {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
timeoutMessage?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function tryWithTimeout<T>(promise: Promise<T>, options: TryWithTimeoutOptions): Promise<T | TimeoutError>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TimeoutError } from "../errors/TimeoutError.js";
|
|
2
|
+
export function tryWithTimeout(promise, options) {
|
|
3
|
+
return Promise.race([
|
|
4
|
+
promise,
|
|
5
|
+
new Promise(
|
|
6
|
+
(_, reject) => setTimeout(() => reject(new TimeoutError(options?.timeoutMessage)), options?.timeout ?? 1e3)
|
|
7
|
+
)
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PaginationQueryRaw, PaginationQueryValidated, SortQuery, SortQueryRaw } from '../../types';
|
|
2
|
+
export declare function getValidatedSort<T extends string[]>(query: SortQueryRaw, availableColumns: readonly [...T]): SortQuery<T[number]>;
|
|
3
|
+
export declare function getValidatedPagination(query: PaginationQueryRaw): PaginationQueryValidated;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HTTP_CODE_BAD_REQUEST } from "#cms/http-codes";
|
|
2
|
+
import { InternalHttpError } from "../errors/InternalHttpError.js";
|
|
3
|
+
export function getValidatedSort(query, availableColumns) {
|
|
4
|
+
if (!query.sortColumn || !availableColumns.includes(query.sortColumn)) {
|
|
5
|
+
throw new InternalHttpError(HTTP_CODE_BAD_REQUEST);
|
|
6
|
+
}
|
|
7
|
+
const sortType = query.sortType === "asc" ? "asc" : "desc";
|
|
8
|
+
const sortColumn = query.sortColumn;
|
|
9
|
+
return {
|
|
10
|
+
sortType,
|
|
11
|
+
sortColumn
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function getValidatedPagination(query) {
|
|
15
|
+
const perPage = Number(query.perPage);
|
|
16
|
+
if (!Number.isInteger(perPage) || perPage < 1 || perPage > 100) {
|
|
17
|
+
throw new InternalHttpError(HTTP_CODE_BAD_REQUEST);
|
|
18
|
+
}
|
|
19
|
+
const page = Number(query.page) || 1;
|
|
20
|
+
const pageOffset = (page - 1) * perPage;
|
|
21
|
+
return {
|
|
22
|
+
page,
|
|
23
|
+
perPage,
|
|
24
|
+
pageOffset
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
export * from '../components/AutocompleteSelect.vue';
|
|
1
2
|
export * from '../components/ButtonClear.vue';
|
|
3
|
+
export * from '../components/ButtonCopy.vue';
|
|
4
|
+
export * from '../components/ButtonDelete.vue';
|
|
5
|
+
export * from '../components/FormPanel.vue';
|
|
6
|
+
export * from '../components/FormPanelAsideSection.vue';
|
|
7
|
+
export * from '../components/FormPanelSection.vue';
|
|
8
|
+
export * from '../components/InputSeo.vue';
|
|
9
|
+
export * from '../components/InputSlug.vue';
|
|
10
|
+
export * from '../components/ModalConfirm.vue';
|
|
11
|
+
export * from '../components/TableCellPreview.vue';
|
|
12
|
+
export * from '../components/TableCellSeo.vue';
|
|
13
|
+
export * from '../components/TableCellUser.vue';
|
|
14
|
+
export * from '../components/TablePanel.vue';
|
|
15
|
+
export * from '../components/TablePanelColumnSorting.vue';
|
|
16
|
+
export * from '../components/TablePanelColumnVisibility.vue';
|
|
17
|
+
export * from '../components/TablePanelFilters.vue';
|
|
2
18
|
export * from '../components/UploraImage.vue';
|
|
3
19
|
export * from './image';
|
|
20
|
+
export * from './query';
|
|
4
21
|
export * from './seo';
|
|
5
22
|
export * from './utils';
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
export * from "../components/AutocompleteSelect.vue";
|
|
1
2
|
export * from "../components/ButtonClear.vue";
|
|
3
|
+
export * from "../components/ButtonCopy.vue";
|
|
4
|
+
export * from "../components/ButtonDelete.vue";
|
|
5
|
+
export * from "../components/FormPanel.vue";
|
|
6
|
+
export * from "../components/FormPanelAsideSection.vue";
|
|
7
|
+
export * from "../components/FormPanelSection.vue";
|
|
8
|
+
export * from "../components/InputSeo.vue";
|
|
9
|
+
export * from "../components/InputSlug.vue";
|
|
10
|
+
export * from "../components/ModalConfirm.vue";
|
|
11
|
+
export * from "../components/TableCellPreview.vue";
|
|
12
|
+
export * from "../components/TableCellSeo.vue";
|
|
13
|
+
export * from "../components/TableCellUser.vue";
|
|
14
|
+
export * from "../components/TablePanel.vue";
|
|
15
|
+
export * from "../components/TablePanelColumnSorting.vue";
|
|
16
|
+
export * from "../components/TablePanelColumnVisibility.vue";
|
|
17
|
+
export * from "../components/TablePanelFilters.vue";
|
|
2
18
|
export * from "../components/UploraImage.vue";
|
|
3
19
|
export * from "./image.js";
|
|
20
|
+
export * from "./query.js";
|
|
4
21
|
export * from "./seo.js";
|
|
5
22
|
export * from "./utils.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SortQueryRaw {
|
|
2
|
+
sortColumn?: string;
|
|
3
|
+
sortType?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SortQuery<K = string> {
|
|
6
|
+
sortColumn: K;
|
|
7
|
+
sortType: 'asc' | 'desc';
|
|
8
|
+
}
|
|
9
|
+
export interface Pagination {
|
|
10
|
+
total: number;
|
|
11
|
+
}
|
|
12
|
+
export interface PaginationQueryRaw {
|
|
13
|
+
page?: string;
|
|
14
|
+
perPage?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PaginationQuery {
|
|
17
|
+
page: number;
|
|
18
|
+
perPage: number;
|
|
19
|
+
}
|
|
20
|
+
export type PaginationQueryValidated = PaginationQuery & {
|
|
21
|
+
pageOffset: number;
|
|
22
|
+
};
|
|
File without changes
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { AcceptableValue as _AcceptableValue } from 'reka-ui';
|
|
2
|
-
export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>>;
|
|
3
2
|
export * from './tv';
|
|
3
|
+
export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>>;
|
|
4
|
+
export type KeysMatching<T, V> = {
|
|
5
|
+
[K in keyof T]: T[K] extends V ? K : never;
|
|
6
|
+
}[keyof T];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAvatarByName(name?: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { initials } from "@dicebear/collection";
|
|
2
|
+
import { createAvatar } from "@dicebear/core";
|
|
3
|
+
export function createAvatarByName(name = "Anonymous") {
|
|
4
|
+
const avatar = createAvatar(initials, {
|
|
5
|
+
seed: name,
|
|
6
|
+
backgroundType: ["gradientLinear"]
|
|
7
|
+
});
|
|
8
|
+
return avatar.toDataUri();
|
|
9
|
+
}
|
|
@@ -3,7 +3,7 @@ import { imagesExtensionsToMimeTypes } from "@uplora/formats";
|
|
|
3
3
|
import { serialize } from "@uplora/serializer";
|
|
4
4
|
export function createUploraImageResolver() {
|
|
5
5
|
const runtimeConfig = useRuntimeConfig();
|
|
6
|
-
const { fluxorUrl } = runtimeConfig.public
|
|
6
|
+
const { fluxorUrl } = runtimeConfig.public;
|
|
7
7
|
return (id, filters) => {
|
|
8
8
|
const serializeFilters = filters ? serialize(filters) : "";
|
|
9
9
|
return `${fluxorUrl}/${id}${serializeFilters ? `/${serializeFilters}` : ""}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function slugify(text?: string): string;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
2
4
|
|
|
3
|
-
export
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
|
4
8
|
|
|
5
9
|
export * from '../dist/runtime/types/index.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hywax/cms",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
"dist"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@
|
|
58
|
+
"@dicebear/collection": "^9.2.2",
|
|
59
|
+
"@dicebear/core": "^9.2.2",
|
|
60
|
+
"@iconify-json/lucide": "1.2.51",
|
|
59
61
|
"@nuxt/kit": "^3.17.5",
|
|
60
62
|
"@nuxt/ui-pro": "^3.1.3",
|
|
61
63
|
"@nuxtjs/mdc": "^0.17.0",
|
|
@@ -65,18 +67,21 @@
|
|
|
65
67
|
"@vueuse/nuxt": "^13.4.0",
|
|
66
68
|
"defu": "^6.1.4",
|
|
67
69
|
"nuxt-auth-utils": "^0.5.20",
|
|
70
|
+
"pathe": "^2.0.3",
|
|
68
71
|
"prosekit": "^0.13.6",
|
|
72
|
+
"scule": "^1.3.0",
|
|
73
|
+
"slugify": "^1.6.6",
|
|
69
74
|
"zod": "^3.25.67"
|
|
70
75
|
},
|
|
71
76
|
"devDependencies": {
|
|
72
|
-
"@antfu/eslint-config": "^4.
|
|
77
|
+
"@antfu/eslint-config": "^4.15.0",
|
|
73
78
|
"@commitlint/cli": "^19.8.1",
|
|
74
79
|
"@commitlint/config-conventional": "^19.8.1",
|
|
75
80
|
"@nuxt/devtools": "^2.5.0",
|
|
76
81
|
"@nuxt/module-builder": "^1.0.1",
|
|
77
82
|
"@nuxt/schema": "^3.17.5",
|
|
78
83
|
"@nuxt/test-utils": "^3.19.1",
|
|
79
|
-
"@types/node": "^22.
|
|
84
|
+
"@types/node": "^22.15.32",
|
|
80
85
|
"@vue/test-utils": "^2.4.6",
|
|
81
86
|
"changelogen": "^0.6.1",
|
|
82
87
|
"eslint": "^9.29.0",
|
|
@@ -85,7 +90,7 @@
|
|
|
85
90
|
"lint-staged": "^16.1.2",
|
|
86
91
|
"nuxt": "^3.17.5",
|
|
87
92
|
"typescript": "^5.8.3",
|
|
88
|
-
"vitest": "^3.2.
|
|
93
|
+
"vitest": "^3.2.4",
|
|
89
94
|
"vue-tsc": "^2.2.10"
|
|
90
95
|
},
|
|
91
96
|
"resolutions": {
|
|
@@ -102,13 +107,13 @@
|
|
|
102
107
|
"scripts": {
|
|
103
108
|
"release": "pnpm run build && changelogen --release --push && pnpm publish --access public",
|
|
104
109
|
"build": "nuxt-module-build build",
|
|
105
|
-
"build:
|
|
110
|
+
"build:playground": "nuxi build playground",
|
|
106
111
|
"dev": "npm run dev:prepare && nuxi dev playground",
|
|
107
112
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
108
113
|
"lint": "eslint .",
|
|
109
114
|
"lint:fix": "eslint --fix .",
|
|
110
115
|
"test": "vitest run",
|
|
111
116
|
"test:watch": "vitest watch",
|
|
112
|
-
"typecheck": "vue-tsc --noEmit"
|
|
117
|
+
"typecheck": "vue-tsc --noEmit && nuxt typecheck playground"
|
|
113
118
|
}
|
|
114
119
|
}
|