@yoonion/mimi-seed-mcp 0.24.0 → 0.25.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.
- package/dist/admob/cli.js +34 -5
- package/dist/admob/errors.js +39 -14
- package/dist/ai/client.js +35 -14
- package/dist/ai/notes.js +14 -3
- package/dist/ai/review.js +17 -4
- package/dist/android/keystore-store.js +28 -8
- package/dist/android/keystore.d.ts +17 -2
- package/dist/android/keystore.js +110 -21
- package/dist/android/messages.d.ts +13 -11
- package/dist/android/messages.js +166 -72
- package/dist/android/playstore-sa.js +6 -3
- package/dist/appstore/analytics.js +46 -14
- package/dist/appstore/app-info-policy.js +7 -1
- package/dist/appstore/app-info.js +13 -3
- package/dist/appstore/apps.js +7 -1
- package/dist/appstore/asset-library-write.js +119 -37
- package/dist/appstore/asset-library.js +19 -5
- package/dist/appstore/auth.d.ts +2 -0
- package/dist/appstore/auth.js +31 -5
- package/dist/appstore/client.js +27 -6
- package/dist/appstore/declarations.js +22 -6
- package/dist/appstore/errors.d.ts +1 -1
- package/dist/appstore/errors.js +60 -34
- package/dist/appstore/http.d.ts +6 -0
- package/dist/appstore/http.js +22 -5
- package/dist/appstore/messages.js +86 -28
- package/dist/appstore/previews.js +22 -6
- package/dist/appstore/product-localization.js +10 -2
- package/dist/appstore/product-review.js +29 -10
- package/dist/appstore/products.js +20 -6
- package/dist/appstore/read-response.js +13 -3
- package/dist/appstore/release-target.js +13 -3
- package/dist/appstore/release.js +59 -22
- package/dist/appstore/review-preview.js +17 -6
- package/dist/appstore/review-submission.js +86 -35
- package/dist/appstore/sales.js +96 -44
- package/dist/appstore/screenshots.js +19 -5
- package/dist/appstore/testflight.js +41 -18
- package/dist/appstore/upload-parts.js +12 -3
- package/dist/appstore/versions.js +22 -10
- package/dist/auth/bigquery-auth.js +44 -15
- package/dist/auth/bigquery-setup-cli.js +1 -1
- package/dist/auth/cli.js +4 -2
- package/dist/auth/constants.js +13 -3
- package/dist/auth/drive-auth.d.ts +3 -2
- package/dist/auth/drive-auth.js +47 -17
- package/dist/auth/drive-setup-cli.js +1 -0
- package/dist/auth/errors.d.ts +75 -0
- package/dist/auth/errors.js +190 -86
- package/dist/auth/google-auth.d.ts +3 -1
- package/dist/auth/google-auth.js +39 -27
- package/dist/auth/playstore-auth.d.ts +1 -0
- package/dist/auth/playstore-auth.js +35 -15
- package/dist/auth/scopes.d.ts +11 -29
- package/dist/auth/scopes.js +38 -11
- package/dist/auth/youtube-channel.d.ts +8 -0
- package/dist/auth/youtube-channel.js +11 -3
- package/dist/bigquery/ids.js +19 -5
- package/dist/bigquery/tools.js +24 -8
- package/dist/billing/tools.js +22 -6
- package/dist/checks/appstore-submission.d.ts +1 -1
- package/dist/checks/appstore-submission.js +29 -8
- package/dist/checks/plan.js +169 -62
- package/dist/checks/release-status.js +10 -2
- package/dist/checks/risks.js +230 -63
- package/dist/checks/screenshots.d.ts +4 -4
- package/dist/checks/screenshots.js +63 -22
- package/dist/ci/config.js +8 -5
- package/dist/ci/gitlab.js +3 -1
- package/dist/core/atomic-write.d.ts +5 -2
- package/dist/core/atomic-write.js +8 -4
- package/dist/core/catch-scan.d.ts +17 -0
- package/dist/core/catch-scan.js +111 -0
- package/dist/core/checks/billing.d.ts +5 -0
- package/dist/core/checks/billing.js +36 -5
- package/dist/core/checks/lockfile.js +2 -0
- package/dist/core/checks/release-doctor/fcm.js +1 -0
- package/dist/core/checks/release-doctor/files.d.ts +3 -1
- package/dist/core/checks/release-doctor/files.js +12 -1
- package/dist/core/checks/release-doctor/gradle-apply.js +1 -0
- package/dist/core/checks/release-doctor/ios-xcode.js +22 -3
- package/dist/core/checks/release-doctor/target-sdk.js +1 -1
- package/dist/core/checks/release-doctor/util.d.ts +5 -0
- package/dist/core/checks/release-doctor/util.js +56 -0
- package/dist/core/checks/release-doctor.js +59 -16
- package/dist/core/credential-envelope.d.ts +25 -0
- package/dist/core/credential-envelope.js +66 -0
- package/dist/core/credential-keystore.d.ts +37 -0
- package/dist/core/credential-keystore.js +275 -0
- package/dist/core/credential-read.d.ts +33 -0
- package/dist/core/credential-read.js +112 -0
- package/dist/core/credential-store.d.ts +61 -0
- package/dist/core/credential-store.js +240 -0
- package/dist/core/http-errors.js +1 -0
- package/dist/core/i18n-scan.d.ts +10 -0
- package/dist/core/i18n-scan.js +79 -0
- package/dist/core/json-file.d.ts +30 -0
- package/dist/core/json-file.js +53 -0
- package/dist/core/lang.d.ts +14 -0
- package/dist/core/lang.js +22 -2
- package/dist/core/project-manifest.d.ts +24 -1
- package/dist/core/project-manifest.js +27 -16
- package/dist/drive/tools.js +86 -34
- package/dist/facebook/api.js +3 -1
- package/dist/facebook/config.js +11 -3
- package/dist/facebook/setup.d.ts +2 -0
- package/dist/facebook/setup.js +32 -9
- package/dist/firebase/cli.js +39 -5
- package/dist/firebase/tools.js +36 -10
- package/dist/ga4/cli.js +48 -4
- package/dist/ga4/tools.js +4 -2
- package/dist/googleads/config.js +24 -8
- package/dist/googleads/tools.js +3 -1
- package/dist/gsc/tools.js +10 -2
- package/dist/helpers.d.ts +4 -2
- package/dist/helpers.js +66 -32
- package/dist/i18n/manifest-en.d.ts +6 -0
- package/dist/i18n/manifest-en.js +53 -0
- package/dist/i18n/tools-en/admob.d.ts +25 -0
- package/dist/i18n/tools-en/admob.js +24 -0
- package/dist/i18n/tools-en/ai.d.ts +14 -0
- package/dist/i18n/tools-en/ai.js +13 -0
- package/dist/i18n/tools-en/android.d.ts +14 -0
- package/dist/i18n/tools-en/android.js +13 -0
- package/dist/i18n/tools-en/appstore.d.ts +240 -0
- package/dist/i18n/tools-en/appstore.js +239 -0
- package/dist/i18n/tools-en/auth.d.ts +16 -0
- package/dist/i18n/tools-en/auth.js +15 -0
- package/dist/i18n/tools-en/bigquery.d.ts +16 -0
- package/dist/i18n/tools-en/bigquery.js +15 -0
- package/dist/i18n/tools-en/billing.d.ts +17 -0
- package/dist/i18n/tools-en/billing.js +16 -0
- package/dist/i18n/tools-en/checks.d.ts +23 -0
- package/dist/i18n/tools-en/checks.js +22 -0
- package/dist/i18n/tools-en/ci.d.ts +21 -0
- package/dist/i18n/tools-en/ci.js +20 -0
- package/dist/i18n/tools-en/drive.d.ts +33 -0
- package/dist/i18n/tools-en/drive.js +32 -0
- package/dist/i18n/tools-en/facebook.d.ts +14 -0
- package/dist/i18n/tools-en/facebook.js +13 -0
- package/dist/i18n/tools-en/firebase.d.ts +42 -0
- package/dist/i18n/tools-en/firebase.js +41 -0
- package/dist/i18n/tools-en/ga4.d.ts +35 -0
- package/dist/i18n/tools-en/ga4.js +34 -0
- package/dist/i18n/tools-en/googleads.d.ts +15 -0
- package/dist/i18n/tools-en/googleads.js +14 -0
- package/dist/i18n/tools-en/gsc.d.ts +27 -0
- package/dist/i18n/tools-en/gsc.js +26 -0
- package/dist/i18n/tools-en/iam.d.ts +15 -0
- package/dist/i18n/tools-en/iam.js +14 -0
- package/dist/i18n/tools-en/index.d.ts +7 -0
- package/dist/i18n/tools-en/index.js +58 -0
- package/dist/i18n/tools-en/instagram.d.ts +16 -0
- package/dist/i18n/tools-en/instagram.js +15 -0
- package/dist/i18n/tools-en/jenkins.d.ts +41 -0
- package/dist/i18n/tools-en/jenkins.js +40 -0
- package/dist/i18n/tools-en/naver.d.ts +10 -0
- package/dist/i18n/tools-en/naver.js +9 -0
- package/dist/i18n/tools-en/playstore.d.ts +148 -0
- package/dist/i18n/tools-en/playstore.js +147 -0
- package/dist/i18n/tools-en/registrar.d.ts +6 -0
- package/dist/i18n/tools-en/registrar.js +6 -0
- package/dist/i18n/tools-en/threads.d.ts +21 -0
- package/dist/i18n/tools-en/threads.js +20 -0
- package/dist/i18n/tools-en/tiktok.d.ts +21 -0
- package/dist/i18n/tools-en/tiktok.js +20 -0
- package/dist/i18n/tools-en/video.d.ts +59 -0
- package/dist/i18n/tools-en/video.js +58 -0
- package/dist/i18n/tools-en/youtube.d.ts +44 -0
- package/dist/i18n/tools-en/youtube.js +43 -0
- package/dist/iam/key-files.js +13 -3
- package/dist/instagram/api.js +19 -5
- package/dist/instagram/config.js +11 -3
- package/dist/instagram/setup.js +37 -11
- package/dist/jenkins/builds.d.ts +2 -2
- package/dist/jenkins/builds.js +70 -30
- package/dist/jenkins/config.d.ts +5 -0
- package/dist/jenkins/config.js +25 -6
- package/dist/jenkins/credentials.js +33 -13
- package/dist/jenkins/http.js +6 -3
- package/dist/jenkins/jobs.js +19 -5
- package/dist/jenkins/messages.js +93 -36
- package/dist/lib/cli-args.js +13 -7
- package/dist/lib/google-errors.js +31 -9
- package/dist/lib/http.js +10 -3
- package/dist/lib/json-file.d.ts +15 -0
- package/dist/lib/json-file.js +65 -0
- package/dist/lib/meta-auth.d.ts +1 -1
- package/dist/lib/meta-auth.js +26 -8
- package/dist/lib/package-name.js +15 -4
- package/dist/lib/package-root.js +1 -1
- package/dist/lib/paginate.js +10 -2
- package/dist/lib/path-containment.js +22 -6
- package/dist/lib/resource-id.js +10 -3
- package/dist/lib/store-create-result.js +54 -13
- package/dist/lib/text-validators.js +20 -5
- package/dist/lib/tool-registrar.d.ts +9 -0
- package/dist/lib/tool-registrar.js +33 -14
- package/dist/lib/tool-text.d.ts +31 -0
- package/dist/lib/tool-text.js +52 -0
- package/dist/lib/toolsets.js +13 -3
- package/dist/lib/url-path.js +3 -1
- package/dist/naver/tools.js +138 -46
- package/dist/playstore/data-safety.js +16 -4
- package/dist/playstore/errors.js +33 -8
- package/dist/playstore/financials.js +83 -35
- package/dist/playstore/listing.js +7 -1
- package/dist/playstore/messages.js +179 -57
- package/dist/playstore/products.js +10 -2
- package/dist/playstore/recovery.js +10 -2
- package/dist/playstore/releases.js +34 -14
- package/dist/playstore/reviews.js +14 -4
- package/dist/playstore/statistics.js +3 -1
- package/dist/prompts.js +160 -50
- package/dist/registers/admob.js +36 -11
- package/dist/registers/android.js +25 -9
- package/dist/registers/appstore/apps.js +22 -6
- package/dist/registers/appstore/customer-reviews.js +7 -1
- package/dist/registers/appstore/declarations.js +63 -19
- package/dist/registers/appstore/media.js +76 -24
- package/dist/registers/appstore/metadata.js +26 -8
- package/dist/registers/appstore/products.js +53 -19
- package/dist/registers/appstore/review-submission.js +31 -9
- package/dist/registers/appstore/testflight.js +82 -24
- package/dist/registers/appstore/versions.js +88 -30
- package/dist/registers/auth.js +343 -90
- package/dist/registers/bigquery.js +54 -14
- package/dist/registers/billing.js +18 -4
- package/dist/registers/checks.js +20 -5
- package/dist/registers/ci.js +60 -20
- package/dist/registers/drive.js +18 -7
- package/dist/registers/facebook.js +31 -9
- package/dist/registers/firebase.js +21 -7
- package/dist/registers/googleads.js +23 -6
- package/dist/registers/gsc.js +3 -1
- package/dist/registers/iam.js +44 -13
- package/dist/registers/instagram.js +19 -5
- package/dist/registers/jenkins.js +43 -14
- package/dist/registers/naver.js +13 -3
- package/dist/registers/playstore/financials.d.ts +6 -0
- package/dist/registers/playstore/financials.js +48 -0
- package/dist/registers/playstore/listing.d.ts +15 -0
- package/dist/registers/playstore/listing.js +138 -0
- package/dist/registers/playstore/media.d.ts +6 -0
- package/dist/registers/playstore/media.js +56 -0
- package/dist/registers/playstore/products.d.ts +21 -0
- package/dist/registers/playstore/products.js +238 -0
- package/dist/registers/playstore/recovery.d.ts +11 -0
- package/dist/registers/playstore/recovery.js +105 -0
- package/dist/registers/playstore/releases.d.ts +8 -0
- package/dist/registers/playstore/releases.js +157 -0
- package/dist/registers/playstore/reviews.d.ts +6 -0
- package/dist/registers/playstore/reviews.js +43 -0
- package/dist/registers/playstore/service-accounts.d.ts +13 -0
- package/dist/registers/playstore/service-accounts.js +127 -0
- package/dist/registers/playstore/shared.d.ts +12 -0
- package/dist/registers/playstore/shared.js +24 -0
- package/dist/registers/playstore.d.ts +8 -0
- package/dist/registers/playstore.js +28 -734
- package/dist/registers/threads.js +28 -8
- package/dist/registers/tiktok.js +4 -2
- package/dist/registers/video.js +3 -1
- package/dist/remote-sync.js +80 -28
- package/dist/resources.d.ts +0 -8
- package/dist/resources.js +73 -32
- package/dist/server.d.ts +2 -0
- package/dist/server.js +9 -1
- package/dist/social/profile-store.js +36 -12
- package/dist/social/setup-cli.js +1 -1
- package/dist/threads/api.js +23 -6
- package/dist/threads/setup.js +42 -14
- package/dist/tiktok-business/api.js +13 -3
- package/dist/tiktok-business/auth.js +10 -2
- package/dist/tiktok-business/config.js +8 -3
- package/dist/tiktok-business/posting.d.ts +6 -0
- package/dist/tiktok-business/posting.js +118 -36
- package/dist/tiktok-business/setup-cli.js +3 -1
- package/dist/tools-cli.js +4 -5
- package/dist/video/captions.js +3 -1
- package/dist/video/files.js +13 -3
- package/dist/video/project.js +65 -21
- package/dist/video/providers.js +52 -16
- package/dist/video/render.js +71 -22
- package/dist/video/research.js +10 -2
- package/dist/video/schemas.js +19 -5
- package/dist/video/youtube-publish.js +62 -32
- package/package.json +1 -1
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { lookupProjectManifest, isValidSocialProfileId, manifestSocialProfile, } from '#core/project-manifest.js';
|
|
5
5
|
import { writeCredentialJson } from '#core/atomic-write.js';
|
|
6
|
+
import { catalog } from '#core/lang.js';
|
|
7
|
+
import { readCredentialFileSync } from '#core/credential-read.js';
|
|
8
|
+
const M = catalog({
|
|
9
|
+
invalidId: '소셜 프로필 ID가 올바르지 않습니다. ' +
|
|
10
|
+
'영문자·숫자로 시작하는 1~64자의 영문자/숫자/점/밑줄/하이픈만 사용할 수 있습니다.',
|
|
11
|
+
notObject: '객체 형식이 아닙니다.',
|
|
12
|
+
unreadable: (file, msg) => `기존 소셜 프로필 파일을 읽을 수 없어 덮어쓰지 않았습니다: ${file} ` + `(${msg})`,
|
|
13
|
+
profile: (id) => `프로필 '${id}'`,
|
|
14
|
+
defaultProfile: '기본 프로필',
|
|
15
|
+
manifestInvalid: (file) => `프로젝트 매니페스트를 읽을 수 없어 어느 소셜 계정을 쓸지 정할 수 없습니다: ${file}. ` +
|
|
16
|
+
'기본 계정으로 대신 게시하지 않습니다 — 파일을 고치거나, profile 인자로 프로필을 직접 지정하세요.',
|
|
17
|
+
}, {
|
|
18
|
+
invalidId: 'Invalid social profile ID. ' +
|
|
19
|
+
'Use 1–64 characters of letters, digits, dots, underscores, or hyphens, starting with a letter or digit.',
|
|
20
|
+
notObject: 'It is not an object.',
|
|
21
|
+
unreadable: (file, msg) => `Could not read the existing social profile file, so it was not overwritten: ${file} (${msg})`,
|
|
22
|
+
profile: (id) => `profile '${id}'`,
|
|
23
|
+
defaultProfile: 'default profile',
|
|
24
|
+
manifestInvalid: (file) => `Cannot read the project manifest, so the social account to use is unknown: ${file}. ` +
|
|
25
|
+
'Not falling back to the default account — fix the file, or pass the profile argument explicitly.',
|
|
26
|
+
});
|
|
6
27
|
function validateProfileId(profile) {
|
|
7
28
|
if (!isValidSocialProfileId(profile)) {
|
|
8
|
-
throw new Error(
|
|
9
|
-
'영문자·숫자로 시작하는 1~64자의 영문자/숫자/점/밑줄/하이픈만 사용할 수 있습니다.');
|
|
29
|
+
throw new Error(M().invalidId);
|
|
10
30
|
}
|
|
11
31
|
return profile;
|
|
12
32
|
}
|
|
@@ -18,9 +38,13 @@ export function resolveSocialConfigTarget(platform, options = {}) {
|
|
|
18
38
|
profile = validateProfileId(options.profile);
|
|
19
39
|
}
|
|
20
40
|
else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
// 매니페스트가 깨졌으면 기본 계정으로 폴백하지 않는다 — 그 파일이 다른 프로필을 지정했을 수 있다(다른 계정에 게시).
|
|
42
|
+
// 매니페스트의 socialProfiles 값이 잘못된 경우(manifestSocialProfile 이 throw)와 같은 취급이다.
|
|
43
|
+
const lookup = lookupProjectManifest(options.startDir ?? process.cwd());
|
|
44
|
+
if (lookup.state === 'invalid')
|
|
45
|
+
throw new Error(M().manifestInvalid(lookup.filePath));
|
|
46
|
+
if (lookup.state === 'ok')
|
|
47
|
+
profile = manifestSocialProfile(lookup.loaded.manifest, platform);
|
|
24
48
|
}
|
|
25
49
|
return profile
|
|
26
50
|
? { profile, filePath: path.join(root, 'social-profiles', `${profile}.json`) }
|
|
@@ -29,7 +53,7 @@ export function resolveSocialConfigTarget(platform, options = {}) {
|
|
|
29
53
|
export function loadSocialPlatformConfig(platform, options = {}) {
|
|
30
54
|
const target = resolveSocialConfigTarget(platform, options);
|
|
31
55
|
try {
|
|
32
|
-
const parsed = JSON.parse(
|
|
56
|
+
const parsed = JSON.parse(readCredentialFileSync(target.filePath));
|
|
33
57
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
34
58
|
return null;
|
|
35
59
|
if (target.profile) {
|
|
@@ -38,6 +62,7 @@ export function loadSocialPlatformConfig(platform, options = {}) {
|
|
|
38
62
|
return parsed;
|
|
39
63
|
}
|
|
40
64
|
catch {
|
|
65
|
+
// 깨진 설정은 '미설정' — 대상 파일이 이미 정해져 다른 계정으로 넘어가지 않고, 깨진 파일은 mimi_seed_status 가 보고한다
|
|
41
66
|
return null;
|
|
42
67
|
}
|
|
43
68
|
}
|
|
@@ -48,15 +73,14 @@ export function saveSocialPlatformConfig(platform, config, options = {}) {
|
|
|
48
73
|
let existing = {};
|
|
49
74
|
if (fs.existsSync(target.filePath)) {
|
|
50
75
|
try {
|
|
51
|
-
const parsed = JSON.parse(
|
|
76
|
+
const parsed = JSON.parse(readCredentialFileSync(target.filePath));
|
|
52
77
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
53
|
-
throw new Error(
|
|
78
|
+
throw new Error(M().notObject);
|
|
54
79
|
}
|
|
55
80
|
existing = parsed;
|
|
56
81
|
}
|
|
57
82
|
catch (error) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`(${error instanceof Error ? error.message : String(error)})`, { cause: error });
|
|
83
|
+
throw new Error(M().unreadable(target.filePath, error instanceof Error ? error.message : String(error)), { cause: error });
|
|
60
84
|
}
|
|
61
85
|
}
|
|
62
86
|
value = { ...existing, [platform]: config };
|
|
@@ -65,5 +89,5 @@ export function saveSocialPlatformConfig(platform, config, options = {}) {
|
|
|
65
89
|
return target;
|
|
66
90
|
}
|
|
67
91
|
export function socialTargetLabel(target) {
|
|
68
|
-
return target.profile ?
|
|
92
|
+
return target.profile ? M().profile(target.profile) : M().defaultProfile;
|
|
69
93
|
}
|
package/dist/social/setup-cli.js
CHANGED
|
@@ -154,7 +154,7 @@ async function setupFacebook(profile) {
|
|
|
154
154
|
let result = await connectFacebook(token, pageId || undefined, options);
|
|
155
155
|
// 토큰이 여러 페이지에 닿으면 connectFacebook 은 목록만 주고 저장하지 않는다.
|
|
156
156
|
// 다시 실행하라고 내보내지 말고, 여기서 바로 골라 받는다.
|
|
157
|
-
if (!result.ok && result.
|
|
157
|
+
if (!result.ok && result.needsPageChoice) {
|
|
158
158
|
console.log('');
|
|
159
159
|
console.log(indent(result.text));
|
|
160
160
|
pageId = await ask(M.fbPickPage);
|
package/dist/threads/api.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { metaApiError } from '../lib/meta-auth.js';
|
|
2
2
|
import { fetchWithTimeout } from '../lib/http.js';
|
|
3
3
|
import { encodePathSegment } from '../lib/url-path.js';
|
|
4
|
+
import { catalog } from '#core/lang.js';
|
|
5
|
+
const M = catalog({
|
|
6
|
+
noUserId: 'Threads user ID를 조회하지 못했습니다. 토큰에 threads_basic 권한이 있는지 확인하세요.',
|
|
7
|
+
refreshUnparsable: 'Threads 토큰 갱신 응답을 해석하지 못했습니다. 새 토큰을 발급해 다시 연결하세요.',
|
|
8
|
+
refreshIncomplete: 'Threads 토큰 갱신 응답에 access_token 또는 expires_in이 없습니다.',
|
|
9
|
+
mediaFailed: (status, msg) => `미디어 처리 실패 (${status})${msg ? `: ${msg}` : ''}`,
|
|
10
|
+
mediaTimeout: '미디어 처리 대기 시간 초과 (60초). 잠시 후 다시 시도하세요.',
|
|
11
|
+
carouselCount: (n) => `캐러셀은 2~20장의 이미지가 필요합니다 (받은 수: ${n}).`,
|
|
12
|
+
}, {
|
|
13
|
+
noUserId: 'Could not look up the Threads user ID. Check that the token has the threads_basic permission.',
|
|
14
|
+
refreshUnparsable: 'Could not parse the Threads token refresh response. Issue a new token and connect again.',
|
|
15
|
+
refreshIncomplete: 'The Threads token refresh response has no access_token or expires_in.',
|
|
16
|
+
mediaFailed: (status, msg) => `Media processing failed (${status})${msg ? `: ${msg}` : ''}`,
|
|
17
|
+
mediaTimeout: 'Timed out waiting for media processing (60 seconds). Try again shortly.',
|
|
18
|
+
carouselCount: (n) => `A carousel needs 2–20 images (received: ${n}).`,
|
|
19
|
+
});
|
|
4
20
|
// Threads Graph API. Instagram 과 달리 base 가 하나뿐이라 토큰 prefix 분기가 없다.
|
|
5
21
|
// graph.threads.net/v1.0
|
|
6
22
|
// 게시 흐름은 인스타와 같은 2단계: container 생성(/me/threads) → publish(/me/threads_publish).
|
|
@@ -48,7 +64,7 @@ export async function getAccount(cfg) {
|
|
|
48
64
|
export async function fetchUserId(accessToken) {
|
|
49
65
|
const res = await thFetch(accessToken, '/me', { fields: 'id,username', access_token: accessToken });
|
|
50
66
|
if (!res.id) {
|
|
51
|
-
throw new Error(
|
|
67
|
+
throw new Error(M().noUserId);
|
|
52
68
|
}
|
|
53
69
|
return res.id;
|
|
54
70
|
}
|
|
@@ -77,10 +93,10 @@ export async function refreshAccessToken(accessToken) {
|
|
|
77
93
|
parsed = JSON.parse(text);
|
|
78
94
|
}
|
|
79
95
|
catch {
|
|
80
|
-
throw new Error(
|
|
96
|
+
throw new Error(M().refreshUnparsable);
|
|
81
97
|
}
|
|
82
98
|
if (!parsed.access_token || !Number.isFinite(parsed.expires_in) || parsed.expires_in <= 0) {
|
|
83
|
-
throw new Error(
|
|
99
|
+
throw new Error(M().refreshIncomplete);
|
|
84
100
|
}
|
|
85
101
|
return { accessToken: parsed.access_token, expiresInSeconds: parsed.expires_in };
|
|
86
102
|
}
|
|
@@ -90,6 +106,7 @@ async function fetchPermalink(cfg, mediaId) {
|
|
|
90
106
|
return meta.permalink;
|
|
91
107
|
}
|
|
92
108
|
catch {
|
|
109
|
+
// 게시는 이미 끝났다 — permalink 조회 실패로 성공을 오류로 바꾸면 재시도가 중복 게시를 만든다
|
|
93
110
|
return undefined;
|
|
94
111
|
}
|
|
95
112
|
}
|
|
@@ -103,11 +120,11 @@ async function waitForContainer(cfg, containerId) {
|
|
|
103
120
|
if (status === 'FINISHED')
|
|
104
121
|
return;
|
|
105
122
|
if (status === 'ERROR' || status === 'EXPIRED') {
|
|
106
|
-
throw new Error(
|
|
123
|
+
throw new Error(M().mediaFailed(status, error_message));
|
|
107
124
|
}
|
|
108
125
|
await new Promise((r) => setTimeout(r, INTERVAL_MS));
|
|
109
126
|
}
|
|
110
|
-
throw new Error(
|
|
127
|
+
throw new Error(M().mediaTimeout);
|
|
111
128
|
}
|
|
112
129
|
async function publish(cfg, creationId) {
|
|
113
130
|
const published = await thFetch(cfg.accessToken, '/me/threads_publish', { creation_id: creationId, access_token: cfg.accessToken }, 'POST');
|
|
@@ -143,7 +160,7 @@ export async function postVideo(cfg, videoUrl, text = '', altText) {
|
|
|
143
160
|
}
|
|
144
161
|
export async function postCarousel(cfg, imageUrls, text) {
|
|
145
162
|
if (imageUrls.length < 2 || imageUrls.length > 20) {
|
|
146
|
-
throw new Error(
|
|
163
|
+
throw new Error(M().carouselCount(imageUrls.length));
|
|
147
164
|
}
|
|
148
165
|
// Step 1: 각 이미지를 children container 로 생성 (sequential — 부분 실패 시 명확)
|
|
149
166
|
const childIds = [];
|
package/dist/threads/setup.js
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
import { saveThreadsConfig } from './config.js';
|
|
4
4
|
import * as api from './api.js';
|
|
5
5
|
import { resolveSocialConfigTarget, socialTargetLabel } from '../social/profile-store.js';
|
|
6
|
+
import { catalog } from '#core/lang.js';
|
|
7
|
+
const M = catalog({
|
|
8
|
+
userIdFailed: '❌ userId 자동 조회 실패',
|
|
9
|
+
userIdHint: 'userId를 명시적으로 전달하거나 토큰을 다시 확인하세요.',
|
|
10
|
+
connected: '✅ Threads 연결 확인 완료',
|
|
11
|
+
target: (t) => ` 저장 대상: ${t}`,
|
|
12
|
+
account: (a) => ` 계정: ${a}`,
|
|
13
|
+
expires: (d) => ` 토큰 만료: ${d}`,
|
|
14
|
+
verifyFailed: '❌ 토큰 검증 실패',
|
|
15
|
+
verifyHint: '토큰을 다시 발급받거나 userId를 직접 지정해보세요.',
|
|
16
|
+
refreshed: '✅ Threads 토큰 갱신 완료',
|
|
17
|
+
newExpiry: (d) => ` 새 만료일: ${d}`,
|
|
18
|
+
refreshFailed: '❌ Threads 토큰 자동 갱신 실패 — 기존 설정은 보존했습니다.',
|
|
19
|
+
refreshRecovery: ' 복구: mimi-seed auth threads 로 브라우저에서 다시 로그인하세요.',
|
|
20
|
+
}, {
|
|
21
|
+
userIdFailed: '❌ Could not look up userId automatically',
|
|
22
|
+
userIdHint: 'Pass userId explicitly or check the token again.',
|
|
23
|
+
connected: '✅ Threads connection verified',
|
|
24
|
+
target: (t) => ` Saved to: ${t}`,
|
|
25
|
+
account: (a) => ` Account: ${a}`,
|
|
26
|
+
expires: (d) => ` Token expires: ${d}`,
|
|
27
|
+
verifyFailed: '❌ Token verification failed',
|
|
28
|
+
verifyHint: 'Issue a new token or specify userId directly.',
|
|
29
|
+
refreshed: '✅ Threads token refreshed',
|
|
30
|
+
newExpiry: (d) => ` New expiry: ${d}`,
|
|
31
|
+
refreshFailed: '❌ Automatic Threads token refresh failed — the existing settings were kept.',
|
|
32
|
+
refreshRecovery: ' Recovery: log in again in the browser with mimi-seed auth threads.',
|
|
33
|
+
});
|
|
6
34
|
const SIXTY_DAYS_MS = 60 * 24 * 60 * 60 * 1000;
|
|
7
35
|
export async function connectThreads(accessToken, userId, assumeIssuedNow = true, options = {}, expiresInSeconds) {
|
|
8
36
|
if (expiresInSeconds !== undefined && (!Number.isFinite(expiresInSeconds) || expiresInSeconds <= 0 || expiresInSeconds > 5_184_000)) {
|
|
@@ -19,10 +47,10 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
|
|
|
19
47
|
return {
|
|
20
48
|
ok: false,
|
|
21
49
|
text: [
|
|
22
|
-
|
|
50
|
+
M().userIdFailed,
|
|
23
51
|
` ${err.message}`,
|
|
24
52
|
'',
|
|
25
|
-
|
|
53
|
+
M().userIdHint,
|
|
26
54
|
].join('\n'),
|
|
27
55
|
};
|
|
28
56
|
}
|
|
@@ -41,11 +69,11 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
|
|
|
41
69
|
return {
|
|
42
70
|
ok: true,
|
|
43
71
|
text: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
M().connected,
|
|
73
|
+
M().target(socialTargetLabel(target)),
|
|
74
|
+
M().account(`@${account.username}${account.name ? ` (${account.name})` : ''}`),
|
|
47
75
|
` ID: ${account.id}`,
|
|
48
|
-
expiresAt ?
|
|
76
|
+
expiresAt ? M().expires(expiresAt.slice(0, 10)) : '',
|
|
49
77
|
]
|
|
50
78
|
.filter(Boolean)
|
|
51
79
|
.join('\n'),
|
|
@@ -56,11 +84,11 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
|
|
|
56
84
|
return {
|
|
57
85
|
ok: false,
|
|
58
86
|
text: [
|
|
59
|
-
|
|
87
|
+
M().verifyFailed,
|
|
60
88
|
` userId: ${resolvedUserId}`,
|
|
61
89
|
` ${err.message}`,
|
|
62
90
|
'',
|
|
63
|
-
|
|
91
|
+
M().verifyHint,
|
|
64
92
|
].join('\n'),
|
|
65
93
|
};
|
|
66
94
|
}
|
|
@@ -82,10 +110,10 @@ export async function refreshThreadsToken(currentAccessToken, options = {}) {
|
|
|
82
110
|
return {
|
|
83
111
|
ok: true,
|
|
84
112
|
text: [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
M().refreshed,
|
|
114
|
+
M().target(socialTargetLabel(target)),
|
|
115
|
+
M().account(`@${account.username}`),
|
|
116
|
+
M().newExpiry(expiresAt.slice(0, 10)),
|
|
89
117
|
].join('\n'),
|
|
90
118
|
};
|
|
91
119
|
}
|
|
@@ -93,9 +121,9 @@ export async function refreshThreadsToken(currentAccessToken, options = {}) {
|
|
|
93
121
|
return {
|
|
94
122
|
ok: false,
|
|
95
123
|
text: [
|
|
96
|
-
|
|
124
|
+
M().refreshFailed,
|
|
97
125
|
` ${err.message}`,
|
|
98
|
-
|
|
126
|
+
M().refreshRecovery,
|
|
99
127
|
].join('\n'),
|
|
100
128
|
};
|
|
101
129
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { fetchWithTimeout } from '../lib/http.js';
|
|
2
|
+
import { catalog } from '#core/lang.js';
|
|
2
3
|
export const TIKTOK_API_BASE = 'https://business-api.tiktok.com/open_api/v1.3';
|
|
4
|
+
const M = catalog({
|
|
5
|
+
unparseable: (endpoint, status) => `TikTok ${endpoint} 응답을 해석하지 못했습니다 (HTTP ${status}).`,
|
|
6
|
+
failed: (endpoint, detail, code) => `TikTok ${endpoint} 실패: ${detail} (code ${String(code)})`,
|
|
7
|
+
noTokenFields: (endpoint) => `TikTok ${endpoint} 응답에 필수 토큰 필드가 없습니다.`,
|
|
8
|
+
}, {
|
|
9
|
+
unparseable: (endpoint, status) => `Could not parse the TikTok ${endpoint} response (HTTP ${status}).`,
|
|
10
|
+
failed: (endpoint, detail, code) => `TikTok ${endpoint} failed: ${detail} (code ${String(code)})`,
|
|
11
|
+
noTokenFields: (endpoint) => `The TikTok ${endpoint} response is missing required token fields.`,
|
|
12
|
+
});
|
|
3
13
|
export class TikTokApiError extends Error {
|
|
4
14
|
code;
|
|
5
15
|
requestId;
|
|
@@ -18,10 +28,10 @@ function parseEnvelope(text, status, endpoint) {
|
|
|
18
28
|
body = JSON.parse(text);
|
|
19
29
|
}
|
|
20
30
|
catch {
|
|
21
|
-
throw new TikTokApiError(
|
|
31
|
+
throw new TikTokApiError(M().unparseable(endpoint, status));
|
|
22
32
|
}
|
|
23
33
|
if (status < 200 || status >= 300 || body.code !== 0) {
|
|
24
|
-
throw new TikTokApiError(
|
|
34
|
+
throw new TikTokApiError(M().failed(endpoint, body.message || `HTTP ${status}`, body.code), body.code, body.request_id);
|
|
25
35
|
}
|
|
26
36
|
return body;
|
|
27
37
|
}
|
|
@@ -33,7 +43,7 @@ async function tokenPost(endpoint, payload) {
|
|
|
33
43
|
});
|
|
34
44
|
const envelope = parseEnvelope(await response.text(), response.status, endpoint);
|
|
35
45
|
if (!envelope.data?.access_token || !envelope.data.refresh_token || !envelope.data.open_id) {
|
|
36
|
-
throw new TikTokApiError(
|
|
46
|
+
throw new TikTokApiError(M().noTokenFields(endpoint));
|
|
37
47
|
}
|
|
38
48
|
return envelope.data;
|
|
39
49
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { loadTikTokBusinessConfig, requireTikTokBusinessConfig, saveTikTokBusinessConfig, } from './config.js';
|
|
2
2
|
import { refreshAccessToken } from './api.js';
|
|
3
|
+
import { catalog } from '#core/lang.js';
|
|
4
|
+
const M = catalog({
|
|
5
|
+
refreshExpired: 'TikTok refresh token이 만료되었습니다. `mimi-seed auth tiktok`으로 다시 연결하세요.',
|
|
6
|
+
noPublishScope: 'TikTok 연결에 video.publish 권한이 없습니다. Developer 앱 권한을 승인한 뒤 `mimi-seed auth tiktok`으로 다시 연결하세요.',
|
|
7
|
+
}, {
|
|
8
|
+
refreshExpired: 'The TikTok refresh token has expired. Reconnect with `mimi-seed auth tiktok`.',
|
|
9
|
+
noPublishScope: 'The TikTok connection lacks the video.publish scope. Approve the Developer app permission, then reconnect with `mimi-seed auth tiktok`.',
|
|
10
|
+
});
|
|
3
11
|
const REFRESH_EARLY_MS = 5 * 60 * 1000;
|
|
4
12
|
function expiresAt(seconds, now = Date.now()) {
|
|
5
13
|
return new Date(now + seconds * 1000).toISOString();
|
|
@@ -32,7 +40,7 @@ export async function ensureFreshTikTokConfig() {
|
|
|
32
40
|
const config = requireTikTokBusinessConfig();
|
|
33
41
|
const freshness = tokenFreshness(config);
|
|
34
42
|
if (freshness.state === 'refresh_expired') {
|
|
35
|
-
throw new Error(
|
|
43
|
+
throw new Error(M().refreshExpired);
|
|
36
44
|
}
|
|
37
45
|
if (freshness.state === 'fresh')
|
|
38
46
|
return config;
|
|
@@ -60,7 +68,7 @@ export function safeTokenInspection(config, tokenInfo) {
|
|
|
60
68
|
export async function ensureTikTokPublishConfig() {
|
|
61
69
|
const config = await ensureFreshTikTokConfig();
|
|
62
70
|
if (!hasTikTokScope(config, 'video.publish')) {
|
|
63
|
-
throw new Error(
|
|
71
|
+
throw new Error(M().noPublishScope);
|
|
64
72
|
}
|
|
65
73
|
return config;
|
|
66
74
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import os from 'node:os';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { writeCredentialJson } from '#core/atomic-write.js';
|
|
4
|
+
import { assertCredentialFileReadable } from '../lib/json-file.js';
|
|
5
|
+
import { catalog } from '#core/lang.js';
|
|
6
|
+
import { readCredentialFileSync } from '#core/credential-read.js';
|
|
7
|
+
const M = catalog({ missing: 'TikTok Business 설정이 없습니다. 터미널에서 `mimi-seed auth tiktok`을 실행하세요.' }, { missing: 'No TikTok Business configuration. Run `mimi-seed auth tiktok` in a terminal.' });
|
|
5
8
|
export const TIKTOK_BUSINESS_CONFIG_PATH = path.join(os.homedir(), '.mimi-seed', 'tiktok-business.json');
|
|
6
9
|
export function loadTikTokBusinessConfig() {
|
|
7
10
|
try {
|
|
8
|
-
const value = JSON.parse(
|
|
11
|
+
const value = JSON.parse(readCredentialFileSync(TIKTOK_BUSINESS_CONFIG_PATH));
|
|
9
12
|
const required = [
|
|
10
13
|
'clientId', 'clientSecret', 'redirectUri', 'accessToken', 'refreshToken',
|
|
11
14
|
'accessTokenExpiresAt', 'refreshTokenExpiresAt', 'openId', 'scope', 'tokenType',
|
|
@@ -15,6 +18,7 @@ export function loadTikTokBusinessConfig() {
|
|
|
15
18
|
return value;
|
|
16
19
|
}
|
|
17
20
|
catch {
|
|
21
|
+
// 읽을 수 없으면 '미설정' — 깨진 파일은 requireTikTokBusinessConfig · mimi_seed_status 가 json-file 로 따로 진단한다
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -24,7 +28,8 @@ export function saveTikTokBusinessConfig(config) {
|
|
|
24
28
|
export function requireTikTokBusinessConfig() {
|
|
25
29
|
const config = loadTikTokBusinessConfig();
|
|
26
30
|
if (!config) {
|
|
27
|
-
|
|
31
|
+
assertCredentialFileReadable(TIKTOK_BUSINESS_CONFIG_PATH, '`mimi-seed auth tiktok`');
|
|
32
|
+
throw new Error(M().missing);
|
|
28
33
|
}
|
|
29
34
|
return config;
|
|
30
35
|
}
|
|
@@ -57,6 +57,11 @@ declare function assertVideoFacts(facts: VideoFacts, settings: TikTokVideoSettin
|
|
|
57
57
|
declare function assertThumbnailOffset(thumbnailOffsetMs: number | undefined, durationSec: number): void;
|
|
58
58
|
declare function acquirePublishLock(openId: string, contentHash: string, lockDir?: string): void;
|
|
59
59
|
declare function releasePublishLock(openId: string, contentHash: string, lockDir?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* 같은 계정·영상의 막아야 할 기존 기록. 기록 파일이 있는데 읽을 수 없으면 "기록 없음"으로 보지 않고 throw —
|
|
62
|
+
* 그 파일이 published 였을 수 있고, 잠금 파일까지 지워진 상태라면 공개 게시가 두 번 나간다.
|
|
63
|
+
*/
|
|
64
|
+
declare function existingBlockingAudit(openId: string, contentHash: string, file?: string): TikTokPublishAudit | null;
|
|
60
65
|
export declare function planVideoPost(input: PlanVideoPostInput): Promise<TikTokPostPlan>;
|
|
61
66
|
export declare function loadPostPlan(planId: string): TikTokPostPlan;
|
|
62
67
|
export declare function publishPlannedVideo(planId: string, confirmPublish: boolean): Promise<{
|
|
@@ -96,6 +101,7 @@ export declare const __testing: {
|
|
|
96
101
|
assertVideoFacts: typeof assertVideoFacts;
|
|
97
102
|
acquirePublishLock: typeof acquirePublishLock;
|
|
98
103
|
countMentions: typeof countMentions;
|
|
104
|
+
existingBlockingAudit: typeof existingBlockingAudit;
|
|
99
105
|
fpsValue: typeof fpsValue;
|
|
100
106
|
releasePublishLock: typeof releasePublishLock;
|
|
101
107
|
safeUrl: typeof safeUrl;
|