cmx-sdk 0.1.4 → 0.1.5
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/lib/api-client.d.ts +2 -0
- package/dist/lib/api-client.js +15 -9
- package/package.json +1 -1
- package/src/lib/api-client.ts +16 -9
package/dist/lib/api-client.d.ts
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
interface ApiClientConfig {
|
|
6
6
|
apiUrl: string;
|
|
7
7
|
apiKey: string;
|
|
8
|
+
basePath?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare class AdminApiClient {
|
|
10
11
|
private apiUrl;
|
|
11
12
|
private apiKey;
|
|
13
|
+
private basePath;
|
|
12
14
|
constructor(config: ApiClientConfig);
|
|
13
15
|
private request;
|
|
14
16
|
listCollections(): Promise<any>;
|
package/dist/lib/api-client.js
CHANGED
|
@@ -5,12 +5,18 @@
|
|
|
5
5
|
export class AdminApiClient {
|
|
6
6
|
apiUrl;
|
|
7
7
|
apiKey;
|
|
8
|
+
basePath;
|
|
8
9
|
constructor(config) {
|
|
9
10
|
this.apiUrl = config.apiUrl.replace(/\/$/, "");
|
|
10
11
|
this.apiKey = config.apiKey;
|
|
12
|
+
this.basePath = config.basePath || "/api/v1/sdk/manage";
|
|
11
13
|
}
|
|
12
14
|
async request(method, path, body) {
|
|
13
|
-
|
|
15
|
+
// パスが / で始まる場合は basePath を使わない(絶対パス)
|
|
16
|
+
// それ以外の場合は basePath を結合する(相対パス)
|
|
17
|
+
const url = path.startsWith("/api/")
|
|
18
|
+
? `${this.apiUrl}${path}`
|
|
19
|
+
: `${this.apiUrl}${this.basePath}${path}`;
|
|
14
20
|
const headers = {
|
|
15
21
|
"Content-Type": "application/json",
|
|
16
22
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -28,31 +34,31 @@ export class AdminApiClient {
|
|
|
28
34
|
}
|
|
29
35
|
// Collections
|
|
30
36
|
async listCollections() {
|
|
31
|
-
return this.request("GET", "/
|
|
37
|
+
return this.request("GET", "/collections");
|
|
32
38
|
}
|
|
33
39
|
async createCollection(data) {
|
|
34
|
-
return this.request("POST", "/
|
|
40
|
+
return this.request("POST", "/collections", data);
|
|
35
41
|
}
|
|
36
42
|
// Data Types
|
|
37
43
|
async listDataTypes() {
|
|
38
|
-
return this.request("GET", "/
|
|
44
|
+
return this.request("GET", "/data-types");
|
|
39
45
|
}
|
|
40
46
|
async createDataType(data) {
|
|
41
|
-
return this.request("POST", "/
|
|
47
|
+
return this.request("POST", "/data-types", data);
|
|
42
48
|
}
|
|
43
49
|
// Form Definitions
|
|
44
50
|
async listFormDefinitions() {
|
|
45
|
-
return this.request("GET", "/
|
|
51
|
+
return this.request("GET", "/form-definitions");
|
|
46
52
|
}
|
|
47
53
|
async createFormDefinition(data) {
|
|
48
|
-
return this.request("POST", "/
|
|
54
|
+
return this.request("POST", "/form-definitions", data);
|
|
49
55
|
}
|
|
50
56
|
// Custom Components
|
|
51
57
|
async listCustomComponents() {
|
|
52
|
-
return this.request("GET", "/
|
|
58
|
+
return this.request("GET", "/components");
|
|
53
59
|
}
|
|
54
60
|
async syncComponents(data) {
|
|
55
|
-
return this.request("POST", "/
|
|
61
|
+
return this.request("POST", "/components/sync", data);
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
export function createApiClient() {
|
package/package.json
CHANGED
package/src/lib/api-client.ts
CHANGED
|
@@ -7,19 +7,26 @@
|
|
|
7
7
|
interface ApiClientConfig {
|
|
8
8
|
apiUrl: string
|
|
9
9
|
apiKey: string
|
|
10
|
+
basePath?: string // デフォルト: /api/v1/sdk/manage
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export class AdminApiClient {
|
|
13
14
|
private apiUrl: string
|
|
14
15
|
private apiKey: string
|
|
16
|
+
private basePath: string
|
|
15
17
|
|
|
16
18
|
constructor(config: ApiClientConfig) {
|
|
17
19
|
this.apiUrl = config.apiUrl.replace(/\/$/, "")
|
|
18
20
|
this.apiKey = config.apiKey
|
|
21
|
+
this.basePath = config.basePath || "/api/v1/sdk/manage"
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
private async request(method: string, path: string, body?: unknown) {
|
|
22
|
-
|
|
25
|
+
// パスが / で始まる場合は basePath を使わない(絶対パス)
|
|
26
|
+
// それ以外の場合は basePath を結合する(相対パス)
|
|
27
|
+
const url = path.startsWith("/api/")
|
|
28
|
+
? `${this.apiUrl}${path}`
|
|
29
|
+
: `${this.apiUrl}${this.basePath}${path}`
|
|
23
30
|
const headers: Record<string, string> = {
|
|
24
31
|
"Content-Type": "application/json",
|
|
25
32
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -43,7 +50,7 @@ export class AdminApiClient {
|
|
|
43
50
|
|
|
44
51
|
// Collections
|
|
45
52
|
async listCollections() {
|
|
46
|
-
return this.request("GET", "/
|
|
53
|
+
return this.request("GET", "/collections")
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
async createCollection(data: {
|
|
@@ -52,12 +59,12 @@ export class AdminApiClient {
|
|
|
52
59
|
name: string
|
|
53
60
|
description?: string
|
|
54
61
|
}) {
|
|
55
|
-
return this.request("POST", "/
|
|
62
|
+
return this.request("POST", "/collections", data)
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
// Data Types
|
|
59
66
|
async listDataTypes() {
|
|
60
|
-
return this.request("GET", "/
|
|
67
|
+
return this.request("GET", "/data-types")
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
async createDataType(data: {
|
|
@@ -73,12 +80,12 @@ export class AdminApiClient {
|
|
|
73
80
|
options?: Record<string, unknown>
|
|
74
81
|
}>
|
|
75
82
|
}) {
|
|
76
|
-
return this.request("POST", "/
|
|
83
|
+
return this.request("POST", "/data-types", data)
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
// Form Definitions
|
|
80
87
|
async listFormDefinitions() {
|
|
81
|
-
return this.request("GET", "/
|
|
88
|
+
return this.request("GET", "/form-definitions")
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
async createFormDefinition(data: {
|
|
@@ -94,12 +101,12 @@ export class AdminApiClient {
|
|
|
94
101
|
options?: Record<string, unknown>
|
|
95
102
|
}>
|
|
96
103
|
}) {
|
|
97
|
-
return this.request("POST", "/
|
|
104
|
+
return this.request("POST", "/form-definitions", data)
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
// Custom Components
|
|
101
108
|
async listCustomComponents() {
|
|
102
|
-
return this.request("GET", "/
|
|
109
|
+
return this.request("GET", "/components")
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
async syncComponents(data: {
|
|
@@ -111,7 +118,7 @@ export class AdminApiClient {
|
|
|
111
118
|
examples?: string[]
|
|
112
119
|
}>
|
|
113
120
|
}) {
|
|
114
|
-
return this.request("POST", "/
|
|
121
|
+
return this.request("POST", "/components/sync", data)
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
|