@fougere/defaults 0.12.4-alpha.0 → 0.12.6-alpha.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/ResolvedStorage.d.ts +1 -1
- package/dist/storage/ResolvedStorage.d.ts.map +1 -1
- package/dist/storage/ResolvedStorage.js +8 -5
- package/dist/storage/ResolvedStorage.js.map +1 -1
- package/package.json +8 -7
- package/src/index.ts +7 -3
- package/src/storage/ResolvedStorage.ts +9 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOhE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACpF,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOhE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACpF,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,CAkBnF"}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,16 @@ export { layerOf, resolveStorage, storageFrom } from './storage/ResolvedStorage.
|
|
|
10
10
|
*/
|
|
11
11
|
export async function bootApp(root, opts = {}) {
|
|
12
12
|
const config = await loadConfig(root);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// What this process serves is never remote to it, whatever `fronds:` says of it elsewhere:
|
|
14
|
+
// `fougere serve blog` refused to start on a config that places `blog` at an address.
|
|
15
|
+
const served = new Set(opts.only ?? opts.fronds ?? []);
|
|
16
|
+
const elsewhere = Object.fromEntries(Object.entries(remotesOf(config)).filter(([frond]) => !served.has(frond)));
|
|
17
|
+
const useRemotes = (opts.topology ?? true) && Object.keys(elsewhere).length > 0;
|
|
15
18
|
return boot({
|
|
16
19
|
root,
|
|
17
20
|
only: opts.only ?? opts.fronds,
|
|
18
|
-
|
|
21
|
+
// `{}` and never undefined: `boot` reads the config's own `fronds:` when handed nothing.
|
|
22
|
+
remotes: useRemotes ? elsewhere : {},
|
|
19
23
|
remoteTransport: useRemotes ? (url) => createHttpTransport(url) : undefined,
|
|
20
24
|
// One resolver, one place that knows a storage package.
|
|
21
25
|
db: (cfg) => resolveStorage(cfg.db, cfg.sources, root),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAqBpF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,IAAI,GAAmB,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;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AAC"}
|
|
@@ -55,7 +55,7 @@ export declare function storageFrom(declared: DeclaredStorage): ResolvedStorage;
|
|
|
55
55
|
* Nuxt only: a member added here reached no host, and nothing said so. This is the same
|
|
56
56
|
* lesson one level down — a host spreads the layer instead of listing what it knows of it.
|
|
57
57
|
*/
|
|
58
|
-
export declare function layerOf(storage: ResolvedStorage
|
|
58
|
+
export declare function layerOf(storage: ResolvedStorage): {
|
|
59
59
|
storageFactory: ((entity: any, name: string) => any) | undefined;
|
|
60
60
|
sourceOf: ((entityName: string) => string) | undefined;
|
|
61
61
|
transacts: ((source: string) => boolean) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvedStorage.d.ts","sourceRoot":"","sources":["../../src/storage/ResolvedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKzC,OAAO,
|
|
1
|
+
{"version":3,"file":"ResolvedStorage.d.ts","sourceRoot":"","sources":["../../src/storage/ResolvedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKzC,OAAO,EAAmB,KAAK,UAAU,EAAgC,MAAM,eAAe,CAAC;AAG/F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,iGAAiG;IACjG,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC;IACjE;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE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LrC,QAAQ,YAzLU,MAAM,cAAc,UAAU,KAAK,OAAO;IA0L5D,UAAU,EAAwB,KAAK;IACvC,OAAO,SApLO,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;EAsL7C"}
|
|
@@ -3,7 +3,8 @@ import { Fronds } from '@fougere/core';
|
|
|
3
3
|
import { lowerFirst } from '@fougere/core/contract';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import { isAbsolute, resolve } from 'node:path';
|
|
6
|
-
import { Sources } from '@fougere/core';
|
|
6
|
+
import { Logger, Sources } from '@fougere/core';
|
|
7
|
+
import { createMemorySource } from '@fougere/adapter-memory';
|
|
7
8
|
import { declaresStorage } from './DeclaredStorage.js';
|
|
8
9
|
/** The app as ONE source sees it. */
|
|
9
10
|
function viewOf(app, holds) {
|
|
@@ -30,8 +31,10 @@ export function resolveStorage(dbConf, sources,
|
|
|
30
31
|
* seeds ran, and the app served an empty domain with a green boot.
|
|
31
32
|
*/
|
|
32
33
|
root) {
|
|
33
|
-
if (!declaresStorage(dbConf))
|
|
34
|
-
|
|
34
|
+
if (!declaresStorage(dbConf)) {
|
|
35
|
+
new Logger('storage').warn('no `db:` declared — rows live in memory and are gone when the process exits');
|
|
36
|
+
return storageFrom({ db: createMemorySource() });
|
|
37
|
+
}
|
|
35
38
|
const named = {};
|
|
36
39
|
for (const [name, conf] of Object.entries(sources ?? {})) {
|
|
37
40
|
named[name] = { source: built(conf, `sources.${name}`, root), entities: conf.entities };
|
|
@@ -144,9 +147,9 @@ export function storageFrom(declared) {
|
|
|
144
147
|
* Nuxt only: a member added here reached no host, and nothing said so. This is the same
|
|
145
148
|
* lesson one level down — a host spreads the layer instead of listing what it knows of it.
|
|
146
149
|
*/
|
|
147
|
-
export function layerOf(storage
|
|
150
|
+
export function layerOf(storage) {
|
|
148
151
|
return {
|
|
149
|
-
storageFactory: storage.storageFactory
|
|
152
|
+
storageFactory: storage.storageFactory,
|
|
150
153
|
sourceOf: storage.sourceOf,
|
|
151
154
|
transacts: storage.transacts,
|
|
152
155
|
enforces: storage.enforces,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvedStorage.js","sourceRoot":"","sources":["../../src/storage/ResolvedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,MAAM,EAAwB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAiD,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ResolvedStorage.js","sourceRoot":"","sources":["../../src/storage/ResolvedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,MAAM,EAAwB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAiD,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAsCvD,qCAAqC;AACrC,SAAS,MAAM,CACb,GAAQ,EACR,KAAgC;IAEhC,MAAM,KAAK,GAAG,GAEb,CAAC;IACF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;SACxB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fougere/defaults",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6-alpha.0",
|
|
4
4
|
"description": "The conventional boot of a Fougere app — the one place storage is wired.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fougere",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"src"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@fougere/
|
|
33
|
-
"@fougere/
|
|
34
|
-
"@fougere/
|
|
35
|
-
"@fougere/
|
|
36
|
-
"@fougere/
|
|
32
|
+
"@fougere/core": "0.12.6-alpha.0",
|
|
33
|
+
"@fougere/adapter-sql": "0.12.6-alpha.0",
|
|
34
|
+
"@fougere/compiler": "0.12.6-alpha.0",
|
|
35
|
+
"@fougere/transport-http": "0.12.6-alpha.0",
|
|
36
|
+
"@fougere/adapter-memory": "0.12.6-alpha.0",
|
|
37
|
+
"@fougere/container": "0.12.6-alpha.0"
|
|
37
38
|
},
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"kysely": "^0.28.17",
|
|
43
44
|
"better-sqlite3": "^13.0.3",
|
|
44
45
|
"@types/better-sqlite3": "^7.6.13",
|
|
45
|
-
"@fougere/schema": "0.12.
|
|
46
|
+
"@fougere/schema": "0.12.6-alpha.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"build": "rm -rf dist && tsc",
|
package/src/index.ts
CHANGED
|
@@ -34,13 +34,17 @@ export interface BootAppOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
export async function bootApp(root: string, opts: BootAppOptions = {}): Promise<App> {
|
|
36
36
|
const config = await loadConfig(root);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// What this process serves is never remote to it, whatever `fronds:` says of it elsewhere:
|
|
38
|
+
// `fougere serve blog` refused to start on a config that places `blog` at an address.
|
|
39
|
+
const served = new Set(opts.only ?? opts.fronds ?? []);
|
|
40
|
+
const elsewhere = Object.fromEntries(Object.entries(remotesOf(config)).filter(([frond]) => !served.has(frond)));
|
|
41
|
+
const useRemotes = (opts.topology ?? true) && Object.keys(elsewhere).length > 0;
|
|
39
42
|
|
|
40
43
|
return boot({
|
|
41
44
|
root,
|
|
42
45
|
only: opts.only ?? opts.fronds,
|
|
43
|
-
|
|
46
|
+
// `{}` and never undefined: `boot` reads the config's own `fronds:` when handed nothing.
|
|
47
|
+
remotes: useRemotes ? elsewhere : {},
|
|
44
48
|
remoteTransport: useRemotes ? (url) => createHttpTransport(url) : undefined,
|
|
45
49
|
// One resolver, one place that knows a storage package.
|
|
46
50
|
db: (cfg) => resolveStorage(cfg.db as DbConfig, (cfg as { sources?: unknown }).sources as never, root),
|
|
@@ -4,7 +4,8 @@ import { Fronds, type FrondDescriptor } from '@fougere/core';
|
|
|
4
4
|
import { lowerFirst } from '@fougere/core/contract';
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import { isAbsolute, resolve } from 'node:path';
|
|
7
|
-
import { Sources, type Constraint, type Source, type SourceView } from '@fougere/core';
|
|
7
|
+
import { Logger, Sources, type Constraint, type Source, type SourceView } from '@fougere/core';
|
|
8
|
+
import { createMemorySource } from '@fougere/adapter-memory';
|
|
8
9
|
import { declaresStorage } from './DeclaredStorage.js';
|
|
9
10
|
import type { DbConfig } from './DbConfig.js';
|
|
10
11
|
import type { SourcesConfig } from './SourcesConfig.js';
|
|
@@ -78,7 +79,11 @@ export function resolveStorage(
|
|
|
78
79
|
*/
|
|
79
80
|
root?: string,
|
|
80
81
|
): ResolvedStorage {
|
|
81
|
-
if (!declaresStorage(dbConf))
|
|
82
|
+
if (!declaresStorage(dbConf)) {
|
|
83
|
+
new Logger('storage').warn('no `db:` declared — rows live in memory and are gone when the process exits');
|
|
84
|
+
|
|
85
|
+
return storageFrom({ db: createMemorySource() });
|
|
86
|
+
}
|
|
82
87
|
|
|
83
88
|
const named: Record<string, Placement> = {};
|
|
84
89
|
for (const [name, conf] of Object.entries(sources ?? {})) {
|
|
@@ -206,9 +211,9 @@ export function storageFrom(declared: DeclaredStorage): ResolvedStorage {
|
|
|
206
211
|
* Nuxt only: a member added here reached no host, and nothing said so. This is the same
|
|
207
212
|
* lesson one level down — a host spreads the layer instead of listing what it knows of it.
|
|
208
213
|
*/
|
|
209
|
-
export function layerOf(storage: ResolvedStorage
|
|
214
|
+
export function layerOf(storage: ResolvedStorage) {
|
|
210
215
|
return {
|
|
211
|
-
storageFactory: storage.storageFactory
|
|
216
|
+
storageFactory: storage.storageFactory,
|
|
212
217
|
sourceOf: storage.sourceOf,
|
|
213
218
|
transacts: storage.transacts,
|
|
214
219
|
enforces: storage.enforces,
|