@btst/plugin-cms 0.0.0-stage → 1.0.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/LICENSE.md +17 -0
- package/dist/api/getters.cjs +328 -0
- package/dist/api/getters.mjs +314 -0
- package/dist/api/index.cjs +29 -0
- package/dist/api/index.d.cts +209 -0
- package/dist/api/index.d.mts +209 -0
- package/dist/api/index.d.ts +209 -0
- package/dist/api/index.mjs +7 -0
- package/dist/api/lifecycle-migrations.cjs +13 -0
- package/dist/api/lifecycle-migrations.mjs +11 -0
- package/dist/api/mutations.cjs +59 -0
- package/dist/api/mutations.mjs +57 -0
- package/dist/api/operations.cjs +1769 -0
- package/dist/api/operations.mjs +1762 -0
- package/dist/api/plugin.cjs +337 -0
- package/dist/api/plugin.mjs +331 -0
- package/dist/api/query-key-defs.cjs +44 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/api/relations.cjs +76 -0
- package/dist/api/relations.mjs +70 -0
- package/dist/client/components/forms/content-form.cjs +286 -0
- package/dist/client/components/forms/content-form.mjs +284 -0
- package/dist/client/components/forms/file-upload.cjs +160 -0
- package/dist/client/components/forms/file-upload.mjs +158 -0
- package/dist/client/components/forms/relation-field.cjs +237 -0
- package/dist/client/components/forms/relation-field.mjs +235 -0
- package/dist/client/components/index.cjs +14 -0
- package/dist/client/components/index.d.cts +20 -0
- package/dist/client/components/index.d.mts +20 -0
- package/dist/client/components/index.d.ts +20 -0
- package/dist/client/components/index.mjs +10 -0
- package/dist/client/components/inverse-relations-panel.cjs +272 -0
- package/dist/client/components/inverse-relations-panel.mjs +270 -0
- package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
- package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
- package/dist/client/components/loading/editor-skeleton.cjs +32 -0
- package/dist/client/components/loading/editor-skeleton.mjs +30 -0
- package/dist/client/components/loading/list-skeleton.cjs +32 -0
- package/dist/client/components/loading/list-skeleton.mjs +30 -0
- package/dist/client/components/pages/404-page.cjs +26 -0
- package/dist/client/components/pages/404-page.mjs +24 -0
- package/dist/client/components/pages/content-editor-page.cjs +84 -0
- package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
- package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
- package/dist/client/components/pages/content-editor-page.mjs +82 -0
- package/dist/client/components/pages/content-list-page.cjs +49 -0
- package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
- package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
- package/dist/client/components/pages/content-list-page.mjs +47 -0
- package/dist/client/components/pages/dashboard-page.cjs +42 -0
- package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
- package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
- package/dist/client/components/pages/dashboard-page.mjs +40 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/cms-hooks.cjs +300 -0
- package/dist/client/hooks/cms-hooks.mjs +280 -0
- package/dist/client/hooks/cms-resource.cjs +13 -0
- package/dist/client/hooks/cms-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +25 -0
- package/dist/client/hooks/index.d.cts +693 -0
- package/dist/client/hooks/index.d.mts +693 -0
- package/dist/client/hooks/index.d.ts +693 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +15 -0
- package/dist/client/index.d.cts +654 -0
- package/dist/client/index.d.mts +654 -0
- package/dist/client/index.d.ts +654 -0
- package/dist/client/index.mjs +3 -0
- package/dist/client/overrides.cjs +26 -0
- package/dist/client/overrides.mjs +24 -0
- package/dist/client/plugin.cjs +316 -0
- package/dist/client/plugin.mjs +314 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +118 -0
- package/dist/db.mjs +116 -0
- package/dist/permissions.cjs +46 -0
- package/dist/permissions.d.cts +42 -0
- package/dist/permissions.d.mts +42 -0
- package/dist/permissions.d.ts +42 -0
- package/dist/permissions.mjs +44 -0
- package/dist/query-keys.cjs +229 -0
- package/dist/query-keys.d.cts +8 -0
- package/dist/query-keys.d.mts +8 -0
- package/dist/query-keys.d.ts +8 -0
- package/dist/query-keys.mjs +225 -0
- package/dist/schemas.cjs +81 -0
- package/dist/schemas.mjs +72 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
- package/dist/shared/plugin-cms.DQLAoogy.d.ts +1749 -0
- package/dist/shared/plugin-cms.W4Le8D91.d.mts +1749 -0
- package/dist/shared/plugin-cms.c-GeWvTf.d.cts +1749 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +406 -0
- package/dist/types.d.mts +406 -0
- package/dist/types.d.ts +406 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/badge.cjs +42 -0
- package/dist/ui/src/components/badge.mjs +39 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/card.cjs +56 -0
- package/dist/ui/src/components/card.mjs +51 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/command.cjs +78 -0
- package/dist/ui/src/components/command.mjs +73 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +119 -0
- package/dist/ui/src/components/dialog.mjs +97 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/multi-select.cjs +555 -0
- package/dist/ui/src/components/multi-select.mjs +540 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/hooks/use-debounce.cjs +16 -0
- package/dist/ui/src/hooks/use-debounce.mjs +14 -0
- package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
- package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +19 -0
- package/dist/utils.mjs +12 -0
- package/package.json +170 -3
- package/README.md +0 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { e as ContentListDiscriminator, f as ContentListParams, g as cmsResources, h as contentListDiscriminator, d as createCMSQueryKeys } from './shared/plugin-cms.DQLAoogy.js';
|
|
2
|
+
import '@btst/stack/plugins/client';
|
|
3
|
+
import './types.js';
|
|
4
|
+
import '@btst/stack/authorization';
|
|
5
|
+
import '@btst/stack/plugins/api';
|
|
6
|
+
import 'better-call';
|
|
7
|
+
import '@tanstack/react-query';
|
|
8
|
+
import 'zod';
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { normalizeContentFields } from './schemas.mjs';
|
|
2
|
+
import { createResourceQueryKeys } from '@btst/stack/plugins/client';
|
|
3
|
+
import { contentReadKey, contentListDiscriminator, contentReadDiscriminator } from './api/query-key-defs.mjs';
|
|
4
|
+
|
|
5
|
+
function normalizeSearch(search) {
|
|
6
|
+
return search !== void 0 && search.trim() === "" ? void 0 : search;
|
|
7
|
+
}
|
|
8
|
+
function contentReadQuery(options) {
|
|
9
|
+
return {
|
|
10
|
+
view: options?.view,
|
|
11
|
+
fields: options?.fields === void 0 ? void 0 : JSON.stringify(normalizeContentFields(options.fields))
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function relationPageKey(params) {
|
|
15
|
+
const limit = params.limit ?? 20;
|
|
16
|
+
const offset = params.offset ?? 0;
|
|
17
|
+
return limit === 20 && offset === 0 && !params.view && params.fields === void 0 ? [] : [{ limit, offset, ...contentReadDiscriminator(params) }];
|
|
18
|
+
}
|
|
19
|
+
function paginatedNextPageParam(lastPage, allPages, limit) {
|
|
20
|
+
const items = Array.isArray(lastPage?.items) ? lastPage.items : [];
|
|
21
|
+
if (items.length < limit) return void 0;
|
|
22
|
+
const loadedCount = allPages.reduce(
|
|
23
|
+
(sum, page) => sum + (Array.isArray(page?.items) ? page.items.length : 0),
|
|
24
|
+
0
|
|
25
|
+
);
|
|
26
|
+
const total = lastPage?.total ?? 0;
|
|
27
|
+
if (loadedCount >= total) return void 0;
|
|
28
|
+
return loadedCount;
|
|
29
|
+
}
|
|
30
|
+
const cmsResources = {
|
|
31
|
+
cmsTypes: {
|
|
32
|
+
queries: {
|
|
33
|
+
list: {
|
|
34
|
+
path: "/content-types",
|
|
35
|
+
key: () => ["list"],
|
|
36
|
+
select: (data) => data ?? []
|
|
37
|
+
},
|
|
38
|
+
detail: {
|
|
39
|
+
path: "/content-types/:slug",
|
|
40
|
+
params: (slug) => ({ slug }),
|
|
41
|
+
key: (slug) => [slug],
|
|
42
|
+
select: (data, _slug) => data ?? null,
|
|
43
|
+
skip: (slug) => !slug
|
|
44
|
+
},
|
|
45
|
+
inverseRelations: {
|
|
46
|
+
path: "/content-types/:slug/inverse-relations",
|
|
47
|
+
params: (p) => ({ slug: p.slug }),
|
|
48
|
+
query: (p) => ({ itemId: p.itemId }),
|
|
49
|
+
key: (p) => [p.slug, p.itemId],
|
|
50
|
+
select: (data) => data?.inverseRelations ?? []
|
|
51
|
+
},
|
|
52
|
+
inverseRelationItems: {
|
|
53
|
+
path: "/content-types/:slug/inverse-relations/:sourceType",
|
|
54
|
+
params: (p) => ({
|
|
55
|
+
slug: p.slug,
|
|
56
|
+
sourceType: p.sourceType
|
|
57
|
+
}),
|
|
58
|
+
query: (p) => ({
|
|
59
|
+
...contentReadQuery(p),
|
|
60
|
+
itemId: p.itemId,
|
|
61
|
+
fieldName: p.fieldName,
|
|
62
|
+
limit: p.limit ?? 20,
|
|
63
|
+
offset: p.offset ?? 0
|
|
64
|
+
}),
|
|
65
|
+
key: (p) => [
|
|
66
|
+
p.slug,
|
|
67
|
+
p.sourceType,
|
|
68
|
+
p.itemId,
|
|
69
|
+
p.fieldName,
|
|
70
|
+
...relationPageKey(p)
|
|
71
|
+
],
|
|
72
|
+
select: (data) => data ?? { items: [], total: 0 }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
cmsContent: {
|
|
77
|
+
queries: {
|
|
78
|
+
list: {
|
|
79
|
+
path: "/content/:typeSlug",
|
|
80
|
+
params: (p) => ({ typeSlug: p.typeSlug }),
|
|
81
|
+
query: (p) => ({
|
|
82
|
+
...contentReadQuery(p),
|
|
83
|
+
limit: p.limit ?? 20,
|
|
84
|
+
search: normalizeSearch(p.search)
|
|
85
|
+
}),
|
|
86
|
+
key: (p) => [contentListDiscriminator(p)],
|
|
87
|
+
select: (data, _p) => data,
|
|
88
|
+
infinite: true,
|
|
89
|
+
pageSize: (p) => p.limit ?? 20,
|
|
90
|
+
nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
|
|
91
|
+
},
|
|
92
|
+
detail: {
|
|
93
|
+
path: "/content/:typeSlug/:id",
|
|
94
|
+
params: (typeSlug, id, _options) => ({
|
|
95
|
+
typeSlug,
|
|
96
|
+
id
|
|
97
|
+
}),
|
|
98
|
+
query: (_typeSlug, _id, options) => contentReadQuery(options),
|
|
99
|
+
key: (typeSlug, id, options) => [
|
|
100
|
+
typeSlug,
|
|
101
|
+
id,
|
|
102
|
+
...contentReadKey(options)
|
|
103
|
+
],
|
|
104
|
+
select: (data, _typeSlug, _id, _options) => data ?? null,
|
|
105
|
+
skip: (typeSlug, id) => !typeSlug || !id
|
|
106
|
+
},
|
|
107
|
+
bySlug: {
|
|
108
|
+
path: "/content/:typeSlug",
|
|
109
|
+
params: (typeSlug, _slug, _options) => ({ typeSlug }),
|
|
110
|
+
query: (_typeSlug, slug, options) => ({
|
|
111
|
+
slug,
|
|
112
|
+
limit: 1,
|
|
113
|
+
...contentReadQuery(options)
|
|
114
|
+
}),
|
|
115
|
+
key: (typeSlug, slug, options) => [
|
|
116
|
+
"bySlug",
|
|
117
|
+
typeSlug,
|
|
118
|
+
slug,
|
|
119
|
+
...contentReadKey(options)
|
|
120
|
+
],
|
|
121
|
+
select: (data) => data?.items?.[0] ?? null,
|
|
122
|
+
skip: (typeSlug, slug) => !typeSlug || !slug
|
|
123
|
+
},
|
|
124
|
+
populated: {
|
|
125
|
+
path: "/content/:typeSlug/:id/populated",
|
|
126
|
+
params: (typeSlug, id) => ({ typeSlug, id }),
|
|
127
|
+
key: (typeSlug, id) => [typeSlug, id],
|
|
128
|
+
select: (data) => data ?? null,
|
|
129
|
+
skip: (typeSlug, id) => !typeSlug || !id
|
|
130
|
+
},
|
|
131
|
+
byRelation: {
|
|
132
|
+
path: "/content/:typeSlug/by-relation",
|
|
133
|
+
params: (p) => ({ typeSlug: p.typeSlug }),
|
|
134
|
+
query: (p) => ({
|
|
135
|
+
...contentReadQuery(p),
|
|
136
|
+
field: p.field,
|
|
137
|
+
targetId: p.targetId,
|
|
138
|
+
limit: p.limit ?? 20
|
|
139
|
+
}),
|
|
140
|
+
key: (p) => [
|
|
141
|
+
p.typeSlug,
|
|
142
|
+
p.field,
|
|
143
|
+
p.targetId,
|
|
144
|
+
...relationPageKey(p)
|
|
145
|
+
],
|
|
146
|
+
select: (data, _p) => data,
|
|
147
|
+
infinite: true,
|
|
148
|
+
pageSize: (p) => p.limit ?? 20,
|
|
149
|
+
nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
|
|
150
|
+
},
|
|
151
|
+
// Non-infinite options query for relation pickers (useSelect)
|
|
152
|
+
options: {
|
|
153
|
+
path: "/content/:typeSlug",
|
|
154
|
+
params: (p) => ({ typeSlug: p.typeSlug }),
|
|
155
|
+
query: (p) => ({
|
|
156
|
+
...contentReadQuery(p),
|
|
157
|
+
search: normalizeSearch(p.search),
|
|
158
|
+
limit: p.limit ?? 50
|
|
159
|
+
}),
|
|
160
|
+
key: (p) => [
|
|
161
|
+
"options",
|
|
162
|
+
p.typeSlug,
|
|
163
|
+
normalizeSearch(p.search),
|
|
164
|
+
p.limit ?? 50,
|
|
165
|
+
...contentReadKey(p)
|
|
166
|
+
],
|
|
167
|
+
select: (data, _p) => data?.items ?? []
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
mutations: {
|
|
171
|
+
create: {
|
|
172
|
+
path: "@post/content/:typeSlug",
|
|
173
|
+
method: "POST",
|
|
174
|
+
input: (vars) => ({
|
|
175
|
+
params: { typeSlug: vars.typeSlug },
|
|
176
|
+
body: { slug: vars.slug, data: vars.data }
|
|
177
|
+
}),
|
|
178
|
+
select: (data) => data,
|
|
179
|
+
invalidates: [
|
|
180
|
+
"cmsContent",
|
|
181
|
+
"cmsTypes.list",
|
|
182
|
+
"cmsTypes.inverseRelationItems",
|
|
183
|
+
"cmsTypes.inverseRelations"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
update: {
|
|
187
|
+
path: "@put/content/:typeSlug/:id",
|
|
188
|
+
method: "PUT",
|
|
189
|
+
input: (vars) => ({
|
|
190
|
+
params: { typeSlug: vars.typeSlug, id: vars.id },
|
|
191
|
+
body: vars.data
|
|
192
|
+
}),
|
|
193
|
+
select: (data) => data,
|
|
194
|
+
invalidates: [
|
|
195
|
+
"cmsContent",
|
|
196
|
+
"cmsTypes.inverseRelationItems",
|
|
197
|
+
"cmsTypes.inverseRelations"
|
|
198
|
+
],
|
|
199
|
+
setData: {
|
|
200
|
+
query: "detail",
|
|
201
|
+
args: (updated) => updated?.contentType?.slug ? [updated.contentType.slug, updated.id] : null
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
delete: {
|
|
205
|
+
path: "@delete/content/:typeSlug/:id",
|
|
206
|
+
method: "DELETE",
|
|
207
|
+
input: (vars) => ({
|
|
208
|
+
params: { typeSlug: vars.typeSlug, id: vars.id }
|
|
209
|
+
}),
|
|
210
|
+
select: (data) => data,
|
|
211
|
+
invalidates: [
|
|
212
|
+
"cmsContent",
|
|
213
|
+
"cmsTypes.list",
|
|
214
|
+
"cmsTypes.inverseRelationItems",
|
|
215
|
+
"cmsTypes.inverseRelations"
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function createCMSQueryKeys(client, headers) {
|
|
222
|
+
return createResourceQueryKeys(client, cmsResources, headers);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { cmsResources, contentListDiscriminator, createCMSQueryKeys };
|
package/dist/schemas.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const z = require('zod');
|
|
4
|
+
|
|
5
|
+
function normalizeContentFields(fields) {
|
|
6
|
+
return fields === void 0 ? void 0 : [...new Set(fields)].sort();
|
|
7
|
+
}
|
|
8
|
+
const DEFAULT_MAX_PAGE_SIZE = 1e3;
|
|
9
|
+
const contentReadOptionsSchema = z.z.object({
|
|
10
|
+
view: z.z.literal("content").optional(),
|
|
11
|
+
fields: z.z.array(z.z.string()).min(1).transform((fields) => normalizeContentFields(fields)).optional()
|
|
12
|
+
});
|
|
13
|
+
const contentReadQuerySchema = contentReadOptionsSchema.extend({
|
|
14
|
+
fields: z.z.preprocess((value) => {
|
|
15
|
+
if (value === void 0) return void 0;
|
|
16
|
+
if (typeof value !== "string") return z.z.NEVER;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(value);
|
|
19
|
+
} catch {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
}, contentReadOptionsSchema.shape.fields)
|
|
23
|
+
});
|
|
24
|
+
function createListContentQuerySchema(maxPageSize = DEFAULT_MAX_PAGE_SIZE) {
|
|
25
|
+
return z.z.object({
|
|
26
|
+
...contentReadOptionsSchema.shape,
|
|
27
|
+
slug: z.z.string().optional(),
|
|
28
|
+
search: z.z.string().max(200).optional(),
|
|
29
|
+
limit: z.z.coerce.number().min(1).max(maxPageSize).optional().default(20),
|
|
30
|
+
offset: z.z.coerce.number().min(0).optional().default(0)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
createListContentQuerySchema();
|
|
34
|
+
z.z.object({
|
|
35
|
+
slug: z.z.string().min(1, "Slug is required"),
|
|
36
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
37
|
+
data: z.z.object({}).passthrough()
|
|
38
|
+
});
|
|
39
|
+
z.z.object({
|
|
40
|
+
slug: z.z.string().min(1, "Slug is required").optional(),
|
|
41
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
42
|
+
data: z.z.object({}).passthrough().optional()
|
|
43
|
+
});
|
|
44
|
+
const contentTypeResponseSchema = z.z.object({
|
|
45
|
+
id: z.z.string(),
|
|
46
|
+
name: z.z.string(),
|
|
47
|
+
slug: z.z.string(),
|
|
48
|
+
description: z.z.string().nullable().optional(),
|
|
49
|
+
jsonSchema: z.z.string(),
|
|
50
|
+
createdAt: z.z.string(),
|
|
51
|
+
updatedAt: z.z.string()
|
|
52
|
+
});
|
|
53
|
+
const contentItemResponseSchema = z.z.object({
|
|
54
|
+
id: z.z.string(),
|
|
55
|
+
contentTypeId: z.z.string(),
|
|
56
|
+
slug: z.z.string(),
|
|
57
|
+
data: z.z.string(),
|
|
58
|
+
authorId: z.z.string().nullable().optional(),
|
|
59
|
+
createdAt: z.z.string(),
|
|
60
|
+
updatedAt: z.z.string()
|
|
61
|
+
});
|
|
62
|
+
const contentItemWithDataResponseSchema = contentItemResponseSchema.extend({
|
|
63
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
64
|
+
parsedData: z.z.object({}).passthrough(),
|
|
65
|
+
contentType: contentTypeResponseSchema.optional()
|
|
66
|
+
});
|
|
67
|
+
z.z.object({
|
|
68
|
+
items: z.z.array(contentItemWithDataResponseSchema),
|
|
69
|
+
total: z.z.number(),
|
|
70
|
+
limit: z.z.number(),
|
|
71
|
+
offset: z.z.number()
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
exports.DEFAULT_MAX_PAGE_SIZE = DEFAULT_MAX_PAGE_SIZE;
|
|
75
|
+
exports.contentItemResponseSchema = contentItemResponseSchema;
|
|
76
|
+
exports.contentItemWithDataResponseSchema = contentItemWithDataResponseSchema;
|
|
77
|
+
exports.contentReadOptionsSchema = contentReadOptionsSchema;
|
|
78
|
+
exports.contentReadQuerySchema = contentReadQuerySchema;
|
|
79
|
+
exports.contentTypeResponseSchema = contentTypeResponseSchema;
|
|
80
|
+
exports.createListContentQuerySchema = createListContentQuerySchema;
|
|
81
|
+
exports.normalizeContentFields = normalizeContentFields;
|
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
function normalizeContentFields(fields) {
|
|
4
|
+
return fields === void 0 ? void 0 : [...new Set(fields)].sort();
|
|
5
|
+
}
|
|
6
|
+
const DEFAULT_MAX_PAGE_SIZE = 1e3;
|
|
7
|
+
const contentReadOptionsSchema = z.object({
|
|
8
|
+
view: z.literal("content").optional(),
|
|
9
|
+
fields: z.array(z.string()).min(1).transform((fields) => normalizeContentFields(fields)).optional()
|
|
10
|
+
});
|
|
11
|
+
const contentReadQuerySchema = contentReadOptionsSchema.extend({
|
|
12
|
+
fields: z.preprocess((value) => {
|
|
13
|
+
if (value === void 0) return void 0;
|
|
14
|
+
if (typeof value !== "string") return z.NEVER;
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(value);
|
|
17
|
+
} catch {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}, contentReadOptionsSchema.shape.fields)
|
|
21
|
+
});
|
|
22
|
+
function createListContentQuerySchema(maxPageSize = DEFAULT_MAX_PAGE_SIZE) {
|
|
23
|
+
return z.object({
|
|
24
|
+
...contentReadOptionsSchema.shape,
|
|
25
|
+
slug: z.string().optional(),
|
|
26
|
+
search: z.string().max(200).optional(),
|
|
27
|
+
limit: z.coerce.number().min(1).max(maxPageSize).optional().default(20),
|
|
28
|
+
offset: z.coerce.number().min(0).optional().default(0)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
createListContentQuerySchema();
|
|
32
|
+
z.object({
|
|
33
|
+
slug: z.string().min(1, "Slug is required"),
|
|
34
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
35
|
+
data: z.object({}).passthrough()
|
|
36
|
+
});
|
|
37
|
+
z.object({
|
|
38
|
+
slug: z.string().min(1, "Slug is required").optional(),
|
|
39
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
40
|
+
data: z.object({}).passthrough().optional()
|
|
41
|
+
});
|
|
42
|
+
const contentTypeResponseSchema = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
name: z.string(),
|
|
45
|
+
slug: z.string(),
|
|
46
|
+
description: z.string().nullable().optional(),
|
|
47
|
+
jsonSchema: z.string(),
|
|
48
|
+
createdAt: z.string(),
|
|
49
|
+
updatedAt: z.string()
|
|
50
|
+
});
|
|
51
|
+
const contentItemResponseSchema = z.object({
|
|
52
|
+
id: z.string(),
|
|
53
|
+
contentTypeId: z.string(),
|
|
54
|
+
slug: z.string(),
|
|
55
|
+
data: z.string(),
|
|
56
|
+
authorId: z.string().nullable().optional(),
|
|
57
|
+
createdAt: z.string(),
|
|
58
|
+
updatedAt: z.string()
|
|
59
|
+
});
|
|
60
|
+
const contentItemWithDataResponseSchema = contentItemResponseSchema.extend({
|
|
61
|
+
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
62
|
+
parsedData: z.object({}).passthrough(),
|
|
63
|
+
contentType: contentTypeResponseSchema.optional()
|
|
64
|
+
});
|
|
65
|
+
z.object({
|
|
66
|
+
items: z.array(contentItemWithDataResponseSchema),
|
|
67
|
+
total: z.number(),
|
|
68
|
+
limit: z.number(),
|
|
69
|
+
offset: z.number()
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export { DEFAULT_MAX_PAGE_SIZE, contentItemResponseSchema, contentItemWithDataResponseSchema, contentReadOptionsSchema, contentReadQuerySchema, contentTypeResponseSchema, createListContentQuerySchema, normalizeContentFields };
|