@appweaver/core 1.0.3 → 1.0.4
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
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Appweaver - Core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
> The backend framework for AI-assisted development. Scaffold, extend, and ship APIs with any agent.
|
|
9
|
+
|
|
10
|
+
Appweaver is a batteries-included framework built on top of **Fastify** and **Prisma**, designed from the ground up to
|
|
11
|
+
be developed with AI agents. Instead of writing backend boilerplate from scratch, you describe resources using concise
|
|
12
|
+
factory functions and let the framework handle routing, validation, database, auth, migrations, so you can focus
|
|
13
|
+
on business logic instead of boilerplate.
|
|
14
|
+
|
|
15
|
+
### Why Appweaver for agentic development?
|
|
16
|
+
|
|
17
|
+
- **80% fewer tokens** → Appweaver's conventions and factory API eliminate the boilerplate that dominates most backend
|
|
18
|
+
codebases. Your agent reads and writes only the code that matters, not hundreds of lines of scaffolding.
|
|
19
|
+
- **Zero-code configuration** → every framework behavior like server, database, auth, queues, mailer, storage is
|
|
20
|
+
controlled through `appweaver.json` config files or environment variables. No code changes are needed to reconfigure
|
|
21
|
+
the app for a different environment.
|
|
22
|
+
- **Agent-first conventions** → a consistent, predictable project structure means agents always know where to find and
|
|
23
|
+
place code: models, services, routes, and policies each live in their own file under `src/resources/<name>/`.
|
|
24
|
+
- **Built-in skill files** → every scaffolded project ships with agent-readable skill files that give your agent harness
|
|
25
|
+
a complete map of the framework's API, conventions, and CLI, which means no hallucination, and no trial-and-error.
|
|
26
|
+
- **Works with any agent harness** → Claude Code, Cursor, Codex, Copilot Workspace, or any coding assistant that can
|
|
27
|
+
read project files. Point your agent at the skill files, and it has everything it needs.
|
|
4
28
|
|
|
5
29
|
## License
|
|
6
30
|
|
|
@@ -8,6 +8,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
8
8
|
const common_1 = require("@appweaver/common");
|
|
9
9
|
const context_1 = require("../context");
|
|
10
10
|
const resource_1 = require("../resource");
|
|
11
|
+
const security_1 = require("../security");
|
|
11
12
|
function createService(config, override = false) {
|
|
12
13
|
const name = (0, common_1.capitalize)(config.modelName || node_path_1.default.basename(node_path_1.default.dirname(__dirname)));
|
|
13
14
|
class Service extends resource_1.ResourceService {
|
|
@@ -65,21 +66,24 @@ function createService(config, override = false) {
|
|
|
65
66
|
async readRestrictions(action, data) {
|
|
66
67
|
const policy = (0, context_1.injectPolicy)(name);
|
|
67
68
|
if (policy.readRestrictions) {
|
|
68
|
-
|
|
69
|
+
const user = (0, security_1.currentAuthUser)() ?? null;
|
|
70
|
+
return policy.readRestrictions(user, data, action) ?? {};
|
|
69
71
|
}
|
|
70
72
|
return super.readRestrictions(action, data);
|
|
71
73
|
}
|
|
72
74
|
async writeRestrictions(action, data) {
|
|
73
75
|
const policy = (0, context_1.injectPolicy)(name);
|
|
74
76
|
if (policy.writeRestrictions) {
|
|
75
|
-
|
|
77
|
+
const user = (0, security_1.currentAuthUser)() ?? null;
|
|
78
|
+
return policy.writeRestrictions(user, data, action) ?? {};
|
|
76
79
|
}
|
|
77
80
|
return super.writeRestrictions(action, data);
|
|
78
81
|
}
|
|
79
82
|
async checkAccess(action, resource) {
|
|
80
83
|
const policy = (0, context_1.injectPolicy)(name);
|
|
81
84
|
if (policy?.checkAccess) {
|
|
82
|
-
|
|
85
|
+
const user = (0, security_1.currentAuthUser)() ?? null;
|
|
86
|
+
return policy.checkAccess(user, resource, action);
|
|
83
87
|
}
|
|
84
88
|
return super.checkAccess(action, resource);
|
|
85
89
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appweaver/core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Appweaver -
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Appweaver - the backend framework for AI-assisted development (@core)",
|
|
5
5
|
"author": "Luka Matosevic",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const common_1 = require("@appweaver/common");
|
|
4
|
-
const factory_1 = require("../../../factory");
|
|
5
4
|
const helper_1 = require("../../helper");
|
|
5
|
+
const factory_1 = require("../../../factory");
|
|
6
6
|
function authModelField() {
|
|
7
7
|
return (0, common_1.uncapitalize)((0, helper_1.resourceAuthModel)().name);
|
|
8
8
|
}
|
|
9
9
|
exports.default = common_1.config.SECURITY_API_KEY_ENABLED
|
|
10
10
|
? (0, factory_1.createPolicy)({
|
|
11
11
|
modelName: 'ApiKey',
|
|
12
|
-
checkAccess: (
|
|
12
|
+
checkAccess: (user, resource, action) => {
|
|
13
13
|
const authFieldName = authModelField();
|
|
14
|
-
const currentAuthId =
|
|
14
|
+
const currentAuthId = user.id;
|
|
15
15
|
if (action === 'create') {
|
|
16
16
|
return resource[authFieldName].id === currentAuthId;
|
|
17
17
|
}
|
|
@@ -19,8 +19,8 @@ exports.default = common_1.config.SECURITY_API_KEY_ENABLED
|
|
|
19
19
|
return resource[`${authFieldName}Id`] === currentAuthId;
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
readRestrictions: () => {
|
|
23
|
-
return { [authModelField()]: { id:
|
|
22
|
+
readRestrictions: (user) => {
|
|
23
|
+
return { [authModelField()]: { id: user.id } };
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
26
|
: undefined;
|