@alstar/studio 0.0.0-beta.5 → 0.0.0-beta.6
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/api/api-key.ts +74 -0
- package/api/block.ts +21 -29
- package/api/index.ts +9 -1
- package/api/mcp.ts +53 -0
- package/bin/alstar.ts +42 -0
- package/components/{AdminPanel/AdminPanel.ts → AdminPanel.ts} +22 -27
- package/components/Block.ts +51 -112
- package/components/Entries.ts +3 -3
- package/components/Entry.ts +9 -15
- package/components/Settings.ts +98 -0
- package/components/fields/Blocks.ts +118 -0
- package/components/fields/Text.ts +42 -0
- package/components/fields/index.ts +4 -0
- package/components/icons.ts +59 -0
- package/components/index.ts +1 -1
- package/components/layout.ts +2 -2
- package/index.ts +33 -14
- package/package.json +4 -3
- package/public/admin-panel.css +90 -0
- package/public/blocks.css +53 -0
- package/public/main.css +8 -0
- package/public/main.js +4 -0
- package/public/settings.css +24 -0
- package/queries/block-with-children.ts +74 -0
- package/queries/block.ts +29 -40
- package/queries/db-types.ts +15 -0
- package/queries/getBlockTrees-2.ts +0 -0
- package/queries/getBlockTrees.ts +316 -0
- package/queries/getBlocks.ts +214 -0
- package/queries/index.ts +1 -0
- package/queries/structure-types.ts +97 -0
- package/schemas.ts +14 -3
- package/types.ts +84 -5
- package/utils/buildBlocksTree.ts +4 -4
- package/utils/define.ts +18 -4
- package/utils/get-or-create-row.ts +28 -0
- package/utils/startup-log.ts +9 -0
- package/components/AdminPanel/AdminPanel.css +0 -78
- package/components/Field.ts +0 -168
- package/components/Fields.ts +0 -43
- /package/{components/Entry.css → public/entry.css} +0 -0
package/components/Field.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { html } from 'hono/html'
|
|
2
|
-
import { type Block } from '../types.ts'
|
|
3
|
-
import { type HtmlEscapedString } from 'hono/utils/html'
|
|
4
|
-
import { query } from '../queries/index.ts'
|
|
5
|
-
import { db } from '@alstar/db'
|
|
6
|
-
import BlockComponent from './Block.ts'
|
|
7
|
-
import {
|
|
8
|
-
buildStructurePath,
|
|
9
|
-
type StructurePath,
|
|
10
|
-
} from '../utils/build-structure-path.ts'
|
|
11
|
-
|
|
12
|
-
function getData(parentId: string | number, field: Block, sortOrder: number) {
|
|
13
|
-
const data = query.block({
|
|
14
|
-
parent_block_id: parentId?.toString() || null,
|
|
15
|
-
name: field.name,
|
|
16
|
-
sort_order: sortOrder.toString(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
if (!data) {
|
|
20
|
-
const change = db.insertInto('blocks', {
|
|
21
|
-
name: field.name?.toString(),
|
|
22
|
-
label: field.label?.toString(),
|
|
23
|
-
type: field.type?.toString(),
|
|
24
|
-
sort_order: sortOrder,
|
|
25
|
-
parent_block_id: parentId,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return query.block({ id: change.lastInsertRowid.toString() })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return data
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Field = (props: {
|
|
35
|
-
entryId: string | number
|
|
36
|
-
parentId: string | number
|
|
37
|
-
blockStructure: Block
|
|
38
|
-
sortOrder?: number
|
|
39
|
-
structurePath: StructurePath
|
|
40
|
-
}): HtmlEscapedString | Promise<HtmlEscapedString> => {
|
|
41
|
-
const {
|
|
42
|
-
entryId,
|
|
43
|
-
parentId,
|
|
44
|
-
blockStructure,
|
|
45
|
-
sortOrder = 0,
|
|
46
|
-
structurePath,
|
|
47
|
-
} = props
|
|
48
|
-
|
|
49
|
-
const data = getData(parentId, blockStructure, sortOrder)
|
|
50
|
-
|
|
51
|
-
if (!data) return html`<p>No block</p>`
|
|
52
|
-
|
|
53
|
-
const fieldStructurePath = buildStructurePath(blockStructure, structurePath)
|
|
54
|
-
|
|
55
|
-
return html`
|
|
56
|
-
${blockStructure.type === 'slug' &&
|
|
57
|
-
html`
|
|
58
|
-
<form
|
|
59
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
60
|
-
>
|
|
61
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
62
|
-
<input
|
|
63
|
-
id="block-${data.id}"
|
|
64
|
-
name="value"
|
|
65
|
-
type="text"
|
|
66
|
-
value="${data.value}"
|
|
67
|
-
/>
|
|
68
|
-
|
|
69
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
70
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
71
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
72
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
73
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
74
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
75
|
-
<input
|
|
76
|
-
type="hidden"
|
|
77
|
-
name="path"
|
|
78
|
-
value="${fieldStructurePath.join('.')}"
|
|
79
|
-
/>
|
|
80
|
-
</form>
|
|
81
|
-
`}
|
|
82
|
-
${blockStructure.type === 'text' &&
|
|
83
|
-
html`
|
|
84
|
-
<form
|
|
85
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
86
|
-
>
|
|
87
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
88
|
-
<input
|
|
89
|
-
id="block-${data.id}"
|
|
90
|
-
name="value"
|
|
91
|
-
type="text"
|
|
92
|
-
value="${data.value}"
|
|
93
|
-
/>
|
|
94
|
-
|
|
95
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
96
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
97
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
98
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
99
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
100
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
101
|
-
<input
|
|
102
|
-
type="hidden"
|
|
103
|
-
name="path"
|
|
104
|
-
value="${fieldStructurePath.join('.')}"
|
|
105
|
-
/>
|
|
106
|
-
</form>
|
|
107
|
-
`}
|
|
108
|
-
${blockStructure.type === 'image' &&
|
|
109
|
-
html`
|
|
110
|
-
<form
|
|
111
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
112
|
-
>
|
|
113
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
114
|
-
<input
|
|
115
|
-
id="block-${data.id}"
|
|
116
|
-
name="value"
|
|
117
|
-
type="text"
|
|
118
|
-
value="${data.value}"
|
|
119
|
-
/>
|
|
120
|
-
|
|
121
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
122
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
123
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
124
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
125
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
126
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
127
|
-
<input
|
|
128
|
-
type="hidden"
|
|
129
|
-
name="path"
|
|
130
|
-
value="${fieldStructurePath.join('.')}"
|
|
131
|
-
/>
|
|
132
|
-
</form>
|
|
133
|
-
`}
|
|
134
|
-
${blockStructure.type === 'markdown' &&
|
|
135
|
-
html`
|
|
136
|
-
<form
|
|
137
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
138
|
-
>
|
|
139
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
140
|
-
|
|
141
|
-
<textarea></textarea>
|
|
142
|
-
|
|
143
|
-
<!-- <input
|
|
144
|
-
id="block-${data.id}"
|
|
145
|
-
name="value"
|
|
146
|
-
type="text"
|
|
147
|
-
value="${data.value}"
|
|
148
|
-
/> -->
|
|
149
|
-
|
|
150
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
151
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
152
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
153
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
154
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
155
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
156
|
-
<input
|
|
157
|
-
type="hidden"
|
|
158
|
-
name="path"
|
|
159
|
-
value="${fieldStructurePath.join('.')}"
|
|
160
|
-
/>
|
|
161
|
-
</form>
|
|
162
|
-
`}
|
|
163
|
-
${blockStructure.type === 'blocks' &&
|
|
164
|
-
BlockComponent(entryId, data.id, blockStructure, fieldStructurePath)}
|
|
165
|
-
`
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export default Field
|
package/components/Fields.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { html } from 'hono/html'
|
|
2
|
-
import { type Block } from '../types.ts'
|
|
3
|
-
import { type HtmlEscapedString } from 'hono/utils/html'
|
|
4
|
-
import Field from './Field.ts'
|
|
5
|
-
import {
|
|
6
|
-
buildStructurePath,
|
|
7
|
-
type StructurePath,
|
|
8
|
-
} from '../utils/build-structure-path.ts'
|
|
9
|
-
|
|
10
|
-
const Fields = (props: {
|
|
11
|
-
entryId: string | number
|
|
12
|
-
parentId: string | number
|
|
13
|
-
blockStructure: Block
|
|
14
|
-
structurePath: StructurePath
|
|
15
|
-
}): HtmlEscapedString | Promise<HtmlEscapedString> => {
|
|
16
|
-
const updatedPath = buildStructurePath(
|
|
17
|
-
props.blockStructure,
|
|
18
|
-
props.structurePath,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
return html`
|
|
22
|
-
<div class="fields">
|
|
23
|
-
${props.blockStructure.fields
|
|
24
|
-
? props.blockStructure.fields?.map((field, idx) => {
|
|
25
|
-
return Field({
|
|
26
|
-
entryId: props.entryId,
|
|
27
|
-
parentId: props.parentId,
|
|
28
|
-
blockStructure: field,
|
|
29
|
-
sortOrder: idx,
|
|
30
|
-
structurePath: [...updatedPath, 'fields'],
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
: Field({
|
|
34
|
-
entryId: props.entryId,
|
|
35
|
-
parentId: props.parentId,
|
|
36
|
-
blockStructure: props.blockStructure,
|
|
37
|
-
structurePath: updatedPath,
|
|
38
|
-
})}
|
|
39
|
-
</div>
|
|
40
|
-
`
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default Fields
|
|
File without changes
|