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 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
- yarn add primate
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 `HttpOnly`, `Secure` and `Path`-limited
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
@@ -0,0 +1,5 @@
1
+ {
2
+ "suites": "test/suites",
3
+ "fixtures": "test/fixtures",
4
+ "explicit": false
5
+ }
package/jsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "target": "esnext",
5
+ "module": "esnext"
6
+ },
7
+ "exclude": ["node_modules"]
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.5.0",
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
- "stick": "node --experimental-json-modules node_modules/stick stick.json",
17
- "coverage": "yarn instrument && nyc yarn run stick",
18
- "test": "yarn copy && yarn run stick"
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.3.0"
29
+ "node": ">=17.7.2"
24
30
  }
25
31
  }
@@ -17,9 +17,7 @@
17
17
  },
18
18
  "paths": {
19
19
  "client": "client",
20
- "data": {
21
- "domains": "domains"
22
- },
20
+ "domains": "domains",
23
21
  "public": "public",
24
22
  "server": "server",
25
23
  "static": "static"
@@ -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/InternalServer.js";
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
- return new (await import(path)).default(request, session, context);
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
  }
@@ -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) {
@@ -31,6 +31,10 @@ export default class File {
31
31
  return this.exists && !this.stats.isDirectory();
32
32
  }
33
33
 
34
+ get stream() {
35
+ return this.read_stream;
36
+ }
37
+
34
38
  get read_stream() {
35
39
  return fs.createReadStream(this.path, {"flags": "r"});
36
40
  }
@@ -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.data.domains;
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 (value !== undefined, error),
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,