foldkit-bundle-surface 0.4.2 → 0.5.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/README.md CHANGED
@@ -82,7 +82,7 @@ its path.
82
82
 
83
83
  A placement's state is part of the parent Model, so its fields are already in
84
84
  the application's ref tree. Observing one needs no bundle API:
85
- `App.model.search.query`, `App.model.search.select(projection)`.
85
+ `App.model.search.query`, `ModelRef.focus(App.model.search).select(projection)`.
86
86
 
87
87
  For an application with `search` and `filter` placements, the following
88
88
  integration fragment gives each mirror its own keys. Import `Mirror` from
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Option, Schema } from "effect";
2
2
  import { AnyMessage, AnyPlaced, AnyPlacedCollection, AnyWiring, Bundle, Link, Wrapper } from "foldkit-bundle";
3
3
  import { AppScope, Contract, FieldRef, Module, ModuleItem } from "foldkit-surface";
4
- //#region src/index.d.ts
5
4
  type AnyPlacement = AnyPlaced | AnyPlacedCollection;
6
5
  /** What an assembly lists: placements, collections, and integration wiring. */
7
6
  type AssemblyItems = {
@@ -59,6 +58,5 @@ export declare const BundleSurface: {
59
58
  readonly module: typeof module;
60
59
  readonly parent: typeof parent;
61
60
  };
62
- //#endregion
63
61
  export {};
64
62
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAwBK,eAAe,YAAY;;KAG3B;WAA2B,YAAY,cAAc,eAAe;;;;;;;cAcnE,OAAQ,MAAM,aAAa,oBAAoB,cAAY,KAC1D,SAAS,MAAM,QAAM,SACjB,QAAQ,KAAK,eAAa;WACf,QAAQ,QAAQ;MAAkB,KAAA,+BAAA,QAAA,KAAA,eAAA,OAAA;;;;;cAiBlD,WACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,WAClB,iBACV;;cAYG,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,UACnB,eAAa,iBACP,WAAW,YAAO,OAAA,MAAA,GAAA;;;;;cAa9B,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;EAYF,SAAA,UAAA,eAAa,iBAAkB,WAAW,YAAO,OAAA,MAAA,GAAA;;qBAK3D"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;KAyBK,eAAe,YAAY;;KAG3B;WAA2B,YAAY,cAAc,eAAe;;;;;;;cAcnE,OAAQ,MAAM,aAAa,oBAAoB,cAAY,KAC1D,SAAS,MAAM,QAAM,SACjB,QAAQ,KAAK,eAAa;WACf,QAAQ,QAAQ;MAAkB,KAAA,+BAAA,QAAA,KAAA,eAAA,OAAA;;;;;cAkBlD,WACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,WAClB,iBACV;;cAYG,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,UACnB,eAAa,iBACP,WAAW,YAAO,OAAA,MAAA,GAAA;;;;;cAa9B,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;EAYF,SAAA,UAAA,eAAa,iBAAkB,WAAW,YAAO,OAAA,MAAA,GAAA;;qBAK3D"}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Option } from "effect";
2
2
  import { Bundle, Link } from "foldkit-bundle";
3
- import { Module } from "foldkit-surface";
4
- //#region src/index.ts
3
+ import { ModelRef, Module } from "foldkit-surface";
4
+ // src/index.ts
5
5
  /**
6
6
  * foldkit-bundle assemblies in a foldkit-surface Module: each placement is a
7
7
  * contract that owns the Model path its Link points at, and each integration's
@@ -16,12 +16,13 @@ const wiringContract = (wiring) => wiring.contract === void 0 ? [] : [wiring.con
16
16
  * another application's ref is a `foreign-contract` finding.
17
17
  */
18
18
  const link = (ref, wrapper, options = {}) => {
19
+ const focus = ModelRef.focus(ref);
19
20
  return Link.make({
20
- read: (root) => Option.some(ref.get(root)),
21
- write: ref.set,
21
+ read: (root) => Option.some(focus.get(root)),
22
+ write: focus.set,
22
23
  wrapper,
23
- path: ref.dependency,
24
- owner: ref.owner,
24
+ path: focus.dependency,
25
+ owner: focus.owner,
25
26
  ...options
26
27
  });
27
28
  };
@@ -63,7 +64,6 @@ const BundleSurface = {
63
64
  module,
64
65
  parent
65
66
  };
66
- //#endregion
67
67
  export { BundleSurface };
68
68
 
69
69
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * foldkit-bundle assemblies in a foldkit-surface Module: each placement is a\n * contract that owns the Model path its Link points at, and each integration's\n * wiring brings its own contract, so `Module.validate` checks every owner in\n * the one list.\n */\nimport { Option, type Schema } from 'effect'\nimport {\n Bundle,\n Link,\n type AnyMessage,\n type AnyPlaced,\n type AnyPlacedCollection,\n type AnyWiring,\n type Wrapper,\n} from 'foldkit-bundle'\nimport {\n Module,\n type AppScope,\n type Contract,\n type FieldRef,\n type ModuleItem,\n} from 'foldkit-surface'\n\ntype AnyPlacement = AnyPlaced | AnyPlacedCollection\n\n/** What an assembly lists: placements, collections, and integration wiring. */\ntype AssemblyItems = { readonly placements: ReadonlyArray<AnyPlacement | AnyWiring> }\n\nconst isPlacement = (item: AnyPlacement | AnyWiring): item is AnyPlacement => 'link' in item\n\n// Wiring declares its contract loosely (as `object`) so foldkit-bundle need not\n// import Surface; every integration builds it from Surface's own `Contract`.\nconst wiringContract = (wiring: AnyWiring): ReadonlyArray<Contract> =>\n wiring.contract === undefined ? [] : [wiring.contract as Contract]\n\n/**\n * A Link from a Surface field ref: `App.model.search`. The contract of a\n * placement through it names the ref's application, so placing a child through\n * another application's ref is a `foreign-contract` finding.\n */\nconst link = <Root, Value, const Tag extends string, ChildMessage>(\n ref: FieldRef<Root, Value>,\n wrapper: Wrapper<Tag, ChildMessage>,\n options: { readonly when?: (parent: Root) => boolean } = {},\n) => {\n const made = Link.make<Root, Tag, Value, ChildMessage>({\n read: root => Option.some(ref.get(root)),\n write: ref.set,\n wrapper,\n path: ref.dependency,\n owner: ref.owner,\n ...options,\n })\n return made\n}\n\n/**\n * The contract of one placement or collection: it owns its Model path and names\n * the parent Message tags its Messages travel under.\n */\nconst contract = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n placement: AnyPlacement,\n): Contract => ({\n kind: 'bundle',\n name: placement.key,\n owner: ('owner' in placement.link ? placement.link.owner : undefined) ?? app.owner,\n owns: [placement.link.path],\n observes: [],\n messages: placement.link.messages,\n metadata:\n placement.argsSummary === undefined ? [] : [{ name: 'args', entries: [placement.argsSummary] }],\n})\n\n/** A Module of an assembly's placements and wiring, plus any other contracts of the application. */\nconst module = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n assembly: AssemblyItems,\n items: readonly ModuleItem<Root>[] = [],\n) =>\n Module.make(app, [\n ...assembly.placements.flatMap(item =>\n isPlacement(item) ? [contract(app, item)] : wiringContract(item),\n ),\n ...items,\n ])\n\n/**\n * The parent scope of `foldkit-bundle`, built from a Surface application, with\n * `module` bound to it: `const Page = BundleSurface.parent(App)`.\n */\nconst parent = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n) => {\n const scope = Bundle.parent({\n Model: app.Model as unknown as Schema.Codec<Root, unknown>,\n Message: app.Message as unknown as Schema.Codec<\n Schema.Schema.Type<typeof app.Message> & AnyMessage,\n unknown\n >,\n })\n return {\n ...scope,\n /** A Module of these placements and wiring plus the application's other contracts. */\n module: (assembly: AssemblyItems, items: readonly ModuleItem<Root>[] = []) =>\n module(app, assembly, items),\n }\n}\n\nexport const BundleSurface = { link, contract, module, parent } as const\n"],"mappings":";;;;;;;;;;AA6BA,MAAM,eAAe,SAAyD,UAAU;AAIxF,MAAM,kBAAkB,WACtB,OAAO,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,OAAO,QAAoB;;;;;;AAOnE,MAAM,QACJ,KACA,SACA,UAAyD,CAAC,MACvD;CASH,OARa,KAAK,KAAqC;EACrD,OAAM,SAAQ,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC;EACvC,OAAO,IAAI;EACX;EACA,MAAM,IAAI;EACV,OAAO,IAAI;EACX,GAAG;CACL,CACU;AACZ;;;;;AAMA,MAAM,YAKJ,KACA,eACc;CACd,MAAM;CACN,MAAM,UAAU;CAChB,QAAQ,WAAW,UAAU,OAAO,UAAU,KAAK,QAAQ,KAAA,MAAc,IAAI;CAC7E,MAAM,CAAC,UAAU,KAAK,IAAI;CAC1B,UAAU,CAAC;CACX,UAAU,UAAU,KAAK;CACzB,UACE,UAAU,gBAAgB,KAAA,IAAY,CAAC,IAAI,CAAC;EAAE,MAAM;EAAQ,SAAS,CAAC,UAAU,WAAW;CAAE,CAAC;AAClG;;AAGA,MAAM,UAKJ,KACA,UACA,QAAqC,CAAC,MAEtC,OAAO,KAAK,KAAK,CACf,GAAG,SAAS,WAAW,SAAQ,SAC7B,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,IAAI,eAAe,IAAI,CACjE,GACA,GAAG,KACL,CAAC;;;;;AAMH,MAAM,UAKJ,QACG;CAQH,OAAO;EACL,GARY,OAAO,OAAO;GAC1B,OAAO,IAAI;GACX,SAAS,IAAI;EAIf,CAES;;EAEP,SAAS,UAAyB,QAAqC,CAAC,MACtE,OAAO,KAAK,UAAU,KAAK;CAC/B;AACF;AAEA,MAAa,gBAAgB;CAAE;CAAM;CAAU;CAAQ;AAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * foldkit-bundle assemblies in a foldkit-surface Module: each placement is a\n * contract that owns the Model path its Link points at, and each integration's\n * wiring brings its own contract, so `Module.validate` checks every owner in\n * the one list.\n */\nimport { Option, type Schema } from 'effect'\nimport {\n Bundle,\n Link,\n type AnyMessage,\n type AnyPlaced,\n type AnyPlacedCollection,\n type AnyWiring,\n type Wrapper,\n} from 'foldkit-bundle'\nimport {\n ModelRef,\n Module,\n type AppScope,\n type Contract,\n type FieldRef,\n type ModuleItem,\n} from 'foldkit-surface'\n\ntype AnyPlacement = AnyPlaced | AnyPlacedCollection\n\n/** What an assembly lists: placements, collections, and integration wiring. */\ntype AssemblyItems = { readonly placements: ReadonlyArray<AnyPlacement | AnyWiring> }\n\nconst isPlacement = (item: AnyPlacement | AnyWiring): item is AnyPlacement => 'link' in item\n\n// Wiring declares its contract loosely (as `object`) so foldkit-bundle need not\n// import Surface; every integration builds it from Surface's own `Contract`.\nconst wiringContract = (wiring: AnyWiring): ReadonlyArray<Contract> =>\n wiring.contract === undefined ? [] : [wiring.contract as Contract]\n\n/**\n * A Link from a Surface field ref: `App.model.search`. The contract of a\n * placement through it names the ref's application, so placing a child through\n * another application's ref is a `foreign-contract` finding.\n */\nconst link = <Root, Value, const Tag extends string, ChildMessage>(\n ref: FieldRef<Root, Value>,\n wrapper: Wrapper<Tag, ChildMessage>,\n options: { readonly when?: (parent: Root) => boolean } = {},\n) => {\n const focus = ModelRef.focus(ref)\n const made = Link.make<Root, Tag, Value, ChildMessage>({\n read: root => Option.some(focus.get(root)),\n write: focus.set,\n wrapper,\n path: focus.dependency,\n owner: focus.owner,\n ...options,\n })\n return made\n}\n\n/**\n * The contract of one placement or collection: it owns its Model path and names\n * the parent Message tags its Messages travel under.\n */\nconst contract = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n placement: AnyPlacement,\n): Contract => ({\n kind: 'bundle',\n name: placement.key,\n owner: ('owner' in placement.link ? placement.link.owner : undefined) ?? app.owner,\n owns: [placement.link.path],\n observes: [],\n messages: placement.link.messages,\n metadata:\n placement.argsSummary === undefined ? [] : [{ name: 'args', entries: [placement.argsSummary] }],\n})\n\n/** A Module of an assembly's placements and wiring, plus any other contracts of the application. */\nconst module = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n assembly: AssemblyItems,\n items: readonly ModuleItem<Root>[] = [],\n) =>\n Module.make(app, [\n ...assembly.placements.flatMap(item =>\n isPlacement(item) ? [contract(app, item)] : wiringContract(item),\n ),\n ...items,\n ])\n\n/**\n * The parent scope of `foldkit-bundle`, built from a Surface application, with\n * `module` bound to it: `const Page = BundleSurface.parent(App)`.\n */\nconst parent = <\n Root,\n F extends Schema.Struct.Fields,\n Cases extends Record<string, Schema.Struct.Fields>,\n>(\n app: AppScope<Root, F, Cases>,\n) => {\n const scope = Bundle.parent({\n Model: app.Model as unknown as Schema.Codec<Root, unknown>,\n Message: app.Message as unknown as Schema.Codec<\n Schema.Schema.Type<typeof app.Message> & AnyMessage,\n unknown\n >,\n })\n return {\n ...scope,\n /** A Module of these placements and wiring plus the application's other contracts. */\n module: (assembly: AssemblyItems, items: readonly ModuleItem<Root>[] = []) =>\n module(app, assembly, items),\n }\n}\n\nexport const BundleSurface = { link, contract, module, parent } as const\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,eAAe,SAAyD,UAAU;AAIxF,MAAM,kBAAkB,WACtB,OAAO,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,OAAO,QAAoB;;;;;;AAOnE,MAAM,QACJ,KACA,SACA,UAAyD,CAAC,MACvD;CACH,MAAM,QAAQ,SAAS,MAAM,GAAG;CAShC,OARa,KAAK,KAAqC;EACrD,OAAM,SAAQ,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC;EACzC,OAAO,MAAM;EACb;EACA,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,GAAG;CACL,CACU;AACZ;;;;;AAMA,MAAM,YAKJ,KACA,eACc;CACd,MAAM;CACN,MAAM,UAAU;CAChB,QAAQ,WAAW,UAAU,OAAO,UAAU,KAAK,QAAQ,KAAA,MAAc,IAAI;CAC7E,MAAM,CAAC,UAAU,KAAK,IAAI;CAC1B,UAAU,CAAC;CACX,UAAU,UAAU,KAAK;CACzB,UACE,UAAU,gBAAgB,KAAA,IAAY,CAAC,IAAI,CAAC;EAAE,MAAM;EAAQ,SAAS,CAAC,UAAU,WAAW;CAAE,CAAC;AAClG;;AAGA,MAAM,UAKJ,KACA,UACA,QAAqC,CAAC,MAEtC,OAAO,KAAK,KAAK,CACf,GAAG,SAAS,WAAW,SAAQ,SAC7B,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,IAAI,eAAe,IAAI,CACjE,GACA,GAAG,KACL,CAAC;;;;;AAMH,MAAM,UAKJ,QACG;CAQH,OAAO;EACL,GARY,OAAO,OAAO;GAC1B,OAAO,IAAI;GACX,SAAS,IAAI;EAIf,CAES;;EAEP,SAAS,UAAyB,QAAqC,CAAC,MACtE,OAAO,KAAK,UAAU,KAAK;CAC/B;AACF;AAEA,MAAa,gBAAgB;CAAE;CAAM;CAAU;CAAQ;AAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-bundle-surface",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "foldkit-bundle placements as foldkit-surface Module contracts: each placement owns its Model path, validated with every other owner.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -37,21 +37,21 @@
37
37
  "LICENSE"
38
38
  ],
39
39
  "dependencies": {
40
- "foldkit-surface": "0.10.1",
41
- "foldkit-bundle": "0.8.1"
40
+ "foldkit-bundle": "0.9.0",
41
+ "foldkit-surface": "0.11.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "effect": "^4.0.0",
45
- "foldkit": "^0.169.0"
44
+ "effect": "^4.1.0",
45
+ "foldkit": "^0.170.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@effect/platform-browser": "^4.0.5",
49
- "effect": "^4.0.5",
50
- "foldkit": "0.169.0",
48
+ "@effect/platform-browser": "^4.1.0",
49
+ "effect": "^4.1.0",
50
+ "foldkit": "0.170.0",
51
51
  "jsdom": "30.1.3",
52
52
  "tsdown": "^0.23.1",
53
53
  "typescript": "7.0.2",
54
- "foldkit-mirror": "0.6.2"
54
+ "foldkit-mirror": "0.7.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsdown",