{"_id":"@anhdn-mkt/mkt-business-meta","_rev":"5-68d713a747f0b579fc0c80edb0bf44e9","name":"@anhdn-mkt/mkt-business-meta","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@anhdn-mkt/mkt-business-meta","version":"0.1.0","keywords":["marketing","platform","business","meta"],"author":{"name":"Marketing Platform"},"license":"MIT","_id":"@anhdn-mkt/mkt-business-meta@0.1.0","maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"dist":{"shasum":"df01ababc518b3e7b6b6465fa7433f9502c3d6a6","tarball":"https://registry.npmjs.org/@anhdn-mkt/mkt-business-meta/-/mkt-business-meta-0.1.0.tgz","fileCount":4,"integrity":"sha512-PlLwuejaHq0FJSqNwJI2X9WmFs+3Sm//X/VTKK+sQpSwQsjdL4M0QXRG9H4K487AuOLkPfd+zZylwjM7eIFoSw==","signatures":[{"sig":"MEYCIQCOLdaAt704t0nFRn744H1EDlJ1aVmETBJVOUod9oGjgwIhAJTE4ZvTRn+LCwEePE/xjUDXZRtYaslOf8qbJcGto65J","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":929830},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"index.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"b9be5fd4b1cebfa04f8203f22f04adea019d0bc7","private":false,"scripts":{"dev":"bun --watch src/index.ts","lint":"eslint .","test":"bun test","build":"bun build src/index.ts --outdir dist --target bun","clear":"npm run typecheck && npm run lint:fix && npm run format","format":"prettier --write 'src/**/*.{ts,tsx}'","lint:fix":"eslint . --fix","typecheck":"tsc --noEmit","format:check":"prettier --check 'src/**/*.{ts,tsx}'"},"_npmUser":{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"},"_npmVersion":"10.8.2","description":"Business meta data for the marketing platform","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pino":"^10.3.1","axios":"^1.16.0","otplib":"^13.4.0","pino-pretty":"^13.1.3","class-validator":"^0.15.1","reflect-metadata":"^0.2.2","class-transformer":"^0.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jiti":"^2.7.0","eslint":"^10.3.0","prettier":"^3.8.3","bun-types":"^1.3.14","@eslint/js":"^10.0.1","@types/bun":"latest","typescript-eslint":"^8.59.3"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mkt-business-meta_0.1.0_1778749571075_0.49185239118963087","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@anhdn-mkt/mkt-business-meta","version":"0.1.1","keywords":["marketing","platform","business","meta"],"author":{"name":"Marketing Platform"},"license":"MIT","_id":"@anhdn-mkt/mkt-business-meta@0.1.1","maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"dist":{"shasum":"32f000e4a10522faa0f783363f336c86c7eacf6d","tarball":"https://registry.npmjs.org/@anhdn-mkt/mkt-business-meta/-/mkt-business-meta-0.1.1.tgz","fileCount":5,"integrity":"sha512-QO9kAbnR54TVzbWj17vGcYMcYC58T7SadXzzBYDGBzPnkyXCUZdFNxQnNSgOkmUhPKMhvFCumkcNBv0F2ISwbQ==","signatures":[{"sig":"MEUCIQCSoSQFaqTdnQXEm6u0kJL4tuJmk2eprJcPoEk1oxmFTgIgC7xoPU1bn3dhbPQ01vZF1Y2z2XV/I2tuOCaB/Dwc3qg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3473633},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"index.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"e5d8ee1f83d1817b7073bae4b01de1b3b1156474","private":false,"scripts":{"dev":"bun --watch src/index.ts","lint":"eslint .","test":"bun test","build":"bun build src/index.ts --outfile dist/index.js --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && dts-bundle-generator -o dist/index.d.ts src/index.ts","clear":"npm run typecheck && npm run lint:fix && npm run format","format":"prettier --write 'src/**/*.{ts,tsx}'","lint:fix":"eslint . --fix","typecheck":"tsc --noEmit","format:check":"prettier --check 'src/**/*.{ts,tsx}'"},"_npmUser":{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"},"_npmVersion":"10.8.2","description":"Business meta data for the marketing platform","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pino":"^10.3.1","axios":"^1.16.0","otplib":"^13.4.0","pino-pretty":"^13.1.3","class-validator":"^0.15.1","reflect-metadata":"^0.2.2","class-transformer":"^0.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jiti":"^2.7.0","eslint":"^10.3.0","prettier":"^3.8.3","bun-types":"^1.3.14","@eslint/js":"^10.0.1","@types/bun":"latest","typescript-eslint":"^8.59.3","dts-bundle-generator":"^9.5.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mkt-business-meta_0.1.1_1778830485936_0.1290313723871408","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@anhdn-mkt/mkt-business-meta","version":"0.1.2","keywords":["marketing","platform","business","meta"],"author":{"name":"Marketing Platform"},"license":"MIT","_id":"@anhdn-mkt/mkt-business-meta@0.1.2","maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"dist":{"shasum":"11c22038ace86ed15415da11ae1f1aed9e9c9022","tarball":"https://registry.npmjs.org/@anhdn-mkt/mkt-business-meta/-/mkt-business-meta-0.1.2.tgz","fileCount":5,"integrity":"sha512-IgXTuBjhFwXZlcSCNPcNwmlivVc0yko44/fkFHv2mCa+oakI0H9xHZ96QzVZuZTwntbMVYnudFQSYULVo3xZ4Q==","signatures":[{"sig":"MEQCIB5ceVCk0E7s7V/0peQvLd8u9jdQlJgj1BBdyUfsC3XwAiAE4ayGme7TxgZvjirjVyCDpTebjSSae150teeEvqsM7g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3475219},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"index.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"630731a39db9c2e8c6dcfcbfd9cb7c0357b7d2c5","private":false,"scripts":{"dev":"bun --watch src/index.ts","lint":"eslint .","test":"bun test","build":"bun build src/index.ts --outfile dist/index.js --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && dts-bundle-generator -o dist/index.d.ts src/index.ts","clear":"npm run typecheck && npm run lint:fix && npm run format","format":"prettier --write 'src/**/*.{ts,tsx}'","lint:fix":"eslint . --fix","typecheck":"tsc --noEmit","format:check":"prettier --check 'src/**/*.{ts,tsx}'"},"_npmUser":{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"},"_npmVersion":"10.8.2","description":"Business meta data for the marketing platform","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pino":"^10.3.1","axios":"^1.16.0","otplib":"^13.4.0","pino-pretty":"^13.1.3","class-validator":"^0.15.1","reflect-metadata":"^0.2.2","class-transformer":"^0.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jiti":"^2.7.0","eslint":"^10.3.0","prettier":"^3.8.3","bun-types":"^1.3.14","@eslint/js":"^10.0.1","@types/bun":"latest","typescript-eslint":"^8.59.3","dts-bundle-generator":"^9.5.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mkt-business-meta_0.1.2_1778903531497_0.45481157855122967","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@anhdn-mkt/mkt-business-meta","version":"0.1.3","keywords":["marketing","platform","business","meta"],"author":{"name":"Marketing Platform"},"license":"MIT","_id":"@anhdn-mkt/mkt-business-meta@0.1.3","maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"dist":{"shasum":"d23c69636fcaebe786e75ff3b2da133ffcae1871","tarball":"https://registry.npmjs.org/@anhdn-mkt/mkt-business-meta/-/mkt-business-meta-0.1.3.tgz","fileCount":5,"integrity":"sha512-4/64Gt2a2jTIh5s6U+/yIT8ZX2lU1WDeGl9o4NKL+PapIrdx5JFBw7gMqPrT+CEB85l4MRwmwrfU+wZ0XBW6xw==","signatures":[{"sig":"MEYCIQC5/aD6RxR5qY5Rn4Gs3Y4bgbj87ZpO7SQKKkLkOfe2rAIhAPX4Au2YLUo3VPtUPXrjYyL/XLesSPLioc7FrtOlnSLL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3475268},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"index.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"a0f83708d347c83d9245306459158e42a77da0e2","private":false,"scripts":{"dev":"bun --watch src/index.ts","lint":"eslint .","test":"bun test","build":"bun build src/index.ts --outfile dist/index.js --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && dts-bundle-generator -o dist/index.d.ts src/index.ts","clear":"npm run typecheck && npm run lint:fix && npm run format","format":"prettier --write 'src/**/*.{ts,tsx}'","lint:fix":"eslint . --fix","typecheck":"tsc --noEmit","format:check":"prettier --check 'src/**/*.{ts,tsx}'"},"_npmUser":{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"},"_npmVersion":"10.8.2","description":"Business meta data for the marketing platform","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pino":"^10.3.1","axios":"^1.16.0","otplib":"^13.4.0","pino-pretty":"^13.1.3","class-validator":"^0.15.1","reflect-metadata":"^0.2.2","class-transformer":"^0.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jiti":"^2.7.0","eslint":"^10.3.0","prettier":"^3.8.3","bun-types":"^1.3.14","@eslint/js":"^10.0.1","@types/bun":"latest","typescript-eslint":"^8.59.3","dts-bundle-generator":"^9.5.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mkt-business-meta_0.1.3_1779075383251_0.41995204103914063","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@anhdn-mkt/mkt-business-meta","version":"0.1.4","description":"Business meta data for the marketing platform","author":{"name":"Marketing Platform"},"license":"MIT","keywords":["marketing","platform","business","meta"],"module":"index.ts","type":"module","private":false,"scripts":{"dev":"bun --watch src/index.ts","build":"bun build src/index.ts --outfile dist/index.js --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && dts-bundle-generator -o dist/index.d.ts src/index.ts","typecheck":"tsc --noEmit","lint":"eslint .","lint:fix":"eslint . --fix","format":"prettier --write 'src/**/*.{ts,tsx}'","format:check":"prettier --check 'src/**/*.{ts,tsx}'","clear":"npm run typecheck && npm run lint:fix && npm run format","test":"bun test"},"devDependencies":{"@eslint/js":"^10.0.1","@types/bun":"latest","bun-types":"^1.3.14","dts-bundle-generator":"^9.5.1","eslint":"^10.3.0","jiti":"^2.7.0","prettier":"^3.8.3","typescript-eslint":"^8.59.3"},"peerDependencies":{"typescript":"^5"},"dependencies":{"axios":"^1.16.0","class-transformer":"^0.5.1","class-validator":"^0.15.1","otplib":"^13.4.0","pino":"^10.3.1","pino-pretty":"^13.1.3","reflect-metadata":"^0.2.2"},"main":"./dist/index.cjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","default":"./dist/index.js","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"_id":"@anhdn-mkt/mkt-business-meta@0.1.4","gitHead":"b3e08bcc7cd2dcd656e345e59ac37efa1de6fade","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-YrF12x5GEvgYoxgQOg4Oy0xlbAWBauuHsdX0I95EAWoO98N8Cl4VBBu3h1a4I0X+ipxvuB6BxtHkhRSzulGFzA==","shasum":"0a16e040e151938af2e2ec175a9579122af2b2c1","tarball":"https://registry.npmjs.org/@anhdn-mkt/mkt-business-meta/-/mkt-business-meta-0.1.4.tgz","fileCount":5,"unpackedSize":3475556,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIC+1ApNpQYQszOwGmUwCwSyOJJQv5yi4pnV1mUg5QRdRAiBJcSpeNnkVamY3p7N4vPBmP9OIg9dV3nTk1eIqB0yYgw=="}]},"_npmUser":{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"},"directories":{},"maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mkt-business-meta_0.1.4_1779075920413_0.7949105689632268"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T09:06:10.664Z","modified":"2026-05-18T03:45:20.731Z","0.1.0":"2026-05-14T09:06:11.264Z","0.1.1":"2026-05-15T07:34:46.170Z","0.1.2":"2026-05-16T03:52:11.709Z","0.1.3":"2026-05-18T03:36:23.462Z","0.1.4":"2026-05-18T03:45:20.607Z"},"author":{"name":"Marketing Platform"},"license":"MIT","keywords":["marketing","platform","business","meta"],"description":"Business meta data for the marketing platform","maintainers":[{"name":"vitech-anhdn-mkt","email":"anhdn@vitechgroup.vn"}],"readme":"# mkt-business-meta\n\nTypeScript library for Meta business automation flows:\n- Login (including 2FA)\n- Resolve business pages and page access tokens\n- Create Facebook posts and reels with media upload support\n\nBuilt for Bun runtime.\n\n## Features\n\n- `FbMetaClient` with modular services: `auth`, `businessPages`, `composer`\n- Upload pipeline for:\n  - image posts\n  - video posts\n  - mixed media posts\n  - reels\n- File-path-first media input (`filePath`) with internal base64 conversion\n- Structured success/failure responses for all public APIs\n\n## Installation\n\n```bash\nbun add mkt-business-meta\n```\n\nFor local development in this repo:\n\n```bash\nbun install\n```\n\n## Quick Start\n\n```ts\nimport { FbMetaClient } from 'mkt-business-meta'\n\nconst client = new FbMetaClient({\n  appId: process.env.META_APP_ID!,\n  appAccessToken: process.env.META_APP_ACCESS_TOKEN!,\n  logLevel: 'info',\n})\n```\n\n## API Overview\n\n### 1) Auth\n\n```ts\nconst login = await client.auth.login({\n  email: 'user@example.com',\n  password: 'your-password',\n  // optional when account has 2FA\n  twoFactorSecret: 'BASE32_SECRET',\n})\n```\n\nSuccess response:\n\n```ts\n{\n  success: true,\n  data: {\n    uid: string,\n    accessToken: string,\n    cookieHeader?: string,\n    machineId?: string,\n    cookies?: Array<{ name: string; value: string }>\n  }\n}\n```\n\nError response:\n\n```ts\n{\n  success: false,\n  error: {\n    message: string,\n    code?: number,\n    subcode?: number,\n    raw?: unknown\n  }\n}\n```\n\n### 2) Business Pages / Page Tokens\n\n```ts\nconst pageTokens = await client.businessPages.getPageAccessTokens({\n  accessToken: '<USER_ACCESS_TOKEN>',\n  // optional filter\n  pageIds: ['1132154543308068'],\n})\n```\n\nSuccess response:\n\n```ts\n{\n  success: true,\n  data: {\n    pages: Array<{\n      pageId: string,\n      pageName?: string,\n      actorId: string,\n      accessToken: string,\n      tokenSource: 'admin_info' | 'mailbox',\n      scopeId?: string,\n      scopeName?: string,\n      scopeType?: string,\n      fetchedAt: number\n    }>,\n    failedPages: Array<{\n      pageId: string,\n      pageName?: string,\n      message: string\n    }>,\n    totalRequested: number,\n    totalResolved: number,\n    totalFailed: number\n  }\n}\n```\n\nError response:\n\n```ts\n{\n  success: false,\n  error: {\n    message: string,\n    raw?: unknown\n  }\n}\n```\n\n### 3) Create Post\n\n```ts\nconst post = await client.composer.createPost({\n  pageId: '1132154543308068',\n  accessToken: '<PAGE_ACCESS_TOKEN>',\n  message: 'Hello from library',\n  images: [\n    { filePath: '/absolute/path/to/image-1.jpg' },\n    { filePath: '/absolute/path/to/image-2.png' },\n  ],\n  videos: [{ filePath: '/absolute/path/to/video.mp4' }],\n})\n```\n\nSuccess response:\n\n```ts\n{\n  success: true,\n  data: {\n    postId: string,\n    storyId: string,\n    cacheId: string,\n    postIdSource?: 'story' | 'video_fallback',\n    channelErrors: Record<string, unknown>\n  }\n}\n```\n\nError response:\n\n```ts\n{\n  success: false,\n  error: {\n    message: string,\n    raw?: unknown\n  }\n}\n```\n\n### 4) Create Reel\n\n```ts\nconst reel = await client.composer.createReel({\n  pageId: '1132154543308068',\n  accessToken: '<PAGE_ACCESS_TOKEN>',\n  // optional\n  message: 'Reel caption',\n  videos: [{ filePath: '/absolute/path/to/reel.mp4' }],\n})\n```\n\nSuccess response:\n\n```ts\n{\n  success: true,\n  data: {\n    postId: string,\n    storyId: string,\n    cacheId: string,\n    postIdSource?: 'story' | 'video_fallback',\n    channelErrors: Record<string, unknown>\n  }\n}\n```\n\n## API Matrix\n\n| API | Input | Success | Notes |\n| --- | --- | --- | --- |\n| `auth.login` | `email`, `password`, optional `twoFactorSecret` | `uid`, `accessToken`, optional cookies/machineId | Returns structured auth/session data |\n| `businessPages.getPageAccessTokens` | user access token, optional pageIds | list of page access tokens + failed pages summary | token source is `admin_info` or `mailbox` |\n| `composer.createPost` | page token, message, optional images/videos | `postId`, `storyId`, `cacheId`, `postIdSource`, `channelErrors` | single-video post can fallback `postId = videoId` |\n| `composer.createReel` | page token, one video, optional message | `postId`, `storyId`, `cacheId`, `postIdSource`, `channelErrors` | fallback `postId = videoId` when story id unavailable |\n\nError response:\n\n```ts\n{\n  success: false,\n  error: {\n    message: string,\n    raw?: unknown\n  }\n}\n```\n\n## Exported Types\n\nThe package exports these public payload/response aliases from `src/index.ts`:\n\n- `LoginPayload`, `LoginResponse`\n- `GetPageAccessTokensPayload`, `GetPageAccessTokensResponse`\n- `GetBusinessScopesResponse`\n- `CreatePostPayload`, `CreatePostResponse`\n- `CreateReelPayload`, `CreateReelResponse`\n\nExample:\n\n```ts\nimport type {\n  CreatePostPayload,\n  CreatePostResponse,\n  CreateReelPayload,\n  CreateReelResponse,\n  LoginPayload,\n  LoginResponse,\n} from 'mkt-business-meta'\n```\n\n## Media Input Rules\n\n- `images[].filePath` is required for post images.\n- `videos[].filePath` is required for post/reel videos.\n- Library reads file content internally and sends base64 payload to Meta APIs.\n- Optional fields like `filename`, `mimeType`, and video metadata are supported.\n\n## Response Behavior\n\n### Create Post\n\n- `content` -> returns `postId` when story identifiers are available.\n- `content + multiple images` -> returns `postId` when story identifiers are available.\n- `content + 1 video` -> if story identifiers are missing, fallback `postId = videoId`.\n- `content + multiple images + 1 video` -> no video-id fallback; requires story identifiers.\n\n### Create Reel\n\n- `only video` -> returns `postId` from story when available; fallback `postId = videoId`.\n- `text + video` -> same behavior as above.\n\n`postIdSource` values:\n- `story`: post id returned from story identifiers.\n- `video_fallback`: fallback from uploaded video id.\n\n## Error Shape\n\nAll services return either:\n- `{ success: true, data: ... }`\n- `{ success: false, error: { message, raw? } }`\n\nExample:\n\n```ts\n{\n  success: false,\n  error: {\n    message: 'There was a problem with this request. Try again later.',\n    raw: unknown\n  }\n}\n```\n\n## Development\n\n```bash\nbun run typecheck\nbun run lint\nbun test\n```\n\n## Security Notes\n\n- Do not commit real access tokens.\n- Use environment variables for all credentials.\n- Revoke test tokens after validation.\n","readmeFilename":"README.md"}