@eventcatalog/sdk 2.28.1 → 2.29.1

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.mts CHANGED
@@ -665,6 +665,8 @@ interface ToDSLOptions {
665
665
  type IndexResourceType = 'adr' | 'agent' | 'channel' | 'command' | 'container' | 'data-product' | 'diagram' | 'domain' | 'entity' | 'event' | 'flow' | 'query' | 'service' | 'system' | 'team' | 'user';
666
666
  type IndexSchema = Omit<SchemaPointer, 'file'> & {
667
667
  hash?: string;
668
+ /** Raw schema file text. Only present when the index was built with `includeSchemaContent`. */
669
+ content?: string;
668
670
  };
669
671
  type IndexSpecification = Specification & {
670
672
  hash?: string;
@@ -1420,6 +1422,7 @@ declare const FederationIndexSchema: z.ZodObject<{
1420
1422
  environments: z.ZodOptional<z.ZodArray<z.ZodString>>;
1421
1423
  default: z.ZodOptional<z.ZodBoolean>;
1422
1424
  hash: z.ZodOptional<z.ZodString>;
1425
+ content: z.ZodOptional<z.ZodString>;
1423
1426
  }, z.core.$strict>>>;
1424
1427
  specifications: z.ZodOptional<z.ZodArray<z.ZodObject<{
1425
1428
  type: z.ZodEnum<{
@@ -3519,11 +3522,12 @@ declare const _default: (path: string) => {
3519
3522
  * ```
3520
3523
  */
3521
3524
  createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
3522
- buildIndex: ({ source, commit, hashContent, includeFederated }: {
3525
+ buildIndex: ({ source, commit, hashContent, includeFederated, includeSchemaContent, }: {
3523
3526
  source: string;
3524
3527
  commit: string;
3525
3528
  hashContent?: boolean;
3526
3529
  includeFederated?: boolean;
3530
+ includeSchemaContent?: boolean;
3527
3531
  }) => Promise<Index>;
3528
3532
  diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
3529
3533
  listSnapshots: () => Promise<SnapshotMeta[]>;
package/dist/index.d.ts CHANGED
@@ -665,6 +665,8 @@ interface ToDSLOptions {
665
665
  type IndexResourceType = 'adr' | 'agent' | 'channel' | 'command' | 'container' | 'data-product' | 'diagram' | 'domain' | 'entity' | 'event' | 'flow' | 'query' | 'service' | 'system' | 'team' | 'user';
666
666
  type IndexSchema = Omit<SchemaPointer, 'file'> & {
667
667
  hash?: string;
668
+ /** Raw schema file text. Only present when the index was built with `includeSchemaContent`. */
669
+ content?: string;
668
670
  };
669
671
  type IndexSpecification = Specification & {
670
672
  hash?: string;
@@ -1420,6 +1422,7 @@ declare const FederationIndexSchema: z.ZodObject<{
1420
1422
  environments: z.ZodOptional<z.ZodArray<z.ZodString>>;
1421
1423
  default: z.ZodOptional<z.ZodBoolean>;
1422
1424
  hash: z.ZodOptional<z.ZodString>;
1425
+ content: z.ZodOptional<z.ZodString>;
1423
1426
  }, z.core.$strict>>>;
1424
1427
  specifications: z.ZodOptional<z.ZodArray<z.ZodObject<{
1425
1428
  type: z.ZodEnum<{
@@ -3519,11 +3522,12 @@ declare const _default: (path: string) => {
3519
3522
  * ```
3520
3523
  */
3521
3524
  createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
3522
- buildIndex: ({ source, commit, hashContent, includeFederated }: {
3525
+ buildIndex: ({ source, commit, hashContent, includeFederated, includeSchemaContent, }: {
3523
3526
  source: string;
3524
3527
  commit: string;
3525
3528
  hashContent?: boolean;
3526
3529
  includeFederated?: boolean;
3530
+ includeSchemaContent?: boolean;
3527
3531
  }) => Promise<Index>;
3528
3532
  diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
3529
3533
  listSnapshots: () => Promise<SnapshotMeta[]>;
package/dist/index.js CHANGED
@@ -1040,7 +1040,7 @@ var getResources = async (catalogDir, {
1040
1040
  }) => {
1041
1041
  const ignoreList = latestOnly ? `**/versioned/**` : "";
1042
1042
  const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
1043
- const files = await getFiles(filePattern, [ignoreList, ...ignore2]);
1043
+ const files = await getFiles(filePattern, ["**/examples/**", ignoreList, ...ignore2]);
1044
1044
  if (files.length === 0) return;
1045
1045
  return files.map((file) => {
1046
1046
  const { data, content } = cachedMatterRead(file);
@@ -3911,18 +3911,19 @@ var normalizeAssets = async (directory, hashContent, ignoreRules) => {
3911
3911
  );
3912
3912
  return assets.length === 0 ? void 0 : assets;
3913
3913
  };
3914
- var normalizeSchemas = async (resource, resourcePath, hashContent) => {
3914
+ var normalizeSchemas = async (resource, resourcePath, hashContent, includeSchemaContent) => {
3915
3915
  const schemas = resource.schemas ?? (resource.schemaPath ? [{ path: resource.schemaPath, default: true }] : void 0);
3916
3916
  if (schemas === void 0) return void 0;
3917
3917
  return Promise.all(
3918
3918
  schemas.map(async ({ file, ...schema }) => {
3919
3919
  const schemaPath = file ?? schema.path;
3920
+ const readSchema = schemaPath && (hashContent || includeSchemaContent);
3921
+ const bytes = readSchema ? await import_promises18.default.readFile(import_node_path26.default.join(import_node_path26.default.dirname(resourcePath), schemaPath)) : void 0;
3920
3922
  return {
3921
3923
  ...schema,
3922
3924
  ...schemaPath === void 0 ? {} : { path: schemaPath },
3923
- ...hashContent && schemaPath ? {
3924
- hash: `sha256:${(0, import_node_crypto2.createHash)("sha256").update(await import_promises18.default.readFile(import_node_path26.default.join(import_node_path26.default.dirname(resourcePath), schemaPath))).digest("hex")}`
3925
- } : {}
3925
+ ...bytes && hashContent ? { hash: `sha256:${(0, import_node_crypto2.createHash)("sha256").update(bytes).digest("hex")}` } : {},
3926
+ ...bytes && includeSchemaContent ? { content: bytes.toString("utf8") } : {}
3926
3927
  };
3927
3928
  })
3928
3929
  );
@@ -3969,9 +3970,9 @@ var normalizeSidecars = async (directory, resourcePath, resourceDirectories, rep
3969
3970
  );
3970
3971
  return sidecars.length === 0 ? void 0 : sidecars;
3971
3972
  };
3972
- var toIndexResource = async (directory, type, resource, hashContent, sourcePath, resourceDirectories, ignoreRules) => {
3973
+ var toIndexResource = async (directory, type, resource, hashContent, includeSchemaContent, sourcePath, resourceDirectories, ignoreRules) => {
3973
3974
  const { id, version, name } = resource;
3974
- const schemas = await normalizeSchemas(resource, sourcePath, hashContent);
3975
+ const schemas = await normalizeSchemas(resource, sourcePath, hashContent, includeSchemaContent);
3975
3976
  const specifications = await normalizeSpecifications(resource, sourcePath, hashContent);
3976
3977
  const representedPaths = new Set(
3977
3978
  [
@@ -4038,7 +4039,13 @@ var toIndexResource = async (directory, type, resource, hashContent, sourcePath,
4038
4039
  ...resource.members === void 0 ? {} : { members: resource.members }
4039
4040
  };
4040
4041
  };
4041
- var buildIndex = (directory) => async ({ source, commit, hashContent = true, includeFederated = true }) => {
4042
+ var buildIndex = (directory) => async ({
4043
+ source,
4044
+ commit,
4045
+ hashContent = true,
4046
+ includeFederated = true,
4047
+ includeSchemaContent = false
4048
+ }) => {
4042
4049
  const ignoreRules = await loadIgnoreRules(directory);
4043
4050
  const [
4044
4051
  domains,
@@ -4119,7 +4126,16 @@ var buildIndex = (directory) => async ({ source, commit, hashContent = true, inc
4119
4126
  );
4120
4127
  const resources = await Promise.all(
4121
4128
  locatedResources.map(
4122
- ({ type, resource, sourcePath }) => toIndexResource(directory, type, resource, hashContent, sourcePath, resourceDirectories, ignoreRules)
4129
+ ({ type, resource, sourcePath }) => toIndexResource(
4130
+ directory,
4131
+ type,
4132
+ resource,
4133
+ hashContent,
4134
+ includeSchemaContent,
4135
+ sourcePath,
4136
+ resourceDirectories,
4137
+ ignoreRules
4138
+ )
4123
4139
  )
4124
4140
  );
4125
4141
  const assets = await normalizeAssets(directory, hashContent, ignoreRules);
@@ -4638,7 +4654,8 @@ var IndexSchemaPointerSchema = import_zod.z.object({
4638
4654
  format: import_zod.z.string().optional(),
4639
4655
  environments: import_zod.z.array(import_zod.z.string()).optional(),
4640
4656
  default: import_zod.z.boolean().optional(),
4641
- hash: contentHash.optional()
4657
+ hash: contentHash.optional(),
4658
+ content: import_zod.z.string().optional()
4642
4659
  }).strict();
4643
4660
  var IndexSpecificationSchema = import_zod.z.object({
4644
4661
  type: import_zod.z.enum(["openapi", "asyncapi", "graphql"]),