@objectstack/metadata 17.1.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/index.d.cts CHANGED
@@ -1315,6 +1315,13 @@ declare class MetadataPlugin implements Plugin {
1315
1315
  private repository?;
1316
1316
  /** Chokidar watcher on the artifact file (local-file mode) — ADR-0008 PR-8. */
1317
1317
  private artifactWatcher?;
1318
+ /**
1319
+ * The context handed to `init()`, retained so `destroy()` can log.
1320
+ * [#10772] `Plugin.destroy()` takes NO argument — it is the kernel's only
1321
+ * teardown hook — so the context the old `stop(ctx)` alias received has to
1322
+ * be captured at init time instead of arriving at teardown time.
1323
+ */
1324
+ private initCtx?;
1318
1325
  /**
1319
1326
  * The most recently parsed artifact metadata (the plural-field record:
1320
1327
  * `objects`, `views`, `data`, …). Carried on the `metadata:reloaded`
@@ -1326,7 +1333,32 @@ declare class MetadataPlugin implements Plugin {
1326
1333
  constructor(options?: MetadataPluginOptions);
1327
1334
  init: (ctx: PluginContext) => Promise<void>;
1328
1335
  start: (ctx: PluginContext) => Promise<void>;
1329
- stop: (ctx: PluginContext) => Promise<void>;
1336
+ /**
1337
+ * Teardown — the kernel's ONLY teardown hook.
1338
+ *
1339
+ * [#10772] This body used to be spelled `stop(ctx)`. `Plugin`
1340
+ * (`@objectstack/core`'s `types.ts`) declares `init()`, `start?(ctx)` and
1341
+ * `destroy?()` and no `stop()`, and `ObjectKernel.performShutdown()` /
1342
+ * `LiteKernel.destroy()` walk the plugins in reverse calling
1343
+ * `plugin.destroy()` — so the artifact watcher, the manager and the
1344
+ * repository were all still held after `await kernel.shutdown()` had
1345
+ * RESOLVED. The `start`/`stop` pair read symmetric to a reviewer because
1346
+ * `start()` really is on the interface; only one half was ever called.
1347
+ *
1348
+ * Idempotent: every handle is cleared as it is released, so a second
1349
+ * teardown is a no-op rather than a second close.
1350
+ */
1351
+ destroy: () => Promise<void>;
1352
+ /**
1353
+ * Retained alias for {@link destroy}. Kept because it is public API of an
1354
+ * exported class: an embedder may have learned to call it directly
1355
+ * precisely BECAUSE the kernel never did, and deleting it would break them.
1356
+ * Still an arrow property, so a detached `const { stop } = plugin` call
1357
+ * keeps working too. The parameter is now optional and ignored —
1358
+ * `destroy()` takes no context, so teardown logs through the context
1359
+ * captured in `init()`.
1360
+ */
1361
+ stop: (_ctx?: PluginContext) => Promise<void>;
1330
1362
  /**
1331
1363
  * Fetch JSON content from a URL with configurable timeout.
1332
1364
  */
package/dist/index.d.ts CHANGED
@@ -1315,6 +1315,13 @@ declare class MetadataPlugin implements Plugin {
1315
1315
  private repository?;
1316
1316
  /** Chokidar watcher on the artifact file (local-file mode) — ADR-0008 PR-8. */
1317
1317
  private artifactWatcher?;
1318
+ /**
1319
+ * The context handed to `init()`, retained so `destroy()` can log.
1320
+ * [#10772] `Plugin.destroy()` takes NO argument — it is the kernel's only
1321
+ * teardown hook — so the context the old `stop(ctx)` alias received has to
1322
+ * be captured at init time instead of arriving at teardown time.
1323
+ */
1324
+ private initCtx?;
1318
1325
  /**
1319
1326
  * The most recently parsed artifact metadata (the plural-field record:
1320
1327
  * `objects`, `views`, `data`, …). Carried on the `metadata:reloaded`
@@ -1326,7 +1333,32 @@ declare class MetadataPlugin implements Plugin {
1326
1333
  constructor(options?: MetadataPluginOptions);
1327
1334
  init: (ctx: PluginContext) => Promise<void>;
1328
1335
  start: (ctx: PluginContext) => Promise<void>;
1329
- stop: (ctx: PluginContext) => Promise<void>;
1336
+ /**
1337
+ * Teardown — the kernel's ONLY teardown hook.
1338
+ *
1339
+ * [#10772] This body used to be spelled `stop(ctx)`. `Plugin`
1340
+ * (`@objectstack/core`'s `types.ts`) declares `init()`, `start?(ctx)` and
1341
+ * `destroy?()` and no `stop()`, and `ObjectKernel.performShutdown()` /
1342
+ * `LiteKernel.destroy()` walk the plugins in reverse calling
1343
+ * `plugin.destroy()` — so the artifact watcher, the manager and the
1344
+ * repository were all still held after `await kernel.shutdown()` had
1345
+ * RESOLVED. The `start`/`stop` pair read symmetric to a reviewer because
1346
+ * `start()` really is on the interface; only one half was ever called.
1347
+ *
1348
+ * Idempotent: every handle is cleared as it is released, so a second
1349
+ * teardown is a no-op rather than a second close.
1350
+ */
1351
+ destroy: () => Promise<void>;
1352
+ /**
1353
+ * Retained alias for {@link destroy}. Kept because it is public API of an
1354
+ * exported class: an embedder may have learned to call it directly
1355
+ * precisely BECAUSE the kernel never did, and deleting it would break them.
1356
+ * Still an arrow property, so a detached `const { stop } = plugin` call
1357
+ * keeps working too. The parameter is now optional and ignored —
1358
+ * `destroy()` takes no context, so teardown logs through the context
1359
+ * captured in `init()`.
1360
+ */
1361
+ stop: (_ctx?: PluginContext) => Promise<void>;
1330
1362
  /**
1331
1363
  * Fetch JSON content from a URL with configurable timeout.
1332
1364
  */
package/dist/index.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,6 +4788,18 @@ 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
4804
  ...options,
4774
4805
  watch: options.watch ?? false