@easy-cms/core 0.47.4 → 0.49.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.
@@ -0,0 +1,326 @@
1
+ import { ba as Label, aD as Field, I as ID, k as AdminLocale, t as AdminSwitcher, c1 as SsoProviderRef } from './config-jzFGsNL6.js';
2
+ import { FieldCondition } from './conditions.js';
3
+
4
+ /** A Web Component from an admin module, with its `props` (plain JSON). */
5
+ interface AdminComponentRef {
6
+ tag: string;
7
+ props?: Record<string, unknown>;
8
+ /** A side panel at the top of the side column (`position: 'top'`). */
9
+ position?: 'top';
10
+ }
11
+ /** Where the edit page puts its fields (`admin.layout`), with unplaced fields filled in. */
12
+ type AdminLayoutNode = {
13
+ type: 'field';
14
+ name: string;
15
+ } | {
16
+ type: 'row';
17
+ fields: string[];
18
+ } | {
19
+ type: 'collapsible';
20
+ label: Label;
21
+ collapsed?: boolean;
22
+ description?: Label;
23
+ nodes: AdminLayoutNode[];
24
+ } | {
25
+ type: 'tab';
26
+ label: Label;
27
+ description?: Label;
28
+ nodes: AdminLayoutNode[];
29
+ };
30
+ /** An entry of the admin menu. */
31
+ type AdminNavItem = {
32
+ kind: 'collection';
33
+ slug: string;
34
+ } | {
35
+ kind: 'global';
36
+ slug: string;
37
+ } | {
38
+ kind: 'page';
39
+ path: string;
40
+ } | {
41
+ kind: 'view';
42
+ view: 'roles' | 'sso' | 'backups' | 'email' | 'deliveries' | 'audit';
43
+ };
44
+ /** A group of the admin menu (`admin.nav`), with what this user may open in it. */
45
+ interface AdminNavGroup {
46
+ kind: 'group';
47
+ id: string;
48
+ label: Label;
49
+ icon?: string;
50
+ items: AdminNavNode[];
51
+ }
52
+ type AdminNavNode = AdminNavItem | AdminNavGroup;
53
+ /** A field as the admin UI sees it: plain JSON, no functions. */
54
+ interface AdminField {
55
+ name: string;
56
+ type: Field['type'];
57
+ label?: Label;
58
+ required?: boolean;
59
+ unique?: boolean;
60
+ defaultValue?: unknown;
61
+ minLength?: number;
62
+ maxLength?: number;
63
+ min?: number;
64
+ max?: number;
65
+ options?: {
66
+ label: Label;
67
+ value: string;
68
+ }[];
69
+ hasMany?: boolean;
70
+ to?: string;
71
+ /** An upload's allowed file types, e.g. `image/*`. */
72
+ mimeTypes?: string[];
73
+ /** An upload's media folder (`folder`): where its picker opens; `only`: nowhere else. */
74
+ folder?: {
75
+ id: ID;
76
+ only: boolean;
77
+ };
78
+ /** A relationship with `filterOptions`: the picker asks the server which documents fit. */
79
+ filtered?: boolean;
80
+ from?: string;
81
+ minRows?: number;
82
+ maxRows?: number;
83
+ fields?: AdminField[];
84
+ /** Block kinds of a `blocks` field. */
85
+ blocks?: {
86
+ slug: string;
87
+ labels?: {
88
+ singular?: Label;
89
+ plural?: Label;
90
+ };
91
+ fields: AdminField[];
92
+ }[];
93
+ /** The current user may not change this field. */
94
+ readOnly?: boolean;
95
+ /** One value per content locale. */
96
+ localized?: boolean;
97
+ /** Shown in the edit page's side panel. */
98
+ position?: 'sidebar';
99
+ /** Components from admin modules: instead of the input, below the field, and in lists. */
100
+ admin?: {
101
+ component?: AdminComponentRef;
102
+ after?: AdminComponentRef[];
103
+ cell?: AdminComponentRef;
104
+ };
105
+ /** A column of the list at first (`admin.column`). */
106
+ column?: boolean;
107
+ /** A relationship that offers no "Create" in place (`admin.allowCreate: false`). */
108
+ noCreate?: boolean;
109
+ /** A field of an added type (`fieldTypes`), e.g. `color`; `type` is the base it's stored as. */
110
+ customType?: string;
111
+ /** Help below its label (`admin.description`). */
112
+ description?: Label;
113
+ /** Its share of a row (`admin.width`). */
114
+ width?: string;
115
+ /** Shown only when its siblings match (`admin.condition`). */
116
+ condition?: FieldCondition;
117
+ }
118
+ interface AdminCollection {
119
+ slug: string;
120
+ labels?: {
121
+ singular?: Label;
122
+ plural?: Label;
123
+ };
124
+ icon?: string;
125
+ useAsTitle?: string;
126
+ /** Documents open in a panel over the list. */
127
+ editIn?: 'drawer';
128
+ drafts: boolean;
129
+ versions: boolean;
130
+ /** Has live preview (`preview` in the config). */
131
+ preview: boolean;
132
+ /** Publishing can be scheduled. */
133
+ schedule: boolean;
134
+ fields: AdminField[];
135
+ /** Panels from admin modules in the edit page's side column. */
136
+ sidebar?: AdminComponentRef[];
137
+ /** Tabs, sections and rows of the edit page (`admin.layout`). */
138
+ layout?: AdminLayoutNode[];
139
+ /** A number in the menu (`admin.badge`); the menu's counts come from `GET <api>/admin/ui/counts`. */
140
+ badge?: {
141
+ tone: 'accent' | 'warning' | 'danger';
142
+ label?: Label;
143
+ };
144
+ /** No document count beside it in the menu (`admin.count: false`). */
145
+ noCount?: boolean;
146
+ /** What the list says while it has no documents (`admin.empty`). */
147
+ empty?: {
148
+ description?: Label;
149
+ link?: {
150
+ label: Label;
151
+ href: string;
152
+ };
153
+ };
154
+ /** The list is a tree along this relationship field (`admin.list.tree`). */
155
+ tree?: string;
156
+ /** The list's default order (`admin.list.sort`). */
157
+ defaultSort?: string;
158
+ permissions: {
159
+ read: boolean;
160
+ create: boolean;
161
+ update: boolean;
162
+ delete: boolean;
163
+ publish: boolean;
164
+ };
165
+ /** With `auth.rbac`: the field naming a document's owner (`createdBy` or `admin.ownerField`). */
166
+ owner?: string;
167
+ /** Deleting asks to type the title, and says what goes too (`admin.confirmDelete`). */
168
+ confirmDelete?: {
169
+ typeTitle?: boolean;
170
+ impact?: string;
171
+ };
172
+ }
173
+ interface AdminGlobal {
174
+ slug: string;
175
+ label?: Label;
176
+ icon?: string;
177
+ drafts: boolean;
178
+ versions: boolean;
179
+ /** Has live preview (`preview` in the config). */
180
+ preview: boolean;
181
+ /** Publishing can be scheduled. */
182
+ schedule: boolean;
183
+ fields: AdminField[];
184
+ /** Panels from admin modules in the edit page's side column. */
185
+ sidebar?: AdminComponentRef[];
186
+ /** Tabs, sections and rows of the edit page (`admin.layout`). */
187
+ layout?: AdminLayoutNode[];
188
+ permissions: {
189
+ read: boolean;
190
+ update: boolean;
191
+ publish: boolean;
192
+ };
193
+ }
194
+ /** A page of its own in the admin (`admin.pages`) that this user may open. */
195
+ interface AdminPageRef {
196
+ path: string;
197
+ label: Label;
198
+ icon?: string;
199
+ component: AdminComponentRef;
200
+ }
201
+ /** A dashboard panel (`admin.dashboard`) this user may see. */
202
+ interface AdminWidgetRef {
203
+ component: AdminComponentRef;
204
+ width: 'half' | 'full';
205
+ }
206
+ interface AdminSchema {
207
+ locale: AdminLocale;
208
+ /** A choice for the whole admin, e.g. the tenant (`admin.switcher`). */
209
+ switcher: AdminSwitcher | null;
210
+ /** Admins can email users links to set their password (needs `email` and `serverURL`). */
211
+ passwordLinks: boolean;
212
+ /** The menu: groups and what this user may open in them, in order. */
213
+ nav: AdminNavNode[];
214
+ /** More entries of the command palette (`admin.commands`). */
215
+ commands: {
216
+ label: Label;
217
+ href: string;
218
+ icon?: string;
219
+ keywords?: string[];
220
+ }[];
221
+ /** Content locales, when the config has `localization`. */
222
+ localization: {
223
+ locales: string[];
224
+ defaultLocale: string;
225
+ } | null;
226
+ collections: AdminCollection[];
227
+ globals: AdminGlobal[];
228
+ /** URLs under the API of the admin modules to load (`admin.modules`). */
229
+ modules: string[];
230
+ /** Files can be uploaded from links (`upload.fromURL`). */
231
+ uploadFromURL: boolean;
232
+ /** What the media library takes (`upload.maxFileSize`, `upload.mimeTypes` with groups expanded). */
233
+ upload: {
234
+ maxFileSize: number;
235
+ mimeTypes: string[];
236
+ };
237
+ /**
238
+ * The media library has folders (`upload.folders`); `permissions`: this user may choose which
239
+ * roles use each folder (admins, with `auth.rbac`).
240
+ */
241
+ folders?: {
242
+ permissions: boolean;
243
+ private: boolean;
244
+ };
245
+ /** Which saved deliveries the admin can show (webhooks, emails), for users who may see them. */
246
+ deliveries?: {
247
+ webhook: boolean;
248
+ email: boolean;
249
+ };
250
+ /** Admin pages this user may open: Settings → Backups, Email, Roles; deliveries; the status panel. */
251
+ views: {
252
+ status: boolean;
253
+ deliveries: boolean;
254
+ backups: boolean;
255
+ email: boolean;
256
+ roles: boolean;
257
+ sso: boolean;
258
+ audit: boolean;
259
+ };
260
+ /** Roles from the admin are on (`auth.rbac`): documents have owners. */
261
+ rbac: boolean;
262
+ /** Outside accounts users can sign in with and link (`auth.providers`). */
263
+ providers: SsoProviderRef[];
264
+ /** Pages this user may open (`admin.pages`). */
265
+ pages: AdminPageRef[];
266
+ /** Dashboard panels this user may see (`admin.dashboard`). */
267
+ dashboard: AdminWidgetRef[];
268
+ }
269
+
270
+ /**
271
+ * The version of what the admin gives the Web Components of admin modules (fields, cells, side
272
+ * panels, pages, dashboard panels). It changes only when a component would break.
273
+ */
274
+ declare const ADMIN_API_VERSION = 1;
275
+ /** Where a page (`admin.pages`) is: what follows `/p/<path>/`, and the query's first values. */
276
+ interface AdminPageRoute {
277
+ readonly subpath: string;
278
+ readonly query: Readonly<Record<string, string>>;
279
+ }
280
+ /**
281
+ * The properties the admin sets on a component's element. Components may dispatch:
282
+ *
283
+ * - `change` (`CustomEvent`, `detail`: the new value): sets the field's value.
284
+ * - `set-field` (`detail: { path, value }`): sets another field, e.g. `meta.title`.
285
+ * - `navigate` (`detail`: a path inside the admin, e.g. `/p/forms-overview?range=30`): goes there.
286
+ */
287
+ interface AdminElementProps {
288
+ apiVersion: typeof ADMIN_API_VERSION;
289
+ /** The field's value (field components only). */
290
+ value: unknown;
291
+ /** The field's path in the document, e.g. `meta.title` (field components only). */
292
+ path: string | undefined;
293
+ field: AdminField | undefined;
294
+ /** The field's label in the admin's language (field components only). */
295
+ label: string | undefined;
296
+ /** The whole form as edited, not yet saved (a copy); in a list's cell, that row's document. */
297
+ doc: Record<string, unknown>;
298
+ collection: string | undefined;
299
+ global: string | undefined;
300
+ /** The document's id; `null` while creating one. */
301
+ id: string | number | null;
302
+ /** The content locale being edited (with localization), otherwise `null`. */
303
+ locale: string | null;
304
+ /** The admin's language. */
305
+ uiLocale: AdminLocale;
306
+ readOnly: boolean;
307
+ /** The component's `props` from the config. */
308
+ options: Record<string, unknown>;
309
+ /** Calls the REST API as the logged-in user, e.g. `api('POST', '/seo/generate', body)`. */
310
+ api: <T = unknown>(method: string, path: string, body?: unknown) => Promise<T>;
311
+ /** The logged-in user. */
312
+ user: {
313
+ id: string | number;
314
+ email: string;
315
+ role: string;
316
+ } | null;
317
+ /** On a page of its own (`admin.pages`): the rest of its path and the query; otherwise undefined. */
318
+ route: AdminPageRoute | undefined;
319
+ }
320
+ /** The `detail` of a `set-field` event. */
321
+ interface SetFieldDetail {
322
+ readonly path: string;
323
+ readonly value: unknown;
324
+ }
325
+
326
+ export { ADMIN_API_VERSION as A, type SetFieldDetail as S, type AdminCollection as a, type AdminComponentRef as b, type AdminElementProps as c, type AdminField as d, type AdminGlobal as e, type AdminLayoutNode as f, type AdminNavGroup as g, type AdminNavItem as h, type AdminNavNode as i, type AdminPageRef as j, type AdminPageRoute as k, type AdminSchema as l, type AdminWidgetRef as m };
@@ -0,0 +1,3 @@
1
+ export { a as ADMIN_ICONS, g as AdminComponent, j as AdminIcon, S as AuthUser, a3 as CliCommand, a4 as CollectionAccess, a6 as CollectionConfig, ab as Config, ac as ConfigError, ak as DashboardWidget, av as EasyCMSError, az as Endpoint, aA as EndpointRequest, aB as ErrorCode, aD as Field, aE as FieldAccess, aH as FieldError, aK as FieldTypeBase, aL as FieldTypeDefinition, aM as FieldTypeValidateContext, aY as ForbiddenError, a_ as GlobalConfig, I as ID, b8 as JobConfig, ba as Label, bl as NavGroup, bm as NotFoundError, bo as OnRequest, bp as OnRequestArgs, br as PLUGIN_API_VERSION, bw as PayloadTooLargeError, bx as Plugin, by as PluginInfo, bz as PluginTypes, bC as QueryError, bH as RequestContext, c6 as TooManyRequestsError, c7 as TypedPlugin, c8 as UnauthorizedError, cf as ValidationError, cn as Where, cu as defineFieldType, cv as definePlugin } from './config-jzFGsNL6.js';
2
+ export { A as ADMIN_API_VERSION, c as AdminElementProps, k as AdminPageRoute, S as SetFieldDetail } from './plugin-EX9OHwR3.js';
3
+ import './conditions.js';
package/dist/plugin.js ADDED
@@ -0,0 +1,34 @@
1
+ import {
2
+ ADMIN_API_VERSION
3
+ } from "./chunk-K6GTTRN3.js";
4
+ import {
5
+ ADMIN_ICONS,
6
+ ConfigError,
7
+ EasyCMSError,
8
+ ForbiddenError,
9
+ NotFoundError,
10
+ PLUGIN_API_VERSION,
11
+ PayloadTooLargeError,
12
+ QueryError,
13
+ TooManyRequestsError,
14
+ UnauthorizedError,
15
+ ValidationError,
16
+ defineFieldType,
17
+ definePlugin
18
+ } from "./chunk-CGVNZUW4.js";
19
+ export {
20
+ ADMIN_API_VERSION,
21
+ ADMIN_ICONS,
22
+ ConfigError,
23
+ EasyCMSError,
24
+ ForbiddenError,
25
+ NotFoundError,
26
+ PLUGIN_API_VERSION,
27
+ PayloadTooLargeError,
28
+ QueryError,
29
+ TooManyRequestsError,
30
+ UnauthorizedError,
31
+ ValidationError,
32
+ defineFieldType,
33
+ definePlugin
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/core",
3
- "version": "0.47.4",
3
+ "version": "0.49.0",
4
4
  "description": "Embedded, code-first headless CMS for Nuxt and Next.js",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,6 +18,14 @@
18
18
  "types": "./dist/conditions.d.ts",
19
19
  "default": "./dist/conditions.js"
20
20
  },
21
+ "./plugin": {
22
+ "types": "./dist/plugin.d.ts",
23
+ "default": "./dist/plugin.js"
24
+ },
25
+ "./internal": {
26
+ "types": "./dist/internal.d.ts",
27
+ "default": "./dist/internal.js"
28
+ },
21
29
  "./package.json": "./package.json"
22
30
  },
23
31
  "files": [