@exabugs/dynamodb-client 1.4.17 → 1.5.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/CHANGELOG.md +11 -0
- package/dist/client/FindCursor.d.ts +29 -0
- package/dist/client/FindCursor.d.ts.map +1 -1
- package/dist/client/FindCursor.js +48 -0
- package/dist/client/FindCursor.js.map +1 -1
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.d.ts +4 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.d.ts.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.js +49 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyField.js.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.d.ts +4 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.d.ts.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.js +34 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/ReferenceManyToManyInput.js.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/index.d.ts +4 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/index.d.ts.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/index.js +3 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/index.js.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/types.d.ts +53 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/types.d.ts.map +1 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/types.js +33 -0
- package/dist/integrations/react-admin/components/ReferenceManyToMany/types.js.map +1 -0
- package/dist/integrations/react-admin/components/index.d.ts +1 -2
- package/dist/integrations/react-admin/components/index.d.ts.map +1 -1
- package/dist/integrations/react-admin/components/index.js +1 -2
- package/dist/integrations/react-admin/components/index.js.map +1 -1
- package/dist/integrations/react-admin/dataProvider.js +6 -6
- package/dist/scripts/operations/bulkRecordRepair.js +1 -2
- package/dist/scripts/operations/bulkRecordRepair.js.map +1 -1
- package/dist/server/handler.cjs +3 -3
- package/dist/server/handler.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.d.ts +0 -13
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.d.ts.map +0 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.js +0 -171
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.js.map +0 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyInput.d.ts +0 -41
- package/dist/integrations/react-admin/components/ReferenceManyToManyInput.d.ts.map +0 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyInput.js +0 -119
- package/dist/integrations/react-admin/components/ReferenceManyToManyInput.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exabugs/dynamodb-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "DynamoDB Single-Table Client SDK with MongoDB-like API, Shadow Records, and Lambda implementation for serverless applications",
|
|
5
5
|
"author": "exabugs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
|
-
import type { ReferenceManyToManyFieldProps } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* ReferenceManyToManyField コンポーネント
|
|
5
|
-
*
|
|
6
|
-
* 多対多関係を表示するためのフィールドコンポーネント。
|
|
7
|
-
* 中間テーブルを経由して関連レコードを取得し、子コンポーネントに渡します。
|
|
8
|
-
*
|
|
9
|
-
* 各ターゲットレコードには `_through` フィールドが追加され、
|
|
10
|
-
* 中間テーブルのデータにアクセスできます。
|
|
11
|
-
*/
|
|
12
|
-
export declare const ReferenceManyToManyField: (props: ReferenceManyToManyFieldProps) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=ReferenceManyToManyField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceManyToManyField.d.ts","sourceRoot":"","sources":["../../../../src/integrations/react-admin/components/ReferenceManyToManyField.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAmBjE;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,6BAA6B,KAAG,YA2K/E,CAAC"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* ReferenceManyToManyField - 多対多関係表示コンポーネント
|
|
4
|
-
*
|
|
5
|
-
* 中間テーブルを経由して関連レコードを取得し、表示します。
|
|
6
|
-
* React-Admin Enterprise Editionを使用せずに多対多関係をサポートします。
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* <ReferenceManyToManyField
|
|
11
|
-
* reference="users"
|
|
12
|
-
* through="venueManagers"
|
|
13
|
-
* using="venueId,userId"
|
|
14
|
-
* label="管理者"
|
|
15
|
-
* >
|
|
16
|
-
* <Datagrid>
|
|
17
|
-
* <TextField source="nickname" />
|
|
18
|
-
* <StatusField source="_through.status" label="管理者ステータス" />
|
|
19
|
-
* </Datagrid>
|
|
20
|
-
* </ReferenceManyToManyField>
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
24
|
-
import { ListContextProvider, useDataProvider, useRecordContext } from 'react-admin';
|
|
25
|
-
/**
|
|
26
|
-
* ReferenceManyToManyField コンポーネント
|
|
27
|
-
*
|
|
28
|
-
* 多対多関係を表示するためのフィールドコンポーネント。
|
|
29
|
-
* 中間テーブルを経由して関連レコードを取得し、子コンポーネントに渡します。
|
|
30
|
-
*
|
|
31
|
-
* 各ターゲットレコードには `_through` フィールドが追加され、
|
|
32
|
-
* 中間テーブルのデータにアクセスできます。
|
|
33
|
-
*/
|
|
34
|
-
export const ReferenceManyToManyField = (props) => {
|
|
35
|
-
const { reference, through, using, source = 'id', children, sort = { field: 'id', order: 'ASC' }, } = props;
|
|
36
|
-
const record = useRecordContext();
|
|
37
|
-
const dataProvider = useDataProvider();
|
|
38
|
-
const [data, setData] = useState([]);
|
|
39
|
-
const [total, setTotal] = useState(0);
|
|
40
|
-
const [loading, setLoading] = useState(true);
|
|
41
|
-
const [error, setError] = useState(null);
|
|
42
|
-
// recordIdを安定した値として取得(recordオブジェクトの参照が変わってもIDが同じなら再フェッチしない)
|
|
43
|
-
const recordId = useMemo(() => record?.[source], [record, source]);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
// レコードIDが存在しない場合は何もしない
|
|
46
|
-
if (!recordId) {
|
|
47
|
-
setLoading(false);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const controller = new AbortController();
|
|
51
|
-
const fetchData = async () => {
|
|
52
|
-
try {
|
|
53
|
-
setLoading(true);
|
|
54
|
-
setError(null);
|
|
55
|
-
// usingプロパティをパース(例: "venueId,userId" → ["venueId", "userId"])
|
|
56
|
-
const keys = using.split(',').map((k) => k.trim());
|
|
57
|
-
if (keys.length !== 2) {
|
|
58
|
-
throw new Error(`Invalid using format: "${using}". Expected "sourceKey,targetKey"`);
|
|
59
|
-
}
|
|
60
|
-
const [sourceKey, targetKey] = keys;
|
|
61
|
-
if (!sourceKey || !targetKey) {
|
|
62
|
-
throw new Error(`Invalid using format: "${using}". Expected "sourceKey,targetKey"`);
|
|
63
|
-
}
|
|
64
|
-
// 起点レコードのIDを取得
|
|
65
|
-
const sourceId = recordId;
|
|
66
|
-
if (!sourceId) {
|
|
67
|
-
throw new Error(`Source field "${source}" not found in record`);
|
|
68
|
-
}
|
|
69
|
-
// 1. 中間テーブルから関連IDを取得
|
|
70
|
-
const { data: junctionRecords } = await dataProvider.getList(through, {
|
|
71
|
-
filter: { [sourceKey]: sourceId },
|
|
72
|
-
pagination: { page: 1, perPage: 1000 },
|
|
73
|
-
sort,
|
|
74
|
-
});
|
|
75
|
-
// 中間レコードが存在しない場合は空配列を返す
|
|
76
|
-
if (!junctionRecords || junctionRecords.length === 0) {
|
|
77
|
-
setData([]);
|
|
78
|
-
setTotal(0);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// 2. ターゲットIDを抽出し、中間レコードとのマッピングを作成
|
|
82
|
-
const targetIds = junctionRecords
|
|
83
|
-
.map((r) => r[targetKey])
|
|
84
|
-
.filter(Boolean);
|
|
85
|
-
// 中間レコードをターゲットIDでマッピング
|
|
86
|
-
const junctionMap = new Map();
|
|
87
|
-
junctionRecords.forEach((junction) => {
|
|
88
|
-
const targetId = junction[targetKey];
|
|
89
|
-
if (targetId) {
|
|
90
|
-
junctionMap.set(String(targetId), junction);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
if (targetIds.length === 0) {
|
|
94
|
-
setData([]);
|
|
95
|
-
setTotal(0);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// 3. ターゲットレコードを取得
|
|
99
|
-
const { data: targetRecords } = await dataProvider.getMany(reference, {
|
|
100
|
-
ids: targetIds,
|
|
101
|
-
});
|
|
102
|
-
// 4. ターゲットレコードに中間テーブルのデータを追加
|
|
103
|
-
const enrichedRecords = targetRecords.map((targetRecord) => {
|
|
104
|
-
const junction = junctionMap.get(String(targetRecord.id));
|
|
105
|
-
return {
|
|
106
|
-
...targetRecord,
|
|
107
|
-
_through: junction || null, // 中間テーブルのデータを _through フィールドに追加
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
setData(enrichedRecords);
|
|
111
|
-
setTotal(enrichedRecords.length);
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
// リクエストがキャンセルされた場合はエラーを無視
|
|
115
|
-
if (controller.signal.aborted) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
setError(err);
|
|
119
|
-
setData([]);
|
|
120
|
-
setTotal(0);
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
setLoading(false);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
fetchData();
|
|
127
|
-
// クリーンアップ: コンポーネントがアンマウントされたらリクエストをキャンセル
|
|
128
|
-
return () => {
|
|
129
|
-
controller.abort();
|
|
130
|
-
};
|
|
131
|
-
}, [recordId, reference, through, using]);
|
|
132
|
-
// ローディング中
|
|
133
|
-
if (loading) {
|
|
134
|
-
return _jsx("div", { children: "\u8AAD\u307F\u8FBC\u307F\u4E2D..." });
|
|
135
|
-
}
|
|
136
|
-
// エラー発生時
|
|
137
|
-
if (error) {
|
|
138
|
-
return _jsxs("div", { children: ["\u30A8\u30E9\u30FC: ", error.message] });
|
|
139
|
-
}
|
|
140
|
-
// 子コンポーネントにデータを渡す
|
|
141
|
-
// ListContextProviderでラップして、Datagridなどのリストコンポーネントが動作するようにする
|
|
142
|
-
return (_jsx(ListContextProvider, { value: {
|
|
143
|
-
data,
|
|
144
|
-
total,
|
|
145
|
-
isLoading: false,
|
|
146
|
-
isFetching: false,
|
|
147
|
-
isPending: false,
|
|
148
|
-
error: null,
|
|
149
|
-
resource: reference,
|
|
150
|
-
sort,
|
|
151
|
-
page: 1,
|
|
152
|
-
perPage: data.length,
|
|
153
|
-
setSort: () => { },
|
|
154
|
-
setPage: () => { },
|
|
155
|
-
setPerPage: () => { },
|
|
156
|
-
setFilters: () => { },
|
|
157
|
-
displayedFilters: {},
|
|
158
|
-
filterValues: {},
|
|
159
|
-
showFilter: () => { },
|
|
160
|
-
hideFilter: () => { },
|
|
161
|
-
refetch: () => { },
|
|
162
|
-
hasNextPage: false,
|
|
163
|
-
hasPreviousPage: false,
|
|
164
|
-
selectedIds: [],
|
|
165
|
-
onSelect: () => { },
|
|
166
|
-
onSelectAll: () => { },
|
|
167
|
-
onToggleItem: () => { },
|
|
168
|
-
onUnselectItems: () => { },
|
|
169
|
-
}, children: children }));
|
|
170
|
-
};
|
|
171
|
-
//# sourceMappingURL=ReferenceManyToManyField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceManyToManyField.js","sourceRoot":"","sources":["../../../../src/integrations/react-admin/components/ReferenceManyToManyField.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAqBrF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAoC,EAAgB,EAAE;IAC7F,MAAM,EACJ,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,GAAG,IAAI,EACb,QAAQ,EACR,IAAI,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GACrC,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAmB,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,4DAA4D;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAA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B,IAAI;YACJ,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;YACpB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;YACpB,gBAAgB,EAAE,EAAE;YACpB,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;YACpB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;YACpB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,KAAK;YACtB,WAAW,EAAE,EAAE;YACf,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;YAClB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;YACrB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;YACtB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;SAC1B,YAEA,QAAQ,GACW,CACvB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ReferenceManyToManyInput - 多対多関係編集コンポーネント
|
|
3
|
-
*
|
|
4
|
-
* 中間テーブルを経由して関連レコードを編集します。
|
|
5
|
-
* React-Admin Enterprise Editionを使用せずに多対多関係をサポートします。
|
|
6
|
-
*
|
|
7
|
-
* **重要**: このコンポーネントはフォーム保存時に自動的に中間テーブルを更新します。
|
|
8
|
-
* DataProviderが自動的に処理するため、transform関数を書く必要はありません。
|
|
9
|
-
*
|
|
10
|
-
* NOTE: react-adminの型定義による any の使用
|
|
11
|
-
*
|
|
12
|
-
* このファイルでは、react-adminのDataProviderとコンポーネントの型定義の制約により、
|
|
13
|
-
* 一部で any 型を使用しています。これはreact-adminの設計上の制約です。
|
|
14
|
-
*
|
|
15
|
-
* 実行時の型安全性は以下により確保されています:
|
|
16
|
-
* 1. DataProviderのgetListメソッドは中間テーブルのレコードを返す
|
|
17
|
-
* 2. cloneElementのpropsはreact-adminの標準プロパティ
|
|
18
|
-
* 3. 実際のデータ型は実行時に検証される
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* <ReferenceManyToManyInput
|
|
23
|
-
* reference="users"
|
|
24
|
-
* through="venueManagers"
|
|
25
|
-
* using="venueId,userId"
|
|
26
|
-
* label="管理者"
|
|
27
|
-
* >
|
|
28
|
-
* <AutocompleteArrayInput optionText="nickname" />
|
|
29
|
-
* </ReferenceManyToManyInput>
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
import type { ReactElement } from 'react';
|
|
33
|
-
import type { ReferenceManyToManyInputProps } from '../types.js';
|
|
34
|
-
/**
|
|
35
|
-
* ReferenceManyToManyInput コンポーネント
|
|
36
|
-
*
|
|
37
|
-
* 多対多関係を編集するための入力コンポーネント。
|
|
38
|
-
* DataProviderが保存時に自動的に中間テーブルを更新します。
|
|
39
|
-
*/
|
|
40
|
-
export declare const ReferenceManyToManyInput: (props: ReferenceManyToManyInputProps) => ReactElement;
|
|
41
|
-
//# sourceMappingURL=ReferenceManyToManyInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceManyToManyInput.d.ts","sourceRoot":"","sources":["../../../../src/integrations/react-admin/components/ReferenceManyToManyInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,6BAA6B,KAAG,YA+F/E,CAAC"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* ReferenceManyToManyInput - 多対多関係編集コンポーネント
|
|
4
|
-
*
|
|
5
|
-
* 中間テーブルを経由して関連レコードを編集します。
|
|
6
|
-
* React-Admin Enterprise Editionを使用せずに多対多関係をサポートします。
|
|
7
|
-
*
|
|
8
|
-
* **重要**: このコンポーネントはフォーム保存時に自動的に中間テーブルを更新します。
|
|
9
|
-
* DataProviderが自動的に処理するため、transform関数を書く必要はありません。
|
|
10
|
-
*
|
|
11
|
-
* NOTE: react-adminの型定義による any の使用
|
|
12
|
-
*
|
|
13
|
-
* このファイルでは、react-adminのDataProviderとコンポーネントの型定義の制約により、
|
|
14
|
-
* 一部で any 型を使用しています。これはreact-adminの設計上の制約です。
|
|
15
|
-
*
|
|
16
|
-
* 実行時の型安全性は以下により確保されています:
|
|
17
|
-
* 1. DataProviderのgetListメソッドは中間テーブルのレコードを返す
|
|
18
|
-
* 2. cloneElementのpropsはreact-adminの標準プロパティ
|
|
19
|
-
* 3. 実際のデータ型は実行時に検証される
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* <ReferenceManyToManyInput
|
|
24
|
-
* reference="users"
|
|
25
|
-
* through="venueManagers"
|
|
26
|
-
* using="venueId,userId"
|
|
27
|
-
* label="管理者"
|
|
28
|
-
* >
|
|
29
|
-
* <AutocompleteArrayInput optionText="nickname" />
|
|
30
|
-
* </ReferenceManyToManyInput>
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
34
|
-
import { cloneElement, useEffect, useMemo, useState } from 'react';
|
|
35
|
-
import { ReferenceArrayInput, useDataProvider, useNotify, useRecordContext } from 'react-admin';
|
|
36
|
-
/**
|
|
37
|
-
* ReferenceManyToManyInput コンポーネント
|
|
38
|
-
*
|
|
39
|
-
* 多対多関係を編集するための入力コンポーネント。
|
|
40
|
-
* DataProviderが保存時に自動的に中間テーブルを更新します。
|
|
41
|
-
*/
|
|
42
|
-
export const ReferenceManyToManyInput = (props) => {
|
|
43
|
-
const { reference, through, using, source = 'id', children, label, filter } = props;
|
|
44
|
-
// デバッグ: filterを確認
|
|
45
|
-
console.log('ReferenceManyToManyInput filter:', JSON.stringify(filter, null, 2));
|
|
46
|
-
const record = useRecordContext();
|
|
47
|
-
const dataProvider = useDataProvider();
|
|
48
|
-
const notify = useNotify();
|
|
49
|
-
const [initialIds, setInitialIds] = useState([]);
|
|
50
|
-
const [loading, setLoading] = useState(true);
|
|
51
|
-
const [error, setError] = useState(null);
|
|
52
|
-
// usingプロパティをパース
|
|
53
|
-
const keys = using.split(',').map((k) => k.trim());
|
|
54
|
-
if (keys.length !== 2) {
|
|
55
|
-
throw new Error(`Invalid using format: "${using}". Expected "sourceKey,targetKey"`);
|
|
56
|
-
}
|
|
57
|
-
const [sourceKey, targetKey] = keys;
|
|
58
|
-
// recordIdを安定した値として取得
|
|
59
|
-
const recordId = useMemo(() => record?.[source], [record, source]);
|
|
60
|
-
// フィールド名を特殊な形式にして、DataProviderで識別できるようにする
|
|
61
|
-
// フォーマット: __manyToMany_{through}_{sourceKey}_{targetKey}
|
|
62
|
-
const fieldName = `__manyToMany_${through}_${sourceKey}_${targetKey}`;
|
|
63
|
-
// 初期値を取得(マウント時またはrecordIdが変わった時のみ)
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!recordId) {
|
|
66
|
-
setLoading(false);
|
|
67
|
-
setInitialIds([]);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const controller = new AbortController();
|
|
71
|
-
const fetchCurrentRelations = async () => {
|
|
72
|
-
try {
|
|
73
|
-
setLoading(true);
|
|
74
|
-
setError(null);
|
|
75
|
-
const sourceId = recordId;
|
|
76
|
-
if (!sourceId) {
|
|
77
|
-
throw new Error(`Source field "${source}" not found in record`);
|
|
78
|
-
}
|
|
79
|
-
// 現在の関連を取得
|
|
80
|
-
const { data: junctionRecords } = await dataProvider.getList(through, {
|
|
81
|
-
filter: { [sourceKey]: sourceId },
|
|
82
|
-
pagination: { page: 1, perPage: 1000 },
|
|
83
|
-
sort: { field: 'id', order: 'ASC' },
|
|
84
|
-
});
|
|
85
|
-
const ids = junctionRecords.map((r) => r[targetKey]).filter(Boolean);
|
|
86
|
-
setInitialIds(ids);
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
if (controller.signal.aborted) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
setError(err);
|
|
93
|
-
notify(`関連の取得に失敗しました: ${err.message}`, { type: 'error' });
|
|
94
|
-
setInitialIds([]);
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
setLoading(false);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
fetchCurrentRelations();
|
|
101
|
-
return () => {
|
|
102
|
-
controller.abort();
|
|
103
|
-
};
|
|
104
|
-
}, [recordId, through, using]);
|
|
105
|
-
// ローディング中
|
|
106
|
-
if (loading) {
|
|
107
|
-
return _jsx("div", { children: "\u8AAD\u307F\u8FBC\u307F\u4E2D..." });
|
|
108
|
-
}
|
|
109
|
-
// エラー発生時
|
|
110
|
-
if (error) {
|
|
111
|
-
return _jsxs("div", { children: ["\u30A8\u30E9\u30FC: ", error.message] });
|
|
112
|
-
}
|
|
113
|
-
// フォーム状態として管理
|
|
114
|
-
// DataProviderのupdateメソッドが自動的に中間テーブルを更新します
|
|
115
|
-
return (_jsx(ReferenceArrayInput, { source: fieldName, reference: reference, label: label, filter: filter, children: cloneElement(children, {
|
|
116
|
-
defaultValue: initialIds,
|
|
117
|
-
}) }));
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=ReferenceManyToManyInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceManyToManyInput.js","sourceRoot":"","sources":["../../../../src/integrations/react-admin/components/ReferenceManyToManyInput.tsx"],"names":[],"mappings":";AAAA;;;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