@objectstack/metadata 6.9.0 → 7.1.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
@@ -550,7 +550,7 @@ async function migrateProjectIdToEnvironmentId(driver) {
550
550
  const driverAny = driver;
551
551
  if (typeof driverAny.raw !== "function") {
552
552
  throw new Error(
553
- "migrateProjectIdToEnvironmentId: driver must expose a .raw(sql, bindings?) method. SqlDriver (better-sqlite3/knex) and TursoDriver both support this."
553
+ "migrateProjectIdToEnvironmentId: driver must expose a .raw(sql, bindings?) method. migrateProjectIdToEnvironmentId: driver must expose a .raw(sql, bindings?) method. SqlDriver (better-sqlite3/knex) supports this; cloud-side TursoDriver also conforms."
554
554
  );
555
555
  }
556
556
  const results = [];
@@ -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) {
@@ -3126,6 +3137,7 @@ var ARTIFACT_FIELD_TO_TYPE = {
3126
3137
  mappings: "mapping",
3127
3138
  analyticsCubes: "analytics_cube",
3128
3139
  connectors: "connector",
3140
+ emailTemplates: "email_template",
3129
3141
  data: "dataset"
3130
3142
  };
3131
3143
  var MetadataPlugin = class {
@@ -3599,126 +3611,6 @@ var RemoteLoader = class {
3599
3611
  // src/index.ts
3600
3612
  import { SysMetadataObject as SysMetadataObject3, SysMetadataHistoryObject as SysMetadataHistoryObject3 } from "@objectstack/platform-objects/metadata";
3601
3613
 
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
3614
  // src/utils/history-cleanup.ts
3723
3615
  import { DEFAULT_METADATA_TYPE_REGISTRY as DEFAULT_METADATA_TYPE_REGISTRY2 } from "@objectstack/spec/kernel";
3724
3616
  function executionPinnedTypes() {
@@ -4009,7 +3901,6 @@ export {
4009
3901
  YAMLSerializer,
4010
3902
  calculateChecksum,
4011
3903
  generateDiffSummary,
4012
- generateSimpleDiff,
4013
- registerMetadataHistoryRoutes
3904
+ generateSimpleDiff
4014
3905
  };
4015
3906
  //# sourceMappingURL=index.js.map