@eventcatalog/sdk 1.4.1 → 1.4.2

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.mjs CHANGED
@@ -174,7 +174,20 @@ var rmResourceById = async (catalogDir, id, version, options) => {
174
174
  if (matchedFiles.length === 0) {
175
175
  throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
176
176
  }
177
- await Promise.all(matchedFiles.map((file) => fs2.rm(file)));
177
+ if (options?.persistFiles) {
178
+ await Promise.all(
179
+ matchedFiles.map(async (file) => {
180
+ await fs2.rm(file, { recursive: true });
181
+ })
182
+ );
183
+ } else {
184
+ await Promise.all(
185
+ matchedFiles.map(async (file) => {
186
+ const directory = dirname(file);
187
+ await fs2.rm(directory, { recursive: true, force: true });
188
+ })
189
+ );
190
+ }
178
191
  };
179
192
  var addFileToResource = async (catalogDir, id, file, version) => {
180
193
  const pathToResource = await findFileById(catalogDir, id, version);
@@ -204,8 +217,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
204
217
  var rmEvent = (directory) => async (path) => {
205
218
  await fs3.rm(join3(directory, path), { recursive: true });
206
219
  };
207
- var rmEventById = (directory) => async (id, version) => {
208
- await rmResourceById(directory, id, version, { type: "event" });
220
+ var rmEventById = (directory) => async (id, version, persistFiles) => {
221
+ await rmResourceById(directory, id, version, { type: "event", persistFiles });
209
222
  };
210
223
  var versionEvent = (directory) => async (id) => versionResource(directory, id);
211
224
  var addFileToEvent = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -231,7 +244,7 @@ var writeCommandToService = (directory) => async (command, service, options = {
231
244
  var rmCommand = (directory) => async (path) => {
232
245
  await fs4.rm(join4(directory, path), { recursive: true });
233
246
  };
234
- var rmCommandById = (directory) => async (id, version) => rmResourceById(directory, id, version, { type: "command" });
247
+ var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
235
248
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
236
249
  var addFileToCommand = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
237
250
  var addSchemaToCommand = (directory) => async (id, schema, version) => {
@@ -256,8 +269,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
256
269
  var rmQuery = (directory) => async (path) => {
257
270
  await fs5.rm(join5(directory, path), { recursive: true });
258
271
  };
259
- var rmQueryById = (directory) => async (id, version) => {
260
- await rmResourceById(directory, id, version, { type: "query" });
272
+ var rmQueryById = (directory) => async (id, version, persistFiles) => {
273
+ await rmResourceById(directory, id, version, { type: "query", persistFiles });
261
274
  };
262
275
  var versionQuery = (directory) => async (id) => versionResource(directory, id);
263
276
  var addFileToQuery = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -451,7 +464,7 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
451
464
  }
452
465
  const path = existingResource.split(`/${collection}`)[0];
453
466
  const pathToResource = join8(path, collection);
454
- await rmMessageById(directory)(_message.id, _message.version);
467
+ await rmMessageById(directory)(_message.id, _message.version, true);
455
468
  await writeMessage(pathToResource)(message);
456
469
  };
457
470