@primate/core 0.6.2 → 0.7.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/lib/private/App.d.ts +76 -149
- package/lib/private/App.js +22 -6
- package/lib/private/Flags.d.ts +5 -3
- package/lib/private/Flags.js +4 -2
- package/lib/private/app/Facade.d.ts +77 -156
- package/lib/private/app/Facade.js +4 -1
- package/lib/private/build/App.d.ts +4 -2
- package/lib/private/build/App.js +13 -4
- package/lib/private/build/client/index.js +24 -10
- package/lib/private/build/client/plugin/routes.d.ts +4 -0
- package/lib/private/build/client/plugin/routes.js +74 -0
- package/lib/private/build/hook.js +14 -6
- package/lib/private/build/index.d.ts +3 -2
- package/lib/private/build/index.js +9 -15
- package/lib/private/build/preclient/index.d.ts +3 -0
- package/lib/private/build/preclient/index.js +69 -0
- package/lib/private/build/preclient/plugin/routes.d.ts +4 -0
- package/lib/private/build/preclient/plugin/routes.js +44 -0
- package/lib/private/build/server/index.js +8 -5
- package/lib/private/build/server/plugin/assets.js +3 -3
- package/lib/private/build/server/plugin/native-addons.js +6 -8
- package/lib/private/build/server/plugin/node-imports.js +5 -7
- package/lib/private/build/server/plugin/route-client.d.ts +4 -0
- package/lib/private/build/server/plugin/route-client.js +110 -0
- package/lib/private/build/server/plugin/route.js +3 -10
- package/lib/private/build/server/plugin/virtual-pages.js +3 -3
- package/lib/private/build/server/plugin/virtual-routes.d.ts +2 -1
- package/lib/private/build/server/plugin/virtual-routes.js +27 -8
- package/lib/private/build/server/plugin/wasm.js +3 -2
- package/lib/private/client/Data.d.ts +1 -1
- package/lib/private/client/boot.js +2 -2
- package/lib/private/client/create-form.d.ts +11 -1
- package/lib/private/client/create-form.js +21 -3
- package/lib/private/client/index.d.ts +2 -2
- package/lib/private/client/navigate.d.ts +1 -0
- package/lib/private/client/navigate.js +7 -6
- package/lib/private/client/submit.d.ts +2 -1
- package/lib/private/client/submit.js +8 -7
- package/lib/private/client/{http.d.ts → transport.d.ts} +3 -3
- package/lib/private/client/{http.js → transport.js} +7 -9
- package/lib/private/config/schema.d.ts +5 -13
- package/lib/private/config/schema.js +1 -5
- package/lib/private/db/DB.d.ts +3 -1
- package/lib/private/db/MemoryDB.d.ts +5 -2
- package/lib/private/db/MemoryDB.js +33 -19
- package/lib/private/db/SQLDB.d.ts +23 -0
- package/lib/private/db/SQLDB.js +2 -0
- package/lib/private/db/errors.d.ts +74 -7
- package/lib/private/db/errors.js +31 -7
- package/lib/private/db/migrate/apply.js +8 -9
- package/lib/private/db/migrate/bundle.js +3 -2
- package/lib/private/db/migrate/create.js +18 -20
- package/lib/private/db/migrate/status.js +9 -10
- package/lib/private/db/migrate/store.d.ts +3 -3
- package/lib/private/db/migrate/store.js +5 -5
- package/lib/private/db/test.js +256 -115
- package/lib/private/db/testSQL.d.ts +50 -0
- package/lib/private/db/testSQL.js +196 -0
- package/lib/private/errors.d.ts +66 -9
- package/lib/private/errors.js +37 -16
- package/lib/private/frontend.d.ts +4 -4
- package/lib/private/frontend.js +11 -8
- package/lib/private/i18n/errors.d.ts +7 -1
- package/lib/private/i18n/errors.js +1 -1
- package/lib/private/i18n/index/types.d.ts +1 -1
- package/lib/private/i18n/locale.d.ts +1 -1
- package/lib/private/i18n/module.js +6 -5
- package/lib/private/index.d.ts +10 -2
- package/lib/private/index.js +13 -1
- package/lib/private/logger.d.ts +24 -0
- package/lib/private/logger.js +66 -0
- package/lib/private/module/Setup.d.ts +3 -0
- package/lib/private/module/create.d.ts +2 -1
- package/lib/private/module/create.js +4 -0
- package/lib/private/paths.d.ts +2 -3
- package/lib/private/paths.js +6 -12
- package/lib/private/request/ContentType.d.ts +3 -0
- package/lib/private/request/ContentType.js +2 -0
- package/lib/private/request/RequestBag.d.ts +2 -18
- package/lib/private/request/RequestBag.js +4 -16
- package/lib/private/request/RequestBody.d.ts +20 -28
- package/lib/private/request/RequestBody.js +63 -86
- package/lib/private/request/RequestFacade.d.ts +2 -2
- package/lib/private/request/handle.js +2 -2
- package/lib/private/request/parse.js +2 -4
- package/lib/private/request/route.js +15 -8
- package/lib/private/response/binary.d.ts +2 -2
- package/lib/private/response/binary.js +6 -6
- package/lib/private/response/error.js +6 -2
- package/lib/private/response/json.js +2 -2
- package/lib/private/response/null.d.ts +3 -0
- package/lib/private/response/null.js +6 -0
- package/lib/private/response/redirect.js +4 -3
- package/lib/private/response/respond.js +4 -4
- package/lib/private/response/sse.js +2 -2
- package/lib/private/response/text.js +2 -2
- package/lib/private/route/ContentTypeMap.d.ts +10 -0
- package/lib/private/route/ContentTypeMap.js +2 -0
- package/lib/private/route/Handler.d.ts +3 -2
- package/lib/private/route/NarrowedRequest.d.ts +23 -0
- package/lib/private/route/NarrowedRequest.js +2 -0
- package/lib/private/route/Options.d.ts +6 -1
- package/lib/private/route/Path.d.ts +2 -2
- package/lib/private/route/hook.d.ts +3 -1
- package/lib/private/route/hook.js +1 -2
- package/lib/private/route/router.d.ts +7 -11
- package/lib/private/route/router.js +13 -20
- package/lib/private/route.client.d.ts +36 -0
- package/lib/private/route.client.js +8 -0
- package/lib/private/route.d.ts +21 -5
- package/lib/private/route.js +21 -5
- package/lib/private/serve/App.d.ts +1 -2
- package/lib/private/serve/App.js +64 -58
- package/lib/private/serve/Init.d.ts +2 -0
- package/lib/private/serve/dev-module.js +2 -3
- package/lib/private/serve/index.js +5 -6
- package/lib/private/server/TAG.d.ts +1 -1
- package/lib/private/server/TAG.js +1 -1
- package/lib/private/session/index.d.ts +1 -1
- package/lib/private/session/index.js +3 -2
- package/lib/private/session/module.js +3 -3
- package/lib/private/session/schema.d.ts +3 -3
- package/lib/private/session/schema.js +4 -3
- package/lib/private/store/ExtractRelation.d.ts +7 -0
- package/lib/private/store/ExtractRelation.js +2 -0
- package/lib/private/store/ExtractSchema.d.ts +10 -0
- package/lib/private/{orm → store}/ForeignKey.d.ts +1 -1
- package/lib/private/store/Init.d.ts +13 -0
- package/lib/private/store/Init.js +2 -0
- package/lib/private/{orm/store.d.ts → store/Store.d.ts} +50 -50
- package/lib/private/{orm/store.js → store/Store.js} +163 -107
- package/lib/private/store/StoreInput.d.ts +11 -0
- package/lib/private/store/key.d.ts +8 -0
- package/lib/private/store/key.js +8 -0
- package/lib/private/{orm → store}/parse.d.ts +3 -3
- package/lib/private/{orm → store}/parse.js +7 -2
- package/lib/private/store/relation.d.ts +29 -0
- package/lib/private/store/relation.js +26 -0
- package/lib/private/store.d.ts +24 -0
- package/lib/private/store.js +10 -0
- package/lib/public/db/errors.d.ts +1 -1
- package/lib/public/db/errors.js +1 -1
- package/lib/public/db/testSQL.d.ts +2 -0
- package/lib/public/db/testSQL.js +2 -0
- package/lib/public/db.d.ts +1 -0
- package/lib/public/index.d.ts +1 -0
- package/lib/public/index.js +1 -1
- package/lib/public/response.d.ts +6 -6
- package/lib/public/response.js +4 -1
- package/lib/public/route.client.d.ts +2 -0
- package/lib/public/route.client.js +2 -0
- package/lib/public/store.d.ts +2 -0
- package/lib/public/store.js +2 -0
- package/package.json +24 -17
- package/lib/private/bye.d.ts +0 -3
- package/lib/private/bye.js +0 -4
- package/lib/private/log.d.ts +0 -20
- package/lib/private/log.js +0 -47
- package/lib/private/orm/ExtractSchema.d.ts +0 -9
- package/lib/private/orm/StoreInput.d.ts +0 -10
- package/lib/private/orm/key.d.ts +0 -8
- package/lib/private/orm/key.js +0 -8
- package/lib/private/orm/relation.d.ts +0 -43
- package/lib/private/orm/relation.js +0 -26
- package/lib/private/request/Verb.d.ts +0 -4
- package/lib/private/request/Verb.js +0 -2
- package/lib/private/request/verbs.d.ts +0 -3
- package/lib/private/request/verbs.js +0 -12
- package/lib/private/route/wrap.d.ts +0 -2
- package/lib/private/route/wrap.js +0 -12
- package/lib/public/log.d.ts +0 -2
- package/lib/public/log.js +0 -2
- package/lib/public/orm/key.d.ts +0 -2
- package/lib/public/orm/key.js +0 -2
- package/lib/public/orm/relation.d.ts +0 -2
- package/lib/public/orm/relation.js +0 -2
- package/lib/public/orm/store.d.ts +0 -2
- package/lib/public/orm/store.js +0 -2
- package/lib/public/request/verbs.d.ts +0 -2
- package/lib/public/request/verbs.js +0 -2
- /package/lib/private/{orm → store}/ExtractSchema.js +0 -0
- /package/lib/private/{orm → store}/ForeignKey.js +0 -0
- /package/lib/private/{orm → store}/PrimaryKey.d.ts +0 -0
- /package/lib/private/{orm → store}/PrimaryKey.js +0 -0
- /package/lib/private/{orm → store}/StoreInput.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import key from "#store/key";
|
|
2
|
+
import relation from "#store/relation";
|
|
3
|
+
import Store from "#store/Store";
|
|
4
|
+
function store(init) {
|
|
5
|
+
return new Store(init);
|
|
6
|
+
}
|
|
7
|
+
store.key = key;
|
|
8
|
+
store.relation = relation;
|
|
9
|
+
export default store;
|
|
10
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "#db/errors";
|
|
1
|
+
export { default, Code } from "#db/errors";
|
|
2
2
|
//# sourceMappingURL=errors.d.ts.map
|
package/lib/public/db/errors.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "#db/errors";
|
|
1
|
+
export { default, Code } from "#db/errors";
|
|
2
2
|
//# sourceMappingURL=errors.js.map
|
package/lib/public/db.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { default as PK } from "#db/PK";
|
|
|
5
5
|
export type { default as ReadArgs } from "#db/ReadArgs";
|
|
6
6
|
export type { default as ReadRelationsArgs } from "#db/ReadRelationsArgs";
|
|
7
7
|
export type { default as Sort } from "#db/Sort";
|
|
8
|
+
export type { ExtractPlaceholders, default as SQLDB, SQLInput, SQLOutput, CheckPlaceholders, } from "#db/SQLDB";
|
|
8
9
|
export type { default as TypeMap } from "#db/TypeMap";
|
|
9
10
|
export type { default as Types } from "#db/Types";
|
|
10
11
|
export type { default as With } from "#db/With";
|
package/lib/public/index.d.ts
CHANGED
package/lib/public/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { default } from "#index";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/public/response.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import binary from "#response/binary";
|
|
2
2
|
import error from "#response/error";
|
|
3
3
|
import view from "#response/view";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const _default: {
|
|
4
|
+
import $null from "#response/null";
|
|
5
|
+
declare const response: {
|
|
7
6
|
binary: typeof binary;
|
|
8
7
|
error: typeof error;
|
|
9
8
|
json: (body: unknown, init?: ResponseInit) => (app: import("./index.js").ServeApp) => import("@rcompat/type").MaybePromise<Response>;
|
|
10
|
-
redirect: (location: string, status?: 302 | 301 | 300 | 304 | 308 | 303 | 307) => import("
|
|
9
|
+
redirect: (location: string, status?: 302 | 301 | 300 | 304 | 308 | 303 | 307) => import("./index.js").ResponseFunction;
|
|
11
10
|
sse: (body: {
|
|
12
11
|
close?(): undefined;
|
|
13
12
|
open(events: {
|
|
@@ -16,7 +15,8 @@ declare const _default: {
|
|
|
16
15
|
}, init?: ResponseInit) => (app: import("./index.js").ServeApp) => import("@rcompat/type").MaybePromise<Response>;
|
|
17
16
|
text: (body: string, init?: ResponseInit) => (app: import("./index.js").ServeApp) => import("@rcompat/type").MaybePromise<Response>;
|
|
18
17
|
view: typeof view;
|
|
19
|
-
ws: (actions: import("@rcompat/http").Actions) => import("
|
|
18
|
+
ws: (actions: import("@rcompat/http").Actions) => import("./index.js").ResponseFunction;
|
|
19
|
+
null: typeof $null;
|
|
20
20
|
};
|
|
21
|
-
export default
|
|
21
|
+
export default response;
|
|
22
22
|
//# sourceMappingURL=response.d.ts.map
|
package/lib/public/response.js
CHANGED
|
@@ -6,7 +6,8 @@ import sse from "#response/sse";
|
|
|
6
6
|
import text from "#response/text";
|
|
7
7
|
import view from "#response/view";
|
|
8
8
|
import ws from "#response/ws";
|
|
9
|
-
|
|
9
|
+
import $null from "#response/null";
|
|
10
|
+
const response = {
|
|
10
11
|
binary,
|
|
11
12
|
error,
|
|
12
13
|
json,
|
|
@@ -15,5 +16,7 @@ export default {
|
|
|
15
16
|
text,
|
|
16
17
|
view,
|
|
17
18
|
ws,
|
|
19
|
+
null: $null,
|
|
18
20
|
};
|
|
21
|
+
export default response;
|
|
19
22
|
//# sourceMappingURL=response.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The universal web framework",
|
|
5
5
|
"homepage": "https://primate.run",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -18,23 +18,24 @@
|
|
|
18
18
|
"!/**/*.spec.*"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@rcompat/assert": "^0.
|
|
22
|
-
"@rcompat/cli": "^0.
|
|
23
|
-
"@rcompat/crypto": "^0.
|
|
24
|
-
"@rcompat/dict": "^0.
|
|
25
|
-
"@rcompat/env": "^0.
|
|
26
|
-
"@rcompat/error": "^0.
|
|
27
|
-
"@rcompat/fn": "^0.
|
|
28
|
-
"@rcompat/fs": "^0.
|
|
29
|
-
"@rcompat/http": "^0.
|
|
30
|
-
"@rcompat/io": "^0.
|
|
31
|
-
"@rcompat/is": "^0.
|
|
32
|
-
"@rcompat/kv": "^0.
|
|
33
|
-
"@rcompat/runtime": "^0.
|
|
34
|
-
"@rcompat/string": "^0.
|
|
35
|
-
"@rcompat/
|
|
21
|
+
"@rcompat/assert": "^0.13.0",
|
|
22
|
+
"@rcompat/cli": "^0.24.0",
|
|
23
|
+
"@rcompat/crypto": "^0.21.0",
|
|
24
|
+
"@rcompat/dict": "^0.10.0",
|
|
25
|
+
"@rcompat/env": "^0.22.0",
|
|
26
|
+
"@rcompat/error": "^0.8.0",
|
|
27
|
+
"@rcompat/fn": "^0.10.0",
|
|
28
|
+
"@rcompat/fs": "^0.33.2",
|
|
29
|
+
"@rcompat/http": "^0.30.0",
|
|
30
|
+
"@rcompat/io": "^0.10.0",
|
|
31
|
+
"@rcompat/is": "^0.11.0",
|
|
32
|
+
"@rcompat/kv": "^0.13.0",
|
|
33
|
+
"@rcompat/runtime": "^0.16.0",
|
|
34
|
+
"@rcompat/string": "^0.21.0",
|
|
35
|
+
"@rcompat/symbol": "^0.2.0",
|
|
36
|
+
"@rcompat/type": "^0.17.0",
|
|
36
37
|
"esbuild": "^0.28.0",
|
|
37
|
-
"pema": "^0.
|
|
38
|
+
"pema": "^0.7.0"
|
|
38
39
|
},
|
|
39
40
|
"imports": {
|
|
40
41
|
"#i18n/index": {
|
|
@@ -53,6 +54,12 @@
|
|
|
53
54
|
"browser": "./lib/private/app/Facade.browser.js",
|
|
54
55
|
"default": "./lib/public/AppFacade.js"
|
|
55
56
|
},
|
|
57
|
+
"./route": {
|
|
58
|
+
"types": "./lib/public/route.client.js",
|
|
59
|
+
"@primate/source": "./src/public/route.ts",
|
|
60
|
+
"browser": "./lib/public/route.client.js",
|
|
61
|
+
"default": "./lib/public/route.js"
|
|
62
|
+
},
|
|
56
63
|
"./*": {
|
|
57
64
|
"@primate/source": "./src/public/*.ts",
|
|
58
65
|
"default": "./lib/public/*.js"
|
package/lib/private/bye.d.ts
DELETED
package/lib/private/bye.js
DELETED
package/lib/private/log.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare const levels: {
|
|
2
|
-
readonly error: 0;
|
|
3
|
-
readonly info: 2;
|
|
4
|
-
readonly warn: 1;
|
|
5
|
-
};
|
|
6
|
-
type Levels = typeof levels;
|
|
7
|
-
type Level = keyof Levels;
|
|
8
|
-
type N = Levels[Level];
|
|
9
|
-
declare class Log {
|
|
10
|
-
#private;
|
|
11
|
-
constructor(level: N);
|
|
12
|
-
print(message: string, ...params: unknown[]): void;
|
|
13
|
-
system(message: string, ...params: unknown[]): void;
|
|
14
|
-
info(message: string, ...params: unknown[]): void;
|
|
15
|
-
warn(message: string, ...params: unknown[]): void;
|
|
16
|
-
error(error: unknown): void;
|
|
17
|
-
}
|
|
18
|
-
declare const _default: Log;
|
|
19
|
-
export default _default;
|
|
20
|
-
//# sourceMappingURL=log.d.ts.map
|
package/lib/private/log.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import color from "@rcompat/cli/color";
|
|
2
|
-
import mark from "@rcompat/cli/mark";
|
|
3
|
-
import print from "@rcompat/cli/print";
|
|
4
|
-
import { CodeError } from "@rcompat/error";
|
|
5
|
-
import runtime from "@rcompat/runtime";
|
|
6
|
-
import p from "pema";
|
|
7
|
-
const levels = {
|
|
8
|
-
error: 0,
|
|
9
|
-
info: 2,
|
|
10
|
-
warn: 1,
|
|
11
|
-
};
|
|
12
|
-
const flag = "--log=";
|
|
13
|
-
const n = runtime.args.find(arg => arg.startsWith(flag))?.slice(flag.length);
|
|
14
|
-
const vn = p.union(...Object.keys(levels)).optional().parse(n);
|
|
15
|
-
class Log {
|
|
16
|
-
#level;
|
|
17
|
-
constructor(level) {
|
|
18
|
-
this.#level = level;
|
|
19
|
-
}
|
|
20
|
-
print(message, ...params) {
|
|
21
|
-
print(mark(message, ...params));
|
|
22
|
-
}
|
|
23
|
-
system(message, ...params) {
|
|
24
|
-
print(` ${mark(message, ...params)}\n`);
|
|
25
|
-
}
|
|
26
|
-
info(message, ...params) {
|
|
27
|
-
if (this.#level === levels.info) {
|
|
28
|
-
print(color.green("[INFO]"), mark(message, ...params), "\n");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
warn(message, ...params) {
|
|
32
|
-
if (this.#level >= levels.warn) {
|
|
33
|
-
print(color.yellow("[WARN]"), mark(message, ...params), "\n");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
error(error) {
|
|
37
|
-
if (CodeError.is(error)) {
|
|
38
|
-
const message = error.strings.reduce((acc, str, i) => acc + (i > 0 ? color.bold(String(error.params[i - 1])) : "") + str, "");
|
|
39
|
-
print(color.red("[ERROR]"), message, "\n");
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.error(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export default new Log(n === undefined ? levels.warn : levels[vn]);
|
|
47
|
-
//# sourceMappingURL=log.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type ForeignKey from "#orm/ForeignKey";
|
|
2
|
-
import type PrimaryKey from "#orm/PrimaryKey";
|
|
3
|
-
import type StoreInput from "#orm/StoreInput";
|
|
4
|
-
import type { DataKey, Storable } from "pema";
|
|
5
|
-
type ExtractSchema<T extends StoreInput> = {
|
|
6
|
-
[K in keyof T]: T[K] extends PrimaryKey<infer P> ? P : T[K] extends ForeignKey<infer P> ? P : T[K] extends Storable<DataKey> ? T[K] : never;
|
|
7
|
-
};
|
|
8
|
-
export type { ExtractSchema as default };
|
|
9
|
-
//# sourceMappingURL=ExtractSchema.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type ForeignKey from "#orm/ForeignKey";
|
|
2
|
-
import type { AllowedFKType } from "#orm/ForeignKey";
|
|
3
|
-
import type PrimaryKey from "#orm/PrimaryKey";
|
|
4
|
-
import type { AllowedPKType } from "#orm/PrimaryKey";
|
|
5
|
-
import type { Dict } from "@rcompat/type";
|
|
6
|
-
import type { DataKey, Storable } from "pema";
|
|
7
|
-
type StoreField = Storable<DataKey> | PrimaryKey<AllowedPKType> | ForeignKey<AllowedFKType>;
|
|
8
|
-
type StoreInput = Dict<StoreField>;
|
|
9
|
-
export type { StoreInput as default };
|
|
10
|
-
//# sourceMappingURL=StoreInput.d.ts.map
|
package/lib/private/orm/key.d.ts
DELETED
package/lib/private/orm/key.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Store } from "#orm/store";
|
|
2
|
-
import type StoreInput from "#orm/StoreInput";
|
|
3
|
-
/**
|
|
4
|
-
* extracts schema type from either a schema or a Store.
|
|
5
|
-
*/
|
|
6
|
-
type SchemaOf<T> = T extends Store<infer S, any> ? S : T;
|
|
7
|
-
/**
|
|
8
|
-
* One relation (singular) - returns single record or null
|
|
9
|
-
*
|
|
10
|
-
* Normal: FK is on the OTHER table, pointing to this table's PK.
|
|
11
|
-
* Author has one Profile -> Profile has author_id
|
|
12
|
-
*
|
|
13
|
-
* Reverse: FK is on THIS table, pointing to other table's PK.
|
|
14
|
-
* Profile belongs to Author -> Profile has author_id
|
|
15
|
-
*/
|
|
16
|
-
export type OneRelation<T extends StoreInput, FK extends string> = {
|
|
17
|
-
type: "one";
|
|
18
|
-
schema: T;
|
|
19
|
-
fk: FK;
|
|
20
|
-
reverse: boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Many relation (plural) - returns array of records
|
|
24
|
-
*
|
|
25
|
-
* FK is always on the OTHER table, pointing to this table's PK.
|
|
26
|
-
* Example: Author has many Articles → Article has author_id
|
|
27
|
-
*/
|
|
28
|
-
export type ManyRelation<T extends StoreInput, FK extends string> = {
|
|
29
|
-
type: "many";
|
|
30
|
-
schema: T;
|
|
31
|
-
fk: FK;
|
|
32
|
-
};
|
|
33
|
-
export type Relation = OneRelation<any, string> | ManyRelation<any, string>;
|
|
34
|
-
declare function one<T extends StoreInput | Store<StoreInput, any>, FK extends string>(input: T, fk: FK, options?: {
|
|
35
|
-
reverse?: boolean;
|
|
36
|
-
}): OneRelation<SchemaOf<T>, FK>;
|
|
37
|
-
declare function many<T extends StoreInput | Store<StoreInput, any>, FK extends string>(input: T, fk: FK): ManyRelation<SchemaOf<T>, FK>;
|
|
38
|
-
declare const _default: {
|
|
39
|
-
one: typeof one;
|
|
40
|
-
many: typeof many;
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
|
43
|
-
//# sourceMappingURL=relation.d.ts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import is from "@rcompat/is";
|
|
2
|
-
function is_store(value) {
|
|
3
|
-
return is.dict(value) && "schema" in value && is.function(value.get);
|
|
4
|
-
}
|
|
5
|
-
function extract_schema(schema_or_store) {
|
|
6
|
-
return (is_store(schema_or_store)
|
|
7
|
-
? schema_or_store.schema
|
|
8
|
-
: schema_or_store);
|
|
9
|
-
}
|
|
10
|
-
function one(input, fk, options) {
|
|
11
|
-
return {
|
|
12
|
-
type: "one",
|
|
13
|
-
schema: extract_schema(input),
|
|
14
|
-
fk,
|
|
15
|
-
reverse: options?.reverse ?? false,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function many(input, fk) {
|
|
19
|
-
return {
|
|
20
|
-
type: "many",
|
|
21
|
-
schema: extract_schema(input),
|
|
22
|
-
fk,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export default { one, many };
|
|
26
|
-
//# sourceMappingURL=relation.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import string from "@rcompat/string";
|
|
2
|
-
export default function wrap(code, path, build_id) {
|
|
3
|
-
const router = `ROUTER_${build_id}`;
|
|
4
|
-
const prelude = string.dedent `
|
|
5
|
-
import ${router} from "primate/router";
|
|
6
|
-
${router}.push("${path}");
|
|
7
|
-
`;
|
|
8
|
-
const postlude = `\n${router}.pop();\n`;
|
|
9
|
-
return `${prelude}${code}${postlude}`;
|
|
10
|
-
}
|
|
11
|
-
;
|
|
12
|
-
//# sourceMappingURL=wrap.js.map
|
package/lib/public/log.d.ts
DELETED
package/lib/public/log.js
DELETED
package/lib/public/orm/key.d.ts
DELETED
package/lib/public/orm/key.js
DELETED
package/lib/public/orm/store.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|