@coffer-org/core 1.3.0 → 1.4.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/compose.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import type { ModuleDef } from '@coffer-org/sdk/module';
1
+ import type { ShelfDef } from '@coffer-org/sdk/shelf';
2
2
  import type { OptionItem } from '@coffer-org/sdk/fields';
3
- import type { VaultBundle } from '@coffer-org/sdk/vault';
3
+ import type { LibraryBundle } from '@coffer-org/sdk/library';
4
4
  import type { ExtendDef } from '@coffer-org/sdk/extend';
5
5
  import { type PluginManifest } from '@coffer-org/sdk/plugin';
6
6
  export interface Registry {
7
7
  order: PluginManifest[];
8
- vaults: VaultBundle[];
9
- modules: ModuleDef[];
8
+ libraries: LibraryBundle[];
9
+ shelves: ShelfDef[];
10
10
  extends_: ExtendDef[];
11
- getModule(vault: string, module: string): ModuleDef | undefined;
12
- getVault(id: string): VaultBundle | undefined;
13
- getExtendsFor(vault: string, module: string): ExtendDef[];
14
- getFieldOptions(vault: string, module: string, field: string): OptionItem[];
11
+ getShelf(library: string, shelf: string): ShelfDef | undefined;
12
+ getLibrary(id: string): LibraryBundle | undefined;
13
+ getExtendsFor(library: string, shelf: string): ExtendDef[];
14
+ getFieldOptions(library: string, shelf: string, field: string): OptionItem[];
15
15
  getOptionList(name: string): OptionItem[];
16
- getModuleOwner(vault: string, module: string): string | undefined;
16
+ getShelfOwner(library: string, shelf: string): string | undefined;
17
17
  }
18
18
  export declare function composeRegistry(plugins: PluginManifest[], opts?: {
19
19
  disabled?: Set<string>;
package/dist/compose.js CHANGED
@@ -1,19 +1,19 @@
1
- import { fieldEntries } from '@coffer-org/sdk/module';
1
+ import { fieldEntries } from '@coffer-org/sdk/shelf';
2
2
  import { bindSelectSourceZod } from '@coffer-org/sdk/fields';
3
3
  import { extendMatches } from '@coffer-org/sdk/extend';
4
4
  import { assemblePlugins } from '@coffer-org/sdk/plugin';
5
5
  export function composeRegistry(plugins, opts = {}) {
6
6
  const disabled = opts.disabled ?? new Set();
7
7
  const enabled = plugins.filter((p) => !disabled.has(p.id));
8
- const moduleOwner = new Map();
8
+ const shelfOwner = new Map();
9
9
  for (const p of enabled) {
10
- for (const v of p.vaults ?? [])
11
- for (const m of v.modules)
12
- moduleOwner.set(`${m.vault}/${m.module}`, p.id);
13
- for (const m of p.vaultModules ?? [])
14
- moduleOwner.set(`${m.vault}/${m.module}`, p.id);
10
+ for (const v of p.libraries ?? [])
11
+ for (const m of v.shelves)
12
+ shelfOwner.set(`${m.library}/${m.shelf}`, p.id);
13
+ for (const m of p.libraryShelves ?? [])
14
+ shelfOwner.set(`${m.library}/${m.shelf}`, p.id);
15
15
  }
16
- const getModuleOwner = (vault, module) => moduleOwner.get(`${vault}/${module}`);
16
+ const getShelfOwner = (library, shelf) => shelfOwner.get(`${library}/${shelf}`);
17
17
  for (const p of enabled) {
18
18
  for (const d of p.dependsOn) {
19
19
  if (disabled.has(d)) {
@@ -22,11 +22,11 @@ export function composeRegistry(plugins, opts = {}) {
22
22
  }
23
23
  }
24
24
  const assembled = assemblePlugins(enabled);
25
- const { order, vaults, modules, extends_ } = assembled;
25
+ const { order, libraries, shelves, extends_ } = assembled;
26
26
  const contribMap = new Map();
27
27
  for (const p of enabled) {
28
28
  for (const contrib of p.fieldContribs ?? []) {
29
- const key = `${contrib.vault}/${contrib.module}/${contrib.field}`;
29
+ const key = `${contrib.library}/${contrib.shelf}/${contrib.field}`;
30
30
  const acc = contribMap.get(key) ?? { options: [], suggestions: [] };
31
31
  if (contrib.options)
32
32
  acc.options.push(...contrib.options);
@@ -42,9 +42,9 @@ export function composeRegistry(plugins, opts = {}) {
42
42
  }
43
43
  }
44
44
  const getOptionList = (name) => optionListMap.get(name) ?? [];
45
- for (const m of modules) {
45
+ for (const m of shelves) {
46
46
  for (const [key, f] of fieldEntries(m.fields)) {
47
- const c = contribMap.get(`${m.vault}/${m.module}/${key}`);
47
+ const c = contribMap.get(`${m.library}/${m.shelf}/${key}`);
48
48
  if (!c)
49
49
  continue;
50
50
  if (c.options.length) {
@@ -59,7 +59,7 @@ export function composeRegistry(plugins, opts = {}) {
59
59
  }
60
60
  }
61
61
  const fieldOptionsMap = new Map();
62
- for (const m of modules) {
62
+ for (const m of shelves) {
63
63
  for (const [key, f] of fieldEntries(m.fields)) {
64
64
  const src = f.hints['source'];
65
65
  const base = f.options ?? [];
@@ -71,13 +71,13 @@ export function composeRegistry(plugins, opts = {}) {
71
71
  }
72
72
  if (resolved.length) {
73
73
  f.options = resolved;
74
- fieldOptionsMap.set(`${m.vault}/${m.module}/${key}`, resolved);
74
+ fieldOptionsMap.set(`${m.library}/${m.shelf}/${key}`, resolved);
75
75
  }
76
76
  }
77
77
  }
78
- const getModule = (vault, module) => modules.find((m) => m.vault === vault && m.module === module);
79
- const getVault = (id) => vaults.find((v) => v.meta.id === id);
80
- const getExtendsFor = (vault, module) => extends_.filter((e) => extendMatches(e, vault, module));
81
- const getFieldOptions = (vault, module, field) => fieldOptionsMap.get(`${vault}/${module}/${field}`) ?? [];
82
- return { order, vaults, modules, extends_, getModule, getVault, getExtendsFor, getFieldOptions, getOptionList, getModuleOwner };
78
+ const getShelf = (library, shelf) => shelves.find((m) => m.library === library && m.shelf === shelf);
79
+ const getLibrary = (id) => libraries.find((v) => v.meta.id === id);
80
+ const getExtendsFor = (library, shelf) => extends_.filter((e) => extendMatches(e, library, shelf));
81
+ const getFieldOptions = (library, shelf, field) => fieldOptionsMap.get(`${library}/${shelf}/${field}`) ?? [];
82
+ return { order, libraries, shelves, extends_, getShelf, getLibrary, getExtendsFor, getFieldOptions, getOptionList, getShelfOwner };
83
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffer-org/core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -24,6 +24,6 @@
24
24
  "postpack": "node ../../scripts/swap-exports.mjs src"
25
25
  },
26
26
  "dependencies": {
27
- "@coffer-org/sdk": "^1.3.0"
27
+ "@coffer-org/sdk": "^1.5.0"
28
28
  }
29
29
  }