@platforma-sdk/block-tools 2.13.0 → 2.14.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.
Files changed (68) hide show
  1. package/dist/cli.js +12 -12
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +727 -648
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/cmd/build-kind-manifest.d.ts +7 -0
  6. package/dist/config-CtXMWNgm.js +3 -0
  7. package/dist/config-CtXMWNgm.js.map +1 -0
  8. package/dist/{config-CiC347sB.mjs → config-Dx45aFJ_.mjs} +792 -456
  9. package/dist/config-Dx45aFJ_.mjs.map +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/index.mjs +15 -15
  12. package/dist/structure/engine/api.d.ts +1 -1
  13. package/dist/structure/rules/kind-package-json.d.ts +3 -0
  14. package/dist/structure/rules/kind.d.ts +1 -0
  15. package/dist/v2/build_kind_dist.d.ts +25 -0
  16. package/dist/v2/index.d.ts +4 -0
  17. package/dist/v2/kind/resolve-refs.d.ts +63 -0
  18. package/dist/v2/kind/version-match.d.ts +23 -0
  19. package/dist/v2/model/block_description.d.ts +8 -1
  20. package/dist/v2/publish-block.d.ts +23 -0
  21. package/dist/v2/registry/index.d.ts +2 -0
  22. package/dist/v2/registry/kind_resolver.d.ts +121 -0
  23. package/dist/v2/registry/registry.d.ts +23 -0
  24. package/dist/v2/registry/registry_reader.d.ts +34 -1
  25. package/dist/v2/registry/schema_kinds.d.ts +632 -0
  26. package/dist/v2/registry/schema_public.d.ts +72 -0
  27. package/package.json +10 -10
  28. package/src/cli.test.ts +2 -1
  29. package/src/cli.ts +2 -0
  30. package/src/cmd/build-kind-manifest.ts +41 -0
  31. package/src/cmd/publish.ts +10 -1
  32. package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -0
  33. package/src/structure/engine/api.ts +1 -1
  34. package/src/structure/engine/ctx.ts +1 -0
  35. package/src/structure/engine/discovery.ts +16 -2
  36. package/src/structure/rules/block-package-json.ts +18 -0
  37. package/src/structure/rules/kind-package-json.ts +117 -0
  38. package/src/structure/rules/kind.ts +29 -0
  39. package/src/structure/rules/model-package-json.ts +8 -0
  40. package/src/structure/rules/model.ts +15 -13
  41. package/src/structure/rules/shared/pascal-case.ts +1 -1
  42. package/src/structure/structure-definition.ts +2 -0
  43. package/src/structure/templates/static/kind/.oxfmtrc.json +4 -0
  44. package/src/structure/templates/static/kind/.oxlintrc.json +3 -0
  45. package/src/structure/templates/static/kind/src/index.ts +49 -0
  46. package/src/structure/templates/static/kind/tsconfig.json +10 -0
  47. package/src/structure/templates/text/model/src/index.tpl.ts +18 -0
  48. package/src/v2/build_dist.ts +35 -0
  49. package/src/v2/build_kind_dist.ts +104 -0
  50. package/src/v2/from_pack_v2.test.ts +2 -2
  51. package/src/v2/index.ts +4 -0
  52. package/src/v2/kind/resolve-refs.ts +150 -0
  53. package/src/v2/kind/version-match.test.ts +60 -0
  54. package/src/v2/kind/version-match.ts +55 -0
  55. package/src/v2/model/block_description.ts +15 -4
  56. package/src/v2/publish-block.ts +60 -0
  57. package/src/v2/registry/index.ts +2 -0
  58. package/src/v2/registry/kind_resolver.test.ts +123 -0
  59. package/src/v2/registry/kind_resolver.ts +190 -0
  60. package/src/v2/registry/registry.test.ts +247 -1
  61. package/src/v2/registry/registry.ts +227 -4
  62. package/src/v2/registry/registry_reader.ts +68 -0
  63. package/src/v2/registry/schema_kinds.test.ts +65 -0
  64. package/src/v2/registry/schema_kinds.ts +169 -0
  65. package/dist/config-BmJWc8sR.js +0 -3
  66. package/dist/config-BmJWc8sR.js.map +0 -1
  67. package/dist/config-CiC347sB.mjs.map +0 -1
  68. package/src/structure/templates/static/model/src/index.ts +0 -13
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./config-BmJWc8sR.js`);var t=e.wt({GlobalOverviewPath:()=>e.r,MetaFile:()=>e.i,PlPackageConfigData:()=>e.c,PlPackageJsonConfigFile:()=>e.l,PlPackageYamlConfigFile:()=>e.u,PlRegCommonConfigData:()=>e.d,PlRegFullPackageConfigData:()=>e.f,PlRegPackageConfig:()=>e.t,PlRegPackageConfigDataShard:()=>e.p,packageContentPrefix:()=>e.a,packageOverviewPath:()=>e.o,payloadFilePath:()=>e.s});exports.BlockDescriptionPackageJsonField=e.G,exports.BlockPackFolderName=e.K,exports.BlockRegistryV2=e.b,exports.ChannelNameRegexp=e.x,exports.ChannelsFolder=e.S,exports.FSStorage=e.h,exports.GlobalOverviewFileName=e.C,exports.GlobalOverviewGzFileName=e.w,exports.GlobalOverviewGzPath=e.T,exports.GlobalOverviewPath=e.E,exports.MainPrefix=e.D,exports.ManifestFileName=e.O,exports.ManifestSuffix=e.k,exports.PackageManifestPattern=e.A,exports.PackageOverview=e.j,exports.PackageOverviewFileName=e.M,exports.PackageOverviewVersionEntry=e.N,exports.PublishedCoordsFileName=e.V,Object.defineProperty(exports,`RegistryV1`,{enumerable:!0,get:function(){return t}}),exports.RegistryV2Reader=e.v,exports.S3Storage=e.g,exports.absoluteToBase64=e.ft,exports.absoluteToBytes=e.pt,exports.absoluteToString=e.mt,exports.addRelativePathPrefix=e.$,exports.blockComponentsManifestToAbsoluteUrl=e.nt,exports.buildBlockPackDist=e.Q,exports.buildPublishedCoords=e.H,exports.consolidateBlockComponents=e.rt,exports.consolidateBlockPackDescription=e.et,exports.consolidateBlockPackMeta=e.ot,exports.cpAbsoluteToRelative=e.ht,exports.embedBlockPackMetaAbsoluteBase64=e.st,exports.embedBlockPackMetaAbsoluteBytes=e.ct,exports.embedBlockPackMetaBytes=e.lt,exports.folderReaderByUrl=e.m,exports.inferUpdateSuggestions=e.y,exports.loadPackDescription=e.q,exports.loadPackDescriptionFromManifest=e.J,exports.loadPackDescriptionRaw=e.Y,exports.mapLocalToAbsolute=e.gt,exports.packFolderToRelativeTgz=e._t,exports.packageChannelPrefix=e.P,exports.packageChannelPrefixInsideV2=e.F,exports.packageContentPrefix=e.I,exports.packageContentPrefixInsideV2=e.L,exports.packageOverviewPath=e.R,exports.packageOverviewPathInsideV2=e.z,exports.parseGlobalOverviewReg=e.B,exports.parsePackageName=e.X,exports.relativeToContentString=e.vt,exports.relativeToExplicitBinary64=e.yt,exports.relativeToExplicitBytes=e.bt,exports.relativeToExplicitString=e.xt,exports.resolveBlockComponents=e.it,exports.resolveBlockPackDescription=e.tt,exports.resolveBlockPackMeta=e.ut,exports.resolveManifestBlockComponents=e.at,exports.resolveManifestBlockPackMeta=e.dt,exports.resolveModuleFile=e.St,exports.resolveModuleFolder=e.Ct,exports.resolveToRegistry=e.U,exports.storageByUrl=e._,exports.tryLoadPackDescription=e.Z,exports.writePublishedCoords=e.W;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./config-CtXMWNgm.js`);var t=e.Yt({GlobalOverviewPath:()=>e.r,MetaFile:()=>e.i,PlPackageConfigData:()=>e.c,PlPackageJsonConfigFile:()=>e.l,PlPackageYamlConfigFile:()=>e.u,PlRegCommonConfigData:()=>e.d,PlRegFullPackageConfigData:()=>e.f,PlRegPackageConfig:()=>e.t,PlRegPackageConfigDataShard:()=>e.p,packageContentPrefix:()=>e.a,packageOverviewPath:()=>e.o,payloadFilePath:()=>e.s});exports.BlockDescriptionPackageJsonField=e.mt,exports.BlockPackFolderName=e.ht,exports.BlockRegistryV2=e.w,exports.ChannelNameRegexp=e.T,exports.ChannelsFolder=e.E,exports.FSStorage=e.h,exports.GlobalOverviewFileName=e.D,exports.GlobalOverviewGzFileName=e.O,exports.GlobalOverviewGzPath=e.k,exports.GlobalOverviewPath=e.A,exports.KindImplementer=e.tt,exports.KindManifest=e.nt,exports.KindManifestFile=e.xt,exports.KindManifestFileInfo=e.rt,exports.KindManifestFileName=e.it,exports.KindManifestIdentity=e.at,exports.KindOverview=e.ot,exports.KindOverviewFileName=e.st,exports.KindOverviewPathPattern=e.ct,exports.KindResolutionError=e.b,exports.KindVersionMismatchError=e.X,exports.KindVersionOverview=e.lt,exports.KindsPrefix=e.ut,exports.MainPrefix=e.j,exports.ManifestFileName=e.M,exports.ManifestSuffix=e.N,exports.PackageManifestPattern=e.P,exports.PackageOverview=e.F,exports.PackageOverviewFileName=e.I,exports.PackageOverviewVersionEntry=e.L,exports.PublishedCoordsFileName=e.G,Object.defineProperty(exports,`RegistryV1`,{enumerable:!0,get:function(){return t}}),exports.RegistryV2Reader=e.v,exports.S3Storage=e.g,exports.absoluteToBase64=e.Lt,exports.absoluteToBytes=e.Rt,exports.absoluteToString=e.zt,exports.addRelativePathPrefix=e.wt,exports.blockComponentsManifestToAbsoluteUrl=e.Dt,exports.buildBlockPackDist=e.Ct,exports.buildKindDist=e.St,exports.buildPublishedCoords=e.K,exports.checkKindVersionMatch=e.Z,exports.consolidateBlockComponents=e.Ot,exports.consolidateBlockPackDescription=e.Tt,exports.consolidateBlockPackMeta=e.jt,exports.cpAbsoluteToRelative=e.Bt,exports.embedBlockPackMetaAbsoluteBase64=e.Mt,exports.embedBlockPackMetaAbsoluteBytes=e.Nt,exports.embedBlockPackMetaBytes=e.Pt,exports.folderReaderByUrl=e.m,exports.inferUpdateSuggestions=e.y,exports.kindContentPrefix=e.dt,exports.kindOverviewPath=e.ft,exports.loadPackDescription=e.gt,exports.loadPackDescriptionFromManifest=e._t,exports.loadPackDescriptionRaw=e.vt,exports.mapLocalToAbsolute=e.Vt,exports.npmNameToKindPath=e.pt,exports.packFolderToRelativeTgz=e.Ht,exports.packageChannelPrefix=e.R,exports.packageChannelPrefixInsideV2=e.z,exports.packageContentPrefix=e.B,exports.packageContentPrefixInsideV2=e.V,exports.packageOverviewPath=e.H,exports.packageOverviewPathInsideV2=e.U,exports.parseGlobalOverviewReg=e.W,exports.parsePackageName=e.yt,exports.parseSelector=e.x,exports.publishBlock=e.Y,exports.readFacadeKindDependency=e.Q,exports.readModelCompiledKindRef=e.$,exports.relativeToContentString=e.Ut,exports.relativeToExplicitBinary64=e.Wt,exports.relativeToExplicitBytes=e.Gt,exports.relativeToExplicitString=e.Kt,exports.resolveBlockComponents=e.kt,exports.resolveBlockPackDescription=e.Et,exports.resolveBlockPackMeta=e.Ft,exports.resolveFacadeKind=e.et,exports.resolveKind=e.S,exports.resolveManifestBlockComponents=e.At,exports.resolveManifestBlockPackMeta=e.It,exports.resolveModuleFile=e.qt,exports.resolveModuleFolder=e.Jt,exports.resolveToRegistry=e.q,exports.selectorToRange=e.C,exports.storageByUrl=e._,exports.tryLoadPackDescription=e.bt,exports.writePublishedCoords=e.J;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import { $ as e, A as t, B as n, C as r, Ct as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, M as m, N as h, O as g, P as _, Q as v, R as y, S as b, St as x, T as S, U as C, V as w, W as T, X as E, Y as D, Z as O, _ as k, _t as A, a as j, at as M, b as N, bt as P, c as F, ct as I, d as L, dt as R, et as z, f as B, ft as V, g as H, gt as U, h as W, ht as G, i as K, it as q, j as J, k as Y, l as X, lt as Z, m as Q, mt as $, nt as ee, o as te, ot as ne, p as re, pt as ie, q as ae, r as oe, rt as se, s as ce, st as le, t as ue, tt as de, u as fe, ut as pe, v as me, vt as he, w as ge, wt as _e, x as ve, xt as ye, y as be, yt as xe, z as Se } from "./config-CiC347sB.mjs";
1
+ import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as g, I as _, It as v, J as y, Jt as b, K as x, Kt as S, L as C, Lt as w, M as T, Mt as E, N as D, Nt as O, O as k, Ot as A, P as j, Pt as M, Q as N, R as P, Rt as F, S as I, St as L, T as R, Tt as z, U as B, Ut as V, V as H, Vt as U, W, Wt as G, X as K, Y as q, Yt as J, Z as Y, _ as X, _t as Z, a as Q, at as $, b as ee, bt as te, c as ne, ct as re, d as ie, dt as ae, et as oe, f as se, ft as ce, g as le, gt as ue, h as de, ht as fe, i as pe, it as me, j as he, jt as ge, k as _e, kt as ve, l as ye, lt as be, m as xe, mt as Se, nt as Ce, o as we, ot as Te, p as Ee, pt as De, q as Oe, qt as ke, r as Ae, rt as je, s as Me, st as Ne, t as Pe, tt as Fe, u as Ie, ut as Le, v as Re, vt as ze, w as Be, wt as Ve, x as He, xt as Ue, y as We, yt as Ge, z as Ke, zt as qe } from "./config-Dx45aFJ_.mjs";
2
2
  //#region src/registry_v1/index.ts
3
- var Ce = /* @__PURE__ */ _e({
4
- GlobalOverviewPath: () => oe,
5
- MetaFile: () => K,
6
- PlPackageConfigData: () => F,
7
- PlPackageJsonConfigFile: () => X,
8
- PlPackageYamlConfigFile: () => fe,
9
- PlRegCommonConfigData: () => L,
10
- PlRegFullPackageConfigData: () => B,
11
- PlRegPackageConfig: () => ue,
12
- PlRegPackageConfigDataShard: () => re,
13
- packageContentPrefix: () => j,
14
- packageOverviewPath: () => te,
15
- payloadFilePath: () => ce
3
+ var Je = /* @__PURE__ */ J({
4
+ GlobalOverviewPath: () => Ae,
5
+ MetaFile: () => pe,
6
+ PlPackageConfigData: () => ne,
7
+ PlPackageJsonConfigFile: () => ye,
8
+ PlPackageYamlConfigFile: () => Ie,
9
+ PlRegCommonConfigData: () => ie,
10
+ PlRegFullPackageConfigData: () => se,
11
+ PlRegPackageConfig: () => Pe,
12
+ PlRegPackageConfigDataShard: () => Ee,
13
+ packageContentPrefix: () => Q,
14
+ packageOverviewPath: () => we,
15
+ payloadFilePath: () => Me
16
16
  });
17
17
  //#endregion
18
- export { c as BlockDescriptionPackageJsonField, f as BlockPackFolderName, N as BlockRegistryV2, ve as ChannelNameRegexp, b as ChannelsFolder, W as FSStorage, r as GlobalOverviewFileName, ge as GlobalOverviewGzFileName, S as GlobalOverviewGzPath, o as GlobalOverviewPath, a as MainPrefix, g as ManifestFileName, Y as ManifestSuffix, t as PackageManifestPattern, J as PackageOverview, m as PackageOverviewFileName, h as PackageOverviewVersionEntry, w as PublishedCoordsFileName, Ce as RegistryV1, me as RegistryV2Reader, H as S3Storage, V as absoluteToBase64, ie as absoluteToBytes, $ as absoluteToString, e as addRelativePathPrefix, ee as blockComponentsManifestToAbsoluteUrl, v as buildBlockPackDist, l as buildPublishedCoords, se as consolidateBlockComponents, z as consolidateBlockPackDescription, ne as consolidateBlockPackMeta, G as cpAbsoluteToRelative, le as embedBlockPackMetaAbsoluteBase64, I as embedBlockPackMetaAbsoluteBytes, Z as embedBlockPackMetaBytes, Q as folderReaderByUrl, be as inferUpdateSuggestions, ae as loadPackDescription, d as loadPackDescriptionFromManifest, D as loadPackDescriptionRaw, U as mapLocalToAbsolute, A as packFolderToRelativeTgz, _ as packageChannelPrefix, s as packageChannelPrefixInsideV2, u as packageContentPrefix, p as packageContentPrefixInsideV2, y as packageOverviewPath, Se as packageOverviewPathInsideV2, n as parseGlobalOverviewReg, E as parsePackageName, he as relativeToContentString, xe as relativeToExplicitBinary64, P as relativeToExplicitBytes, ye as relativeToExplicitString, q as resolveBlockComponents, de as resolveBlockPackDescription, pe as resolveBlockPackMeta, M as resolveManifestBlockComponents, R as resolveManifestBlockPackMeta, x as resolveModuleFile, i as resolveModuleFolder, C as resolveToRegistry, k as storageByUrl, O as tryLoadPackDescription, T as writePublishedCoords };
18
+ export { Se as BlockDescriptionPackageJsonField, fe as BlockPackFolderName, Be as BlockRegistryV2, R as ChannelNameRegexp, l as ChannelsFolder, de as FSStorage, s as GlobalOverviewFileName, k as GlobalOverviewGzFileName, _e as GlobalOverviewGzPath, t as GlobalOverviewPath, Fe as KindImplementer, Ce as KindManifest, Ue as KindManifestFile, je as KindManifestFileInfo, me as KindManifestFileName, $ as KindManifestIdentity, Te as KindOverview, Ne as KindOverviewFileName, re as KindOverviewPathPattern, ee as KindResolutionError, K as KindVersionMismatchError, be as KindVersionOverview, Le as KindsPrefix, he as MainPrefix, T as ManifestFileName, D as ManifestSuffix, j as PackageManifestPattern, d as PackageOverview, _ as PackageOverviewFileName, C as PackageOverviewVersionEntry, p as PublishedCoordsFileName, Je as RegistryV1, Re as RegistryV2Reader, le as S3Storage, w as absoluteToBase64, F as absoluteToBytes, qe as absoluteToString, Ve as addRelativePathPrefix, c as blockComponentsManifestToAbsoluteUrl, o as buildBlockPackDist, L as buildKindDist, x as buildPublishedCoords, Y as checkKindVersionMatch, A as consolidateBlockComponents, z as consolidateBlockPackDescription, ge as consolidateBlockPackMeta, i as cpAbsoluteToRelative, E as embedBlockPackMetaAbsoluteBase64, O as embedBlockPackMetaAbsoluteBytes, M as embedBlockPackMetaBytes, xe as folderReaderByUrl, We as inferUpdateSuggestions, ae as kindContentPrefix, ce as kindOverviewPath, ue as loadPackDescription, Z as loadPackDescriptionFromManifest, ze as loadPackDescriptionRaw, U as mapLocalToAbsolute, De as npmNameToKindPath, g as packFolderToRelativeTgz, P as packageChannelPrefix, Ke as packageChannelPrefixInsideV2, r as packageContentPrefix, H as packageContentPrefixInsideV2, h as packageOverviewPath, B as packageOverviewPathInsideV2, W as parseGlobalOverviewReg, Ge as parsePackageName, He as parseSelector, q as publishBlock, N as readFacadeKindDependency, e as readModelCompiledKindRef, V as relativeToContentString, G as relativeToExplicitBinary64, m as relativeToExplicitBytes, S as relativeToExplicitString, ve as resolveBlockComponents, u as resolveBlockPackDescription, f as resolveBlockPackMeta, oe as resolveFacadeKind, I as resolveKind, n as resolveManifestBlockComponents, v as resolveManifestBlockPackMeta, ke as resolveModuleFile, b as resolveModuleFolder, Oe as resolveToRegistry, a as selectorToRange, X as storageByUrl, te as tryLoadPackDescription, y as writePublishedCoords };
19
19
 
20
20
  //# sourceMappingURL=index.mjs.map
@@ -1,5 +1,5 @@
1
1
  import { ContentForm, ManagedBody, RunMode, Structure, TriggerFn } from './ir';
2
- export type Scope = "root" | "block" | "model" | "ui" | "workflow" | "test" | "software";
2
+ export type Scope = "root" | "block" | "model" | "ui" | "workflow" | "test" | "software" | "kind";
3
3
  /** Variables describing a block — populated by `init` or parsed by
4
4
  * `check`/`refresh` from the block's package.json `name`. */
5
5
  export type BlockVars = {
@@ -0,0 +1,3 @@
1
+ import { RunContext } from '../engine/api';
2
+ export declare function kindPackageJsonInitial(ctx: RunContext): Record<string, unknown>;
3
+ export declare function kindPackageJsonRules(): void;
@@ -0,0 +1 @@
1
+ export declare function kindRules(): void;
@@ -0,0 +1,25 @@
1
+ import { KindManifest } from './registry/schema_kinds';
2
+ export interface BuildKindDistOptions {
3
+ /** Kind package directory (the dir containing `package.json`, `src/`, `dist/`). */
4
+ modulePath?: string;
5
+ /** Source directory hashed into `sourceHash`, relative to `modulePath`. */
6
+ srcDir?: string;
7
+ /** Output directory holding the compiled bundle and receiving `manifest.json`. */
8
+ dst?: string;
9
+ /** Compiled entry file name inside `dst` (rolldown emits `kind.js`). */
10
+ entryFileName?: string;
11
+ }
12
+ export type { KindManifest, KindManifestIdentity, KindManifestFileInfo, } from './registry/schema_kinds';
13
+ export declare const KindManifestFile = "manifest.json";
14
+ /**
15
+ * Commander-free core: bundle-in, manifest-out. Reads the kind's npm package
16
+ * `name`/`version` from its `package.json`, computes one sha256 over the `src/`
17
+ * tree (upper-case), and writes `manifest.json` LAST as the commit marker (the
18
+ * build_dist.ts convention: readers treat the manifest's presence as "the dist
19
+ * is complete").
20
+ *
21
+ * Shaped commander-free so the deferred publish-time source-hash guard can
22
+ * `import` and reuse both the hash computation and this manifest shape without
23
+ * CLI coupling.
24
+ */
25
+ export declare function buildKindDist(opts?: BuildKindDistOptions): Promise<KindManifest>;
@@ -1,5 +1,9 @@
1
1
  export * from './model';
2
2
  export * from './build_dist';
3
+ export * from './build_kind_dist';
4
+ export * from './publish-block';
5
+ export * from './kind/resolve-refs';
6
+ export * from './kind/version-match';
3
7
  export * from './source_package';
4
8
  export * from './resolve_to_registry';
5
9
  export * from './registry';
@@ -0,0 +1,63 @@
1
+ import { BlockKindReference } from '@milaboratories/pl-model-common';
2
+ import { BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
3
+ import { KindManifest } from '../registry/schema_kinds';
4
+ import { RelativeContentReader } from '../model';
5
+ /**
6
+ * The kind reference the MODEL was compiled against, as baked into the block manifest
7
+ * when the block was built.
8
+ *
9
+ * It sits at the TOP LEVEL of the description — `description.kind`, a `{name}@{version}`
10
+ * string (declared in `block_description.ts`, read back by the registry's reconciler) —
11
+ * rather than under the model component, because the build lifts the model's
12
+ * container-level `kind` up when it writes the manifest. `undefined` means the block
13
+ * declares no kind.
14
+ */
15
+ export declare function readModelCompiledKindRef(manifest: BlockPackManifest): BlockKindReference | undefined;
16
+ /** A kind dependency as declared in the facade's `package.json`. */
17
+ export interface FacadeKindDependency {
18
+ /** npm package name of the kind (ends in `.kind`). */
19
+ npmName: string;
20
+ /** Raw version range as written in `package.json` (e.g. `^1.2.3`, `workspace:*`). */
21
+ range: string;
22
+ }
23
+ /**
24
+ * The facade-side kind dependency, read from the facade's `package.json`.
25
+ *
26
+ * The facade depends on its kind DIRECTLY: the `.kind`-suffixed entry is a direct
27
+ * dependency of the facade, not something reached transitively through
28
+ * `model/package.json`. We scan both `dependencies` and
29
+ * `devDependencies` for the single `.kind` entry — the slim facade keeps the
30
+ * kind (like its model/ui/workflow siblings) as a build-time `workspace:*`
31
+ * devDep, and its concrete version is resolved from the kind's built manifest
32
+ * downstream, so the range written here (`workspace:*`/`catalog:`/a semver
33
+ * range) is not load-bearing.
34
+ *
35
+ * Returns `undefined` when no kind dependency is declared.
36
+ */
37
+ export declare function readFacadeKindDependency(facadeDir: string): FacadeKindDependency | undefined;
38
+ /**
39
+ * Resolved, publishable kind artifacts: the concrete reference, the kind's
40
+ * content manifest, and a reader rooted at the kind's `dist/` folder.
41
+ */
42
+ export interface ResolvedFacadeKind {
43
+ /** Concrete `{name}@{version}` reference of the kind the facade actually ships. */
44
+ ref: BlockKindReference;
45
+ /** The kind content manifest (`build_kind_dist` output) read from the kind's dist. */
46
+ manifest: KindManifest;
47
+ /** Reads the manifest's `files[].name` relative to the kind's `dist/`. */
48
+ fileReader: RelativeContentReader;
49
+ }
50
+ /**
51
+ * Resolve the facade's kind dependency to concrete publishable artifacts.
52
+ *
53
+ * Resolves the kind npm package from the facade's perspective, reads its
54
+ * built `dist/manifest.json` (the authoritative concrete version — the facade
55
+ * `package.json` range may be `workspace:*`/`catalog:` and carry no concrete
56
+ * version), and returns a `dist/`-rooted file reader for `publishKind`.
57
+ *
58
+ * The concrete version comes from the built manifest, so a `workspace:*`/`catalog:`
59
+ * range in the facade's `package.json` resolves cleanly. Resolution uses standard node resolution from the facade dir; if the
60
+ * package or its manifest cannot be found it throws with a pointed message
61
+ * rather than silently skipping.
62
+ */
63
+ export declare function resolveFacadeKind(facadeDir: string, npmName: string): Promise<ResolvedFacadeKind>;
@@ -0,0 +1,23 @@
1
+ import { BlockKindReference } from '@milaboratories/pl-model-common';
2
+ /**
3
+ * Thrown when the kind version the model was compiled against does not match
4
+ * the kind version the facade ships. Typed so the publish command (and future
5
+ * callers) can distinguish this hard-fail from generic errors.
6
+ */
7
+ export declare class KindVersionMismatchError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ /**
11
+ * Pure pre-publish gate: assert the model's compiled-against kind and the
12
+ * facade's declared kind are the same kind at the same version. Throws
13
+ * {@link KindVersionMismatchError} on mismatch; success is "did not throw".
14
+ *
15
+ * No I/O — both inputs are already-resolved `{name}@{version}` references, so a
16
+ * mismatch aborts before any S3 write (a strict superset of "abort before the
17
+ * facade publish"). Reuses the SINGLE `{name}@{version}` codec `parseKindRef`
18
+ * from `block_kind_ref.ts` (§3) — it is NOT redefined here.
19
+ *
20
+ * @param modelKindRef reference the model was compiled against (`description.kind`)
21
+ * @param facadeKindDep concrete reference the facade ships (from resolve-refs)
22
+ */
23
+ export declare function checkKindVersionMatch(modelKindRef: BlockKindReference, facadeKindDep: BlockKindReference): void;
@@ -7,7 +7,14 @@ export type BlockPackDescriptionAbsolute = BlockPackDescription<BlockComponentsD
7
7
  * Resolves a raw `package.json`-form block-pack description against the
8
8
  * module root: workflow/model/ui paths via node module resolution, text and
9
9
  * binary fields in `meta` via `mapLocalToAbsolute`. Reads the resolved model
10
- * file to extract feature flags from its `BlockConfigContainer`.
10
+ * file to extract feature flags and the kind reference from its
11
+ * `BlockConfigContainer`.
12
+ *
13
+ * Both of those come from the built model rather than from `package.json`,
14
+ * because both are decided when the model is compiled. Carrying the kind here
15
+ * means a description means the same thing whichever side it was loaded from —
16
+ * a manifest already records it, and a caller should not have to know that a
17
+ * source package does not and re-read the model to find out.
11
18
  */
12
19
  export declare function resolveBlockPackDescription(raw: BlockPackDescriptionRaw, root: string): Promise<BlockPackDescriptionAbsolute>;
13
20
  /**
@@ -0,0 +1,23 @@
1
+ import { BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
2
+ import { BlockRegistryV2 } from './registry/registry';
3
+ import { RelativeContentReader } from './model';
4
+ /**
5
+ * Publish a block package, kind-first.
6
+ *
7
+ * This is the single forward-compat seam the deferred kind/template phases
8
+ * extend. It sequences exactly three steps around the existing facade publish:
9
+ *
10
+ * 1. resolve both kind refs — every assumption about how the facade names and locates
11
+ * its kind lives in `resolve-refs`, so this step has no shape details of its own,
12
+ * 2. run the pure version-match gate — hard-fails before ANY S3 write,
13
+ * 3. `publishKind` (kind content → `kinds/` tree, idempotent, source-hash
14
+ * guarded), then
15
+ * 4. `publishPackage` — the facade block, byte-for-byte unchanged.
16
+ *
17
+ * A block that declares no kind (`description.kind` absent) publishes exactly as
18
+ * before: the gate and `publishKind` are skipped entirely.
19
+ *
20
+ * The channel marker / coords write / refresh tail stays in the publish command
21
+ * and runs only after this resolves.
22
+ */
23
+ export declare function publishBlock(registry: BlockRegistryV2, manifest: BlockPackManifest, facadeDir: string, fileReader: RelativeContentReader): Promise<void>;
@@ -1,3 +1,5 @@
1
1
  export * from './registry';
2
2
  export * from './registry_reader';
3
3
  export * from './schema_public';
4
+ export * from './schema_kinds';
5
+ export * from './kind_resolver';
@@ -0,0 +1,121 @@
1
+ import { BlockPackId } from '@milaboratories/pl-model-middle-layer';
2
+ import { KindOverview } from './schema_kinds';
3
+ /**
4
+ * PURE, IO-free block-kind resolution core.
5
+ *
6
+ * Given a parsed {@link KindOverview} projection (fetched by the reader) and a
7
+ * version selector, this module answers "which concrete implementing block
8
+ * satisfies `{name}@{selector}`?" with a discriminated {@link KindResolution}.
9
+ *
10
+ * Everything here is fed literals in unit tests — no `FolderReader`, no cache,
11
+ * no `semver` use beyond range math. This is the net-new, correctness-critical
12
+ * seam (implementation-path §6): selector→range translation and channel
13
+ * selection each have edges worth isolating and testing.
14
+ *
15
+ * Naming: this module never parses the `{name}@{version}` *reference* string
16
+ * (that codec is `parseKindRef`, block_kind_ref.ts) nor the npm-name→path split
17
+ * (`npmNameToKindPath`, schema_kinds.ts). It consumes an already-split selector.
18
+ */
19
+ /**
20
+ * The three version-selector tiers of the redefined-semver scheme
21
+ * (01-kind-and-lifecycle.md:63):
22
+ * - `exact` — `@X.Y.Z`, pin to one version.
23
+ * - `patch` — `~X.Y.Z`, behavior frozen (patch floats).
24
+ * - `minor` — `^X.Y.Z`, behavior floats (minor floats).
25
+ */
26
+ export type SelectorOp = "exact" | "patch" | "minor";
27
+ export interface Selector {
28
+ op: SelectorOp;
29
+ version: string;
30
+ }
31
+ /**
32
+ * Split a raw selector string into its {@link Selector} operator + version.
33
+ *
34
+ * The leading character encodes the tier: `~`→patch, `^`→minor, `@`→exact.
35
+ * A bare version (no recognized leading operator) is treated as `exact`. Note
36
+ * that `@` as a *leading* char is redundant with the bare form and accepted
37
+ * only because the reference form is `{name}@{version}` — after `parseKindRef`
38
+ * splits on the final `@`, the version half is normally bare or `~`/`^`-prefixed.
39
+ */
40
+ export declare function parseSelector(raw: string): Selector;
41
+ /**
42
+ * Map a {@link Selector} to a semver range string:
43
+ * - `exact` — `=X.Y.Z`
44
+ * - `patch` — `>=X.Y.Z <X.(Y+1).0-0`, behavior frozen, params float
45
+ * - `minor` — `>=X.Y.Z <(X+1).0.0-0`, behavior floats, never crosses a params-break
46
+ *
47
+ * The kind scheme redefines the *meaning* of major/minor/patch, not the range
48
+ * arithmetic — so the arithmetic is written out here rather than delegated to
49
+ * npm's `~`/`^` operators, which are not major-agnostic. Below 1.0.0 npm expands
50
+ * both `^0.2.3` and `~0.2.3` to `>=0.2.3 <0.3.0-0`, treating a `0.x` minor as the
51
+ * breaking boundary per ecosystem convention. Under the kind scheme a
52
+ * params-break is a MAJOR bump at every major including zero, and nothing
53
+ * guarantees a kind starts at `1.0.0`, so borrowing `^` would silently collapse
54
+ * `patch` and `minor` into one tier for any `0.x` kind — erasing the distinction
55
+ * the whole scheme rests on.
56
+ *
57
+ * For `X >= 1` these forms are equivalent to `~`/`^`, down to npm's `-0`
58
+ * upper-bound suffix that keeps prereleases of the boundary out of range.
59
+ *
60
+ * @throws if `sel.version` is not a valid semver version. {@link parseSelector}
61
+ * does not validate it; the model-side `parseKindSelector` does.
62
+ */
63
+ export declare function selectorToRange(sel: Selector): string;
64
+ /**
65
+ * Outcome of resolving a kind reference against its overview projection.
66
+ *
67
+ * The three failure reasons are distinct on purpose (the caller maps each to a
68
+ * different user-facing error):
69
+ * - `no-matching-kind-version` — the selector satisfies zero kind versions
70
+ * (`maxSatisfying` returned `null`).
71
+ * - `no-implementation` — a kind version matched, but it has no implementing
72
+ * block at all.
73
+ * - `no-stable-implementation` — implementing blocks exist for the matched
74
+ * kind version, but none is on the `stable` channel and `allowUnstable` is
75
+ * off.
76
+ */
77
+ export type KindResolution = {
78
+ ok: true;
79
+ blockId: BlockPackId;
80
+ channel: string;
81
+ } | {
82
+ ok: false;
83
+ reason: "no-matching-kind-version";
84
+ } | {
85
+ ok: false;
86
+ reason: "no-implementation";
87
+ } | {
88
+ ok: false;
89
+ reason: "no-stable-implementation";
90
+ };
91
+ export type KindResolutionReason = Extract<KindResolution, {
92
+ ok: false;
93
+ }>["reason"];
94
+ /**
95
+ * Typed error the reader/facade throw when {@link resolveKind} fails, carrying
96
+ * the discriminated {@link KindResolutionReason} and the offending reference so
97
+ * a caller can map it to a spec-level error without re-deriving the reason.
98
+ */
99
+ export declare class KindResolutionError extends Error {
100
+ readonly reason: KindResolutionReason;
101
+ readonly ref: string;
102
+ constructor(reason: KindResolutionReason, ref: string);
103
+ }
104
+ /**
105
+ * Resolve a kind reference to a concrete implementing block.
106
+ *
107
+ * 1. Pick the newest kind version satisfying the selector via
108
+ * `semver.maxSatisfying` over the overview's `kindVersions`.
109
+ * 2. Select the target channel: `stable` by default, `any` when `allowUnstable`
110
+ * is set (the apply-time flag).
111
+ * 3. Pick the newest implementing block in that `(version, channel)` via
112
+ * `semver.gt`, reading the flat `implementers` source of truth and falling
113
+ * back to the derived `latestByChannel` projection for older overviews.
114
+ *
115
+ * @param overview parsed & normalized kind projection (reader-supplied).
116
+ * @param selector either a raw selector string (`^1.2.3`, `~1.2.3`, `1.2.3`)
117
+ * or a pre-parsed {@link Selector}.
118
+ */
119
+ export declare function resolveKind(overview: KindOverview, selector: string | Selector, opt: {
120
+ allowUnstable: boolean;
121
+ }): KindResolution;
@@ -2,6 +2,7 @@ import { MiLogger } from '@milaboratories/ts-helpers';
2
2
  import { RegistryStorage } from '../../io/storage';
3
3
  import { BlockPackId, BlockPackIdNoVersion, BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
4
4
  import { GlobalOverviewReg, PackageOverview } from './schema_public';
5
+ import { KindManifest } from './schema_kinds';
5
6
  import { RelativeContentReader } from '../model';
6
7
  export interface BlockRegistrySettings {
7
8
  skipSnapshotCreation?: boolean;
@@ -25,10 +26,32 @@ export declare class BlockRegistryV2 {
25
26
  updateIfNeeded(mode?: "force" | "normal" | "dry-run"): Promise<void>;
26
27
  getPackageOverview(name: BlockPackIdNoVersion): Promise<undefined | PackageOverview>;
27
28
  getGlobalOverview(): Promise<undefined | GlobalOverviewReg>;
29
+ /** Read+parse a kind overview by its absolute `kinds/{org}/{name}/overview.json` path. */
30
+ private getKindOverviewAt;
28
31
  private marchChanged;
29
32
  addPackageToChannel(id: BlockPackId, channel: string): Promise<void>;
30
33
  removePackageFromChannel(id: BlockPackId, channel: string): Promise<void>;
31
34
  listGlobalOverviewSnapshots(): Promise<GlobalOverviewBackupDescription[]>;
32
35
  restoreGlobalOverviewFromSnapshot(backupId: string): Promise<void>;
33
36
  publishPackage(manifest: BlockPackManifest, fileReader: RelativeContentReader): Promise<void>;
37
+ /**
38
+ * Publish a block *kind* into the `kinds/` tree — idempotent, immutable,
39
+ * content-first. Cloned from {@link publishPackage} with two differences:
40
+ *
41
+ * 1. NET-NEW source-hash guard: kind versions are immutable. If a manifest
42
+ * already exists with the same `sourceHash` this is a no-op; with a
43
+ * different `sourceHash` it hard-fails. (No such guard exists for
44
+ * blocks — `publishPackage` still overwrites same-version content.)
45
+ * 2. NO `marchChanged`: the kind projection is derived from *block*
46
+ * manifests by the reconciler, so kind content publish drops no ticket —
47
+ * it rides the block's publish ticket. A kind with zero implementing
48
+ * blocks is deliberately invisible (no `overview.json`).
49
+ *
50
+ * The path is derived from the manifest's full npm package name
51
+ * (`kind.name`) via `npmNameToKindPath` (inside `kindContentPrefix`) — the
52
+ * SAME derivation the reconciler and readers use, so content and overview
53
+ * always co-locate under one `{org}/{name}` folder. There is no separate
54
+ * `organization` field on the identity.
55
+ */
56
+ publishKind(kindManifest: KindManifest, fileReader: RelativeContentReader): Promise<void>;
34
57
  }
@@ -1,5 +1,7 @@
1
- import { BlockPackId, BlockPackIdNoVersion, UpdateSuggestions, SingleBlockPackOverview, BlockPackOverviewNoRegistryId } from '@milaboratories/pl-model-middle-layer';
1
+ import { BlockPackId, BlockPackIdNoVersion, UpdateSuggestions, SingleBlockPackOverview, BlockPackOverviewNoRegistryId, BlockPackFromRegistryV2 } from '@milaboratories/pl-model-middle-layer';
2
+ import { BlockKindReference } from '@milaboratories/pl-model-common';
2
3
  import { FolderReader } from '../../io';
4
+ import { KindOverview } from './schema_kinds';
3
5
  import { BlockComponentsAbsoluteUrl } from '../model';
4
6
  export type RegistryV2ReaderOps = {
5
7
  /** Number of milliseconds to cache retrieved block list for */
@@ -12,6 +14,8 @@ export declare function inferUpdateSuggestions(currentVersion: string, available
12
14
  export declare class RegistryV2Reader {
13
15
  private readonly registryReader;
14
16
  private readonly v2RootFolderReader;
17
+ /** Rooted at `kinds/`, a sibling of `v2/` — the kind projection tree. */
18
+ private readonly kindsRootFolderReader;
15
19
  private readonly ops;
16
20
  constructor(registryReader: FolderReader, ops?: Partial<RegistryV2ReaderOps>);
17
21
  /**
@@ -31,4 +35,33 @@ export declare class RegistryV2Reader {
31
35
  getSpecificOverview(id: BlockPackId, channel: string): Promise<SingleBlockPackOverview>;
32
36
  private readonly componentsCache;
33
37
  getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl>;
38
+ /**
39
+ * Read the kind projection at `kinds/{org}/{name}/overview.json` for a kind
40
+ * npm package name. Single, no-LIST read against the `kinds/` sibling tree
41
+ * (rooted separately from `v2/`). Returns `undefined` when the overview is
42
+ * absent — a kind with zero implementing blocks has no overview by design.
43
+ *
44
+ * Client-side selector→version resolution is left to the §6 resolution
45
+ * concern; this method only fetches and parses.
46
+ */
47
+ getKindOverview(kindNpmName: string, options?: {
48
+ signal?: AbortSignal;
49
+ }): Promise<KindOverview | undefined>;
50
+ /**
51
+ * Resolve a kind reference (`{name}@{selector}`) to a concrete implementing
52
+ * block, returning the **byte-identical** `from-registry-v2` spec shape that
53
+ * {@link getSpecificOverview} emits — so the resolved block flows through the
54
+ * unchanged add-block / `getComponents` / `prepareBlockPack` path.
55
+ *
56
+ * One projection read ({@link getKindOverview}) + client-side semver
57
+ * ({@link resolveKindOverview}); kind and its implementing blocks share this
58
+ * one registry, so no cross-registry intersection is needed. Throws a typed
59
+ * {@link KindResolutionError} on any failure (absent projection or no
60
+ * satisfying version/implementation) — the caller maps it to a spec error.
61
+ */
62
+ resolveKind(ref: BlockKindReference, { allowUnstable }: {
63
+ allowUnstable: boolean;
64
+ }, options?: {
65
+ signal?: AbortSignal;
66
+ }): Promise<BlockPackFromRegistryV2>;
34
67
  }