opacacms 0.2.1 → 0.3.1
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/README.md +31 -22
- package/dist/admin/auth-client.d.ts +39 -39
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +15 -10520
- package/dist/admin/plugin-client.d.ts +65 -0
- package/dist/admin/react.d.ts +2 -2
- package/dist/admin/react.js +34 -4
- package/dist/admin/stores/ui.d.ts +19 -4
- package/dist/admin/ui/components/PluginSettingsForm.d.ts +2 -2
- package/dist/admin/ui/components/custom-alert.d.ts +7 -0
- package/dist/admin/ui/components/{DetailSheet.d.ts → detail-sheet.d.ts} +1 -2
- package/dist/admin/ui/components/fields/FieldLabel.d.ts +1 -1
- package/dist/admin/ui/components/fields/RelationshipField.d.ts +1 -1
- package/dist/admin/ui/components/media/AssetManagerModal.d.ts +2 -2
- package/dist/admin/ui/components/plugin-iframe.d.ts +7 -0
- package/dist/admin/ui/components/ui/accordion.d.ts +17 -7
- package/dist/admin/ui/components/ui/alert-dialog.d.ts +16 -12
- package/dist/admin/ui/components/ui/button.d.ts +11 -7
- package/dist/admin/ui/components/ui/relationship.d.ts +1 -1
- package/dist/admin/ui/components/ui/sheet.d.ts +14 -27
- package/dist/admin/ui/components/ui/tooltip.d.ts +7 -0
- package/dist/admin/ui/components/versions-sheet.d.ts +4 -5
- package/dist/admin/ui/views/collection-list-view.d.ts +1 -1
- package/dist/admin/ui/views/dashboard-view.d.ts +1 -1
- package/dist/admin/ui/views/media-registry-view.d.ts +3 -3
- package/dist/admin/ui/views/settings-view.d.ts +2 -2
- package/dist/admin/vue.js +27 -4
- package/dist/admin/webcomponent.js +66 -16
- package/dist/admin.css +1 -1
- package/dist/auth/index.d.ts +43 -43
- package/dist/{chunk-7y1nbmw6.js → chunk-1bd7fz7n.js} +32 -2
- package/dist/chunk-1qm0m8r8.js +413 -0
- package/dist/chunk-2k3ysje3.js +31 -0
- package/dist/{chunk-jdfw4v3r.js → chunk-3j9zjfmn.js} +95 -30
- package/dist/{chunk-byq8g0rd.js → chunk-48ywpd0a.js} +16 -22
- package/dist/{chunk-tfnaf41w.js → chunk-5422w4eq.js} +41 -25
- package/dist/chunk-56n342hs.js +95 -0
- package/dist/chunk-5b8r0v8c.js +47 -0
- package/dist/chunk-63yg00vx.js +263 -0
- package/dist/{chunk-8sqjbsgt.js → chunk-6bywt602.js} +26 -1
- package/dist/{chunk-v9z61v3g.js → chunk-6qs0g65f.js} +43 -3
- package/dist/chunk-7rr5p01g.js +581 -0
- package/dist/{chunk-2es275xs.js → chunk-941zxavt.js} +867 -322
- package/dist/{chunk-51z3x7kq.js → chunk-a3qae86h.js} +1 -1
- package/dist/{chunk-3rdhbedb.js → chunk-adq2b75c.js} +2 -2
- package/dist/chunk-d0tb1xjw.js +93 -0
- package/dist/chunk-d7cgd6vn.js +318 -0
- package/dist/{chunk-6d1vdfwa.js → chunk-e0g6gn7n.js} +54 -75
- package/dist/chunk-ec4jhybj.js +1137 -0
- package/dist/chunk-fatyf6f7.js +221 -0
- package/dist/{chunk-526a3gqx.js → chunk-fnsf1dfm.js} +1 -1
- package/dist/chunk-g9bxb6h0.js +205 -0
- package/dist/chunk-gyaf5kgf.js +10 -0
- package/dist/{chunk-9kxpbcb1.js → chunk-h6dhexzr.js} +16 -7
- package/dist/{chunk-dykn5hr6.js → chunk-j8js1y0h.js} +31 -74
- package/dist/{chunk-t0zg026p.js → chunk-jq1drsen.js} +12 -1
- package/dist/{chunk-b3kr8w41.js → chunk-m24yqkeq.js} +38 -26
- package/dist/chunk-m5ems3hh.js +410 -0
- package/dist/{chunk-8scgdznr.js → chunk-m83ybzf8.js} +15 -18
- package/dist/chunk-majsbncm.js +98 -0
- package/dist/chunk-mp2gt9yh.js +237 -0
- package/dist/chunk-n1twhqmf.js +54 -0
- package/dist/{chunk-bygjkgrx.js → chunk-naqcqj8n.js} +57 -80
- package/dist/chunk-q5sb5dcr.js +15 -0
- package/dist/{chunk-06ks4ggh.js → chunk-qhdsjek6.js} +49 -89
- package/dist/{chunk-n133qpsm.js → chunk-qsh2nqz3.js} +50 -81
- package/dist/chunk-r0ms5tk1.js +76 -0
- package/dist/chunk-rwqwsanx.js +75 -0
- package/dist/chunk-sqsfk9p4.js +700 -0
- package/dist/{chunk-5gvbp2qa.js → chunk-x7bnzswh.js} +25 -18
- package/dist/cli/commands/dev.d.ts +8 -0
- package/dist/cli/commands/doctor.d.ts +8 -0
- package/dist/cli/commands/generate.d.ts +26 -0
- package/dist/cli/commands/init.d.ts +13 -1
- package/dist/cli/commands/migrate.d.ts +33 -0
- package/dist/cli/commands/plugin.d.ts +13 -0
- package/dist/cli/commands/seed.d.ts +21 -0
- package/dist/cli/{commands/migrate-commands.d.ts → core/migrations/migrate-logic.d.ts} +2 -2
- package/dist/cli/core/migrations/schema-diff-engine.d.ts +12 -0
- package/dist/cli/core/migrations/schema-diff.d.ts +11 -0
- package/dist/cli/{seeding.d.ts → core/seeding/auto-seed.d.ts} +7 -4
- package/dist/cli/core/seeding/seed-logic.d.ts +2 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +6 -170
- package/dist/client/RichText.d.ts +5 -0
- package/dist/client/rich-text-utils.d.ts +5 -0
- package/dist/client.js +3 -2
- package/dist/config.d.ts +3 -3
- package/dist/db/better-sqlite.d.ts +2 -3
- package/dist/db/better-sqlite.js +6 -5
- package/dist/db/bun-sqlite.d.ts +2 -3
- package/dist/db/bun-sqlite.js +6 -5
- package/dist/db/d1.d.ts +13 -7
- package/dist/db/d1.js +6 -5
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +10 -12
- package/dist/db/kysely/factory.d.ts +29 -0
- package/dist/db/kysely/plugins/audit-logging.d.ts +48 -0
- package/dist/db/kysely/plugins/auto-timestamps.d.ts +38 -0
- package/dist/db/kysely/plugins/cursor-pagination.d.ts +42 -0
- package/dist/db/kysely/plugins/deadlock-handler.d.ts +47 -0
- package/dist/db/kysely/plugins/draft-swapper.d.ts +33 -0
- package/dist/db/kysely/plugins/field-masking.d.ts +45 -0
- package/dist/db/kysely/plugins/fts-normalizer.d.ts +38 -0
- package/dist/db/kysely/plugins/i18n-fallback.d.ts +48 -0
- package/dist/db/kysely/plugins/id-generation.d.ts +42 -0
- package/dist/db/kysely/plugins/index.d.ts +16 -0
- package/dist/db/kysely/plugins/json-flattener.d.ts +38 -0
- package/dist/db/kysely/plugins/relationship-preloading.d.ts +39 -0
- package/dist/db/kysely/plugins/slug-generation.d.ts +37 -0
- package/dist/db/kysely/plugins/soft-delete.d.ts +42 -0
- package/dist/db/kysely/plugins/tree-resolver.d.ts +39 -0
- package/dist/db/kysely/plugins/virtual-field-resolver.d.ts +54 -0
- package/dist/db/kysely/plugins/zod-coercion.d.ts +34 -0
- package/dist/db/kysely/snapshot/snapshot-manager.d.ts +18 -0
- package/dist/db/postgres.d.ts +2 -2
- package/dist/db/postgres.js +6 -5
- package/dist/db/sqlite.d.ts +2 -3
- package/dist/db/sqlite.js +6 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +161 -7
- package/dist/runtimes/bun.js +9 -6
- package/dist/runtimes/cloudflare-workers.d.ts +3 -1
- package/dist/runtimes/cloudflare-workers.js +36 -7
- package/dist/runtimes/next.js +8 -5
- package/dist/runtimes/node.js +9 -6
- package/dist/schema/collection.d.ts +116 -70
- package/dist/schema/compiler.d.ts +6 -0
- package/dist/schema/global.d.ts +38 -71
- package/dist/schema/index.d.ts +5 -4
- package/dist/schema/index.js +35 -550
- package/dist/schema/zod.d.ts +564 -0
- package/dist/server/admin-router.d.ts +1 -1
- package/dist/server/collection-router.d.ts +1 -1
- package/dist/server/graphql.d.ts +6 -0
- package/dist/server/handlers.d.ts +25 -7
- package/dist/server/middlewares/auth.d.ts +1 -1
- package/dist/server/plugins-loader.d.ts +1 -1
- package/dist/server/router.d.ts +2 -2
- package/dist/server/routers/admin.d.ts +1 -1
- package/dist/server/routers/auth.d.ts +1 -1
- package/dist/server/routers/collections.d.ts +4 -1
- package/dist/server/routers/plugins.d.ts +2 -2
- package/dist/server/setup-middlewares.d.ts +1 -1
- package/dist/server/system-router.d.ts +1 -1
- package/dist/server.js +11 -6
- package/dist/storage/adapters/cloudflare-r2.d.ts +11 -2
- package/dist/storage/index.js +5 -5
- package/dist/types.d.ts +253 -42
- package/dist/utils/context.d.ts +14 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/string.d.ts +10 -0
- package/dist/utils/webhooks-engine.d.ts +24 -0
- package/dist/validation.d.ts +67 -1
- package/dist/validator.d.ts +1 -0
- package/package.json +50 -11
- package/src/cli/index.ts +117 -0
- package/dist/chunk-6qq3ne6b.js +0 -288
- package/dist/chunk-6v1fw7q7.js +0 -126
- package/dist/chunk-7a9kn0np.js +0 -116
- package/dist/chunk-bexcv7xe.js +0 -36
- package/dist/chunk-d3ffeqp9.js +0 -87
- package/dist/chunk-fj19qccp.js +0 -78
- package/dist/chunk-g1jb60xd.js +0 -17
- package/dist/chunk-j53pz21t.js +0 -20
- package/dist/chunk-mkn49zmy.js +0 -102
- package/dist/chunk-r39em4yj.js +0 -29
- package/dist/chunk-rsf0tpy1.js +0 -8
- package/dist/chunk-srsac177.js +0 -85
- package/dist/chunk-twpvxfce.js +0 -64
- package/dist/chunk-ywm4t2gm.js +0 -19
- package/dist/cli/commands/plugin-sync.d.ts +0 -1
- package/dist/cli/commands/seed-command.d.ts +0 -2
- package/dist/plugins/ui-bridge.d.ts +0 -12
- package/dist/schema/fields/base.d.ts +0 -84
- package/dist/schema/fields/index.d.ts +0 -147
- package/dist/schema/infer.d.ts +0 -55
- /package/dist/admin/ui/components/{ColumnVisibilityToggle.d.ts → column-visibility-toggle.d.ts} +0 -0
- /package/dist/admin/ui/components/{DataDetailView.d.ts → data-detail-view.d.ts} +0 -0
- /package/dist/cli/{d1-mock.d.ts → core/mocks/d1-mock.d.ts} +0 -0
- /package/dist/cli/{r2-mock.d.ts → core/mocks/r2-mock.d.ts} +0 -0
- /package/dist/cli/{commands → core/plugins}/plugin-build.d.ts +0 -0
- /package/dist/cli/{commands → core/plugins}/plugin-init.d.ts +0 -0
- /package/dist/cli/{commands → core/types}/generate-types.d.ts +0 -0
- /package/dist/{schema/fields/validation.test.d.ts → cli/seeding.test.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-6bywt602.js";
|
|
2
2
|
|
|
3
|
-
// src/cli/r2-mock.ts
|
|
3
|
+
// src/cli/core/mocks/r2-mock.ts
|
|
4
4
|
import { Database } from "bun:sqlite";
|
|
5
5
|
import crypto from "node:crypto";
|
|
6
6
|
import fs from "node:fs";
|
|
@@ -19,31 +19,38 @@ function createR2Mock(dbPath) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (!finalDbPath) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
finalDbPath = path.join(absolutePath, "mock-bucket.sqlite");
|
|
26
|
-
} else if (!absolutePath.endsWith(".sqlite")) {
|
|
27
|
-
finalDbPath = absolutePath.endsWith("/") ? path.join(absolutePath, "mock-bucket.sqlite") : absolutePath + ".sqlite";
|
|
22
|
+
if (!dbPath) {
|
|
23
|
+
finalDbPath = ":memory:";
|
|
24
|
+
console.log("[OpacaCMS] Using in-memory R2 mock");
|
|
28
25
|
} else {
|
|
29
|
-
|
|
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)}`);
|
|
30
35
|
}
|
|
31
|
-
console.log(`[OpacaCMS] Using local R2 mock: ${path.basename(finalDbPath)}`);
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fs.
|
|
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()}`);
|
|
36
48
|
}
|
|
37
49
|
try {
|
|
38
50
|
sqlite = new Database(finalDbPath);
|
|
39
51
|
} catch (err) {
|
|
40
52
|
throw new Error(`Failed to open R2 mock database at ${finalDbPath}: ${err.message}`);
|
|
41
53
|
}
|
|
42
|
-
blobsDir = finalDbPath.replace(".sqlite", ".blobs");
|
|
43
|
-
if (!fs.existsSync(blobsDir)) {
|
|
44
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
45
|
-
fs.mkdirSync(blobsDir, { recursive: true });
|
|
46
|
-
}
|
|
47
54
|
sqlite.exec(`
|
|
48
55
|
CREATE TABLE IF NOT EXISTS _mf_objects (
|
|
49
56
|
key TEXT PRIMARY KEY,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly type: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "What to generate: 'types', 'collection', or 'global'";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly name: {
|
|
8
|
+
readonly type: "positional";
|
|
9
|
+
readonly description: "The name of the collection or global to generate (if applicable)";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
readonly url: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "The URL of the OpacaCMS instance (for 'types')";
|
|
15
|
+
};
|
|
16
|
+
readonly token: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "The API Key to use for fetching metadata (for 'types')";
|
|
19
|
+
};
|
|
20
|
+
readonly out: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly alias: "o";
|
|
23
|
+
readonly description: "The output file path (for 'types')";
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export default _default;
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly target: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "Target directory name";
|
|
5
|
+
readonly required: false;
|
|
6
|
+
};
|
|
7
|
+
readonly example: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly alias: "e";
|
|
10
|
+
readonly description: "Use an example template";
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly config: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly alias: "c";
|
|
5
|
+
readonly description: "Path to the OpacaCMS configuration file";
|
|
6
|
+
};
|
|
7
|
+
readonly action: {
|
|
8
|
+
readonly type: "positional";
|
|
9
|
+
readonly description: "Action to perform: run (default), create, diff, status, d1";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
readonly name: {
|
|
13
|
+
readonly type: "positional";
|
|
14
|
+
readonly description: "Name of the migration (for create)";
|
|
15
|
+
readonly required: false;
|
|
16
|
+
};
|
|
17
|
+
readonly out: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly alias: "o";
|
|
20
|
+
readonly description: "Output directory for migrations";
|
|
21
|
+
};
|
|
22
|
+
readonly remote: {
|
|
23
|
+
readonly type: "boolean";
|
|
24
|
+
readonly description: "Apply migrations to remote D1";
|
|
25
|
+
};
|
|
26
|
+
readonly binding: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly alias: "b";
|
|
29
|
+
readonly description: "D1 database binding name";
|
|
30
|
+
readonly default: "DB";
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly action: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "Action to perform: init, build";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly name: {
|
|
8
|
+
readonly type: "positional";
|
|
9
|
+
readonly description: "Name of the plugin (for init)";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly config: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly alias: "c";
|
|
5
|
+
readonly description: "Path to the OpacaCMS configuration file";
|
|
6
|
+
};
|
|
7
|
+
readonly count: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Number of documents to seed";
|
|
10
|
+
readonly default: "10";
|
|
11
|
+
};
|
|
12
|
+
readonly reset: {
|
|
13
|
+
readonly type: "boolean";
|
|
14
|
+
readonly description: "Clear the database before seeding";
|
|
15
|
+
};
|
|
16
|
+
readonly assets: {
|
|
17
|
+
readonly type: "boolean";
|
|
18
|
+
readonly description: "Seed only assets";
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DatabaseAdapter, OpacaConfig } from "
|
|
2
|
-
export declare function migrateCreateCommand(opaca: OpacaConfig, migrationName?: string, outDir?: string): Promise<
|
|
1
|
+
import type { DatabaseAdapter, OpacaConfig } from "../../../types";
|
|
2
|
+
export declare function migrateCreateCommand(opaca: OpacaConfig, migrationName?: string, outDir?: string): Promise<boolean>;
|
|
3
3
|
export declare function migrateRunCommand(db: DatabaseAdapter): Promise<void>;
|
|
4
4
|
export declare function migrateStatusCommand(opaca: OpacaConfig): Promise<void>;
|
|
5
5
|
export declare function migrateD1Command(migrationDir: string, isRemote: boolean, binding?: string): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ColumnSnapshot, SchemaSnapshot, TableSnapshot } from "../../../db/kysely/snapshot/snapshot-manager.js";
|
|
2
|
+
export interface DiffAction {
|
|
3
|
+
type: "create_table" | "drop_table" | "rename_table" | "add_column" | "drop_column" | "rename_column" | "change_column";
|
|
4
|
+
tableName: string;
|
|
5
|
+
newName?: string;
|
|
6
|
+
columnName?: string;
|
|
7
|
+
newColumnName?: string;
|
|
8
|
+
tableSnapshot?: TableSnapshot;
|
|
9
|
+
columnSnapshot?: ColumnSnapshot;
|
|
10
|
+
confirmed?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function compareSchemas(previous: SchemaSnapshot, current: SchemaSnapshot, interactive?: boolean): Promise<DiffAction[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OpacaConfig } from "../../../types";
|
|
2
|
+
interface DiffResult {
|
|
3
|
+
upCode: string;
|
|
4
|
+
downCode: string;
|
|
5
|
+
hasChanges: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function generateDiffCode(opaca: OpacaConfig, dialect: "postgres" | "sqlite" | "d1", migrationDir: string, snapshotName: string, options?: {
|
|
8
|
+
saveSnapshot?: boolean;
|
|
9
|
+
interactive?: boolean;
|
|
10
|
+
}): Promise<DiffResult>;
|
|
11
|
+
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type { Collection, DatabaseAdapter, OpacaConfig } from "
|
|
1
|
+
import type { Collection, DatabaseAdapter, OpacaConfig } from "../../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Default generators for each field type.
|
|
4
4
|
*/
|
|
5
|
-
export declare const defaultFieldGenerators: Record<string, () =>
|
|
5
|
+
export declare const defaultFieldGenerators: Record<string, () => unknown>;
|
|
6
|
+
export declare function getRandomIds(db: DatabaseAdapter, relationTo: string, count?: number): Promise<string[]>;
|
|
6
7
|
/**
|
|
7
8
|
* Generates a single record for a collection.
|
|
8
9
|
*/
|
|
9
|
-
export declare function generateRecord(db: DatabaseAdapter, collection: Collection, locales?: string[]): Promise<
|
|
10
|
+
export declare function generateRecord(db: DatabaseAdapter, collection: Collection, locales?: string[]): Promise<{
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
}>;
|
|
10
13
|
/**
|
|
11
14
|
* Topologically sorts collections based on their dependencies.
|
|
12
15
|
*/
|
|
@@ -14,4 +17,4 @@ export declare function sortCollections(collections: Collection[]): Collection[]
|
|
|
14
17
|
/**
|
|
15
18
|
* Seeds the database with mock data.
|
|
16
19
|
*/
|
|
17
|
-
export declare function autoSeed(config: OpacaConfig, countPerCollection?: number, reset?: boolean, type?: "collections" | "assets" | "all"): Promise<void>;
|
|
20
|
+
export declare function autoSeed(config: OpacaConfig, countPerCollection?: number, reset?: boolean, type?: "collections" | "assets" | "all", targetTable?: string): Promise<void>;
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -3,3 +3,7 @@
|
|
|
3
3
|
* Loads and validates the OpacaCMS configuration from a file.
|
|
4
4
|
*/
|
|
5
5
|
export declare function loadConfig(configPath: string): Promise<any>;
|
|
6
|
+
/**
|
|
7
|
+
* Tries to find the Opaca config file automatically.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveConfigPath(explicitPath?: string): string;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,175 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import { resolve } from "node:path";
|
|
9
|
-
import { parseArgs } from "node:util";
|
|
10
|
-
import { pathToFileURL } from "node:url";
|
|
11
|
-
async function loadConfig(configPath) {
|
|
12
|
-
if (!fs.existsSync(configPath)) {
|
|
13
|
-
throw new Error(`Config file not found at ${configPath}`);
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const configUrl = pathToFileURL(configPath).href;
|
|
17
|
-
const mod = await import(configUrl);
|
|
18
|
-
if (!mod.default) {
|
|
19
|
-
throw new Error(`The configuration file at ${configPath} must have a 'default' export.`);
|
|
20
|
-
}
|
|
21
|
-
const namedExports = Object.keys(mod).filter((k) => k !== "default" && k !== "__esModule");
|
|
22
|
-
if (namedExports.length > 0) {
|
|
23
|
-
throw new Error(`Named exports are not allowed in the configuration file. Found: ${namedExports.join(", ")}.`);
|
|
24
|
-
}
|
|
25
|
-
let opaca = mod.default;
|
|
26
|
-
if (typeof opaca === "function") {
|
|
27
|
-
const { createD1Mock } = await import("../chunk-9kxpbcb1.js");
|
|
28
|
-
const { createR2Mock } = await import("../chunk-5gvbp2qa.js");
|
|
29
|
-
const mockDb = createD1Mock();
|
|
30
|
-
const mockBucket = createR2Mock();
|
|
31
|
-
const mockSecureBucket = createR2Mock(".opaca/local-r2/secure");
|
|
32
|
-
opaca = await opaca({
|
|
33
|
-
DB: mockDb,
|
|
34
|
-
BUCKET: mockBucket,
|
|
35
|
-
SECURE_BUCKET: mockSecureBucket,
|
|
36
|
-
OPACA_SECRET: "cli-secret"
|
|
37
|
-
}, { url: "http://localhost:3000" });
|
|
38
|
-
}
|
|
39
|
-
if (opaca?.fetch) {
|
|
40
|
-
throw new Error("Default export is a Hono application. The CLI requires the configuration object.");
|
|
41
|
-
}
|
|
42
|
-
if (!opaca.db) {
|
|
43
|
-
throw new Error("No database adapter found in config");
|
|
44
|
-
}
|
|
45
|
-
return opaca;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async function main() {
|
|
51
|
-
const { values, positionals } = parseArgs({
|
|
52
|
-
args: process.argv.slice(2),
|
|
53
|
-
options: {
|
|
54
|
-
config: { type: "string", short: "c" },
|
|
55
|
-
example: { type: "string", short: "e" },
|
|
56
|
-
help: { type: "boolean", short: "h" },
|
|
57
|
-
version: { type: "boolean", short: "v" },
|
|
58
|
-
out: { type: "string", short: "o" },
|
|
59
|
-
remote: { type: "boolean" },
|
|
60
|
-
local: { type: "boolean" },
|
|
61
|
-
binding: { type: "string", short: "b" },
|
|
62
|
-
url: { type: "string" },
|
|
63
|
-
token: { type: "string" },
|
|
64
|
-
count: { type: "string" },
|
|
65
|
-
reset: { type: "boolean" },
|
|
66
|
-
watch: { type: "boolean", short: "w" }
|
|
67
|
-
},
|
|
68
|
-
allowPositionals: true
|
|
69
|
-
});
|
|
70
|
-
if (values.help) {
|
|
71
|
-
console.log("Usage: opacacms <command> [options]");
|
|
72
|
-
console.log(`
|
|
73
|
-
Commands:`);
|
|
74
|
-
console.log(" init [target] Initialize a new project");
|
|
75
|
-
console.log(" migrate:create Generate migrations from your schema");
|
|
76
|
-
console.log(" migrate Run pending migrations");
|
|
77
|
-
console.log(" migrate:status Show migration status");
|
|
78
|
-
console.log(" migrate:d1 Apply SQL migrations to D1");
|
|
79
|
-
console.log(" seed Seed database with mock data");
|
|
80
|
-
console.log(" seed:assets Seed only assets");
|
|
81
|
-
console.log(" generate:types Generate TS definitions from instance");
|
|
82
|
-
console.log(" plugin:init [name] Initialize a new plugin project");
|
|
83
|
-
console.log(" plugin:sync Build a plugin project (transpile & bake)");
|
|
84
|
-
process.exit(0);
|
|
85
|
-
}
|
|
86
|
-
if (values.version) {
|
|
87
|
-
console.log("OpacaCMS v0.1.0");
|
|
88
|
-
process.exit(0);
|
|
89
|
-
}
|
|
90
|
-
const command = positionals[0];
|
|
91
|
-
if (!command) {
|
|
92
|
-
console.log("Usage: opacacms <command> [options]. Use --help for more info.");
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
if (command === "init") {
|
|
96
|
-
const { initCommand } = await import("../chunk-srsac177.js");
|
|
97
|
-
await initCommand(positionals[1] || "my-opaca-app", values.example);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (command === "generate:types") {
|
|
101
|
-
const { generateTypesCommand } = await import("../chunk-7a9kn0np.js");
|
|
102
|
-
await generateTypesCommand(values.url, values.token, values.out || "opaca-types.d.ts");
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (command === "plugin:init") {
|
|
106
|
-
const { pluginInitCommand } = await import("../chunk-mkn49zmy.js");
|
|
107
|
-
await pluginInitCommand(positionals[1] || "my-opaca-plugin");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (command === "plugin:sync") {
|
|
111
|
-
const { pluginSyncCommand } = await import("../chunk-rsf0tpy1.js");
|
|
112
|
-
await pluginSyncCommand(process.cwd(), !!values.watch);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (command === "plugin:build") {
|
|
116
|
-
const { pluginBuildCommand } = await import("../chunk-fj19qccp.js");
|
|
117
|
-
await pluginBuildCommand(process.cwd());
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
let configPath = values.config ? resolve(process.cwd(), values.config) : "";
|
|
121
|
-
if (!configPath) {
|
|
122
|
-
const defaults = ["opacacms.config.ts", "opacacms.config.js", "src/opacacms.config.ts", "src/opacacms.config.js", "opaca.config.ts", "opaca.config.js"];
|
|
123
|
-
for (const d of defaults) {
|
|
124
|
-
if (fs.existsSync(resolve(process.cwd(), d))) {
|
|
125
|
-
configPath = resolve(process.cwd(), d);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (!configPath || !fs.existsSync(configPath)) {
|
|
131
|
-
console.error("Config file not found. Use -c or --config to specify path.");
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
const opaca = await loadConfig(configPath);
|
|
135
|
-
switch (command) {
|
|
136
|
-
case "migrate:create": {
|
|
137
|
-
const { migrateCreateCommand } = await import("../chunk-6v1fw7q7.js");
|
|
138
|
-
await migrateCreateCommand(opaca, positionals[1], values.out);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
case "migrate": {
|
|
142
|
-
const { migrateRunCommand } = await import("../chunk-6v1fw7q7.js");
|
|
143
|
-
await migrateRunCommand(opaca.db);
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case "migrate:status": {
|
|
147
|
-
const { migrateStatusCommand } = await import("../chunk-6v1fw7q7.js");
|
|
148
|
-
await migrateStatusCommand(opaca);
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case "migrate:d1": {
|
|
152
|
-
const { migrateD1Command } = await import("../chunk-6v1fw7q7.js");
|
|
153
|
-
await migrateD1Command(values.out || "./migrations", !!values.remote, values.binding || "DB");
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case "seed":
|
|
157
|
-
case "seed:assets": {
|
|
158
|
-
const { seedCommand } = await import("../chunk-g1jb60xd.js");
|
|
159
|
-
await seedCommand(opaca, parseInt(values.count) || 10, !!values.reset, command === "seed:assets" ? "assets" : "collections");
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
default:
|
|
163
|
-
console.error(`Unknown command: ${command}`);
|
|
164
|
-
process.exit(1);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (__require.main == __require.module) {
|
|
168
|
-
main().catch((err) => {
|
|
169
|
-
console.error(err);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
3
|
+
loadConfig,
|
|
4
|
+
resolveConfigPath
|
|
5
|
+
} from "../chunk-majsbncm.js";
|
|
6
|
+
import"../chunk-1qm0m8r8.js";
|
|
7
|
+
import"../chunk-6bywt602.js";
|
|
173
8
|
export {
|
|
9
|
+
resolveConfigPath,
|
|
174
10
|
loadConfig
|
|
175
11
|
};
|
package/dist/client.js
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ type BuiltResource<T> = T extends {
|
|
|
8
8
|
type Buildable<T> = T | {
|
|
9
9
|
build: () => T;
|
|
10
10
|
};
|
|
11
|
-
type ResourceOf<C, G> = (C extends readonly (infer U)[] ?
|
|
11
|
+
type ResourceOf<C, G> = (C extends readonly (infer U)[] ? BuiltResource<U> extends {
|
|
12
12
|
slug: infer S;
|
|
13
|
-
} ? S : never
|
|
13
|
+
} ? S : never : never) | (G extends readonly (infer U)[] ? BuiltResource<U> extends {
|
|
14
14
|
slug: infer S;
|
|
15
|
-
} ? S : never
|
|
15
|
+
} ? S : never : never);
|
|
16
16
|
/**
|
|
17
17
|
* Helper logic to infer slugs from collections and globals.
|
|
18
18
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Kysely } from "kysely";
|
|
2
|
-
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
1
|
+
import { type Kysely } from "kysely";
|
|
3
2
|
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
3
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
4
|
export declare class BetterSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
5
|
private path;
|
|
6
6
|
name: string;
|
|
@@ -21,7 +21,6 @@ export declare class BetterSQLiteAdapter extends BaseDatabaseAdapter {
|
|
|
21
21
|
connect(): Promise<void>;
|
|
22
22
|
disconnect(): Promise<void>;
|
|
23
23
|
unsafe(query: string, params?: any[]): Promise<unknown>;
|
|
24
|
-
private coerceData;
|
|
25
24
|
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
26
25
|
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
27
26
|
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
package/dist/db/better-sqlite.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BetterSQLiteAdapter,
|
|
3
3
|
createBetterSQLiteAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-naqcqj8n.js";
|
|
5
|
+
import"../chunk-j8js1y0h.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
+
import"../chunk-q5sb5dcr.js";
|
|
7
8
|
import"../chunk-qxt9vge8.js";
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
10
|
-
import"../chunk-
|
|
9
|
+
import"../chunk-jq1drsen.js";
|
|
10
|
+
import"../chunk-6qs0g65f.js";
|
|
11
|
+
import"../chunk-6bywt602.js";
|
|
11
12
|
export {
|
|
12
13
|
createBetterSQLiteAdapter,
|
|
13
14
|
BetterSQLiteAdapter
|
package/dist/db/bun-sqlite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Kysely } from "kysely";
|
|
2
|
-
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
1
|
+
import { type Kysely } from "kysely";
|
|
3
2
|
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
3
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
4
|
export declare class BunSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
5
|
private path;
|
|
6
6
|
name: string;
|
|
@@ -21,7 +21,6 @@ export declare class BunSQLiteAdapter extends BaseDatabaseAdapter {
|
|
|
21
21
|
connect(): Promise<void>;
|
|
22
22
|
disconnect(): Promise<void>;
|
|
23
23
|
unsafe(query: string, params?: any[]): Promise<unknown>;
|
|
24
|
-
private coerceData;
|
|
25
24
|
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
26
25
|
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
27
26
|
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
package/dist/db/bun-sqlite.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BunSQLiteAdapter,
|
|
3
3
|
createBunSQLiteAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-qsh2nqz3.js";
|
|
5
|
+
import"../chunk-j8js1y0h.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
+
import"../chunk-q5sb5dcr.js";
|
|
7
8
|
import"../chunk-qxt9vge8.js";
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
10
|
-
import"../chunk-
|
|
9
|
+
import"../chunk-jq1drsen.js";
|
|
10
|
+
import"../chunk-6qs0g65f.js";
|
|
11
|
+
import"../chunk-6bywt602.js";
|
|
11
12
|
export {
|
|
12
13
|
createBunSQLiteAdapter,
|
|
13
14
|
BunSQLiteAdapter
|
package/dist/db/d1.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { Kysely } from "kysely";
|
|
3
|
-
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
1
|
+
import { type Kysely } from "kysely";
|
|
4
2
|
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
3
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* A compatible interface for D1Database that avoids version mismatches.
|
|
6
|
+
*/
|
|
7
|
+
export interface OpacaD1Database {
|
|
8
|
+
prepare(query: string): any;
|
|
9
|
+
batch(queries: any[]): Promise<any[]>;
|
|
10
|
+
exec(query: string): Promise<any>;
|
|
11
|
+
}
|
|
5
12
|
export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
6
13
|
name: string;
|
|
7
14
|
private _rawDb;
|
|
@@ -11,9 +18,9 @@ export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
|
11
18
|
push: boolean;
|
|
12
19
|
migrationDir: string;
|
|
13
20
|
pushDestructive: boolean;
|
|
14
|
-
get raw():
|
|
21
|
+
get raw(): OpacaD1Database;
|
|
15
22
|
get db(): Kysely<any>;
|
|
16
|
-
constructor(db:
|
|
23
|
+
constructor(db: OpacaD1Database, options?: {
|
|
17
24
|
push?: boolean;
|
|
18
25
|
pushDestructive?: boolean;
|
|
19
26
|
migrationDir?: string;
|
|
@@ -21,7 +28,6 @@ export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
|
21
28
|
connect(): Promise<void>;
|
|
22
29
|
disconnect(): Promise<void>;
|
|
23
30
|
unsafe(query: string, params?: unknown[]): Promise<unknown>;
|
|
24
|
-
private coerceData;
|
|
25
31
|
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
26
32
|
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
27
33
|
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
@@ -35,7 +41,7 @@ export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
|
35
41
|
runMigrations(): Promise<void>;
|
|
36
42
|
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
37
43
|
}
|
|
38
|
-
export declare function createD1Adapter(db:
|
|
44
|
+
export declare function createD1Adapter(db: OpacaD1Database, options?: {
|
|
39
45
|
push?: boolean;
|
|
40
46
|
pushDestructive?: boolean;
|
|
41
47
|
migrationDir?: string;
|
package/dist/db/d1.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
D1Adapter,
|
|
3
3
|
createD1Adapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-qhdsjek6.js";
|
|
5
|
+
import"../chunk-j8js1y0h.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
+
import"../chunk-q5sb5dcr.js";
|
|
7
8
|
import"../chunk-qxt9vge8.js";
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
10
|
-
import"../chunk-
|
|
9
|
+
import"../chunk-jq1drsen.js";
|
|
10
|
+
import"../chunk-6qs0g65f.js";
|
|
11
|
+
import"../chunk-6bywt602.js";
|
|
11
12
|
export {
|
|
12
13
|
createD1Adapter,
|
|
13
14
|
D1Adapter
|
package/dist/db/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { Kysely } from "kysely";
|
|
|
2
2
|
export { sql } from "kysely";
|
|
3
3
|
export type OpacaMigrationDb = Kysely<any>;
|
|
4
4
|
export * from "./adapter";
|
|
5
|
-
export * from "./postgres";
|
|
6
|
-
export * from "./sqlite";
|
|
7
5
|
export * from "./better-sqlite";
|
|
8
6
|
export * from "./bun-sqlite";
|
|
9
7
|
export * from "./d1";
|
|
8
|
+
export * from "./postgres";
|
|
9
|
+
export * from "./sqlite";
|