@fougere/adapter-memory 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fougere contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @fougere/adapter-memory
2
+
3
+ > Rows in a Map — the source that ships no driver
4
+
5
+ What an app with no `db` runs on, and what a test runs on when the shape is the subject
6
+ and the engine is not.
7
+
8
+ ```ts
9
+ // fougere.config.ts
10
+ export default defineFougere({
11
+ db: { source: 'memory' },
12
+ sources: { cache: { source: 'memory', entities: ['Draft'] } },
13
+ });
14
+ ```
15
+
16
+ Nothing else to wire: importing this package is what makes `'memory'` an answered name.
17
+ `@fougere/app` already depends on it, so the fallback needs no declaration at all.
18
+
19
+ ## It answers the whole port
20
+
21
+ The thirteen gestures, not six — and it reads the axes, which is the difference between a
22
+ store and a stand-in. A `primary(text())` with no generator is refused rather than given an
23
+ invented `id`; `created()` is stamped; a second `create` on one key is refused instead of
24
+ overwriting in silence.
25
+
26
+ That is not written here. `storageOver` (`@fougere/core`) derives the thirteen from the four
27
+ below, so this package is the four:
28
+
29
+ ```ts
30
+ const store = new Map<string, Row>();
31
+
32
+ return {
33
+ client: store,
34
+ get: async (key) => store.get(key),
35
+ has: async (key) => store.has(key),
36
+ set: async (key, row) => { store.set(key, row); },
37
+ delete: async (key) => store.delete(key),
38
+ all: async () => [...store.values()],
39
+ };
40
+ ```
41
+
42
+ ## What it does not declare
43
+
44
+ No `transacted`: a Map has no unit of work. A
45
+ [frame](https://fougere.dev/docs/business/together) reads the absence, compensates instead of
46
+ transacting, and the boot says which of the two it built. No `migrate` either — a Map has no
47
+ shape to bring up to date.
48
+
49
+ Rows live for the life of the process and go with it. Nothing is written anywhere; for rows
50
+ that must survive a restart, see `@fougere/adapter-file`.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Rows in a Map — the source that ships no driver, in the ten lines the frame leaves.
3
+ *
4
+ * It is what an app with no `db` runs on, and what a test runs on when the shape is the
5
+ * subject and the engine is not. `storageOver` derives the thirteen gestures from the four
6
+ * below, so nothing about pages, criteria or lifecycle stamps is respelled here — three
7
+ * hand-written copies of this in the demos each answered six of the thirteen, forced the
8
+ * field name `id` and minted a uuid whatever the entity declared.
9
+ *
10
+ * No `transacted`: a Map has no unit of work, so a frame reads the absence and compensates
11
+ * instead of transacting (`boot/together.ts`), saying which of the two it built. No
12
+ * `migrate` either — a Map has no shape to bring up to date.
13
+ */
14
+ import { type Source } from '@fougere/core';
15
+ /** The whole port over a Map, per entity. */
16
+ export declare const createMemoryStorage: import("@fougere/core").StorageFactory;
17
+ export declare function setupMemory(): Source;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAA6C,KAAK,MAAM,EAAqB,MAAM,eAAe,CAAC;AAgB1G,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,wCAA+B,CAAC;AAEhE,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Rows in a Map — the source that ships no driver, in the ten lines the frame leaves.
3
+ *
4
+ * It is what an app with no `db` runs on, and what a test runs on when the shape is the
5
+ * subject and the engine is not. `storageOver` derives the thirteen gestures from the four
6
+ * below, so nothing about pages, criteria or lifecycle stamps is respelled here — three
7
+ * hand-written copies of this in the demos each answered six of the thirteen, forced the
8
+ * field name `id` and minted a uuid whatever the entity declared.
9
+ *
10
+ * No `transacted`: a Map has no unit of work, so a frame reads the absence and compensates
11
+ * instead of transacting (`boot/together.ts`), saying which of the two it built. No
12
+ * `migrate` either — a Map has no shape to bring up to date.
13
+ */
14
+ import { Sources, storageOver } from '@fougere/core';
15
+ /** One entity's rows. Held for the life of the process, released with nothing to close. */
16
+ function mapRows() {
17
+ const store = new Map();
18
+ return {
19
+ client: store,
20
+ get: async (key) => store.get(key),
21
+ has: async (key) => store.has(key),
22
+ set: async (key, row) => { store.set(key, row); },
23
+ delete: async (key) => store.delete(key),
24
+ all: async () => [...store.values()],
25
+ };
26
+ }
27
+ /** The whole port over a Map, per entity. */
28
+ export const createMemoryStorage = storageOver(() => mapRows());
29
+ export function setupMemory() {
30
+ return { storageFactory: createMemoryStorage, name: 'memory' };
31
+ }
32
+ Sources.register('memory', (_conf) => setupMemory());
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAuD,MAAM,eAAe,CAAC;AAE1G,2FAA2F;AAC3F,SAAS,OAAO;IACd,MAAM,KAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IAErC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QAClC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QAClC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;QACxC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAEhE,MAAM,UAAU,WAAW;IACzB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACjE,CAAC;AAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAmB,EAAU,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@fougere/adapter-memory",
3
+ "version": "0.6.0-alpha.0",
4
+ "description": "Rows in a Map — the source a first run meets, and the one that ships no driver.",
5
+ "keywords": [
6
+ "fougere",
7
+ "typescript",
8
+ "storage",
9
+ "in-memory",
10
+ "testing"
11
+ ],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/chok/fougere.git",
16
+ "directory": "packages/adapter/memory"
17
+ },
18
+ "type": "module",
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "src"
30
+ ],
31
+ "dependencies": {
32
+ "@fougere/core": "0.6.0-alpha.0",
33
+ "@fougere/schema": "0.6.0-alpha.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "build": "rm -rf dist && tsc",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "typecheck": "tsc --noEmit -p tsconfig.test.json"
43
+ }
44
+ }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Rows in a Map — the source that ships no driver, in the ten lines the frame leaves.
3
+ *
4
+ * It is what an app with no `db` runs on, and what a test runs on when the shape is the
5
+ * subject and the engine is not. `storageOver` derives the thirteen gestures from the four
6
+ * below, so nothing about pages, criteria or lifecycle stamps is respelled here — three
7
+ * hand-written copies of this in the demos each answered six of the thirteen, forced the
8
+ * field name `id` and minted a uuid whatever the entity declared.
9
+ *
10
+ * No `transacted`: a Map has no unit of work, so a frame reads the absence and compensates
11
+ * instead of transacting (`boot/together.ts`), saying which of the two it built. No
12
+ * `migrate` either — a Map has no shape to bring up to date.
13
+ */
14
+ import { Sources, storageOver, type Row, type Rows, type Source, type SourceConfig } from '@fougere/core';
15
+
16
+ /** One entity's rows. Held for the life of the process, released with nothing to close. */
17
+ function mapRows(): Rows {
18
+ const store = new Map<string, Row>();
19
+
20
+ return {
21
+ client: store,
22
+ get: async (key) => store.get(key),
23
+ has: async (key) => store.has(key),
24
+ set: async (key, row) => { store.set(key, row); },
25
+ delete: async (key) => store.delete(key),
26
+ all: async () => [...store.values()],
27
+ };
28
+ }
29
+
30
+ /** The whole port over a Map, per entity. */
31
+ export const createMemoryStorage = storageOver(() => mapRows());
32
+
33
+ export function setupMemory(): Source {
34
+ return { storageFactory: createMemoryStorage, name: 'memory' };
35
+ }
36
+
37
+ Sources.register('memory', (_conf: SourceConfig): Source => setupMemory());