@objectstack/metadata 17.0.0 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -4538,7 +4538,10 @@ var ARTIFACT_FIELD_TO_TYPE = {
4538
4538
  dashboards: "dashboard",
4539
4539
  reports: "report",
4540
4540
  actions: "action",
4541
- themes: "theme",
4541
+ // `themes: 'theme'` removed at #10485 (ADR-0049): the carrier key is
4542
+ // retired, so a parsed artifact can no longer carry the field — and the
4543
+ // ingest half of the dead pipeline (items stored, read by nothing) goes
4544
+ // with the authoring half rather than surviving it as drift.
4542
4545
  workflows: "workflow",
4543
4546
  flows: "flow",
4544
4547
  // ADR-0090 D3: stacks declare `positions` (stack.zod.ts); the retired
@@ -4591,6 +4594,7 @@ var MetadataPlugin = class {
4591
4594
  */
4592
4595
  this.optionalDependencies = ["com.objectstack.engine.objectql"];
4593
4596
  this.init = async (ctx) => {
4597
+ this.initCtx = ctx;
4594
4598
  ctx.logger.info("Initializing Metadata Manager", {
4595
4599
  root: this.options.rootDir || process.cwd(),
4596
4600
  watch: this.options.watch,
@@ -4772,7 +4776,22 @@ var MetadataPlugin = class {
4772
4776
  console.warn("[MetadataPlugin] Failed to register HMR endpoint", e?.message);
4773
4777
  }
4774
4778
  };
4775
- this.stop = async (ctx) => {
4779
+ /**
4780
+ * Teardown — the kernel's ONLY teardown hook.
4781
+ *
4782
+ * [#10772] This body used to be spelled `stop(ctx)`. `Plugin`
4783
+ * (`@objectstack/core`'s `types.ts`) declares `init()`, `start?(ctx)` and
4784
+ * `destroy?()` and no `stop()`, and `ObjectKernel.performShutdown()` /
4785
+ * `LiteKernel.destroy()` walk the plugins in reverse calling
4786
+ * `plugin.destroy()` — so the artifact watcher, the manager and the
4787
+ * repository were all still held after `await kernel.shutdown()` had
4788
+ * RESOLVED. The `start`/`stop` pair read symmetric to a reviewer because
4789
+ * `start()` really is on the interface; only one half was ever called.
4790
+ *
4791
+ * Idempotent: every handle is cleared as it is released, so a second
4792
+ * teardown is a no-op rather than a second close.
4793
+ */
4794
+ this.destroy = async () => {
4776
4795
  if (this.artifactWatcher) {
4777
4796
  try {
4778
4797
  await this.artifactWatcher.close();
@@ -4783,7 +4802,7 @@ var MetadataPlugin = class {
4783
4802
  try {
4784
4803
  await this.manager.dispose();
4785
4804
  } catch (e) {
4786
- ctx.logger.warn("[MetadataPlugin] manager.dispose() failed", { error: e?.message });
4805
+ this.initCtx?.logger?.warn?.("[MetadataPlugin] manager.dispose() failed", { error: e?.message });
4787
4806
  }
4788
4807
  const repo = this.repository;
4789
4808
  if (repo && typeof repo.close === "function") {
@@ -4794,13 +4813,25 @@ var MetadataPlugin = class {
4794
4813
  }
4795
4814
  this.repository = void 0;
4796
4815
  };
4816
+ /**
4817
+ * Retained alias for {@link destroy}. Kept because it is public API of an
4818
+ * exported class: an embedder may have learned to call it directly
4819
+ * precisely BECAUSE the kernel never did, and deleting it would break them.
4820
+ * Still an arrow property, so a detached `const { stop } = plugin` call
4821
+ * keeps working too. The parameter is now optional and ignored —
4822
+ * `destroy()` takes no context, so teardown logs through the context
4823
+ * captured in `init()`.
4824
+ */
4825
+ this.stop = async (_ctx) => {
4826
+ await this.destroy();
4827
+ };
4797
4828
  this.options = {
4798
- watch: true,
4799
- ...options
4829
+ ...options,
4830
+ watch: options.watch ?? false
4800
4831
  };
4801
4832
  const rootDir = this.options.rootDir || process.cwd();
4802
4833
  const bootstrapMode = this.options.config?.bootstrap ?? "eager";
4803
- const effectiveWatch = bootstrapMode === "artifact-only" ? false : this.options.watch ?? true;
4834
+ const effectiveWatch = bootstrapMode === "artifact-only" ? false : this.options.watch ?? false;
4804
4835
  this.manager = new NodeMetadataManager({
4805
4836
  rootDir,
4806
4837
  watch: effectiveWatch,