opacacms 0.3.18 → 0.3.19
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/{chunk-1bd7fz7n.js → chunk-8mqs2q7j.js} +1 -1
- package/dist/{chunk-2abqb0h6.js → chunk-9dsw6x4x.js} +23 -16
- package/dist/{chunk-b1g8jmth.js → chunk-mvz5hmdb.js} +263 -8
- package/dist/cli/index.js +3 -2
- package/dist/db/better-sqlite.js +1632 -42
- package/dist/db/bun-sqlite.js +1627 -37
- package/dist/db/d1.js +2326 -31
- package/dist/db/index.js +29 -4
- package/dist/db/postgres.js +1623 -32
- package/dist/db/sqlite.js +1631 -41
- package/dist/index.js +7 -9
- package/dist/runtimes/bun.js +3 -7
- package/dist/runtimes/cloudflare-workers.js +3068 -13
- package/dist/runtimes/next.js +3 -7
- package/dist/runtimes/node.js +3 -7
- package/dist/server.js +18 -13
- package/dist/storage/index.js +6 -3
- package/package.json +1 -1
- package/dist/chunk-40tky6qh.js +0 -10
- package/dist/chunk-5xpf5jxd.js +0 -114
- package/dist/chunk-gzbz5jwy.js +0 -700
- package/dist/chunk-h8v093av.js +0 -185
- package/dist/chunk-jq1drsen.js +0 -82
- package/dist/chunk-q5sb5dcr.js +0 -15
- package/dist/chunk-re459gm9.js +0 -429
- package/dist/chunk-s8mqwnm1.js +0 -14
- package/dist/chunk-z9ek88xr.js +0 -15
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
OpacaLogger,
|
|
2
3
|
createAuth,
|
|
4
|
+
exports_system_schema,
|
|
5
|
+
getSystemCollections,
|
|
6
|
+
init_system_schema,
|
|
7
|
+
logger,
|
|
3
8
|
sanitizeConfig
|
|
4
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-mvz5hmdb.js";
|
|
5
10
|
import {
|
|
6
11
|
sanitizeGraphQLName
|
|
7
12
|
} from "./chunk-2vbfc4q8.js";
|
|
8
|
-
import {
|
|
9
|
-
requestContext
|
|
10
|
-
} from "./chunk-q5sb5dcr.js";
|
|
11
|
-
import {
|
|
12
|
-
toSnakeCase
|
|
13
|
-
} from "./chunk-5xpf5jxd.js";
|
|
14
|
-
import {
|
|
15
|
-
OpacaLogger,
|
|
16
|
-
logger
|
|
17
|
-
} from "./chunk-jq1drsen.js";
|
|
18
|
-
import {
|
|
19
|
-
exports_system_schema,
|
|
20
|
-
getSystemCollections,
|
|
21
|
-
init_system_schema
|
|
22
|
-
} from "./chunk-h8v093av.js";
|
|
23
13
|
import {
|
|
24
14
|
__require,
|
|
25
15
|
__toCommonJS
|
|
@@ -1695,6 +1685,15 @@ function createCorsMiddleware(config) {
|
|
|
1695
1685
|
});
|
|
1696
1686
|
}
|
|
1697
1687
|
|
|
1688
|
+
// src/db/kysely/field-mapper.ts
|
|
1689
|
+
function toSnakeCase(str) {
|
|
1690
|
+
const res = str.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
1691
|
+
if (res.startsWith("_") && !str.startsWith("_")) {
|
|
1692
|
+
return res.slice(1);
|
|
1693
|
+
}
|
|
1694
|
+
return res;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1698
1697
|
// src/auth/migrations.ts
|
|
1699
1698
|
init_system_schema();
|
|
1700
1699
|
async function runAuthMigrations(db) {
|
|
@@ -1870,6 +1869,14 @@ function createRateLimitMiddleware(config) {
|
|
|
1870
1869
|
};
|
|
1871
1870
|
}
|
|
1872
1871
|
|
|
1872
|
+
// src/utils/context.ts
|
|
1873
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1874
|
+
var GLOBAL_CONTEXT_KEY = Symbol.for("opacacms.requestContext");
|
|
1875
|
+
if (!globalThis[GLOBAL_CONTEXT_KEY]) {
|
|
1876
|
+
globalThis[GLOBAL_CONTEXT_KEY] = new AsyncLocalStorage;
|
|
1877
|
+
}
|
|
1878
|
+
var requestContext = globalThis[GLOBAL_CONTEXT_KEY];
|
|
1879
|
+
|
|
1873
1880
|
// src/server/setup-middlewares.ts
|
|
1874
1881
|
function setupMiddlewares(router, config, state) {
|
|
1875
1882
|
router.use("*", async (c, next) => {
|
|
@@ -3,16 +3,190 @@ import {
|
|
|
3
3
|
init_compiler
|
|
4
4
|
} from "./chunk-hthm9srb.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
getSystemCollections,
|
|
10
|
-
init_system_schema
|
|
11
|
-
} from "./chunk-h8v093av.js";
|
|
12
|
-
import {
|
|
6
|
+
__esm,
|
|
7
|
+
__export,
|
|
13
8
|
__toCommonJS
|
|
14
9
|
} from "./chunk-8sqjbsgt.js";
|
|
15
10
|
|
|
11
|
+
// src/db/system-schema.ts
|
|
12
|
+
var exports_system_schema = {};
|
|
13
|
+
__export(exports_system_schema, {
|
|
14
|
+
getSystemCollections: () => getSystemCollections
|
|
15
|
+
});
|
|
16
|
+
var getSystemCollections = () => [
|
|
17
|
+
{
|
|
18
|
+
slug: "_assets",
|
|
19
|
+
label: "Assets",
|
|
20
|
+
apiPath: "assets",
|
|
21
|
+
fields: [
|
|
22
|
+
{ name: "id", type: "text", required: true },
|
|
23
|
+
{ name: "key", type: "text", required: true },
|
|
24
|
+
{ name: "filename", type: "text", required: true },
|
|
25
|
+
{ name: "originalFilename", type: "text", required: true },
|
|
26
|
+
{ name: "mimeType", type: "text", required: true },
|
|
27
|
+
{ name: "filesize", type: "number", required: true },
|
|
28
|
+
{ name: "bucket", type: "text", required: true },
|
|
29
|
+
{ name: "folder", type: "text" },
|
|
30
|
+
{ name: "altText", type: "text" },
|
|
31
|
+
{ name: "caption", type: "text" },
|
|
32
|
+
{ name: "uploadedBy", type: "text" }
|
|
33
|
+
],
|
|
34
|
+
timestamps: true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
slug: "_users",
|
|
38
|
+
apiPath: "users",
|
|
39
|
+
fields: [
|
|
40
|
+
{ name: "id", type: "text", required: true },
|
|
41
|
+
{ name: "name", type: "text", required: true },
|
|
42
|
+
{ name: "email", type: "text", required: true, unique: true },
|
|
43
|
+
{ name: "emailVerified", type: "boolean", required: true, defaultValue: false },
|
|
44
|
+
{ name: "image", type: "text" },
|
|
45
|
+
{ name: "role", type: "text" },
|
|
46
|
+
{ name: "banned", type: "boolean" },
|
|
47
|
+
{ name: "banReason", type: "text" },
|
|
48
|
+
{ name: "banExpires", type: "date" }
|
|
49
|
+
],
|
|
50
|
+
timestamps: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
slug: "_sessions",
|
|
54
|
+
fields: [
|
|
55
|
+
{ name: "id", type: "text", required: true },
|
|
56
|
+
{ name: "expiresAt", type: "date", required: true },
|
|
57
|
+
{ name: "token", type: "text", required: true, unique: true },
|
|
58
|
+
{ name: "ipAddress", type: "text" },
|
|
59
|
+
{ name: "userAgent", type: "text" },
|
|
60
|
+
{
|
|
61
|
+
name: "userId",
|
|
62
|
+
type: "text",
|
|
63
|
+
required: true,
|
|
64
|
+
references: { table: "_users", column: "id", onDelete: "cascade" }
|
|
65
|
+
},
|
|
66
|
+
{ name: "impersonatedBy", type: "text" }
|
|
67
|
+
],
|
|
68
|
+
timestamps: true,
|
|
69
|
+
hidden: true
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
slug: "_accounts",
|
|
73
|
+
fields: [
|
|
74
|
+
{ name: "id", type: "text", required: true },
|
|
75
|
+
{ name: "accountId", type: "text", required: true },
|
|
76
|
+
{ name: "providerId", type: "text", required: true },
|
|
77
|
+
{
|
|
78
|
+
name: "userId",
|
|
79
|
+
type: "text",
|
|
80
|
+
required: true,
|
|
81
|
+
references: { table: "_users", column: "id", onDelete: "cascade" }
|
|
82
|
+
},
|
|
83
|
+
{ name: "accessToken", type: "text" },
|
|
84
|
+
{ name: "refreshToken", type: "text" },
|
|
85
|
+
{ name: "idToken", type: "text" },
|
|
86
|
+
{ name: "accessTokenExpiresAt", type: "date" },
|
|
87
|
+
{ name: "refreshTokenExpiresAt", type: "date" },
|
|
88
|
+
{ name: "scope", type: "text" },
|
|
89
|
+
{ name: "password", type: "text" }
|
|
90
|
+
],
|
|
91
|
+
timestamps: true,
|
|
92
|
+
hidden: true
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
slug: "_verifications",
|
|
96
|
+
fields: [
|
|
97
|
+
{ name: "id", type: "text", required: true },
|
|
98
|
+
{ name: "identifier", type: "text", required: true },
|
|
99
|
+
{ name: "value", type: "text", required: true },
|
|
100
|
+
{ name: "expiresAt", type: "date", required: true }
|
|
101
|
+
],
|
|
102
|
+
timestamps: true,
|
|
103
|
+
hidden: true
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
slug: "_api_keys",
|
|
107
|
+
fields: [
|
|
108
|
+
{ name: "id", type: "text", required: true },
|
|
109
|
+
{ name: "configId", type: "text", required: true },
|
|
110
|
+
{ name: "name", type: "text" },
|
|
111
|
+
{ name: "start", type: "text" },
|
|
112
|
+
{ name: "prefix", type: "text" },
|
|
113
|
+
{ name: "key", type: "text", required: true },
|
|
114
|
+
{ name: "referenceId", type: "text", required: true },
|
|
115
|
+
{ name: "refillInterval", type: "number" },
|
|
116
|
+
{ name: "refillAmount", type: "number" },
|
|
117
|
+
{ name: "lastRefillAt", type: "date" },
|
|
118
|
+
{ name: "enabled", type: "boolean", required: true },
|
|
119
|
+
{ name: "rateLimitEnabled", type: "boolean", required: true },
|
|
120
|
+
{ name: "rateLimitTimeWindow", type: "number" },
|
|
121
|
+
{ name: "rateLimitMax", type: "number" },
|
|
122
|
+
{ name: "requestCount", type: "number", required: true },
|
|
123
|
+
{ name: "remaining", type: "number" },
|
|
124
|
+
{ name: "lastRequest", type: "date" },
|
|
125
|
+
{ name: "expiresAt", type: "date" },
|
|
126
|
+
{ name: "permissions", type: "text" },
|
|
127
|
+
{ name: "metadata", type: "text" }
|
|
128
|
+
],
|
|
129
|
+
timestamps: { createdAt: "createdAt", updatedAt: "updatedAt" },
|
|
130
|
+
hidden: true
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
slug: "_plugin_settings",
|
|
134
|
+
label: "Plugin Settings",
|
|
135
|
+
apiPath: "plugin-settings",
|
|
136
|
+
fields: [
|
|
137
|
+
{ name: "pluginName", type: "text", required: true, unique: true },
|
|
138
|
+
{ name: "config", type: "json", required: true }
|
|
139
|
+
],
|
|
140
|
+
timestamps: true,
|
|
141
|
+
hidden: false,
|
|
142
|
+
admin: {
|
|
143
|
+
hidden: true,
|
|
144
|
+
disableAdmin: true
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
slug: "_audit_logs",
|
|
149
|
+
label: "Audit Logs",
|
|
150
|
+
apiPath: "audit-logs",
|
|
151
|
+
fields: [
|
|
152
|
+
{ name: "id", type: "text", required: true },
|
|
153
|
+
{ name: "operation", type: "text", required: true },
|
|
154
|
+
{ name: "collection", type: "text", required: true },
|
|
155
|
+
{ name: "entity_id", type: "text", required: true },
|
|
156
|
+
{ name: "user_id", type: "text" },
|
|
157
|
+
{ name: "previous_data", type: "json" },
|
|
158
|
+
{ name: "new_data", type: "json" },
|
|
159
|
+
{ name: "timestamp", type: "date" }
|
|
160
|
+
],
|
|
161
|
+
timestamps: true,
|
|
162
|
+
admin: {
|
|
163
|
+
hidden: true,
|
|
164
|
+
disableAdmin: true
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
slug: "_doc_versions",
|
|
169
|
+
label: "Document Versions",
|
|
170
|
+
apiPath: "doc-versions",
|
|
171
|
+
fields: [
|
|
172
|
+
{ name: "id", type: "text", required: true },
|
|
173
|
+
{ name: "collection", type: "text", required: true },
|
|
174
|
+
{ name: "entity_id", type: "text", required: true },
|
|
175
|
+
{ name: "data", type: "json", required: true },
|
|
176
|
+
{ name: "status", type: "text" },
|
|
177
|
+
{ name: "autosave", type: "boolean", defaultValue: false },
|
|
178
|
+
{ name: "version_name", type: "text" },
|
|
179
|
+
{ name: "created_by", type: "text" }
|
|
180
|
+
],
|
|
181
|
+
timestamps: true,
|
|
182
|
+
admin: {
|
|
183
|
+
hidden: true,
|
|
184
|
+
disableAdmin: true
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
var init_system_schema = () => {};
|
|
189
|
+
|
|
16
190
|
// src/auth/index.ts
|
|
17
191
|
import { apiKey } from "@better-auth/api-key";
|
|
18
192
|
import { betterAuth } from "better-auth";
|
|
@@ -52,6 +226,87 @@ function createPermissions(config) {
|
|
|
52
226
|
};
|
|
53
227
|
}
|
|
54
228
|
|
|
229
|
+
// src/utils/logger.ts
|
|
230
|
+
var RESET = "\x1B[0m";
|
|
231
|
+
var BOLD = "\x1B[1m";
|
|
232
|
+
var BLUE = "\x1B[34m";
|
|
233
|
+
var GREEN = "\x1B[32m";
|
|
234
|
+
var YELLOW = "\x1B[33m";
|
|
235
|
+
var RED = "\x1B[31m";
|
|
236
|
+
var GRAY = "\x1B[90m";
|
|
237
|
+
var PREFIX = `${BLUE}${BOLD}[OpacaCMS]${RESET}`;
|
|
238
|
+
var LOG_LEVELS = {
|
|
239
|
+
debug: 0,
|
|
240
|
+
info: 1,
|
|
241
|
+
warn: 2,
|
|
242
|
+
error: 3
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
class OpacaLogger {
|
|
246
|
+
config;
|
|
247
|
+
constructor(config = {}) {
|
|
248
|
+
this.config = config;
|
|
249
|
+
}
|
|
250
|
+
shouldLog(level) {
|
|
251
|
+
if (this.config.disabled)
|
|
252
|
+
return false;
|
|
253
|
+
const configLevel = this.config.level || "info";
|
|
254
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[configLevel];
|
|
255
|
+
}
|
|
256
|
+
info(message, ...args) {
|
|
257
|
+
if (!this.shouldLog("info"))
|
|
258
|
+
return;
|
|
259
|
+
console.log(`${PREFIX} ${message}`, ...args);
|
|
260
|
+
}
|
|
261
|
+
success(message, ...args) {
|
|
262
|
+
if (!this.shouldLog("info"))
|
|
263
|
+
return;
|
|
264
|
+
console.log(`${PREFIX} ${GREEN}${message}${RESET}`, ...args);
|
|
265
|
+
}
|
|
266
|
+
debug(message, ...args) {
|
|
267
|
+
if (!this.shouldLog("debug"))
|
|
268
|
+
return;
|
|
269
|
+
console.log(`${PREFIX} ${GRAY}${message}${RESET}`, ...args);
|
|
270
|
+
}
|
|
271
|
+
warn(message, ...args) {
|
|
272
|
+
if (!this.shouldLog("warn"))
|
|
273
|
+
return;
|
|
274
|
+
console.warn(`${PREFIX} ${YELLOW}Warning: ${message}${RESET}`, ...args);
|
|
275
|
+
}
|
|
276
|
+
error(message, ...args) {
|
|
277
|
+
if (!this.shouldLog("error"))
|
|
278
|
+
return;
|
|
279
|
+
console.error(`${PREFIX} ${RED}Error: ${message}${RESET}`, ...args);
|
|
280
|
+
}
|
|
281
|
+
log(message, ...args) {
|
|
282
|
+
if (this.config.disabled)
|
|
283
|
+
return;
|
|
284
|
+
console.log(message, ...args);
|
|
285
|
+
}
|
|
286
|
+
bold(msg) {
|
|
287
|
+
if (this.config.disableColors)
|
|
288
|
+
return msg;
|
|
289
|
+
return `${BOLD}${msg}${RESET}`;
|
|
290
|
+
}
|
|
291
|
+
format(color, msg) {
|
|
292
|
+
if (this.config.disableColors)
|
|
293
|
+
return msg;
|
|
294
|
+
switch (color) {
|
|
295
|
+
case "green":
|
|
296
|
+
return `${GREEN}${msg}${RESET}`;
|
|
297
|
+
case "red":
|
|
298
|
+
return `${RED}${msg}${RESET}`;
|
|
299
|
+
case "yellow":
|
|
300
|
+
return `${YELLOW}${msg}${RESET}`;
|
|
301
|
+
case "gray":
|
|
302
|
+
return `${GRAY}${msg}${RESET}`;
|
|
303
|
+
default:
|
|
304
|
+
return msg;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
var logger = new OpacaLogger;
|
|
309
|
+
|
|
55
310
|
// src/auth/index.ts
|
|
56
311
|
async function createAuth(config) {
|
|
57
312
|
const env = typeof process !== "undefined" ? process.env : {};
|
|
@@ -302,4 +557,4 @@ function sanitizeConfig(config, settings = {}) {
|
|
|
302
557
|
};
|
|
303
558
|
}
|
|
304
559
|
|
|
305
|
-
export { createAuth, sanitizeConfig };
|
|
560
|
+
export { OpacaLogger, logger, createAuth, getSystemCollections, exports_system_schema, init_system_schema, sanitizeConfig };
|
package/dist/cli/index.js
CHANGED
|
@@ -6865,7 +6865,7 @@ function resolveConfigPath(explicitPath) {
|
|
|
6865
6865
|
}
|
|
6866
6866
|
return configPath;
|
|
6867
6867
|
}
|
|
6868
|
-
var mainCommand;
|
|
6868
|
+
var mainCommand, isMain;
|
|
6869
6869
|
var init_cli = __esm(() => {
|
|
6870
6870
|
init_dist();
|
|
6871
6871
|
mainCommand = defineCommand({
|
|
@@ -6891,7 +6891,8 @@ var init_cli = __esm(() => {
|
|
|
6891
6891
|
dev: () => Promise.resolve().then(() => (init_dev(), exports_dev)).then((m2) => m2.default)
|
|
6892
6892
|
}
|
|
6893
6893
|
});
|
|
6894
|
-
|
|
6894
|
+
isMain = __require.main == __require.module;
|
|
6895
|
+
if (isMain) {
|
|
6895
6896
|
runMain(mainCommand);
|
|
6896
6897
|
}
|
|
6897
6898
|
});
|