opacacms 0.3.1 → 0.3.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.
Files changed (59) hide show
  1. package/dist/admin/auth-client.d.ts +41 -41
  2. package/dist/admin/index.js +1 -1
  3. package/dist/admin/react.js +1 -1
  4. package/dist/admin/vue.js +1 -1
  5. package/dist/auth/index.d.ts +43 -48
  6. package/dist/{chunk-g9bxb6h0.js → chunk-2fm4kv2q.js} +1 -1
  7. package/dist/chunk-2vbfc4q8.js +6 -0
  8. package/dist/{chunk-adq2b75c.js → chunk-40tky6qh.js} +2 -2
  9. package/dist/{chunk-e0g6gn7n.js → chunk-49e16hjg.js} +3 -3
  10. package/dist/{chunk-fnsf1dfm.js → chunk-526a3gqx.js} +1 -1
  11. package/dist/{chunk-sqsfk9p4.js → chunk-6m1jhxmd.js} +1 -1
  12. package/dist/{chunk-6bywt602.js → chunk-8sqjbsgt.js} +1 -26
  13. package/dist/{chunk-n1twhqmf.js → chunk-acghejk8.js} +1 -1
  14. package/dist/{chunk-m24yqkeq.js → chunk-b1g8jmth.js} +3 -3
  15. package/dist/{chunk-5422w4eq.js → chunk-cm5rvcnn.js} +5 -5
  16. package/dist/{chunk-941zxavt.js → chunk-h2y2t07h.js} +4 -4
  17. package/dist/{chunk-6qs0g65f.js → chunk-h8v093av.js} +1 -1
  18. package/dist/{chunk-m5ems3hh.js → chunk-hthm9srb.js} +1 -1
  19. package/dist/{chunk-2k3ysje3.js → chunk-nch158fe.js} +1 -1
  20. package/dist/{chunk-naqcqj8n.js → chunk-pj31j6j0.js} +4 -4
  21. package/dist/{chunk-qsh2nqz3.js → chunk-pw2a9war.js} +3 -3
  22. package/dist/{chunk-j8js1y0h.js → chunk-r5k7jw66.js} +1 -1
  23. package/dist/{chunk-48ywpd0a.js → chunk-vmz9ncf1.js} +1 -1
  24. package/dist/{chunk-qhdsjek6.js → chunk-wry3rqh0.js} +3 -3
  25. package/dist/cli/commands/init.d.ts +1 -6
  26. package/dist/cli/index.js +6793 -6
  27. package/dist/client.js +3 -3
  28. package/dist/db/better-sqlite.js +4 -4
  29. package/dist/db/bun-sqlite.js +4 -4
  30. package/dist/db/d1.js +4 -4
  31. package/dist/db/index.js +8 -8
  32. package/dist/db/postgres.js +4 -4
  33. package/dist/db/sqlite.js +4 -4
  34. package/dist/index.js +7 -7
  35. package/dist/runtimes/bun.js +6 -6
  36. package/dist/runtimes/cloudflare-workers.js +6 -6
  37. package/dist/runtimes/next.js +6 -6
  38. package/dist/runtimes/node.js +6 -6
  39. package/dist/schema/index.js +3 -3
  40. package/dist/server.js +6 -6
  41. package/dist/storage/index.js +1 -1
  42. package/package.json +4 -2
  43. package/dist/chunk-1qm0m8r8.js +0 -413
  44. package/dist/chunk-3j9zjfmn.js +0 -376
  45. package/dist/chunk-56n342hs.js +0 -95
  46. package/dist/chunk-5b8r0v8c.js +0 -47
  47. package/dist/chunk-63yg00vx.js +0 -263
  48. package/dist/chunk-7rr5p01g.js +0 -581
  49. package/dist/chunk-d0tb1xjw.js +0 -93
  50. package/dist/chunk-d7cgd6vn.js +0 -318
  51. package/dist/chunk-ec4jhybj.js +0 -1137
  52. package/dist/chunk-fatyf6f7.js +0 -221
  53. package/dist/chunk-gyaf5kgf.js +0 -10
  54. package/dist/chunk-h6dhexzr.js +0 -94
  55. package/dist/chunk-majsbncm.js +0 -98
  56. package/dist/chunk-mp2gt9yh.js +0 -237
  57. package/dist/chunk-r0ms5tk1.js +0 -76
  58. package/dist/chunk-rwqwsanx.js +0 -75
  59. package/dist/chunk-x7bnzswh.js +0 -174
@@ -1,76 +0,0 @@
1
- import {
2
- require_picocolors
3
- } from "./chunk-rwqwsanx.js";
4
- import {
5
- Gt,
6
- R,
7
- Vt,
8
- Wt
9
- } from "./chunk-ec4jhybj.js";
10
- import {
11
- defineCommand
12
- } from "./chunk-1qm0m8r8.js";
13
- import {
14
- __toESM
15
- } from "./chunk-6bywt602.js";
16
-
17
- // src/cli/commands/dev.ts
18
- import { spawn } from "node:child_process";
19
- import fs from "node:fs";
20
- import { resolve } from "node:path";
21
- var import_picocolors = __toESM(require_picocolors(), 1);
22
- var dev_default = defineCommand({
23
- meta: {
24
- name: "dev",
25
- description: "Start the OpacaCMS development server"
26
- },
27
- args: {
28
- entry: {
29
- type: "string",
30
- description: "Path to your entry point (default: index.ts)",
31
- default: "index.ts"
32
- }
33
- },
34
- async run({ args }) {
35
- console.log();
36
- Wt(import_picocolors.default.bgBlue(import_picocolors.default.white(" OpacaCMS Dev Server ")));
37
- const entryPath = resolve(process.cwd(), args.entry);
38
- if (!fs.existsSync(entryPath)) {
39
- R.error(import_picocolors.default.red(`Entry file not found at ${entryPath}`));
40
- R.info("Try specifying the entry file: opacacms dev --entry src/index.ts");
41
- process.exit(1);
42
- }
43
- Vt(`Watching for changes...`, "Status");
44
- const isD1 = fs.readFileSync(entryPath, "utf-8").includes("createCloudflareWorkersHandler");
45
- let cmd = "bun";
46
- let cmdArgs = ["run", "--watch", args.entry];
47
- if (isD1) {
48
- cmd = "bun";
49
- cmdArgs = ["x", "wrangler", "dev", args.entry];
50
- }
51
- const child = spawn(cmd, cmdArgs, {
52
- stdio: "inherit",
53
- cwd: process.cwd(),
54
- env: process.env
55
- });
56
- child.on("error", (err) => {
57
- R.error(import_picocolors.default.red(`Failed to start server: ${err.message}`));
58
- });
59
- child.on("exit", (code) => {
60
- if (code !== 0) {
61
- R.warn(`Server exited with code ${code}`);
62
- }
63
- Gt("Goodbye!");
64
- process.exit(code || 0);
65
- });
66
- process.on("SIGINT", () => {
67
- child.kill("SIGINT");
68
- });
69
- process.on("SIGTERM", () => {
70
- child.kill("SIGTERM");
71
- });
72
- }
73
- });
74
- export {
75
- dev_default as default
76
- };
@@ -1,75 +0,0 @@
1
- import {
2
- __commonJS
3
- } from "./chunk-6bywt602.js";
4
-
5
- // ../../node_modules/picocolors/picocolors.js
6
- var require_picocolors = __commonJS((exports, module) => {
7
- var p = process || {};
8
- var argv = p.argv || [];
9
- var env = p.env || {};
10
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
11
- var formatter = (open, close, replace = open) => (input) => {
12
- let string = "" + input, index = string.indexOf(close, open.length);
13
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
14
- };
15
- var replaceClose = (string, close, replace, index) => {
16
- let result = "", cursor = 0;
17
- do {
18
- result += string.substring(cursor, index) + replace;
19
- cursor = index + close.length;
20
- index = string.indexOf(close, cursor);
21
- } while (~index);
22
- return result + string.substring(cursor);
23
- };
24
- var createColors = (enabled = isColorSupported) => {
25
- let f = enabled ? formatter : () => String;
26
- return {
27
- isColorSupported: enabled,
28
- reset: f("\x1B[0m", "\x1B[0m"),
29
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
30
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
31
- italic: f("\x1B[3m", "\x1B[23m"),
32
- underline: f("\x1B[4m", "\x1B[24m"),
33
- inverse: f("\x1B[7m", "\x1B[27m"),
34
- hidden: f("\x1B[8m", "\x1B[28m"),
35
- strikethrough: f("\x1B[9m", "\x1B[29m"),
36
- black: f("\x1B[30m", "\x1B[39m"),
37
- red: f("\x1B[31m", "\x1B[39m"),
38
- green: f("\x1B[32m", "\x1B[39m"),
39
- yellow: f("\x1B[33m", "\x1B[39m"),
40
- blue: f("\x1B[34m", "\x1B[39m"),
41
- magenta: f("\x1B[35m", "\x1B[39m"),
42
- cyan: f("\x1B[36m", "\x1B[39m"),
43
- white: f("\x1B[37m", "\x1B[39m"),
44
- gray: f("\x1B[90m", "\x1B[39m"),
45
- bgBlack: f("\x1B[40m", "\x1B[49m"),
46
- bgRed: f("\x1B[41m", "\x1B[49m"),
47
- bgGreen: f("\x1B[42m", "\x1B[49m"),
48
- bgYellow: f("\x1B[43m", "\x1B[49m"),
49
- bgBlue: f("\x1B[44m", "\x1B[49m"),
50
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
51
- bgCyan: f("\x1B[46m", "\x1B[49m"),
52
- bgWhite: f("\x1B[47m", "\x1B[49m"),
53
- blackBright: f("\x1B[90m", "\x1B[39m"),
54
- redBright: f("\x1B[91m", "\x1B[39m"),
55
- greenBright: f("\x1B[92m", "\x1B[39m"),
56
- yellowBright: f("\x1B[93m", "\x1B[39m"),
57
- blueBright: f("\x1B[94m", "\x1B[39m"),
58
- magentaBright: f("\x1B[95m", "\x1B[39m"),
59
- cyanBright: f("\x1B[96m", "\x1B[39m"),
60
- whiteBright: f("\x1B[97m", "\x1B[39m"),
61
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
62
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
63
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
64
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
65
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
66
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
67
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
68
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
69
- };
70
- };
71
- module.exports = createColors();
72
- module.exports.createColors = createColors;
73
- });
74
-
75
- export { require_picocolors };
@@ -1,174 +0,0 @@
1
- import"./chunk-6bywt602.js";
2
-
3
- // src/cli/core/mocks/r2-mock.ts
4
- import { Database } from "bun:sqlite";
5
- import crypto from "node:crypto";
6
- import fs from "node:fs";
7
- import path from "node:path";
8
- function createR2Mock(dbPath) {
9
- let sqlite;
10
- let blobsDir;
11
- let finalDbPath;
12
- const wranglerR2Dir = path.resolve(process.cwd(), ".wrangler/state/v3/r2/miniflare-R2BucketObject");
13
- if (!dbPath && fs.existsSync(wranglerR2Dir)) {
14
- const files = fs.readdirSync(wranglerR2Dir);
15
- const sqliteFile = files.find((f) => f.endsWith(".sqlite"));
16
- if (sqliteFile) {
17
- finalDbPath = path.join(wranglerR2Dir, sqliteFile);
18
- console.log(`[OpacaCMS] Using Wrangler R2 local state: ${sqliteFile}`);
19
- }
20
- }
21
- if (!finalDbPath) {
22
- if (!dbPath) {
23
- finalDbPath = ":memory:";
24
- console.log("[OpacaCMS] Using in-memory R2 mock");
25
- } else {
26
- const absolutePath = path.isAbsolute(dbPath) ? dbPath : path.resolve(process.cwd(), dbPath);
27
- if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory()) {
28
- finalDbPath = path.join(absolutePath, "mock-bucket.sqlite");
29
- } else if (!absolutePath.endsWith(".sqlite")) {
30
- finalDbPath = absolutePath.endsWith("/") ? path.join(absolutePath, "mock-bucket.sqlite") : absolutePath + ".sqlite";
31
- } else {
32
- finalDbPath = absolutePath;
33
- }
34
- console.log(`[OpacaCMS] Using local R2 mock: ${path.basename(finalDbPath)}`);
35
- }
36
- }
37
- if (finalDbPath !== ":memory:") {
38
- const dir = path.dirname(finalDbPath);
39
- if (!fs.existsSync(dir)) {
40
- fs.mkdirSync(dir, { recursive: true });
41
- }
42
- blobsDir = finalDbPath.replace(".sqlite", ".blobs");
43
- if (!fs.existsSync(blobsDir)) {
44
- fs.mkdirSync(blobsDir, { recursive: true });
45
- }
46
- } else {
47
- blobsDir = path.join(fs.realpathSync("/tmp"), `opaca-blobs-${crypto.randomUUID()}`);
48
- }
49
- try {
50
- sqlite = new Database(finalDbPath);
51
- } catch (err) {
52
- throw new Error(`Failed to open R2 mock database at ${finalDbPath}: ${err.message}`);
53
- }
54
- sqlite.exec(`
55
- CREATE TABLE IF NOT EXISTS _mf_objects (
56
- key TEXT PRIMARY KEY,
57
- blob_id TEXT,
58
- version TEXT,
59
- size INTEGER,
60
- etag TEXT,
61
- uploaded INTEGER,
62
- checksums TEXT,
63
- http_metadata TEXT,
64
- custom_metadata TEXT
65
- )
66
- `);
67
- const getBlobPath = (blobId) => path.join(blobsDir, blobId);
68
- return {
69
- async put(key, value, options) {
70
- const blobId = crypto.randomUUID();
71
- const filePath = getBlobPath(blobId);
72
- const buffer = value instanceof Uint8Array ? value : value instanceof ArrayBuffer ? new Uint8Array(value) : typeof value === "string" || value instanceof Buffer ? Buffer.from(value) : new Uint8Array(await value.arrayBuffer());
73
- fs.writeFileSync(filePath, buffer);
74
- const etag = crypto.createHash("md5").update(buffer).digest("hex");
75
- const uploaded = Date.now();
76
- const size = buffer.length;
77
- const httpMetadataObj = {};
78
- if (options?.httpMetadata?.contentType) {
79
- httpMetadataObj.contentType = options.httpMetadata.contentType;
80
- }
81
- const customMetadataObj = { ...options?.customMetadata };
82
- if (options?.customMetadata?.sourceUrl) {
83
- customMetadataObj.sourceUrl = options.customMetadata.sourceUrl;
84
- }
85
- const httpMetadata = JSON.stringify(httpMetadataObj);
86
- const customMetadata = JSON.stringify(customMetadataObj);
87
- sqlite.prepare(`
88
- INSERT OR REPLACE INTO _mf_objects
89
- (key, blob_id, version, size, etag, uploaded, checksums, http_metadata, custom_metadata)
90
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
91
- `).run(key, blobId, "v1", size, etag, uploaded, "{}", httpMetadata, customMetadata);
92
- return {
93
- key,
94
- size,
95
- etag,
96
- httpMetadata: options?.httpMetadata || {},
97
- customMetadata: options?.customMetadata || {}
98
- };
99
- },
100
- async get(key) {
101
- const row = sqlite.prepare("SELECT * FROM _mf_objects WHERE key = ?").get(key);
102
- if (!row)
103
- return null;
104
- const filePath = getBlobPath(row.blob_id);
105
- if (!fs.existsSync(filePath))
106
- return null;
107
- const buffer = fs.readFileSync(filePath);
108
- const stream = new ReadableStream({
109
- start(controller) {
110
- controller.enqueue(new Uint8Array(buffer));
111
- controller.close();
112
- }
113
- });
114
- return {
115
- key: row.key,
116
- size: row.size,
117
- etag: row.etag,
118
- uploaded: new Date(row.uploaded),
119
- httpMetadata: JSON.parse(row.http_metadata || "{}"),
120
- customMetadata: JSON.parse(row.custom_metadata || "{}"),
121
- body: stream,
122
- bodyUsed: false,
123
- async arrayBuffer() {
124
- return buffer.buffer;
125
- },
126
- async text() {
127
- return buffer.toString();
128
- },
129
- async json() {
130
- return JSON.parse(buffer.toString());
131
- }
132
- };
133
- },
134
- async head(key) {
135
- const row = sqlite.prepare("SELECT key, size, etag, http_metadata, custom_metadata, uploaded FROM _mf_objects WHERE key = ?").get(key);
136
- if (!row)
137
- return null;
138
- return {
139
- key: row.key,
140
- size: row.size,
141
- etag: row.etag,
142
- uploaded: new Date(row.uploaded),
143
- httpMetadata: JSON.parse(row.http_metadata || "{}"),
144
- customMetadata: JSON.parse(row.custom_metadata || "{}")
145
- };
146
- },
147
- async delete(key) {
148
- const row = sqlite.prepare("SELECT blob_id FROM _mf_objects WHERE key = ?").get(key);
149
- if (row) {
150
- const filePath = getBlobPath(row.blob_id);
151
- if (fs.existsSync(filePath))
152
- fs.unlinkSync(filePath);
153
- sqlite.prepare("DELETE FROM _mf_objects WHERE key = ?").run(key);
154
- }
155
- },
156
- async list() {
157
- const rows = sqlite.prepare("SELECT * FROM _mf_objects").all();
158
- return {
159
- objects: rows.map((row) => ({
160
- key: row.key,
161
- size: row.size,
162
- etag: row.etag,
163
- uploaded: new Date(row.uploaded),
164
- httpMetadata: JSON.parse(row.http_metadata || "{}"),
165
- customMetadata: JSON.parse(row.custom_metadata || "{}")
166
- })),
167
- truncated: false
168
- };
169
- }
170
- };
171
- }
172
- export {
173
- createR2Mock
174
- };