@eventcatalog/sdk 0.0.5 → 0.0.6
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/commands.d.mts +172 -0
- package/dist/commands.d.ts +172 -0
- package/dist/commands.js +191 -0
- package/dist/commands.js.map +1 -0
- package/dist/commands.mjs +150 -0
- package/dist/commands.mjs.map +1 -0
- package/dist/events.d.mts +3 -3
- package/dist/events.d.ts +3 -3
- package/dist/events.js.map +1 -1
- package/dist/events.mjs.map +1 -1
- package/dist/index.d.mts +64 -1
- package/dist/index.d.ts +64 -1
- package/dist/index.js +86 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -16
- package/dist/index.mjs.map +1 -1
- package/dist/services.d.mts +2 -2
- package/dist/services.d.ts +2 -2
- package/dist/services.js.map +1 -1
- package/dist/services.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Command } from './types.d.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a command from EventCatalog.
|
|
5
|
+
*
|
|
6
|
+
* You can optionally specify a version to get a specific version of the command
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import utils from '@eventcatalog/utils';
|
|
11
|
+
*
|
|
12
|
+
* const { getCommand } = utils('/path/to/eventcatalog');
|
|
13
|
+
*
|
|
14
|
+
* // Gets the latest version of the command
|
|
15
|
+
* const command = await getCommand('UpdateInventory');
|
|
16
|
+
*
|
|
17
|
+
* // Gets a version of the command
|
|
18
|
+
* const command = await getCommand('UpdateInventory', '0.0.1');
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const getCommand: (directory: string) => (id: string, version?: string) => Promise<Command>;
|
|
22
|
+
/**
|
|
23
|
+
* Write a command to EventCatalog.
|
|
24
|
+
*
|
|
25
|
+
* You can optionally override the path of the command.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import utils from '@eventcatalog/utils';
|
|
30
|
+
*
|
|
31
|
+
* const { writeCommand } = utils('/path/to/eventcatalog');
|
|
32
|
+
*
|
|
33
|
+
* // Write a command to the catalog
|
|
34
|
+
* // Command would be written to commands/UpdateInventory
|
|
35
|
+
* await writeCommand({
|
|
36
|
+
* id: 'UpdateInventory',
|
|
37
|
+
* name: 'Update Inventory',
|
|
38
|
+
* version: '0.0.1',
|
|
39
|
+
* summary: 'This is a summary',
|
|
40
|
+
* markdown: '# Hello world',
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Write a command to the catalog but override the path
|
|
44
|
+
* // Command would be written to commands/Inventory/UpdateInventory
|
|
45
|
+
* await writeCommand({
|
|
46
|
+
* id: 'UpdateInventory',
|
|
47
|
+
* name: 'Update Inventory',
|
|
48
|
+
* version: '0.0.1',
|
|
49
|
+
* summary: 'This is a summary',
|
|
50
|
+
* markdown: '# Hello world',
|
|
51
|
+
* }, { path: "/Inventory/UpdateInventory"});
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const writeCommand: (directory: string) => (command: Command, options?: {
|
|
55
|
+
path: string;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a command at it's given path.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import utils from '@eventcatalog/utils';
|
|
63
|
+
*
|
|
64
|
+
* const { rmCommand } = utils('/path/to/eventcatalog');
|
|
65
|
+
*
|
|
66
|
+
* // removes a command at the given path (commands dir is appended to the given path)
|
|
67
|
+
* // Removes the command at commands/UpdateInventory
|
|
68
|
+
* await rmCommand('/UpdateInventory');
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const rmCommand: (directory: string) => (path: string) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a command by it's id.
|
|
74
|
+
*
|
|
75
|
+
* Optionally specify a version to delete a specific version of the command.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import utils from '@eventcatalog/utils';
|
|
80
|
+
*
|
|
81
|
+
* const { rmCommandById } = utils('/path/to/eventcatalog');
|
|
82
|
+
*
|
|
83
|
+
* // deletes the latest UpdateInventory command
|
|
84
|
+
* await rmCommandById('UpdateInventory');
|
|
85
|
+
*
|
|
86
|
+
* // deletes a specific version of the UpdateInventory command
|
|
87
|
+
* await rmCommandById('UpdateInventory', '0.0.1');
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare const rmCommandById: (directory: string) => (id: string, version?: string) => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Version a command by it's id.
|
|
93
|
+
*
|
|
94
|
+
* Takes the latest command and moves it to a versioned directory.
|
|
95
|
+
* All files with this command are also versioned (e.g /commands/UpdateInventory/schema.json)
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import utils from '@eventcatalog/utils';
|
|
100
|
+
*
|
|
101
|
+
* const { versionCommand } = utils('/path/to/eventcatalog');
|
|
102
|
+
*
|
|
103
|
+
* // moves the latest UpdateInventory command to a versioned directory
|
|
104
|
+
* // the version within that command is used as the version number.
|
|
105
|
+
* await versionCommand('UpdateInventory');
|
|
106
|
+
*
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare const versionCommand: (directory: string) => (id: string) => Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Add a file to a command by it's id.
|
|
112
|
+
*
|
|
113
|
+
* Optionally specify a version to add a file to a specific version of the command.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import utils from '@eventcatalog/utils';
|
|
118
|
+
*
|
|
119
|
+
* const { addFileToCommand } = utils('/path/to/eventcatalog');
|
|
120
|
+
*
|
|
121
|
+
* // adds a file to the latest UpdateInventory command
|
|
122
|
+
* await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' });
|
|
123
|
+
*
|
|
124
|
+
* // adds a file to a specific version of the UpdateInventory command
|
|
125
|
+
* await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
|
|
126
|
+
*
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare const addFileToCommand: (directory: string) => (id: string, file: {
|
|
130
|
+
content: string;
|
|
131
|
+
fileName: string;
|
|
132
|
+
}, version?: string) => Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Add a schema to a command by it's id.
|
|
135
|
+
*
|
|
136
|
+
* Optionally specify a version to add a schema to a specific version of the command.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import utils from '@eventcatalog/utils';
|
|
141
|
+
*
|
|
142
|
+
* const { addSchemaToCommand } = utils('/path/to/eventcatalog');
|
|
143
|
+
*
|
|
144
|
+
* // JSON schema example
|
|
145
|
+
* const schema = {
|
|
146
|
+
* "$schema": "http://json-schema.org/draft-07/schema#",
|
|
147
|
+
* "type": "object",
|
|
148
|
+
* "properties": {
|
|
149
|
+
* "name": {
|
|
150
|
+
* "type": "string"
|
|
151
|
+
* },
|
|
152
|
+
* "age": {
|
|
153
|
+
* "type": "number"
|
|
154
|
+
* }
|
|
155
|
+
* },
|
|
156
|
+
* "required": ["name", "age"]
|
|
157
|
+
* };
|
|
158
|
+
*
|
|
159
|
+
* // adds a schema to the latest UpdateInventory command
|
|
160
|
+
* await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' });
|
|
161
|
+
*
|
|
162
|
+
* // adds a file to a specific version of the UpdateInventory command
|
|
163
|
+
* await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' }, '0.0.1');
|
|
164
|
+
*
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare const addSchemaToCommand: (directory: string) => (id: string, schema: {
|
|
168
|
+
schema: string;
|
|
169
|
+
fileName: string;
|
|
170
|
+
}, version?: string) => Promise<void>;
|
|
171
|
+
|
|
172
|
+
export { addFileToCommand, addSchemaToCommand, getCommand, rmCommand, rmCommandById, versionCommand, writeCommand };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Command } from './types.d.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a command from EventCatalog.
|
|
5
|
+
*
|
|
6
|
+
* You can optionally specify a version to get a specific version of the command
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import utils from '@eventcatalog/utils';
|
|
11
|
+
*
|
|
12
|
+
* const { getCommand } = utils('/path/to/eventcatalog');
|
|
13
|
+
*
|
|
14
|
+
* // Gets the latest version of the command
|
|
15
|
+
* const command = await getCommand('UpdateInventory');
|
|
16
|
+
*
|
|
17
|
+
* // Gets a version of the command
|
|
18
|
+
* const command = await getCommand('UpdateInventory', '0.0.1');
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const getCommand: (directory: string) => (id: string, version?: string) => Promise<Command>;
|
|
22
|
+
/**
|
|
23
|
+
* Write a command to EventCatalog.
|
|
24
|
+
*
|
|
25
|
+
* You can optionally override the path of the command.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import utils from '@eventcatalog/utils';
|
|
30
|
+
*
|
|
31
|
+
* const { writeCommand } = utils('/path/to/eventcatalog');
|
|
32
|
+
*
|
|
33
|
+
* // Write a command to the catalog
|
|
34
|
+
* // Command would be written to commands/UpdateInventory
|
|
35
|
+
* await writeCommand({
|
|
36
|
+
* id: 'UpdateInventory',
|
|
37
|
+
* name: 'Update Inventory',
|
|
38
|
+
* version: '0.0.1',
|
|
39
|
+
* summary: 'This is a summary',
|
|
40
|
+
* markdown: '# Hello world',
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Write a command to the catalog but override the path
|
|
44
|
+
* // Command would be written to commands/Inventory/UpdateInventory
|
|
45
|
+
* await writeCommand({
|
|
46
|
+
* id: 'UpdateInventory',
|
|
47
|
+
* name: 'Update Inventory',
|
|
48
|
+
* version: '0.0.1',
|
|
49
|
+
* summary: 'This is a summary',
|
|
50
|
+
* markdown: '# Hello world',
|
|
51
|
+
* }, { path: "/Inventory/UpdateInventory"});
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const writeCommand: (directory: string) => (command: Command, options?: {
|
|
55
|
+
path: string;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a command at it's given path.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import utils from '@eventcatalog/utils';
|
|
63
|
+
*
|
|
64
|
+
* const { rmCommand } = utils('/path/to/eventcatalog');
|
|
65
|
+
*
|
|
66
|
+
* // removes a command at the given path (commands dir is appended to the given path)
|
|
67
|
+
* // Removes the command at commands/UpdateInventory
|
|
68
|
+
* await rmCommand('/UpdateInventory');
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const rmCommand: (directory: string) => (path: string) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a command by it's id.
|
|
74
|
+
*
|
|
75
|
+
* Optionally specify a version to delete a specific version of the command.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import utils from '@eventcatalog/utils';
|
|
80
|
+
*
|
|
81
|
+
* const { rmCommandById } = utils('/path/to/eventcatalog');
|
|
82
|
+
*
|
|
83
|
+
* // deletes the latest UpdateInventory command
|
|
84
|
+
* await rmCommandById('UpdateInventory');
|
|
85
|
+
*
|
|
86
|
+
* // deletes a specific version of the UpdateInventory command
|
|
87
|
+
* await rmCommandById('UpdateInventory', '0.0.1');
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare const rmCommandById: (directory: string) => (id: string, version?: string) => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Version a command by it's id.
|
|
93
|
+
*
|
|
94
|
+
* Takes the latest command and moves it to a versioned directory.
|
|
95
|
+
* All files with this command are also versioned (e.g /commands/UpdateInventory/schema.json)
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import utils from '@eventcatalog/utils';
|
|
100
|
+
*
|
|
101
|
+
* const { versionCommand } = utils('/path/to/eventcatalog');
|
|
102
|
+
*
|
|
103
|
+
* // moves the latest UpdateInventory command to a versioned directory
|
|
104
|
+
* // the version within that command is used as the version number.
|
|
105
|
+
* await versionCommand('UpdateInventory');
|
|
106
|
+
*
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare const versionCommand: (directory: string) => (id: string) => Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Add a file to a command by it's id.
|
|
112
|
+
*
|
|
113
|
+
* Optionally specify a version to add a file to a specific version of the command.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import utils from '@eventcatalog/utils';
|
|
118
|
+
*
|
|
119
|
+
* const { addFileToCommand } = utils('/path/to/eventcatalog');
|
|
120
|
+
*
|
|
121
|
+
* // adds a file to the latest UpdateInventory command
|
|
122
|
+
* await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' });
|
|
123
|
+
*
|
|
124
|
+
* // adds a file to a specific version of the UpdateInventory command
|
|
125
|
+
* await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
|
|
126
|
+
*
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare const addFileToCommand: (directory: string) => (id: string, file: {
|
|
130
|
+
content: string;
|
|
131
|
+
fileName: string;
|
|
132
|
+
}, version?: string) => Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Add a schema to a command by it's id.
|
|
135
|
+
*
|
|
136
|
+
* Optionally specify a version to add a schema to a specific version of the command.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import utils from '@eventcatalog/utils';
|
|
141
|
+
*
|
|
142
|
+
* const { addSchemaToCommand } = utils('/path/to/eventcatalog');
|
|
143
|
+
*
|
|
144
|
+
* // JSON schema example
|
|
145
|
+
* const schema = {
|
|
146
|
+
* "$schema": "http://json-schema.org/draft-07/schema#",
|
|
147
|
+
* "type": "object",
|
|
148
|
+
* "properties": {
|
|
149
|
+
* "name": {
|
|
150
|
+
* "type": "string"
|
|
151
|
+
* },
|
|
152
|
+
* "age": {
|
|
153
|
+
* "type": "number"
|
|
154
|
+
* }
|
|
155
|
+
* },
|
|
156
|
+
* "required": ["name", "age"]
|
|
157
|
+
* };
|
|
158
|
+
*
|
|
159
|
+
* // adds a schema to the latest UpdateInventory command
|
|
160
|
+
* await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' });
|
|
161
|
+
*
|
|
162
|
+
* // adds a file to a specific version of the UpdateInventory command
|
|
163
|
+
* await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' }, '0.0.1');
|
|
164
|
+
*
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare const addSchemaToCommand: (directory: string) => (id: string, schema: {
|
|
168
|
+
schema: string;
|
|
169
|
+
fileName: string;
|
|
170
|
+
}, version?: string) => Promise<void>;
|
|
171
|
+
|
|
172
|
+
export { addFileToCommand, addSchemaToCommand, getCommand, rmCommand, rmCommandById, versionCommand, writeCommand };
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/commands.ts
|
|
31
|
+
var commands_exports = {};
|
|
32
|
+
__export(commands_exports, {
|
|
33
|
+
addFileToCommand: () => addFileToCommand,
|
|
34
|
+
addSchemaToCommand: () => addSchemaToCommand,
|
|
35
|
+
getCommand: () => getCommand,
|
|
36
|
+
rmCommand: () => rmCommand,
|
|
37
|
+
rmCommandById: () => rmCommandById,
|
|
38
|
+
versionCommand: () => versionCommand,
|
|
39
|
+
writeCommand: () => writeCommand
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(commands_exports);
|
|
42
|
+
var import_promises3 = __toESM(require("fs/promises"));
|
|
43
|
+
var import_node_path2 = require("path");
|
|
44
|
+
|
|
45
|
+
// src/internal/resources.ts
|
|
46
|
+
var import_path = require("path");
|
|
47
|
+
|
|
48
|
+
// src/internal/utils.ts
|
|
49
|
+
var import_glob = require("glob");
|
|
50
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
51
|
+
var import_fs_extra = require("fs-extra");
|
|
52
|
+
var import_node_path = require("path");
|
|
53
|
+
var versionExists = async (catalogDir, id, version) => {
|
|
54
|
+
const files = await getFiles(`${catalogDir}/**/index.md`);
|
|
55
|
+
const matchedFiles = await searchFilesForId(files, id, version) || [];
|
|
56
|
+
return matchedFiles.length > 0;
|
|
57
|
+
};
|
|
58
|
+
var findFileById = async (catalogDir, id, version) => {
|
|
59
|
+
const files = await getFiles(`${catalogDir}/**/index.md`);
|
|
60
|
+
const matchedFiles = await searchFilesForId(files, id) || [];
|
|
61
|
+
if (!version) {
|
|
62
|
+
return matchedFiles.find((path) => !path.includes("versioned"));
|
|
63
|
+
}
|
|
64
|
+
return matchedFiles.find((path) => path.includes(`versioned/${version}`));
|
|
65
|
+
};
|
|
66
|
+
var getFiles = async (pattern) => {
|
|
67
|
+
try {
|
|
68
|
+
const files = await (0, import_glob.glob)(pattern, { ignore: "node_modules/**" });
|
|
69
|
+
return files;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(`Error finding files: ${error}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var searchFilesForId = async (files, id, version) => {
|
|
75
|
+
const idRegex = new RegExp(`^id:\\s*['"]?${id}['"]?\\s*$`, "m");
|
|
76
|
+
const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
|
|
77
|
+
const matches = await Promise.all(
|
|
78
|
+
files.map(async (file) => {
|
|
79
|
+
const content = await import_promises.default.readFile(file, "utf-8");
|
|
80
|
+
const hasIdMatch = content.match(idRegex);
|
|
81
|
+
if (version && !content.match(versionRegex)) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
if (hasIdMatch) {
|
|
85
|
+
return file;
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
return matches.filter(Boolean).filter((file) => file !== void 0);
|
|
90
|
+
};
|
|
91
|
+
var copyDir = async (catalogDir, source, target, filter) => {
|
|
92
|
+
const tmpDirectory = (0, import_node_path.join)(catalogDir, "tmp");
|
|
93
|
+
await import_promises.default.mkdir(tmpDirectory, { recursive: true });
|
|
94
|
+
await (0, import_fs_extra.copy)(source, tmpDirectory, {
|
|
95
|
+
overwrite: true,
|
|
96
|
+
filter
|
|
97
|
+
});
|
|
98
|
+
await (0, import_fs_extra.copy)(tmpDirectory, target, {
|
|
99
|
+
overwrite: true,
|
|
100
|
+
filter
|
|
101
|
+
});
|
|
102
|
+
await import_promises.default.rm(tmpDirectory, { recursive: true });
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/internal/resources.ts
|
|
106
|
+
var import_gray_matter = __toESM(require("gray-matter"));
|
|
107
|
+
var import_promises2 = __toESM(require("fs/promises"));
|
|
108
|
+
var versionResource = async (catalogDir, id) => {
|
|
109
|
+
const files = await getFiles(`${catalogDir}/**/index.md`);
|
|
110
|
+
const matchedFiles = await searchFilesForId(files, id);
|
|
111
|
+
if (matchedFiles.length === 0) {
|
|
112
|
+
throw new Error(`No event found with id: ${id}`);
|
|
113
|
+
}
|
|
114
|
+
const file = matchedFiles[0];
|
|
115
|
+
const sourceDirectory = (0, import_path.dirname)(file);
|
|
116
|
+
const { data: { version = "0.0.1" } = {} } = import_gray_matter.default.read(file);
|
|
117
|
+
const targetDirectory = (0, import_path.join)(sourceDirectory, "versioned", version);
|
|
118
|
+
await import_promises2.default.mkdir(targetDirectory, { recursive: true });
|
|
119
|
+
await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {
|
|
120
|
+
return !src.includes("versioned");
|
|
121
|
+
});
|
|
122
|
+
await import_promises2.default.readdir(sourceDirectory).then(async (resourceFiles) => {
|
|
123
|
+
await Promise.all(
|
|
124
|
+
resourceFiles.map(async (file2) => {
|
|
125
|
+
if (file2 !== "versioned") {
|
|
126
|
+
await import_promises2.default.rm((0, import_path.join)(sourceDirectory, file2), { recursive: true });
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
var writeResource = async (catalogDir, resource, options = { path: "", type: "" }) => {
|
|
133
|
+
const path = options.path || `/${resource.id}`;
|
|
134
|
+
const exists = await versionExists(catalogDir, resource.id, resource.version);
|
|
135
|
+
if (exists) {
|
|
136
|
+
throw new Error(`Failed to write ${options.type} as the version ${resource.version} already exists`);
|
|
137
|
+
}
|
|
138
|
+
const { markdown, ...frontmatter } = resource;
|
|
139
|
+
const document = import_gray_matter.default.stringify(markdown.trim(), frontmatter);
|
|
140
|
+
await import_promises2.default.mkdir((0, import_path.join)(catalogDir, path), { recursive: true });
|
|
141
|
+
await import_promises2.default.writeFile((0, import_path.join)(catalogDir, path, "index.md"), document);
|
|
142
|
+
};
|
|
143
|
+
var getResource = async (catalogDir, id, version, options) => {
|
|
144
|
+
const file = await findFileById(catalogDir, id, version);
|
|
145
|
+
if (!file)
|
|
146
|
+
throw new Error(
|
|
147
|
+
`No ${options?.type || "resource"} found for the given id: ${id}` + (version ? ` and version ${version}` : "")
|
|
148
|
+
);
|
|
149
|
+
const { data, content } = import_gray_matter.default.read(file);
|
|
150
|
+
return {
|
|
151
|
+
...data,
|
|
152
|
+
markdown: content.trim()
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
var rmResourceById = async (catalogDir, id, version, options) => {
|
|
156
|
+
const files = await getFiles(`${catalogDir}/**/index.md`);
|
|
157
|
+
const matchedFiles = await searchFilesForId(files, id, version);
|
|
158
|
+
if (matchedFiles.length === 0) {
|
|
159
|
+
throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
|
|
160
|
+
}
|
|
161
|
+
await Promise.all(matchedFiles.map((file) => import_promises2.default.rm(file)));
|
|
162
|
+
};
|
|
163
|
+
var addFileToResource = async (catalogDir, id, file, version) => {
|
|
164
|
+
const pathToResource = await findFileById(catalogDir, id, version);
|
|
165
|
+
if (!pathToResource) throw new Error("Cannot find directory to write file to");
|
|
166
|
+
await import_promises2.default.writeFile((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName), file.content);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// src/commands.ts
|
|
170
|
+
var getCommand = (directory) => async (id, version) => getResource(directory, id, version, { type: "command" });
|
|
171
|
+
var writeCommand = (directory) => async (command, options = { path: "" }) => writeResource(directory, { ...command }, { ...options, type: "command" });
|
|
172
|
+
var rmCommand = (directory) => async (path) => {
|
|
173
|
+
await import_promises3.default.rm((0, import_node_path2.join)(directory, path), { recursive: true });
|
|
174
|
+
};
|
|
175
|
+
var rmCommandById = (directory) => async (id, version) => rmResourceById(directory, id, version, { type: "command" });
|
|
176
|
+
var versionCommand = (directory) => async (id) => versionResource(directory, id);
|
|
177
|
+
var addFileToCommand = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
178
|
+
var addSchemaToCommand = (directory) => async (id, schema, version) => {
|
|
179
|
+
await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version);
|
|
180
|
+
};
|
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
182
|
+
0 && (module.exports = {
|
|
183
|
+
addFileToCommand,
|
|
184
|
+
addSchemaToCommand,
|
|
185
|
+
getCommand,
|
|
186
|
+
rmCommand,
|
|
187
|
+
rmCommandById,
|
|
188
|
+
versionCommand,
|
|
189
|
+
writeCommand
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands.ts","../src/internal/resources.ts","../src/internal/utils.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { Command } from './types';\nimport { addFileToResource, getResource, rmResourceById, versionResource, writeResource } from './internal/resources';\n\n/**\n * Returns a command from EventCatalog.\n *\n * You can optionally specify a version to get a specific version of the command\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { getCommand } = utils('/path/to/eventcatalog');\n *\n * // Gets the latest version of the command\n * const command = await getCommand('UpdateInventory');\n *\n * // Gets a version of the command\n * const command = await getCommand('UpdateInventory', '0.0.1');\n * ```\n */\nexport const getCommand =\n (directory: string) =>\n async (id: string, version?: string): Promise<Command> =>\n getResource(directory, id, version, { type: 'command' }) as Promise<Command>;\n\n/**\n * Write a command to EventCatalog.\n *\n * You can optionally override the path of the command.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { writeCommand } = utils('/path/to/eventcatalog');\n *\n * // Write a command to the catalog\n * // Command would be written to commands/UpdateInventory\n * await writeCommand({\n * id: 'UpdateInventory',\n * name: 'Update Inventory',\n * version: '0.0.1',\n * summary: 'This is a summary',\n * markdown: '# Hello world',\n * });\n *\n * // Write a command to the catalog but override the path\n * // Command would be written to commands/Inventory/UpdateInventory\n * await writeCommand({\n * id: 'UpdateInventory',\n * name: 'Update Inventory',\n * version: '0.0.1',\n * summary: 'This is a summary',\n * markdown: '# Hello world',\n * }, { path: \"/Inventory/UpdateInventory\"});\n * ```\n */\nexport const writeCommand =\n (directory: string) =>\n async (command: Command, options: { path: string } = { path: '' }) =>\n writeResource(directory, { ...command }, { ...options, type: 'command' });\n\n/**\n * Delete a command at it's given path.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { rmCommand } = utils('/path/to/eventcatalog');\n *\n * // removes a command at the given path (commands dir is appended to the given path)\n * // Removes the command at commands/UpdateInventory\n * await rmCommand('/UpdateInventory');\n * ```\n */\nexport const rmCommand = (directory: string) => async (path: string) => {\n await fs.rm(join(directory, path), { recursive: true });\n};\n\n/**\n * Delete a command by it's id.\n *\n * Optionally specify a version to delete a specific version of the command.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { rmCommandById } = utils('/path/to/eventcatalog');\n *\n * // deletes the latest UpdateInventory command\n * await rmCommandById('UpdateInventory');\n *\n * // deletes a specific version of the UpdateInventory command\n * await rmCommandById('UpdateInventory', '0.0.1');\n * ```\n */\nexport const rmCommandById = (directory: string) => async (id: string, version?: string) =>\n rmResourceById(directory, id, version, { type: 'command' });\n\n/**\n * Version a command by it's id.\n *\n * Takes the latest command and moves it to a versioned directory.\n * All files with this command are also versioned (e.g /commands/UpdateInventory/schema.json)\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { versionCommand } = utils('/path/to/eventcatalog');\n *\n * // moves the latest UpdateInventory command to a versioned directory\n * // the version within that command is used as the version number.\n * await versionCommand('UpdateInventory');\n *\n * ```\n */\nexport const versionCommand = (directory: string) => async (id: string) => versionResource(directory, id);\n\n/**\n * Add a file to a command by it's id.\n *\n * Optionally specify a version to add a file to a specific version of the command.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { addFileToCommand } = utils('/path/to/eventcatalog');\n *\n * // adds a file to the latest UpdateInventory command\n * await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' });\n *\n * // adds a file to a specific version of the UpdateInventory command\n * await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');\n *\n * ```\n */\nexport const addFileToCommand =\n (directory: string) => async (id: string, file: { content: string; fileName: string }, version?: string) =>\n addFileToResource(directory, id, file, version);\n\n/**\n * Add a schema to a command by it's id.\n *\n * Optionally specify a version to add a schema to a specific version of the command.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { addSchemaToCommand } = utils('/path/to/eventcatalog');\n *\n * // JSON schema example\n * const schema = {\n * \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n * \"type\": \"object\",\n * \"properties\": {\n * \"name\": {\n * \"type\": \"string\"\n * },\n * \"age\": {\n * \"type\": \"number\"\n * }\n * },\n * \"required\": [\"name\", \"age\"]\n * };\n *\n * // adds a schema to the latest UpdateInventory command\n * await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' });\n *\n * // adds a file to a specific version of the UpdateInventory command\n * await addSchemaToCommand('UpdateInventory', { schema, fileName: 'schema.json' }, '0.0.1');\n *\n * ```\n */\nexport const addSchemaToCommand =\n (directory: string) => async (id: string, schema: { schema: string; fileName: string }, version?: string) => {\n await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version);\n };\n","import { dirname, join } from 'path';\nimport { copyDir, findFileById, getFiles, searchFilesForId, versionExists } from './utils';\nimport matter from 'gray-matter';\nimport fs from 'node:fs/promises';\nimport { Message, Service } from '../types';\n\ntype Resource = Service | Message;\n\nexport const versionResource = async (catalogDir: string, id: string) => {\n // Find all the events in the directory\n const files = await getFiles(`${catalogDir}/**/index.md`);\n const matchedFiles = await searchFilesForId(files, id);\n\n if (matchedFiles.length === 0) {\n throw new Error(`No event found with id: ${id}`);\n }\n\n // Event that is in the route of the project\n const file = matchedFiles[0];\n const sourceDirectory = dirname(file);\n const { data: { version = '0.0.1' } = {} } = matter.read(file);\n const targetDirectory = join(sourceDirectory, 'versioned', version);\n\n await fs.mkdir(targetDirectory, { recursive: true });\n\n // Copy the event to the versioned directory\n await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {\n return !src.includes('versioned');\n });\n\n // Remove all the files in the root of the resource as they have now been versioned\n await fs.readdir(sourceDirectory).then(async (resourceFiles) => {\n await Promise.all(\n resourceFiles.map(async (file) => {\n if (file !== 'versioned') {\n await fs.rm(join(sourceDirectory, file), { recursive: true });\n }\n })\n );\n });\n};\n\nexport const writeResource = async (\n catalogDir: string,\n resource: Resource,\n options: { path: string; type: string } = { path: '', type: '' }\n) => {\n // Get the path\n const path = options.path || `/${resource.id}`;\n const exists = await versionExists(catalogDir, resource.id, resource.version);\n\n if (exists) {\n throw new Error(`Failed to write ${options.type} as the version ${resource.version} already exists`);\n }\n\n const { markdown, ...frontmatter } = resource;\n const document = matter.stringify(markdown.trim(), frontmatter);\n await fs.mkdir(join(catalogDir, path), { recursive: true });\n await fs.writeFile(join(catalogDir, path, 'index.md'), document);\n};\n\nexport const getResource = async (\n catalogDir: string,\n id: string,\n version?: string,\n options?: { type: string }\n): Promise<Resource> => {\n const file = await findFileById(catalogDir, id, version);\n\n if (!file)\n throw new Error(\n `No ${options?.type || 'resource'} found for the given id: ${id}` + (version ? ` and version ${version}` : '')\n );\n\n const { data, content } = matter.read(file);\n\n return {\n ...data,\n markdown: content.trim(),\n } as Resource;\n};\n\nexport const rmResourceById = async (catalogDir: string, id: string, version?: string, options?: { type: string }) => {\n const files = await getFiles(`${catalogDir}/**/index.md`);\n const matchedFiles = await searchFilesForId(files, id, version);\n\n if (matchedFiles.length === 0) {\n throw new Error(`No ${options?.type || 'resource'} found with id: ${id}`);\n }\n\n await Promise.all(matchedFiles.map((file) => fs.rm(file)));\n};\n\nexport const addFileToResource = async (\n catalogDir: string,\n id: string,\n file: { content: string; fileName: string },\n version?: string\n) => {\n const pathToResource = await findFileById(catalogDir, id, version);\n\n if (!pathToResource) throw new Error('Cannot find directory to write file to');\n\n await fs.writeFile(join(dirname(pathToResource), file.fileName), file.content);\n};\n","import { glob } from 'glob';\nimport fs from 'node:fs/promises';\nimport { copy, CopyFilterAsync, CopyFilterSync } from 'fs-extra';\nimport { join } from 'node:path';\n\n/**\n * Returns true if a given version of a resource id exists in the catalog\n */\nexport const versionExists = async (catalogDir: string, id: string, version: string) => {\n const files = await getFiles(`${catalogDir}/**/index.md`);\n const matchedFiles = (await searchFilesForId(files, id, version)) || [];\n return matchedFiles.length > 0;\n};\n\nexport const findFileById = async (catalogDir: string, id: string, version?: string): Promise<string | undefined> => {\n const files = await getFiles(`${catalogDir}/**/index.md`);\n const matchedFiles = (await searchFilesForId(files, id)) || [];\n\n // Return the latest one\n if (!version) {\n return matchedFiles.find((path) => !path.includes('versioned'));\n }\n\n // Find the versioned event\n return matchedFiles.find((path) => path.includes(`versioned/${version}`));\n};\n\nexport const getFiles = async (pattern: string) => {\n try {\n const files = await glob(pattern, { ignore: 'node_modules/**' });\n return files;\n } catch (error) {\n throw new Error(`Error finding files: ${error}`);\n }\n};\n\nexport const searchFilesForId = async (files: string[], id: string, version?: string) => {\n const idRegex = new RegExp(`^id:\\\\s*['\"]?${id}['\"]?\\\\s*$`, 'm');\n const versionRegex = new RegExp(`^version:\\\\s*['\"]?${version}['\"]?\\\\s*$`, 'm');\n\n const matches = await Promise.all(\n files.map(async (file) => {\n const content = await fs.readFile(file, 'utf-8');\n const hasIdMatch = content.match(idRegex);\n\n // Check version if provided\n if (version && !content.match(versionRegex)) {\n return undefined;\n }\n\n if (hasIdMatch) {\n return file;\n }\n })\n );\n\n return matches.filter(Boolean).filter((file) => file !== undefined);\n};\n\n/**\n * Function to copy a directory from source to target, uses a tmp directory\n * @param catalogDir\n * @param source\n * @param target\n * @param filter\n */\nexport const copyDir = async (catalogDir: string, source: string, target: string, filter?: CopyFilterAsync | CopyFilterSync) => {\n const tmpDirectory = join(catalogDir, 'tmp');\n await fs.mkdir(tmpDirectory, { recursive: true });\n\n // Copy everything over\n await copy(source, tmpDirectory, {\n overwrite: true,\n filter,\n });\n\n await copy(tmpDirectory, target, {\n overwrite: true,\n filter,\n });\n\n // Remove the tmp directory\n await fs.rm(tmpDirectory, { recursive: true });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAe;AACf,IAAAC,oBAAqB;;;ACDrB,kBAA8B;;;ACA9B,kBAAqB;AACrB,sBAAe;AACf,sBAAsD;AACtD,uBAAqB;AAKd,IAAM,gBAAgB,OAAO,YAAoB,IAAY,YAAoB;AACtF,QAAM,QAAQ,MAAM,SAAS,GAAG,UAAU,cAAc;AACxD,QAAM,eAAgB,MAAM,iBAAiB,OAAO,IAAI,OAAO,KAAM,CAAC;AACtE,SAAO,a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