@elek-io/core 0.16.2 → 0.17.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/README.md CHANGED
@@ -2,13 +2,36 @@
2
2
 
3
3
  [![codecov](https://codecov.io/gh/elek-io/core/graph/badge.svg?token=GSZIZMVG6Q)](https://codecov.io/gh/elek-io/core)
4
4
 
5
- Handles core functionality of elek.io Projects like file IO and version control as well as providing schemas and types.
5
+ Handles core functionality of elek.io Projects like file IO and version control as well as providing schemas, types and a local REST API.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @elek-io/core
11
+ ```
12
+
13
+ ## Exports
14
+
15
+ The package provides multiple entry points for different environments:
16
+
17
+ - **Node** (`@elek-io/core`) — The `ElekIoCore` main class with full access to services, API, schemas and utilities.
18
+ - **Browser** (`@elek-io/core`) — All schemas and types but without the `ElekIoCore` class, since it is not usable in a browser environment.
19
+ - **Astro** (`@elek-io/core/astro`) — Astro content loaders `elekAssets()` and `elekEntries()` for loading Project data into Astro.
20
+ - **CLI** (`elek`) — A command-line interface with commands for generating API clients, starting a local API and exporting Projects.
21
+
22
+ ## Source structure
6
23
 
7
24
  ```
8
25
  |-- src
9
26
  | |-- api
10
- | | Exports a local API that allows reading Project data
11
- | | mainly for development of websites or apps on the same device.
27
+ | | Local REST API built on Hono with OpenAPI documentation.
28
+ | | Provides routes for Projects, Collections, Entries and Assets.
29
+ | |-- astro
30
+ | | Astro integration with content loaders and dynamic schema building
31
+ | | based on Collection Field definitions.
32
+ | |-- cli
33
+ | | Command-line interface with commands:
34
+ | | generate:client, api:start and export.
12
35
  | |-- error
13
36
  | | Different classes extending Error.
14
37
  | |-- schema
@@ -17,6 +40,9 @@ Handles core functionality of elek.io Projects like file IO and version control
17
40
  | | Contains CRUD logic that does file-io as well as utility functions.
18
41
  | | The methods are mostly used as endpoints
19
42
  | | so their input is validated against our zod schemas.
43
+ | | |-- migrations
44
+ | | | Version-aware schema migrations for Projects, Assets,
45
+ | | | Collections and Entries.
20
46
  | |-- test
21
47
  | | Additional files and utility functions only used for testing.
22
48
  | |-- util
@@ -28,9 +54,13 @@ Handles core functionality of elek.io Projects like file IO and version control
28
54
  | |-- index.node.ts
29
55
  | | Exports the ElekIoCore main class which makes the services and API
30
56
  | | endpoints accessible as well as schemas and utility functions.
57
+ | |-- index.astro.ts
58
+ | | Exports the Astro content loaders for Assets and Entries.
59
+ | |-- index.cli.ts
60
+ | | Entry point for the CLI binary.
31
61
  ```
32
62
 
33
- ## The concept behind Projects, Collections, Entries, Values and Assets
63
+ ## The concept behind Projects, Collections, Entries, Values, Assets and Releases
34
64
 
35
65
  ```
36
66
  |-- Project - e.g. "Website"
@@ -40,6 +70,7 @@ Handles core functionality of elek.io Projects like file IO and version control
40
70
  | | | |-- Value - e.g for a post's title: "Quarterly results 7% higher than expected"
41
71
  | | | |-- Asset - a reference to a previously added Asset like image, PDF or ZIP
42
72
  | | | |-- Entry - a reference to another Entry e.g. to show the user related posts
73
+ | |-- Release - e.g. "v1.0.0" - a tagged snapshot of the Project at a specific point in time
43
74
  ```
44
75
 
45
76
  ### Projects
@@ -57,7 +88,7 @@ e.g. for a Blog, it could have the following Field definition for each post / En
57
88
  - an author that wrote the post (Entry reference)
58
89
 
59
90
  Each definition like the title, contains additional information for the input Field, that is used to modify it's Value.
60
- e.g. the title would be a simple one line input Field, that has a maximum lenght of 150 characters and is required for each post. But the content is a markdown editor to easily add formatting. The image let's the user select a jpeg or png from disk. And the author is a reference to another Collection's Entry, so the user is able to choose one of them.
91
+ e.g. the title would be a simple one line input Field, that has a maximum length of 150 characters and is required for each post. But the content is a markdown editor to easily add formatting. The image let's the user select a jpeg or png from disk. And the author is a reference to another Collection's Entry, so the user is able to choose one of them.
61
92
 
62
93
  ### Entries
63
94
 
@@ -65,9 +96,39 @@ Contains Values and references that follow the Collection's Field definitions. W
65
96
 
66
97
  ### Values
67
98
 
68
- Represent either a single piece of data like the string "How to be successfull in 3 easy steps", a number or a boolean - or a reference to Assets or other Entries.
99
+ Represent either a single piece of data like the string "How to be successful in 3 easy steps", a number or a boolean - or a reference to Assets or other Entries.
69
100
 
70
101
  ### Assets
71
102
 
72
103
  Are files / blobs like images (png, jpeg etc.), documents (excel sheets etc.), music or a compressed folder.
73
104
  Assets have two files inside the Project's repository - the actual file and additionally a file containing meta information like the size.
105
+
106
+ ### Releases
107
+
108
+ Are tagged snapshots of a Project at a specific point in time, managed through git tags. They allow you to mark stable versions of your content that can be deployed or exported.
109
+
110
+ ## CLI
111
+
112
+ The package includes a CLI accessible via the `elek` command:
113
+
114
+ - `elek generate:client` — Generate a JavaScript/TypeScript API client (ESM or CJS)
115
+ - `elek api:start` — Start a local REST API server (default port 31310)
116
+ - `elek export` — Export Projects to JSON (nested or as separate files)
117
+
118
+ ## Documentation
119
+
120
+ The `docs/` folder contains additional in-depth documentation on specific topics like the migration and history reading flow.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ pnpm install # Install dependencies
126
+ pnpm dev # Run tests in watch mode
127
+ pnpm test # Run tests once
128
+ pnpm coverage # Run tests with coverage
129
+ pnpm build # Build all entry points
130
+ pnpm lint # Lint
131
+ pnpm check-types # Type check
132
+ pnpm check-format # Check formatting
133
+ pnpm format # Format code
134
+ ```
@@ -7,7 +7,8 @@ interface ElekAssetsProps {
7
7
  }
8
8
  interface ElekEntriesOptions {
9
9
  projectId: string;
10
- collectionId: string;
10
+ /** Collection UUID or slug */
11
+ collectionIdOrSlug: string;
11
12
  }
12
13
  /**
13
14
  * Astro content loader for elek.io Assets.