primate 0.1.1 → 0.4.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 +4 -3
- package/package.json +9 -3
- package/source/client/Action.js +14 -19
- package/source/client/App.js +1 -4
- package/source/client/Client.js +14 -24
- package/source/client/Context.js +9 -15
- package/source/client/Element.js +12 -5
- package/source/client/Session.js +27 -0
- package/source/client/document.js +6 -0
- package/source/preset/primate.json +2 -6
- package/source/server/Action.js +53 -75
- package/source/server/App.js +26 -7
- package/source/server/Bundler.js +13 -16
- package/source/server/Context.js +64 -56
- package/source/server/{promises/Eager.js → EagerPromise.js} +3 -1
- package/source/server/File.js +6 -2
- package/source/server/Projector.js +86 -0
- package/source/server/Router.js +7 -9
- package/source/server/Session.js +9 -33
- package/source/server/attributes.js +2 -0
- package/source/server/conf.js +20 -26
- package/source/server/{Crypto.js → crypto.js} +0 -0
- package/source/server/domain/Domain.js +61 -56
- package/source/server/domain/Field.js +16 -13
- package/source/server/domain/domains.js +16 -0
- package/source/server/errors.js +0 -1
- package/source/server/exports.js +9 -8
- package/source/server/{utils/extend_object.js → extend_object.js} +0 -0
- package/source/server/invariants.js +0 -2
- package/source/server/sanitize.js +5 -0
- package/source/server/servers/Dynamic.js +19 -13
- package/source/server/servers/Static.js +25 -20
- package/source/server/servers/content-security-policy.json +0 -2
- package/source/server/store/Store.js +13 -0
- package/source/server/types/Date.js +2 -2
- package/source/server/types/Domain.js +0 -5
- package/source/server/types/Storeable.js +6 -7
- package/source/server/view/TreeNode.js +2 -0
- package/source/server/view/View.js +5 -0
- package/source/client/Base.js +0 -5
- package/source/server/Base.js +0 -35
- package/source/server/constructible.js +0 -8
- package/source/server/errors/Fallback.js +0 -1
- package/source/server/fallback.js +0 -11
- package/source/server/promises/Meta.js +0 -42
- package/source/server/promises.js +0 -2
package/source/server/Base.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import conf from "./conf.js";
|
|
2
|
-
import log from "./log.js";
|
|
3
|
-
import package_json from "../../package.json" assert {"type": "json" };
|
|
4
|
-
|
|
5
|
-
const _conf = conf();
|
|
6
|
-
let routes;
|
|
7
|
-
try {
|
|
8
|
-
routes = await import(`${_conf.root}/routes.json`, {
|
|
9
|
-
"assert": {"type": "json"}
|
|
10
|
-
});
|
|
11
|
-
} catch (error) {
|
|
12
|
-
// local routes.json not required
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default class Base {
|
|
16
|
-
static get conf() {
|
|
17
|
-
return _conf;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get conf() {
|
|
21
|
-
return this.Class().conf;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get package() {
|
|
25
|
-
return package_json;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get routes() {
|
|
29
|
-
return routes?.default ?? [];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Class() {
|
|
33
|
-
return this.constructor;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default class extends Error {}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const fallback = async (from, to, logic_from, logic_to) => {
|
|
2
|
-
try {
|
|
3
|
-
return await logic_from(from);
|
|
4
|
-
} catch (error) {
|
|
5
|
-
return logic_to(to);
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default (from, to, logic) => logic !== undefined
|
|
10
|
-
? fallback(from, to, logic, logic)
|
|
11
|
-
: fallback(undefined, undefined, from, to);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import Domain from "../domain/Domain.js";
|
|
2
|
-
|
|
3
|
-
const identity = value => value;
|
|
4
|
-
const by = {
|
|
5
|
-
"undefined": () => undefined,
|
|
6
|
-
"boolean": identity,
|
|
7
|
-
"string": identity,
|
|
8
|
-
"number": identity,
|
|
9
|
-
"array": identity,
|
|
10
|
-
"true_object": value => value instanceof Domain ? {} : value,
|
|
11
|
-
"object": value => by[Array.isArray(value) ? "array" : "true_object"](value),
|
|
12
|
-
};
|
|
13
|
-
const resolve_type = async (document, property) => {
|
|
14
|
-
if (document === undefined) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const resolved = await document[property];
|
|
18
|
-
return by[typeof resolved](resolved);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default async function resolve(document, projection = []) {
|
|
22
|
-
const resolved = {};
|
|
23
|
-
if (Array.isArray(document)) {
|
|
24
|
-
return Promise.all(document.map(sub => resolve(sub, projection)));
|
|
25
|
-
}
|
|
26
|
-
for (const property of projection) {
|
|
27
|
-
if (typeof property === "string") {
|
|
28
|
-
const result = await resolve_type(document, property);
|
|
29
|
-
if (result !== undefined) {
|
|
30
|
-
resolved[property] = result;
|
|
31
|
-
}
|
|
32
|
-
} else if (typeof property === "object") {
|
|
33
|
-
for (const property2 in property) {
|
|
34
|
-
const value = await document[property2];
|
|
35
|
-
if (value !== undefined) {
|
|
36
|
-
resolved[property2] = await resolve(value, property[property2]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return resolved;
|
|
42
|
-
}
|