@btst/plugin-cms 1.0.0 → 1.2.0-beta.0
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/api/getters.cjs +37 -25
- package/dist/api/getters.mjs +37 -25
- package/dist/api/index.cjs +1 -0
- package/dist/api/index.d.cts +17 -8
- package/dist/api/index.d.mts +17 -8
- package/dist/api/index.d.ts +17 -8
- package/dist/api/index.mjs +1 -1
- package/dist/api/mutations.cjs +46 -19
- package/dist/api/mutations.mjs +46 -20
- package/dist/api/operations.cjs +586 -177
- package/dist/api/operations.mjs +585 -178
- package/dist/api/plugin.cjs +56 -7
- package/dist/api/plugin.mjs +57 -8
- package/dist/api/publication.cjs +8 -0
- package/dist/api/publication.mjs +6 -0
- package/dist/client/components/forms/content-form.cjs +107 -1
- package/dist/client/components/forms/content-form.mjs +108 -2
- package/dist/client/components/pages/content-editor-page.internal.cjs +23 -5
- package/dist/client/components/pages/content-editor-page.internal.mjs +23 -5
- package/dist/client/components/pages/content-list-page.internal.cjs +3 -0
- package/dist/client/components/pages/content-list-page.internal.mjs +3 -0
- package/dist/client/components/pages/dashboard-page.internal.cjs +10 -30
- package/dist/client/components/pages/dashboard-page.internal.mjs +10 -30
- package/dist/client/components/revision-history.cjs +161 -0
- package/dist/client/components/revision-history.mjs +159 -0
- package/dist/client/components/shared/content-type-card.cjs +56 -0
- package/dist/client/components/shared/content-type-card.mjs +54 -0
- package/dist/client/components/shared/empty-state.cjs +18 -1
- package/dist/client/components/shared/empty-state.mjs +19 -2
- package/dist/client/hooks/cms-hooks.cjs +18 -2
- package/dist/client/hooks/cms-hooks.mjs +17 -3
- package/dist/client/hooks/index.cjs +2 -0
- package/dist/client/hooks/index.d.cts +306 -2
- package/dist/client/hooks/index.d.mts +306 -2
- package/dist/client/hooks/index.d.ts +306 -2
- package/dist/client/hooks/index.mjs +1 -1
- package/dist/client/index.d.cts +55 -2
- package/dist/client/index.d.mts +55 -2
- package/dist/client/index.d.ts +55 -2
- package/dist/db.cjs +25 -0
- package/dist/db.mjs +25 -0
- package/dist/permissions.cjs +2 -0
- package/dist/permissions.d.cts +1 -0
- package/dist/permissions.d.mts +1 -0
- package/dist/permissions.d.ts +1 -0
- package/dist/permissions.mjs +2 -0
- package/dist/query-keys.cjs +31 -1
- package/dist/query-keys.d.cts +1 -1
- package/dist/query-keys.d.mts +1 -1
- package/dist/query-keys.d.ts +1 -1
- package/dist/query-keys.mjs +31 -1
- package/dist/shared/{plugin-cms.W4Le8D91.d.mts → plugin-cms.DAAUZ41w.d.mts} +377 -144
- package/dist/shared/{plugin-cms.c-GeWvTf.d.cts → plugin-cms.DJ_293QU.d.cts} +377 -144
- package/dist/shared/{plugin-cms.DQLAoogy.d.ts → plugin-cms.DlUSv7wz.d.ts} +377 -144
- package/dist/types.d.cts +38 -2
- package/dist/types.d.mts +38 -2
- package/dist/types.d.ts +38 -2
- package/dist/ui/src/components/auto-form/config.cjs +2 -0
- package/dist/ui/src/components/auto-form/config.mjs +2 -0
- package/dist/ui/src/components/auto-form/fields/file.cjs +68 -0
- package/dist/ui/src/components/auto-form/fields/file.mjs +63 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +9 -2
- package/dist/ui/src/components/auto-form/fields/object.mjs +9 -2
- package/dist/ui/src/components/auto-form/helpers.cjs +9 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +9 -0
- package/dist/ui/src/components/auto-form/index.cjs +29 -4
- package/dist/ui/src/components/auto-form/index.mjs +31 -6
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +34 -29
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +35 -30
- package/dist/ui/src/components/sheet.cjs +126 -0
- package/dist/ui/src/components/sheet.mjs +105 -0
- package/dist/ui/src/lib/form-visibility.cjs +20 -0
- package/dist/ui/src/lib/form-visibility.mjs +18 -0
- package/dist/ui/src/lib/schema-converter.cjs +101 -0
- package/dist/ui/src/lib/schema-converter.mjs +100 -1
- package/package.json +5 -4
package/dist/api/mutations.cjs
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
const getters = require('./getters.cjs');
|
|
4
4
|
const relations = require('./relations.cjs');
|
|
5
5
|
|
|
6
|
+
async function recordContentRevision(adapter, item, authorId) {
|
|
7
|
+
const latest = await adapter.findMany({
|
|
8
|
+
model: "contentRevision",
|
|
9
|
+
where: [{ field: "contentItemId", value: item.id, operator: "eq" }],
|
|
10
|
+
sortBy: { field: "version", direction: "desc" },
|
|
11
|
+
limit: 1
|
|
12
|
+
});
|
|
13
|
+
const version = (latest[0]?.version ?? 0) + 1;
|
|
14
|
+
return adapter.create({
|
|
15
|
+
model: "contentRevision",
|
|
16
|
+
data: {
|
|
17
|
+
revisionKey: `${item.id}:${version}`,
|
|
18
|
+
contentItemId: item.id,
|
|
19
|
+
version,
|
|
20
|
+
slug: item.slug,
|
|
21
|
+
data: item.data,
|
|
22
|
+
publishAt: item.publishAt ?? null,
|
|
23
|
+
...authorId ? { authorId } : {},
|
|
24
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
6
28
|
async function createCMSContentItem(adapter, contentTypeSlug, input, options = {}) {
|
|
7
29
|
const contentType = await adapter.findOne({
|
|
8
30
|
model: "contentType",
|
|
@@ -33,27 +55,32 @@ async function createCMSContentItem(adapter, contentTypeSlug, input, options = {
|
|
|
33
55
|
`Content item with slug "${input.slug}" already exists in type "${contentTypeSlug}"`
|
|
34
56
|
);
|
|
35
57
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
return adapter.transaction(async (tx) => {
|
|
59
|
+
const item = await tx.create({
|
|
60
|
+
model: "contentItem",
|
|
61
|
+
data: {
|
|
62
|
+
contentTypeId: contentType.id,
|
|
63
|
+
slug: input.slug,
|
|
64
|
+
data: JSON.stringify(input.data),
|
|
65
|
+
...input.publishAt !== void 0 ? { publishAt: input.publishAt } : {},
|
|
66
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
67
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (options.syncRelations) {
|
|
71
|
+
const relationFields = relations.extractRelationFields(contentType);
|
|
72
|
+
if (Object.keys(relationFields).length > 0) {
|
|
73
|
+
const relationIds = relations.collectExistingRelationIds(
|
|
74
|
+
input.data,
|
|
75
|
+
relationFields
|
|
76
|
+
);
|
|
77
|
+
await relations.syncRelations(tx, item.id, relationIds);
|
|
78
|
+
}
|
|
44
79
|
}
|
|
80
|
+
await recordContentRevision(tx, item);
|
|
81
|
+
return getters.serializeContentItem(item);
|
|
45
82
|
});
|
|
46
|
-
if (options.syncRelations) {
|
|
47
|
-
const relationFields = relations.extractRelationFields(contentType);
|
|
48
|
-
if (Object.keys(relationFields).length > 0) {
|
|
49
|
-
const relationIds = relations.collectExistingRelationIds(
|
|
50
|
-
input.data,
|
|
51
|
-
relationFields
|
|
52
|
-
);
|
|
53
|
-
await relations.syncRelations(adapter, item.id, relationIds);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return getters.serializeContentItem(item);
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
exports.createCMSContentItem = createCMSContentItem;
|
|
86
|
+
exports.recordContentRevision = recordContentRevision;
|
package/dist/api/mutations.mjs
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { serializeContentItem } from './getters.mjs';
|
|
2
2
|
import { extractRelationFields, collectExistingRelationIds, syncRelations } from './relations.mjs';
|
|
3
3
|
|
|
4
|
+
async function recordContentRevision(adapter, item, authorId) {
|
|
5
|
+
const latest = await adapter.findMany({
|
|
6
|
+
model: "contentRevision",
|
|
7
|
+
where: [{ field: "contentItemId", value: item.id, operator: "eq" }],
|
|
8
|
+
sortBy: { field: "version", direction: "desc" },
|
|
9
|
+
limit: 1
|
|
10
|
+
});
|
|
11
|
+
const version = (latest[0]?.version ?? 0) + 1;
|
|
12
|
+
return adapter.create({
|
|
13
|
+
model: "contentRevision",
|
|
14
|
+
data: {
|
|
15
|
+
revisionKey: `${item.id}:${version}`,
|
|
16
|
+
contentItemId: item.id,
|
|
17
|
+
version,
|
|
18
|
+
slug: item.slug,
|
|
19
|
+
data: item.data,
|
|
20
|
+
publishAt: item.publishAt ?? null,
|
|
21
|
+
...authorId ? { authorId } : {},
|
|
22
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
4
26
|
async function createCMSContentItem(adapter, contentTypeSlug, input, options = {}) {
|
|
5
27
|
const contentType = await adapter.findOne({
|
|
6
28
|
model: "contentType",
|
|
@@ -31,27 +53,31 @@ async function createCMSContentItem(adapter, contentTypeSlug, input, options = {
|
|
|
31
53
|
`Content item with slug "${input.slug}" already exists in type "${contentTypeSlug}"`
|
|
32
54
|
);
|
|
33
55
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
return adapter.transaction(async (tx) => {
|
|
57
|
+
const item = await tx.create({
|
|
58
|
+
model: "contentItem",
|
|
59
|
+
data: {
|
|
60
|
+
contentTypeId: contentType.id,
|
|
61
|
+
slug: input.slug,
|
|
62
|
+
data: JSON.stringify(input.data),
|
|
63
|
+
...input.publishAt !== void 0 ? { publishAt: input.publishAt } : {},
|
|
64
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
65
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (options.syncRelations) {
|
|
69
|
+
const relationFields = extractRelationFields(contentType);
|
|
70
|
+
if (Object.keys(relationFields).length > 0) {
|
|
71
|
+
const relationIds = collectExistingRelationIds(
|
|
72
|
+
input.data,
|
|
73
|
+
relationFields
|
|
74
|
+
);
|
|
75
|
+
await syncRelations(tx, item.id, relationIds);
|
|
76
|
+
}
|
|
42
77
|
}
|
|
78
|
+
await recordContentRevision(tx, item);
|
|
79
|
+
return serializeContentItem(item);
|
|
43
80
|
});
|
|
44
|
-
if (options.syncRelations) {
|
|
45
|
-
const relationFields = extractRelationFields(contentType);
|
|
46
|
-
if (Object.keys(relationFields).length > 0) {
|
|
47
|
-
const relationIds = collectExistingRelationIds(
|
|
48
|
-
input.data,
|
|
49
|
-
relationFields
|
|
50
|
-
);
|
|
51
|
-
await syncRelations(adapter, item.id, relationIds);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return serializeContentItem(item);
|
|
55
81
|
}
|
|
56
82
|
|
|
57
|
-
export { createCMSContentItem };
|
|
83
|
+
export { createCMSContentItem, recordContentRevision };
|