@milaboratories/pl-middle-layer 1.66.19 → 1.67.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 (130) hide show
  1. package/dist/block_registry/index.cjs +3 -0
  2. package/dist/block_registry/index.d.ts +2 -1
  3. package/dist/block_registry/index.js +2 -1
  4. package/dist/block_registry/location_provider.cjs +117 -0
  5. package/dist/block_registry/location_provider.cjs.map +1 -0
  6. package/dist/block_registry/location_provider.js +114 -0
  7. package/dist/block_registry/location_provider.js.map +1 -0
  8. package/dist/block_registry/registry.cjs +13 -0
  9. package/dist/block_registry/registry.cjs.map +1 -1
  10. package/dist/block_registry/registry.d.ts +14 -1
  11. package/dist/block_registry/registry.d.ts.map +1 -1
  12. package/dist/block_registry/registry.js +13 -0
  13. package/dist/block_registry/registry.js.map +1 -1
  14. package/dist/block_registry/template_provider.cjs +104 -0
  15. package/dist/block_registry/template_provider.cjs.map +1 -0
  16. package/dist/block_registry/template_provider.d.ts +62 -0
  17. package/dist/block_registry/template_provider.d.ts.map +1 -0
  18. package/dist/block_registry/template_provider.js +103 -0
  19. package/dist/block_registry/template_provider.js.map +1 -0
  20. package/dist/block_registry/watcher.cjs +3 -3
  21. package/dist/block_registry/watcher.js +2 -2
  22. package/dist/dev_env/util.js +2 -2
  23. package/dist/dev_env/util.js.map +1 -1
  24. package/dist/index.cjs +10 -0
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +5 -1
  27. package/dist/js_render/computable_context.cjs +1 -1
  28. package/dist/js_render/computable_context.js +1 -1
  29. package/dist/middle_layer/driver_kit.d.ts +1 -1
  30. package/dist/middle_layer/middle_layer.cjs +144 -2
  31. package/dist/middle_layer/middle_layer.cjs.map +1 -1
  32. package/dist/middle_layer/middle_layer.d.ts +67 -1
  33. package/dist/middle_layer/middle_layer.d.ts.map +1 -1
  34. package/dist/middle_layer/middle_layer.js +146 -4
  35. package/dist/middle_layer/middle_layer.js.map +1 -1
  36. package/dist/middle_layer/project.cjs +1 -0
  37. package/dist/middle_layer/project.cjs.map +1 -1
  38. package/dist/middle_layer/project.d.ts +2 -2
  39. package/dist/middle_layer/project.js +4 -4
  40. package/dist/middle_layer/project.js.map +1 -1
  41. package/dist/middle_layer/sharing_list.d.ts +1 -1
  42. package/dist/model/args.cjs +9 -28
  43. package/dist/model/args.cjs.map +1 -1
  44. package/dist/model/args.js +9 -28
  45. package/dist/model/args.js.map +1 -1
  46. package/dist/model/index.cjs +7 -0
  47. package/dist/model/index.d.ts +4 -1
  48. package/dist/model/index.js +4 -1
  49. package/dist/model/project_helper.cjs +111 -0
  50. package/dist/model/project_helper.cjs.map +1 -1
  51. package/dist/model/project_helper.d.ts +76 -1
  52. package/dist/model/project_helper.d.ts.map +1 -1
  53. package/dist/model/project_helper.js +111 -0
  54. package/dist/model/project_helper.js.map +1 -1
  55. package/dist/model/project_model.d.ts +1 -1
  56. package/dist/model/sharing_model.d.ts +1 -1
  57. package/dist/model/template_apply.cjs +67 -0
  58. package/dist/model/template_apply.cjs.map +1 -0
  59. package/dist/model/template_apply.d.ts +50 -0
  60. package/dist/model/template_apply.d.ts.map +1 -0
  61. package/dist/model/template_apply.js +64 -0
  62. package/dist/model/template_apply.js.map +1 -0
  63. package/dist/model/template_export.cjs +82 -0
  64. package/dist/model/template_export.cjs.map +1 -0
  65. package/dist/model/template_export.d.ts +9 -0
  66. package/dist/model/template_export.d.ts.map +1 -0
  67. package/dist/model/template_export.js +82 -0
  68. package/dist/model/template_export.js.map +1 -0
  69. package/dist/model/template_parser.cjs +74 -0
  70. package/dist/model/template_parser.cjs.map +1 -0
  71. package/dist/model/template_parser.d.ts +43 -0
  72. package/dist/model/template_parser.d.ts.map +1 -0
  73. package/dist/model/template_parser.js +72 -0
  74. package/dist/model/template_parser.js.map +1 -0
  75. package/dist/model/template_resolve.cjs +134 -0
  76. package/dist/model/template_resolve.cjs.map +1 -0
  77. package/dist/model/template_resolve.d.ts +193 -0
  78. package/dist/model/template_resolve.d.ts.map +1 -0
  79. package/dist/model/template_resolve.js +133 -0
  80. package/dist/model/template_resolve.js.map +1 -0
  81. package/dist/model/template_serializer.cjs +162 -0
  82. package/dist/model/template_serializer.cjs.map +1 -0
  83. package/dist/model/template_serializer.d.ts +17 -0
  84. package/dist/model/template_serializer.d.ts.map +1 -0
  85. package/dist/model/template_serializer.js +157 -0
  86. package/dist/model/template_serializer.js.map +1 -0
  87. package/dist/mutator/block-pack/block_pack.cjs +1 -1
  88. package/dist/mutator/block-pack/block_pack.js +1 -1
  89. package/dist/mutator/migration.cjs +1 -1
  90. package/dist/mutator/migration.js +1 -1
  91. package/dist/mutator/project.cjs +35 -5
  92. package/dist/mutator/project.cjs.map +1 -1
  93. package/dist/mutator/project.d.ts.map +1 -1
  94. package/dist/mutator/project.js +35 -5
  95. package/dist/mutator/project.js.map +1 -1
  96. package/dist/mutator/template_construct.cjs +77 -0
  97. package/dist/mutator/template_construct.cjs.map +1 -0
  98. package/dist/mutator/template_construct.js +77 -0
  99. package/dist/mutator/template_construct.js.map +1 -0
  100. package/dist/network_check/template.js +3 -3
  101. package/dist/network_check/template.js.map +1 -1
  102. package/package.json +18 -18
  103. package/src/block_registry/index.ts +1 -0
  104. package/src/block_registry/location_provider.test.ts +236 -0
  105. package/src/block_registry/location_provider.ts +124 -0
  106. package/src/block_registry/registry.ts +22 -0
  107. package/src/block_registry/template_provider.test.ts +275 -0
  108. package/src/block_registry/template_provider.ts +168 -0
  109. package/src/middle_layer/middle_layer.ts +192 -1
  110. package/src/middle_layer/project.ts +1 -1
  111. package/src/model/args.test.ts +26 -1
  112. package/src/model/args.ts +16 -31
  113. package/src/model/index.ts +21 -0
  114. package/src/model/project_helper.ts +238 -0
  115. package/src/model/project_helper_params_init.test.ts +249 -0
  116. package/src/model/template_apply.test.ts +65 -0
  117. package/src/model/template_apply.ts +128 -0
  118. package/src/model/template_export.test.ts +255 -0
  119. package/src/model/template_export.ts +136 -0
  120. package/src/model/template_parser.test.ts +264 -0
  121. package/src/model/template_parser.ts +108 -0
  122. package/src/model/template_resolve.test.ts +397 -0
  123. package/src/model/template_resolve.ts +346 -0
  124. package/src/model/template_serializer.test.ts +398 -0
  125. package/src/model/template_serializer.ts +232 -0
  126. package/src/model/template_serializer_fixtures.test.ts +274 -0
  127. package/src/mutator/project-v3.test.ts +11 -11
  128. package/src/mutator/project.ts +92 -5
  129. package/src/mutator/template_construct.test.ts +456 -0
  130. package/src/mutator/template_construct.ts +150 -0
@@ -0,0 +1,104 @@
1
+ const require_location_provider = require("./location_provider.cjs");
2
+ let _platforma_sdk_model = require("@platforma-sdk/model");
3
+ let _milaboratories_pl_model_middle_layer = require("@milaboratories/pl-model-middle-layer");
4
+ let _platforma_sdk_block_tools = require("@platforma-sdk/block-tools");
5
+ //#region src/block_registry/template_provider.ts
6
+ /**
7
+ * The ids of the configured registries a template can be resolved against, in the order
8
+ * they should be consulted.
9
+ *
10
+ * Answers the standing "which registry" question, and answers it by capability rather
11
+ * than by preference: kinds are published to the `kinds/` tree of a `remote-v2`
12
+ * registry, so no other registry type can satisfy an entry at all. A `local-dev`
13
+ * registry serves dev packets, which have no manifest and no kind publication — every
14
+ * template entry names a kind, so such a registry can never answer one.
15
+ *
16
+ * Configured order is kept: it is the order the environment chose, and the first
17
+ * registry that has the kind wins. Nothing here dedupes a kind published to two
18
+ * registries — with the search stopping at the first hit, the earlier registry is
19
+ * simply the answer.
20
+ */
21
+ function kindCapableRegistryIds(entries) {
22
+ return entries.filter((entry) => entry.spec.type === "remote-v2").map((entry) => entry.id);
23
+ }
24
+ /**
25
+ * A {@link BlockPackProvider} over the configured block registries.
26
+ *
27
+ * The adapter between the import path's port and what the registry layer already does:
28
+ * `resolveKind` walks a kind's projection and picks an implementing block,
29
+ * `getOverview` reads one block's manifest. Both live in the registry; the port exists
30
+ * so that resolution can be tested without one, and so that which registries to consult
31
+ * stays an environment decision.
32
+ *
33
+ * Both routes also return the block's published title, because both have to read a
34
+ * manifest to produce a spec anyway and nothing downstream can recover it. On the pinned
35
+ * route it is free; on the kind route it costs one manifest read after the projection.
36
+ *
37
+ * @param registryIds Registries to consult, in order — see {@link kindCapableRegistryIds}
38
+ * @param logger Where a registry that could not answer is recorded. A read failure and
39
+ * an absent block are indistinguishable here (the reader throws for both), so the
40
+ * fallback to the next registry has to swallow the reason; this is the only place it
41
+ * survives
42
+ */
43
+ function templateBlockPackProvider(deps) {
44
+ const { registry, registryIds, logger } = deps;
45
+ return {
46
+ byKind: async (kind, options) => {
47
+ let furthest;
48
+ for (const registryId of registryIds) try {
49
+ const spec = await registry.resolveKind(registryId, kind, options);
50
+ return {
51
+ ok: true,
52
+ spec,
53
+ title: (await registry.getOverview(registryId, spec.id, spec.channel ?? _milaboratories_pl_model_middle_layer.StableChannel)).meta.title
54
+ };
55
+ } catch (e) {
56
+ if (!(e instanceof _platforma_sdk_block_tools.KindResolutionError)) throw e;
57
+ furthest = furthestFailure(furthest, e.reason);
58
+ }
59
+ return {
60
+ ok: false,
61
+ reason: furthest ?? "no-matching-kind-version"
62
+ };
63
+ },
64
+ byLocation: require_location_provider.resolveBlockPackLocation,
65
+ byExactVersion: async (id) => {
66
+ for (const registryId of registryIds) try {
67
+ const overview = await registry.getOverview(registryId, id, _milaboratories_pl_model_middle_layer.StableChannel);
68
+ return {
69
+ ok: true,
70
+ spec: overview.spec,
71
+ title: overview.meta.title
72
+ };
73
+ } catch (e) {
74
+ logger.info(`template apply: block ${id.organization}/${id.name} ${id.version} not read from registry '${registryId}': ${(0, _platforma_sdk_model.ensureError)(e).message}`);
75
+ }
76
+ return {
77
+ ok: false,
78
+ reason: "no-such-block-version"
79
+ };
80
+ }
81
+ };
82
+ }
83
+ /**
84
+ * The more informative of two failures across registries.
85
+ *
86
+ * With several registries consulted, the reasons can differ — one has never heard of the
87
+ * kind, another has it but only as a pre-release. Reporting the first would tell the
88
+ * reader to check their spelling when the real answer is "import again with unstable
89
+ * allowed", so the one that got furthest wins.
90
+ */
91
+ function furthestFailure(current, next) {
92
+ const rank = {
93
+ "no-matching-kind-version": 0,
94
+ "no-implementation": 1,
95
+ "no-stable-implementation": 2
96
+ };
97
+ if (current === void 0) return next;
98
+ return rank[next] > rank[current] ? next : current;
99
+ }
100
+ //#endregion
101
+ exports.kindCapableRegistryIds = kindCapableRegistryIds;
102
+ exports.templateBlockPackProvider = templateBlockPackProvider;
103
+
104
+ //# sourceMappingURL=template_provider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template_provider.cjs","names":["StableChannel","KindResolutionError","resolveBlockPackLocation"],"sources":["../../src/block_registry/template_provider.ts"],"sourcesContent":["import { KindResolutionError } from \"@platforma-sdk/block-tools\";\nimport type {\n BlockPackFromRegistryV2,\n BlockPackId,\n RegistryEntry,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { StableChannel } from \"@milaboratories/pl-model-middle-layer\";\nimport type { BlockKindReference } from \"@milaboratories/pl-model-common\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ensureError } from \"@platforma-sdk/model\";\nimport type { BlockPackProvider, ExactResolution, KindResolution } from \"../model/template_resolve\";\nimport { resolveBlockPackLocation } from \"./location_provider\";\n\n/**\n * The part of {@link BlockPackRegistry} a template's provider uses.\n *\n * Structural, so the provider can be exercised without a registry, a network or a\n * configured environment — and so it is obvious that these two calls are the entire\n * dependency.\n */\nexport type KindAwareRegistry = {\n resolveKind: (\n registryId: string,\n ref: BlockKindReference,\n options: { allowUnstable: boolean },\n ) => Promise<BlockPackFromRegistryV2>;\n getOverview: (\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ) => Promise<SingleBlockPackOverview>;\n};\n\n/**\n * The ids of the configured registries a template can be resolved against, in the order\n * they should be consulted.\n *\n * Answers the standing \"which registry\" question, and answers it by capability rather\n * than by preference: kinds are published to the `kinds/` tree of a `remote-v2`\n * registry, so no other registry type can satisfy an entry at all. A `local-dev`\n * registry serves dev packets, which have no manifest and no kind publication — every\n * template entry names a kind, so such a registry can never answer one.\n *\n * Configured order is kept: it is the order the environment chose, and the first\n * registry that has the kind wins. Nothing here dedupes a kind published to two\n * registries — with the search stopping at the first hit, the earlier registry is\n * simply the answer.\n */\nexport function kindCapableRegistryIds(entries: readonly RegistryEntry[]): string[] {\n return entries.filter((entry) => entry.spec.type === \"remote-v2\").map((entry) => entry.id);\n}\n\n/**\n * A {@link BlockPackProvider} over the configured block registries.\n *\n * The adapter between the import path's port and what the registry layer already does:\n * `resolveKind` walks a kind's projection and picks an implementing block,\n * `getOverview` reads one block's manifest. Both live in the registry; the port exists\n * so that resolution can be tested without one, and so that which registries to consult\n * stays an environment decision.\n *\n * Both routes also return the block's published title, because both have to read a\n * manifest to produce a spec anyway and nothing downstream can recover it. On the pinned\n * route it is free; on the kind route it costs one manifest read after the projection.\n *\n * @param registryIds Registries to consult, in order — see {@link kindCapableRegistryIds}\n * @param logger Where a registry that could not answer is recorded. A read failure and\n * an absent block are indistinguishable here (the reader throws for both), so the\n * fallback to the next registry has to swallow the reason; this is the only place it\n * survives\n */\nexport function templateBlockPackProvider(deps: {\n readonly registry: KindAwareRegistry;\n readonly registryIds: readonly string[];\n readonly logger: MiLogger;\n}): BlockPackProvider {\n const { registry, registryIds, logger } = deps;\n\n return {\n byKind: async (kind, options): Promise<KindResolution> => {\n let furthest: KindResolutionFailure | undefined;\n\n for (const registryId of registryIds) {\n try {\n // The selector brand is widened here, deliberately and in one place. The\n // facade types this parameter as an exact `{name}@X.Y.Z` reference, but its\n // implementation passes the version segment to the selector parser, so\n // `~`/`^` resolve correctly — the type is narrower than the behaviour. Until\n // the facade takes the selector brand, the cast is the honest way to say so.\n const spec = await registry.resolveKind(\n registryId,\n kind as unknown as BlockKindReference,\n options,\n );\n // Read back the manifest of the block the projection picked, in the channel it\n // was picked from. `channel` is optional on the spec and the resolver always\n // fills it, so the fallback is unreachable — it exists because the channel only\n // decides where future update suggestions come from, and `stable` is the answer\n // that surprises nobody.\n const overview = await registry.getOverview(\n registryId,\n spec.id,\n spec.channel ?? StableChannel,\n );\n return { ok: true, spec, title: overview.meta.title };\n } catch (e) {\n if (!(e instanceof KindResolutionError)) {\n // Not an answer about this kind: an unreadable registry, or a registry that\n // does not serve kinds at all. Falling through would report \"no such kind\"\n // for what is really an outage, so it propagates instead. (The second case\n // is unreachable through `kindCapableRegistryIds`, which filters by type.)\n throw e;\n }\n furthest = furthestFailure(furthest, e.reason);\n }\n }\n\n return { ok: false, reason: furthest ?? \"no-matching-kind-version\" };\n },\n\n // No registry is consulted for a located entry, and none of this adapter's\n // registry knowledge applies to it — which is why it is a straight delegation.\n byLocation: resolveBlockPackLocation,\n\n byExactVersion: async (id): Promise<ExactResolution> => {\n for (const registryId of registryIds) {\n try {\n // `stable` is recorded on the spec as the channel to watch for updates in.\n // The entry pinned this exact version, so nothing is being chosen here — the\n // channel only decides where a future update suggestion would come from.\n const overview = await registry.getOverview(registryId, id, StableChannel);\n return { ok: true, spec: overview.spec, title: overview.meta.title };\n } catch (e) {\n logger.info(\n `template apply: block ${id.organization}/${id.name} ${id.version} not read ` +\n `from registry '${registryId}': ${ensureError(e).message}`,\n );\n }\n }\n\n return { ok: false, reason: \"no-such-block-version\" };\n },\n };\n}\n\ntype KindResolutionFailure = Extract<KindResolution, { ok: false }>[\"reason\"];\n\n/**\n * The more informative of two failures across registries.\n *\n * With several registries consulted, the reasons can differ — one has never heard of the\n * kind, another has it but only as a pre-release. Reporting the first would tell the\n * reader to check their spelling when the real answer is \"import again with unstable\n * allowed\", so the one that got furthest wins.\n */\nfunction furthestFailure(\n current: KindResolutionFailure | undefined,\n next: KindResolutionFailure,\n): KindResolutionFailure {\n const rank: Record<KindResolutionFailure, number> = {\n \"no-matching-kind-version\": 0,\n \"no-implementation\": 1,\n \"no-stable-implementation\": 2,\n };\n if (current === undefined) return next;\n return rank[next] > rank[current] ? next : current;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,uBAAuB,SAA6C;CAClF,OAAO,QAAQ,QAAQ,UAAU,MAAM,KAAK,SAAS,WAAW,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE;AAC3F;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BAA0B,MAIpB;CACpB,MAAM,EAAE,UAAU,aAAa,WAAW;CAE1C,OAAO;EACL,QAAQ,OAAO,MAAM,YAAqC;GACxD,IAAI;GAEJ,KAAK,MAAM,cAAc,aACvB,IAAI;IAMF,MAAM,OAAO,MAAM,SAAS,YAC1B,YACA,MACA,OACF;IAWA,OAAO;KAAE,IAAI;KAAM;KAAM,QAAO,MALT,SAAS,YAC9B,YACA,KAAK,IACL,KAAK,WAAWA,sCAAAA,aAClB,EAAA,CACyC,KAAK;IAAM;GACtD,SAAS,GAAG;IACV,IAAI,EAAE,aAAaC,2BAAAA,sBAKjB,MAAM;IAER,WAAW,gBAAgB,UAAU,EAAE,MAAM;GAC/C;GAGF,OAAO;IAAE,IAAI;IAAO,QAAQ,YAAY;GAA2B;EACrE;EAIA,YAAYC,0BAAAA;EAEZ,gBAAgB,OAAO,OAAiC;GACtD,KAAK,MAAM,cAAc,aACvB,IAAI;IAIF,MAAM,WAAW,MAAM,SAAS,YAAY,YAAY,IAAIF,sCAAAA,aAAa;IACzE,OAAO;KAAE,IAAI;KAAM,MAAM,SAAS;KAAM,OAAO,SAAS,KAAK;IAAM;GACrE,SAAS,GAAG;IACV,OAAO,KACL,yBAAyB,GAAG,aAAa,GAAG,GAAG,KAAK,GAAG,GAAG,QAAQ,2BAC9C,WAAW,MAAA,GAAA,qBAAA,YAAA,CAAiB,CAAC,CAAC,CAAC,SACrD;GACF;GAGF,OAAO;IAAE,IAAI;IAAO,QAAQ;GAAwB;EACtD;CACF;AACF;;;;;;;;;AAYA,SAAS,gBACP,SACA,MACuB;CACvB,MAAM,OAA8C;EAClD,4BAA4B;EAC5B,qBAAqB;EACrB,4BAA4B;CAC9B;CACA,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,OAAO,KAAK,QAAQ,KAAK,WAAW,OAAO;AAC7C"}
@@ -0,0 +1,62 @@
1
+ import { BlockPackProvider } from "../model/template_resolve.js";
2
+ import { BlockPackFromRegistryV2, BlockPackId, RegistryEntry, SingleBlockPackOverview } from "@milaboratories/pl-model-middle-layer";
3
+ import { MiLogger } from "@milaboratories/ts-helpers";
4
+ import { BlockKindReference } from "@milaboratories/pl-model-common";
5
+
6
+ //#region src/block_registry/template_provider.d.ts
7
+ /**
8
+ * The part of {@link BlockPackRegistry} a template's provider uses.
9
+ *
10
+ * Structural, so the provider can be exercised without a registry, a network or a
11
+ * configured environment — and so it is obvious that these two calls are the entire
12
+ * dependency.
13
+ */
14
+ type KindAwareRegistry = {
15
+ resolveKind: (registryId: string, ref: BlockKindReference, options: {
16
+ allowUnstable: boolean;
17
+ }) => Promise<BlockPackFromRegistryV2>;
18
+ getOverview: (registryId: string, blockId: BlockPackId, channel: string) => Promise<SingleBlockPackOverview>;
19
+ };
20
+ /**
21
+ * The ids of the configured registries a template can be resolved against, in the order
22
+ * they should be consulted.
23
+ *
24
+ * Answers the standing "which registry" question, and answers it by capability rather
25
+ * than by preference: kinds are published to the `kinds/` tree of a `remote-v2`
26
+ * registry, so no other registry type can satisfy an entry at all. A `local-dev`
27
+ * registry serves dev packets, which have no manifest and no kind publication — every
28
+ * template entry names a kind, so such a registry can never answer one.
29
+ *
30
+ * Configured order is kept: it is the order the environment chose, and the first
31
+ * registry that has the kind wins. Nothing here dedupes a kind published to two
32
+ * registries — with the search stopping at the first hit, the earlier registry is
33
+ * simply the answer.
34
+ */
35
+ declare function kindCapableRegistryIds(entries: readonly RegistryEntry[]): string[];
36
+ /**
37
+ * A {@link BlockPackProvider} over the configured block registries.
38
+ *
39
+ * The adapter between the import path's port and what the registry layer already does:
40
+ * `resolveKind` walks a kind's projection and picks an implementing block,
41
+ * `getOverview` reads one block's manifest. Both live in the registry; the port exists
42
+ * so that resolution can be tested without one, and so that which registries to consult
43
+ * stays an environment decision.
44
+ *
45
+ * Both routes also return the block's published title, because both have to read a
46
+ * manifest to produce a spec anyway and nothing downstream can recover it. On the pinned
47
+ * route it is free; on the kind route it costs one manifest read after the projection.
48
+ *
49
+ * @param registryIds Registries to consult, in order — see {@link kindCapableRegistryIds}
50
+ * @param logger Where a registry that could not answer is recorded. A read failure and
51
+ * an absent block are indistinguishable here (the reader throws for both), so the
52
+ * fallback to the next registry has to swallow the reason; this is the only place it
53
+ * survives
54
+ */
55
+ declare function templateBlockPackProvider(deps: {
56
+ readonly registry: KindAwareRegistry;
57
+ readonly registryIds: readonly string[];
58
+ readonly logger: MiLogger;
59
+ }): BlockPackProvider;
60
+ //#endregion
61
+ export { KindAwareRegistry, kindCapableRegistryIds, templateBlockPackProvider };
62
+ //# sourceMappingURL=template_provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template_provider.d.ts","names":[],"sources":["../../src/block_registry/template_provider.ts"],"mappings":";;;;;;;;AAqBA;;;;;KAAY,iBAAA;EACV,WAAA,GACE,UAAA,UACA,GAAA,EAAK,kBAAA,EACL,OAAA;IAAW,aAAA;EAAA,MACR,OAAA,CAAQ,uBAAA;EACb,WAAA,GACE,UAAA,UACA,OAAA,EAAS,WAAA,EACT,OAAA,aACG,OAAA,CAAQ,uBAAA;AAAA;;;;;;;;;;;;;;;;iBAkBC,sBAAA,CAAuB,OAAiC,WAAf,aAAa;AAlBhC;AAkBtC;;;;AAAwE;AAuBxE;;;;;;;;;;;;;AAzCsC,iBAyCtB,yBAAA,CAA0B,IAAA;EAAA,SAC/B,QAAA,EAAU,iBAAA;EAAA,SACV,WAAA;EAAA,SACA,MAAA,EAAQ,QAAA;AAAA,IACf,iBAAA"}
@@ -0,0 +1,103 @@
1
+ import { resolveBlockPackLocation } from "./location_provider.js";
2
+ import { ensureError } from "@platforma-sdk/model";
3
+ import { StableChannel } from "@milaboratories/pl-model-middle-layer";
4
+ import { KindResolutionError } from "@platforma-sdk/block-tools";
5
+ //#region src/block_registry/template_provider.ts
6
+ /**
7
+ * The ids of the configured registries a template can be resolved against, in the order
8
+ * they should be consulted.
9
+ *
10
+ * Answers the standing "which registry" question, and answers it by capability rather
11
+ * than by preference: kinds are published to the `kinds/` tree of a `remote-v2`
12
+ * registry, so no other registry type can satisfy an entry at all. A `local-dev`
13
+ * registry serves dev packets, which have no manifest and no kind publication — every
14
+ * template entry names a kind, so such a registry can never answer one.
15
+ *
16
+ * Configured order is kept: it is the order the environment chose, and the first
17
+ * registry that has the kind wins. Nothing here dedupes a kind published to two
18
+ * registries — with the search stopping at the first hit, the earlier registry is
19
+ * simply the answer.
20
+ */
21
+ function kindCapableRegistryIds(entries) {
22
+ return entries.filter((entry) => entry.spec.type === "remote-v2").map((entry) => entry.id);
23
+ }
24
+ /**
25
+ * A {@link BlockPackProvider} over the configured block registries.
26
+ *
27
+ * The adapter between the import path's port and what the registry layer already does:
28
+ * `resolveKind` walks a kind's projection and picks an implementing block,
29
+ * `getOverview` reads one block's manifest. Both live in the registry; the port exists
30
+ * so that resolution can be tested without one, and so that which registries to consult
31
+ * stays an environment decision.
32
+ *
33
+ * Both routes also return the block's published title, because both have to read a
34
+ * manifest to produce a spec anyway and nothing downstream can recover it. On the pinned
35
+ * route it is free; on the kind route it costs one manifest read after the projection.
36
+ *
37
+ * @param registryIds Registries to consult, in order — see {@link kindCapableRegistryIds}
38
+ * @param logger Where a registry that could not answer is recorded. A read failure and
39
+ * an absent block are indistinguishable here (the reader throws for both), so the
40
+ * fallback to the next registry has to swallow the reason; this is the only place it
41
+ * survives
42
+ */
43
+ function templateBlockPackProvider(deps) {
44
+ const { registry, registryIds, logger } = deps;
45
+ return {
46
+ byKind: async (kind, options) => {
47
+ let furthest;
48
+ for (const registryId of registryIds) try {
49
+ const spec = await registry.resolveKind(registryId, kind, options);
50
+ return {
51
+ ok: true,
52
+ spec,
53
+ title: (await registry.getOverview(registryId, spec.id, spec.channel ?? StableChannel)).meta.title
54
+ };
55
+ } catch (e) {
56
+ if (!(e instanceof KindResolutionError)) throw e;
57
+ furthest = furthestFailure(furthest, e.reason);
58
+ }
59
+ return {
60
+ ok: false,
61
+ reason: furthest ?? "no-matching-kind-version"
62
+ };
63
+ },
64
+ byLocation: resolveBlockPackLocation,
65
+ byExactVersion: async (id) => {
66
+ for (const registryId of registryIds) try {
67
+ const overview = await registry.getOverview(registryId, id, StableChannel);
68
+ return {
69
+ ok: true,
70
+ spec: overview.spec,
71
+ title: overview.meta.title
72
+ };
73
+ } catch (e) {
74
+ logger.info(`template apply: block ${id.organization}/${id.name} ${id.version} not read from registry '${registryId}': ${ensureError(e).message}`);
75
+ }
76
+ return {
77
+ ok: false,
78
+ reason: "no-such-block-version"
79
+ };
80
+ }
81
+ };
82
+ }
83
+ /**
84
+ * The more informative of two failures across registries.
85
+ *
86
+ * With several registries consulted, the reasons can differ — one has never heard of the
87
+ * kind, another has it but only as a pre-release. Reporting the first would tell the
88
+ * reader to check their spelling when the real answer is "import again with unstable
89
+ * allowed", so the one that got furthest wins.
90
+ */
91
+ function furthestFailure(current, next) {
92
+ const rank = {
93
+ "no-matching-kind-version": 0,
94
+ "no-implementation": 1,
95
+ "no-stable-implementation": 2
96
+ };
97
+ if (current === void 0) return next;
98
+ return rank[next] > rank[current] ? next : current;
99
+ }
100
+ //#endregion
101
+ export { kindCapableRegistryIds, templateBlockPackProvider };
102
+
103
+ //# sourceMappingURL=template_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template_provider.js","names":[],"sources":["../../src/block_registry/template_provider.ts"],"sourcesContent":["import { KindResolutionError } from \"@platforma-sdk/block-tools\";\nimport type {\n BlockPackFromRegistryV2,\n BlockPackId,\n RegistryEntry,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { StableChannel } from \"@milaboratories/pl-model-middle-layer\";\nimport type { BlockKindReference } from \"@milaboratories/pl-model-common\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ensureError } from \"@platforma-sdk/model\";\nimport type { BlockPackProvider, ExactResolution, KindResolution } from \"../model/template_resolve\";\nimport { resolveBlockPackLocation } from \"./location_provider\";\n\n/**\n * The part of {@link BlockPackRegistry} a template's provider uses.\n *\n * Structural, so the provider can be exercised without a registry, a network or a\n * configured environment — and so it is obvious that these two calls are the entire\n * dependency.\n */\nexport type KindAwareRegistry = {\n resolveKind: (\n registryId: string,\n ref: BlockKindReference,\n options: { allowUnstable: boolean },\n ) => Promise<BlockPackFromRegistryV2>;\n getOverview: (\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ) => Promise<SingleBlockPackOverview>;\n};\n\n/**\n * The ids of the configured registries a template can be resolved against, in the order\n * they should be consulted.\n *\n * Answers the standing \"which registry\" question, and answers it by capability rather\n * than by preference: kinds are published to the `kinds/` tree of a `remote-v2`\n * registry, so no other registry type can satisfy an entry at all. A `local-dev`\n * registry serves dev packets, which have no manifest and no kind publication — every\n * template entry names a kind, so such a registry can never answer one.\n *\n * Configured order is kept: it is the order the environment chose, and the first\n * registry that has the kind wins. Nothing here dedupes a kind published to two\n * registries — with the search stopping at the first hit, the earlier registry is\n * simply the answer.\n */\nexport function kindCapableRegistryIds(entries: readonly RegistryEntry[]): string[] {\n return entries.filter((entry) => entry.spec.type === \"remote-v2\").map((entry) => entry.id);\n}\n\n/**\n * A {@link BlockPackProvider} over the configured block registries.\n *\n * The adapter between the import path's port and what the registry layer already does:\n * `resolveKind` walks a kind's projection and picks an implementing block,\n * `getOverview` reads one block's manifest. Both live in the registry; the port exists\n * so that resolution can be tested without one, and so that which registries to consult\n * stays an environment decision.\n *\n * Both routes also return the block's published title, because both have to read a\n * manifest to produce a spec anyway and nothing downstream can recover it. On the pinned\n * route it is free; on the kind route it costs one manifest read after the projection.\n *\n * @param registryIds Registries to consult, in order — see {@link kindCapableRegistryIds}\n * @param logger Where a registry that could not answer is recorded. A read failure and\n * an absent block are indistinguishable here (the reader throws for both), so the\n * fallback to the next registry has to swallow the reason; this is the only place it\n * survives\n */\nexport function templateBlockPackProvider(deps: {\n readonly registry: KindAwareRegistry;\n readonly registryIds: readonly string[];\n readonly logger: MiLogger;\n}): BlockPackProvider {\n const { registry, registryIds, logger } = deps;\n\n return {\n byKind: async (kind, options): Promise<KindResolution> => {\n let furthest: KindResolutionFailure | undefined;\n\n for (const registryId of registryIds) {\n try {\n // The selector brand is widened here, deliberately and in one place. The\n // facade types this parameter as an exact `{name}@X.Y.Z` reference, but its\n // implementation passes the version segment to the selector parser, so\n // `~`/`^` resolve correctly — the type is narrower than the behaviour. Until\n // the facade takes the selector brand, the cast is the honest way to say so.\n const spec = await registry.resolveKind(\n registryId,\n kind as unknown as BlockKindReference,\n options,\n );\n // Read back the manifest of the block the projection picked, in the channel it\n // was picked from. `channel` is optional on the spec and the resolver always\n // fills it, so the fallback is unreachable — it exists because the channel only\n // decides where future update suggestions come from, and `stable` is the answer\n // that surprises nobody.\n const overview = await registry.getOverview(\n registryId,\n spec.id,\n spec.channel ?? StableChannel,\n );\n return { ok: true, spec, title: overview.meta.title };\n } catch (e) {\n if (!(e instanceof KindResolutionError)) {\n // Not an answer about this kind: an unreadable registry, or a registry that\n // does not serve kinds at all. Falling through would report \"no such kind\"\n // for what is really an outage, so it propagates instead. (The second case\n // is unreachable through `kindCapableRegistryIds`, which filters by type.)\n throw e;\n }\n furthest = furthestFailure(furthest, e.reason);\n }\n }\n\n return { ok: false, reason: furthest ?? \"no-matching-kind-version\" };\n },\n\n // No registry is consulted for a located entry, and none of this adapter's\n // registry knowledge applies to it — which is why it is a straight delegation.\n byLocation: resolveBlockPackLocation,\n\n byExactVersion: async (id): Promise<ExactResolution> => {\n for (const registryId of registryIds) {\n try {\n // `stable` is recorded on the spec as the channel to watch for updates in.\n // The entry pinned this exact version, so nothing is being chosen here — the\n // channel only decides where a future update suggestion would come from.\n const overview = await registry.getOverview(registryId, id, StableChannel);\n return { ok: true, spec: overview.spec, title: overview.meta.title };\n } catch (e) {\n logger.info(\n `template apply: block ${id.organization}/${id.name} ${id.version} not read ` +\n `from registry '${registryId}': ${ensureError(e).message}`,\n );\n }\n }\n\n return { ok: false, reason: \"no-such-block-version\" };\n },\n };\n}\n\ntype KindResolutionFailure = Extract<KindResolution, { ok: false }>[\"reason\"];\n\n/**\n * The more informative of two failures across registries.\n *\n * With several registries consulted, the reasons can differ — one has never heard of the\n * kind, another has it but only as a pre-release. Reporting the first would tell the\n * reader to check their spelling when the real answer is \"import again with unstable\n * allowed\", so the one that got furthest wins.\n */\nfunction furthestFailure(\n current: KindResolutionFailure | undefined,\n next: KindResolutionFailure,\n): KindResolutionFailure {\n const rank: Record<KindResolutionFailure, number> = {\n \"no-matching-kind-version\": 0,\n \"no-implementation\": 1,\n \"no-stable-implementation\": 2,\n };\n if (current === undefined) return next;\n return rank[next] > rank[current] ? next : current;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,uBAAuB,SAA6C;CAClF,OAAO,QAAQ,QAAQ,UAAU,MAAM,KAAK,SAAS,WAAW,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE;AAC3F;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BAA0B,MAIpB;CACpB,MAAM,EAAE,UAAU,aAAa,WAAW;CAE1C,OAAO;EACL,QAAQ,OAAO,MAAM,YAAqC;GACxD,IAAI;GAEJ,KAAK,MAAM,cAAc,aACvB,IAAI;IAMF,MAAM,OAAO,MAAM,SAAS,YAC1B,YACA,MACA,OACF;IAWA,OAAO;KAAE,IAAI;KAAM;KAAM,QAAO,MALT,SAAS,YAC9B,YACA,KAAK,IACL,KAAK,WAAW,aAClB,EAAA,CACyC,KAAK;IAAM;GACtD,SAAS,GAAG;IACV,IAAI,EAAE,aAAa,sBAKjB,MAAM;IAER,WAAW,gBAAgB,UAAU,EAAE,MAAM;GAC/C;GAGF,OAAO;IAAE,IAAI;IAAO,QAAQ,YAAY;GAA2B;EACrE;EAIA,YAAY;EAEZ,gBAAgB,OAAO,OAAiC;GACtD,KAAK,MAAM,cAAc,aACvB,IAAI;IAIF,MAAM,WAAW,MAAM,SAAS,YAAY,YAAY,IAAI,aAAa;IACzE,OAAO;KAAE,IAAI;KAAM,MAAM,SAAS;KAAM,OAAO,SAAS,KAAK;IAAM;GACrE,SAAS,GAAG;IACV,OAAO,KACL,yBAAyB,GAAG,aAAa,GAAG,GAAG,KAAK,GAAG,GAAG,QAAQ,2BAC9C,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,SACrD;GACF;GAGF,OAAO;IAAE,IAAI;IAAO,QAAQ;GAAwB;EACtD;CACF;AACF;;;;;;;;;AAYA,SAAS,gBACP,SACA,MACuB;CACvB,MAAM,OAA8C;EAClD,4BAA4B;EAC5B,qBAAqB;EACrB,4BAA4B;CAC9B;CACA,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,OAAO,KAAK,QAAQ,KAAK,WAAW,OAAO;AAC7C"}
@@ -2,12 +2,12 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_registry = require("./registry.cjs");
3
3
  let _milaboratories_pl_model_middle_layer = require("@milaboratories/pl-model-middle-layer");
4
4
  let _platforma_sdk_block_tools = require("@platforma-sdk/block-tools");
5
- let _milaboratories_computable = require("@milaboratories/computable");
6
5
  let node_url = require("node:url");
7
- let canonicalize = require("canonicalize");
8
- canonicalize = require_runtime.__toESM(canonicalize, 1);
6
+ let _milaboratories_computable = require("@milaboratories/computable");
9
7
  let semver = require("semver");
10
8
  semver = require_runtime.__toESM(semver, 1);
9
+ let canonicalize = require("canonicalize");
10
+ canonicalize = require_runtime.__toESM(canonicalize, 1);
11
11
  //#region src/block_registry/watcher.ts
12
12
  const DefaultBlockUpdateWatcherOps = { minDelay: 1500 };
13
13
  const NoUpdatesKey = "__no_updates__";
@@ -1,10 +1,10 @@
1
1
  import { getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime } from "./registry.js";
2
2
  import { AnyChannel, StableChannel, blockPackIdToString } from "@milaboratories/pl-model-middle-layer";
3
3
  import { loadPackDescriptionFromManifest, tryLoadPackDescription } from "@platforma-sdk/block-tools";
4
- import { PollComputablePool } from "@milaboratories/computable";
5
4
  import { fileURLToPath } from "node:url";
6
- import canonicalize from "canonicalize";
5
+ import { PollComputablePool } from "@milaboratories/computable";
7
6
  import * as semver from "semver";
7
+ import canonicalize from "canonicalize";
8
8
  //#region src/block_registry/watcher.ts
9
9
  const DefaultBlockUpdateWatcherOps = { minDelay: 1500 };
10
10
  const NoUpdatesKey = "__no_updates__";
@@ -1,8 +1,8 @@
1
- import * as fsp from "node:fs/promises";
1
+ import * as fsp$1 from "node:fs/promises";
2
2
  //#region src/dev_env/util.ts
3
3
  async function tryStat(path) {
4
4
  try {
5
- return await fsp.stat(path, { bigint: true });
5
+ return await fsp$1.stat(path, { bigint: true });
6
6
  } catch (error) {
7
7
  if (error.code === "ENOENT") return;
8
8
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":[],"sources":["../../src/dev_env/util.ts"],"sourcesContent":["import type { BigIntStats } from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\n\nexport async function tryStat(path: string): Promise<BigIntStats | undefined> {\n try {\n return await fsp.stat(path, { bigint: true });\n } catch (error: any) {\n if (error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n"],"mappings":";;AAGA,eAAsB,QAAQ,MAAgD;CAC5E,IAAI;EACF,OAAO,MAAM,IAAI,KAAK,MAAM,EAAE,QAAQ,KAAK,CAAC;CAC9C,SAAS,OAAY;EACnB,IAAI,MAAM,SAAS,UACjB;EAEF,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"util.js","names":["fsp"],"sources":["../../src/dev_env/util.ts"],"sourcesContent":["import type { BigIntStats } from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\n\nexport async function tryStat(path: string): Promise<BigIntStats | undefined> {\n try {\n return await fsp.stat(path, { bigint: true });\n } catch (error: any) {\n if (error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n"],"mappings":";;AAGA,eAAsB,QAAQ,MAAgD;CAC5E,IAAI;EACF,OAAO,MAAMA,MAAI,KAAK,MAAM,EAAE,QAAQ,KAAK,CAAC;CAC9C,SAAS,OAAY;EACnB,IAAI,MAAM,SAAS,UACjB;EAEF,MAAM;CACR;AACF"}
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_registry = require("./block_registry/registry.cjs");
3
3
  const require_registry_v2_provider = require("./block_registry/registry-v2-provider.cjs");
4
4
  const require_well_known_registries = require("./block_registry/well_known_registries.cjs");
5
+ const require_template_provider = require("./block_registry/template_provider.cjs");
5
6
  require("./block_registry/index.cjs");
6
7
  const require_project_model = require("./model/project_model.cjs");
7
8
  const require_project_list = require("./middle_layer/project_list.cjs");
@@ -9,6 +10,9 @@ const require_render_template = require("./mutator/template/render_template.cjs"
9
10
  const require_template_loading = require("./mutator/template/template_loading.cjs");
10
11
  const require_block_pack_spec = require("./model/block_pack_spec.cjs");
11
12
  const require_sharing_model = require("./model/sharing_model.cjs");
13
+ const require_template_parser = require("./model/template_parser.cjs");
14
+ const require_template_resolve = require("./model/template_resolve.cjs");
15
+ const require_template_apply = require("./model/template_apply.cjs");
12
16
  require("./model/index.cjs");
13
17
  const require_project = require("./mutator/project.cjs");
14
18
  const require_data = require("./pool/data.cjs");
@@ -53,6 +57,7 @@ exports.SharingStateField = require_sharing_model.SharingStateField;
53
57
  exports.SharingStateResourceType = require_sharing_model.SharingStateResourceType;
54
58
  exports.TemplateCacheFieldName = require_template_cache.TemplateCacheFieldName;
55
59
  exports.TemplateCacheType = require_template_cache.TemplateCacheType;
60
+ exports.TemplateEntryRejected = require_template_apply.TemplateEntryRejected;
56
61
  exports.TengoTemplateGet = require_template_loading.TengoTemplateGet;
57
62
  exports.TengoTemplateGetRegistry = require_template_loading.TengoTemplateGetRegistry;
58
63
  exports.TengoTemplateGetTemplate = require_template_loading.TengoTemplateGetTemplate;
@@ -87,12 +92,17 @@ exports.initDriverKit = require_driver_kit.initDriverKit;
87
92
  exports.initNetworkCheck = require_network_check.initNetworkCheck;
88
93
  exports.invalidateTemplateCacheId = require_template_cache.invalidateTemplateCacheId;
89
94
  exports.isAcceptanceField = require_sharing_model.isAcceptanceField;
95
+ exports.kindCapableRegistryIds = require_template_provider.kindCapableRegistryIds;
90
96
  exports.loadTemplate = require_template_loading.loadTemplate;
91
97
  exports.loadTemplateCached = require_template_cache.loadTemplateCached;
92
98
  exports.newShareId = require_sharing_model.newShareId;
99
+ exports.parseBlockPackName = require_template_resolve.parseBlockPackName;
93
100
  exports.parseFinalPObjectCollection = require_p_object_collection.parseFinalPObjectCollection;
101
+ exports.parseProjectTemplateV1Yaml = require_template_parser.parseProjectTemplateV1Yaml;
94
102
  exports.prepareTemplateSpec = require_template_loading.prepareTemplateSpec;
103
+ exports.resolveTemplateEntries = require_template_resolve.resolveTemplateEntries;
95
104
  exports.runGc = require_template_cache.runGc;
105
+ exports.templateBlockPackProvider = require_template_provider.templateBlockPackProvider;
96
106
  var _platforma_sdk_model = require("@platforma-sdk/model");
97
107
  Object.keys(_platforma_sdk_model).forEach(function(k) {
98
108
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  import { V2RegistryProvider } from "./block_registry/registry-v2-provider.js";
2
2
  import { BlockPackRegistry, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime } from "./block_registry/registry.js";
3
3
  import { CentralBlockRegistry, V1CentralDevSnapshotRegistry, V1CentralRegistry } from "./block_registry/well_known_registries.js";
4
+ import { AppliedEntry, TemplateApplyProblem, TemplateApplyReport, TemplateEntryRejected } from "./model/template_apply.js";
5
+ import { BlockPackProvider, ExactResolution, KindResolution, ResolvedEntry, TemplateResolveOutcome, parseBlockPackName, resolveTemplateEntries } from "./model/template_resolve.js";
6
+ import { KindAwareRegistry, kindCapableRegistryIds, templateBlockPackProvider } from "./block_registry/template_provider.js";
4
7
  import { BlockArgsAuthorKeyPrefix, ProjectCreatedTimestamp, ProjectField, ProjectId, ProjectLastModifiedTimestamp, ProjectListEntry, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, SchemaVersionCurrent, SchemaVersionKey } from "./model/project_model.js";
5
8
  import { AcceptanceFieldPrefix, EnvelopeAcceptance, EnvelopeData, EnvelopeMode, EnvelopeProject, ProjectChangeAction, ProjectFieldUuid, ShareId, ShareProjectsOptions, SharedEnvelopeResourceType, SharingDecision, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, acceptanceField, acceptanceFieldLogin, asShareId, canGrantToEveryone, canImpersonate, decisionField, decodeEnvelopeData, isAcceptanceField, newShareId } from "./model/sharing_model.js";
6
9
  import { OutgoingShare, PendingShare } from "./middle_layer/sharing_list.js";
7
10
  import { CachedTemplate, ExplicitTemplate, PreparedTemplate, TemplateFromFile, TemplateFromRegistry, TemplateSpecAny, TemplateSpecPrepared } from "./model/template_spec.js";
8
11
  import { BlockPackExplicit, BlockPackSpecAny, BlockPackSpecPrepared, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec } from "./model/block_pack_spec.js";
12
+ import { TemplateParseOutcome, parseProjectTemplateV1Yaml } from "./model/template_parser.js";
9
13
  import { Project } from "./middle_layer/project.js";
10
14
  import { DefaultDriverKitOpsPaths, DefaultDriverKitOpsSettings, DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings, DriverKitOps, DriverKitOpsConstructor, DriverKitOpsPaths, DriverKitOpsSettings, MiddleLayerDebugOptions, MiddleLayerOps, MiddleLayerOpsConstructor, MiddleLayerOpsPaths, MiddleLayerOpsSettings } from "./middle_layer/ops.js";
11
15
  import { MiddleLayerDriverKit, initDriverKit } from "./middle_layer/driver_kit.js";
@@ -24,4 +28,4 @@ export * from "@platforma-sdk/model";
24
28
  export * from "@milaboratories/pl-model-middle-layer";
25
29
  export * from "@milaboratories/pl-deployments";
26
30
  export * from "@milaboratories/pl-client";
27
- export { ACCESS_COUNT_KEY, ACCESS_KEY_PREFIX, AcceptanceFieldPrefix, BlockArgsAuthorKeyPrefix, BlockPackExplicit, BlockPackRegistry, BlockPackSpecAny, BlockPackSpecPrepared, CachedTemplate, CentralBlockRegistry, CheckNetworkOpts, DefaultDriverKitOpsPaths, DefaultDriverKitOpsSettings, DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings, DriverKitOps, DriverKitOpsConstructor, DriverKitOpsPaths, DriverKitOpsSettings, EnvelopeAcceptance, EnvelopeData, EnvelopeMode, EnvelopeProject, ExplicitTemplate, type FieldType, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec, GC_ACCESS_THRESHOLD, GC_MAX_ENTRIES, type InternalLsDriver, MiddleLayer, MiddleLayerDebugOptions, MiddleLayerDriverKit, MiddleLayerOps, MiddleLayerOpsConstructor, MiddleLayerOpsPaths, MiddleLayerOpsSettings, type OutgoingShare, type PendingShare, PreparedTemplate, Project, ProjectChangeAction, ProjectCreatedTimestamp, type ProjectField, ProjectFieldUuid, type ProjectId, ProjectLastModifiedTimestamp, type ProjectListEntry, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, ProjectsField, type ResourceType, SchemaVersionCurrent, SchemaVersionKey, ShareId, ShareProjectsOptions, SharedEnvelopeResourceType, SharingDecision, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, TemplateCacheFieldName, TemplateCacheStat, TemplateCacheType, TemplateFromFile, TemplateFromRegistry, TemplateSpecAny, TemplateSpecPrepared, TengoTemplateGet, TengoTemplateGetRegistry, TengoTemplateGetTemplate, TengoTemplateGetTemplateURI, TengoTemplatePack, TengoTemplatePackConvert, TengoTemplatePackConvertTemplate, TengoTemplatePackConvertTemplatePack, V1CentralDevSnapshotRegistry, V1CentralRegistry, V2RegistryProvider, acceptanceField, acceptanceFieldLogin, asShareId, cacheBlockPackTemplate, canGrantToEveryone, canImpersonate, checkNetwork, createRenderTemplate, decisionField, decodeEnvelopeData, deriveGlobalPObjectId, deriveLocalPObjectId, dropTemplateCache, duplicateProject, flattenTemplateTree, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime, getOrCreateTemplateCache, initDriverKit, initNetworkCheck, invalidateTemplateCacheId, isAcceptanceField, loadTemplate, loadTemplateCached, newShareId, parseFinalPObjectCollection, prepareTemplateSpec, runGc };
31
+ export { ACCESS_COUNT_KEY, ACCESS_KEY_PREFIX, AcceptanceFieldPrefix, type AppliedEntry, BlockArgsAuthorKeyPrefix, BlockPackExplicit, type BlockPackProvider, BlockPackRegistry, BlockPackSpecAny, BlockPackSpecPrepared, CachedTemplate, CentralBlockRegistry, CheckNetworkOpts, DefaultDriverKitOpsPaths, DefaultDriverKitOpsSettings, DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings, DriverKitOps, DriverKitOpsConstructor, DriverKitOpsPaths, DriverKitOpsSettings, EnvelopeAcceptance, EnvelopeData, EnvelopeMode, EnvelopeProject, type ExactResolution, ExplicitTemplate, type FieldType, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec, GC_ACCESS_THRESHOLD, GC_MAX_ENTRIES, type InternalLsDriver, KindAwareRegistry, type KindResolution, MiddleLayer, MiddleLayerDebugOptions, MiddleLayerDriverKit, MiddleLayerOps, MiddleLayerOpsConstructor, MiddleLayerOpsPaths, MiddleLayerOpsSettings, type OutgoingShare, type PendingShare, PreparedTemplate, Project, ProjectChangeAction, ProjectCreatedTimestamp, type ProjectField, ProjectFieldUuid, type ProjectId, ProjectLastModifiedTimestamp, type ProjectListEntry, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, ProjectsField, type ResolvedEntry, type ResourceType, SchemaVersionCurrent, SchemaVersionKey, ShareId, ShareProjectsOptions, SharedEnvelopeResourceType, SharingDecision, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, type TemplateApplyProblem, type TemplateApplyReport, TemplateCacheFieldName, TemplateCacheStat, TemplateCacheType, TemplateEntryRejected, TemplateFromFile, TemplateFromRegistry, type TemplateParseOutcome, type TemplateResolveOutcome, TemplateSpecAny, TemplateSpecPrepared, TengoTemplateGet, TengoTemplateGetRegistry, TengoTemplateGetTemplate, TengoTemplateGetTemplateURI, TengoTemplatePack, TengoTemplatePackConvert, TengoTemplatePackConvertTemplate, TengoTemplatePackConvertTemplatePack, V1CentralDevSnapshotRegistry, V1CentralRegistry, V2RegistryProvider, acceptanceField, acceptanceFieldLogin, asShareId, cacheBlockPackTemplate, canGrantToEveryone, canImpersonate, checkNetwork, createRenderTemplate, decisionField, decodeEnvelopeData, deriveGlobalPObjectId, deriveLocalPObjectId, dropTemplateCache, duplicateProject, flattenTemplateTree, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime, getOrCreateTemplateCache, initDriverKit, initNetworkCheck, invalidateTemplateCacheId, isAcceptanceField, kindCapableRegistryIds, loadTemplate, loadTemplateCached, newShareId, parseBlockPackName, parseFinalPObjectCollection, parseProjectTemplateV1Yaml, prepareTemplateSpec, resolveTemplateEntries, runGc, templateBlockPackProvider };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { BlockPackRegistry, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime } from "./block_registry/registry.js";
2
2
  import { V2RegistryProvider } from "./block_registry/registry-v2-provider.js";
3
3
  import { CentralBlockRegistry, V1CentralDevSnapshotRegistry, V1CentralRegistry } from "./block_registry/well_known_registries.js";
4
+ import { kindCapableRegistryIds, templateBlockPackProvider } from "./block_registry/template_provider.js";
4
5
  import "./block_registry/index.js";
5
6
  import { BlockArgsAuthorKeyPrefix, ProjectCreatedTimestamp, ProjectLastModifiedTimestamp, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, SchemaVersionCurrent, SchemaVersionKey } from "./model/project_model.js";
6
7
  import { ProjectsField } from "./middle_layer/project_list.js";
@@ -8,6 +9,9 @@ import { createRenderTemplate } from "./mutator/template/render_template.js";
8
9
  import { TengoTemplateGet, TengoTemplateGetRegistry, TengoTemplateGetTemplate, TengoTemplateGetTemplateURI, TengoTemplatePack, TengoTemplatePackConvert, TengoTemplatePackConvertTemplate, TengoTemplatePackConvertTemplatePack, loadTemplate, prepareTemplateSpec } from "./mutator/template/template_loading.js";
9
10
  import { FrontendFromFolderResourceType, FrontendFromLocalTgzResourceType, FrontendFromUrlResourceType } from "./model/block_pack_spec.js";
10
11
  import { AcceptanceFieldPrefix, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, acceptanceField, acceptanceFieldLogin, asShareId, canGrantToEveryone, canImpersonate, decisionField, decodeEnvelopeData, isAcceptanceField, newShareId } from "./model/sharing_model.js";
12
+ import { parseProjectTemplateV1Yaml } from "./model/template_parser.js";
13
+ import { parseBlockPackName, resolveTemplateEntries } from "./model/template_resolve.js";
14
+ import { TemplateEntryRejected } from "./model/template_apply.js";
11
15
  import "./model/index.js";
12
16
  import { duplicateProject } from "./mutator/project.js";
13
17
  import { deriveGlobalPObjectId, deriveLocalPObjectId } from "./pool/data.js";
@@ -23,4 +27,4 @@ export * from "@platforma-sdk/model";
23
27
  export * from "@milaboratories/pl-model-middle-layer";
24
28
  export * from "@milaboratories/pl-deployments";
25
29
  export * from "@milaboratories/pl-client";
26
- export { ACCESS_COUNT_KEY, ACCESS_KEY_PREFIX, AcceptanceFieldPrefix, BlockArgsAuthorKeyPrefix, BlockPackRegistry, CentralBlockRegistry, DefaultDriverKitOpsPaths, DefaultDriverKitOpsSettings, DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings, FrontendFromFolderResourceType, FrontendFromLocalTgzResourceType, FrontendFromUrlResourceType, GC_ACCESS_THRESHOLD, GC_MAX_ENTRIES, MiddleLayer, Project, ProjectCreatedTimestamp, ProjectLastModifiedTimestamp, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, ProjectsField, SchemaVersionCurrent, SchemaVersionKey, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, TemplateCacheFieldName, TemplateCacheType, TengoTemplateGet, TengoTemplateGetRegistry, TengoTemplateGetTemplate, TengoTemplateGetTemplateURI, TengoTemplatePack, TengoTemplatePackConvert, TengoTemplatePackConvertTemplate, TengoTemplatePackConvertTemplatePack, V1CentralDevSnapshotRegistry, V1CentralRegistry, V2RegistryProvider, acceptanceField, acceptanceFieldLogin, asShareId, cacheBlockPackTemplate, canGrantToEveryone, canImpersonate, checkNetwork, createRenderTemplate, decisionField, decodeEnvelopeData, deriveGlobalPObjectId, deriveLocalPObjectId, dropTemplateCache, duplicateProject, flattenTemplateTree, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime, getOrCreateTemplateCache, initDriverKit, initNetworkCheck, invalidateTemplateCacheId, isAcceptanceField, loadTemplate, loadTemplateCached, newShareId, parseFinalPObjectCollection, prepareTemplateSpec, runGc };
30
+ export { ACCESS_COUNT_KEY, ACCESS_KEY_PREFIX, AcceptanceFieldPrefix, BlockArgsAuthorKeyPrefix, BlockPackRegistry, CentralBlockRegistry, DefaultDriverKitOpsPaths, DefaultDriverKitOpsSettings, DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings, FrontendFromFolderResourceType, FrontendFromLocalTgzResourceType, FrontendFromUrlResourceType, GC_ACCESS_THRESHOLD, GC_MAX_ENTRIES, MiddleLayer, Project, ProjectCreatedTimestamp, ProjectLastModifiedTimestamp, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, ProjectsField, SchemaVersionCurrent, SchemaVersionKey, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, TemplateCacheFieldName, TemplateCacheType, TemplateEntryRejected, TengoTemplateGet, TengoTemplateGetRegistry, TengoTemplateGetTemplate, TengoTemplateGetTemplateURI, TengoTemplatePack, TengoTemplatePackConvert, TengoTemplatePackConvertTemplate, TengoTemplatePackConvertTemplatePack, V1CentralDevSnapshotRegistry, V1CentralRegistry, V2RegistryProvider, acceptanceField, acceptanceFieldLogin, asShareId, cacheBlockPackTemplate, canGrantToEveryone, canImpersonate, checkNetwork, createRenderTemplate, decisionField, decodeEnvelopeData, deriveGlobalPObjectId, deriveLocalPObjectId, dropTemplateCache, duplicateProject, flattenTemplateTree, getDevV1PacketMtime, getDevV2PacketMtime, getFromPackV2Mtime, getOrCreateTemplateCache, initDriverKit, initNetworkCheck, invalidateTemplateCacheId, isAcceptanceField, kindCapableRegistryIds, loadTemplate, loadTemplateCached, newShareId, parseBlockPackName, parseFinalPObjectCollection, parseProjectTemplateV1Yaml, prepareTemplateSpec, resolveTemplateEntries, runGc, templateBlockPackProvider };
@@ -6,10 +6,10 @@ const require_column_registry = require("./column_registry.cjs");
6
6
  const require_spec_override_collapse = require("./spec_override_collapse.cjs");
7
7
  let _platforma_sdk_model = require("@platforma-sdk/model");
8
8
  let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
9
+ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
9
10
  let _milaboratories_computable = require("@milaboratories/computable");
10
11
  let node_crypto = require("node:crypto");
11
12
  let quickjs_emscripten = require("quickjs-emscripten");
12
- let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
13
13
  //#region src/js_render/computable_context.ts
14
14
  var ComputableContextHelper = class {
15
15
  parent;
@@ -6,10 +6,10 @@ import { buildColumnRegistry, resolvePColumnById } from "./column_registry.js";
6
6
  import { collapseSpecOverrideNode } from "./spec_override_collapse.js";
7
7
  import { MainAccessorName, StagingAccessorName, checkBlockFlag, isDataInfo, mapDataInfo, mapPObjectData, mapPTableDef, mapPTableDefV2, mapValueInVOE } from "@platforma-sdk/model";
8
8
  import { notEmpty } from "@milaboratories/ts-helpers";
9
+ import { PoolEntryGuard, ServiceInjectionError, ServiceMethodNotFoundError, Services, resolveRequiredServices, serviceFnKey } from "@milaboratories/pl-model-common";
9
10
  import { Computable } from "@milaboratories/computable";
10
11
  import { randomUUID } from "node:crypto";
11
12
  import { Scope } from "quickjs-emscripten";
12
- import { PoolEntryGuard, ServiceInjectionError, ServiceMethodNotFoundError, Services, resolveRequiredServices, serviceFnKey } from "@milaboratories/pl-model-common";
13
13
  //#region src/js_render/computable_context.ts
14
14
  var ComputableContextHelper = class {
15
15
  parent;
@@ -1,9 +1,9 @@
1
1
  import { InternalPFrameDriver } from "../pool/driver.js";
2
2
  import { DriverKitOpsConstructor } from "./ops.js";
3
3
  import { Signer } from "@milaboratories/ts-helpers";
4
+ import * as Sdk from "@milaboratories/pl-model-common";
4
5
  import { PlClient } from "@milaboratories/pl-client";
5
6
  import { DownloadBlobToURLDriver, DownloadDriver, DownloadUrlDriver, InternalLsDriver, LogsDriver, UploadDriver } from "@milaboratories/pl-drivers";
6
- import * as Sdk from "@milaboratories/pl-model-common";
7
7
 
8
8
  //#region src/middle_layer/driver_kit.d.ts
9
9
  /**