@eventcatalog/sdk 2.3.6 → 2.4.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/channels.js +30 -4
- package/dist/channels.js.map +1 -1
- package/dist/channels.mjs +44 -12
- package/dist/channels.mjs.map +1 -1
- package/dist/commands.d.mts +10 -1
- package/dist/commands.d.ts +10 -1
- package/dist/commands.js +28 -2
- package/dist/commands.js.map +1 -1
- package/dist/commands.mjs +34 -8
- package/dist/commands.mjs.map +1 -1
- package/dist/custom-docs.js +15 -1
- package/dist/custom-docs.js.map +1 -1
- package/dist/custom-docs.mjs +26 -9
- package/dist/custom-docs.mjs.map +1 -1
- package/dist/domains.js +27 -1
- package/dist/domains.js.map +1 -1
- package/dist/domains.mjs +34 -8
- package/dist/domains.mjs.map +1 -1
- package/dist/eventcatalog.js +40 -5
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +67 -32
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/events.d.mts +10 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.js +28 -2
- package/dist/events.js.map +1 -1
- package/dist/events.mjs +34 -8
- package/dist/events.mjs.map +1 -1
- package/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -32
- package/dist/index.mjs.map +1 -1
- package/dist/queries.d.mts +10 -1
- package/dist/queries.d.ts +10 -1
- package/dist/queries.js +28 -2
- package/dist/queries.js.map +1 -1
- package/dist/queries.mjs +34 -8
- package/dist/queries.mjs.map +1 -1
- package/dist/services.js +27 -1
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +33 -7
- package/dist/services.mjs.map +1 -1
- package/dist/teams.mjs +7 -6
- package/dist/teams.mjs.map +1 -1
- package/dist/types.d.d.mts +3 -0
- package/dist/types.d.d.ts +3 -0
- package/dist/types.d.js.map +1 -1
- package/dist/users.mjs +7 -6
- package/dist/users.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ declare const _default: (path: string) => {
|
|
|
14
14
|
* @param version - Optional id of the version to get (supports semver)
|
|
15
15
|
* @returns Event|Undefined
|
|
16
16
|
*/
|
|
17
|
-
getEvent: (id: string, version?: string
|
|
17
|
+
getEvent: (id: string, version?: string, options?: {
|
|
18
|
+
attachSchema?: boolean;
|
|
19
|
+
}) => Promise<Event>;
|
|
18
20
|
/**
|
|
19
21
|
* Returns all events from EventCatalog
|
|
20
22
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
@@ -22,6 +24,7 @@ declare const _default: (path: string) => {
|
|
|
22
24
|
*/
|
|
23
25
|
getEvents: (options?: {
|
|
24
26
|
latestOnly?: boolean;
|
|
27
|
+
attachSchema?: boolean;
|
|
25
28
|
}) => Promise<Event[]>;
|
|
26
29
|
/**
|
|
27
30
|
* Adds an event to EventCatalog
|
|
@@ -111,7 +114,9 @@ declare const _default: (path: string) => {
|
|
|
111
114
|
* @param version - Optional id of the version to get (supports semver)
|
|
112
115
|
* @returns Command|Undefined
|
|
113
116
|
*/
|
|
114
|
-
getCommand: (id: string, version?: string
|
|
117
|
+
getCommand: (id: string, version?: string, options?: {
|
|
118
|
+
attachSchema?: boolean;
|
|
119
|
+
}) => Promise<Command>;
|
|
115
120
|
/**
|
|
116
121
|
* Returns all commands from EventCatalog
|
|
117
122
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
@@ -119,6 +124,7 @@ declare const _default: (path: string) => {
|
|
|
119
124
|
*/
|
|
120
125
|
getCommands: (options?: {
|
|
121
126
|
latestOnly?: boolean;
|
|
127
|
+
attachSchema?: boolean;
|
|
122
128
|
}) => Promise<Command[]>;
|
|
123
129
|
/**
|
|
124
130
|
* Adds an command to EventCatalog
|
|
@@ -208,7 +214,9 @@ declare const _default: (path: string) => {
|
|
|
208
214
|
* @param version - Optional id of the version to get (supports semver)
|
|
209
215
|
* @returns Query|Undefined
|
|
210
216
|
*/
|
|
211
|
-
getQuery: (id: string, version?: string
|
|
217
|
+
getQuery: (id: string, version?: string, options?: {
|
|
218
|
+
attachSchema?: boolean;
|
|
219
|
+
}) => Promise<Query>;
|
|
212
220
|
/**
|
|
213
221
|
* Returns all queries from EventCatalog
|
|
214
222
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
@@ -216,6 +224,7 @@ declare const _default: (path: string) => {
|
|
|
216
224
|
*/
|
|
217
225
|
getQueries: (options?: {
|
|
218
226
|
latestOnly?: boolean;
|
|
227
|
+
attachSchema?: boolean;
|
|
219
228
|
}) => Promise<Query[]>;
|
|
220
229
|
/**
|
|
221
230
|
* Adds a query to EventCatalog
|
|
@@ -462,12 +471,7 @@ declare const _default: (path: string) => {
|
|
|
462
471
|
}, options?: {
|
|
463
472
|
path?: string;
|
|
464
473
|
format?: "md" | "mdx";
|
|
465
|
-
override
|
|
466
|
-
* Remove an command by an Event id
|
|
467
|
-
*
|
|
468
|
-
* @param id - The id of the command you want to remove
|
|
469
|
-
*
|
|
470
|
-
*/: boolean;
|
|
474
|
+
override?: boolean;
|
|
471
475
|
}) => Promise<void>;
|
|
472
476
|
/**
|
|
473
477
|
* Returns a service from EventCatalog
|
|
@@ -813,6 +817,19 @@ declare const _default: (path: string) => {
|
|
|
813
817
|
dumpCatalog: (options?: {
|
|
814
818
|
includeMarkdown?: boolean;
|
|
815
819
|
}) => Promise<EventCatalogObject>;
|
|
820
|
+
/**
|
|
821
|
+
* ================================
|
|
822
|
+
* Resources Utils
|
|
823
|
+
* ================================
|
|
824
|
+
*/
|
|
825
|
+
/**
|
|
826
|
+
* Returns the path to a given resource by id and version
|
|
827
|
+
*/
|
|
828
|
+
getResourcePath: (catalogDir: string, id: string, version?: string) => Promise<{
|
|
829
|
+
fullPath: string;
|
|
830
|
+
relativePath: string;
|
|
831
|
+
directory: string;
|
|
832
|
+
} | undefined>;
|
|
816
833
|
};
|
|
817
834
|
|
|
818
835
|
export { _default as default };
|
package/dist/index.js
CHANGED
|
@@ -221,9 +221,22 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
var getResource = async (catalogDir, id, version, options) => {
|
|
224
|
+
const attachSchema = options?.attachSchema || false;
|
|
224
225
|
const file = await findFileById(catalogDir, id, version);
|
|
225
226
|
if (!file) return;
|
|
226
227
|
const { data, content } = import_gray_matter2.default.read(file);
|
|
228
|
+
if (attachSchema && data?.schemaPath) {
|
|
229
|
+
const resourceDirectory = (0, import_path.dirname)(file);
|
|
230
|
+
const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
|
|
231
|
+
if (import_node_fs2.default.existsSync(pathToSchema)) {
|
|
232
|
+
const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
|
|
233
|
+
try {
|
|
234
|
+
data.schema = JSON.parse(schema);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
data.schema = schema;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
227
240
|
return {
|
|
228
241
|
...data,
|
|
229
242
|
markdown: content.trim()
|
|
@@ -242,7 +255,8 @@ var getResources = async (catalogDir, {
|
|
|
242
255
|
type,
|
|
243
256
|
latestOnly = false,
|
|
244
257
|
ignore = [],
|
|
245
|
-
pattern = ""
|
|
258
|
+
pattern = "",
|
|
259
|
+
attachSchema = false
|
|
246
260
|
}) => {
|
|
247
261
|
const ignoreList = latestOnly ? `**/versioned/**` : "";
|
|
248
262
|
const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
|
|
@@ -250,6 +264,18 @@ var getResources = async (catalogDir, {
|
|
|
250
264
|
if (files.length === 0) return;
|
|
251
265
|
return files.map((file) => {
|
|
252
266
|
const { data, content } = import_gray_matter2.default.read(file);
|
|
267
|
+
if (attachSchema && data?.schemaPath) {
|
|
268
|
+
const resourceDirectory = (0, import_path.dirname)(file);
|
|
269
|
+
const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
|
|
270
|
+
if (import_node_fs2.default.existsSync(pathToSchema)) {
|
|
271
|
+
const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
|
|
272
|
+
try {
|
|
273
|
+
data.schema = JSON.parse(schema);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
data.schema = schema;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
253
279
|
return {
|
|
254
280
|
...data,
|
|
255
281
|
markdown: content.trim()
|
|
@@ -300,7 +326,7 @@ var getVersionedDirectory = (sourceDirectory, version) => {
|
|
|
300
326
|
};
|
|
301
327
|
|
|
302
328
|
// src/events.ts
|
|
303
|
-
var getEvent = (directory) => async (id, version) => getResource(directory, id, version, { type: "event" });
|
|
329
|
+
var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
|
|
304
330
|
var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
|
|
305
331
|
var writeEvent = (directory) => async (event, options = {
|
|
306
332
|
path: "",
|
|
@@ -335,7 +361,7 @@ var eventHasVersion = (directory) => async (id, version) => {
|
|
|
335
361
|
// src/commands.ts
|
|
336
362
|
var import_promises3 = __toESM(require("fs/promises"));
|
|
337
363
|
var import_node_path3 = require("path");
|
|
338
|
-
var getCommand = (directory) => async (id, version) => getResource(directory, id, version, { type: "command" });
|
|
364
|
+
var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
|
|
339
365
|
var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
|
|
340
366
|
var writeCommand = (directory) => async (command, options = {
|
|
341
367
|
path: "",
|
|
@@ -369,7 +395,7 @@ var commandHasVersion = (directory) => async (id, version) => {
|
|
|
369
395
|
// src/queries.ts
|
|
370
396
|
var import_promises4 = __toESM(require("fs/promises"));
|
|
371
397
|
var import_node_path4 = require("path");
|
|
372
|
-
var getQuery = (directory) => async (id, version) => getResource(directory, id, version, { type: "query" });
|
|
398
|
+
var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
|
|
373
399
|
var writeQuery = (directory) => async (query, options = {
|
|
374
400
|
path: "",
|
|
375
401
|
override: false,
|
|
@@ -1517,7 +1543,16 @@ var index_default = (path4) => {
|
|
|
1517
1543
|
* @param directory - The directory to dump the catalog to
|
|
1518
1544
|
* @returns A JSON file with the catalog
|
|
1519
1545
|
*/
|
|
1520
|
-
dumpCatalog: dumpCatalog((0, import_node_path12.join)(path4))
|
|
1546
|
+
dumpCatalog: dumpCatalog((0, import_node_path12.join)(path4)),
|
|
1547
|
+
/**
|
|
1548
|
+
* ================================
|
|
1549
|
+
* Resources Utils
|
|
1550
|
+
* ================================
|
|
1551
|
+
*/
|
|
1552
|
+
/**
|
|
1553
|
+
* Returns the path to a given resource by id and version
|
|
1554
|
+
*/
|
|
1555
|
+
getResourcePath
|
|
1521
1556
|
};
|
|
1522
1557
|
};
|
|
1523
1558
|
//# sourceMappingURL=index.js.map
|