@intercom/cli 0.2.0 → 0.3.0

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.
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  applyJq,
4
4
  formatJson
5
- } from "./chunk-QEXGKXTU.js";
5
+ } from "./chunk-Y4JK5AHH.js";
6
6
  export {
7
7
  applyJq,
8
8
  formatJson
9
9
  };
10
- //# sourceMappingURL=json-TDEGGEUF.js.map
10
+ //# sourceMappingURL=json-MMBOB7YU.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intercom/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CLI tool for managing Intercom workspaces",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  "@napi-rs/keyring": "^1.2.0",
27
27
  "adm-zip": "^0.5.16",
28
28
  "commander": "^14.0.3",
29
+ "picocolors": "^1.1.1",
29
30
  "turndown": "^7.2.2"
30
31
  },
31
32
  "devDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts","../src/output/json.ts"],"sourcesContent":["export interface IntercomError {\n code: string;\n message: string;\n status: number;\n retry_after?: number;\n}\n\nexport class CLIError extends Error {\n constructor(\n message: string,\n public readonly exitCode: number = 1,\n public readonly error?: IntercomError,\n ) {\n super(message);\n this.name = \"CLIError\";\n }\n}\n\nexport class AuthError extends CLIError {\n constructor(message: string) {\n super(message, 2);\n }\n}\n\nexport class RateLimitError extends CLIError {\n constructor(\n message: string,\n public readonly retryAfter: number,\n ) {\n super(message, 3);\n }\n}\n\nexport class NotFoundError extends CLIError {\n constructor(message: string) {\n super(message, 4);\n }\n}\n\nexport class PermissionError extends CLIError {\n constructor(message: string) {\n super(message, 5);\n }\n}\n\nexport class TimeoutError extends CLIError {\n constructor(message: string) {\n super(message, 6);\n }\n}\n\nexport type AuthType = \"oauth\" | \"api_key\";\n\n/**\n * Detect whether a token is an OAuth token or an API key.\n * Eagle OAuth tokens are base64-encoded and decode to \"tok:...\" format.\n */\nexport function detectAuthType(token: string): AuthType {\n try {\n const decoded = Buffer.from(token, \"base64\").toString(\"utf-8\");\n if (decoded.startsWith(\"tok:\")) {\n return \"oauth\";\n }\n } catch {\n // Not valid base64 — assume API key\n }\n return \"api_key\";\n}\n\nexport interface StoredCredential {\n token: string;\n auth_type: AuthType;\n app_id: string;\n workspace_name?: string;\n expires_at?: string;\n}\n\nexport interface WorkspaceConfig {\n app_id: string;\n name: string;\n}\n\nexport interface Config {\n workspaces: Record<string, WorkspaceConfig>;\n default?: string;\n}\n\nexport interface PaginatedResponse<T> {\n type: \"list\";\n data: T[];\n pages?: {\n next?: string;\n page: number;\n per_page: number;\n total_pages: number;\n };\n}\n","import { CLIError } from \"../types.js\";\n\nexport function formatJson(data: unknown): string {\n return JSON.stringify(data, null, 2);\n}\n\nexport function applyJq(data: unknown, expr: string): unknown {\n if (expr === \".\") return data;\n\n // Must start with \".\"\n if (!expr.startsWith(\".\")) {\n throw new CLIError(\n `Unsupported jq expression: \"${expr}\". Supported: \".\", \".field\", \".field.nested\", \".field[].nested\"`,\n );\n }\n\n // Reject pipes, functions, parens, etc.\n if (/[|(){},;]/.test(expr)) {\n throw new CLIError(\n `Unsupported jq expression: \"${expr}\". Supported: \".\", \".field\", \".field.nested\", \".field[].nested\"`,\n );\n }\n\n const parts = expr.replace(/^\\.\\s*/, \"\").split(/\\./).filter(Boolean);\n\n for (const part of parts) {\n if (!/^\\w+(\\[\\])?$/.test(part)) {\n throw new CLIError(\n `Unsupported jq expression: \"${expr}\". Supported: \".\", \".field\", \".field.nested\", \".field[].nested\"`,\n );\n }\n }\n let current: unknown = data;\n\n for (const part of parts) {\n const arrayMatch = part.match(/^(\\w+)\\[\\]$/);\n if (arrayMatch) {\n const key = arrayMatch[1];\n if (current && typeof current === \"object\" && key in current) {\n const arr = (current as Record<string, unknown>)[key];\n if (!Array.isArray(arr)) return undefined;\n current = arr;\n } else {\n return undefined;\n }\n } else if (Array.isArray(current)) {\n current = current.map((item) =>\n item && typeof item === \"object\"\n ? (item as Record<string, unknown>)[part]\n : undefined,\n );\n } else if (current && typeof current === \"object\") {\n current = (current as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n\n return current;\n}\n"],"mappings":";;;AAOO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACgB,WAAmB,GACnB,OAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,SAAS;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,SAAS,CAAC;AAAA,EAClB;AACF;AAEO,IAAM,iBAAN,cAA6B,SAAS;AAAA,EAC3C,YACE,SACgB,YAChB;AACA,UAAM,SAAS,CAAC;AAFA;AAAA,EAGlB;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,SAAiB;AAC3B,UAAM,SAAS,CAAC;AAAA,EAClB;AACF;AAEO,IAAM,kBAAN,cAA8B,SAAS;AAAA,EAC5C,YAAY,SAAiB;AAC3B,UAAM,SAAS,CAAC;AAAA,EAClB;AACF;AAEO,IAAM,eAAN,cAA2B,SAAS;AAAA,EACzC,YAAY,SAAiB;AAC3B,UAAM,SAAS,CAAC;AAAA,EAClB;AACF;AAQO,SAAS,eAAe,OAAyB;AACtD,MAAI;AACF,UAAM,UAAU,OAAO,KAAK,OAAO,QAAQ,EAAE,SAAS,OAAO;AAC7D,QAAI,QAAQ,WAAW,MAAM,GAAG;AAC9B,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;;;ACjEO,SAAS,WAAW,MAAuB;AAChD,SAAO,KAAK,UAAU,MAAM,MAAM,CAAC;AACrC;AAEO,SAAS,QAAQ,MAAe,MAAuB;AAC5D,MAAI,SAAS,IAAK,QAAO;AAGzB,MAAI,CAAC,KAAK,WAAW,GAAG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