@kyro-cms/core 0.9.8 → 0.10.0
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/api-handler-graphql.cjs +22 -17
- package/dist/api-handler-graphql.cjs.map +1 -1
- package/dist/api-handler-graphql.js +18 -13
- package/dist/api-handler-graphql.js.map +1 -1
- package/dist/api-handler-trpc.cjs +13 -13
- package/dist/api-handler-trpc.js +11 -11
- package/dist/api-handler.cjs +14 -14
- package/dist/api-handler.js +11 -11
- package/dist/{bootstrap-4CELFLJO.cjs → bootstrap-FUAPY2OF.cjs} +9 -9
- package/dist/{bootstrap-4CELFLJO.cjs.map → bootstrap-FUAPY2OF.cjs.map} +1 -1
- package/dist/bootstrap-OXNVM7FP.js +7 -0
- package/dist/{bootstrap-3PV3GJ3S.js.map → bootstrap-OXNVM7FP.js.map} +1 -1
- package/dist/{chunk-HA4MGAZJ.js → chunk-354ISGA4.js} +112 -49
- package/dist/chunk-354ISGA4.js.map +1 -0
- package/dist/{chunk-2GXALYKV.js → chunk-3AKCVYDB.js} +4 -109
- package/dist/chunk-3AKCVYDB.js.map +1 -0
- package/dist/{chunk-OVZO4KB6.cjs → chunk-3P5AHK2U.cjs} +34 -38
- package/dist/chunk-3P5AHK2U.cjs.map +1 -0
- package/dist/{chunk-KGJRJ7CU.cjs → chunk-4OCMVGEY.cjs} +4 -110
- package/dist/chunk-4OCMVGEY.cjs.map +1 -0
- package/dist/{chunk-EQTMBMDR.js → chunk-526M5MOA.js} +19 -8
- package/dist/chunk-526M5MOA.js.map +1 -0
- package/dist/{chunk-5PMQQFRE.cjs → chunk-5GFQPHGT.cjs} +6 -9
- package/dist/chunk-5GFQPHGT.cjs.map +1 -0
- package/dist/chunk-5RPRLTTN.js +861 -0
- package/dist/chunk-5RPRLTTN.js.map +1 -0
- package/dist/{chunk-ZFHTJ2YX.js → chunk-AN2L2CJZ.js} +16 -20
- package/dist/chunk-AN2L2CJZ.js.map +1 -0
- package/dist/{chunk-RFFSZSCL.cjs → chunk-GYIJ3JJM.cjs} +3 -11
- package/dist/chunk-GYIJ3JJM.cjs.map +1 -0
- package/dist/{chunk-PQ72Z6WC.js → chunk-GZS4LMR7.js} +2 -5
- package/dist/chunk-GZS4LMR7.js.map +1 -0
- package/dist/{chunk-GAAHG2Z4.js → chunk-HY6B7B5A.js} +4 -7
- package/dist/chunk-HY6B7B5A.js.map +1 -0
- package/dist/{chunk-2CBCU5ML.cjs → chunk-ISKYUUP4.cjs} +142 -79
- package/dist/chunk-ISKYUUP4.cjs.map +1 -0
- package/dist/{chunk-Z7OH3MWT.cjs → chunk-LNTFRAHF.cjs} +110 -2
- package/dist/chunk-LNTFRAHF.cjs.map +1 -0
- package/dist/chunk-N4GN6Q3V.cjs +869 -0
- package/dist/chunk-N4GN6Q3V.cjs.map +1 -0
- package/dist/{chunk-6UNONDW7.js → chunk-N5QSHUA6.js} +2 -11
- package/dist/chunk-N5QSHUA6.js.map +1 -0
- package/dist/{chunk-PJ7F4TCC.cjs → chunk-NQJJYRLP.cjs} +24 -13
- package/dist/chunk-NQJJYRLP.cjs.map +1 -0
- package/dist/{chunk-65DSXNQL.js → chunk-OX6GOIPH.js} +4 -4
- package/dist/{chunk-65DSXNQL.js.map → chunk-OX6GOIPH.js.map} +1 -1
- package/dist/{chunk-Q23GAMLE.cjs → chunk-THBQG64D.cjs} +2 -5
- package/dist/chunk-THBQG64D.cjs.map +1 -0
- package/dist/{chunk-W3GT55TY.cjs → chunk-TQG7G7YI.cjs} +13 -13
- package/dist/{chunk-W3GT55TY.cjs.map → chunk-TQG7G7YI.cjs.map} +1 -1
- package/dist/{chunk-Y7AQK4R4.cjs → chunk-VKREAIBA.cjs} +2 -11
- package/dist/chunk-VKREAIBA.cjs.map +1 -0
- package/dist/{chunk-2Z7YAJBS.js → chunk-WDTTHKDS.js} +109 -3
- package/dist/chunk-WDTTHKDS.js.map +1 -0
- package/dist/{chunk-V7KZQIZ6.js → chunk-XHAAAEXX.js} +2 -10
- package/dist/chunk-XHAAAEXX.js.map +1 -0
- package/dist/cli/index.cjs +145 -51
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +145 -51
- package/dist/cli/index.js.map +1 -1
- package/dist/drizzle/index.cjs +9 -9
- package/dist/drizzle/index.js +1 -1
- package/dist/graphql/index.cjs +7 -7
- package/dist/graphql/index.d.cts +21 -13
- package/dist/graphql/index.d.ts +21 -13
- package/dist/graphql/index.js +2 -2
- package/dist/index.cjs +92 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/mongodb/index.cjs +3 -3
- package/dist/mongodb/index.js +1 -1
- package/dist/rest/index.cjs +8 -8
- package/dist/rest/index.js +6 -6
- package/dist/trpc/index.cjs +12 -12
- package/dist/trpc/index.js +3 -3
- package/package.json +1 -1
- package/dist/bootstrap-3PV3GJ3S.js +0 -7
- package/dist/chunk-2CBCU5ML.cjs.map +0 -1
- package/dist/chunk-2GXALYKV.js.map +0 -1
- package/dist/chunk-2Z7YAJBS.js.map +0 -1
- package/dist/chunk-5PMQQFRE.cjs.map +0 -1
- package/dist/chunk-6DURKQ6W.js +0 -1072
- package/dist/chunk-6DURKQ6W.js.map +0 -1
- package/dist/chunk-6UNONDW7.js.map +0 -1
- package/dist/chunk-EQTMBMDR.js.map +0 -1
- package/dist/chunk-GAAHG2Z4.js.map +0 -1
- package/dist/chunk-HA4MGAZJ.js.map +0 -1
- package/dist/chunk-KGJRJ7CU.cjs.map +0 -1
- package/dist/chunk-OVZO4KB6.cjs.map +0 -1
- package/dist/chunk-PF642V5O.cjs +0 -1080
- package/dist/chunk-PF642V5O.cjs.map +0 -1
- package/dist/chunk-PJ7F4TCC.cjs.map +0 -1
- package/dist/chunk-PQ72Z6WC.js.map +0 -1
- package/dist/chunk-Q23GAMLE.cjs.map +0 -1
- package/dist/chunk-RFFSZSCL.cjs.map +0 -1
- package/dist/chunk-V7KZQIZ6.js.map +0 -1
- package/dist/chunk-Y7AQK4R4.cjs.map +0 -1
- package/dist/chunk-Z7OH3MWT.cjs.map +0 -1
- package/dist/chunk-ZFHTJ2YX.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { PasswordPolicy, ConfigService, EmailTransport } from './chunk-
|
|
1
|
+
import { PasswordPolicy, ConfigService, EmailTransport } from './chunk-N5QSHUA6.js';
|
|
2
2
|
import { usersCollection } from './chunk-XEB7PH2E.js';
|
|
3
3
|
import { SQLiteAuthAdapter } from './chunk-Q72BOAPK.js';
|
|
4
4
|
import { createAuditContext } from './chunk-P2YW545G.js';
|
|
5
|
-
import { WEBHOOK_EVENTS } from './chunk-
|
|
6
|
-
import { API_KEY_COLLECTION, generateApiKey, generateApiKeyPrefix,
|
|
7
|
-
import { genId, DrizzleAdapter } from './chunk-
|
|
5
|
+
import { WEBHOOK_EVENTS, checkCollectionAccess, checkGlobalAccess } from './chunk-WDTTHKDS.js';
|
|
6
|
+
import { API_KEY_COLLECTION, generateApiKey, generateApiKeyPrefix, extractApiKeyFromRequest, validateApiKey, createApiKeyContext } from './chunk-3AKCVYDB.js';
|
|
7
|
+
import { genId, DrizzleAdapter } from './chunk-XHAAAEXX.js';
|
|
8
8
|
import { PostgresAuthAdapter } from './chunk-CJX74IYK.js';
|
|
9
|
-
import { MongoDBAdapter } from './chunk-
|
|
9
|
+
import { MongoDBAdapter } from './chunk-GZS4LMR7.js';
|
|
10
10
|
import { MongoDBAuthAdapter } from './chunk-7OGPN7MP.js';
|
|
11
11
|
import { hasPermission } from './chunk-L4EZKIEX.js';
|
|
12
12
|
import { __esm, __export, __toCommonJS } from './chunk-4CV4JOE5.js';
|
|
@@ -44,11 +44,9 @@ async function loadSecrets() {
|
|
|
44
44
|
maxSessionsPerUser: result.maxSessionsPerUser || 3
|
|
45
45
|
} : null
|
|
46
46
|
};
|
|
47
|
-
console.log("\u{1F510} Loaded secrets from database");
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
} catch (e) {
|
|
51
|
-
console.log("\u26A0\uFE0F Could not load system settings from DB, using env fallback");
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
cachedSecrets = {
|
|
@@ -2197,14 +2195,6 @@ function getDisplayName(provider) {
|
|
|
2197
2195
|
}
|
|
2198
2196
|
}
|
|
2199
2197
|
function createS3Storage(config) {
|
|
2200
|
-
console.log("[createS3Storage] Creating provider:", config.provider);
|
|
2201
|
-
console.log("[createS3Storage] Credentials:", {
|
|
2202
|
-
accessKeyId: config.accessKeyId ? "SET" : "UNDEFINED",
|
|
2203
|
-
secretAccessKey: config.secretAccessKey ? "SET" : "UNDEFINED",
|
|
2204
|
-
bucket: config.bucket,
|
|
2205
|
-
accountId: config.accountId,
|
|
2206
|
-
endpoint: config.endpoint
|
|
2207
|
-
});
|
|
2208
2198
|
const client = new S3Client({
|
|
2209
2199
|
region: config.region || "auto",
|
|
2210
2200
|
endpoint: config.endpoint,
|
|
@@ -2540,13 +2530,6 @@ function createCloudinaryStorage(config) {
|
|
|
2540
2530
|
folder = folderParts.length > 1 ? folderParts.slice(0, -1).join("/") : "";
|
|
2541
2531
|
const newFilename = newKey.replace(/\.[^.]+$/, "");
|
|
2542
2532
|
newPublicId = folder ? `${folder}/${newFilename}` : newFilename;
|
|
2543
|
-
console.log("[Cloudinary rename]", {
|
|
2544
|
-
urlPath,
|
|
2545
|
-
version,
|
|
2546
|
-
publicIdWithoutVersion,
|
|
2547
|
-
folder,
|
|
2548
|
-
newPublicId
|
|
2549
|
-
});
|
|
2550
2533
|
const timestamp = Math.round(Date.now() / 1e3);
|
|
2551
2534
|
const signatureParams = {
|
|
2552
2535
|
from_public_id: publicIdWithoutVersion,
|
|
@@ -2571,7 +2554,6 @@ function createCloudinaryStorage(config) {
|
|
|
2571
2554
|
);
|
|
2572
2555
|
if (response.ok) {
|
|
2573
2556
|
const data = await response.json();
|
|
2574
|
-
console.log("[Cloudinary rename] Success:", data.secure_url);
|
|
2575
2557
|
return data.secure_url;
|
|
2576
2558
|
} else {
|
|
2577
2559
|
const error = await response.json();
|
|
@@ -2948,7 +2930,7 @@ var MediaService = class _MediaService {
|
|
|
2948
2930
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
2949
2931
|
return { where, params: p, orderBy: sortDir, sortCol };
|
|
2950
2932
|
}
|
|
2951
|
-
rowToMedia(row) {
|
|
2933
|
+
rowToMedia(row, origin) {
|
|
2952
2934
|
return {
|
|
2953
2935
|
id: row.id,
|
|
2954
2936
|
filename: row.filename,
|
|
@@ -2958,8 +2940,8 @@ var MediaService = class _MediaService {
|
|
|
2958
2940
|
fileSize: row.file_size ?? row.fileSize,
|
|
2959
2941
|
width: row.width ?? null,
|
|
2960
2942
|
height: row.height ?? null,
|
|
2961
|
-
url: row.url,
|
|
2962
|
-
thumbnailUrl: row.thumbnail_url ?? row.thumbnailUrl ?? null,
|
|
2943
|
+
url: _MediaService.resolveMediaUrl(row.url, origin),
|
|
2944
|
+
thumbnailUrl: _MediaService.resolveMediaUrl(row.thumbnail_url ?? row.thumbnailUrl ?? null, origin),
|
|
2963
2945
|
folder: row.folder ?? null,
|
|
2964
2946
|
provider: row.provider,
|
|
2965
2947
|
alt: row.alt ?? null,
|
|
@@ -2969,6 +2951,12 @@ var MediaService = class _MediaService {
|
|
|
2969
2951
|
updatedAt: row.updated_at ?? row.updatedAt
|
|
2970
2952
|
};
|
|
2971
2953
|
}
|
|
2954
|
+
static resolveMediaUrl(url, origin) {
|
|
2955
|
+
if (!url) return null;
|
|
2956
|
+
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("blob:") || url.startsWith("data:")) return url;
|
|
2957
|
+
const base = (process.env.KYRO_BASE_URL || origin || "http://localhost:4321").replace(/\/+$/, "");
|
|
2958
|
+
return `${base}${url.startsWith("/") ? "" : "/"}${url}`;
|
|
2959
|
+
}
|
|
2972
2960
|
async sqliteRun(sql, params = []) {
|
|
2973
2961
|
const stmt = this.db.prepare(sql);
|
|
2974
2962
|
const sqlLower = sql.trim().toLowerCase();
|
|
@@ -3096,17 +3084,19 @@ var MediaService = class _MediaService {
|
|
|
3096
3084
|
const file = new File([blob], originalName, { type: mimeType });
|
|
3097
3085
|
return this.upload(file, folder);
|
|
3098
3086
|
}
|
|
3099
|
-
async delete(id) {
|
|
3087
|
+
async delete(id, origin) {
|
|
3100
3088
|
let item = null;
|
|
3101
3089
|
if (this.dialect === "sqlite") {
|
|
3102
|
-
|
|
3103
|
-
id
|
|
3104
|
-
|
|
3090
|
+
const row = this.sqliteGet(
|
|
3091
|
+
`SELECT * FROM ${this.mediaTable} WHERE id = ?`,
|
|
3092
|
+
[id]
|
|
3093
|
+
);
|
|
3094
|
+
if (row) item = this.rowToMedia(row, origin);
|
|
3105
3095
|
} else {
|
|
3106
3096
|
const { media: mediaSchema } = await import('./media-7WDX4BDJ.js');
|
|
3107
3097
|
const { eq } = await import('drizzle-orm');
|
|
3108
3098
|
const [row] = await this.db.select().from(mediaSchema).where(eq(mediaSchema.id, id));
|
|
3109
|
-
if (row) item = this.rowToMedia(row);
|
|
3099
|
+
if (row) item = this.rowToMedia(row, origin);
|
|
3110
3100
|
}
|
|
3111
3101
|
if (!item) return;
|
|
3112
3102
|
await this.deleteFile(item.url);
|
|
@@ -3127,7 +3117,7 @@ var MediaService = class _MediaService {
|
|
|
3127
3117
|
async deleteFile(url) {
|
|
3128
3118
|
await this.storage.delete(url);
|
|
3129
3119
|
}
|
|
3130
|
-
async rename(id, newKey) {
|
|
3120
|
+
async rename(id, newKey, origin) {
|
|
3131
3121
|
let item = null;
|
|
3132
3122
|
if (this.dialect === "sqlite") {
|
|
3133
3123
|
item = this.sqliteGet(`SELECT * FROM ${this.mediaTable} WHERE id = ?`, [
|
|
@@ -3137,7 +3127,7 @@ var MediaService = class _MediaService {
|
|
|
3137
3127
|
const { media: mediaSchema } = await import('./media-7WDX4BDJ.js');
|
|
3138
3128
|
const { eq } = await import('drizzle-orm');
|
|
3139
3129
|
const [row] = await this.db.select().from(mediaSchema).where(eq(mediaSchema.id, id));
|
|
3140
|
-
if (row) item = this.rowToMedia(row);
|
|
3130
|
+
if (row) item = this.rowToMedia(row, origin);
|
|
3141
3131
|
}
|
|
3142
3132
|
if (!item) return null;
|
|
3143
3133
|
const newUrl = await this.storage.rename(item.url, newKey);
|
|
@@ -3180,20 +3170,20 @@ var MediaService = class _MediaService {
|
|
|
3180
3170
|
thumbnailUrl: updateData.thumbnailUrl ?? null
|
|
3181
3171
|
};
|
|
3182
3172
|
}
|
|
3183
|
-
async findById(id) {
|
|
3173
|
+
async findById(id, origin) {
|
|
3184
3174
|
if (this.dialect === "sqlite") {
|
|
3185
3175
|
const row2 = this.sqliteGet(
|
|
3186
3176
|
`SELECT * FROM ${this.mediaTable} WHERE id = ?`,
|
|
3187
3177
|
[id]
|
|
3188
3178
|
);
|
|
3189
|
-
return row2 ? this.rowToMedia(row2) : null;
|
|
3179
|
+
return row2 ? this.rowToMedia(row2, origin) : null;
|
|
3190
3180
|
}
|
|
3191
3181
|
const { media: mediaSchema } = await import('./media-7WDX4BDJ.js');
|
|
3192
3182
|
const { eq } = await import('drizzle-orm');
|
|
3193
3183
|
const [row] = await this.db.select().from(mediaSchema).where(eq(mediaSchema.id, id));
|
|
3194
|
-
return row ? this.rowToMedia(row) : null;
|
|
3184
|
+
return row ? this.rowToMedia(row, origin) : null;
|
|
3195
3185
|
}
|
|
3196
|
-
async find(params = {}) {
|
|
3186
|
+
async find(params = {}, origin) {
|
|
3197
3187
|
const {
|
|
3198
3188
|
page = 1,
|
|
3199
3189
|
limit = 30,
|
|
@@ -3229,7 +3219,7 @@ var MediaService = class _MediaService {
|
|
|
3229
3219
|
[...p, limit, offset]
|
|
3230
3220
|
);
|
|
3231
3221
|
return {
|
|
3232
|
-
docs: rows.map((r) => this.rowToMedia(r)),
|
|
3222
|
+
docs: rows.map((r) => this.rowToMedia(r, origin)),
|
|
3233
3223
|
totalDocs: totalDocs2,
|
|
3234
3224
|
page,
|
|
3235
3225
|
limit,
|
|
@@ -3276,14 +3266,14 @@ var MediaService = class _MediaService {
|
|
|
3276
3266
|
const [{ count }] = await this.db.select({ count: sql`count(*)` }).from(mediaSchema).where(whereClause);
|
|
3277
3267
|
const totalDocs = Number(count);
|
|
3278
3268
|
return {
|
|
3279
|
-
docs: docs.map((r) => this.rowToMedia(r)),
|
|
3269
|
+
docs: docs.map((r) => this.rowToMedia(r, origin)),
|
|
3280
3270
|
totalDocs,
|
|
3281
3271
|
page,
|
|
3282
3272
|
limit,
|
|
3283
3273
|
totalPages: Math.ceil(totalDocs / limit)
|
|
3284
3274
|
};
|
|
3285
3275
|
}
|
|
3286
|
-
async update(id, data) {
|
|
3276
|
+
async update(id, data, origin) {
|
|
3287
3277
|
const now = this.now();
|
|
3288
3278
|
if (this.dialect === "sqlite") {
|
|
3289
3279
|
const sets = ["updated_at = ?"];
|
|
@@ -3302,7 +3292,7 @@ var MediaService = class _MediaService {
|
|
|
3302
3292
|
}
|
|
3303
3293
|
if (data.folder !== void 0) {
|
|
3304
3294
|
sets.push("folder = ?");
|
|
3305
|
-
p.push(data.folder
|
|
3295
|
+
p.push(data.folder);
|
|
3306
3296
|
}
|
|
3307
3297
|
p.push(id);
|
|
3308
3298
|
await this.sqliteRun(
|
|
@@ -3313,12 +3303,12 @@ var MediaService = class _MediaService {
|
|
|
3313
3303
|
`SELECT * FROM ${this.mediaTable} WHERE id = ?`,
|
|
3314
3304
|
[id]
|
|
3315
3305
|
);
|
|
3316
|
-
return row ? this.rowToMedia(row) : null;
|
|
3306
|
+
return row ? this.rowToMedia(row, origin) : null;
|
|
3317
3307
|
}
|
|
3318
3308
|
const { media: mediaSchema } = await import('./media-7WDX4BDJ.js');
|
|
3319
3309
|
const { eq } = await import('drizzle-orm');
|
|
3320
3310
|
const [updated] = await this.db.update(mediaSchema).set({ ...data, updatedAt: /* @__PURE__ */ new Date() }).where(eq(mediaSchema.id, id)).returning();
|
|
3321
|
-
return updated ? this.rowToMedia(updated) : null;
|
|
3311
|
+
return updated ? this.rowToMedia(updated, origin) : null;
|
|
3322
3312
|
}
|
|
3323
3313
|
async updateMany(ids, data) {
|
|
3324
3314
|
const now = this.now();
|
|
@@ -4105,12 +4095,13 @@ function createHonoApp(options) {
|
|
|
4105
4095
|
const { user: ctxUser } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
4106
4096
|
if (!ctxUser) return c.json({ error: "Authentication required" }, 401);
|
|
4107
4097
|
const service = await getMedia();
|
|
4098
|
+
const origin = new URL(c.req.url).origin;
|
|
4108
4099
|
const page = parseInt(c.req.query("page") || "1");
|
|
4109
4100
|
const limit = parseInt(c.req.query("limit") || "30");
|
|
4110
4101
|
const search = c.req.query("search") || "";
|
|
4111
4102
|
const type = c.req.query("type") || "";
|
|
4112
4103
|
const folder = c.req.query("folder") || "";
|
|
4113
|
-
const result = await service.find({ page, limit, search, type, folder });
|
|
4104
|
+
const result = await service.find({ page, limit, search, type, folder }, origin);
|
|
4114
4105
|
return c.json(result);
|
|
4115
4106
|
} catch (error) {
|
|
4116
4107
|
console.error("[Media] find error:", error);
|
|
@@ -4194,7 +4185,8 @@ function createHonoApp(options) {
|
|
|
4194
4185
|
if (!ctxUser) return c.json({ error: "Authentication required" }, 401);
|
|
4195
4186
|
const service = await getMedia();
|
|
4196
4187
|
const id = c.req.param("id");
|
|
4197
|
-
|
|
4188
|
+
const origin = new URL(c.req.url).origin;
|
|
4189
|
+
await service.delete(id, origin);
|
|
4198
4190
|
return c.json({ success: true });
|
|
4199
4191
|
} catch (error) {
|
|
4200
4192
|
console.error("[Media] delete error:", error);
|
|
@@ -4250,7 +4242,8 @@ function createHonoApp(options) {
|
|
|
4250
4242
|
if (!ctxUser) return c.json({ error: "Authentication required" }, 401);
|
|
4251
4243
|
const service = await getMedia();
|
|
4252
4244
|
const id = c.req.param("id");
|
|
4253
|
-
const
|
|
4245
|
+
const origin = new URL(c.req.url).origin;
|
|
4246
|
+
const doc = await service.findById(id, origin);
|
|
4254
4247
|
if (!doc) return c.json({ error: "Media not found" }, 404);
|
|
4255
4248
|
return c.json(doc);
|
|
4256
4249
|
} catch (error) {
|
|
@@ -4265,8 +4258,9 @@ function createHonoApp(options) {
|
|
|
4265
4258
|
const service = await getMedia();
|
|
4266
4259
|
const id = c.req.param("id");
|
|
4267
4260
|
const body = await c.req.json();
|
|
4261
|
+
const origin = new URL(c.req.url).origin;
|
|
4268
4262
|
if (body.folder !== void 0) {
|
|
4269
|
-
const updated = await service.update(id, { folder: body.folder });
|
|
4263
|
+
const updated = await service.update(id, { folder: body.folder }, origin);
|
|
4270
4264
|
return c.json({ doc: updated });
|
|
4271
4265
|
}
|
|
4272
4266
|
return c.json({ error: "No valid fields to update" }, 400);
|
|
@@ -5047,6 +5041,75 @@ function createHonoApp(options) {
|
|
|
5047
5041
|
return c.json({ error: error.message }, 500);
|
|
5048
5042
|
}
|
|
5049
5043
|
});
|
|
5044
|
+
function serializeField(field) {
|
|
5045
|
+
const safe = {};
|
|
5046
|
+
const keys = [
|
|
5047
|
+
"name",
|
|
5048
|
+
"type",
|
|
5049
|
+
"required",
|
|
5050
|
+
"hasMany",
|
|
5051
|
+
"relationTo",
|
|
5052
|
+
"options",
|
|
5053
|
+
"min",
|
|
5054
|
+
"max",
|
|
5055
|
+
"minLength",
|
|
5056
|
+
"maxLength",
|
|
5057
|
+
"defaultValue",
|
|
5058
|
+
"label",
|
|
5059
|
+
"localized",
|
|
5060
|
+
"admin",
|
|
5061
|
+
"unique",
|
|
5062
|
+
"index",
|
|
5063
|
+
"hidden",
|
|
5064
|
+
"readOnly",
|
|
5065
|
+
"deprecated"
|
|
5066
|
+
];
|
|
5067
|
+
for (const k of keys) {
|
|
5068
|
+
if (k in field) safe[k] = field[k];
|
|
5069
|
+
}
|
|
5070
|
+
if (field.fields) {
|
|
5071
|
+
safe.fields = field.fields.map(serializeField);
|
|
5072
|
+
}
|
|
5073
|
+
if (field.tabs) {
|
|
5074
|
+
safe.tabs = field.tabs.map((t) => ({
|
|
5075
|
+
label: t.label,
|
|
5076
|
+
name: t.name,
|
|
5077
|
+
fields: t.fields.map(serializeField)
|
|
5078
|
+
}));
|
|
5079
|
+
}
|
|
5080
|
+
return safe;
|
|
5081
|
+
}
|
|
5082
|
+
app.get("/api/__schema", async (c) => {
|
|
5083
|
+
try {
|
|
5084
|
+
const { user: ctxUser, apiKeyContext } = await resolveAuthContext(
|
|
5085
|
+
c.req.raw,
|
|
5086
|
+
authMw,
|
|
5087
|
+
user,
|
|
5088
|
+
tenantID
|
|
5089
|
+
);
|
|
5090
|
+
if (!ctxUser && !apiKeyContext) {
|
|
5091
|
+
return c.json({ error: "Unauthorized" }, 401);
|
|
5092
|
+
}
|
|
5093
|
+
const cols = registry.getCollections().filter(
|
|
5094
|
+
(col) => col.slug !== "users" && col.slug !== "audit_logs"
|
|
5095
|
+
);
|
|
5096
|
+
const serialized = cols.map((col) => ({
|
|
5097
|
+
slug: col.slug,
|
|
5098
|
+
label: col.label,
|
|
5099
|
+
labelPlural: col.labelPlural,
|
|
5100
|
+
singularLabel: col.singularLabel,
|
|
5101
|
+
timestamps: col.timestamps,
|
|
5102
|
+
auth: !!col.auth,
|
|
5103
|
+
tenantScoped: !!col.tenantScoped,
|
|
5104
|
+
upload: col.upload ? { staticDir: col.upload.staticDir, imageSizes: col.upload.imageSizes, mimeTypes: col.upload.mimeTypes } : void 0,
|
|
5105
|
+
fields: col.fields.map(serializeField)
|
|
5106
|
+
}));
|
|
5107
|
+
return c.json(serialized);
|
|
5108
|
+
} catch (error) {
|
|
5109
|
+
console.error("[Schema] error:", error);
|
|
5110
|
+
return c.json({ error: error.message }, 500);
|
|
5111
|
+
}
|
|
5112
|
+
});
|
|
5050
5113
|
const collections = registry.getCollections();
|
|
5051
5114
|
for (const collection of collections) {
|
|
5052
5115
|
let computeDiff2 = function(a, b) {
|
|
@@ -6390,5 +6453,5 @@ function createRESTAPI(registry, db, options) {
|
|
|
6390
6453
|
}
|
|
6391
6454
|
|
|
6392
6455
|
export { AuditLogger, AuthRoutes, InMemoryAuditLogger, InMemoryRateLimiter, MediaService, createAuditContext2 as createAuditContext, createCloudinaryStorage, createFtpStorage, createHonoApp, createLocalStorage, createRESTAPI, createS3Storage, getAppSecret, getDefaultRegistry, getEncryptionKey, getSessionConfig, init_secret, loadSecrets, resolveProvider, setDbAdapter };
|
|
6393
|
-
//# sourceMappingURL=chunk-
|
|
6394
|
-
//# sourceMappingURL=chunk-
|
|
6456
|
+
//# sourceMappingURL=chunk-354ISGA4.js.map
|
|
6457
|
+
//# sourceMappingURL=chunk-354ISGA4.js.map
|