primate 0.5.0 → 0.5.1
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 +3 -5
- package/debris.json +5 -0
- package/jsconfig.json +8 -0
- package/package.json +11 -5
- package/source/preset/primate.json +1 -3
- package/source/server/Action.js +3 -2
- package/source/server/App.js +1 -1
- package/source/server/File.js +4 -0
- package/source/server/Projector.js +1 -1
- package/source/server/domain/domains.js +1 -1
- package/source/server/invariants.js +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# Primate: a JavaScript framework
|
|
2
2
|
|
|
3
|
-
⚠️ **This software is currently its initial development phase. It is not
|
|
4
|
-
considered production-ready. Expect breakage.** ⚠️
|
|
5
|
-
|
|
6
3
|
Primate is a server-client JavaScript framework for web applications aimed at
|
|
7
4
|
relieving you of dealing with repetitive, error-prone tasks and letting you
|
|
8
5
|
concentrate on writing effective, expressive code.
|
|
@@ -10,7 +7,7 @@ concentrate on writing effective, expressive code.
|
|
|
10
7
|
## Installing
|
|
11
8
|
|
|
12
9
|
```
|
|
13
|
-
|
|
10
|
+
npm install primate
|
|
14
11
|
```
|
|
15
12
|
|
|
16
13
|
## Concepts
|
|
@@ -23,7 +20,8 @@ yarn add primate
|
|
|
23
20
|
* **Correct** data verification using field definitions in domains
|
|
24
21
|
* **Secure** serving hash-verified scripts on secure HTTP with a strong CSP
|
|
25
22
|
* **Roles** access control with contexts
|
|
26
|
-
* **Sessions** using cookies that are `
|
|
23
|
+
* **Sessions** using cookies that are `Secure`, `SameSite=Strict`, `HttpOnly`
|
|
24
|
+
and `Path`-limited
|
|
27
25
|
* **Sane defaults** minimally opinionated with good, overrideable defaults
|
|
28
26
|
for most features
|
|
29
27
|
* **Data linking** modeling `1:1`, `1:n` and `n:m` relationships on domains via
|
package/debris.json
ADDED
package/jsconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primate",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"author": "Primate core team <core@primatejs.com>",
|
|
5
5
|
"homepage": "https://primatejs.com",
|
|
6
6
|
"bugs": "https://adaptivecloud.dev/primate/primate/issues",
|
|
@@ -13,13 +13,19 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"copy": "rm -rf output && mkdir output && cp source/* output -a",
|
|
15
15
|
"instrument": "nyc instrument source ./output",
|
|
16
|
-
"
|
|
17
|
-
"coverage": "
|
|
18
|
-
"test": "
|
|
16
|
+
"debris": "node --experimental-json-modules node_modules/debris debris.json",
|
|
17
|
+
"coverage": "npm run instrument && nyc npm run debris",
|
|
18
|
+
"test": "npm run copy && npm run debris"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"debris": "^0.2.0",
|
|
22
|
+
"eslint": "^8.11.0",
|
|
23
|
+
"eslint-plugin-json": "^3.1.0",
|
|
24
|
+
"nyc": "^15.1.0"
|
|
19
25
|
},
|
|
20
26
|
"type": "module",
|
|
21
27
|
"exports": "./source/server/exports.js",
|
|
22
28
|
"engines": {
|
|
23
|
-
"node": ">=17.
|
|
29
|
+
"node": ">=17.7.2"
|
|
24
30
|
}
|
|
25
31
|
}
|
package/source/server/Action.js
CHANGED
|
@@ -2,7 +2,7 @@ import {resolve} from "path";
|
|
|
2
2
|
import {default as EagerPromise, eager} from "./EagerPromise.js";
|
|
3
3
|
import View from "./view/View.js";
|
|
4
4
|
import Projector from "./Projector.js";
|
|
5
|
-
import InternalServerError from "./errors
|
|
5
|
+
import {InternalServerError} from "./errors.js";
|
|
6
6
|
import {assert, defined} from "./invariants.js";
|
|
7
7
|
import sanitize from "./sanitize.js";
|
|
8
8
|
|
|
@@ -25,7 +25,8 @@ export default class Action {
|
|
|
25
25
|
const route = `${namespace}/${action}`;
|
|
26
26
|
const path = resolve(`${context.directory}/${route}.js`);
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
const {"default": UserAction} = await import(path);
|
|
29
|
+
return new UserAction(request, session, context);
|
|
29
30
|
} catch (error) {
|
|
30
31
|
throw new Error(`route \`${route}\` missing`);
|
|
31
32
|
}
|
package/source/server/App.js
CHANGED
|
@@ -6,7 +6,7 @@ import DynamicServer from "./servers/Dynamic.js";
|
|
|
6
6
|
import StaticServer from "./servers/Static.js";
|
|
7
7
|
import cache from "./cache.js";
|
|
8
8
|
import log from "./log.js";
|
|
9
|
-
import package_json from "../../package.json" assert {"type": "json"
|
|
9
|
+
import package_json from "../../package.json" assert {"type": "json"};
|
|
10
10
|
|
|
11
11
|
export default class App {
|
|
12
12
|
constructor(conf) {
|
package/source/server/File.js
CHANGED
|
@@ -72,7 +72,7 @@ export default class Projector {
|
|
|
72
72
|
return (await Promise.all(Object.keys(this.documents).map(async key => {
|
|
73
73
|
const resolved = this.projection[key] === undefined
|
|
74
74
|
? undefined
|
|
75
|
-
: await this.resolve(this.documents[key], this.projection[key]);
|
|
75
|
+
: await this.resolve(await this.documents[key], this.projection[key]);
|
|
76
76
|
return {key, resolved};
|
|
77
77
|
}))).reduce((projected, {key, resolved}) => {
|
|
78
78
|
if (resolved === undefined) {
|
|
@@ -4,7 +4,7 @@ import Field from "./Field.js";
|
|
|
4
4
|
import Domain from "./Domain.js";
|
|
5
5
|
|
|
6
6
|
const domains = {};
|
|
7
|
-
const base = conf().paths.
|
|
7
|
+
const base = conf().paths.domains;
|
|
8
8
|
|
|
9
9
|
for (const domain of await new File(base).list(".js")) {
|
|
10
10
|
const name = domain.slice(0, -3);
|
|
@@ -14,7 +14,7 @@ const assert = (predicate, error) => Boolean(predicate) || errored(error);
|
|
|
14
14
|
const is = {
|
|
15
15
|
"array": value => assert(Array.isArray(value), "must be array"),
|
|
16
16
|
"string": value => assert(typeof value === "string", "must be string"),
|
|
17
|
-
"defined": (value, error) => assert
|
|
17
|
+
"defined": (value, error) => assert(value !== undefined, error),
|
|
18
18
|
"undefined": value => assert(value === undefined, "must be undefined"),
|
|
19
19
|
"constructible": (value, error) => assert(constructible(value), error),
|
|
20
20
|
"instance": (object, Class) => assert(object instanceof Class,
|