webspresso 0.0.94 → 0.0.96
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/.agents/ADMIN.md +225 -0
- package/.agents/AGENTS.md +72 -0
- package/.agents/ARCHITECTURE.md +119 -0
- package/.agents/AUTH.md +103 -0
- package/.agents/CLI.md +115 -0
- package/.agents/COMPRESSION.md +59 -0
- package/.agents/CONVENTIONS.md +46 -0
- package/.agents/EMAIL.md +141 -0
- package/.agents/ERRORS.md +201 -0
- package/.agents/MCP.md +103 -0
- package/.agents/ORM.md +230 -0
- package/.agents/PLUGINS.md +419 -0
- package/.agents/QUEUE.md +113 -0
- package/.agents/REALTIME.md +213 -0
- package/.agents/ROUTING.md +292 -0
- package/.agents/SERVICES.md +341 -0
- package/.agents/SHUTDOWN.md +67 -0
- package/.agents/STREAMING.md +73 -0
- package/.agents/WORKFLOW.md +27 -0
- package/.agents/internal/DOCUMENTATION_REVIEW.md +485 -0
- package/.agents/internal/TECHNICAL_REVIEW.md +428 -0
- package/.cursorrules +14 -0
- package/AGENTS.md +175 -0
- package/CLAUDE.md +54 -0
- package/README.md +18 -14
- package/bin/commands/agents-init.js +169 -0
- package/bin/commands/api.js +114 -48
- package/bin/commands/doctor.js +35 -0
- package/bin/commands/new.js +13 -2
- package/bin/commands/page.js +75 -89
- package/bin/commands/service.js +77 -0
- package/bin/webspresso.js +2 -2
- package/core/compileSchema.js +1 -1
- package/core/errors/middleware.js +22 -2
- package/core/errors/normalize.js +29 -2
- package/{utils/schemaCache.js → core/schema-cache.js} +2 -3
- package/index.d.ts +306 -0
- package/index.js +35 -1
- package/package.json +19 -6
- package/plugins/admin-panel/client/parts/05-rich-text-file-helpers.js +22 -1
- package/plugins/csrf/index.js +3 -2
- package/plugins/csv/engine.js +447 -0
- package/plugins/csv/index.js +94 -0
- package/plugins/csv/middleware.js +80 -0
- package/plugins/csv/services.js +138 -0
- package/plugins/file-manager/admin-component.js +613 -0
- package/plugins/file-manager/api-handlers.js +261 -0
- package/plugins/file-manager/core.js +601 -0
- package/plugins/file-manager/index.js +139 -0
- package/plugins/file-manager/security.js +207 -0
- package/plugins/index.js +8 -0
- package/plugins/polar/CHANGELOG.md +18 -0
- package/plugins/polar/README.md +30 -7
- package/plugins/polar/index.js +6 -1
- package/plugins/polar/src/billing-hooks.js +51 -0
- package/plugins/polar/src/config.js +2 -0
- package/plugins/polar/src/rate-limit.js +96 -28
- package/plugins/polar/src/routes.js +3 -2
- package/plugins/polar/src/urls.js +26 -2
- package/plugins/polar/src/user-resolver.js +5 -1
- package/plugins/rate-limit/index.js +5 -1
- package/plugins/xlsx/engine.js +397 -0
- package/plugins/xlsx/index.js +91 -0
- package/plugins/xlsx/middleware.js +87 -0
- package/plugins/xlsx/services.js +118 -0
- package/src/api/api-loader.js +233 -0
- package/src/api/define-api.js +35 -0
- package/src/discovery/file-route-parser.js +201 -0
- package/src/discovery/scan-routes.js +265 -0
- package/src/file-router.js +6 -0
- package/src/modules/define-module.js +99 -0
- package/src/modules/module-discovery.js +117 -0
- package/src/pages/define-page.js +36 -0
- package/src/pages/page-loader.js +214 -0
- package/src/routing/mount-discovered-routes.js +78 -0
- package/src/routing/route-table.js +191 -0
- package/src/server.js +112 -15
- package/src/services/builtins/file-manager.js +178 -0
- package/src/services/index.js +2 -0
- package/bin/commands/skill.js +0 -187
- package/templates/skills/webspresso-usage/REFERENCE-framework.md +0 -289
- package/templates/skills/webspresso-usage/REFERENCE-kernel.md +0 -93
- package/templates/skills/webspresso-usage/SKILL.md +0 -48
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Built-in CSV Services
|
|
5
|
+
* Exposed via ctx.service('csv.*') and req.service('csv.*')
|
|
6
|
+
* @module plugins/csv/services
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { z } = require('zod');
|
|
10
|
+
const { generate, parse, fromModel, CSV_MIME_TYPE } = require('./engine');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates built-in services for the CSV plugin
|
|
14
|
+
* @param {Object} [options]
|
|
15
|
+
* @param {Object} [options.db]
|
|
16
|
+
* @returns {Object.<string, Object>}
|
|
17
|
+
*/
|
|
18
|
+
function createCsvServices(options = {}) {
|
|
19
|
+
return {
|
|
20
|
+
'csv.generate': {
|
|
21
|
+
schema: z.object({
|
|
22
|
+
rows: z.array(z.record(z.any())).optional(),
|
|
23
|
+
data: z.array(z.record(z.any())).optional(),
|
|
24
|
+
columns: z
|
|
25
|
+
.array(
|
|
26
|
+
z.union([
|
|
27
|
+
z.string(),
|
|
28
|
+
z.object({
|
|
29
|
+
header: z.string().optional(),
|
|
30
|
+
key: z.string(),
|
|
31
|
+
}),
|
|
32
|
+
])
|
|
33
|
+
)
|
|
34
|
+
.optional(),
|
|
35
|
+
delimiter: z.string().optional().default(','),
|
|
36
|
+
eol: z.string().optional().default('\r\n'),
|
|
37
|
+
header: z.boolean().optional().default(true),
|
|
38
|
+
bom: z.boolean().optional().default(true),
|
|
39
|
+
sanitizeFormulas: z.boolean().optional().default(true),
|
|
40
|
+
}),
|
|
41
|
+
handler: async (input) => {
|
|
42
|
+
const buffer = generate(input);
|
|
43
|
+
const csvString = buffer.toString('utf8');
|
|
44
|
+
return {
|
|
45
|
+
csv: csvString,
|
|
46
|
+
base64: buffer.toString('base64'),
|
|
47
|
+
size: buffer.length,
|
|
48
|
+
mimeType: CSV_MIME_TYPE,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
'csv.parse': {
|
|
54
|
+
schema: z.object({
|
|
55
|
+
text: z.string().optional(),
|
|
56
|
+
base64: z.string().optional(),
|
|
57
|
+
delimiter: z.string().optional(),
|
|
58
|
+
columns: z.union([z.boolean(), z.array(z.string())]).optional().default(true),
|
|
59
|
+
skip_empty_lines: z.boolean().optional().default(true),
|
|
60
|
+
trim: z.boolean().optional().default(true),
|
|
61
|
+
}),
|
|
62
|
+
handler: async (input) => {
|
|
63
|
+
let target;
|
|
64
|
+
if (input.text !== undefined) {
|
|
65
|
+
target = input.text;
|
|
66
|
+
} else if (input.base64) {
|
|
67
|
+
target = Buffer.from(input.base64, 'base64');
|
|
68
|
+
} else if (input.buffer) {
|
|
69
|
+
target = input.buffer;
|
|
70
|
+
} else {
|
|
71
|
+
throw new Error('csv.parse requires text, base64, or buffer');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const data = await parse(target, {
|
|
75
|
+
delimiter: input.delimiter,
|
|
76
|
+
columns: input.columns,
|
|
77
|
+
skip_empty_lines: input.skip_empty_lines,
|
|
78
|
+
trim: input.trim,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
data,
|
|
83
|
+
rowCount: data.length,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
'csv.exportModel': {
|
|
89
|
+
schema: z.object({
|
|
90
|
+
model: z.string().min(1),
|
|
91
|
+
filter: z.record(z.any()).optional().default({}),
|
|
92
|
+
columns: z.array(z.string()).optional(),
|
|
93
|
+
filename: z.string().optional(),
|
|
94
|
+
delimiter: z.string().optional().default(','),
|
|
95
|
+
bom: z.boolean().optional().default(true),
|
|
96
|
+
}),
|
|
97
|
+
handler: async (input, ctx) => {
|
|
98
|
+
const db = ctx.db || options.db;
|
|
99
|
+
if (!db || typeof db.getRepository !== 'function') {
|
|
100
|
+
throw new Error('csv.exportModel requires an active database connection');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const repo = db.getRepository(input.model);
|
|
104
|
+
if (!repo) {
|
|
105
|
+
throw new Error(`Model repository "${input.model}" not found`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let customColumns;
|
|
109
|
+
if (input.columns) {
|
|
110
|
+
customColumns = input.columns.map((c) => ({
|
|
111
|
+
header: c,
|
|
112
|
+
key: c,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const buffer = await fromModel(repo, input.filter, {
|
|
117
|
+
columns: customColumns,
|
|
118
|
+
delimiter: input.delimiter,
|
|
119
|
+
bom: input.bom,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const filename = input.filename || `${input.model.toLowerCase()}_export.csv`;
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
filename: filename.endsWith('.csv') ? filename : `${filename}.csv`,
|
|
126
|
+
csv: buffer.toString('utf8'),
|
|
127
|
+
base64: buffer.toString('base64'),
|
|
128
|
+
size: buffer.length,
|
|
129
|
+
mimeType: CSV_MIME_TYPE,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
module.exports = {
|
|
137
|
+
createCsvServices,
|
|
138
|
+
};
|