@requesto/cli 1.10.0 → 1.10.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
@@ -76651,6 +76651,17 @@ var require_collection_service = __commonJS({
76651
76651
  constructor(repo) {
76652
76652
  this.repo = repo;
76653
76653
  }
76654
+ isEmpty(collection) {
76655
+ return collection.requests.length === 0 && (collection.folders ?? []).length === 0;
76656
+ }
76657
+ async pruneUncategorizedIfEmpty(collectionId) {
76658
+ if (collectionId !== collection_1.UNCATEGORIZED_COLLECTION_ID)
76659
+ return;
76660
+ const collection = await this.repo.getById(collection_1.UNCATEGORIZED_COLLECTION_ID);
76661
+ if (collection && this.isEmpty(collection)) {
76662
+ await this.repo.delete(collection_1.UNCATEGORIZED_COLLECTION_ID);
76663
+ }
76664
+ }
76654
76665
  /**
76655
76666
  * Idempotently ensure the system-managed "Uncategorized" collection exists.
76656
76667
  * Used as a catch-all when users save a request without picking a collection.
@@ -76670,7 +76681,13 @@ var require_collection_service = __commonJS({
76670
76681
  return this.repo.create(collection);
76671
76682
  }
76672
76683
  async getAll() {
76673
- return this.repo.getAll();
76684
+ const all2 = await this.repo.getAll();
76685
+ const uncategorized = all2.find((c) => c.id === collection_1.UNCATEGORIZED_COLLECTION_ID);
76686
+ if (uncategorized && this.isEmpty(uncategorized)) {
76687
+ await this.repo.delete(collection_1.UNCATEGORIZED_COLLECTION_ID);
76688
+ return all2.filter((c) => c.id !== collection_1.UNCATEGORIZED_COLLECTION_ID);
76689
+ }
76690
+ return all2;
76674
76691
  }
76675
76692
  async getById(id) {
76676
76693
  const collection = await this.repo.getById(id);
@@ -76747,6 +76764,7 @@ var require_collection_service = __commonJS({
76747
76764
  if (!deleted) {
76748
76765
  throw app_error_1.AppError.notFound("Collection or request not found");
76749
76766
  }
76767
+ await this.pruneUncategorizedIfEmpty(collectionId);
76750
76768
  }
76751
76769
  async duplicateRequest(collectionId, requestId) {
76752
76770
  const collection = await this.repo.getById(collectionId);
@@ -76828,6 +76846,7 @@ var require_collection_service = __commonJS({
76828
76846
  ...slotRequests
76829
76847
  ];
76830
76848
  await this.repo.saveAll(allCollections);
76849
+ await this.pruneUncategorizedIfEmpty(sourceCollectionId);
76831
76850
  return movedRequest;
76832
76851
  }
76833
76852
  async moveFolder(params) {
@@ -131429,7 +131448,13 @@ async function runCollections(opts) {
131429
131448
  headers: response.headers,
131430
131449
  body: response.body,
131431
131450
  duration: response.duration
131432
- }, { method: proxyReq.method, url: proxyReq.url, headers: proxyReq.headers, body: proxyReq.body }, envRecord(liveEnv));
131451
+ }, {
131452
+ method: proxyReq.method,
131453
+ url: proxyReq.url,
131454
+ headers: proxyReq.headers,
131455
+ body: proxyReq.body,
131456
+ formDataEntries: proxyReq.formDataEntries?.map(({ key, value, type: type2, fileName }) => ({ key, value, type: type2, fileName }))
131457
+ }, envRecord(liveEnv));
131433
131458
  testResults = outcome.testResults;
131434
131459
  liveEnv = applyEnvOverrides(liveEnv, outcome);
131435
131460
  }
@@ -267,7 +267,7 @@ ${script}`);
267
267
  }
268
268
  function executeTestScript(script, context) {
269
269
  const results = [];
270
- const { response: responseCtx, request } = context;
270
+ const { response: responseCtx, request: requestCtx } = context;
271
271
  const { store, types, api } = createEnvironment(context.env);
272
272
  const response = {
273
273
  status: responseCtx.status,
@@ -277,6 +277,23 @@ function executeTestScript(script, context) {
277
277
  duration: responseCtx.duration,
278
278
  json: () => JSON.parse(responseCtx.body)
279
279
  };
280
+ let params = {};
281
+ try {
282
+ params = Object.fromEntries(new URL(requestCtx.url).searchParams);
283
+ } catch {
284
+ }
285
+ const form = {};
286
+ for (const entry of requestCtx.formDataEntries ?? []) {
287
+ form[entry.key] = entry.type === "file" ? entry.fileName ?? "" : entry.value;
288
+ }
289
+ const request = {
290
+ method: requestCtx.method,
291
+ url: requestCtx.url,
292
+ headers: requestCtx.headers ? { ...requestCtx.headers } : void 0,
293
+ body: requestCtx.body,
294
+ params,
295
+ form
296
+ };
280
297
  const test = (name, fn2) => {
281
298
  try {
282
299
  fn2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requesto/cli",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Run your Requesto collections from the terminal and CI pipelines",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -26,8 +26,8 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^26.4.1",
28
28
  "esbuild": "^0.28.2",
29
- "requesto-backend": "1.10.0",
30
- "requesto-engine": "1.10.0",
29
+ "requesto-backend": "1.10.2",
30
+ "requesto-engine": "1.10.2",
31
31
  "tsx": "^4.23.13",
32
32
  "typescript": "^7.0.2",
33
33
  "vitest": "^5.0.0"