cmx-sdk 0.2.21 → 0.2.23
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/{add-studio-QWLCCO5M.js → add-studio-2COHXK65.js} +6 -3
- package/dist/{chunk-ZBI5OLBT.js → chunk-2WLUAJR2.js} +0 -108
- package/dist/chunk-WJ5REY5E.js +124 -0
- package/dist/{chunk-FPQYL5GE.js → chunk-YYDYSBN7.js} +6 -3
- package/dist/cli.js +18 -27
- package/dist/index.d.ts +69 -1
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/dist/{interactive-menu-5NJTB5LJ.js → interactive-menu-R3TJZOMK.js} +2 -2
- package/dist/{report-bug-PT7NNFNN.js → report-bug-WSGGML4H.js} +5 -3
- package/dist/{update-studio-TWCYSYIS.js → update-studio-QSBDG7ZI.js} +2 -1
- package/package.json +1 -1
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
getStudioStandaloneDevCommand
|
|
11
11
|
} from "./chunk-EDXXR5BE.js";
|
|
12
12
|
import "./chunk-IIQLQIDP.js";
|
|
13
|
+
import {
|
|
14
|
+
getApiUrl
|
|
15
|
+
} from "./chunk-WJ5REY5E.js";
|
|
13
16
|
|
|
14
17
|
// src/commands/add-studio.ts
|
|
15
18
|
import { existsSync } from "fs";
|
|
@@ -32,13 +35,13 @@ async function addStudio() {
|
|
|
32
35
|
}
|
|
33
36
|
const envFile = existsSync(join(projectRoot, ".env.local")) ? join(projectRoot, ".env.local") : join(projectRoot, ".env");
|
|
34
37
|
config({ path: envFile });
|
|
35
|
-
const apiUrl = process.env.CMX_API_URL;
|
|
36
38
|
const apiKey = process.env.CMX_API_KEY;
|
|
37
|
-
if (!
|
|
38
|
-
console.error(" \u274C
|
|
39
|
+
if (!apiKey) {
|
|
40
|
+
console.error(" \u274C CMX_API_KEY \u304C\u5FC5\u8981\u3067\u3059");
|
|
39
41
|
console.error(" .env.local \u306B\u8A8D\u8A3C\u60C5\u5831\u3092\u8A2D\u5B9A\u3057\u3066\u304B\u3089\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
40
42
|
process.exit(1);
|
|
41
43
|
}
|
|
44
|
+
const apiUrl = getApiUrl();
|
|
42
45
|
console.log(" \u23F3 Studio \u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u4E2D...");
|
|
43
46
|
try {
|
|
44
47
|
await downloadStudioFiles(studioDir, { apiUrl, apiKey });
|
|
@@ -1,108 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/commands/utils.ts
|
|
4
|
-
import { readFileSync } from "fs";
|
|
5
|
-
function stringifyErrorValue(value) {
|
|
6
|
-
if (typeof value === "string") return value;
|
|
7
|
-
if (value === null || value === void 0) return "";
|
|
8
|
-
if (typeof value === "object") {
|
|
9
|
-
const objectValue = value;
|
|
10
|
-
if (typeof objectValue.message === "string" && objectValue.message.length > 0) {
|
|
11
|
-
return objectValue.message;
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
return JSON.stringify(value);
|
|
15
|
-
} catch {
|
|
16
|
-
return String(value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return String(value);
|
|
20
|
-
}
|
|
21
|
-
function formatApiErrorPayload(payload) {
|
|
22
|
-
if (typeof payload === "string") {
|
|
23
|
-
return formatApiErrorMessage(payload);
|
|
24
|
-
}
|
|
25
|
-
const parsed = payload ?? {};
|
|
26
|
-
const main = stringifyErrorValue(parsed.error ?? parsed.message);
|
|
27
|
-
const details = stringifyErrorValue(parsed.details);
|
|
28
|
-
const code = typeof parsed.code === "string" ? parsed.code : void 0;
|
|
29
|
-
const message = [main, details].filter((part, index, parts) => part.length > 0 && parts.indexOf(part) === index).join(" | ");
|
|
30
|
-
if (code && message) return `${code}: ${message}`;
|
|
31
|
-
if (code) return code;
|
|
32
|
-
if (message) return message;
|
|
33
|
-
return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
34
|
-
}
|
|
35
|
-
function formatApiErrorMessage(errorBody) {
|
|
36
|
-
if (!errorBody) return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
37
|
-
try {
|
|
38
|
-
return formatApiErrorPayload(JSON.parse(errorBody));
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
return errorBody;
|
|
42
|
-
}
|
|
43
|
-
var sdkFetchInterceptorInstalled = false;
|
|
44
|
-
function installSdkFetchInterceptor() {
|
|
45
|
-
if (sdkFetchInterceptorInstalled) return;
|
|
46
|
-
if (typeof globalThis.fetch !== "function") return;
|
|
47
|
-
const originalFetch = globalThis.fetch.bind(globalThis);
|
|
48
|
-
globalThis.fetch = async (input, init) => {
|
|
49
|
-
if (typeof input === "string" || input instanceof URL) {
|
|
50
|
-
const rawUrl = input.toString();
|
|
51
|
-
if (rawUrl.startsWith("/api/v1/sdk")) {
|
|
52
|
-
const apiUrl = process.env.CMX_API_URL;
|
|
53
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
54
|
-
if (!apiUrl || !apiKey) {
|
|
55
|
-
throw new Error("\u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
56
|
-
}
|
|
57
|
-
const baseUrl = apiUrl.replace(/\/$/, "");
|
|
58
|
-
const absoluteUrl = `${baseUrl}${rawUrl}`;
|
|
59
|
-
const headers = new Headers(init?.headers);
|
|
60
|
-
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
61
|
-
return originalFetch(absoluteUrl, {
|
|
62
|
-
...init,
|
|
63
|
-
headers
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return originalFetch(input, init);
|
|
68
|
-
};
|
|
69
|
-
sdkFetchInterceptorInstalled = true;
|
|
70
|
-
}
|
|
71
|
-
function assertSdkSuccess(response) {
|
|
72
|
-
if (response.status >= 200 && response.status < 300) {
|
|
73
|
-
return response.data;
|
|
74
|
-
}
|
|
75
|
-
throw new Error(`API \u30A8\u30E9\u30FC (${response.status}): ${formatApiErrorPayload(response.data)}`);
|
|
76
|
-
}
|
|
77
|
-
function readJsonInput(options) {
|
|
78
|
-
if (options.json) {
|
|
79
|
-
try {
|
|
80
|
-
return JSON.parse(options.json);
|
|
81
|
-
} catch {
|
|
82
|
-
console.error("\u30A8\u30E9\u30FC: --json \u306E JSON \u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059");
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (options.file) {
|
|
87
|
-
try {
|
|
88
|
-
const content = readFileSync(options.file, "utf-8");
|
|
89
|
-
return JSON.parse(content);
|
|
90
|
-
} catch (err) {
|
|
91
|
-
console.error(`\u30A8\u30E9\u30FC: JSON \u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${options.file}`);
|
|
92
|
-
console.error(err instanceof Error ? err.message : err);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
console.error("\u30A8\u30E9\u30FC: --json \u307E\u305F\u306F --file \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
function ensureApiCredentials() {
|
|
100
|
-
if (!process.env.CMX_API_URL || !process.env.CMX_API_KEY) {
|
|
101
|
-
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
3
|
// src/core/date-reviver.ts
|
|
107
4
|
var isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;
|
|
108
5
|
function dateReviver(_key, value) {
|
|
@@ -798,11 +695,6 @@ var postManageBugReports = async (sdkCreateBugReportBody, options) => {
|
|
|
798
695
|
};
|
|
799
696
|
|
|
800
697
|
export {
|
|
801
|
-
formatApiErrorMessage,
|
|
802
|
-
installSdkFetchInterceptor,
|
|
803
|
-
assertSdkSuccess,
|
|
804
|
-
readJsonInput,
|
|
805
|
-
ensureApiCredentials,
|
|
806
698
|
getManageCollections,
|
|
807
699
|
postManageCollections,
|
|
808
700
|
getManageCollectionsSlug,
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/utils.ts
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
|
+
var DEFAULT_API_URL = "https://app.cmx-ai.org";
|
|
6
|
+
function getApiUrl() {
|
|
7
|
+
return (process.env.CMX_API_URL || DEFAULT_API_URL).replace(/\/$/, "");
|
|
8
|
+
}
|
|
9
|
+
function getApiCredentials() {
|
|
10
|
+
const apiKey = process.env.CMX_API_KEY;
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
return { apiUrl: getApiUrl(), apiKey };
|
|
16
|
+
}
|
|
17
|
+
function stringifyErrorValue(value) {
|
|
18
|
+
if (typeof value === "string") return value;
|
|
19
|
+
if (value === null || value === void 0) return "";
|
|
20
|
+
if (typeof value === "object") {
|
|
21
|
+
const objectValue = value;
|
|
22
|
+
if (typeof objectValue.message === "string" && objectValue.message.length > 0) {
|
|
23
|
+
return objectValue.message;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return JSON.stringify(value);
|
|
27
|
+
} catch {
|
|
28
|
+
return String(value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return String(value);
|
|
32
|
+
}
|
|
33
|
+
function formatApiErrorPayload(payload) {
|
|
34
|
+
if (typeof payload === "string") {
|
|
35
|
+
return formatApiErrorMessage(payload);
|
|
36
|
+
}
|
|
37
|
+
const parsed = payload ?? {};
|
|
38
|
+
const main = stringifyErrorValue(parsed.error ?? parsed.message);
|
|
39
|
+
const details = stringifyErrorValue(parsed.details);
|
|
40
|
+
const code = typeof parsed.code === "string" ? parsed.code : void 0;
|
|
41
|
+
const message = [main, details].filter((part, index, parts) => part.length > 0 && parts.indexOf(part) === index).join(" | ");
|
|
42
|
+
if (code && message) return `${code}: ${message}`;
|
|
43
|
+
if (code) return code;
|
|
44
|
+
if (message) return message;
|
|
45
|
+
return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
46
|
+
}
|
|
47
|
+
function formatApiErrorMessage(errorBody) {
|
|
48
|
+
if (!errorBody) return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
49
|
+
try {
|
|
50
|
+
return formatApiErrorPayload(JSON.parse(errorBody));
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
return errorBody;
|
|
54
|
+
}
|
|
55
|
+
var sdkFetchInterceptorInstalled = false;
|
|
56
|
+
function installSdkFetchInterceptor() {
|
|
57
|
+
if (sdkFetchInterceptorInstalled) return;
|
|
58
|
+
if (typeof globalThis.fetch !== "function") return;
|
|
59
|
+
const originalFetch = globalThis.fetch.bind(globalThis);
|
|
60
|
+
globalThis.fetch = async (input, init) => {
|
|
61
|
+
if (typeof input === "string" || input instanceof URL) {
|
|
62
|
+
const rawUrl = input.toString();
|
|
63
|
+
if (rawUrl.startsWith("/api/v1/sdk")) {
|
|
64
|
+
const apiKey = process.env.CMX_API_KEY;
|
|
65
|
+
if (!apiKey) {
|
|
66
|
+
throw new Error("\u74B0\u5883\u5909\u6570 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
67
|
+
}
|
|
68
|
+
const absoluteUrl = `${getApiUrl()}${rawUrl}`;
|
|
69
|
+
const headers = new Headers(init?.headers);
|
|
70
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
71
|
+
return originalFetch(absoluteUrl, {
|
|
72
|
+
...init,
|
|
73
|
+
headers
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return originalFetch(input, init);
|
|
78
|
+
};
|
|
79
|
+
sdkFetchInterceptorInstalled = true;
|
|
80
|
+
}
|
|
81
|
+
function assertSdkSuccess(response) {
|
|
82
|
+
if (response.status >= 200 && response.status < 300) {
|
|
83
|
+
return response.data;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`API \u30A8\u30E9\u30FC (${response.status}): ${formatApiErrorPayload(response.data)}`);
|
|
86
|
+
}
|
|
87
|
+
function readJsonInput(options) {
|
|
88
|
+
if (options.json) {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(options.json);
|
|
91
|
+
} catch {
|
|
92
|
+
console.error("\u30A8\u30E9\u30FC: --json \u306E JSON \u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (options.file) {
|
|
97
|
+
try {
|
|
98
|
+
const content = readFileSync(options.file, "utf-8");
|
|
99
|
+
return JSON.parse(content);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.error(`\u30A8\u30E9\u30FC: JSON \u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${options.file}`);
|
|
102
|
+
console.error(err instanceof Error ? err.message : err);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
console.error("\u30A8\u30E9\u30FC: --json \u307E\u305F\u306F --file \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
function ensureApiCredentials() {
|
|
110
|
+
if (!process.env.CMX_API_KEY) {
|
|
111
|
+
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
getApiUrl,
|
|
118
|
+
getApiCredentials,
|
|
119
|
+
formatApiErrorMessage,
|
|
120
|
+
installSdkFetchInterceptor,
|
|
121
|
+
assertSdkSuccess,
|
|
122
|
+
readJsonInput,
|
|
123
|
+
ensureApiCredentials
|
|
124
|
+
};
|
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
getInstallCommand,
|
|
10
10
|
getStudioStandaloneDevCommand
|
|
11
11
|
} from "./chunk-EDXXR5BE.js";
|
|
12
|
+
import {
|
|
13
|
+
getApiUrl
|
|
14
|
+
} from "./chunk-WJ5REY5E.js";
|
|
12
15
|
|
|
13
16
|
// src/commands/update-studio.ts
|
|
14
17
|
import { confirm } from "@inquirer/prompts";
|
|
@@ -56,13 +59,13 @@ async function updateStudio(options = {}) {
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
config({ path: join(projectRoot, ".env") });
|
|
59
|
-
const apiUrl = process.env.CMX_API_URL;
|
|
60
62
|
const apiKey = process.env.CMX_API_KEY;
|
|
61
|
-
if (!
|
|
62
|
-
console.error(" \u274C
|
|
63
|
+
if (!apiKey) {
|
|
64
|
+
console.error(" \u274C CMX_API_KEY \u304C\u5FC5\u8981\u3067\u3059");
|
|
63
65
|
console.error(" .env \u306B\u8A8D\u8A3C\u60C5\u5831\u3092\u8A2D\u5B9A\u3057\u3066\u304B\u3089\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
64
66
|
process.exit(1);
|
|
65
67
|
}
|
|
68
|
+
const apiUrl = getApiUrl();
|
|
66
69
|
const timestamp = formatBackupTimestamp();
|
|
67
70
|
const cmxDir = join(projectRoot, ".cmx");
|
|
68
71
|
const backupDir = join(cmxDir, `studio.backup-${timestamp}`);
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-7TDMLYBI.js";
|
|
5
5
|
import {
|
|
6
6
|
updateStudio
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YYDYSBN7.js";
|
|
8
8
|
import {
|
|
9
9
|
updateSdk
|
|
10
10
|
} from "./chunk-Y3S3K6M3.js";
|
|
@@ -12,15 +12,12 @@ import "./chunk-NZQ6SBFS.js";
|
|
|
12
12
|
import "./chunk-EDXXR5BE.js";
|
|
13
13
|
import "./chunk-IIQLQIDP.js";
|
|
14
14
|
import {
|
|
15
|
-
assertSdkSuccess,
|
|
16
15
|
deleteManageCollectionsSlug,
|
|
17
16
|
deleteManageCollectionsSlugDataTypesDtSlug,
|
|
18
17
|
deleteManageContentsId,
|
|
19
18
|
deleteManageDataTypeSlugId,
|
|
20
19
|
deleteManageDataTypesSlug,
|
|
21
20
|
deleteManageFormDefinitionsSlug,
|
|
22
|
-
ensureApiCredentials,
|
|
23
|
-
formatApiErrorMessage,
|
|
24
21
|
getManageCollectionPresets,
|
|
25
22
|
getManageCollections,
|
|
26
23
|
getManageCollectionsSlug,
|
|
@@ -35,7 +32,6 @@ import {
|
|
|
35
32
|
getManageDataTypeSlugIdDeletionImpact,
|
|
36
33
|
getManageDataTypes,
|
|
37
34
|
getManageFormDefinitions,
|
|
38
|
-
installSdkFetchInterceptor,
|
|
39
35
|
patchManageDataTypeSlugId,
|
|
40
36
|
postManageCollections,
|
|
41
37
|
postManageCollectionsSlugDataTypes,
|
|
@@ -52,9 +48,16 @@ import {
|
|
|
52
48
|
putManageContentsIdReferences,
|
|
53
49
|
putManageDataTypesSlug,
|
|
54
50
|
putManageDocsType,
|
|
55
|
-
putManageFormDefinitionsSlug
|
|
51
|
+
putManageFormDefinitionsSlug
|
|
52
|
+
} from "./chunk-2WLUAJR2.js";
|
|
53
|
+
import {
|
|
54
|
+
assertSdkSuccess,
|
|
55
|
+
ensureApiCredentials,
|
|
56
|
+
formatApiErrorMessage,
|
|
57
|
+
getApiCredentials,
|
|
58
|
+
installSdkFetchInterceptor,
|
|
56
59
|
readJsonInput
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-WJ5REY5E.js";
|
|
58
61
|
|
|
59
62
|
// src/cli.ts
|
|
60
63
|
import { Command } from "commander";
|
|
@@ -3940,8 +3943,7 @@ async function uploadAsset(options) {
|
|
|
3940
3943
|
console.error("\u30A8\u30E9\u30FC: --file \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
3941
3944
|
process.exit(1);
|
|
3942
3945
|
}
|
|
3943
|
-
const apiUrl =
|
|
3944
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
3946
|
+
const { apiUrl, apiKey } = getApiCredentials();
|
|
3945
3947
|
try {
|
|
3946
3948
|
const fileBuffer = await readFile(options.file);
|
|
3947
3949
|
const mimeType = resolveMimeType(options.file, options.mime);
|
|
@@ -4000,8 +4002,7 @@ function parseJsonSafely2(raw) {
|
|
|
4000
4002
|
}
|
|
4001
4003
|
async function listAssets(options) {
|
|
4002
4004
|
ensureApiCredentials();
|
|
4003
|
-
const apiUrl =
|
|
4004
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
4005
|
+
const { apiUrl, apiKey } = getApiCredentials();
|
|
4005
4006
|
try {
|
|
4006
4007
|
const limit = parseIntegerOption("limit", options.limit);
|
|
4007
4008
|
const offset = parseIntegerOption("offset", options.offset);
|
|
@@ -4087,8 +4088,7 @@ async function updateAsset(options) {
|
|
|
4087
4088
|
console.error("\u30A8\u30E9\u30FC: \u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u5C11\u306A\u304F\u3068\u30821\u3064\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4088
4089
|
process.exit(1);
|
|
4089
4090
|
}
|
|
4090
|
-
const apiUrl =
|
|
4091
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
4091
|
+
const { apiUrl, apiKey } = getApiCredentials();
|
|
4092
4092
|
try {
|
|
4093
4093
|
console.log(`\u30A2\u30BB\u30C3\u30C8\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4094
4094
|
const response = await fetch(`${apiUrl}/api/mcp/assets`, {
|
|
@@ -4141,8 +4141,7 @@ async function deleteAsset(options) {
|
|
|
4141
4141
|
process.exit(0);
|
|
4142
4142
|
}
|
|
4143
4143
|
}
|
|
4144
|
-
const apiUrl =
|
|
4145
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
4144
|
+
const { apiUrl, apiKey } = getApiCredentials();
|
|
4146
4145
|
try {
|
|
4147
4146
|
console.log(`\u30A2\u30BB\u30C3\u30C8\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4148
4147
|
const response = await fetch(`${apiUrl}/api/mcp/assets`, {
|
|
@@ -4173,17 +4172,9 @@ config();
|
|
|
4173
4172
|
installSdkFetchInterceptor();
|
|
4174
4173
|
var program = new Command();
|
|
4175
4174
|
program.name("cmx-sdk").description("CMX \u30B9\u30AD\u30FC\u30DE\u3068\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u64CD\u4F5C\u3059\u308B CLI \u30C4\u30FC\u30EB").version("0.2.11").allowExcessArguments(false);
|
|
4176
|
-
|
|
4177
|
-
const apiUrl = process.env.CMX_API_URL;
|
|
4178
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
4179
|
-
if (!apiUrl || !apiKey) {
|
|
4180
|
-
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4181
|
-
process.exit(1);
|
|
4182
|
-
}
|
|
4183
|
-
return { apiUrl, apiKey };
|
|
4184
|
-
}
|
|
4175
|
+
var requireApiCredentials = getApiCredentials;
|
|
4185
4176
|
program.action(async () => {
|
|
4186
|
-
const { interactiveMenu } = await import("./interactive-menu-
|
|
4177
|
+
const { interactiveMenu } = await import("./interactive-menu-R3TJZOMK.js");
|
|
4187
4178
|
await interactiveMenu();
|
|
4188
4179
|
});
|
|
4189
4180
|
program.command("init [project-name]").description("\u65B0\u3057\u3044 CMX \u30B5\u30A4\u30C8\u3092\u4F5C\u6210").option("--no-studio", "CMX Studio \u3092\u30B9\u30AD\u30C3\u30D7").option("--pm <manager>", "\u30D1\u30C3\u30B1\u30FC\u30B8\u30DE\u30CD\u30FC\u30B8\u30E3\u30FC (npm, pnpm, yarn)").option("--key <key>", "CMX API \u30AD\u30FC\uFF08\u5FC5\u9808\u3002\u672A\u6307\u5B9A\u6642\u306F\u30D7\u30ED\u30F3\u30D7\u30C8\u8868\u793A\uFF09").option("--api-url <url>", "CMX API \u30B5\u30FC\u30D0\u30FC\u306E URL").option("--project-name <name>", "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u7528\u53EF\u80FD\uFF09").action(async (projectName, options) => {
|
|
@@ -4192,7 +4183,7 @@ program.command("init [project-name]").description("\u65B0\u3057\u3044 CMX \u30B
|
|
|
4192
4183
|
await init(finalProjectName, options);
|
|
4193
4184
|
});
|
|
4194
4185
|
program.command("add-studio").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B CMX Studio \u3092\u8FFD\u52A0").action(async () => {
|
|
4195
|
-
const { addStudio } = await import("./add-studio-
|
|
4186
|
+
const { addStudio } = await import("./add-studio-2COHXK65.js");
|
|
4196
4187
|
await addStudio();
|
|
4197
4188
|
});
|
|
4198
4189
|
program.command("update-studio").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E CMX Studio \u3092\u6700\u65B0\u5316").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action((options) => updateStudio(options));
|
|
@@ -4316,7 +4307,7 @@ program.command("archive-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u
|
|
|
4316
4307
|
program.command("validate-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u306E MDX \u53C2\u7167\u6574\u5408\u6027\u3092\u691C\u8A3C\uFF08\u554F\u984C\u3042\u308A\u6642\u306F exit code 1\uFF09").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(validateContent);
|
|
4317
4308
|
program.command("get-data-entry-deletion-impact").description("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u524A\u9664\u6642\u306E\u5F71\u97FF\u3092\u78BA\u8A8D").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--id <id>", "\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC ID").action(getDataEntryDeletionImpact);
|
|
4318
4309
|
program.command("report-bug").description("CMX \u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u306E\u30D0\u30B0\u3092\u5831\u544A").requiredOption("--title <title>", "\u30D0\u30B0\u306E\u6982\u8981\u30BF\u30A4\u30C8\u30EB").requiredOption("--description <description>", "\u30D0\u30B0\u306E\u8A73\u7D30\u8AAC\u660E").option("--severity <severity>", "\u91CD\u8981\u5EA6 (low, medium, high, critical)", "medium").option("--steps <steps>", "\u518D\u73FE\u624B\u9806").option("--error <message>", "\u30A8\u30E9\u30FC\u30E1\u30C3\u30BB\u30FC\u30B8").option("--command <command>", "\u5B9F\u884C\u3057\u305F CLI \u30B3\u30DE\u30F3\u30C9").action(async (options) => {
|
|
4319
|
-
const { reportBug } = await import("./report-bug-
|
|
4310
|
+
const { reportBug } = await import("./report-bug-WSGGML4H.js");
|
|
4320
4311
|
await reportBug(options);
|
|
4321
4312
|
});
|
|
4322
4313
|
program.parse();
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,16 @@ declare function sdkCustomInstance<T>(url: string, options?: RequestInit): Promi
|
|
|
69
69
|
* Next.js ISR/on-demand revalidation対応
|
|
70
70
|
*/
|
|
71
71
|
declare function sdkFetchWithTags<T>(path: string, tags?: string[], revalidate?: number | false): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* MCP APIのベースURL取得
|
|
74
|
+
*/
|
|
75
|
+
declare function getMcpApiBaseUrl(): string;
|
|
76
|
+
/**
|
|
77
|
+
* キャッシュタグ付きのMCP APIリクエスト用ラッパー
|
|
78
|
+
* Next.js ISR/on-demand revalidation対応
|
|
79
|
+
* アセット取得など、MCP APIエンドポイントへのアクセスに使用
|
|
80
|
+
*/
|
|
81
|
+
declare function mcpFetchWithTags<T>(path: string, tags?: string[], revalidate?: number | false): Promise<T>;
|
|
72
82
|
/**
|
|
73
83
|
* SDK API用のPOSTリクエストfetcher
|
|
74
84
|
* サーバーサイド(Server Action等)から使用
|
|
@@ -90,6 +100,10 @@ declare const CACHE_TAGS: {
|
|
|
90
100
|
readonly data: "data";
|
|
91
101
|
/** 特定データタイプ */
|
|
92
102
|
readonly dataType: (slug: string) => string;
|
|
103
|
+
/** 全アセット共通 */
|
|
104
|
+
readonly assets: "assets";
|
|
105
|
+
/** 特定グループのアセット */
|
|
106
|
+
readonly assetGroup: (group: string) => string;
|
|
93
107
|
};
|
|
94
108
|
|
|
95
109
|
/**
|
|
@@ -3413,6 +3427,60 @@ declare function fetchRuntimeSettings(): Promise<SdkRuntimeSettingsResponse>;
|
|
|
3413
3427
|
* Get daily analytics metrics collected by CMX.
|
|
3414
3428
|
*/
|
|
3415
3429
|
declare function fetchAnalyticsDailyMetrics(params?: GetAnalyticsDailyParams): Promise<SdkAnalyticsDailyListResponse>;
|
|
3430
|
+
/**
|
|
3431
|
+
* Asset item returned from the assets search API
|
|
3432
|
+
*/
|
|
3433
|
+
interface AssetItem {
|
|
3434
|
+
id: string;
|
|
3435
|
+
url: string;
|
|
3436
|
+
alt: string | null;
|
|
3437
|
+
description: string | null;
|
|
3438
|
+
aiSummary: string | null;
|
|
3439
|
+
width: number | null;
|
|
3440
|
+
height: number | null;
|
|
3441
|
+
mime: string;
|
|
3442
|
+
size: number;
|
|
3443
|
+
variants: Record<string, string>;
|
|
3444
|
+
groupId: string | null;
|
|
3445
|
+
createdAt: string;
|
|
3446
|
+
tags: Array<{
|
|
3447
|
+
name: string;
|
|
3448
|
+
}>;
|
|
3449
|
+
group: {
|
|
3450
|
+
slug: string;
|
|
3451
|
+
name: string;
|
|
3452
|
+
} | null;
|
|
3453
|
+
}
|
|
3454
|
+
/**
|
|
3455
|
+
* Response from the assets search API
|
|
3456
|
+
*/
|
|
3457
|
+
interface AssetsResponse {
|
|
3458
|
+
assets: AssetItem[];
|
|
3459
|
+
pagination: {
|
|
3460
|
+
total: number;
|
|
3461
|
+
limit: number;
|
|
3462
|
+
offset: number;
|
|
3463
|
+
};
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Options for fetching assets
|
|
3467
|
+
*/
|
|
3468
|
+
interface AssetsOptions extends FetchOptions {
|
|
3469
|
+
group?: string;
|
|
3470
|
+
tags?: string;
|
|
3471
|
+
query?: string;
|
|
3472
|
+
mime?: string;
|
|
3473
|
+
limit?: number;
|
|
3474
|
+
offset?: number;
|
|
3475
|
+
}
|
|
3476
|
+
/**
|
|
3477
|
+
* Get assets from the MCP assets search API
|
|
3478
|
+
*/
|
|
3479
|
+
declare function getAssets(options?: AssetsOptions): Promise<AssetsResponse>;
|
|
3480
|
+
/**
|
|
3481
|
+
* Get assets filtered by group slug
|
|
3482
|
+
*/
|
|
3483
|
+
declare function getAssetsByGroup(group: string, options?: Omit<AssetsOptions, "group">): Promise<AssetsResponse>;
|
|
3416
3484
|
|
|
3417
3485
|
interface CalloutProps {
|
|
3418
3486
|
type?: "info" | "warning" | "error" | "success" | "tip";
|
|
@@ -4052,4 +4120,4 @@ declare function renderMdx(mdx: string, references?: References, options?: Rende
|
|
|
4052
4120
|
*/
|
|
4053
4121
|
declare function renderMdxPreview(mdx: string, additionalComponents?: Record<string, React.ComponentType<any>>): Promise<React.ReactElement>;
|
|
4054
4122
|
|
|
4055
|
-
export { type ApiResponse, type AssetReference, type AssetReferenceVariants, BlogCard, Button, CACHE_TAGS, Callout, CmxApiError, type CollectionConfig, type CollectionConfigDefaults, type CollectionContentDetailResponse, type CollectionContentsOptions, type CollectionContentsResponse, type CollectionListResponse, type CollectionResponse, CollectionType, type ComponentDefinition, type ComponentName, type ContentReference, ContentStatus, type CreateCollectionRequest, type CreateContentRequest, type CreateDataTypeRequest, type CreateFormDefinitionRequest, type CreateSocialPostRequest, CreateSocialPostRequestStatus, type CreateSocialPostRequestTargetsItem, type CreateSocialPostRequestTargetsItemPlatformMeta, type DataEntriesOptions, type DataEntryDetailResponse, type DataEntryItem, type DataListResponse, type DataTypeConfig, type DataTypeResponse, type DeleteManageContentsIdParams, type DeleteManageDataTypeSlugIdParams, Embed, type ErrorResponse, type ErrorResponseDetails, type FetchOptions, type FieldDefinition, type FieldOptions, type FieldOptionsChoicesItem, FieldType, type FormDefinitionResponse, type FormDefinitionResponseConfigJson, type GetAnalyticsDailyParams, type GetCollectionsSlugContentsParams, GetCollectionsSlugContentsSortBy, GetCollectionsSlugContentsSortOrder, type GetDataTypeSlugParams, GetDataTypeSlugSortBy, GetDataTypeSlugSortOrder, type GetManageCollectionPresets200, type GetManageCollectionPresetsParams, GetManageCollectionPresetsType, type GetManageContentsIdParams, type GetManageContentsParams, type GetManageDataTypeSlugIdParams, type GetManageDataTypeSlugParams, GetManageDataTypeSlugSortBy, GetManageDataTypeSlugSortOrder, GetManageDataTypeSlugStatus, type GetManageSocialPostsParams, GetManageSocialPostsStatus, type GetPreviewToken200, type GetPreviewToken200Collection, type GetPreviewToken200Content, type GetPreviewToken200References, type GetPreviewToken200ReferencesAssets, type GetPreviewToken200ReferencesAssetsVariants, type GetPreviewToken200ReferencesContents, Image, type PreviewResponse, type PublicCollectionInfo, type PublicContentDetail, type PublicContentListItem, type PublicContentParent, type PublicFetcherOptions, type PublicSubmissionRequest, type PublicSubmissionRequestData, type PublicSubmissionResponse, type ReferenceField, ReferenceFieldReferenceType, type References, type ReferencesAssets, type ReferencesContents, type RenderOptions, type RenderResult, type ResolvedReferences, type RevalidationConfig, type SchemaCollection, type SchemaDataType, type SchemaFieldDefinition, type SchemaFieldOption, type SchemaFieldOptionChoicesItem, type SchemaFormDefinition, type SchemaResponse, type SdkAddCollectionDataTypeRequest, SdkAddCollectionDataTypeRequestReferenceType, type SdkAnalyticsDailyListResponse, type SdkAnalyticsDailyMetric, type SdkAnalyticsDailyMetricRawJson, type SdkBugReportResponse, SdkBugSeverity, type SdkCollectionDataTypeResponse, type SdkComponentDefinition, type SdkComponentDefinitionPropsSchema, type SdkComponentProp, type SdkComponentSuccessResponse, type SdkComponentSyncRequest, type SdkContentDetail, type SdkContentDetailFrontmatterJson, type SdkContentDetailSeoJson, type SdkContentDetailSeoJsonStructuredData, type SdkContentItem, type SdkContentListResponse, type SdkContentReferencesResponse, type SdkContentReferencesResponseReferencesItem, type SdkContentReferencesResponseReferencesItemDataEntriesItem, type SdkContentReferencesResponseReferencesItemDataEntriesItemData, type SdkCreateBugReportBody, type SdkCreateBugReportBodyEnvironmentInfo, type SdkCreateContentResponse, type SdkCreateContentResponseWarningsItem, SdkCreateContentResponseWarningsItemIssueType, SdkCreateContentResponseWarningsItemTargetType, type SdkCreateEntryRequest, type SdkCreateEntryRequestDataJson, SdkCreateEntryRequestStatus, type SdkCustomComponentResponse, type SdkCustomComponentResponsePropsSchema, SdkCustomComponentResponseStatus, type SdkCustomComponentsListResponse, type SdkDataEntriesListResponse, type SdkDataEntryDeletionImpactItem, type SdkDataEntryDeletionImpactResponse, type SdkDataEntryDetailResponse, type SdkDataEntryResponse, type SdkDataEntryResponseDataJson, SdkDataEntryResponseStatus, type SdkDataTypeInfo, type SdkDeleteCollectionDataTypeResponse, type SdkDeleteCollectionResponse, type SdkDeleteContentResponse, type SdkDeleteDataEntryResponse, type SdkDeleteDataTypeResponse, type SdkDeleteFormDefinitionResponse, type SdkDeleteSocialPostResponse, type SdkDocResponse, SdkDocType, type SdkLinkExistingDataTypeRequest, SdkLinkExistingDataTypeRequestReferenceType, type SdkPreset, SdkPresetReferenceType, type SdkPublishContentResponse, type SdkRequestReviewResponse, type SdkRuntimeSettingsResponse, type SdkRuntimeSettingsResponseSettings, type SdkRuntimeSettingsResponseSettingsAnalytics, SdkRuntimeSettingsResponseSettingsAnalyticsProvider, type SdkRuntimeSettingsResponseSettingsAnalyticsTracking, type SdkRuntimeSettingsResponseSettingsRevalidation, type SdkSetContentReferencesRequest, type SdkSetContentReferencesRequestReferencesItem, type SdkSetContentReferencesResponse, type SdkUpdateContentResponse, type SdkUpdateContentResponseWarningsItem, SdkUpdateContentResponseWarningsItemIssueType, SdkUpdateContentResponseWarningsItemTargetType, type SdkUpdateEntryRequest, type SdkUpdateEntryRequestDataJson, SdkUpdateEntryRequestStatus, type SdkUpsertDocBody, type SdkValidateContentResponse, type SdkValidateContentResponseIssuesItem, SdkValidateContentResponseIssuesItemIssueType, SdkValidateContentResponseIssuesItemTargetType, type SocialAccountListResponse, type SocialAccountResponse, SocialAccountResponsePlatform, SocialAccountResponseStatus, type SocialPostListItem, SocialPostListItemStatus, type SocialPostListItemTargetSummary, SocialPostListItemTargetSummaryPlatformsItem, type SocialPostListItemTargetSummaryStatusCounts, type SocialPostListResponse, type SocialPostResponse, SocialPostResponseStatus, type SocialPostResponseTargetSummary, SocialPostResponseTargetSummaryPlatformsItem, type SocialPostResponseTargetSummaryStatusCounts, type SocialPostResponseTargetsItem, SocialPostResponseTargetsItemPlatform, type SocialPostResponseTargetsItemPlatformMeta, SocialPostResponseTargetsItemStatus, type UpdateCollectionRequest, type UpdateContentRequest, type UpdateDataTypeRequest, type UpdateFormDefinitionRequest, type UpdateFormDefinitionRequestConfigJson, type UpdateSocialPostRequest, UpdateSocialPostRequestStatus, type ValidationError, type ValidationResult, basicComponents, componentCatalog, componentSchemas, customComponents, fetchAnalyticsDailyMetrics, fetchRuntimeSettings, getAnalyticsDaily, getCatalogForAI, getCollectionContentDetail, getCollectionContentDetailOrThrow, getCollectionContents, getCollectionContentsOrThrow, getCollections, getCollectionsSlugContents, getCollectionsSlugContentsContentSlug, getComponentsByCategory, getComponentsWithReferences, getDataEntries, getDataEntriesOrThrow, getDataEntry, getDataEntryOrThrow, getDataTypeSlug, getGetAnalyticsDailyUrl, getGetCollectionsSlugContentsContentSlugUrl, getGetCollectionsSlugContentsUrl, getGetDataTypeSlugUrl, getGetPreviewTokenUrl, getGetRuntimeSettingsUrl, getPreviewByToken, getPreviewToken, getRuntimeSettings, getSchema, getSdkApiBaseUrl, getSdkApiToken, isValidComponent, markdownComponents, mdxComponents, quickValidateMdx, renderMdx, renderMdxPreview, sdkCustomInstance, sdkFetchWithTags, sdkFetcher, sdkPostFetcher, submitFormData, validateComponentProps, validateMdx };
|
|
4123
|
+
export { type ApiResponse, type AssetItem, type AssetReference, type AssetReferenceVariants, type AssetsOptions, type AssetsResponse, BlogCard, Button, CACHE_TAGS, Callout, CmxApiError, type CollectionConfig, type CollectionConfigDefaults, type CollectionContentDetailResponse, type CollectionContentsOptions, type CollectionContentsResponse, type CollectionListResponse, type CollectionResponse, CollectionType, type ComponentDefinition, type ComponentName, type ContentReference, ContentStatus, type CreateCollectionRequest, type CreateContentRequest, type CreateDataTypeRequest, type CreateFormDefinitionRequest, type CreateSocialPostRequest, CreateSocialPostRequestStatus, type CreateSocialPostRequestTargetsItem, type CreateSocialPostRequestTargetsItemPlatformMeta, type DataEntriesOptions, type DataEntryDetailResponse, type DataEntryItem, type DataListResponse, type DataTypeConfig, type DataTypeResponse, type DeleteManageContentsIdParams, type DeleteManageDataTypeSlugIdParams, Embed, type ErrorResponse, type ErrorResponseDetails, type FetchOptions, type FieldDefinition, type FieldOptions, type FieldOptionsChoicesItem, FieldType, type FormDefinitionResponse, type FormDefinitionResponseConfigJson, type GetAnalyticsDailyParams, type GetCollectionsSlugContentsParams, GetCollectionsSlugContentsSortBy, GetCollectionsSlugContentsSortOrder, type GetDataTypeSlugParams, GetDataTypeSlugSortBy, GetDataTypeSlugSortOrder, type GetManageCollectionPresets200, type GetManageCollectionPresetsParams, GetManageCollectionPresetsType, type GetManageContentsIdParams, type GetManageContentsParams, type GetManageDataTypeSlugIdParams, type GetManageDataTypeSlugParams, GetManageDataTypeSlugSortBy, GetManageDataTypeSlugSortOrder, GetManageDataTypeSlugStatus, type GetManageSocialPostsParams, GetManageSocialPostsStatus, type GetPreviewToken200, type GetPreviewToken200Collection, type GetPreviewToken200Content, type GetPreviewToken200References, type GetPreviewToken200ReferencesAssets, type GetPreviewToken200ReferencesAssetsVariants, type GetPreviewToken200ReferencesContents, Image, type PreviewResponse, type PublicCollectionInfo, type PublicContentDetail, type PublicContentListItem, type PublicContentParent, type PublicFetcherOptions, type PublicSubmissionRequest, type PublicSubmissionRequestData, type PublicSubmissionResponse, type ReferenceField, ReferenceFieldReferenceType, type References, type ReferencesAssets, type ReferencesContents, type RenderOptions, type RenderResult, type ResolvedReferences, type RevalidationConfig, type SchemaCollection, type SchemaDataType, type SchemaFieldDefinition, type SchemaFieldOption, type SchemaFieldOptionChoicesItem, type SchemaFormDefinition, type SchemaResponse, type SdkAddCollectionDataTypeRequest, SdkAddCollectionDataTypeRequestReferenceType, type SdkAnalyticsDailyListResponse, type SdkAnalyticsDailyMetric, type SdkAnalyticsDailyMetricRawJson, type SdkBugReportResponse, SdkBugSeverity, type SdkCollectionDataTypeResponse, type SdkComponentDefinition, type SdkComponentDefinitionPropsSchema, type SdkComponentProp, type SdkComponentSuccessResponse, type SdkComponentSyncRequest, type SdkContentDetail, type SdkContentDetailFrontmatterJson, type SdkContentDetailSeoJson, type SdkContentDetailSeoJsonStructuredData, type SdkContentItem, type SdkContentListResponse, type SdkContentReferencesResponse, type SdkContentReferencesResponseReferencesItem, type SdkContentReferencesResponseReferencesItemDataEntriesItem, type SdkContentReferencesResponseReferencesItemDataEntriesItemData, type SdkCreateBugReportBody, type SdkCreateBugReportBodyEnvironmentInfo, type SdkCreateContentResponse, type SdkCreateContentResponseWarningsItem, SdkCreateContentResponseWarningsItemIssueType, SdkCreateContentResponseWarningsItemTargetType, type SdkCreateEntryRequest, type SdkCreateEntryRequestDataJson, SdkCreateEntryRequestStatus, type SdkCustomComponentResponse, type SdkCustomComponentResponsePropsSchema, SdkCustomComponentResponseStatus, type SdkCustomComponentsListResponse, type SdkDataEntriesListResponse, type SdkDataEntryDeletionImpactItem, type SdkDataEntryDeletionImpactResponse, type SdkDataEntryDetailResponse, type SdkDataEntryResponse, type SdkDataEntryResponseDataJson, SdkDataEntryResponseStatus, type SdkDataTypeInfo, type SdkDeleteCollectionDataTypeResponse, type SdkDeleteCollectionResponse, type SdkDeleteContentResponse, type SdkDeleteDataEntryResponse, type SdkDeleteDataTypeResponse, type SdkDeleteFormDefinitionResponse, type SdkDeleteSocialPostResponse, type SdkDocResponse, SdkDocType, type SdkLinkExistingDataTypeRequest, SdkLinkExistingDataTypeRequestReferenceType, type SdkPreset, SdkPresetReferenceType, type SdkPublishContentResponse, type SdkRequestReviewResponse, type SdkRuntimeSettingsResponse, type SdkRuntimeSettingsResponseSettings, type SdkRuntimeSettingsResponseSettingsAnalytics, SdkRuntimeSettingsResponseSettingsAnalyticsProvider, type SdkRuntimeSettingsResponseSettingsAnalyticsTracking, type SdkRuntimeSettingsResponseSettingsRevalidation, type SdkSetContentReferencesRequest, type SdkSetContentReferencesRequestReferencesItem, type SdkSetContentReferencesResponse, type SdkUpdateContentResponse, type SdkUpdateContentResponseWarningsItem, SdkUpdateContentResponseWarningsItemIssueType, SdkUpdateContentResponseWarningsItemTargetType, type SdkUpdateEntryRequest, type SdkUpdateEntryRequestDataJson, SdkUpdateEntryRequestStatus, type SdkUpsertDocBody, type SdkValidateContentResponse, type SdkValidateContentResponseIssuesItem, SdkValidateContentResponseIssuesItemIssueType, SdkValidateContentResponseIssuesItemTargetType, type SocialAccountListResponse, type SocialAccountResponse, SocialAccountResponsePlatform, SocialAccountResponseStatus, type SocialPostListItem, SocialPostListItemStatus, type SocialPostListItemTargetSummary, SocialPostListItemTargetSummaryPlatformsItem, type SocialPostListItemTargetSummaryStatusCounts, type SocialPostListResponse, type SocialPostResponse, SocialPostResponseStatus, type SocialPostResponseTargetSummary, SocialPostResponseTargetSummaryPlatformsItem, type SocialPostResponseTargetSummaryStatusCounts, type SocialPostResponseTargetsItem, SocialPostResponseTargetsItemPlatform, type SocialPostResponseTargetsItemPlatformMeta, SocialPostResponseTargetsItemStatus, type UpdateCollectionRequest, type UpdateContentRequest, type UpdateDataTypeRequest, type UpdateFormDefinitionRequest, type UpdateFormDefinitionRequestConfigJson, type UpdateSocialPostRequest, UpdateSocialPostRequestStatus, type ValidationError, type ValidationResult, basicComponents, componentCatalog, componentSchemas, customComponents, fetchAnalyticsDailyMetrics, fetchRuntimeSettings, getAnalyticsDaily, getAssets, getAssetsByGroup, getCatalogForAI, getCollectionContentDetail, getCollectionContentDetailOrThrow, getCollectionContents, getCollectionContentsOrThrow, getCollections, getCollectionsSlugContents, getCollectionsSlugContentsContentSlug, getComponentsByCategory, getComponentsWithReferences, getDataEntries, getDataEntriesOrThrow, getDataEntry, getDataEntryOrThrow, getDataTypeSlug, getGetAnalyticsDailyUrl, getGetCollectionsSlugContentsContentSlugUrl, getGetCollectionsSlugContentsUrl, getGetDataTypeSlugUrl, getGetPreviewTokenUrl, getGetRuntimeSettingsUrl, getMcpApiBaseUrl, getPreviewByToken, getPreviewToken, getRuntimeSettings, getSchema, getSdkApiBaseUrl, getSdkApiToken, isValidComponent, markdownComponents, mcpFetchWithTags, mdxComponents, quickValidateMdx, renderMdx, renderMdxPreview, sdkCustomInstance, sdkFetchWithTags, sdkFetcher, sdkPostFetcher, submitFormData, validateComponentProps, validateMdx };
|
package/dist/index.js
CHANGED
|
@@ -132,6 +132,31 @@ async function sdkFetchWithTags(path, tags, revalidate) {
|
|
|
132
132
|
}
|
|
133
133
|
return response.json();
|
|
134
134
|
}
|
|
135
|
+
function getMcpApiBaseUrl() {
|
|
136
|
+
const apiUrl = process.env.CMX_API_URL || DEFAULT_API_URL;
|
|
137
|
+
return `${apiUrl}/api/mcp`;
|
|
138
|
+
}
|
|
139
|
+
async function mcpFetchWithTags(path, tags, revalidate) {
|
|
140
|
+
const token = getSdkApiToken();
|
|
141
|
+
const baseUrl = getMcpApiBaseUrl();
|
|
142
|
+
const url = `${baseUrl}${path}`;
|
|
143
|
+
const fetchOptions = {
|
|
144
|
+
method: "GET",
|
|
145
|
+
headers: {
|
|
146
|
+
"Content-Type": "application/json",
|
|
147
|
+
Authorization: `Bearer ${token}`
|
|
148
|
+
},
|
|
149
|
+
next: {
|
|
150
|
+
tags: tags || [],
|
|
151
|
+
...revalidate !== void 0 && { revalidate }
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const response = await fetch(url, fetchOptions);
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
throw await toCmxApiError(response);
|
|
157
|
+
}
|
|
158
|
+
return response.json();
|
|
159
|
+
}
|
|
135
160
|
async function sdkPostFetcher(path, body) {
|
|
136
161
|
const token = getSdkApiToken();
|
|
137
162
|
const baseUrl = getSdkApiBaseUrl();
|
|
@@ -162,7 +187,11 @@ var CACHE_TAGS = {
|
|
|
162
187
|
/** 全データタイプ共通 */
|
|
163
188
|
data: "data",
|
|
164
189
|
/** 特定データタイプ */
|
|
165
|
-
dataType: (slug) => `data:${slug}
|
|
190
|
+
dataType: (slug) => `data:${slug}`,
|
|
191
|
+
/** 全アセット共通 */
|
|
192
|
+
assets: "assets",
|
|
193
|
+
/** 特定グループのアセット */
|
|
194
|
+
assetGroup: (group) => `assets:${group}`
|
|
166
195
|
};
|
|
167
196
|
|
|
168
197
|
// src/core/date-reviver.ts
|
|
@@ -404,6 +433,25 @@ async function fetchAnalyticsDailyMetrics(params) {
|
|
|
404
433
|
}
|
|
405
434
|
return response.data;
|
|
406
435
|
}
|
|
436
|
+
async function getAssets(options) {
|
|
437
|
+
const params = new URLSearchParams();
|
|
438
|
+
if (options?.group) params.set("group", options.group);
|
|
439
|
+
if (options?.tags) params.set("tags", options.tags);
|
|
440
|
+
if (options?.query) params.set("q", options.query);
|
|
441
|
+
if (options?.mime) params.set("mime", options.mime);
|
|
442
|
+
if (options?.limit !== void 0) params.set("limit", String(options.limit));
|
|
443
|
+
if (options?.offset !== void 0) params.set("offset", String(options.offset));
|
|
444
|
+
const query = params.toString();
|
|
445
|
+
const tags = options?.group ? [CACHE_TAGS.assets, CACHE_TAGS.assetGroup(options.group)] : [CACHE_TAGS.assets];
|
|
446
|
+
return mcpFetchWithTags(
|
|
447
|
+
`/assets/search${query ? `?${query}` : ""}`,
|
|
448
|
+
tags,
|
|
449
|
+
options?.revalidate
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
async function getAssetsByGroup(group, options) {
|
|
453
|
+
return getAssets({ ...options, group });
|
|
454
|
+
}
|
|
407
455
|
|
|
408
456
|
// src/mdx/components/basic/Callout.tsx
|
|
409
457
|
import { AlertCircle, AlertTriangle, CheckCircle, Info, Lightbulb } from "lucide-react";
|
|
@@ -2211,6 +2259,8 @@ export {
|
|
|
2211
2259
|
fetchAnalyticsDailyMetrics,
|
|
2212
2260
|
fetchRuntimeSettings,
|
|
2213
2261
|
getAnalyticsDaily,
|
|
2262
|
+
getAssets,
|
|
2263
|
+
getAssetsByGroup,
|
|
2214
2264
|
getCatalogForAI,
|
|
2215
2265
|
getCollectionContentDetail,
|
|
2216
2266
|
getCollectionContentDetailOrThrow,
|
|
@@ -2232,6 +2282,7 @@ export {
|
|
|
2232
2282
|
getGetDataTypeSlugUrl,
|
|
2233
2283
|
getGetPreviewTokenUrl,
|
|
2234
2284
|
getGetRuntimeSettingsUrl,
|
|
2285
|
+
getMcpApiBaseUrl,
|
|
2235
2286
|
getPreviewByToken,
|
|
2236
2287
|
getPreviewToken,
|
|
2237
2288
|
getRuntimeSettings,
|
|
@@ -2240,6 +2291,7 @@ export {
|
|
|
2240
2291
|
getSdkApiToken,
|
|
2241
2292
|
isValidComponent,
|
|
2242
2293
|
markdownComponents,
|
|
2294
|
+
mcpFetchWithTags,
|
|
2243
2295
|
mdxComponents,
|
|
2244
2296
|
quickValidateMdx,
|
|
2245
2297
|
renderMdx,
|