@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.js CHANGED
@@ -4513,7 +4513,10 @@ var ARTIFACT_FIELD_TO_TYPE = {
4513
4513
  dashboards: "dashboard",
4514
4514
  reports: "report",
4515
4515
  actions: "action",
4516
- themes: "theme",
4516
+ // `themes: 'theme'` removed at #10485 (ADR-0049): the carrier key is
4517
+ // retired, so a parsed artifact can no longer carry the field — and the
4518
+ // ingest half of the dead pipeline (items stored, read by nothing) goes
4519
+ // with the authoring half rather than surviving it as drift.
4517
4520
  workflows: "workflow",
4518
4521
  flows: "flow",
4519
4522
  // ADR-0090 D3: stacks declare `positions` (stack.zod.ts); the retired
@@ -4566,6 +4569,7 @@ var MetadataPlugin = class {
4566
4569
  */
4567
4570
  this.optionalDependencies = ["com.objectstack.engine.objectql"];
4568
4571
  this.init = async (ctx) => {
4572
+ this.initCtx = ctx;
4569
4573
  ctx.logger.info("Initializing Metadata Manager", {
4570
4574
  root: this.options.rootDir || process.cwd(),
4571
4575
  watch: this.options.watch,
@@ -4747,7 +4751,22 @@ var MetadataPlugin = class {
4747
4751
  console.warn("[MetadataPlugin] Failed to register HMR endpoint", e?.message);
4748
4752
  }
4749
4753
  };
4750
- this.stop = async (ctx) => {
4754
+ /**
4755
+ * Teardown — the kernel's ONLY teardown hook.
4756
+ *
4757
+ * [#10772] This body used to be spelled `stop(ctx)`. `Plugin`
4758
+ * (`@objectstack/core`'s `types.ts`) declares `init()`, `start?(ctx)` and
4759
+ * `destroy?()` and no `stop()`, and `ObjectKernel.performShutdown()` /
4760
+ * `LiteKernel.destroy()` walk the plugins in reverse calling
4761
+ * `plugin.destroy()` — so the artifact watcher, the manager and the
4762
+ * repository were all still held after `await kernel.shutdown()` had
4763
+ * RESOLVED. The `start`/`stop` pair read symmetric to a reviewer because
4764
+ * `start()` really is on the interface; only one half was ever called.
4765
+ *
4766
+ * Idempotent: every handle is cleared as it is released, so a second
4767
+ * teardown is a no-op rather than a second close.
4768
+ */
4769
+ this.destroy = async () => {
4751
4770
  if (this.artifactWatcher) {
4752
4771
  try {
4753
4772
  await this.artifactWatcher.close();
@@ -4758,7 +4777,7 @@ var MetadataPlugin = class {
4758
4777
  try {
4759
4778
  await this.manager.dispose();
4760
4779
  } catch (e) {
4761
- ctx.logger.warn("[MetadataPlugin] manager.dispose() failed", { error: e?.message });
4780
+ this.initCtx?.logger?.warn?.("[MetadataPlugin] manager.dispose() failed", { error: e?.message });
4762
4781
  }
4763
4782
  const repo = this.repository;
4764
4783
  if (repo && typeof repo.close === "function") {
@@ -4769,13 +4788,25 @@ var MetadataPlugin = class {
4769
4788
  }
4770
4789
  this.repository = void 0;
4771
4790
  };
4791
+ /**
4792
+ * Retained alias for {@link destroy}. Kept because it is public API of an
4793
+ * exported class: an embedder may have learned to call it directly
4794
+ * precisely BECAUSE the kernel never did, and deleting it would break them.
4795
+ * Still an arrow property, so a detached `const { stop } = plugin` call
4796
+ * keeps working too. The parameter is now optional and ignored —
4797
+ * `destroy()` takes no context, so teardown logs through the context
4798
+ * captured in `init()`.
4799
+ */
4800
+ this.stop = async (_ctx) => {
4801
+ await this.destroy();
4802
+ };
4772
4803
  this.options = {
4773
- watch: true,
4774
- ...options
4804
+ ...options,
4805
+ watch: options.watch ?? false
4775
4806
  };
4776
4807
  const rootDir = this.options.rootDir || process.cwd();
4777
4808
  const bootstrapMode = this.options.config?.bootstrap ?? "eager";
4778
- const effectiveWatch = bootstrapMode === "artifact-only" ? false : this.options.watch ?? true;
4809
+ const effectiveWatch = bootstrapMode === "artifact-only" ? false : this.options.watch ?? false;
4779
4810
  this.manager = new NodeMetadataManager({
4780
4811
  rootDir,
4781
4812
  watch: effectiveWatch,