@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.d.cts CHANGED
@@ -1336,6 +1336,11 @@ interface CrmRouteOpts {
1336
1336
  * admin actor (401 otherwise) EXCEPT the public unsubscribe pair, where the
1337
1337
  * per-channel token is the credential. Domain errors map to 400/404 JSON;
1338
1338
  * anything unexpected is a 500 without internals.
1339
+ *
1340
+ * An id in the path (a record, activity or view id, or a tag) is
1341
+ * percent-decoded once, so the id `CrmClient` encodes is the id looked up;
1342
+ * malformed encoding there is a 400. Build paths by hand the same way:
1343
+ * `encodeURIComponent(id)`.
1339
1344
  */
1340
1345
  declare function createCrmRoutes(options: CrmRouteOpts): (req: Request) => Promise<Response | null>;
1341
1346
 
package/dist/index.d.ts CHANGED
@@ -1336,6 +1336,11 @@ interface CrmRouteOpts {
1336
1336
  * admin actor (401 otherwise) EXCEPT the public unsubscribe pair, where the
1337
1337
  * per-channel token is the credential. Domain errors map to 400/404 JSON;
1338
1338
  * anything unexpected is a 500 without internals.
1339
+ *
1340
+ * An id in the path (a record, activity or view id, or a tag) is
1341
+ * percent-decoded once, so the id `CrmClient` encodes is the id looked up;
1342
+ * malformed encoding there is a 400. Build paths by hand the same way:
1343
+ * `encodeURIComponent(id)`.
1339
1344
  */
1340
1345
  declare function createCrmRoutes(options: CrmRouteOpts): (req: Request) => Promise<Response | null>;
1341
1346
 
package/dist/index.js CHANGED
@@ -2019,6 +2019,13 @@ function unsubscribePage(token, done) {
2019
2019
  }
2020
2020
 
2021
2021
  // src/routes/params.ts
2022
+ function pathId(segment) {
2023
+ try {
2024
+ return decodeURIComponent(segment);
2025
+ } catch {
2026
+ throw new CrmInputError("malformed percent-encoding in the path");
2027
+ }
2028
+ }
2022
2029
  function str(body, key) {
2023
2030
  const value = body[key];
2024
2031
  if (typeof value !== "string" || value === "")
@@ -2180,7 +2187,7 @@ async function handleTags(ctx, req, id, rest) {
2180
2187
  return json(result, 201);
2181
2188
  }
2182
2189
  if (req.method === "DELETE" && rest.length === 1) {
2183
- const result = await removeTag(ctx.deps, { recordId: id, tag: decodeURIComponent(rest[0]) });
2190
+ const result = await removeTag(ctx.deps, { recordId: id, tag: rest[0] });
2184
2191
  return json(result);
2185
2192
  }
2186
2193
  return json({ error: "method not allowed" }, 405);
@@ -2528,30 +2535,31 @@ async function handleCrmDiscussionReferences(ctx, req, url) {
2528
2535
 
2529
2536
  // src/routes/index.ts
2530
2537
  async function route(ctx, req, url, seg) {
2531
- const [head, id, action, ...rest] = seg;
2532
- if (head === "discussion-references" && id === void 0)
2538
+ const [head, second, action, ...rest] = seg;
2539
+ if (head === "discussion-references" && second === void 0)
2533
2540
  return handleCrmDiscussionReferences(ctx, req, url);
2534
2541
  if (head === "records") {
2535
- if (id === void 0) return handleRecordsRoot(ctx, req, url);
2542
+ if (second === void 0) return handleRecordsRoot(ctx, req, url);
2543
+ const id = pathId(second);
2536
2544
  if (action === void 0) return handleRecordItem(ctx, req, id);
2537
2545
  if (action === "archive") return handleArchive(ctx, req, id);
2538
2546
  if (action === "stage") return handleStage(ctx, req, id);
2539
2547
  if (action === "rank") return handleRank(ctx, req, id);
2540
- if (action === "tags") return handleTags(ctx, req, id, rest);
2548
+ if (action === "tags") return handleTags(ctx, req, id, rest.map(pathId));
2541
2549
  if (action === "links") return handleLinks(ctx, req, id);
2542
2550
  if (action === "link-identity") return handleLinkIdentity(ctx, req, id);
2543
2551
  if (action === "email") return handleSendEmail(ctx, req, id);
2544
2552
  if (action === "activities") return handleRecordActivities(ctx, req, url, id);
2545
2553
  return null;
2546
2554
  }
2547
- if (head === "activities" && id !== void 0 && action === void 0)
2548
- return handleActivityItem(ctx, req, id);
2549
- if (head === "tasks" && id === void 0) return handleTasks(ctx, req, url);
2550
- if (head === "views") return handleViews(ctx, req, url, seg.slice(1));
2551
- if (head === "summary" && id === void 0) return handleSummary(ctx, req, url);
2552
- if (head === "config" && id === void 0) return handleConfig(ctx, req);
2553
- if (head === "email-log" && id === void 0) return handleEmailLog(ctx, req, url);
2554
- if (head === "rank" && id === "rebalance" && action === void 0)
2555
+ if (head === "activities" && second !== void 0 && action === void 0)
2556
+ return handleActivityItem(ctx, req, pathId(second));
2557
+ if (head === "tasks" && second === void 0) return handleTasks(ctx, req, url);
2558
+ if (head === "views") return handleViews(ctx, req, url, seg.slice(1).map(pathId));
2559
+ if (head === "summary" && second === void 0) return handleSummary(ctx, req, url);
2560
+ if (head === "config" && second === void 0) return handleConfig(ctx, req);
2561
+ if (head === "email-log" && second === void 0) return handleEmailLog(ctx, req, url);
2562
+ if (head === "rank" && second === "rebalance" && action === void 0)
2555
2563
  return handleRebalance(ctx, req);
2556
2564
  return null;
2557
2565
  }