SMOODEV-2644: th api crm assoc — CRM entity associations from the CLI#218
Merged
Conversation
Adds `th api crm assoc link/unlink/list/set-type/set-label`, taking entities as TYPE:REF operands (contact:jane@x.com, company:Acme, deal:"Big Deal", task:<uuid>). contact/company/deal refs resolve by name/email/title via the existing resolvers; other types accept a uuid. Also adds thin sugar over the legacy FKs: contacts set-company, deals set-contact, deals set-company, companies set-parent (each takes none/- to clear). Backed by the native api-prime associations endpoints from SmooAI/smooai#3068 — the commands 404 against prod until that deploys. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnpE2VsHBgEq5XNQuXNLse
🦋 Changeset detectedLatest commit: 7cb6f46 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ulary The associations API returns direction as "source"/"target" (not "outgoing"/"incoming"). Parent links are stored child—parent→parent, so querying the child returns its parent row with direction=="source". Extract the predicate to a pure, unit-tested `parent_row_points_up` and match on "source". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnpE2VsHBgEq5XNQuXNLse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CRM now models entity-to-entity associations (contacts ↔ companies ↔ deals ↔ tasks/proposals/funnels/custom objects) beyond the legacy single FKs, but
thhad no way to create, inspect, or remove them. SMOODEV-2644.Solution
Adds a
th api crm assoccommand group (aliases:associations,association,links) plus thin sugar wrappers over the legacy FKs — all incrates/smooth-cli/src/smooai/crm.rs, matching the file's existing clap-derive + org-resolution +UserClient+ output-helper style.assocsubcommands — entities areTYPE:REFoperands (contact:jane@x.com,company:Acme,deal:"Big Deal", ortask:<uuid>):link <FROM> <TO> [--as <type>] [--label <text>]— resolve both refs, POST the associationunlink <FROM> <TO> [--as <type>]— GET the matching row(s), DELETE; errors listing the types when several link the pair and--asis absentlist <ENTITY> [--type <otherType>] [--as <assocType>] [--json]— readable table (type, label, other entity + sublabel, id)set-type <ASSOCIATION_ID> <type>/set-label <ASSOCIATION_ID> <text>— PATCH by idcontact/company/dealrefs resolve by name/email/title via the existingresolve_*_idhelpers (uuid passthrough);task/proposal/funnel/custom_objectaccept a uuid only (clear error otherwise, since no resolver exists yet).Sugar wrappers (reuse the simpler legacy PATCH/association endpoints; each takes
none/-to clear):contacts set-company <CONTACT> <COMPANY|none>— PATCHcompanyIddeals set-contact <DEAL> <CONTACT|none>/deals set-company <DEAL> <COMPANY|none>— PATCHcontactId/companyIdcompanies set-parent <COMPANY> <PARENT|none>— POST aparentassociation (clearing = find + DELETE the parent row)Verification
cargo test -p smooai-smooth-cli— 19 passing, including 5 new unit tests for the pureTYPE:REFparser / type normalization / clear-token sentinelscargo fmt -- --checkclean;cargo clippyintroduces no new denied lints (pedantic/nursery stay advisory per the repo's CI policy)th api crm assoc --helpand each sugar subcommand's--helpparse and render as expected@smooai/smoothminor changeset🤖 Generated with Claude Code