@odla-ai/crm 0.11.0 → 0.11.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/dist/index.cjs CHANGED
@@ -2145,6 +2145,13 @@ function unsubscribePage(token, done) {
2145
2145
  }
2146
2146
 
2147
2147
  // src/routes/params.ts
2148
+ function pathId(segment) {
2149
+ try {
2150
+ return decodeURIComponent(segment);
2151
+ } catch {
2152
+ throw new CrmInputError("malformed percent-encoding in the path");
2153
+ }
2154
+ }
2148
2155
  function str(body, key) {
2149
2156
  const value = body[key];
2150
2157
  if (typeof value !== "string" || value === "")
@@ -2306,7 +2313,7 @@ async function handleTags(ctx, req, id, rest) {
2306
2313
  return json(result, 201);
2307
2314
  }
2308
2315
  if (req.method === "DELETE" && rest.length === 1) {
2309
- const result = await removeTag(ctx.deps, { recordId: id, tag: decodeURIComponent(rest[0]) });
2316
+ const result = await removeTag(ctx.deps, { recordId: id, tag: rest[0] });
2310
2317
  return json(result);
2311
2318
  }
2312
2319
  return json({ error: "method not allowed" }, 405);
@@ -2654,30 +2661,31 @@ async function handleCrmDiscussionReferences(ctx, req, url) {
2654
2661
 
2655
2662
  // src/routes/index.ts
2656
2663
  async function route(ctx, req, url, seg) {
2657
- const [head, id, action, ...rest] = seg;
2658
- if (head === "discussion-references" && id === void 0)
2664
+ const [head, second, action, ...rest] = seg;
2665
+ if (head === "discussion-references" && second === void 0)
2659
2666
  return handleCrmDiscussionReferences(ctx, req, url);
2660
2667
  if (head === "records") {
2661
- if (id === void 0) return handleRecordsRoot(ctx, req, url);
2668
+ if (second === void 0) return handleRecordsRoot(ctx, req, url);
2669
+ const id = pathId(second);
2662
2670
  if (action === void 0) return handleRecordItem(ctx, req, id);
2663
2671
  if (action === "archive") return handleArchive(ctx, req, id);
2664
2672
  if (action === "stage") return handleStage(ctx, req, id);
2665
2673
  if (action === "rank") return handleRank(ctx, req, id);
2666
- if (action === "tags") return handleTags(ctx, req, id, rest);
2674
+ if (action === "tags") return handleTags(ctx, req, id, rest.map(pathId));
2667
2675
  if (action === "links") return handleLinks(ctx, req, id);
2668
2676
  if (action === "link-identity") return handleLinkIdentity(ctx, req, id);
2669
2677
  if (action === "email") return handleSendEmail(ctx, req, id);
2670
2678
  if (action === "activities") return handleRecordActivities(ctx, req, url, id);
2671
2679
  return null;
2672
2680
  }
2673
- if (head === "activities" && id !== void 0 && action === void 0)
2674
- return handleActivityItem(ctx, req, id);
2675
- if (head === "tasks" && id === void 0) return handleTasks(ctx, req, url);
2676
- if (head === "views") return handleViews(ctx, req, url, seg.slice(1));
2677
- if (head === "summary" && id === void 0) return handleSummary(ctx, req, url);
2678
- if (head === "config" && id === void 0) return handleConfig(ctx, req);
2679
- if (head === "email-log" && id === void 0) return handleEmailLog(ctx, req, url);
2680
- if (head === "rank" && id === "rebalance" && action === void 0)
2681
+ if (head === "activities" && second !== void 0 && action === void 0)
2682
+ return handleActivityItem(ctx, req, pathId(second));
2683
+ if (head === "tasks" && second === void 0) return handleTasks(ctx, req, url);
2684
+ if (head === "views") return handleViews(ctx, req, url, seg.slice(1).map(pathId));
2685
+ if (head === "summary" && second === void 0) return handleSummary(ctx, req, url);
2686
+ if (head === "config" && second === void 0) return handleConfig(ctx, req);
2687
+ if (head === "email-log" && second === void 0) return handleEmailLog(ctx, req, url);
2688
+ if (head === "rank" && second === "rebalance" && action === void 0)
2681
2689
  return handleRebalance(ctx, req);
2682
2690
  return null;
2683
2691
  }