@nocobase/server 2.0.0-alpha.5 → 2.0.0-alpha.51
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/lib/acl/available-action.js +1 -1
- package/lib/aes-encryptor.js +4 -0
- package/lib/app-command.d.ts +1 -0
- package/lib/app-command.js +3 -0
- package/lib/app-supervisor.d.ts +7 -2
- package/lib/app-supervisor.js +54 -15
- package/lib/application.d.ts +4 -6
- package/lib/application.js +19 -11
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +11 -0
- package/lib/commands/repair.d.ts +11 -0
- package/lib/commands/repair.js +43 -0
- package/lib/commands/start.js +1 -1
- package/lib/event-queue.js +7 -3
- package/lib/gateway/errors.js +10 -5
- package/lib/gateway/index.d.ts +8 -0
- package/lib/gateway/index.js +26 -2
- package/lib/helper.d.ts +359 -0
- package/lib/helper.js +58 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -3
- package/lib/locale/locale.js +1 -1
- package/lib/locale/resource.js +6 -9
- package/lib/main-data-source.d.ts +11 -0
- package/lib/main-data-source.js +128 -0
- package/lib/middlewares/data-template.js +1 -6
- package/lib/middlewares/parse-variables.js +2 -49
- package/lib/plugin-manager/options/resource.js +48 -25
- package/lib/plugin-manager/plugin-manager.d.ts +1 -0
- package/lib/plugin-manager/plugin-manager.js +36 -1
- package/lib/pub-sub-manager/pub-sub-manager.d.ts +1 -1
- package/lib/pub-sub-manager/pub-sub-manager.js +8 -8
- package/package.json +17 -16
- package/lib/background-job-manager.d.ts +0 -40
- package/lib/background-job-manager.js +0 -111
package/lib/helper.d.ts
CHANGED
|
@@ -17,3 +17,362 @@ export declare const getCommandFullName: (command: Command) => string;
|
|
|
17
17
|
export declare const tsxRerunning: () => Promise<void>;
|
|
18
18
|
export declare const enablePerfHooks: (app: Application) => void;
|
|
19
19
|
export declare function getBodyLimit(): string;
|
|
20
|
+
export declare function createContextVariablesScope(ctx: any): {
|
|
21
|
+
timezone: any;
|
|
22
|
+
now: string;
|
|
23
|
+
getField: (path: any) => any;
|
|
24
|
+
vars: {
|
|
25
|
+
ctx: {
|
|
26
|
+
state: any;
|
|
27
|
+
};
|
|
28
|
+
$system: {
|
|
29
|
+
now: string;
|
|
30
|
+
};
|
|
31
|
+
$date: {
|
|
32
|
+
now: string;
|
|
33
|
+
today: ({ now, timezone, field }: {
|
|
34
|
+
now?: any;
|
|
35
|
+
timezone?: string | number;
|
|
36
|
+
field?: {
|
|
37
|
+
timezone?: string | number;
|
|
38
|
+
};
|
|
39
|
+
}) => any;
|
|
40
|
+
yesterday: ({ now, timezone, field }: {
|
|
41
|
+
now?: any;
|
|
42
|
+
timezone?: string | number;
|
|
43
|
+
field?: {
|
|
44
|
+
timezone?: string | number;
|
|
45
|
+
};
|
|
46
|
+
}) => any;
|
|
47
|
+
tomorrow: ({ now, timezone, field }: {
|
|
48
|
+
now?: any;
|
|
49
|
+
timezone?: string | number;
|
|
50
|
+
field?: {
|
|
51
|
+
timezone?: string | number;
|
|
52
|
+
};
|
|
53
|
+
}) => any;
|
|
54
|
+
thisWeek: ({ now, timezone, field }: {
|
|
55
|
+
now?: any;
|
|
56
|
+
timezone?: string | number;
|
|
57
|
+
field?: {
|
|
58
|
+
timezone?: string | number;
|
|
59
|
+
};
|
|
60
|
+
}) => any;
|
|
61
|
+
lastWeek: ({ now, timezone, field }: {
|
|
62
|
+
now?: any;
|
|
63
|
+
timezone?: string | number;
|
|
64
|
+
field?: {
|
|
65
|
+
timezone?: string | number;
|
|
66
|
+
};
|
|
67
|
+
}) => any;
|
|
68
|
+
nextWeek: ({ now, timezone, field }: {
|
|
69
|
+
now?: any;
|
|
70
|
+
timezone?: string | number;
|
|
71
|
+
field?: {
|
|
72
|
+
timezone?: string | number;
|
|
73
|
+
};
|
|
74
|
+
}) => any;
|
|
75
|
+
thisIsoWeek: ({ now, timezone, field }: {
|
|
76
|
+
now?: any;
|
|
77
|
+
timezone?: string | number;
|
|
78
|
+
field?: {
|
|
79
|
+
timezone?: string | number;
|
|
80
|
+
};
|
|
81
|
+
}) => any;
|
|
82
|
+
lastIsoWeek: ({ now, timezone, field }: {
|
|
83
|
+
now?: any;
|
|
84
|
+
timezone?: string | number;
|
|
85
|
+
field?: {
|
|
86
|
+
timezone?: string | number;
|
|
87
|
+
};
|
|
88
|
+
}) => any;
|
|
89
|
+
nextIsoWeek: ({ now, timezone, field }: {
|
|
90
|
+
now?: any;
|
|
91
|
+
timezone?: string | number;
|
|
92
|
+
field?: {
|
|
93
|
+
timezone?: string | number;
|
|
94
|
+
};
|
|
95
|
+
}) => any;
|
|
96
|
+
thisMonth: ({ now, timezone, field }: {
|
|
97
|
+
now?: any;
|
|
98
|
+
timezone?: string | number;
|
|
99
|
+
field?: {
|
|
100
|
+
timezone?: string | number;
|
|
101
|
+
};
|
|
102
|
+
}) => any;
|
|
103
|
+
lastMonth: ({ now, timezone, field }: {
|
|
104
|
+
now?: any;
|
|
105
|
+
timezone?: string | number;
|
|
106
|
+
field?: {
|
|
107
|
+
timezone?: string | number;
|
|
108
|
+
};
|
|
109
|
+
}) => any;
|
|
110
|
+
nextMonth: ({ now, timezone, field }: {
|
|
111
|
+
now?: any;
|
|
112
|
+
timezone?: string | number;
|
|
113
|
+
field?: {
|
|
114
|
+
timezone?: string | number;
|
|
115
|
+
};
|
|
116
|
+
}) => any;
|
|
117
|
+
thisQuarter: ({ now, timezone, field }: {
|
|
118
|
+
now?: any;
|
|
119
|
+
timezone?: string | number;
|
|
120
|
+
field?: {
|
|
121
|
+
timezone?: string | number;
|
|
122
|
+
};
|
|
123
|
+
}) => any;
|
|
124
|
+
lastQuarter: ({ now, timezone, field }: {
|
|
125
|
+
now?: any;
|
|
126
|
+
timezone?: string | number;
|
|
127
|
+
field?: {
|
|
128
|
+
timezone?: string | number;
|
|
129
|
+
};
|
|
130
|
+
}) => any;
|
|
131
|
+
nextQuarter: ({ now, timezone, field }: {
|
|
132
|
+
now?: any;
|
|
133
|
+
timezone?: string | number;
|
|
134
|
+
field?: {
|
|
135
|
+
timezone?: string | number;
|
|
136
|
+
};
|
|
137
|
+
}) => any;
|
|
138
|
+
thisYear: ({ now, timezone, field }: {
|
|
139
|
+
now?: any;
|
|
140
|
+
timezone?: string | number;
|
|
141
|
+
field?: {
|
|
142
|
+
timezone?: string | number;
|
|
143
|
+
};
|
|
144
|
+
}) => any;
|
|
145
|
+
lastYear: ({ now, timezone, field }: {
|
|
146
|
+
now?: any;
|
|
147
|
+
timezone?: string | number;
|
|
148
|
+
field?: {
|
|
149
|
+
timezone?: string | number;
|
|
150
|
+
};
|
|
151
|
+
}) => any;
|
|
152
|
+
nextYear: ({ now, timezone, field }: {
|
|
153
|
+
now?: any;
|
|
154
|
+
timezone?: string | number;
|
|
155
|
+
field?: {
|
|
156
|
+
timezone?: string | number;
|
|
157
|
+
};
|
|
158
|
+
}) => any;
|
|
159
|
+
last7Days: ({ now, timezone, field }: {
|
|
160
|
+
now?: any;
|
|
161
|
+
timezone?: string | number;
|
|
162
|
+
field?: {
|
|
163
|
+
timezone?: string | number;
|
|
164
|
+
};
|
|
165
|
+
}) => (string | number)[];
|
|
166
|
+
next7Days: ({ now, timezone, field }: {
|
|
167
|
+
now?: any;
|
|
168
|
+
timezone?: string | number;
|
|
169
|
+
field?: {
|
|
170
|
+
timezone?: string | number;
|
|
171
|
+
};
|
|
172
|
+
}) => (string | number)[];
|
|
173
|
+
last30Days: ({ now, timezone, field }: {
|
|
174
|
+
now?: any;
|
|
175
|
+
timezone?: string | number;
|
|
176
|
+
field?: {
|
|
177
|
+
timezone?: string | number;
|
|
178
|
+
};
|
|
179
|
+
}) => (string | number)[];
|
|
180
|
+
next30Days: ({ now, timezone, field }: {
|
|
181
|
+
now?: any;
|
|
182
|
+
timezone?: string | number;
|
|
183
|
+
field?: {
|
|
184
|
+
timezone?: string | number;
|
|
185
|
+
};
|
|
186
|
+
}) => (string | number)[];
|
|
187
|
+
last90Days: ({ now, timezone, field }: {
|
|
188
|
+
now?: any;
|
|
189
|
+
timezone?: string | number;
|
|
190
|
+
field?: {
|
|
191
|
+
timezone?: string | number;
|
|
192
|
+
};
|
|
193
|
+
}) => (string | number)[];
|
|
194
|
+
next90Days: ({ now, timezone, field }: {
|
|
195
|
+
now?: any;
|
|
196
|
+
timezone?: string | number;
|
|
197
|
+
field?: {
|
|
198
|
+
timezone?: string | number;
|
|
199
|
+
};
|
|
200
|
+
}) => (string | number)[];
|
|
201
|
+
};
|
|
202
|
+
$nDate: {
|
|
203
|
+
now: string;
|
|
204
|
+
today: ({ now, timezone, field }: {
|
|
205
|
+
now?: any;
|
|
206
|
+
timezone?: string | number;
|
|
207
|
+
field?: {
|
|
208
|
+
timezone?: string | number;
|
|
209
|
+
};
|
|
210
|
+
}) => any;
|
|
211
|
+
yesterday: ({ now, timezone, field }: {
|
|
212
|
+
now?: any;
|
|
213
|
+
timezone?: string | number;
|
|
214
|
+
field?: {
|
|
215
|
+
timezone?: string | number;
|
|
216
|
+
};
|
|
217
|
+
}) => any;
|
|
218
|
+
tomorrow: ({ now, timezone, field }: {
|
|
219
|
+
now?: any;
|
|
220
|
+
timezone?: string | number;
|
|
221
|
+
field?: {
|
|
222
|
+
timezone?: string | number;
|
|
223
|
+
};
|
|
224
|
+
}) => any;
|
|
225
|
+
thisWeek: ({ now, timezone, field }: {
|
|
226
|
+
now?: any;
|
|
227
|
+
timezone?: string | number;
|
|
228
|
+
field?: {
|
|
229
|
+
timezone?: string | number;
|
|
230
|
+
};
|
|
231
|
+
}) => any;
|
|
232
|
+
lastWeek: ({ now, timezone, field }: {
|
|
233
|
+
now?: any;
|
|
234
|
+
timezone?: string | number;
|
|
235
|
+
field?: {
|
|
236
|
+
timezone?: string | number;
|
|
237
|
+
};
|
|
238
|
+
}) => any;
|
|
239
|
+
nextWeek: ({ now, timezone, field }: {
|
|
240
|
+
now?: any;
|
|
241
|
+
timezone?: string | number;
|
|
242
|
+
field?: {
|
|
243
|
+
timezone?: string | number;
|
|
244
|
+
};
|
|
245
|
+
}) => any;
|
|
246
|
+
thisIsoWeek: ({ now, timezone, field }: {
|
|
247
|
+
now?: any;
|
|
248
|
+
timezone?: string | number;
|
|
249
|
+
field?: {
|
|
250
|
+
timezone?: string | number;
|
|
251
|
+
};
|
|
252
|
+
}) => any;
|
|
253
|
+
lastIsoWeek: ({ now, timezone, field }: {
|
|
254
|
+
now?: any;
|
|
255
|
+
timezone?: string | number;
|
|
256
|
+
field?: {
|
|
257
|
+
timezone?: string | number;
|
|
258
|
+
};
|
|
259
|
+
}) => any;
|
|
260
|
+
nextIsoWeek: ({ now, timezone, field }: {
|
|
261
|
+
now?: any;
|
|
262
|
+
timezone?: string | number;
|
|
263
|
+
field?: {
|
|
264
|
+
timezone?: string | number;
|
|
265
|
+
};
|
|
266
|
+
}) => any;
|
|
267
|
+
thisMonth: ({ now, timezone, field }: {
|
|
268
|
+
now?: any;
|
|
269
|
+
timezone?: string | number;
|
|
270
|
+
field?: {
|
|
271
|
+
timezone?: string | number;
|
|
272
|
+
};
|
|
273
|
+
}) => any;
|
|
274
|
+
lastMonth: ({ now, timezone, field }: {
|
|
275
|
+
now?: any;
|
|
276
|
+
timezone?: string | number;
|
|
277
|
+
field?: {
|
|
278
|
+
timezone?: string | number;
|
|
279
|
+
};
|
|
280
|
+
}) => any;
|
|
281
|
+
nextMonth: ({ now, timezone, field }: {
|
|
282
|
+
now?: any;
|
|
283
|
+
timezone?: string | number;
|
|
284
|
+
field?: {
|
|
285
|
+
timezone?: string | number;
|
|
286
|
+
};
|
|
287
|
+
}) => any;
|
|
288
|
+
thisQuarter: ({ now, timezone, field }: {
|
|
289
|
+
now?: any;
|
|
290
|
+
timezone?: string | number;
|
|
291
|
+
field?: {
|
|
292
|
+
timezone?: string | number;
|
|
293
|
+
};
|
|
294
|
+
}) => any;
|
|
295
|
+
lastQuarter: ({ now, timezone, field }: {
|
|
296
|
+
now?: any;
|
|
297
|
+
timezone?: string | number;
|
|
298
|
+
field?: {
|
|
299
|
+
timezone?: string | number;
|
|
300
|
+
};
|
|
301
|
+
}) => any;
|
|
302
|
+
nextQuarter: ({ now, timezone, field }: {
|
|
303
|
+
now?: any;
|
|
304
|
+
timezone?: string | number;
|
|
305
|
+
field?: {
|
|
306
|
+
timezone?: string | number;
|
|
307
|
+
};
|
|
308
|
+
}) => any;
|
|
309
|
+
thisYear: ({ now, timezone, field }: {
|
|
310
|
+
now?: any;
|
|
311
|
+
timezone?: string | number;
|
|
312
|
+
field?: {
|
|
313
|
+
timezone?: string | number;
|
|
314
|
+
};
|
|
315
|
+
}) => any;
|
|
316
|
+
lastYear: ({ now, timezone, field }: {
|
|
317
|
+
now?: any;
|
|
318
|
+
timezone?: string | number;
|
|
319
|
+
field?: {
|
|
320
|
+
timezone?: string | number;
|
|
321
|
+
};
|
|
322
|
+
}) => any;
|
|
323
|
+
nextYear: ({ now, timezone, field }: {
|
|
324
|
+
now?: any;
|
|
325
|
+
timezone?: string | number;
|
|
326
|
+
field?: {
|
|
327
|
+
timezone?: string | number;
|
|
328
|
+
};
|
|
329
|
+
}) => any;
|
|
330
|
+
last7Days: ({ now, timezone, field }: {
|
|
331
|
+
now?: any;
|
|
332
|
+
timezone?: string | number;
|
|
333
|
+
field?: {
|
|
334
|
+
timezone?: string | number;
|
|
335
|
+
};
|
|
336
|
+
}) => (string | number)[];
|
|
337
|
+
next7Days: ({ now, timezone, field }: {
|
|
338
|
+
now?: any;
|
|
339
|
+
timezone?: string | number;
|
|
340
|
+
field?: {
|
|
341
|
+
timezone?: string | number;
|
|
342
|
+
};
|
|
343
|
+
}) => (string | number)[];
|
|
344
|
+
last30Days: ({ now, timezone, field }: {
|
|
345
|
+
now?: any;
|
|
346
|
+
timezone?: string | number;
|
|
347
|
+
field?: {
|
|
348
|
+
timezone?: string | number;
|
|
349
|
+
};
|
|
350
|
+
}) => (string | number)[];
|
|
351
|
+
next30Days: ({ now, timezone, field }: {
|
|
352
|
+
now?: any;
|
|
353
|
+
timezone?: string | number;
|
|
354
|
+
field?: {
|
|
355
|
+
timezone?: string | number;
|
|
356
|
+
};
|
|
357
|
+
}) => (string | number)[];
|
|
358
|
+
last90Days: ({ now, timezone, field }: {
|
|
359
|
+
now?: any;
|
|
360
|
+
timezone?: string | number;
|
|
361
|
+
field?: {
|
|
362
|
+
timezone?: string | number;
|
|
363
|
+
};
|
|
364
|
+
}) => (string | number)[];
|
|
365
|
+
next90Days: ({ now, timezone, field }: {
|
|
366
|
+
now?: any;
|
|
367
|
+
timezone?: string | number;
|
|
368
|
+
field?: {
|
|
369
|
+
timezone?: string | number;
|
|
370
|
+
};
|
|
371
|
+
}) => (string | number)[];
|
|
372
|
+
};
|
|
373
|
+
$user: ({ fields }: {
|
|
374
|
+
fields: any;
|
|
375
|
+
}) => Promise<any>;
|
|
376
|
+
$nRole: any;
|
|
377
|
+
};
|
|
378
|
+
};
|
package/lib/helper.js
CHANGED
|
@@ -38,6 +38,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
38
38
|
var helper_exports = {};
|
|
39
39
|
__export(helper_exports, {
|
|
40
40
|
createAppProxy: () => createAppProxy,
|
|
41
|
+
createContextVariablesScope: () => createContextVariablesScope,
|
|
41
42
|
createI18n: () => createI18n,
|
|
42
43
|
createResourcer: () => createResourcer,
|
|
43
44
|
enablePerfHooks: () => enablePerfHooks,
|
|
@@ -193,9 +194,66 @@ function getBodyLimit() {
|
|
|
193
194
|
return process.env.REQUEST_BODY_LIMIT || "10mb";
|
|
194
195
|
}
|
|
195
196
|
__name(getBodyLimit, "getBodyLimit");
|
|
197
|
+
function getUser(ctx) {
|
|
198
|
+
return async ({ fields }) => {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
const userFields = fields.filter((f) => f && ctx.db.getFieldByPath("users." + f));
|
|
201
|
+
(_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
|
|
202
|
+
if (!ctx.state.currentUser) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (!userFields.length) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const user = await ctx.db.getRepository("users").findOne({
|
|
209
|
+
filterByTk: ctx.state.currentUser.id,
|
|
210
|
+
fields: userFields
|
|
211
|
+
});
|
|
212
|
+
(_b = ctx.logger) == null ? void 0 : _b.info("filter-parse: ", {
|
|
213
|
+
$user: user == null ? void 0 : user.toJSON()
|
|
214
|
+
});
|
|
215
|
+
return user;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
__name(getUser, "getUser");
|
|
219
|
+
function isNumeric(str) {
|
|
220
|
+
if (typeof str === "number") return true;
|
|
221
|
+
if (typeof str != "string") return false;
|
|
222
|
+
return !isNaN(str) && !isNaN(parseFloat(str));
|
|
223
|
+
}
|
|
224
|
+
__name(isNumeric, "isNumeric");
|
|
225
|
+
function createContextVariablesScope(ctx) {
|
|
226
|
+
const state = JSON.parse(JSON.stringify(ctx.state));
|
|
227
|
+
return {
|
|
228
|
+
timezone: ctx.get("x-timezone"),
|
|
229
|
+
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
230
|
+
getField: /* @__PURE__ */ __name((path) => {
|
|
231
|
+
const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join(".");
|
|
232
|
+
const { resourceName } = ctx.action;
|
|
233
|
+
return ctx.db.getFieldByPath(`${resourceName}.${fieldPath}`);
|
|
234
|
+
}, "getField"),
|
|
235
|
+
vars: {
|
|
236
|
+
ctx: {
|
|
237
|
+
state
|
|
238
|
+
},
|
|
239
|
+
// @deprecated
|
|
240
|
+
$system: {
|
|
241
|
+
now: (/* @__PURE__ */ new Date()).toISOString()
|
|
242
|
+
},
|
|
243
|
+
// @deprecated
|
|
244
|
+
$date: (0, import_utils.getDateVars)(),
|
|
245
|
+
// 新的命名方式,防止和 formily 内置变量冲突
|
|
246
|
+
$nDate: (0, import_utils.getDateVars)(),
|
|
247
|
+
$user: getUser(ctx),
|
|
248
|
+
$nRole: ctx.state.currentRole === "__union__" ? ctx.state.currentRoles : ctx.state.currentRole
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
__name(createContextVariablesScope, "createContextVariablesScope");
|
|
196
253
|
// Annotate the CommonJS export names for ESM import in node:
|
|
197
254
|
0 && (module.exports = {
|
|
198
255
|
createAppProxy,
|
|
256
|
+
createContextVariablesScope,
|
|
199
257
|
createI18n,
|
|
200
258
|
createResourcer,
|
|
201
259
|
enablePerfHooks,
|
package/lib/index.d.ts
CHANGED
|
@@ -19,9 +19,10 @@ export * from './plugin';
|
|
|
19
19
|
export * from './plugin-manager';
|
|
20
20
|
export * from './pub-sub-manager';
|
|
21
21
|
export * from './event-queue';
|
|
22
|
-
export * from './background-job-manager';
|
|
23
22
|
export * from './worker-id-allocator';
|
|
24
23
|
export * from './redis-connection-manager';
|
|
24
|
+
export * from './main-data-source';
|
|
25
25
|
export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
26
26
|
export { appendToBuiltInPlugins, findAllPlugins, findBuiltInPlugins, findLocalPlugins, packageNameTrim, } from './plugin-manager/findPackageNames';
|
|
27
27
|
export { runPluginStaticImports } from './run-plugin-static-imports';
|
|
28
|
+
export { createContextVariablesScope } from './helper';
|
package/lib/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var src_exports = {};
|
|
|
39
39
|
__export(src_exports, {
|
|
40
40
|
OFFICIAL_PLUGIN_PREFIX: () => OFFICIAL_PLUGIN_PREFIX,
|
|
41
41
|
appendToBuiltInPlugins: () => import_findPackageNames.appendToBuiltInPlugins,
|
|
42
|
+
createContextVariablesScope: () => import_helper.createContextVariablesScope,
|
|
42
43
|
default: () => import_application.Application,
|
|
43
44
|
findAllPlugins: () => import_findPackageNames.findAllPlugins,
|
|
44
45
|
findBuiltInPlugins: () => import_findPackageNames.findBuiltInPlugins,
|
|
@@ -61,16 +62,18 @@ __reExport(src_exports, require("./plugin"), module.exports);
|
|
|
61
62
|
__reExport(src_exports, require("./plugin-manager"), module.exports);
|
|
62
63
|
__reExport(src_exports, require("./pub-sub-manager"), module.exports);
|
|
63
64
|
__reExport(src_exports, require("./event-queue"), module.exports);
|
|
64
|
-
__reExport(src_exports, require("./background-job-manager"), module.exports);
|
|
65
65
|
__reExport(src_exports, require("./worker-id-allocator"), module.exports);
|
|
66
66
|
__reExport(src_exports, require("./redis-connection-manager"), module.exports);
|
|
67
|
+
__reExport(src_exports, require("./main-data-source"), module.exports);
|
|
67
68
|
var import_findPackageNames = require("./plugin-manager/findPackageNames");
|
|
68
69
|
var import_run_plugin_static_imports = require("./run-plugin-static-imports");
|
|
70
|
+
var import_helper = require("./helper");
|
|
69
71
|
const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
70
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
73
|
0 && (module.exports = {
|
|
72
74
|
OFFICIAL_PLUGIN_PREFIX,
|
|
73
75
|
appendToBuiltInPlugins,
|
|
76
|
+
createContextVariablesScope,
|
|
74
77
|
findAllPlugins,
|
|
75
78
|
findBuiltInPlugins,
|
|
76
79
|
findLocalPlugins,
|
|
@@ -88,7 +91,7 @@ const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
|
88
91
|
...require("./plugin-manager"),
|
|
89
92
|
...require("./pub-sub-manager"),
|
|
90
93
|
...require("./event-queue"),
|
|
91
|
-
...require("./background-job-manager"),
|
|
92
94
|
...require("./worker-id-allocator"),
|
|
93
|
-
...require("./redis-connection-manager")
|
|
95
|
+
...require("./redis-connection-manager"),
|
|
96
|
+
...require("./main-data-source")
|
|
94
97
|
});
|
package/lib/locale/locale.js
CHANGED
|
@@ -138,7 +138,7 @@ const _Locale = class _Locale {
|
|
|
138
138
|
if (!packageName) {
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
|
-
const res = (0, import_resource.getResource)(packageName, lang);
|
|
141
|
+
const res = await (0, import_resource.getResource)(packageName, lang);
|
|
142
142
|
if (res) {
|
|
143
143
|
resources[packageName] = { ...res };
|
|
144
144
|
if (packageName.includes(import__.OFFICIAL_PLUGIN_PREFIX)) {
|
package/lib/locale/resource.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(resource_exports, {
|
|
|
40
40
|
getResource: () => getResource
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(resource_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
44
44
|
const arr2obj = /* @__PURE__ */ __name((items) => {
|
|
45
45
|
const obj = {};
|
|
46
46
|
for (const item of items) {
|
|
@@ -48,7 +48,7 @@ const arr2obj = /* @__PURE__ */ __name((items) => {
|
|
|
48
48
|
}
|
|
49
49
|
return obj;
|
|
50
50
|
}, "arr2obj");
|
|
51
|
-
const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true) => {
|
|
51
|
+
const getResource = /* @__PURE__ */ __name(async (packageName, lang, isPlugin = true) => {
|
|
52
52
|
const resources = [];
|
|
53
53
|
const prefixes = [isPlugin ? "dist" : "lib"];
|
|
54
54
|
if (process.env.APP_ENV !== "production") {
|
|
@@ -70,13 +70,10 @@ const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true)
|
|
|
70
70
|
}
|
|
71
71
|
for (const prefix of prefixes) {
|
|
72
72
|
try {
|
|
73
|
-
const file = `${packageName}/${prefix}/locale/${lang}`;
|
|
73
|
+
const file = `${packageName}/${prefix}/locale/${lang}.json`;
|
|
74
74
|
const f = require.resolve(file);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
const resource = (0, import_utils.requireModule)(file);
|
|
79
|
-
resources.push(resource);
|
|
75
|
+
const resource = await import_promises.default.readFile(f, "utf8");
|
|
76
|
+
resources.push(JSON.parse(resource));
|
|
80
77
|
} catch (error) {
|
|
81
78
|
}
|
|
82
79
|
if (resources.length) {
|
|
@@ -84,7 +81,7 @@ const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true)
|
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
if (resources.length === 0 && lang.replace("-", "_") !== lang) {
|
|
87
|
-
return getResource(packageName, lang.replace("-", "_"));
|
|
84
|
+
return await getResource(packageName, lang.replace("-", "_"));
|
|
88
85
|
}
|
|
89
86
|
return arr2obj(resources);
|
|
90
87
|
}, "getResource");
|
|
@@ -6,7 +6,18 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { Context } from '@nocobase/actions';
|
|
9
10
|
import { DataSourceOptions, SequelizeDataSource } from '@nocobase/data-source-manager';
|
|
11
|
+
type MainDataSourceStatus = 'loaded' | 'loading';
|
|
10
12
|
export declare class MainDataSource extends SequelizeDataSource {
|
|
13
|
+
status: MainDataSourceStatus;
|
|
11
14
|
init(options?: DataSourceOptions): void;
|
|
15
|
+
readTables(): Promise<{
|
|
16
|
+
name: string;
|
|
17
|
+
}[]>;
|
|
18
|
+
private tables2Collections;
|
|
19
|
+
loadTables(ctx: Context, tables: string[]): Promise<void>;
|
|
20
|
+
private getLoadedCollections;
|
|
21
|
+
syncFieldsFromDatabase(ctx: any, collectionNames?: string[]): Promise<void>;
|
|
12
22
|
}
|
|
23
|
+
export {};
|