@opengis/cms 0.0.3 → 0.0.4

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.
Files changed (144) hide show
  1. package/dist/cms.js +5900 -0
  2. package/dist/cms.umd.cjs +19 -0
  3. package/package.json +4 -1
  4. package/.gitlab-ci.yml +0 -36
  5. package/config.example +0 -21
  6. package/docs/.vitepress/abbr.mjs +0 -26
  7. package/docs/.vitepress/config.mjs +0 -119
  8. package/docs/.vitepress/navigation.mjs +0 -82
  9. package/docs/.vitepress/theme/Layout.vue +0 -17
  10. package/docs/.vitepress/theme/components/NavigationLinks.vue +0 -102
  11. package/docs/.vitepress/theme/components/Panzoom.vue +0 -169
  12. package/docs/.vitepress/theme/index.mjs +0 -15
  13. package/docs/.vitepress/theme/style.scss +0 -136
  14. package/docs/abbr.json +0 -4
  15. package/docs/api/builder/cms.builder.delete.md +0 -65
  16. package/docs/api/builder/cms.builder.get.md +0 -70
  17. package/docs/api/builder/cms.builder.list.md +0 -98
  18. package/docs/api/builder/cms.builder.post.md +0 -72
  19. package/docs/api/builder/cms.builder.put.md +0 -88
  20. package/docs/api/category/cms.category.delete.md +0 -60
  21. package/docs/api/category/cms.category.get.md +0 -61
  22. package/docs/api/category/cms.category.list.md +0 -77
  23. package/docs/api/category/cms.category.post.md +0 -62
  24. package/docs/api/category/cms.category.put.md +0 -78
  25. package/docs/api/index.md +0 -50
  26. package/docs/api/manager/cms.manager.delete.md +0 -64
  27. package/docs/api/manager/cms.manager.get.md +0 -72
  28. package/docs/api/manager/cms.manager.list.md +0 -96
  29. package/docs/api/manager/cms.manager.post.md +0 -70
  30. package/docs/api/manager/cms.manager.put.md +0 -86
  31. package/docs/api/media/del.md +0 -64
  32. package/docs/api/media/edit.md +0 -92
  33. package/docs/api/media/list.md +0 -70
  34. package/docs/api/media/metadata.md +0 -57
  35. package/docs/api/media/preview.md +0 -33
  36. package/docs/api/media/upload.md +0 -84
  37. package/docs/db/erd.md +0 -173
  38. package/docs/db/index.md +0 -7
  39. package/docs/index.md +0 -39
  40. package/docs/public/logo-dark.svg +0 -24
  41. package/docs/public/logo-light.svg +0 -24
  42. package/docs/public/logo-short.svg +0 -15
  43. package/docs/public/logo.svg +0 -19
  44. package/docs/readme/index.md +0 -6
  45. package/docs/src/vs-button.vue +0 -157
  46. package/docs/vue/basic/button.md +0 -144
  47. package/docs/vue/index.md +0 -9
  48. package/index.html +0 -14
  49. package/server/app.js +0 -25
  50. package/server/config.js +0 -5
  51. package/server/index.js +0 -23
  52. package/server/migrations/media.sql +0 -30
  53. package/server/plugins/hook.js +0 -91
  54. package/server/plugins/vite.js +0 -80
  55. package/server/routes/builder/controllers/cms.builder.delete.js +0 -21
  56. package/server/routes/builder/controllers/cms.builder.get.js +0 -17
  57. package/server/routes/builder/controllers/cms.builder.list.js +0 -16
  58. package/server/routes/builder/controllers/cms.builder.post.js +0 -21
  59. package/server/routes/builder/controllers/cms.builder.put.js +0 -23
  60. package/server/routes/builder/index.mjs +0 -22
  61. package/server/routes/category/controllers/cms.category.delete.js +0 -21
  62. package/server/routes/category/controllers/cms.category.get.js +0 -17
  63. package/server/routes/category/controllers/cms.category.list.js +0 -16
  64. package/server/routes/category/controllers/cms.category.post.js +0 -21
  65. package/server/routes/category/controllers/cms.category.put.js +0 -23
  66. package/server/routes/category/index.mjs +0 -22
  67. package/server/routes/manager/controllers/cms.manager.delete.js +0 -22
  68. package/server/routes/manager/controllers/cms.manager.get.js +0 -21
  69. package/server/routes/manager/controllers/cms.manager.list.js +0 -31
  70. package/server/routes/manager/controllers/cms.manager.post.js +0 -28
  71. package/server/routes/manager/controllers/cms.manager.put.js +0 -23
  72. package/server/routes/manager/index.mjs +0 -22
  73. package/server/routes/media/controllers/delete.js +0 -59
  74. package/server/routes/media/controllers/edit.js +0 -94
  75. package/server/routes/media/controllers/list.js +0 -74
  76. package/server/routes/media/controllers/metadata.js +0 -51
  77. package/server/routes/media/controllers/preview.js +0 -47
  78. package/server/routes/media/controllers/upload.js +0 -79
  79. package/server/routes/media/index.mjs +0 -16
  80. package/server/routes/root.mjs +0 -15
  81. package/server/templates/cls/cms.category_type.json +0 -10
  82. package/server/templates/cls/cms.content_review_status.json +0 -10
  83. package/server/templates/cls/cms.content_status.json +0 -10
  84. package/server/templates/cls/cms.content_type.json +0 -10
  85. package/server/templates/cls/cms.lang.json +0 -10
  86. package/server/templates/page/login.html +0 -59
  87. package/server/templates/select/cms.category_id.sql +0 -1
  88. package/server/templates/select/cms.type_id.sql +0 -1
  89. package/src/App.vue +0 -4
  90. package/src/assets/tailwind/tailwind.js +0 -62
  91. package/src/assets/vue.svg +0 -1
  92. package/src/components/builder/vs-builder-content.vue +0 -163
  93. package/src/components/builder/vs-builder-menu.vue +0 -142
  94. package/src/components/formats/index.js +0 -8
  95. package/src/components/formats/vs-manager-table-date.vue +0 -29
  96. package/src/components/formats/vs-manager-table-switch.vue +0 -16
  97. package/src/components/icons/icon-actions.vue +0 -24
  98. package/src/components/icons/icon-arrow-left.vue +0 -19
  99. package/src/components/icons/icon-check.vue +0 -23
  100. package/src/components/icons/icon-chewron-right.vue +0 -16
  101. package/src/components/icons/icon-close.vue +0 -22
  102. package/src/components/icons/icon-edit.vue +0 -22
  103. package/src/components/icons/icon-folder.vue +0 -18
  104. package/src/components/icons/icon-folder2.vue +0 -17
  105. package/src/components/icons/icon-home.vue +0 -16
  106. package/src/components/icons/icon-image.vue +0 -18
  107. package/src/components/icons/icon-logo.vue +0 -22
  108. package/src/components/icons/icon-media.vue +0 -22
  109. package/src/components/icons/icon-point.vue +0 -11
  110. package/src/components/icons/icon-search.vue +0 -22
  111. package/src/components/icons/icon-table.vue +0 -22
  112. package/src/components/icons/icon-users.vue +0 -18
  113. package/src/components/icons/icon.plus.vue +0 -18
  114. package/src/components/manager/children/vs-manager-collection-content.vue +0 -55
  115. package/src/components/manager/children/vs-manager-collection-item-content.vue +0 -116
  116. package/src/components/manager/children/vs-manager-single-content.vue +0 -112
  117. package/src/components/manager/manager-table/vs-manager-colection-table-add.vue +0 -84
  118. package/src/components/manager/manager-table/vs-manager-collection-table.vue +0 -59
  119. package/src/components/manager/vs-manager-menu.vue +0 -73
  120. package/src/components/media/Breadcrumb.vue +0 -73
  121. package/src/components/shared-components/vs-not-data.vue +0 -213
  122. package/src/components/vs-main-menu.vue +0 -53
  123. package/src/helpers/debounce.js +0 -10
  124. package/src/helpers/translite.js +0 -19
  125. package/src/main.js +0 -30
  126. package/src/misc/import-file.js +0 -32
  127. package/src/pages/vs-builder.vue +0 -22
  128. package/src/pages/vs-layout.vue +0 -17
  129. package/src/pages/vs-manager.vue +0 -30
  130. package/src/pages/vs-media.vue +0 -398
  131. package/src/router/router.js +0 -9
  132. package/src/router/routes.config.js +0 -40
  133. package/src/style.css +0 -0
  134. package/src/templates/form-columns.js +0 -70
  135. package/src/templates/form-template.js +0 -22
  136. package/test/config.js +0 -17
  137. package/test/files/eye.svg +0 -4
  138. package/test/helper.js +0 -30
  139. package/test/routes/builder.test.js +0 -99
  140. package/test/routes/category.test.js +0 -97
  141. package/test/routes/manager.test.js +0 -103
  142. package/test/routes/media.test.js +0 -252
  143. package/vite.config.js +0 -37
  144. /package/{public → dist}/vite.svg +0 -0
@@ -1,157 +0,0 @@
1
- <template>
2
- <button
3
- type="button"
4
- class="vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all"
5
- :class="{
6
- ...buttonData.params,
7
- [size === 'mini'
8
- ? 'py-1 px-3'
9
- : size === 'large'
10
- ? 'py-3 px-7'
11
- : 'py-1.5 px-5']: true,
12
- [disabled
13
- ? 'disabled opacity-50 focus:ring-0 focus:ring-offset-0 cursor-not-allowed'
14
- : 'focus:ring-2 focus:ring-offset-2']: true,
15
- ['!px-2 !py-2 !rounded-full']: circle,
16
- ['!px-2 !py-2 !rounded-md']: square,
17
- }"
18
- >
19
- <slot>{{title}}</slot>
20
- <i
21
- v-if="icon"
22
- :class="'ti ' + icon"
23
- class="pointer-events-none"
24
- />
25
- <div
26
- v-if="loading"
27
- role="status"
28
- >
29
- <svg
30
- aria-hidden="true"
31
- class="inline w-4 h-4 text-gray-200 animate-spin fill-blue-600"
32
- viewBox="0 0 100 101"
33
- fill="none"
34
- xmlns="http://www.w3.org/2000/svg"
35
- >
36
- <path
37
- d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
38
- fill="currentColor"
39
- />
40
- <path
41
- d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
42
- fill="currentFill"
43
- />
44
- </svg>
45
- </div>
46
- </button>
47
- </template>
48
- <script lang="ts">
49
-
50
- interface IButtonClass {
51
- [key: string]: {
52
- params: object
53
- }
54
- }
55
-
56
- interface IButtonData {
57
- buttonClass: IButtonClass
58
- }
59
-
60
- export default {
61
- props: {
62
- type: { type: String, default: () => '' },
63
- title: { type: String, default: () => '' },
64
- color: { type: String, default: 'blue' },
65
- size: { type: String, default: () => '' },
66
- disabled: { type: Boolean, default: false },
67
- loading: { type: Boolean, default: false },
68
- icon: { type: String, default: () => '' },
69
- circle: Boolean,
70
- square: Boolean,
71
- },
72
- data() {
73
- return {
74
- buttonClass: {},
75
- } as IButtonData;
76
- },
77
- computed: {
78
- // Return button class by type in props
79
- buttonData() {
80
- return this.buttonClass?.[this.type] || this.buttonClass.default;
81
- },
82
- },
83
- watch: {
84
- color: {
85
- immediate: true,
86
- // Here is all aviable types with theirs styles
87
- handler(newColor) {
88
- this.buttonClass = {
89
- primary: {
90
- params: {
91
- 'border-1 border-transparent text-white': true,
92
- [`bg-${newColor}-500`]: true,
93
- [`hover:bg-${newColor}-600`]: true,
94
- [`focus:ring-${newColor}-500`]: true,
95
- },
96
- },
97
- text: {
98
- params: {
99
- 'border border-transparent': true,
100
- [`text-${newColor}-500`]: true,
101
- [`hover:bg-${newColor}-100`]: true,
102
- [`focus:ring-${newColor}-500`]: true,
103
- },
104
- },
105
- plain: {
106
- params: {
107
- 'border border-transparent hover:text-white ring-offset-white': true,
108
- [`bg-${newColor}-100`]: true,
109
- [`text-${newColor}-500`]: true,
110
- [`hover:bg-${newColor}-500`]: true,
111
- [`focus:ring-${newColor}-500`]: true,
112
- },
113
- },
114
- border: {
115
- params: {
116
- 'border font-medium bg-white shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white': true,
117
- [`text-${newColor}-700`]: true,
118
- [`focus:ring-${newColor}-600`]: true,
119
- },
120
- },
121
- link: {
122
- params: {
123
- 'border border-transparent ring-offset-white': true,
124
- [`text-${newColor}-600`]: true,
125
- [`hover:text-${newColor}-700`]: true,
126
- [`focus:ring-${newColor}-600`]: true,
127
- },
128
- },
129
- default: {
130
- params: {
131
- 'border !border-gray-200 hover:text-white bg-white': true,
132
- [`text-${newColor}-500`]: true,
133
- [`hover:border-${newColor}-500`]: true,
134
- [`hover:bg-${newColor}-500`]: true,
135
- [`focus:ring-${newColor}-500`]: true,
136
- },
137
- },
138
- };
139
- },
140
- },
141
- },
142
- };
143
- </script>
144
- <style lang="scss" scoped>
145
- .vs-button {
146
- width: fit-content;
147
- &:active {
148
- opacity: 0.8;
149
- }
150
-
151
- &.disabled {
152
- &:active {
153
- opacity: 0.5;
154
- }
155
- }
156
- }
157
- </style>
@@ -1,144 +0,0 @@
1
- <script setup>
2
- import VsButton from '../../src/vs-button.vue'
3
- </script>
4
-
5
- # VsButton
6
-
7
- Часто використовувана кнопка.
8
-
9
- ## Підключення
10
-
11
- ```html title='vue'
12
- <VsButton title="Default" />
13
- ```
14
-
15
- <div class="flex mt-2">
16
- <VsButton class="mr-2" title="Default" />
17
- </div>
18
-
19
- ## Component API
20
-
21
- ::: tabs
22
-
23
- == Style
24
-
25
- | Name | Description | Type |
26
- | :-----: | :-------------------------------------------------------------------------------: | :------: |
27
- | `size` | Розмір кнопки (mini, small, large) | `String` |
28
- | `color` | Колір кнопки. [Доступні кольори](https://tailwindcss.com/docs/customizing-colors) | `String` |
29
- | `type` | Тип кнопки (primary, text, plain, border, link, default) | `String` |
30
-
31
- == State
32
-
33
- | Name | Description | Type |
34
- | :--------: | :------------------------------------------: | :-------: |
35
- | `disabled` | Визначає, чи кнопка вимкнена | `Boolean` |
36
- | `loading` | Анімація індикатора загрузки поруч з текстом | `Boolean` |
37
-
38
- == Content
39
-
40
- | Name | Description | Type |
41
- | :----: | :---------------------------: | :------: |
42
- | `icon` | Іконка поруч з текстом кнопки | `String` |
43
-
44
- == Events
45
-
46
- | Name | Description |
47
- | :------: | :-------------------------: |
48
- | `@onClick` | Реалізує клік по компоненту |
49
-
50
- == Slots
51
-
52
- | Name | Description | Default |
53
- | :-------: | :----------------------------------------------------------: | :------------------------- |
54
- | `default` | Дефолтний слот, зазвичай у кнопку вставляється текст, іконка | `<template>...</template>` |
55
-
56
- :::
57
-
58
- ## Приклади
59
-
60
- ### Базове використання (тип кнопки)
61
-
62
- Використовуйте типи `default`, `primary`, `plain` `border`, `text`, `link` щоб визначити стиль кнопки.
63
-
64
- ```html title='vue'
65
- <VsButton title="Default" />
66
- <VsButton title="Primary" type="primary"/>
67
- <VsButton title="Plain" type="plain"/>
68
- <VsButton title="Border" type="border"/>
69
- <VsButton title="Link" type="link"/>
70
- <VsButton title="Text" type="text"/>
71
- ```
72
-
73
- <div class="flex mt-2">
74
- <VsButton class="mr-2" title="Default" />
75
- <VsButton class="mr-2" title="Primary" type="primary"/>
76
- <VsButton class="mr-2" title="Plain" type="plain"/>
77
- <VsButton class="mr-2" title="Border" type="border"/>
78
- <VsButton class="mr-2" title="Link" type="link"/>
79
- <VsButton title="Text" type="text"/>
80
- </div>
81
-
82
- ### Розміри
83
-
84
- Окрім розміру за замовчуванням (`default`), компонент надає два додаткові розміри для вибору з різних сценаріїв.
85
- Використовуйте розмір атрибута, щоб установити додаткові розміри (`large`, `mini`).
86
-
87
- <!-- <VueExample title="VsButton" >
88
- { `
89
- <VsButton type="primary" size="mini">Primary</VsButton>
90
- <VsButton type="primary" size="default">Primary</VsButton>
91
- <VsButton type="primary" size="large">Primary</VsButton>
92
- ` }
93
- </VueExample> -->
94
-
95
- ```html title='vue'
96
- <VsButton title="Mini" size="mini" type="primary"/>
97
- <VsButton title="Default" size="default" type="primary"/>
98
- <VsButton title="Large" size="large" type="primary"/>
99
- ```
100
-
101
- <div class="flex mt-2 items-center">
102
- <VsButton class="mr-2" title="Mini" size="mini" type="primary"/>
103
- <VsButton class="mr-2" title="Default" size="default" type="primary"/>
104
- <VsButton class="mr-2" title="Large" size="large" type="primary"/>
105
- </div>
106
-
107
- ### Вимкнення кнопки
108
-
109
- Атрибут `disabled` визначає, чи кнопка вимкнена.
110
- Використовуйте атрибут `disabled`, щоб визначити, чи кнопка вимкнена. Він приймає логічне значення.
111
-
112
- ```html title='vue'
113
- <VsButton title="Mini" size="mini" type="primary"/>
114
- <VsButton title="Default" size="default" type="primary"/>
115
- <VsButton title="Large" size="large" type="primary"/>
116
- ```
117
-
118
- <div class="flex mt-2 items-center">
119
- <VsButton class="mr-2" disabled title="Mini" type="primary"/>
120
- <VsButton class="mr-2" disabled title="Default" type="primary"/>
121
- <VsButton class="mr-2" disabled title="Large" type="primary"/>
122
- </div>
123
-
124
- ### Завантаження
125
-
126
- Відображає анімацію в кнопці під час завантаження даних.
127
-
128
- ```html title='vue'
129
- <VsButton type="default" color="rose" :loading="true">Default</VsButton>
130
- ```
131
-
132
- <div class="flex mt-2 items-center">
133
- <VsButton type="default" color="rose" :loading="true">Default</VsButton>
134
- </div>
135
-
136
- ### Іконка
137
-
138
- Використовуйте іконки, щоб додати більше значення кнопці. Ви можете використовувати лише значок, щоб заощадити місце, або використовувати його з текстом.
139
- Використовуйте атрибут `icon` у якості слота або пропса, щоб додати іконку. Ви можете знайти список значків на сайті [Tabler]("https://tabler.io/icons").
140
-
141
- <VsButton
142
- type="primary"
143
- icon="ti ti-search"
144
- />
package/docs/vue/index.md DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- order: 0
3
- ---
4
-
5
- # Список компонентів
6
-
7
- ## Basic
8
-
9
- - [Button](basic/button) - Кнопка з різноманітними стилями та можливостями кастомізації.
package/index.html DELETED
@@ -1,14 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>User Profile</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <div id="modal"></div>
12
- <script type="module" src="/src/main.js"></script>
13
- </body>
14
- </html>
package/server/app.js DELETED
@@ -1,25 +0,0 @@
1
- import path from 'node:path';
2
- import { config, execMigrations } from '@opengis/fastify-table/utils.js';
3
-
4
- config.prefix = config.prefix || '/api';
5
- const { prefix } = config;
6
-
7
- const cwd = process.cwd();
8
-
9
- export default async function (fastify) {
10
- // core
11
- fastify.register(import('./plugins/hook.js'));
12
-
13
- fastify.register(import('@opengis/fastify-table'), config);
14
- fastify.register(import('@opengis/fastify-auth'), config);
15
- fastify.register(import('@opengis/fastify-file'), config);
16
-
17
- fastify.register(import('./plugins/vite.js'));
18
- // API
19
- fastify.register(import('./routes/root.mjs'));
20
- fastify.register(import('./routes/builder/index.mjs'), { prefix });
21
- fastify.register(import('./routes/category/index.mjs'), { prefix });
22
- fastify.register(import('./routes/manager/index.mjs'), { prefix });
23
- fastify.register(import('./routes/media/index.mjs'), { prefix });
24
- execMigrations(path.join(cwd, 'server/migrations')).catch(err => console.log(err));
25
- }
package/server/config.js DELETED
@@ -1,5 +0,0 @@
1
- import { readFile } from 'fs/promises';
2
- import fs from 'fs';
3
- const config = fs.existsSync('config.json') ? JSON.parse(await readFile('config.json')) : {};
4
-
5
- export default config;
package/server/index.js DELETED
@@ -1,23 +0,0 @@
1
- import Fastify from 'fastify';
2
-
3
-
4
- import appService from './app.js';
5
- import config from './config.js';
6
-
7
- const isProduction = process.env.NODE_ENV === 'production';
8
-
9
- // Instantiate Fastify with some config
10
- const app = Fastify({ logger: !isProduction });
11
-
12
- // Register your application as a normal plugin.
13
-
14
- app.register(appService);
15
-
16
- process.env.PORT = process.env.PORT || config.port || 3000;
17
- // Start listening.
18
- app.listen({ host: '0.0.0.0', port: process.env.PORT }, (err) => {
19
- if (err) {
20
- app.log.error(err);
21
- process.exit(1);
22
- }
23
- });
@@ -1,30 +0,0 @@
1
- create schema if not exists crm;
2
- create table if not exists crm.media();
3
-
4
- CREATE TABLE IF NOT EXISTS crm.media();
5
- ALTER TABLE crm.media DROP CONSTRAINT IF EXISTS crm_media_id_pkey;
6
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS media_id text NOT NULL DEFAULT next_id();
7
-
8
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS uploaded_name text;
9
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS file_path text;
10
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS caption text;
11
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS altname text;
12
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS size numeric;
13
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS ext text;
14
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS tags text[];
15
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS uid text;
16
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS files json;
17
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
18
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS editor_id text;
19
- ALTER TABLE crm.media ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
20
- ALTER TABLE crm.media ADD CONSTRAINT crm_media_id_pkey PRIMARY KEY (media_id);
21
-
22
- comment on table crm.media is 'Медіа файли';
23
-
24
- comment on column crm.media.uploaded_name is 'Назва файлу';
25
- comment on column crm.media.file_path is 'Відносний шлях до файлу';
26
- comment on column crm.media.caption is 'Заголовок';
27
- comment on column crm.media.altname is 'Альтернативна назва';
28
- comment on column crm.media.size is 'Розмір файлу';
29
- comment on column crm.media.ext is 'Розширення файлу';
30
- comment on column crm.media.tags is 'Теги файлу';
@@ -1,91 +0,0 @@
1
- import fp from 'fastify-plugin';
2
- import fs from 'fs';
3
- import config from '../config.js';
4
-
5
- // the use of fastify-plugin is required to be able
6
- // to export the decorators to the outer scope
7
-
8
- async function plugin(fastify) {
9
- fastify.decorate('config', config);
10
-
11
- // pre Request
12
- fastify.addHook('onRequest', async (req) => {
13
- req.funcs = fastify;
14
- const { user } = req.session?.passport || {};
15
- req.user = user;
16
- });
17
-
18
- // preSerialization
19
- fastify.addHook('preSerialization', async (req, reply, payload) => {
20
- if (req.url.includes('/suggest/') && !req.query.json) {
21
- return payload?.data;
22
- }
23
- /* if (payload.redirect) {
24
- return reply.redirect(payload.redirect);
25
- }*/
26
- if (reply.sent) {
27
- return null;
28
- }
29
- if (!payload) {
30
- return payload;
31
- }
32
-
33
- if (['200', '400', '500', '403', '404'].includes(payload.status)) {
34
- reply.status(payload.status);
35
- }
36
- /* if (payload.headers) {
37
- reply.headers(payload.headers);
38
- } */
39
- if (payload.buffer) {
40
- return payload.buffer;
41
- }
42
- if (payload.file) {
43
- // const buffer = await readFile(payload.file);
44
- // return reply.send(buffer);
45
- const stream = fs.createReadStream(payload.file);
46
- return stream;
47
- // return reply.send(stream);
48
- }
49
-
50
- if (payload.message) {
51
- return payload.message;
52
- }
53
- return payload;
54
- });
55
-
56
- // preValidation
57
- fastify.addHook('preValidation', async (req) => {
58
- const parseRawBody = ['POST', 'PUT'].includes(req.method) && req.body && typeof req.body === 'string'
59
- && req.body.trim(/\r\n/g).startsWith('{')
60
- && req.body.trim(/\r\n/g).endsWith('}');
61
- if (parseRawBody) {
62
- try {
63
- req.body = JSON.parse(req.body || '{}');
64
- }
65
- catch (err) {
66
- // throw new Error('invalid body');
67
- // return { error: 'invalid body', status: 400 };
68
- }
69
- }
70
- });
71
-
72
- // allow upload file
73
- const kIsMultipart = Symbol.for('[FastifyMultipart.isMultipart]');
74
- fastify.addContentTypeParser('multipart', (request, _, done) => {
75
- request[kIsMultipart] = true;
76
- done(null);
77
- });
78
-
79
- // parse Body
80
- function contentParser(req, body, done) {
81
- const parseBody = decodeURIComponent(body.toString()).split('&').reduce((acc, el) => {
82
- const [key, val] = el.split('=');
83
- return { ...acc, [key]: val };
84
- }, {});
85
- done(null, parseBody);
86
- }
87
-
88
- fastify.addContentTypeParser('application/x-www-form-urlencoded', { parseAs: 'buffer' }, contentParser);
89
- }
90
-
91
- export default fp(plugin);
@@ -1,80 +0,0 @@
1
- import fs from 'fs';
2
- import path, { dirname } from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const dir = dirname(fileURLToPath(import.meta.url));
6
- const root = `${dir}/../..`;
7
- import config from '../config.js';
8
-
9
- const isProduction = process.env.NODE_ENV === 'production' || config.production;
10
-
11
- async function plugin(fastify) {
12
- // vite server
13
- if (!isProduction) {
14
- const vite = await import('vite');
15
-
16
- const viteServer = await vite.createServer({
17
- root: `${root}`,
18
- server: {
19
- middlewareMode: true,
20
- },
21
- });
22
-
23
- // add root to watch
24
- viteServer.watcher.add(root);
25
-
26
- // hot relaod template
27
- viteServer.watcher.on('all', (d, t) => {
28
- if (!t.includes('module')) return;
29
- console.log(d, t);
30
- viteServer.ws.send({ type: 'full-reload' });
31
- });
32
-
33
- // this is middleware for vite's dev servert
34
- fastify.addHook('onRequest', async (req, reply) => {
35
- const { user } = req.session?.passport || {};
36
- const { disableAuth } = req.funcs?.config || {};
37
- if (!user && !disableAuth) {
38
- return reply.redirect('/login');
39
- }
40
-
41
- const next = () => new Promise((resolve) => {
42
- viteServer.middlewares(req.raw, reply.raw, () => resolve());
43
- });
44
- await next();
45
- });
46
- fastify.get('*', async () => { });
47
- return;
48
- }
49
-
50
- // From Build
51
- fastify.get('*', async (req, reply) => {
52
- const { user } = req.session?.passport || {};
53
- const assetsDir = '/dist';
54
- if (!user) return reply.redirect('/login');
55
- const stream = fs.createReadStream(`${assetsDir}/index.html`);
56
- return reply.type('text/html').send(stream);
57
- });
58
-
59
- const fileSize = {};
60
- async function staticFile(req, reply) {
61
- const assetsDir = '/dist';
62
- const filePath = path.join(root, assetsDir, req.url);
63
- const ext = path.extname(filePath);
64
-
65
- if (!fs.existsSync(filePath)) return { status: 404, message: 'not found' };
66
- fileSize[filePath] = fileSize[filePath] || fs.statSync(filePath).size;
67
- const mime = {
68
- '.js': 'text/javascript', '.css': 'text/css', '.woff2': 'application/font-woff', '.png': 'image/png', '.svg': 'image/svg+xml', '.jpg': 'image/jpg',
69
- }[ext];
70
- reply.headers({ 'Cache-control': 'max-age=3600, public', 'Content-length': fileSize[filePath], 'Content-Encoding': 'identity' });
71
-
72
- const stream = fs.createReadStream(filePath);
73
- return mime ? reply.type(mime).send(stream) : stream;
74
- }
75
-
76
- fastify.get('/assets/*', staticFile);
77
- fastify.get('/public/*', staticFile);
78
- }
79
-
80
- export default plugin;
@@ -1,21 +0,0 @@
1
- import { dataDelete, getMeta } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function builderDelete({ user = {}, params = {} }) {
4
-
5
- if (!params.id) {
6
- return { message: 'id is required', status: 400 };
7
- }
8
- const { pk } = await getMeta({ table: 'site.content_types' });
9
-
10
- if (!pk) {
11
- return { message: 'table not found', status: 404 };
12
- }
13
-
14
- const res = await dataDelete({
15
- table: 'site.content_types',
16
- id: params.id,
17
- uid: user?.uid
18
- });
19
-
20
- return { id: res.content_id, rows: [res] };
21
- }
@@ -1,17 +0,0 @@
1
- import { pgClients, getMeta } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function builderGet({ pg = pgClients.client, params = {} }) {
4
-
5
-
6
- const { pk } = await getMeta({ table: 'site.content_types' });
7
-
8
- if (!pk) {
9
- return { message: 'table not found', status: 404 };
10
- }
11
-
12
- const { rows, rowCount: total } = await pg.query(
13
- `select a.content_type_id as id, a.* FROM site.content_types a
14
- where a.content_type_id=$1`, [params.id]
15
- );
16
- return { message: { total, rows }, status: 200 };
17
- }
@@ -1,16 +0,0 @@
1
- import { pgClients, getMeta } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function builderList({ pg = pgClients.client, query = {} }) {
4
-
5
- const { pk } = await getMeta({ table: 'site.content_types' });
6
-
7
- if (!pk) {
8
- return { message: 'table not found', status: 404 };
9
- }
10
- const sql = `select a.content_type_id as id, a.* FROM site.content_types a
11
- where ${query.content_type_id ? 'content_type_id=$1' : '1=1'}`
12
-
13
- const { rows, rowCount: total } = await pg.query(sql, [query.content_type_id].filter((el) => el));
14
-
15
- return { message: { total, rows }, status: 200 };
16
- }
@@ -1,21 +0,0 @@
1
- import { dataInsert, getMeta } from "@opengis/fastify-table/utils.js";
2
-
3
- export default async function builderPost(req) {
4
- const { user = {}, body = {} } = req;
5
-
6
- const { pk } = await getMeta({ table: "site.content_types" });
7
-
8
- if (!pk) {
9
- return { message: "table not found", status: 404 };
10
- }
11
-
12
- const resData = await dataInsert({
13
- table: "site.content_types",
14
- data: body,
15
- uid: user?.uid,
16
- });
17
- // console.log(resData);
18
- const res = resData?.rows[0];
19
-
20
- return { id: res.content_type_id, rows: [res] };
21
- }