(address: string)
| 278 | * `tools.<integration>.<owner>.<connection>.aliases.deleteAlias` — the same |
| 279 | * dotted nesting the sandbox `tools` proxy produces from property access. */ |
| 280 | export const parseToolAddress = (address: string): ParsedToolAddress | null => { |
| 281 | // Walk to the 4th dot; everything past it is the tool (dots and all). |
| 282 | let cut = -1; |
| 283 | for (let i = 0; i < 4; i++) { |
| 284 | cut = address.indexOf(".", cut + 1); |
| 285 | if (cut === -1) return null; |
| 286 | } |
| 287 | const [prefix, integration, owner, connection] = address.slice(0, cut).split(".") as [ |
| 288 | string, |
| 289 | string, |
| 290 | string, |
| 291 | string, |
| 292 | ]; |
| 293 | const tool = address.slice(cut + 1); |
| 294 | if (prefix !== ADDRESS_PREFIX) return null; |
| 295 | if (!isOwner(owner)) return null; |
| 296 | if (integration.length === 0 || connection.length === 0 || tool.length === 0) { |
| 297 | return null; |
| 298 | } |
| 299 | return { |
| 300 | integration: IntegrationSlug.make(integration), |
| 301 | owner, |
| 302 | connection: ConnectionName.make(connection), |
| 303 | tool: ToolName.make(tool), |
| 304 | }; |
| 305 | }; |
| 306 | |
| 307 | export const connectionAddress = ( |
| 308 | owner: Owner, |
no test coverage detected