@fougere/defaults 0.17.4-alpha.0 → 0.18.0-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/storage/DeclaredStorage.d.ts +2 -2
- package/dist/storage/DeclaredStorage.d.ts.map +1 -1
- package/dist/storage/ResolvedStorage.d.ts.map +1 -1
- package/dist/storage/ResolvedStorage.js +5 -19
- package/dist/storage/ResolvedStorage.js.map +1 -1
- package/dist/storage/{Placement.d.ts → SourceEntities.d.ts} +2 -2
- package/dist/storage/SourceEntities.d.ts.map +1 -0
- package/dist/storage/SourceEntities.js +2 -0
- package/dist/storage/SourceEntities.js.map +1 -0
- package/package.json +8 -8
- package/src/storage/DeclaredStorage.ts +2 -2
- package/src/storage/ResolvedStorage.ts +7 -28
- package/src/storage/{Placement.ts → SourceEntities.ts} +1 -1
- package/dist/storage/Placement.d.ts.map +0 -1
- package/dist/storage/Placement.js +0 -2
- package/dist/storage/Placement.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type Source } from '@fougere/core';
|
|
2
2
|
import type { DbConfig } from './DbConfig.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SourceEntities } from './SourceEntities.js';
|
|
4
4
|
/** Does this config ask for persistence at all? */
|
|
5
5
|
export declare function declaresStorage(dbConf: DbConfig): boolean;
|
|
6
6
|
export interface DeclaredStorage {
|
|
7
7
|
/** The default source — where an entity no placement names lands. */
|
|
8
8
|
db: Source;
|
|
9
9
|
/** The other places. Absent means one source, the way it always was. */
|
|
10
|
-
sources?: Record<string,
|
|
10
|
+
sources?: Record<string, SourceEntities>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=DeclaredStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredStorage.d.ts","sourceRoot":"","sources":["../../src/storage/DeclaredStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DeclaredStorage.d.ts","sourceRoot":"","sources":["../../src/storage/DeclaredStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAIzD;AAED,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC1C"}
|
|
@@ -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;
|
|
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;AAIzC,OAAO,EAAiC,KAAK,UAAU,EAAe,MAAM,eAAe,CAAC;AAG5F,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;IAC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AC,EAAE,MAAM,GACZ,eAAe,CAgBjB;AAoCD,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,CAqFtE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,eAAe;IAE5C,cAAc,YAlMU,GAAG,QAAQ,MAAM,KAAK,GAAG;IAmMjD,QAAQ,gBA9Lc,MAAM,KAAK,MAAM;IA+LvC,SAAS,YAtLU,MAAM,KAAK,OAAO;IAuLrC,QAAQ,YArLU,MAAM,cAAc,UAAU,KAAK,OAAO;IAsL5D,UAAU,EAAwB,KAAK;IACvC,OAAO,SA9KO,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;EAgL1C"}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import '@fougere/adapter-sql/sqlite';
|
|
2
|
-
import { Fronds } from '@fougere/core';
|
|
3
2
|
import { lowerFirst } from '@fougere/core/contract';
|
|
4
3
|
import { existsSync } from 'node:fs';
|
|
5
4
|
import { isAbsolute, resolve } from 'node:path';
|
|
6
|
-
import { Logger, Sources } from '@fougere/core';
|
|
5
|
+
import { Logger, Sources, sourceViewOf } from '@fougere/core';
|
|
7
6
|
import { createMemorySource } from '@fougere/adapter-memory';
|
|
8
7
|
import { declaresStorage } from './DeclaredStorage.js';
|
|
9
|
-
/** The app as ONE source sees it. */
|
|
10
|
-
function viewOf(app, holds) {
|
|
11
|
-
const typed = app;
|
|
12
|
-
const fronds = typed.fronds
|
|
13
|
-
.map((frond) => ({ ...frond, entities: frond.entities.filter((entry) => holds(entry.name)) }))
|
|
14
|
-
.filter((frond) => frond.entities.length > 0);
|
|
15
|
-
return {
|
|
16
|
-
fronds,
|
|
17
|
-
// Lifted, because this function reads its app structurally on purpose — a caller
|
|
18
|
-
// may hand it a shape that is app-LIKE, and the question is still the same one.
|
|
19
|
-
elsewhere: Fronds.hosting(typed.fronds).entityNames().filter((name) => !holds(name)),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
8
|
/** Resolve the data layer. */
|
|
23
9
|
export function resolveStorage(dbConf, sources,
|
|
24
10
|
/**
|
|
@@ -126,9 +112,9 @@ export function storageFrom(declared) {
|
|
|
126
112
|
// which is what makes a cross-source `ref()` a miss rather than a constraint against a
|
|
127
113
|
// stranger. What a pass DOES is the source's own: it knows its engine, this does not.
|
|
128
114
|
migrate: async (app) => {
|
|
129
|
-
const said = [await base.migrate?.(
|
|
115
|
+
const said = [await base.migrate?.(sourceViewOf(app.fronds, (name) => !home.has(lowerFirst(name))))];
|
|
130
116
|
for (const [name, engine] of engines) {
|
|
131
|
-
said.push(await engine.migrate?.(
|
|
117
|
+
said.push(await engine.migrate?.(sourceViewOf(app.fronds, (e) => home.get(lowerFirst(e)) === name)));
|
|
132
118
|
}
|
|
133
119
|
const reports = said.filter((report) => Boolean(report));
|
|
134
120
|
return reports.length > 0 ? reports.join('\n') : undefined;
|
|
@@ -136,9 +122,9 @@ export function storageFrom(declared) {
|
|
|
136
122
|
// The same partition `migrate` writes through, read — so what the boot refuses is exactly
|
|
137
123
|
// what the command would create. A named source says its name; the default one needs none.
|
|
138
124
|
pending: async (app) => {
|
|
139
|
-
const lines = [...(await base.pending?.(
|
|
125
|
+
const lines = [...(await base.pending?.(sourceViewOf(app.fronds, (name) => !home.has(lowerFirst(name)))) ?? [])];
|
|
140
126
|
for (const [name, engine] of engines) {
|
|
141
|
-
const behind = await engine.pending?.(
|
|
127
|
+
const behind = await engine.pending?.(sourceViewOf(app.fronds, (e) => home.get(lowerFirst(e)) === name)) ?? [];
|
|
142
128
|
lines.push(...behind.map((line) => `${name}: ${line}`));
|
|
143
129
|
}
|
|
144
130
|
return lines;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvedStorage.js","sourceRoot":"","sources":["../../src/storage/ResolvedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":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E,CAAC,CAAC,CAAC;YACjH,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACrC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;gBAC/G,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QACD,sFAAsF;QACtF,qEAAqE;QACrE,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;gBAAE,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;YAC7E,MAAM,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAwB;IAC9C,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAmB;QACvC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Source } from '@fougere/core';
|
|
2
2
|
/** One source: what realizes it, and the entities that live there. */
|
|
3
|
-
export interface
|
|
3
|
+
export interface SourceEntities {
|
|
4
4
|
source: Source;
|
|
5
5
|
entities: string[];
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=SourceEntities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceEntities.d.ts","sourceRoot":"","sources":["../../src/storage/SourceEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceEntities.js","sourceRoot":"","sources":["../../src/storage/SourceEntities.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fougere/defaults",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-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,18 +29,18 @@
|
|
|
29
29
|
"src"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@fougere/core": "0.
|
|
33
|
-
"@fougere/adapter-sql": "0.
|
|
34
|
-
"@fougere/transport-http": "0.
|
|
35
|
-
"@fougere/container": "0.
|
|
36
|
-
"@fougere/compiler": "0.
|
|
37
|
-
"@fougere/adapter-memory": "0.
|
|
32
|
+
"@fougere/core": "0.18.0-alpha.0",
|
|
33
|
+
"@fougere/adapter-sql": "0.18.0-alpha.0",
|
|
34
|
+
"@fougere/transport-http": "0.18.0-alpha.0",
|
|
35
|
+
"@fougere/container": "0.18.0-alpha.0",
|
|
36
|
+
"@fougere/compiler": "0.18.0-alpha.0",
|
|
37
|
+
"@fougere/adapter-memory": "0.18.0-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@fougere/schema": "0.
|
|
43
|
+
"@fougere/schema": "0.18.0-alpha.0",
|
|
44
44
|
"kysely": "^0.28.17",
|
|
45
45
|
"better-sqlite3": "^13.0.3",
|
|
46
46
|
"@types/better-sqlite3": "^7.6.13"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Source } from '@fougere/core';
|
|
2
2
|
import type { DbConfig } from './DbConfig.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SourceEntities } from './SourceEntities.js';
|
|
4
4
|
|
|
5
5
|
/** Does this config ask for persistence at all? */
|
|
6
6
|
export function declaresStorage(dbConf: DbConfig): boolean {
|
|
@@ -13,5 +13,5 @@ export interface DeclaredStorage {
|
|
|
13
13
|
/** The default source — where an entity no placement names lands. */
|
|
14
14
|
db: Source;
|
|
15
15
|
/** The other places. Absent means one source, the way it always was. */
|
|
16
|
-
sources?: Record<string,
|
|
16
|
+
sources?: Record<string, SourceEntities>;
|
|
17
17
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import '@fougere/adapter-sql/sqlite';
|
|
2
2
|
import type { App } from '@fougere/core';
|
|
3
|
-
import { Fronds, type FrondDescriptor } from '@fougere/core';
|
|
4
3
|
import { lowerFirst } from '@fougere/core/contract';
|
|
5
4
|
import { existsSync } from 'node:fs';
|
|
6
5
|
import { isAbsolute, resolve } from 'node:path';
|
|
7
|
-
import { Logger, Sources, type Constraint, type Source
|
|
6
|
+
import { Logger, Sources, sourceViewOf, type Constraint, type Source } from '@fougere/core';
|
|
8
7
|
import { createMemorySource } from '@fougere/adapter-memory';
|
|
9
8
|
import { declaresStorage } from './DeclaredStorage.js';
|
|
10
9
|
import type { DbConfig } from './DbConfig.js';
|
|
11
10
|
import type { SourcesConfig } from './SourcesConfig.js';
|
|
12
|
-
import type {
|
|
11
|
+
import type { SourceEntities } from './SourceEntities.js';
|
|
13
12
|
import type { DeclaredStorage } from './DeclaredStorage.js';
|
|
14
13
|
|
|
15
14
|
export interface ResolvedStorage {
|
|
@@ -46,26 +45,6 @@ export interface ResolvedStorage {
|
|
|
46
45
|
/** Raw synchronous handle, when the engine exposes one. */
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
/** The app as ONE source sees it. */
|
|
50
|
-
function viewOf(
|
|
51
|
-
app: App,
|
|
52
|
-
holds: (name: string) => boolean,
|
|
53
|
-
): SourceView {
|
|
54
|
-
const typed = app as unknown as {
|
|
55
|
-
fronds: { name: string; entities: { name: string }[] }[];
|
|
56
|
-
};
|
|
57
|
-
const fronds = typed.fronds
|
|
58
|
-
.map((frond) => ({ ...frond, entities: frond.entities.filter((entry) => holds(entry.name)) }))
|
|
59
|
-
.filter((frond) => frond.entities.length > 0);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
fronds,
|
|
63
|
-
// Lifted, because this function reads its app structurally on purpose — a caller
|
|
64
|
-
// may hand it a shape that is app-LIKE, and the question is still the same one.
|
|
65
|
-
elsewhere: Fronds.hosting(typed.fronds as FrondDescriptor[]).entityNames().filter((name) => !holds(name)),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
48
|
/** Resolve the data layer. */
|
|
70
49
|
export function resolveStorage(
|
|
71
50
|
dbConf: DbConfig,
|
|
@@ -87,7 +66,7 @@ export function resolveStorage(
|
|
|
87
66
|
return storageFrom({ db: createMemorySource() });
|
|
88
67
|
}
|
|
89
68
|
|
|
90
|
-
const named: Record<string,
|
|
69
|
+
const named: Record<string, SourceEntities> = {};
|
|
91
70
|
for (const [name, conf] of Object.entries(sources ?? {})) {
|
|
92
71
|
named[name] = { source: built(conf, `sources.${name}`, root), entities: conf.entities };
|
|
93
72
|
}
|
|
@@ -192,9 +171,9 @@ export function storageFrom(declared: DeclaredStorage): ResolvedStorage {
|
|
|
192
171
|
// which is what makes a cross-source `ref()` a miss rather than a constraint against a
|
|
193
172
|
// stranger. What a pass DOES is the source's own: it knows its engine, this does not.
|
|
194
173
|
migrate: async (app) => {
|
|
195
|
-
const said = [await base.migrate?.(
|
|
174
|
+
const said = [await base.migrate?.(sourceViewOf(app.fronds, (name) => !home.has(lowerFirst(name))))];
|
|
196
175
|
for (const [name, engine] of engines) {
|
|
197
|
-
said.push(await engine.migrate?.(
|
|
176
|
+
said.push(await engine.migrate?.(sourceViewOf(app.fronds, (e) => home.get(lowerFirst(e)) === name)));
|
|
198
177
|
}
|
|
199
178
|
const reports = said.filter((report): report is string => Boolean(report));
|
|
200
179
|
|
|
@@ -203,9 +182,9 @@ export function storageFrom(declared: DeclaredStorage): ResolvedStorage {
|
|
|
203
182
|
// The same partition `migrate` writes through, read — so what the boot refuses is exactly
|
|
204
183
|
// what the command would create. A named source says its name; the default one needs none.
|
|
205
184
|
pending: async (app) => {
|
|
206
|
-
const lines = [...(await base.pending?.(
|
|
185
|
+
const lines = [...(await base.pending?.(sourceViewOf(app.fronds, (name) => !home.has(lowerFirst(name)))) ?? [])];
|
|
207
186
|
for (const [name, engine] of engines) {
|
|
208
|
-
const behind = await engine.pending?.(
|
|
187
|
+
const behind = await engine.pending?.(sourceViewOf(app.fronds, (e) => home.get(lowerFirst(e)) === name)) ?? [];
|
|
209
188
|
lines.push(...behind.map((line) => `${name}: ${line}`));
|
|
210
189
|
}
|
|
211
190
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Placement.d.ts","sourceRoot":"","sources":["../../src/storage/Placement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Placement.js","sourceRoot":"","sources":["../../src/storage/Placement.ts"],"names":[],"mappings":""}
|