@objectstack/metadata 7.0.0 → 7.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
@@ -358,7 +358,18 @@ declare class MetadataManager implements IMetadataService {
358
358
  importMetadata(data: unknown, options?: MetadataImportOptions): Promise<MetadataImportResult>;
359
359
  /**
360
360
  * Validate a metadata item against its type schema.
361
- * Returns validation result with errors and warnings.
361
+ *
362
+ * NOTE: This is a lightweight structural check (presence of `name`,
363
+ * basic shape). The authoritative spec validation lives in
364
+ * `protocol.saveMetaItem` (write path) and is surfaced on read
365
+ * paths via the `_diagnostics` envelope attached by
366
+ * `protocol.getMetaItems` / `getMetaItem`. Both delegate to
367
+ * `getMetadataTypeSchema()` — the single source of truth. We
368
+ * deliberately do NOT run the full Zod schema here because
369
+ * `MetadataManager`'s registry stores *publish envelopes*
370
+ * (`{name, packageId, state, metadata: {...spec}}`), not raw spec
371
+ * documents — running spec validation against the envelope would
372
+ * yield false negatives.
362
373
  */
363
374
  validate(_type: string, data: unknown): Promise<MetadataValidationResult>;
364
375
  /**
@@ -863,27 +874,6 @@ declare class DatabaseLoader implements MetadataLoader {
863
874
  delete(type: string, name: string): Promise<void>;
864
875
  }
865
876
 
866
- /**
867
- * Metadata History API Routes
868
- *
869
- * REST API endpoints for metadata version history, rollback, and diff operations.
870
- * These routes extend the standard metadata API with history-specific functionality.
871
- *
872
- * Routes:
873
- * - GET /api/v1/metadata/:type/:name/history - Get version history
874
- * - POST /api/v1/metadata/:type/:name/rollback - Rollback to a specific version
875
- * - GET /api/v1/metadata/:type/:name/diff - Compare two versions
876
- */
877
-
878
- /**
879
- * Register metadata history routes on a Hono app or any HTTP server.
880
- *
881
- * @param app - The HTTP server/router instance (Hono-compatible)
882
- * @param metadataService - The metadata service instance
883
- */
884
- declare function registerMetadataHistoryRoutes(app: any, // Hono app or compatible
885
- metadataService: IMetadataService): void;
886
-
887
877
  /**
888
878
  * Metadata History Utilities
889
879
  *
@@ -1028,4 +1018,4 @@ declare class TypeScriptSerializer implements MetadataSerializer {
1028
1018
  getFormat(): MetadataFormat;
1029
1019
  }
1030
1020
 
1031
- export { DatabaseLoader, type DatabaseLoaderOptions, HistoryCleanupManager, JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer, calculateChecksum, generateDiffSummary, generateSimpleDiff, registerMetadataHistoryRoutes };
1021
+ export { DatabaseLoader, type DatabaseLoaderOptions, HistoryCleanupManager, JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer, calculateChecksum, generateDiffSummary, generateSimpleDiff };
package/dist/index.d.ts CHANGED
@@ -358,7 +358,18 @@ declare class MetadataManager implements IMetadataService {
358
358
  importMetadata(data: unknown, options?: MetadataImportOptions): Promise<MetadataImportResult>;
359
359
  /**
360
360
  * Validate a metadata item against its type schema.
361
- * Returns validation result with errors and warnings.
361
+ *
362
+ * NOTE: This is a lightweight structural check (presence of `name`,
363
+ * basic shape). The authoritative spec validation lives in
364
+ * `protocol.saveMetaItem` (write path) and is surfaced on read
365
+ * paths via the `_diagnostics` envelope attached by
366
+ * `protocol.getMetaItems` / `getMetaItem`. Both delegate to
367
+ * `getMetadataTypeSchema()` — the single source of truth. We
368
+ * deliberately do NOT run the full Zod schema here because
369
+ * `MetadataManager`'s registry stores *publish envelopes*
370
+ * (`{name, packageId, state, metadata: {...spec}}`), not raw spec
371
+ * documents — running spec validation against the envelope would
372
+ * yield false negatives.
362
373
  */
363
374
  validate(_type: string, data: unknown): Promise<MetadataValidationResult>;
364
375
  /**
@@ -863,27 +874,6 @@ declare class DatabaseLoader implements MetadataLoader {
863
874
  delete(type: string, name: string): Promise<void>;
864
875
  }
865
876
 
866
- /**
867
- * Metadata History API Routes
868
- *
869
- * REST API endpoints for metadata version history, rollback, and diff operations.
870
- * These routes extend the standard metadata API with history-specific functionality.
871
- *
872
- * Routes:
873
- * - GET /api/v1/metadata/:type/:name/history - Get version history
874
- * - POST /api/v1/metadata/:type/:name/rollback - Rollback to a specific version
875
- * - GET /api/v1/metadata/:type/:name/diff - Compare two versions
876
- */
877
-
878
- /**
879
- * Register metadata history routes on a Hono app or any HTTP server.
880
- *
881
- * @param app - The HTTP server/router instance (Hono-compatible)
882
- * @param metadataService - The metadata service instance
883
- */
884
- declare function registerMetadataHistoryRoutes(app: any, // Hono app or compatible
885
- metadataService: IMetadataService): void;
886
-
887
877
  /**
888
878
  * Metadata History Utilities
889
879
  *
@@ -1028,4 +1018,4 @@ declare class TypeScriptSerializer implements MetadataSerializer {
1028
1018
  getFormat(): MetadataFormat;
1029
1019
  }
1030
1020
 
1031
- export { DatabaseLoader, type DatabaseLoaderOptions, HistoryCleanupManager, JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer, calculateChecksum, generateDiffSummary, generateSimpleDiff, registerMetadataHistoryRoutes };
1021
+ export { DatabaseLoader, type DatabaseLoaderOptions, HistoryCleanupManager, JSONSerializer, MemoryLoader, type MetadataLoader, MetadataManager, type MetadataManagerOptions, MetadataPlugin, type MetadataSerializer, index as Migration, RemoteLoader, type SerializeOptions, TypeScriptSerializer, type WatchCallback, YAMLSerializer, calculateChecksum, generateDiffSummary, generateSimpleDiff };
package/dist/index.js CHANGED
@@ -2086,7 +2086,18 @@ var _MetadataManager = class _MetadataManager {
2086
2086
  // ==========================================
2087
2087
  /**
2088
2088
  * Validate a metadata item against its type schema.
2089
- * Returns validation result with errors and warnings.
2089
+ *
2090
+ * NOTE: This is a lightweight structural check (presence of `name`,
2091
+ * basic shape). The authoritative spec validation lives in
2092
+ * `protocol.saveMetaItem` (write path) and is surfaced on read
2093
+ * paths via the `_diagnostics` envelope attached by
2094
+ * `protocol.getMetaItems` / `getMetaItem`. Both delegate to
2095
+ * `getMetadataTypeSchema()` — the single source of truth. We
2096
+ * deliberately do NOT run the full Zod schema here because
2097
+ * `MetadataManager`'s registry stores *publish envelopes*
2098
+ * (`{name, packageId, state, metadata: {...spec}}`), not raw spec
2099
+ * documents — running spec validation against the envelope would
2100
+ * yield false negatives.
2090
2101
  */
2091
2102
  async validate(_type, data) {
2092
2103
  if (data === null || data === void 0) {
@@ -3093,11 +3104,13 @@ var MemoryLoader = class {
3093
3104
  import { DEFAULT_METADATA_TYPE_REGISTRY } from "@objectstack/spec/kernel";
3094
3105
  import {
3095
3106
  SysMetadataObject as SysMetadataObject2,
3096
- SysMetadataHistoryObject as SysMetadataHistoryObject2
3107
+ SysMetadataHistoryObject as SysMetadataHistoryObject2,
3108
+ SysMetadataAuditObject
3097
3109
  } from "@objectstack/platform-objects/metadata";
3098
3110
  var queryableMetadataObjects = [
3099
3111
  SysMetadataObject2,
3100
- SysMetadataHistoryObject2
3112
+ SysMetadataHistoryObject2,
3113
+ SysMetadataAuditObject
3101
3114
  ];
3102
3115
  var REPO_SUBDIR = ".objectstack/metadata";
3103
3116
  var ARTIFACT_FIELD_TO_TYPE = {
@@ -3126,6 +3139,7 @@ var ARTIFACT_FIELD_TO_TYPE = {
3126
3139
  mappings: "mapping",
3127
3140
  analyticsCubes: "analytics_cube",
3128
3141
  connectors: "connector",
3142
+ emailTemplates: "email_template",
3129
3143
  data: "dataset"
3130
3144
  };
3131
3145
  var MetadataPlugin = class {
@@ -3599,126 +3613,6 @@ var RemoteLoader = class {
3599
3613
  // src/index.ts
3600
3614
  import { SysMetadataObject as SysMetadataObject3, SysMetadataHistoryObject as SysMetadataHistoryObject3 } from "@objectstack/platform-objects/metadata";
3601
3615
 
3602
- // src/routes/history-routes.ts
3603
- function registerMetadataHistoryRoutes(app, metadataService) {
3604
- app.get("/api/v1/metadata/:type/:name/history", async (c) => {
3605
- if (!metadataService.getHistory) {
3606
- return c.json({ error: "History tracking not enabled" }, 501);
3607
- }
3608
- const { type, name } = c.req.param();
3609
- const query = c.req.query();
3610
- try {
3611
- const options = {};
3612
- if (query.limit !== void 0) {
3613
- const limit = parseInt(query.limit, 10);
3614
- if (!Number.isFinite(limit) || limit < 1) {
3615
- return c.json({ success: false, error: "limit must be a positive integer" }, 400);
3616
- }
3617
- options.limit = limit;
3618
- }
3619
- if (query.offset !== void 0) {
3620
- const offset = parseInt(query.offset, 10);
3621
- if (!Number.isFinite(offset) || offset < 0) {
3622
- return c.json({ success: false, error: "offset must be a non-negative integer" }, 400);
3623
- }
3624
- options.offset = offset;
3625
- }
3626
- if (query.since) options.since = query.since;
3627
- if (query.until) options.until = query.until;
3628
- if (query.operationType) options.operationType = query.operationType;
3629
- if (query.includeMetadata !== void 0) {
3630
- options.includeMetadata = query.includeMetadata === "true";
3631
- }
3632
- const result = await metadataService.getHistory(type, name, options);
3633
- return c.json({
3634
- success: true,
3635
- data: result
3636
- });
3637
- } catch (error) {
3638
- return c.json(
3639
- {
3640
- success: false,
3641
- error: error instanceof Error ? error.message : "Failed to retrieve history"
3642
- },
3643
- 500
3644
- );
3645
- }
3646
- });
3647
- app.post("/api/v1/metadata/:type/:name/rollback", async (c) => {
3648
- if (!metadataService.rollback) {
3649
- return c.json({ error: "Rollback not supported" }, 501);
3650
- }
3651
- const { type, name } = c.req.param();
3652
- try {
3653
- const body = await c.req.json();
3654
- const { version, changeNote, recordedBy } = body;
3655
- if (typeof version !== "number") {
3656
- return c.json(
3657
- {
3658
- success: false,
3659
- error: "Version number is required"
3660
- },
3661
- 400
3662
- );
3663
- }
3664
- const restoredMetadata = await metadataService.rollback(type, name, version, {
3665
- changeNote,
3666
- recordedBy
3667
- });
3668
- return c.json({
3669
- success: true,
3670
- data: {
3671
- type,
3672
- name,
3673
- version,
3674
- metadata: restoredMetadata
3675
- }
3676
- });
3677
- } catch (error) {
3678
- return c.json(
3679
- {
3680
- success: false,
3681
- error: error instanceof Error ? error.message : "Rollback failed"
3682
- },
3683
- 500
3684
- );
3685
- }
3686
- });
3687
- app.get("/api/v1/metadata/:type/:name/diff", async (c) => {
3688
- if (!metadataService.diff) {
3689
- return c.json({ error: "Diff not supported" }, 501);
3690
- }
3691
- const { type, name } = c.req.param();
3692
- const query = c.req.query();
3693
- try {
3694
- const version1 = parseInt(query.version1, 10);
3695
- const version2 = parseInt(query.version2, 10);
3696
- if (isNaN(version1) || isNaN(version2)) {
3697
- return c.json(
3698
- {
3699
- success: false,
3700
- error: "Both version1 and version2 query parameters are required"
3701
- },
3702
- 400
3703
- );
3704
- }
3705
- const diffResult = await metadataService.diff(type, name, version1, version2);
3706
- return c.json({
3707
- success: true,
3708
- data: diffResult
3709
- });
3710
- } catch (error) {
3711
- return c.json(
3712
- {
3713
- success: false,
3714
- error: error instanceof Error ? error.message : "Diff failed"
3715
- },
3716
- 500
3717
- );
3718
- }
3719
- });
3720
- }
3721
-
3722
3616
  // src/utils/history-cleanup.ts
3723
3617
  import { DEFAULT_METADATA_TYPE_REGISTRY as DEFAULT_METADATA_TYPE_REGISTRY2 } from "@objectstack/spec/kernel";
3724
3618
  function executionPinnedTypes() {
@@ -4009,7 +3903,6 @@ export {
4009
3903
  YAMLSerializer,
4010
3904
  calculateChecksum,
4011
3905
  generateDiffSummary,
4012
- generateSimpleDiff,
4013
- registerMetadataHistoryRoutes
3906
+ generateSimpleDiff
4014
3907
  };
4015
3908
  //# sourceMappingURL=index.js.map