@nocobase/portal-template-default 1.0.0 → 1.0.1
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/README.MD +70 -0
- package/components.json +3 -1
- package/package.json +19 -5
- package/registry/nocobase-acl/README.md +19 -0
- package/registry/nocobase-acl/components/acl-boundary.tsx +106 -0
- package/registry/nocobase-acl/components/index.ts +3 -0
- package/registry/nocobase-acl/components/role-options.ts +29 -0
- package/registry/nocobase-acl/components/role-switcher.tsx +130 -0
- package/registry/nocobase-acl/demo/boundary-api.tsx +115 -0
- package/registry/nocobase-acl/demo/components.tsx +210 -0
- package/registry/nocobase-acl/demo/index.tsx +474 -0
- package/registry/nocobase-acl/demo/lazy-route.tsx +15 -0
- package/registry/nocobase-acl/demo/prompt-generator.tsx +115 -0
- package/registry/nocobase-acl/demo/role-switcher-prompt-generator.tsx +179 -0
- package/registry/nocobase-acl/demo/scenario-section.tsx +37 -0
- package/registry/nocobase-acl/extension.tsx +71 -0
- package/registry/nocobase-acl/index.ts +1 -0
- package/registry/nocobase-acl/tests/acl-regression.mjs +313 -0
- package/registry/nocobase-ai/README.md +70 -0
- package/registry/nocobase-ai/adapters/react-hook-form.ts +20 -0
- package/registry/nocobase-ai/assets/nocobase-ai-chat.svg +50 -0
- package/registry/nocobase-ai/components/ai-root-provider.tsx +32 -0
- package/registry/nocobase-ai/components/chat/ai-employee-avatar.tsx +31 -0
- package/registry/nocobase-ai/components/chat/chat-attachment.tsx +92 -0
- package/registry/nocobase-ai/components/chat/chat-compact.tsx +90 -0
- package/registry/nocobase-ai/components/chat/chat-composer.tsx +429 -0
- package/registry/nocobase-ai/components/chat/chat-empty-state.tsx +51 -0
- package/registry/nocobase-ai/components/chat/chat-header.tsx +88 -0
- package/registry/nocobase-ai/components/chat/chat-history-dialog.tsx +77 -0
- package/registry/nocobase-ai/components/chat/chat-message.tsx +252 -0
- package/registry/nocobase-ai/components/chat/chat-messages.tsx +174 -0
- package/registry/nocobase-ai/components/chat/chat-window.tsx +118 -0
- package/registry/nocobase-ai/components/chat/conversation-list.tsx +345 -0
- package/registry/nocobase-ai/components/chat/markdown-message.tsx +165 -0
- package/registry/nocobase-ai/components/chat/model-select-options.tsx +30 -0
- package/registry/nocobase-ai/components/chat/reasoning-panel.tsx +29 -0
- package/registry/nocobase-ai/components/chat/sub-agent-conversation.tsx +142 -0
- package/registry/nocobase-ai/components/chat/tool-call-card.tsx +316 -0
- package/registry/nocobase-ai/components/chat/user-prompt-editor.tsx +99 -0
- package/registry/nocobase-ai/components/chat/work-context-chip.tsx +114 -0
- package/registry/nocobase-ai/components/index.ts +59 -0
- package/registry/nocobase-ai/components/page-elements/ai-form.tsx +44 -0
- package/registry/nocobase-ai/components/page-elements/page-element-provider.tsx +469 -0
- package/registry/nocobase-ai/components/surfaces/chat-dialog.tsx +31 -0
- package/registry/nocobase-ai/components/surfaces/chat-inline.tsx +18 -0
- package/registry/nocobase-ai/components/surfaces/chat-page.tsx +18 -0
- package/registry/nocobase-ai/components/surfaces/chat-side-panel-layout.tsx +54 -0
- package/registry/nocobase-ai/components/surfaces/chat-side-panel.tsx +74 -0
- package/registry/nocobase-ai/components/surfaces/chat-surface-actions.tsx +54 -0
- package/registry/nocobase-ai/components/tools/builtin-tool-renderers.tsx +31 -0
- package/registry/nocobase-ai/components/tools/business-report-dialog.tsx +367 -0
- package/registry/nocobase-ai/components/tools/business-report-renderer.tsx +122 -0
- package/registry/nocobase-ai/components/tools/business-report-utils.tsx +282 -0
- package/registry/nocobase-ai/components/tools/chart-renderer.tsx +110 -0
- package/registry/nocobase-ai/components/tools/echarts-preview.tsx +62 -0
- package/registry/nocobase-ai/components/tools/echarts-runtime-advanced.ts +18 -0
- package/registry/nocobase-ai/components/tools/echarts-runtime-common.ts +20 -0
- package/registry/nocobase-ai/components/tools/echarts-runtime-components.ts +34 -0
- package/registry/nocobase-ai/components/tools/echarts-runtime-hierarchy.ts +24 -0
- package/registry/nocobase-ai/components/tools/echarts-runtime.ts +138 -0
- package/registry/nocobase-ai/components/tools/sub-agent-renderer.tsx +67 -0
- package/registry/nocobase-ai/components/tools/suggestions-renderer.tsx +59 -0
- package/registry/nocobase-ai/components/tools/tool-renderer-provider.tsx +55 -0
- package/registry/nocobase-ai/components/tools/tool-renderer-utils.ts +18 -0
- package/registry/nocobase-ai/components/tools/workflow-renderer.tsx +108 -0
- package/registry/nocobase-ai/components/triggers/ai-chat-floating-trigger.tsx +73 -0
- package/registry/nocobase-ai/components/triggers/ai-employee-shortcut.tsx +149 -0
- package/registry/nocobase-ai/demo/configuration-gate.tsx +52 -0
- package/registry/nocobase-ai/demo/container-showcase.tsx +210 -0
- package/registry/nocobase-ai/demo/floating.tsx +134 -0
- package/registry/nocobase-ai/demo/index.tsx +346 -0
- package/registry/nocobase-ai/demo/interaction-showcase.tsx +151 -0
- package/registry/nocobase-ai/demo/page-context-prompt-generator.tsx +355 -0
- package/registry/nocobase-ai/demo/page-context.tsx +884 -0
- package/registry/nocobase-ai/demo/page-element-showcase.tsx +197 -0
- package/registry/nocobase-ai/demo/prompt-card.tsx +41 -0
- package/registry/nocobase-ai/demo/prompt-generator.tsx +452 -0
- package/registry/nocobase-ai/demo/shortcut.tsx +1207 -0
- package/registry/nocobase-ai/demo/tool-cards.tsx +530 -0
- package/registry/nocobase-ai/extension.tsx +163 -0
- package/registry/nocobase-ai/global-ai-chat.tsx +213 -0
- package/registry/nocobase-ai/index.ts +3 -0
- package/registry/nocobase-ai/providers/ai-provider.tsx +323 -0
- package/registry/nocobase-ai/providers/avatars.ts +817 -0
- package/registry/nocobase-ai/providers/chat-context.tsx +109 -0
- package/registry/nocobase-ai/providers/chat-controller.ts +84 -0
- package/registry/nocobase-ai/providers/chat-message-utils.ts +198 -0
- package/registry/nocobase-ai/providers/chat-provider.tsx +871 -0
- package/registry/nocobase-ai/providers/chat-reducer.ts +147 -0
- package/registry/nocobase-ai/providers/chat-task-utils.ts +105 -0
- package/registry/nocobase-ai/providers/chat-transport.ts +184 -0
- package/registry/nocobase-ai/providers/form-registry.tsx +271 -0
- package/registry/nocobase-ai/providers/frontend-tool-registry.tsx +231 -0
- package/registry/nocobase-ai/providers/index.ts +61 -0
- package/registry/nocobase-ai/providers/model.ts +32 -0
- package/registry/nocobase-ai/providers/page-context.tsx +136 -0
- package/registry/nocobase-ai/providers/stream-coalescer.ts +60 -0
- package/registry/nocobase-ai/providers/stream-event-utils.ts +82 -0
- package/registry/nocobase-ai/providers/stream-parser.ts +61 -0
- package/registry/nocobase-ai/providers/sub-agent-stream.ts +316 -0
- package/registry/nocobase-ai/providers/types.ts +183 -0
- package/registry/nocobase-ai/providers/ui-message-stream.ts +463 -0
- package/registry/nocobase-ai/providers/use-automatic-tool-approval.ts +94 -0
- package/registry/nocobase-ai/providers/use-chat-attachments.ts +206 -0
- package/registry/nocobase-ai/providers/use-chat-message-actions.ts +554 -0
- package/registry/nocobase-ai/providers/use-chat-runtime.ts +210 -0
- package/registry/nocobase-ai/providers/use-chat-work-context.ts +93 -0
- package/registry/nocobase-ai/providers/use-conversation-catalog.ts +108 -0
- package/registry/nocobase-ai/providers/use-conversation-history.ts +178 -0
- package/registry/nocobase-ai/services/index.ts +7 -0
- package/registry/nocobase-ai/services/nocobase-ai-service.ts +454 -0
- package/registry/nocobase-ai/services/types.ts +82 -0
- package/registry/nocobase-ai/tests/business-report-regression.mjs +70 -0
- package/registry/nocobase-ai/tests/form-filler-regression.mjs +129 -0
- package/registry/nocobase-ai/tests/frontend-tool-regression.mjs +128 -0
- package/registry/nocobase-ai/tests/page-context-regression.mjs +48 -0
- package/registry/nocobase-ai/tests/stream-regression.mjs +207 -0
- package/registry.config.json +143 -0
- package/scripts/registry.mjs +161 -0
- package/src/App.css +95 -0
- package/src/App.tsx +127 -50
- package/src/app/extension.ts +9 -0
- package/src/app/extensions.tsx +28 -0
- package/src/components/access-control/access-denied.tsx +30 -0
- package/src/components/access-control/acl-bootstrap.tsx +9 -0
- package/src/components/access-control/acl-gate.tsx +42 -0
- package/src/components/access-control/navigate-to-accessible-resource.tsx +17 -0
- package/src/components/access-control/resource-access-guard.tsx +21 -0
- package/src/components/access-control/use-acl-runtime.ts +28 -0
- package/src/components/app-shell/header.tsx +4 -1
- package/src/components/app-shell/sidebar.tsx +34 -4
- package/src/lib/nocobase/acl/action.ts +147 -0
- package/src/lib/nocobase/acl/data-source.ts +24 -0
- package/src/lib/nocobase/acl/index.ts +6 -0
- package/src/lib/nocobase/acl/menu.ts +41 -0
- package/src/lib/nocobase/acl/record-permissions.ts +111 -0
- package/src/lib/nocobase/acl/store.ts +182 -0
- package/src/lib/nocobase/acl/types.ts +96 -0
- package/src/lib/nocobase/client.ts +262 -0
- package/src/lib/nocobase/error.ts +32 -0
- package/src/providers/access-control.ts +34 -0
- package/src/providers/auth.ts +74 -60
- package/src/providers/constants.ts +2 -37
- package/src/providers/data.ts +242 -85
- package/vite.config.ts +17 -0
package/src/providers/data.ts
CHANGED
|
@@ -22,7 +22,13 @@ import type {
|
|
|
22
22
|
UpdateResponse,
|
|
23
23
|
} from "@refinedev/core";
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { nocobaseClient } from "@/lib/nocobase/client";
|
|
26
|
+
import {
|
|
27
|
+
notifyRecordPermissionsChanged,
|
|
28
|
+
resolveAclDataSourceKey,
|
|
29
|
+
type ResourceAcl,
|
|
30
|
+
updateRecordPermissions,
|
|
31
|
+
} from "@/lib/nocobase/acl";
|
|
26
32
|
|
|
27
33
|
type NocoBaseListResponse<T> = {
|
|
28
34
|
rows?: T[];
|
|
@@ -30,23 +36,30 @@ type NocoBaseListResponse<T> = {
|
|
|
30
36
|
data?: T[] | NocoBaseListResponse<T>;
|
|
31
37
|
meta?: {
|
|
32
38
|
count?: number;
|
|
39
|
+
allowedActions?: Record<string, Array<string | number>>;
|
|
40
|
+
};
|
|
41
|
+
allowedActions?: Record<string, Array<string | number>>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type NocoBaseGetResponse<T> = {
|
|
45
|
+
data?: T;
|
|
46
|
+
meta?: {
|
|
47
|
+
allowedActions?: Record<string, Array<string | number>>;
|
|
33
48
|
};
|
|
34
49
|
};
|
|
35
50
|
|
|
36
51
|
type NocoBaseMeta = MetaQuery & {
|
|
37
52
|
appends?: string[];
|
|
38
53
|
token?: string;
|
|
54
|
+
dataSourceKey?: string;
|
|
55
|
+
idField?: string;
|
|
56
|
+
acl?: ResourceAcl;
|
|
39
57
|
};
|
|
40
58
|
|
|
41
59
|
type NocoBaseFilter = Record<string, unknown>;
|
|
42
60
|
|
|
43
|
-
const getToken = (meta?: NocoBaseMeta) =>
|
|
44
|
-
meta?.token ??
|
|
45
|
-
localStorage.getItem(NOCOBASE_TOKEN_KEY) ??
|
|
46
|
-
import.meta.env.NOCOBASE_API_TOKEN;
|
|
47
|
-
|
|
48
61
|
const toNocoBaseFilter = (
|
|
49
|
-
filters: GetListParams["filters"] = []
|
|
62
|
+
filters: GetListParams["filters"] = []
|
|
50
63
|
): NocoBaseFilter | undefined => {
|
|
51
64
|
const filterItems: NocoBaseFilter[] = filters.flatMap((filter) => {
|
|
52
65
|
if ("field" in filter) {
|
|
@@ -81,31 +94,6 @@ const toNocoBaseFilter = (
|
|
|
81
94
|
return filterItems.length === 1 ? filterItems[0] : { $and: filterItems };
|
|
82
95
|
};
|
|
83
96
|
|
|
84
|
-
const buildUrl = (
|
|
85
|
-
resource: string,
|
|
86
|
-
action: string,
|
|
87
|
-
query: Record<string, string | number | undefined> = {},
|
|
88
|
-
meta?: NocoBaseMeta,
|
|
89
|
-
) => {
|
|
90
|
-
const endpoint = `${API_URL.replace(/\/$/, "")}/${resource}:${action}`;
|
|
91
|
-
const url = endpoint.startsWith("http://") || endpoint.startsWith("https://")
|
|
92
|
-
? new URL(endpoint)
|
|
93
|
-
: new URL(endpoint, window.location.origin);
|
|
94
|
-
|
|
95
|
-
for (const [key, value] of Object.entries(query)) {
|
|
96
|
-
if (value !== undefined) url.searchParams.set(key, String(value));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
meta?.appends?.forEach((append) => url.searchParams.append("appends[]", append));
|
|
100
|
-
if (Array.isArray(meta?.fields)) {
|
|
101
|
-
meta.fields
|
|
102
|
-
.filter((field): field is string => typeof field === "string")
|
|
103
|
-
.forEach((field) => url.searchParams.append("fields[]", field));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return url;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
97
|
const request = async <T>(
|
|
110
98
|
resource: string,
|
|
111
99
|
action: string,
|
|
@@ -115,30 +103,70 @@ const request = async <T>(
|
|
|
115
103
|
body?: unknown;
|
|
116
104
|
meta?: NocoBaseMeta;
|
|
117
105
|
unwrapData?: boolean;
|
|
118
|
-
} = {}
|
|
106
|
+
} = {}
|
|
119
107
|
): Promise<T> => {
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
const dataSourceKey = resolveAclDataSourceKey(options.meta);
|
|
109
|
+
const fields = Array.isArray(options.meta?.fields)
|
|
110
|
+
? options.meta.fields.filter(
|
|
111
|
+
(field): field is string => typeof field === "string"
|
|
112
|
+
)
|
|
113
|
+
: undefined;
|
|
114
|
+
return nocobaseClient.action<T>(resource, action, {
|
|
115
|
+
method: options.method,
|
|
116
|
+
query: {
|
|
117
|
+
...options.query,
|
|
118
|
+
...(options.meta?.appends?.length
|
|
119
|
+
? { "appends[]": options.meta.appends }
|
|
120
|
+
: {}),
|
|
121
|
+
...(fields?.length ? { "fields[]": fields } : {}),
|
|
122
|
+
},
|
|
123
|
+
body: options.body,
|
|
124
|
+
token: options.meta?.token,
|
|
125
|
+
headers: dataSourceKey
|
|
126
|
+
? { "X-Data-Source": dataSourceKey }
|
|
127
|
+
: undefined,
|
|
128
|
+
unwrap: options.unwrapData === false ? "none" : "data",
|
|
128
129
|
});
|
|
130
|
+
};
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const getAllowedActions = (response: NocoBaseListResponse<unknown>) =>
|
|
133
|
+
response.meta?.allowedActions ??
|
|
134
|
+
response.allowedActions ??
|
|
135
|
+
(!Array.isArray(response.data) && response.data
|
|
136
|
+
? response.data.meta?.allowedActions ?? response.data.allowedActions
|
|
137
|
+
: undefined);
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
const cacheAllowedActions = <TData extends BaseRecord>({
|
|
140
|
+
resource,
|
|
141
|
+
records,
|
|
142
|
+
response,
|
|
143
|
+
meta,
|
|
144
|
+
}: {
|
|
145
|
+
resource: string;
|
|
146
|
+
records: TData[];
|
|
147
|
+
response: NocoBaseListResponse<TData>;
|
|
148
|
+
meta?: NocoBaseMeta;
|
|
149
|
+
}) => {
|
|
150
|
+
const idField = meta?.idField ?? "id";
|
|
151
|
+
const dataSourceKey = resolveAclDataSourceKey(meta);
|
|
152
|
+
const recordIds = records
|
|
153
|
+
.map((record) => record[idField])
|
|
154
|
+
.filter(
|
|
155
|
+
(id): id is string | number =>
|
|
156
|
+
typeof id === "string" || typeof id === "number"
|
|
157
|
+
);
|
|
158
|
+
return updateRecordPermissions({
|
|
159
|
+
dataSourceKey,
|
|
160
|
+
resource,
|
|
161
|
+
recordIds,
|
|
162
|
+
allowedActions: getAllowedActions(response),
|
|
163
|
+
});
|
|
140
164
|
};
|
|
141
165
|
|
|
166
|
+
const getResponseData = <TData extends BaseRecord>(
|
|
167
|
+
response: NocoBaseGetResponse<TData>
|
|
168
|
+
) => response.data ?? (response as TData);
|
|
169
|
+
|
|
142
170
|
export const dataProvider: DataProvider = {
|
|
143
171
|
async getList<TData extends BaseRecord = BaseRecord>({
|
|
144
172
|
resource,
|
|
@@ -150,51 +178,144 @@ export const dataProvider: DataProvider = {
|
|
|
150
178
|
const page = pagination?.currentPage ?? 1;
|
|
151
179
|
const pageSize = pagination?.pageSize ?? 10;
|
|
152
180
|
const filter = toNocoBaseFilter(filters);
|
|
153
|
-
const sort = sorters?.map(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
const sort = sorters?.map(
|
|
182
|
+
(sorter) => `${sorter.order === "desc" ? "-" : ""}${sorter.field}`
|
|
183
|
+
);
|
|
184
|
+
const response = await request<NocoBaseListResponse<TData>>(
|
|
185
|
+
resource,
|
|
186
|
+
"list",
|
|
187
|
+
{
|
|
188
|
+
query: {
|
|
189
|
+
page,
|
|
190
|
+
pageSize,
|
|
191
|
+
...(filter ? { filter: JSON.stringify(filter) } : {}),
|
|
192
|
+
...(sort?.length ? { sort: sort.join(",") } : {}),
|
|
193
|
+
},
|
|
194
|
+
meta,
|
|
195
|
+
unwrapData: false,
|
|
196
|
+
}
|
|
197
|
+
);
|
|
164
198
|
|
|
165
199
|
const list = Array.isArray(response.data)
|
|
166
200
|
? { rows: response.data, count: response.meta?.count }
|
|
167
201
|
: response.data ?? response;
|
|
202
|
+
const records = list.rows ?? [];
|
|
203
|
+
if (cacheAllowedActions({ resource, records, response, meta })) {
|
|
204
|
+
notifyRecordPermissionsChanged();
|
|
205
|
+
}
|
|
168
206
|
|
|
169
207
|
return {
|
|
170
|
-
data:
|
|
171
|
-
total: list.count ??
|
|
208
|
+
data: records,
|
|
209
|
+
total: list.count ?? records.length,
|
|
210
|
+
meta: response.meta,
|
|
172
211
|
};
|
|
173
212
|
},
|
|
174
213
|
|
|
175
|
-
async getOne<TData extends BaseRecord = BaseRecord>({
|
|
176
|
-
|
|
214
|
+
async getOne<TData extends BaseRecord = BaseRecord>({
|
|
215
|
+
resource,
|
|
216
|
+
id,
|
|
217
|
+
meta,
|
|
218
|
+
}: GetOneParams): Promise<GetOneResponse<TData>> {
|
|
219
|
+
const response = await request<NocoBaseGetResponse<TData>>(
|
|
220
|
+
resource,
|
|
221
|
+
"get",
|
|
222
|
+
{
|
|
223
|
+
query: { filterByTk: id },
|
|
224
|
+
meta,
|
|
225
|
+
unwrapData: false,
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
const data = getResponseData(response);
|
|
229
|
+
if (
|
|
230
|
+
cacheAllowedActions({
|
|
231
|
+
resource,
|
|
232
|
+
records: [data],
|
|
233
|
+
response: response as NocoBaseListResponse<TData>,
|
|
234
|
+
meta,
|
|
235
|
+
})
|
|
236
|
+
) {
|
|
237
|
+
notifyRecordPermissionsChanged();
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
data,
|
|
241
|
+
};
|
|
177
242
|
},
|
|
178
243
|
|
|
179
|
-
async getMany<TData extends BaseRecord = BaseRecord>({
|
|
180
|
-
|
|
181
|
-
|
|
244
|
+
async getMany<TData extends BaseRecord = BaseRecord>({
|
|
245
|
+
resource,
|
|
246
|
+
ids,
|
|
247
|
+
meta,
|
|
248
|
+
}: GetManyParams): Promise<GetManyResponse<TData>> {
|
|
249
|
+
const responses = await Promise.all(
|
|
250
|
+
ids.map((id) =>
|
|
251
|
+
request<NocoBaseGetResponse<TData>>(resource, "get", {
|
|
252
|
+
query: { filterByTk: id },
|
|
253
|
+
meta,
|
|
254
|
+
unwrapData: false,
|
|
255
|
+
})
|
|
256
|
+
)
|
|
182
257
|
);
|
|
258
|
+
const data = responses.map(getResponseData);
|
|
259
|
+
let permissionsChanged = false;
|
|
260
|
+
responses.forEach((response, index) => {
|
|
261
|
+
permissionsChanged =
|
|
262
|
+
cacheAllowedActions({
|
|
263
|
+
resource,
|
|
264
|
+
records: [data[index]],
|
|
265
|
+
response: response as NocoBaseListResponse<TData>,
|
|
266
|
+
meta,
|
|
267
|
+
}) || permissionsChanged;
|
|
268
|
+
});
|
|
269
|
+
if (permissionsChanged) notifyRecordPermissionsChanged();
|
|
183
270
|
return { data };
|
|
184
271
|
},
|
|
185
272
|
|
|
186
|
-
async create<
|
|
187
|
-
|
|
273
|
+
async create<
|
|
274
|
+
TData extends BaseRecord = BaseRecord,
|
|
275
|
+
TVariables = Record<string, unknown>
|
|
276
|
+
>({
|
|
277
|
+
resource,
|
|
278
|
+
variables,
|
|
279
|
+
meta,
|
|
280
|
+
}: CreateParams<TVariables>): Promise<CreateResponse<TData>> {
|
|
281
|
+
return {
|
|
282
|
+
data: await request<TData>(resource, "create", {
|
|
283
|
+
method: "POST",
|
|
284
|
+
body: variables,
|
|
285
|
+
meta,
|
|
286
|
+
}),
|
|
287
|
+
};
|
|
188
288
|
},
|
|
189
289
|
|
|
190
|
-
async createMany<
|
|
290
|
+
async createMany<
|
|
291
|
+
TData extends BaseRecord = BaseRecord,
|
|
292
|
+
TVariables = Record<string, unknown>
|
|
293
|
+
>({
|
|
294
|
+
resource,
|
|
295
|
+
variables,
|
|
296
|
+
meta,
|
|
297
|
+
}: CreateManyParams<TVariables>): Promise<CreateManyResponse<TData>> {
|
|
191
298
|
const data = await Promise.all(
|
|
192
|
-
variables.map((values) =>
|
|
299
|
+
variables.map((values) =>
|
|
300
|
+
request<TData>(resource, "create", {
|
|
301
|
+
method: "POST",
|
|
302
|
+
body: values,
|
|
303
|
+
meta,
|
|
304
|
+
})
|
|
305
|
+
)
|
|
193
306
|
);
|
|
194
307
|
return { data };
|
|
195
308
|
},
|
|
196
309
|
|
|
197
|
-
async update<
|
|
310
|
+
async update<
|
|
311
|
+
TData extends BaseRecord = BaseRecord,
|
|
312
|
+
TVariables = Record<string, unknown>
|
|
313
|
+
>({
|
|
314
|
+
resource,
|
|
315
|
+
id,
|
|
316
|
+
variables,
|
|
317
|
+
meta,
|
|
318
|
+
}: UpdateParams<TVariables>): Promise<UpdateResponse<TData>> {
|
|
198
319
|
return {
|
|
199
320
|
data: await request<TData>(resource, "update", {
|
|
200
321
|
method: "POST",
|
|
@@ -205,28 +326,64 @@ export const dataProvider: DataProvider = {
|
|
|
205
326
|
};
|
|
206
327
|
},
|
|
207
328
|
|
|
208
|
-
async updateMany<
|
|
329
|
+
async updateMany<
|
|
330
|
+
TData extends BaseRecord = BaseRecord,
|
|
331
|
+
TVariables = Record<string, unknown>
|
|
332
|
+
>({
|
|
333
|
+
resource,
|
|
334
|
+
ids,
|
|
335
|
+
variables,
|
|
336
|
+
meta,
|
|
337
|
+
}: UpdateManyParams<TVariables>): Promise<UpdateManyResponse<TData>> {
|
|
209
338
|
const data = await Promise.all(
|
|
210
|
-
ids.map((id) =>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
339
|
+
ids.map((id) =>
|
|
340
|
+
request<TData>(resource, "update", {
|
|
341
|
+
method: "POST",
|
|
342
|
+
query: { filterByTk: id },
|
|
343
|
+
body: variables,
|
|
344
|
+
meta,
|
|
345
|
+
})
|
|
346
|
+
)
|
|
216
347
|
);
|
|
217
348
|
return { data };
|
|
218
349
|
},
|
|
219
350
|
|
|
220
|
-
async deleteOne<
|
|
221
|
-
|
|
351
|
+
async deleteOne<
|
|
352
|
+
TData extends BaseRecord = BaseRecord,
|
|
353
|
+
TVariables = Record<string, unknown>
|
|
354
|
+
>({
|
|
355
|
+
resource,
|
|
356
|
+
id,
|
|
357
|
+
meta,
|
|
358
|
+
}: DeleteOneParams<TVariables>): Promise<DeleteOneResponse<TData>> {
|
|
359
|
+
return {
|
|
360
|
+
data: await request<TData>(resource, "destroy", {
|
|
361
|
+
method: "POST",
|
|
362
|
+
query: { filterByTk: id },
|
|
363
|
+
meta,
|
|
364
|
+
}),
|
|
365
|
+
};
|
|
222
366
|
},
|
|
223
367
|
|
|
224
|
-
async deleteMany<
|
|
368
|
+
async deleteMany<
|
|
369
|
+
TData extends BaseRecord = BaseRecord,
|
|
370
|
+
TVariables = Record<string, unknown>
|
|
371
|
+
>({
|
|
372
|
+
resource,
|
|
373
|
+
ids,
|
|
374
|
+
meta,
|
|
375
|
+
}: DeleteManyParams<TVariables>): Promise<DeleteManyResponse<TData>> {
|
|
225
376
|
const data = await Promise.all(
|
|
226
|
-
ids.map((id) =>
|
|
377
|
+
ids.map((id) =>
|
|
378
|
+
request<TData>(resource, "destroy", {
|
|
379
|
+
method: "POST",
|
|
380
|
+
query: { filterByTk: id },
|
|
381
|
+
meta,
|
|
382
|
+
})
|
|
383
|
+
)
|
|
227
384
|
);
|
|
228
385
|
return { data };
|
|
229
386
|
},
|
|
230
387
|
|
|
231
|
-
getApiUrl: () =>
|
|
388
|
+
getApiUrl: () => nocobaseClient.getApiUrl(),
|
|
232
389
|
};
|
package/vite.config.ts
CHANGED
|
@@ -60,6 +60,23 @@ export default defineConfig(({ mode }) => {
|
|
|
60
60
|
target: proxyTarget,
|
|
61
61
|
changeOrigin: true,
|
|
62
62
|
secure: false,
|
|
63
|
+
configure(proxy) {
|
|
64
|
+
proxy.on("proxyReq", (proxyRequest, request) => {
|
|
65
|
+
if (!request.url?.includes("aiConversations:")) return;
|
|
66
|
+
proxyRequest.setHeader("accept-encoding", "identity");
|
|
67
|
+
proxyRequest.setHeader("cache-control", "no-cache");
|
|
68
|
+
});
|
|
69
|
+
proxy.on("proxyRes", (proxyResponse) => {
|
|
70
|
+
const contentType = String(
|
|
71
|
+
proxyResponse.headers["content-type"] ?? ""
|
|
72
|
+
);
|
|
73
|
+
if (!contentType.includes("text/event-stream")) return;
|
|
74
|
+
delete proxyResponse.headers["content-length"];
|
|
75
|
+
proxyResponse.headers["cache-control"] =
|
|
76
|
+
"no-cache, no-transform";
|
|
77
|
+
proxyResponse.headers["x-accel-buffering"] = "no";
|
|
78
|
+
});
|
|
79
|
+
},
|
|
63
80
|
headers: proxyOrigin
|
|
64
81
|
? {
|
|
65
82
|
origin: proxyOrigin,
|