@eventcatalog/core 0.0.0 → 0.0.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/CHANGELOG.md CHANGED
@@ -1 +1 @@
1
- # @eventcatalog/core
1
+ # @eventcatalog/core
@@ -79,16 +79,19 @@ export default function ContentView({
79
79
  )}
80
80
  </div>
81
81
  <div className="mt-4 flex space-x-3 md:mt-0">
82
- <button
82
+ <a
83
+ href={editUrl}
84
+ target="_blank"
83
85
  type="button"
84
86
  className="hidden md:inline-flex h-10 justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-900"
87
+ rel="noreferrer"
85
88
  >
86
89
  <PencilIcon
87
90
  className="-ml-1 mr-2 h-5 w-5 text-gray-400"
88
91
  aria-hidden="true"
89
92
  />
90
93
  <span>Edit</span>
91
- </button>
94
+ </a>
92
95
  </div>
93
96
  </div>
94
97
  <div className="py-3 xl:pt-6 xl:pb-0">
@@ -19,8 +19,8 @@ function EventSideBar({ event, loadedVersion }: EventSideBarProps) {
19
19
  try {
20
20
  const res = await fetch(`/api/event/${event.name}/download`);
21
21
  if (res.status === 404) throw new Error('Failed to find file');
22
- const data = await res.text();
23
- fileDownload(data, event.name);
22
+ const { schema, fileName } = await res.json();
23
+ fileDownload(schema, fileName);
24
24
  } catch (error) {
25
25
  // TODO: Maybe better error experince
26
26
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,16 +8,19 @@ export default function (req, res) {
8
8
  const eventDir = path.join(process.env.PROJECT_DIR, 'events', eventName);
9
9
 
10
10
  try {
11
- // Find the schema file
12
11
  const filesInEventDir = fs.readdirSync(eventDir);
13
12
  const schemaFileName = filesInEventDir.find((fileName) => fileName.indexOf('schema.') > -1);
14
13
 
15
14
  if (schemaFileName) {
15
+ const extension = schemaFileName.split('.').pop();
16
16
  const schemaFile = fs.readFileSync(path.join(eventDir, schemaFileName));
17
- res.send(schemaFile).end();
18
- } else {
19
- res.status(404).end();
17
+
18
+ res.send({
19
+ schema: schemaFile.toString(),
20
+ fileName: `${eventName}.${extension}`,
21
+ });
20
22
  }
23
+ res.status(404).end();
21
24
  } catch (error) {
22
25
  console.log(error);
23
26
  res.status(404).end();