@saena-io/content 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saena-io/content",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -27,6 +27,10 @@ import {
27
27
  // Public-site reads (a page's sections, or a collection's entries) for the host's SSR loaders to call directly —
28
28
  // public rendering is SSR in the route loader, not a client RPC.
29
29
  export { getPageContent, getSectionContent, getItemBySlug, listItems } from './service';
30
+ // Server-direct writes for scripts (seeding, imports) that hold a privileged RequestContext — symmetric with the
31
+ // reads above. Both enforce `content.manage`; a seed acts as a staff actor. The admin's own edits go through the
32
+ // plugin's RPC server fns (./contract), not these.
33
+ export { saveSection, saveItem } from './service';
30
34
  export type { SaveSectionInput, SaveCollectionItemInput, CollectionItemRecord } from './service';
31
35
 
32
36
  export const contentPlugin = definePlugin({
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { singletonMap } from './singleton';
3
+
4
+ // Regression guard for the bug that broke Content in scaffolded apps: when @saena-io/content is consumed as
5
+ // a published dependency, define.ts could load as two module instances, so a plain `new Map()` registry split
6
+ // in two. singletonMap anchors the Map on globalThis, so every instance shares it.
7
+ describe('singletonMap', () => {
8
+ it('returns the same Map for the same key (shared across callers)', () => {
9
+ const a = singletonMap<string, number>('content.test.shared');
10
+ a.set('x', 1);
11
+ const b = singletonMap<string, number>('content.test.shared');
12
+ expect(b).toBe(a);
13
+ expect(b.get('x')).toBe(1);
14
+ });
15
+
16
+ it('returns distinct Maps for different keys', () => {
17
+ const a = singletonMap('content.test.a');
18
+ const b = singletonMap('content.test.b');
19
+ expect(a).not.toBe(b);
20
+ });
21
+ });