opacacms 0.3.17 → 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/admin/webcomponent.js +14 -14
- package/dist/admin.css +1 -1
- 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/core/seeding/auto-seed.d.ts +1 -1
- package/dist/cli/index.js +3 -2
- package/dist/config.d.ts +2 -6
- package/dist/db/adapter.d.ts +1 -1
- package/dist/db/better-sqlite.d.ts +1 -1
- package/dist/db/better-sqlite.js +1633 -39
- package/dist/db/bun-sqlite.js +1627 -37
- package/dist/db/d1.d.ts +1 -1
- package/dist/db/d1.js +2326 -31
- package/dist/db/index.js +29 -4
- package/dist/db/kysely/plugins/draft-swapper.d.ts +2 -2
- package/dist/db/kysely/plugins/i18n-fallback.d.ts +2 -2
- package/dist/db/kysely/plugins/json-flattener.d.ts +2 -2
- package/dist/db/kysely/plugins/virtual-field-resolver.d.ts +2 -2
- package/dist/db/kysely/schema-builder.d.ts +1 -1
- package/dist/db/kysely/snapshot/snapshot-manager.d.ts +1 -1
- package/dist/db/postgres.js +1623 -32
- package/dist/db/sqlite.d.ts +1 -1
- package/dist/db/sqlite.js +1632 -38
- 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/dist/types.d.ts +3 -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
|
@@ -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 };
|
|
@@ -13,7 +13,7 @@ export declare function generateRecord(db: DatabaseAdapter, collection: Collecti
|
|
|
13
13
|
/**
|
|
14
14
|
* Topologically sorts collections based on their dependencies.
|
|
15
15
|
*/
|
|
16
|
-
export declare function sortCollections(collections: Collection[]): Collection[];
|
|
16
|
+
export declare function sortCollections(collections: Collection[] | readonly Collection[]): Collection[];
|
|
17
17
|
/**
|
|
18
18
|
* Seeds the database with mock data.
|
|
19
19
|
*/
|
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
|
});
|
package/dist/config.d.ts
CHANGED
|
@@ -24,11 +24,7 @@ export declare function defineConfig<const TCollections extends readonly Buildab
|
|
|
24
24
|
collections: TCollections;
|
|
25
25
|
globals?: TGlobals;
|
|
26
26
|
}): Omit<OpacaConfig<TResource>, "collections" | "globals"> & {
|
|
27
|
-
collections:
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
globals: {
|
|
31
|
-
[K in keyof TGlobals]: BuiltResource<TGlobals[K]>;
|
|
32
|
-
};
|
|
27
|
+
collections: BuiltResource<TCollections[number]>[];
|
|
28
|
+
globals: BuiltResource<TGlobals[number]>[];
|
|
33
29
|
};
|
|
34
30
|
export {};
|
package/dist/db/adapter.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare abstract class BaseDatabaseAdapter implements DatabaseAdapter {
|
|
|
26
26
|
abstract deleteMany?(collection: string, query: any): Promise<number>;
|
|
27
27
|
abstract findGlobal?<T extends object>(slug: string): Promise<T | null>;
|
|
28
28
|
abstract updateGlobal?<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
29
|
-
abstract migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
29
|
+
abstract migrate(collections: Collection[] | readonly Collection[], globals?: Global[] | readonly Global[]): Promise<void>;
|
|
30
30
|
push?: boolean;
|
|
31
31
|
pushDestructive?: boolean;
|
|
32
32
|
migrationDir?: string;
|
|
@@ -32,7 +32,7 @@ export declare class BetterSQLiteAdapter extends BaseDatabaseAdapter {
|
|
|
32
32
|
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
33
33
|
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
34
34
|
runMigrations(): Promise<void>;
|
|
35
|
-
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
35
|
+
migrate(collections: Collection[] | readonly Collection[], globals?: Global[] | readonly Global[]): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
export declare function createBetterSQLiteAdapter(path: string, options?: {
|
|
38
38
|
push?: boolean;
|