nextjs-cms 0.8.1 → 0.8.3
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/api/lib/serverActions.d.ts +3 -1
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +42 -18
- package/dist/core/factories/section-factory-with-jiti.d.ts +4 -1
- package/dist/core/factories/section-factory-with-jiti.d.ts.map +1 -1
- package/dist/core/factories/section-factory-with-jiti.js +9 -3
- package/package.json +3 -3
|
@@ -305,7 +305,9 @@ export declare const getSidebar: (session: Session) => Promise<{
|
|
|
305
305
|
}[];
|
|
306
306
|
}>;
|
|
307
307
|
/**
|
|
308
|
-
* Return a stream from the disk
|
|
308
|
+
* Return a stream from the disk with proper backpressure handling.
|
|
309
|
+
* Uses Node.js built-in Readable.toWeb() which correctly pauses/resumes
|
|
310
|
+
* the underlying fs stream based on consumer demand.
|
|
309
311
|
* @param {string} path - The location of the file
|
|
310
312
|
* @param options
|
|
311
313
|
* @returns {ReadableStream} A readable stream of the file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAQlD,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKxE,eAAO,MAAM,eAAe,GAAU,gCAInC;IACC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACjB,qBAmBA,CAAA;AACD,eAAO,MAAM,WAAW,GACpB,SAAS,OAAO,EAChB,OAAO;IAAE,IAAI,EAAE,MAAM,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@ -7,6 +7,7 @@ import { FieldFactory, SectionFactory } from '../../core/factories/index.js';
|
|
|
7
7
|
import { SelectField } from '../../core/fields/index.js';
|
|
8
8
|
import { MysqlTableChecker } from '../../core/db/index.js';
|
|
9
9
|
import fs from 'fs';
|
|
10
|
+
import { Readable } from 'stream';
|
|
10
11
|
import path from 'path';
|
|
11
12
|
import { sanitizeFileName, sanitizeFolderOrFileName } from '../../utils/index.js';
|
|
12
13
|
import sharp from 'sharp';
|
|
@@ -136,17 +137,44 @@ export const getDocument = async (session, input) => {
|
|
|
136
137
|
};
|
|
137
138
|
/**
|
|
138
139
|
* Helper function with proper cleanup for converting Node.js stream to Web ReadableStream
|
|
140
|
+
* Uses pull()-based reading for proper backpressure support.
|
|
139
141
|
* @param nodeStream
|
|
140
142
|
* @param sharpInstance
|
|
141
143
|
*/
|
|
142
144
|
function nodeStreamToWebStream(nodeStream, sharpInstance) {
|
|
143
145
|
return new ReadableStream({
|
|
144
|
-
start(
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
start() {
|
|
147
|
+
// Start paused — let pull() drive reading
|
|
148
|
+
if ('pause' in nodeStream && typeof nodeStream.pause === 'function') {
|
|
149
|
+
nodeStream.pause();
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
pull(controller) {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const onData = (chunk) => {
|
|
155
|
+
controller.enqueue(new Uint8Array(chunk));
|
|
156
|
+
if ('pause' in nodeStream && typeof nodeStream.pause === 'function') {
|
|
157
|
+
nodeStream.pause();
|
|
158
|
+
}
|
|
159
|
+
nodeStream.removeListener('data', onData);
|
|
160
|
+
nodeStream.removeListener('error', onError);
|
|
161
|
+
resolve();
|
|
162
|
+
};
|
|
163
|
+
const onError = (err) => {
|
|
164
|
+
controller.error(err);
|
|
165
|
+
nodeStream.removeListener('data', onData);
|
|
166
|
+
reject(err);
|
|
167
|
+
};
|
|
168
|
+
nodeStream.on('data', onData);
|
|
169
|
+
nodeStream.on('error', onError);
|
|
170
|
+
nodeStream.once('end', () => {
|
|
171
|
+
controller.close();
|
|
172
|
+
resolve();
|
|
173
|
+
});
|
|
174
|
+
if ('resume' in nodeStream && typeof nodeStream.resume === 'function') {
|
|
175
|
+
nodeStream.resume();
|
|
176
|
+
}
|
|
147
177
|
});
|
|
148
|
-
nodeStream.on('end', () => controller.close());
|
|
149
|
-
nodeStream.on('error', (error) => controller.error(error));
|
|
150
178
|
},
|
|
151
179
|
cancel() {
|
|
152
180
|
// Proper cleanup sequence
|
|
@@ -1017,7 +1045,11 @@ export const getSidebar = async (session) => {
|
|
|
1017
1045
|
* Add the plugin sections (excluding dashboard override)
|
|
1018
1046
|
*/
|
|
1019
1047
|
...pluginSections,
|
|
1020
|
-
...fixed.map((section) => ({
|
|
1048
|
+
...fixed.map((section) => ({
|
|
1049
|
+
title: getString(section.name, session.user.locale),
|
|
1050
|
+
path: `/${section.name}`,
|
|
1051
|
+
icon: section.icon,
|
|
1052
|
+
})),
|
|
1021
1053
|
];
|
|
1022
1054
|
return {
|
|
1023
1055
|
fixed_sections: fixedSections,
|
|
@@ -1027,22 +1059,14 @@ export const getSidebar = async (session) => {
|
|
|
1027
1059
|
};
|
|
1028
1060
|
};
|
|
1029
1061
|
/**
|
|
1030
|
-
* Return a stream from the disk
|
|
1062
|
+
* Return a stream from the disk with proper backpressure handling.
|
|
1063
|
+
* Uses Node.js built-in Readable.toWeb() which correctly pauses/resumes
|
|
1064
|
+
* the underlying fs stream based on consumer demand.
|
|
1031
1065
|
* @param {string} path - The location of the file
|
|
1032
1066
|
* @param options
|
|
1033
1067
|
* @returns {ReadableStream} A readable stream of the file
|
|
1034
1068
|
*/
|
|
1035
1069
|
export const streamFile = async (path, options) => {
|
|
1036
1070
|
const stream = fs.createReadStream(path, options);
|
|
1037
|
-
return
|
|
1038
|
-
start(controller) {
|
|
1039
|
-
// @ts-ignore
|
|
1040
|
-
stream.on('data', (chunk) => controller.enqueue(new Uint8Array(chunk)));
|
|
1041
|
-
stream.on('end', () => controller.close());
|
|
1042
|
-
stream.on('error', (error) => controller.error(error));
|
|
1043
|
-
},
|
|
1044
|
-
cancel() {
|
|
1045
|
-
stream.destroy();
|
|
1046
|
-
},
|
|
1047
|
-
});
|
|
1071
|
+
return Readable.toWeb(stream);
|
|
1048
1072
|
};
|
|
@@ -56,7 +56,10 @@ export declare class SectionFactory {
|
|
|
56
56
|
simple: SimpleSectionConfig[];
|
|
57
57
|
has_items: HasItemsSectionConfig[];
|
|
58
58
|
category: CategorySectionConfig[];
|
|
59
|
-
fixed:
|
|
59
|
+
fixed: {
|
|
60
|
+
name: string;
|
|
61
|
+
icon: string;
|
|
62
|
+
}[];
|
|
60
63
|
}>;
|
|
61
64
|
/**
|
|
62
65
|
* Get a section
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-factory-with-jiti.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-jiti.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAgCrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AA0ExE,KAAK,gBAAgB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAwC;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA+B;IACrE,OAAO,CAAC,MAAM,CAAC,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AAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA+D5C,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
|
|
@@ -183,9 +183,15 @@ export class SectionFactory {
|
|
|
183
183
|
})
|
|
184
184
|
.from(AdminPrivilegesTable)
|
|
185
185
|
.where(eq(AdminPrivilegesTable.adminId, admin.id));
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
const FIXED_SECTIONS = [
|
|
187
|
+
{
|
|
188
|
+
name: 'admins',
|
|
189
|
+
icon: 'users',
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
const fixedSectionNames = new Set(FIXED_SECTIONS.map((s) => s.name));
|
|
193
|
+
const privilegedFixedNames = new Set(privileges.filter((p) => fixedSectionNames.has(p.sectionName)).map((p) => p.sectionName));
|
|
194
|
+
const fixedSections = FIXED_SECTIONS.filter((s) => privilegedFixedNames.has(s.name));
|
|
189
195
|
const simpleSections = sections.filter((section) => section.type === 'simple');
|
|
190
196
|
const hasItemsSections = sections.filter((section) => section.type === 'has_items');
|
|
191
197
|
const categorySections = sections.filter((section) => section.type === 'category');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cms",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -202,8 +202,8 @@
|
|
|
202
202
|
"tsx": "^4.20.6",
|
|
203
203
|
"typescript": "^5.9.2",
|
|
204
204
|
"@lzcms/eslint-config": "0.3.0",
|
|
205
|
-
"@lzcms/
|
|
206
|
-
"@lzcms/
|
|
205
|
+
"@lzcms/tsconfig": "0.1.0",
|
|
206
|
+
"@lzcms/prettier-config": "0.1.0"
|
|
207
207
|
},
|
|
208
208
|
"license": "MIT",
|
|
209
209
|
"keywords": [
|