stonyx 0.2.3-alpha.6 → 0.2.3-alpha.7
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 +4 -12
- package/docs/cli.md +0 -10
- package/docs/conventions/orm-conventions.md +32 -0
- package/docs/modules.md +1 -5
- package/package.json +2 -2
- package/src/cli.js +1 -1
package/README.md
CHANGED
|
@@ -5,23 +5,19 @@
|
|
|
5
5
|
- 100% JavaScript (ES Modules)
|
|
6
6
|
- Drop-in module system — no boilerplate
|
|
7
7
|
- Automatic async module loading and initialization
|
|
8
|
-
- Built-in CLI for
|
|
8
|
+
- Built-in CLI for bootstrapping and testing
|
|
9
9
|
|
|
10
10
|
## Quick Start
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install
|
|
14
|
-
stonyx new my-app
|
|
15
|
-
cd my-app
|
|
16
|
-
stonyx serve
|
|
13
|
+
npm install stonyx
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
The
|
|
16
|
+
The CLI handles everything — no manual `new Stonyx()` calls needed:
|
|
20
17
|
|
|
21
18
|
```bash
|
|
22
19
|
stonyx serve # Bootstrap + run app.js
|
|
23
20
|
stonyx test # Bootstrap + run tests
|
|
24
|
-
stonyx help # Show all available commands
|
|
25
21
|
```
|
|
26
22
|
|
|
27
23
|
Stonyx reads `config/environment.js`, initializes all `@stonyx/*` modules from your `devDependencies`, and runs your application.
|
|
@@ -44,12 +40,8 @@ Stonyx reads `config/environment.js`, initializes all `@stonyx/*` modules from y
|
|
|
44
40
|
| Module | Description |
|
|
45
41
|
|--------|-------------|
|
|
46
42
|
| [@stonyx/cron](https://github.com/abofs/stonyx-cron) | Lightweight async job scheduling |
|
|
47
|
-
| [@stonyx/discord](https://github.com/abofs/stonyx-discord) | Discord bot with command and event handler auto-discovery |
|
|
48
|
-
| [@stonyx/events](https://github.com/abofs/stonyx-events) | Pub/sub event system |
|
|
49
|
-
| [@stonyx/oauth](https://github.com/abofs/stonyx-oauth) | OAuth provider integration |
|
|
50
|
-
| [@stonyx/orm](https://github.com/abofs/stonyx-orm) | ORM with models, relationships, and serializers |
|
|
51
43
|
| [@stonyx/rest-server](https://github.com/abofs/stonyx-rest-server) | Dynamic REST server with auto-route registration |
|
|
52
|
-
| [@stonyx/
|
|
44
|
+
| [@stonyx/orm](https://github.com/abofs/stonyx-orm) | ORM with models, relationships, and serializers |
|
|
53
45
|
|
|
54
46
|
## License
|
|
55
47
|
|
package/docs/cli.md
CHANGED
|
@@ -12,20 +12,10 @@ stonyx <command> [...args]
|
|
|
12
12
|
|
|
13
13
|
| Command | Alias | Description |
|
|
14
14
|
|---------|-------|-------------|
|
|
15
|
-
| `new` | `n` | Scaffold a new Stonyx project |
|
|
16
15
|
| `serve` | `s` | Bootstrap Stonyx and run the app |
|
|
17
16
|
| `test` | `t` | Bootstrap Stonyx in test mode and run tests |
|
|
18
17
|
| `help` | `h` | Show available commands |
|
|
19
18
|
|
|
20
|
-
### new
|
|
21
|
-
|
|
22
|
-
Scaffolds a new Stonyx project in the current directory. Prompts for a project name and which modules to include, then generates the project structure and runs `pnpm install`.
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
stonyx new # Prompts for project name
|
|
26
|
-
stonyx new my-app # Creates my-app/ in the current directory
|
|
27
|
-
```
|
|
28
|
-
|
|
29
19
|
### serve
|
|
30
20
|
|
|
31
21
|
Bootstraps Stonyx (loads config, initializes modules, runs lifecycle hooks), then imports your application entry point.
|
|
@@ -156,3 +156,35 @@ export default class DBModel extends Model {
|
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
Located at `config/db-schema.js`, referenced from `config/environment.js`.
|
|
159
|
+
|
|
160
|
+
## Store
|
|
161
|
+
|
|
162
|
+
The store is the in-memory data layer. Use it for internal app logic (not REST API consumers).
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
import Orm, { store, createRecord, updateRecord } from '@stonyx/orm';
|
|
166
|
+
|
|
167
|
+
// Read — sync, from memory (requires memory: true on model, which is the default)
|
|
168
|
+
const record = store.get('animal', 1);
|
|
169
|
+
const allAnimals = store.data.get('animals');
|
|
170
|
+
|
|
171
|
+
// Read — async, queries DB if memory: false
|
|
172
|
+
const record = await store.find('animal', 1);
|
|
173
|
+
const all = await store.findAll('animal');
|
|
174
|
+
|
|
175
|
+
// Create — adds to store and returns the record
|
|
176
|
+
const animal = createRecord('animal', { type: 'dog', age: 3, owner: 'angela' });
|
|
177
|
+
|
|
178
|
+
// Update — patches fields on an existing record
|
|
179
|
+
updateRecord(animal, { age: 4 });
|
|
180
|
+
|
|
181
|
+
// Delete
|
|
182
|
+
store.remove('animal', 1);
|
|
183
|
+
|
|
184
|
+
// Persist to disk — required when not using REST-triggered autosave
|
|
185
|
+
await Orm.db.save();
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**When to use `Orm.db.save()`**: The `autosave: 'onUpdate'` config only triggers on REST POST/PATCH/DELETE. When modifying data directly via `createRecord` / `updateRecord` in app code (not through REST), call `Orm.db.save()` explicitly to persist.
|
|
189
|
+
|
|
190
|
+
**Store vs REST**: Use `store` for internal app logic (session tracking, state management). Use REST request handlers for external API consumers. Both operate on the same in-memory data.
|
package/docs/modules.md
CHANGED
|
@@ -72,11 +72,7 @@ await waitForModule('rest-server'); // Waits for @stonyx/rest-server
|
|
|
72
72
|
| Module | Description |
|
|
73
73
|
|--------|-------------|
|
|
74
74
|
| [@stonyx/cron](https://github.com/abofs/stonyx-cron) | Lightweight async job scheduling with min-heap |
|
|
75
|
-
| [@stonyx/discord](https://github.com/abofs/stonyx-discord) | Discord bot with command and event handler auto-discovery |
|
|
76
|
-
| [@stonyx/events](https://github.com/abofs/stonyx-events) | Pub/sub event system |
|
|
77
|
-
| [@stonyx/oauth](https://github.com/abofs/stonyx-oauth) | OAuth provider integration |
|
|
78
|
-
| [@stonyx/orm](https://github.com/abofs/stonyx-orm) | ORM with models, relationships, serializers, and optional REST integration |
|
|
79
75
|
| [@stonyx/rest-server](https://github.com/abofs/stonyx-rest-server) | Dynamic REST server with auto-route registration |
|
|
80
|
-
| [@stonyx/
|
|
76
|
+
| [@stonyx/orm](https://github.com/abofs/stonyx-orm) | ORM with models, relationships, serializers, and optional REST integration |
|
|
81
77
|
|
|
82
78
|
See each module's repository for its specific documentation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stonyx",
|
|
3
|
-
"version": "0.2.3-alpha.
|
|
3
|
+
"version": "0.2.3-alpha.7",
|
|
4
4
|
"description": "Base stonyx framework module",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"url": "https://github.com/abofs/stonyx/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stonyx/utils": "0.2.3-beta.5",
|
|
34
33
|
"node-chronicle": "^0.2.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
36
|
+
"@stonyx/utils": "0.2.3-beta.7",
|
|
37
37
|
"qunit": "^2.24.1",
|
|
38
38
|
"sinon": "^21.0.0"
|
|
39
39
|
},
|
package/src/cli.js
CHANGED