@airdraft/ui-core 0.1.2 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.5](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.3...ui-core@v0.1.5) (2026-05-23)
6
+
7
+
8
+ ### Documentation
9
+
10
+ * **ui-core:** add README.md for shared UI-layer constants and utilities ([91fb464](https://github.com/aevrHQ/airdraft/commit/91fb4643eb7340ea16b1db9fd06e33ce0866b4b3))
11
+
12
+ ### [0.1.4](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.3...ui-core@v0.1.4) (2026-05-23)
13
+
14
+ ### [0.1.3](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.2...ui-core@v0.1.3) (2026-05-23)
15
+
16
+
17
+ ### Features
18
+
19
+ * add `story` field type with schema definition and UI support; include media file for demo ([f5d3f88](https://github.com/aevrHQ/airdraft/commit/f5d3f884afda98e613c50ce1a0ebb3c591a84511))
20
+ * enhance media field handling in renderTypes function to include metadata support ([b80245c](https://github.com/aevrHQ/airdraft/commit/b80245caf91e2a436172e875fff89c83a56b5ff3))
21
+ * enhance MIME type handling in FilesSdkMediaAdapter and withMedia plugin ([186d33f](https://github.com/aevrHQ/airdraft/commit/186d33f33d31431c579a821eaa1a7a5ea13be4e7))
22
+ * implement `blocks` field type with schema definition, validation, and UI support ([a3d57d1](https://github.com/aevrHQ/airdraft/commit/a3d57d11d82f38871fe044641bbb5a98cda3cb75))
23
+ * **react-content:** add support for media lists and urls ([2cb0891](https://github.com/aevrHQ/airdraft/commit/2cb089102b0530217f305c782435138592f7754d))
24
+ * **types:** add asCollectionConfig function for casting schema objects ([f5bcaaf](https://github.com/aevrHQ/airdraft/commit/f5bcaafa42fb43d749c89dfe7e7b075adcd18474))
25
+
26
+
27
+ ### Code Refactoring
28
+
29
+ * code structure for improved readability and maintainability ([410de76](https://github.com/aevrHQ/airdraft/commit/410de761725340ea8edbb50b7de122797b58d942))
30
+
5
31
  ### [0.1.2](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.1...ui-core@v0.1.2) (2026-05-23)
6
32
 
7
33
  ### [0.1.1](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.0...ui-core@v0.1.1) (2026-05-23)
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @airdraft/ui-core
2
+
3
+ Shared UI-layer constants and utilities for Airdraft. Provides field-type metadata (labels, icons, descriptions), the schema editor mutation helpers, and collection name validators consumed by `@airdraft/react-ui`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @airdraft/ui-core
9
+ ```
10
+
11
+ This package is typically a transitive dependency — you don't need to install it directly unless you're building a custom schema editor or type picker.
12
+
13
+ ## Exports
14
+
15
+ ### Field type metadata
16
+
17
+ ```ts
18
+ import { FIELD_TYPE_META, VISIBLE_FIELD_TYPES } from '@airdraft/ui-core'
19
+ import type { FieldTypeMeta } from '@airdraft/ui-core'
20
+ ```
21
+
22
+ | Export | Description |
23
+ |---|---|
24
+ | `FIELD_TYPE_META` | `Record<FieldType, FieldTypeMeta>` — label, description, and Lucide icon name for every field type |
25
+ | `VISIBLE_FIELD_TYPES` | `FieldType[]` — all field types with `hidden !== true`; use this to populate a type picker (excludes the deprecated `image` type) |
26
+ | `FieldTypeMeta` | `{ type, label, description, icon, hidden? }` |
27
+
28
+ **Supported field types** (all included in `FIELD_TYPE_META`):
29
+
30
+ `string` · `text` · `number` · `boolean` · `date` · `datetime` · `list` · `select` · `multiselect` · `rich-text` · `relation` · `relations` · `object` · `url` · `media` · `blocks`
31
+
32
+ `image` is present but marked `hidden: true` — it is excluded from `VISIBLE_FIELD_TYPES` and the schema editor type picker. Use `media` for new fields.
33
+
34
+ ### Schema editor mutations
35
+
36
+ ```ts
37
+ import { applyFieldUpdate, applyFieldDelete, buildDefaultPath } from '@airdraft/ui-core'
38
+ ```
39
+
40
+ | Export | Description |
41
+ |---|---|
42
+ | `applyFieldUpdate(schema, collection, key, config)` | Returns a new `CmsSchema` with the field upserted |
43
+ | `applyFieldDelete(schema, collection, key)` | Returns a new `CmsSchema` with the field removed |
44
+ | `buildDefaultPath(collection, format, slugSource?)` | Generates a default `path` pattern for a new collection |
45
+
46
+ ### Validators
47
+
48
+ ```ts
49
+ import { validateFieldKey, generateFieldKey, validateCollectionName } from '@airdraft/ui-core'
50
+ ```
51
+
52
+ | Export | Description |
53
+ |---|---|
54
+ | `validateFieldKey(key)` | Returns an error string if the key is invalid (empty, reserved, non-slug), or `null` if valid |
55
+ | `generateFieldKey(label)` | Converts a human label to a valid snake_case field key |
56
+ | `validateCollectionName(name)` | Returns an error string if the name collides with a reserved route, or `null` if valid |
57
+
58
+ ### Constants
59
+
60
+ ```ts
61
+ import { RESERVED_COLLECTION_NAMES } from '@airdraft/ui-core'
62
+ ```
63
+
64
+ `RESERVED_COLLECTION_NAMES` — `Set<string>` of names that cannot be used as collection names (`schema`, `media`, `openapi`, `health`, etc.).
65
+
66
+ ## Changelog
67
+
68
+ See [CHANGELOG.md](./CHANGELOG.md).
@@ -1 +1 @@
1
- {"version":3,"file":"field-type-meta.d.ts","sourceRoot":"","sources":["../src/field-type-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAkBnF,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,aAEX,CAAA"}
1
+ {"version":3,"file":"field-type-meta.d.ts","sourceRoot":"","sources":["../src/field-type-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAmBnF,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,aAEX,CAAA"}
@@ -14,6 +14,7 @@ export const FIELD_TYPE_META = {
14
14
  object: { type: 'object', label: 'Object', description: 'Nested field group', icon: 'Braces' },
15
15
  url: { type: 'url', label: 'URL', description: 'Absolute or relative URL', icon: 'Link2' },
16
16
  media: { type: 'media', label: 'Media', description: 'File or media asset', icon: 'Paperclip' },
17
+ blocks: { type: 'blocks', label: 'Blocks', description: 'Structured nested fields', icon: 'LayoutList' },
17
18
  /** @deprecated hidden from picker — use 'media' for new fields */
18
19
  image: { type: 'image', label: 'Image', description: 'Image URL or media asset', icon: 'Image', hidden: true },
19
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"field-type-meta.js","sourceRoot":"","sources":["../src/field-type-meta.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,eAAe,GAA4D;IACtF,MAAM,EAAO,EAAE,IAAI,EAAE,QAAQ,EAAO,KAAK,EAAE,YAAY,EAAI,WAAW,EAAE,qBAAqB,EAAY,IAAI,EAAE,MAAM,EAAE;IACvH,IAAI,EAAS,EAAE,IAAI,EAAE,MAAM,EAAS,KAAK,EAAE,WAAW,EAAK,WAAW,EAAE,uBAAuB,EAAW,IAAI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AE,IAAI,EAAE,QAAQ,EAAO,KAAK,EAAE,QAAQ,EAAQ,WAAW,EAAE,oBAAoB,EAAc,IAAI,EAAE,QAAQ,EAAE;IAC1H,GAAG,EAAU,EAAE,IAAI,EAAE,KAAK,EAAU,KAAK,EAAE,KAAK,EAAW,WAAW,EAAE,0BAA0B,EAAQ,IAAI,EAAE,OAAO,EAAE;IACzH,KAAK,EAAQ,EAAE,IAAI,EAAE,OAAO,EAAQ,KAAK,EAAE,OAAO,EAAS,WAAW,EAAE,qBAAqB,EAAa,IAAI,EAAE,WAAW,EAAE;IAC7H,MAAM,EAAO,EAAE,IAAI,EAAE,QAAQ,EAAO,KAAK,EAAE,QAAQ,EAAQ,WAAW,EAAE,0BAA0B,EAAQ,IAAI,EAAE,YAAY,EAAE;IAC9H,kEAAkE;IAClE,KAAK,EAAQ,EAAE,IAAI,EAAE,OAAO,EAAQ,KAAK,EAAE,OAAO,EAAS,WAAW,EAAE,0BAA0B,EAAQ,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;CACxI,CAAA;AAED,6FAA6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAiD;KAC/G,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KACxB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airdraft/ui-core",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "Airdraft UI core — field type metadata, validators, and schema mutation helpers (zero framework deps)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",