okno 1.0.0-beta.38 → 1.0.0-beta.39
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/astro/index.d.ts +0 -8
- package/dist/astro/index.d.ts.map +1 -1
- package/dist/astro/index.js +6 -18
- package/dist/codegen/modules.d.ts +0 -16
- package/dist/codegen/modules.d.ts.map +1 -1
- package/dist/{dispatch-oBWbJ5Pl.js → dispatch-BifB_3GO.js} +181 -193
- package/dist/editor/index.js +14 -3
- package/dist/index.js +1 -1
- package/dist/next/index.js +1 -1
- package/dist/plugin-BdiBIiAv.js +489 -0
- package/dist/types/schema.d.ts +0 -5
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/codegen/modules-instant.d.ts +0 -21
- package/dist/codegen/modules-instant.d.ts.map +0 -1
- package/dist/plugin-Bgk7L4b7.js +0 -575
- package/dist/runtime/instant.d.ts +0 -55
- package/dist/runtime/instant.d.ts.map +0 -1
- package/dist/runtime/instant.js +0 -146
- package/src/runtime/instant.test.ts +0 -113
- package/src/runtime/instant.ts +0 -287
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { join as _, relative as H, sep as U, dirname as N, resolve as ue } from "node:path";
|
|
2
|
-
import { readdir as E, readFile as
|
|
3
|
-
import { existsSync as $, readFileSync as v, readdirSync as se, statSync as
|
|
2
|
+
import { readdir as E, readFile as we, writeFile as be } from "node:fs/promises";
|
|
3
|
+
import { existsSync as $, readFileSync as v, readdirSync as se, statSync as Se, realpathSync as Oe, writeFileSync as R, mkdirSync as W, unlinkSync as B, renameSync as ve } from "node:fs";
|
|
4
4
|
import { execSync as oe } from "node:child_process";
|
|
5
|
-
import { fileURLToPath as
|
|
5
|
+
import { fileURLToPath as je } from "node:url";
|
|
6
6
|
import { p as Z } from "./parse-tlTHgSSs.js";
|
|
7
|
-
import { o as
|
|
7
|
+
import { o as Ae } from "./order-bAkdncZC.js";
|
|
8
8
|
import { simpleGit as fe } from "simple-git";
|
|
9
|
-
import { b as ee, a as
|
|
10
|
-
import { applyKeyChanges as me, setStringsSchema as
|
|
11
|
-
const
|
|
9
|
+
import { b as ee, a as Te, e as xe } from "./encode-BfJY0Xy5.js";
|
|
10
|
+
import { applyKeyChanges as me, setStringsSchema as Re, saveFields as Pe, setLocales as Ee, setName as Me, setUrl as Ne, renameSlug as Ie, reorderKind as We, setLayout as Fe, setCollectionOrder as Le, setDrafts as Ue, deleteSchemaEntry as Ce, scaffoldEntry as ze, fieldsToContent as Je, EngineError as Ve } from "./engine/index.js";
|
|
11
|
+
const Be = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), Ge = /* @__PURE__ */ new Set([
|
|
12
12
|
"node_modules",
|
|
13
13
|
".astro",
|
|
14
14
|
".svelte-kit",
|
|
@@ -22,16 +22,16 @@ const Ge = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", "
|
|
|
22
22
|
]);
|
|
23
23
|
async function Y(e, n) {
|
|
24
24
|
const s = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']okno[:/]${n}["']`, "g"), i = /* @__PURE__ */ new Set();
|
|
25
|
-
async function u(
|
|
25
|
+
async function u(c) {
|
|
26
26
|
let p;
|
|
27
27
|
try {
|
|
28
|
-
p = await E(
|
|
28
|
+
p = await E(c, { withFileTypes: !0 });
|
|
29
29
|
} catch {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
for (const f of p) {
|
|
33
|
-
if (f.name.startsWith(".") && f.name !== "." ||
|
|
34
|
-
const a = _(
|
|
33
|
+
if (f.name.startsWith(".") && f.name !== "." || Ge.has(f.name)) continue;
|
|
34
|
+
const a = _(c, f.name);
|
|
35
35
|
if (f.isDirectory()) {
|
|
36
36
|
await u(a);
|
|
37
37
|
continue;
|
|
@@ -39,10 +39,10 @@ async function Y(e, n) {
|
|
|
39
39
|
const t = f.name.lastIndexOf(".");
|
|
40
40
|
if (t === -1) continue;
|
|
41
41
|
const r = f.name.slice(t);
|
|
42
|
-
if (!
|
|
42
|
+
if (!Be.has(r)) continue;
|
|
43
43
|
let o;
|
|
44
44
|
try {
|
|
45
|
-
o = await
|
|
45
|
+
o = await we(a, "utf-8");
|
|
46
46
|
} catch {
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
@@ -59,7 +59,7 @@ async function Y(e, n) {
|
|
|
59
59
|
return await u(e), i;
|
|
60
60
|
}
|
|
61
61
|
async function bt(e, n) {
|
|
62
|
-
const s = await
|
|
62
|
+
const s = await et(e), i = new Map(s.map((l) => [l.name, l.first])), u = Ye(e), c = [
|
|
63
63
|
"// Auto-generated by okno. Do not edit.",
|
|
64
64
|
"",
|
|
65
65
|
"/** A wrapped content value that can be spread onto elements and rendered as text. */",
|
|
@@ -120,31 +120,31 @@ async function bt(e, n) {
|
|
|
120
120
|
" readonly updated: OknoWrapped<OknoStamp>",
|
|
121
121
|
"}",
|
|
122
122
|
""
|
|
123
|
-
], p = ([,
|
|
123
|
+
], p = ([, l]) => l?.type === "reference" && typeof l.collection == "string" && i.has(l.collection), f = ([, l]) => l?.type === "enum", a = ([l, g]) => {
|
|
124
124
|
const k = (Array.isArray(g?.options) ? g.options : []).map((w) => typeof w == "string" ? w : w?.value).filter((w) => typeof w == "string"), S = `{ name: string; value: ${k.length ? k.map((w) => JSON.stringify(w)).join(" | ") : "string"} }`;
|
|
125
|
-
return `${
|
|
126
|
-
}, t = (
|
|
127
|
-
const g = u?.collections?.[
|
|
125
|
+
return `${l}: ${g.multiple ? `${S}[]` : S}`;
|
|
126
|
+
}, t = (l) => `typeof import("./collections/${l}/${i.get(l)}").default`, r = (l) => {
|
|
127
|
+
const g = u?.collections?.[l]?.url;
|
|
128
128
|
return typeof g == "string" && g.trim() ? " & { href: string }" : "";
|
|
129
|
-
}, o = (
|
|
130
|
-
const k = t(
|
|
131
|
-
if (w.length === 0 && O.length === 0) return `${k}${r(
|
|
132
|
-
const j = [...w, ...O].map(([P]) => `"${P}"`).join(" | "), A = new Set(g).add(
|
|
129
|
+
}, o = (l, g) => {
|
|
130
|
+
const k = t(l), b = u?.collections?.[l]?.fields, S = b ? Object.entries(b) : [], w = S.filter(p), O = S.filter(f);
|
|
131
|
+
if (w.length === 0 && O.length === 0) return `${k}${r(l)}`;
|
|
132
|
+
const j = [...w, ...O].map(([P]) => `"${P}"`).join(" | "), A = new Set(g).add(l), C = [
|
|
133
133
|
...w.map(([P, I]) => {
|
|
134
134
|
const M = I.collection, x = g.has(M) ? t(M) : o(M, A);
|
|
135
135
|
return `${P}: ${I.multiple ? `(${x})[]` : x}`;
|
|
136
136
|
}),
|
|
137
137
|
...O.map(a)
|
|
138
138
|
].join("; ");
|
|
139
|
-
return `Omit<${k}, ${j}> & { ${C} }${r(
|
|
140
|
-
}, m = (
|
|
141
|
-
const b = `typeof import("${k}").default`, S = u?.[
|
|
139
|
+
return `Omit<${k}, ${j}> & { ${C} }${r(l)}`;
|
|
140
|
+
}, m = (l, g, k) => {
|
|
141
|
+
const b = `typeof import("${k}").default`, S = u?.[l]?.[g]?.fields, w = S ? Object.entries(S) : [], O = w.filter(p), j = w.filter(f), A = '"created" | "updated"', C = l === "collections" ? r(g) : "";
|
|
142
142
|
if (O.length === 0 && j.length === 0)
|
|
143
143
|
return `OknoWrapped<Omit<${b}, ${A}>${C}> & OknoMeta`;
|
|
144
|
-
const P =
|
|
144
|
+
const P = l === "collections" ? /* @__PURE__ */ new Set([g]) : /* @__PURE__ */ new Set(), I = `${[...O, ...j].map(([x]) => `"${x}"`).join(" | ")} | ${A}`, M = [
|
|
145
145
|
...O.map(([x, V]) => {
|
|
146
|
-
const z = V.collection,
|
|
147
|
-
return `${x}: ${V.multiple ? `(${
|
|
146
|
+
const z = V.collection, ce = P.has(z) ? t(z) : o(z, P);
|
|
147
|
+
return `${x}: ${V.multiple ? `(${ce})[]` : ce}`;
|
|
148
148
|
}),
|
|
149
149
|
...j.map(a)
|
|
150
150
|
].join("; ");
|
|
@@ -154,25 +154,25 @@ async function bt(e, n) {
|
|
|
154
154
|
Y(n, "globals"),
|
|
155
155
|
Y(n, "collections")
|
|
156
156
|
]);
|
|
157
|
-
|
|
157
|
+
c.push(
|
|
158
158
|
...de("okno:pages", "pages", await te(_(e, "pages")), d, m)
|
|
159
|
-
),
|
|
159
|
+
), c.push(...Qe(s, y, m)), c.push(
|
|
160
160
|
...de("okno:globals", "globals", await te(_(e, "globals")), h, m)
|
|
161
|
-
),
|
|
162
|
-
for (const
|
|
163
|
-
|
|
164
|
-
await
|
|
161
|
+
), c.push(...Ze(De(e), qe(u))), c.push(...Ke()), c.push(...He());
|
|
162
|
+
for (const l of ["pages", "collections", "globals", "locales", "strings", "content"])
|
|
163
|
+
c.push(`declare module "okno/${l}" {`, ` export * from "okno:${l}";`, "}", "");
|
|
164
|
+
await be(_(e, "modules.d.ts"), c.join(`
|
|
165
165
|
`));
|
|
166
166
|
}
|
|
167
167
|
function de(e, n, s, i, u) {
|
|
168
|
-
const
|
|
168
|
+
const c = /* @__PURE__ */ new Set(), p = [];
|
|
169
169
|
for (const f of s)
|
|
170
|
-
p.push(` export const ${f}: ${u(n, f, `./${n}/${f}`)}`),
|
|
170
|
+
p.push(` export const ${f}: ${u(n, f, `./${n}/${f}`)}`), c.add(f);
|
|
171
171
|
for (const f of i)
|
|
172
|
-
|
|
172
|
+
c.has(f) || p.push(` export const ${f}: OknoUnscaffolded`);
|
|
173
173
|
return [`declare module "${e}" {`, ...p, "}", ""];
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Ke() {
|
|
176
176
|
return [
|
|
177
177
|
'declare module "okno:locales" {',
|
|
178
178
|
' /** A configured language. `id` is the BCP-47 tag (e.g. "zh-Hant"), `name` the display label, `slug` the URL segment you map into routing. `link(url)` returns this page\'s hreflang <link> descriptor — spread onto a <link> (pass Astro.url for an absolute href). Okno owns no routing; you map these. */',
|
|
@@ -188,7 +188,7 @@ function He() {
|
|
|
188
188
|
""
|
|
189
189
|
];
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function He() {
|
|
192
192
|
return [
|
|
193
193
|
'declare module "okno:content" {',
|
|
194
194
|
' /** Unified content namespace — `import * as okno from "okno:content"` then `okno.pages.home`, `okno.globals.nav`, `okno.collections.articles`, `okno.strings.nav.home`. */',
|
|
@@ -200,8 +200,8 @@ function Ze() {
|
|
|
200
200
|
""
|
|
201
201
|
];
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
const s = e.length ? `${
|
|
203
|
+
function Ze(e, n) {
|
|
204
|
+
const s = e.length ? `${Xe(e, n)}` : "any", i = e.length ? `
|
|
205
205
|
locale(code?: string | null): ${s}` : "";
|
|
206
206
|
return [
|
|
207
207
|
'declare module "okno:strings" {',
|
|
@@ -212,7 +212,7 @@ function Xe(e, n) {
|
|
|
212
212
|
""
|
|
213
213
|
];
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function Xe(e, n) {
|
|
216
216
|
const s = { children: /* @__PURE__ */ new Map() };
|
|
217
217
|
for (const p of e) {
|
|
218
218
|
let f = s;
|
|
@@ -224,35 +224,35 @@ function qe(e, n) {
|
|
|
224
224
|
const i = (p) => p === "text" ? "string" : "number", u = (p) => {
|
|
225
225
|
const f = n[p];
|
|
226
226
|
return !f || Object.keys(f).length === 0 ? "OknoValue<string>" : `(p: { ${Object.entries(f).map(([t, r]) => `${JSON.stringify(t)}: ${i(r)}`).join("; ")} }) => OknoValue<string>`;
|
|
227
|
-
},
|
|
228
|
-
([t, r]) => `${JSON.stringify(t)}: ${
|
|
227
|
+
}, c = (p, f) => p.children.size === 0 ? u(f) : `{ ${[...p.children.entries()].map(
|
|
228
|
+
([t, r]) => `${JSON.stringify(t)}: ${c(r, f ? `${f}.${t}` : t)}`
|
|
229
229
|
).join("; ")} }`;
|
|
230
|
-
return
|
|
230
|
+
return c(s, "");
|
|
231
231
|
}
|
|
232
|
-
function
|
|
232
|
+
function qe(e) {
|
|
233
233
|
const n = {}, s = e?.strings;
|
|
234
234
|
if (!s || typeof s != "object" || Array.isArray(s)) return n;
|
|
235
235
|
for (const [i, u] of Object.entries(s)) {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
236
|
+
const c = u?.slots;
|
|
237
|
+
if (!c || typeof c != "object" || Array.isArray(c)) continue;
|
|
238
238
|
const p = {};
|
|
239
|
-
for (const [f, a] of Object.entries(
|
|
239
|
+
for (const [f, a] of Object.entries(c))
|
|
240
240
|
(a === "text" || a === "number" || a === "count") && (p[f] = a);
|
|
241
241
|
Object.keys(p).length && (n[i] = p);
|
|
242
242
|
}
|
|
243
243
|
return n;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Qe(e, n, s) {
|
|
246
246
|
const i = /* @__PURE__ */ new Set(), u = [];
|
|
247
|
-
for (const
|
|
248
|
-
const p = s("collections",
|
|
249
|
-
u.push(` export const ${
|
|
247
|
+
for (const c of e) {
|
|
248
|
+
const p = s("collections", c.name, `./collections/${c.name}/${c.first}`);
|
|
249
|
+
u.push(` export const ${c.name}: (${p} & OknoDrag)[]`), i.add(c.name);
|
|
250
250
|
}
|
|
251
|
-
for (const
|
|
252
|
-
i.has(
|
|
251
|
+
for (const c of n)
|
|
252
|
+
i.has(c) || u.push(` export const ${c}: OknoUnscaffolded[]`);
|
|
253
253
|
return ['declare module "okno:collections" {', ...u, "}", ""];
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function Ye(e) {
|
|
256
256
|
const n = _(e, "schema.ts");
|
|
257
257
|
if (!$(n)) return null;
|
|
258
258
|
try {
|
|
@@ -263,7 +263,7 @@ function De(e) {
|
|
|
263
263
|
return null;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function De(e) {
|
|
267
267
|
const n = _(e, "strings.ts");
|
|
268
268
|
if (!$(n)) return [];
|
|
269
269
|
try {
|
|
@@ -277,13 +277,13 @@ function et(e) {
|
|
|
277
277
|
return [];
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
async function
|
|
280
|
+
async function et(e) {
|
|
281
281
|
const n = _(e, "collections");
|
|
282
282
|
if (!$(n)) return [];
|
|
283
283
|
const s = (await E(n, { withFileTypes: !0 })).filter((u) => u.isDirectory()), i = [];
|
|
284
284
|
for (const u of s) {
|
|
285
|
-
const
|
|
286
|
-
|
|
285
|
+
const c = await te(_(n, u.name));
|
|
286
|
+
c.length > 0 && i.push({ name: u.name, first: c[0] });
|
|
287
287
|
}
|
|
288
288
|
return i;
|
|
289
289
|
}
|
|
@@ -297,7 +297,7 @@ function re(e) {
|
|
|
297
297
|
return null;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function tt() {
|
|
301
301
|
const e = re("git rev-parse --abbrev-ref HEAD");
|
|
302
302
|
if (e && e !== "HEAD") return e;
|
|
303
303
|
const n = process.env;
|
|
@@ -311,31 +311,24 @@ function St() {
|
|
|
311
311
|
const e = re("git remote get-url origin");
|
|
312
312
|
if (!e) return null;
|
|
313
313
|
const n = e.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
314
|
-
return n ? `${n[1]}/${n[2]}@${
|
|
314
|
+
return n ? `${n[1]}/${n[2]}@${tt()}` : null;
|
|
315
315
|
}
|
|
316
316
|
function Ot() {
|
|
317
317
|
const e = re("git rev-parse --show-toplevel");
|
|
318
318
|
return e ? H(e, process.cwd()).split(U).join("/") : "";
|
|
319
319
|
}
|
|
320
|
-
const ae = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', pe = N(
|
|
320
|
+
const ae = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', pe = N(je(import.meta.url)), nt = [
|
|
321
321
|
ue(pe, "./runtime/wrap.js"),
|
|
322
322
|
// bundled at dist/ (Vite plugin chunk)
|
|
323
323
|
ue(pe, "../runtime/wrap.js")
|
|
324
324
|
// bundled at dist/next/ (Next entry)
|
|
325
325
|
];
|
|
326
326
|
function vt() {
|
|
327
|
-
for (const e of
|
|
327
|
+
for (const e of nt)
|
|
328
328
|
if ($(e)) return v(e, "utf-8");
|
|
329
329
|
return null;
|
|
330
330
|
}
|
|
331
331
|
function jt() {
|
|
332
|
-
for (const e of ye) {
|
|
333
|
-
const n = e.replace(/wrap\.js$/, "instant.js");
|
|
334
|
-
if ($(n)) return v(n, "utf-8");
|
|
335
|
-
}
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
function At() {
|
|
339
332
|
return [
|
|
340
333
|
'export * as pages from "okno:pages"',
|
|
341
334
|
'export * as globals from "okno:globals"',
|
|
@@ -350,7 +343,7 @@ function q(e) {
|
|
|
350
343
|
try {
|
|
351
344
|
const i = Z(v(n, "utf-8"))?.locales?.supported;
|
|
352
345
|
if (!Array.isArray(i) || i.length === 0) return null;
|
|
353
|
-
const u = i.map((
|
|
346
|
+
const u = i.map((c) => typeof c == "string" ? c : c?.id).filter((c) => typeof c == "string");
|
|
354
347
|
return u.length ? new Set(u) : null;
|
|
355
348
|
} catch {
|
|
356
349
|
return null;
|
|
@@ -383,22 +376,22 @@ function ot(e) {
|
|
|
383
376
|
return { orders: s, draftsOff: i, schedulingOff: u };
|
|
384
377
|
}
|
|
385
378
|
const rt = /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|[0-9]{3}))?$/i, Q = (e) => e.replace(/[^a-zA-Z0-9]/g, "_");
|
|
386
|
-
function
|
|
379
|
+
function le(e) {
|
|
387
380
|
return e.replace(".ts", "").replace(/-/g, "_");
|
|
388
381
|
}
|
|
389
|
-
function
|
|
382
|
+
function ye(e) {
|
|
390
383
|
return e.replace(".ts", "").replace(/-/g, "_");
|
|
391
384
|
}
|
|
392
385
|
function X(e) {
|
|
393
386
|
return e.replace(".ts", "");
|
|
394
387
|
}
|
|
395
|
-
function
|
|
388
|
+
function At(e) {
|
|
396
389
|
const n = _(e, "schema.ts");
|
|
397
390
|
let s = [], i = "";
|
|
398
391
|
if ($(n))
|
|
399
392
|
try {
|
|
400
|
-
const u = Z(v(n, "utf-8")),
|
|
401
|
-
Array.isArray(
|
|
393
|
+
const u = Z(v(n, "utf-8")), c = u?.locales?.supported;
|
|
394
|
+
Array.isArray(c) && (s = c.map((p) => typeof p == "string" ? { id: p } : p).filter((p) => !!p && typeof p.id == "string").map((p) => ({
|
|
402
395
|
id: p.id,
|
|
403
396
|
name: p.name || st(p.id),
|
|
404
397
|
// Preserve an intentionally empty slug (= no URL prefix for the default).
|
|
@@ -434,7 +427,7 @@ function Tt(e) {
|
|
|
434
427
|
].join(`
|
|
435
428
|
`);
|
|
436
429
|
}
|
|
437
|
-
async function
|
|
430
|
+
async function Tt(e) {
|
|
438
431
|
const n = _(e, "strings.ts");
|
|
439
432
|
if (!$(n))
|
|
440
433
|
return [
|
|
@@ -442,9 +435,9 @@ async function xt(e) {
|
|
|
442
435
|
'export const strings = __oknoMakeStrings({}, {}, "")'
|
|
443
436
|
].join(`
|
|
444
437
|
`);
|
|
445
|
-
const s = _(e, "schema.ts"), i = $(s), u = q(e),
|
|
446
|
-
if ($(
|
|
447
|
-
const o = await E(
|
|
438
|
+
const s = _(e, "schema.ts"), i = $(s), u = q(e), c = _(e, "strings"), p = [];
|
|
439
|
+
if ($(c)) {
|
|
440
|
+
const o = await E(c, { withFileTypes: !0 });
|
|
448
441
|
for (const m of o) {
|
|
449
442
|
if (!m.isFile() || !m.name.endsWith(".ts") || m.name === "index.ts") continue;
|
|
450
443
|
const d = m.name.replace(/\.ts$/, "");
|
|
@@ -463,17 +456,17 @@ async function xt(e) {
|
|
|
463
456
|
const r = [];
|
|
464
457
|
for (const o of p) {
|
|
465
458
|
const m = Q(o);
|
|
466
|
-
f.push(`import _strings_${m} from "${_(
|
|
459
|
+
f.push(`import _strings_${m} from "${_(c, o + ".ts")}"`), r.push(`"${o}": __oknoExpandStrings(_strings_${m})`);
|
|
467
460
|
}
|
|
468
461
|
return f.push("const _strings_base = __oknoExpandStrings(_strings_default)"), f.push(`const _strings_localized = __oknoLocalize(_strings_base, { ${r.join(", ")} })`), f.push(`export const strings = __oknoMakeStrings(_strings_localized, ${a}, ${t})`), f.join(`
|
|
469
462
|
`);
|
|
470
463
|
}
|
|
471
|
-
async function
|
|
472
|
-
const s = _(e, "pages"), i = _(e, "schema.ts"), u = $(i),
|
|
464
|
+
async function xt(e, n = /* @__PURE__ */ new Set()) {
|
|
465
|
+
const s = _(e, "pages"), i = _(e, "schema.ts"), u = $(i), c = [
|
|
473
466
|
'import { __oknoWrap, __oknoLocalize, __oknoResolveRefs, __oknoResolveEnums, __oknoSetImages, __oknoSetRoutes } from "okno:runtime"',
|
|
474
467
|
ae
|
|
475
468
|
];
|
|
476
|
-
u && (
|
|
469
|
+
u && (c.push('import * as __collections from "okno:collections"'), c.push(`import __schema from "${i}"`), c.push("__oknoSetRoutes(__schema)"));
|
|
477
470
|
let p = "[]";
|
|
478
471
|
const f = (t, r) => {
|
|
479
472
|
if (!u) return `_${t}`;
|
|
@@ -485,9 +478,9 @@ async function Rt(e, n = /* @__PURE__ */ new Set()) {
|
|
|
485
478
|
p = JSON.stringify(o);
|
|
486
479
|
const m = await ie(s);
|
|
487
480
|
for (const d of m) {
|
|
488
|
-
const h =
|
|
481
|
+
const h = le(d), y = ye(d), l = X(d), g = _(s, d);
|
|
489
482
|
if (o.length === 0) {
|
|
490
|
-
|
|
483
|
+
c.push(`import _${h} from "${g}"`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
|
|
491
484
|
continue;
|
|
492
485
|
}
|
|
493
486
|
const k = [`import _${h}_default from "${g}"`], b = [];
|
|
@@ -498,31 +491,31 @@ async function Rt(e, n = /* @__PURE__ */ new Set()) {
|
|
|
498
491
|
k.push(`import _${h}_${O} from "${w}"`), b.push(`"${S}": _${h}_${O}`);
|
|
499
492
|
}
|
|
500
493
|
}
|
|
501
|
-
|
|
494
|
+
c.push(...k), c.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
|
|
502
495
|
}
|
|
503
496
|
}
|
|
504
497
|
for (const t of n)
|
|
505
|
-
a.has(t) ||
|
|
506
|
-
return
|
|
498
|
+
a.has(t) || c.push(`export const ${t} = __oknoWrap(null, "${t}")`);
|
|
499
|
+
return c.join(`
|
|
507
500
|
`);
|
|
508
501
|
}
|
|
509
|
-
async function
|
|
502
|
+
async function Rt(e, n = /* @__PURE__ */ new Set(), s = !1) {
|
|
510
503
|
const i = _(e, "collections");
|
|
511
504
|
if (!$(i)) {
|
|
512
|
-
const
|
|
505
|
+
const l = [];
|
|
513
506
|
for (const g of n) {
|
|
514
507
|
const k = g.replace(/-/g, "_");
|
|
515
|
-
|
|
508
|
+
l.push(`export const ${k} = []`);
|
|
516
509
|
}
|
|
517
|
-
return
|
|
510
|
+
return l.join(`
|
|
518
511
|
`) || "export {}";
|
|
519
512
|
}
|
|
520
|
-
const u = q(e),
|
|
521
|
-
for (const
|
|
522
|
-
const g = await E(_(i,
|
|
513
|
+
const u = q(e), c = await E(i, { withFileTypes: !0 }), p = c.filter((l) => l.isDirectory() && K(l.name, u)).map((l) => l.name), f = c.filter((l) => l.isDirectory() && !p.includes(l.name)).map((l) => l.name), a = JSON.stringify(p);
|
|
514
|
+
for (const l of f) {
|
|
515
|
+
const g = await E(_(i, l), { withFileTypes: !0 }).catch(() => []);
|
|
523
516
|
for (const k of g)
|
|
524
517
|
k.isDirectory() && K(k.name, u) && console.warn(
|
|
525
|
-
`[okno] "collections/${
|
|
518
|
+
`[okno] "collections/${l}/${k.name}/" looks like a misplaced locale folder. Collection locale overrides go at "collections/${k.name}/${l}/<slug>.ts" (locale right after "collections/"). This folder will NOT be localized.`
|
|
526
519
|
);
|
|
527
520
|
}
|
|
528
521
|
const { orders: t, draftsOff: r, schedulingOff: o } = ot(e), m = _(e, "schema.ts"), d = $(m), h = [
|
|
@@ -531,16 +524,16 @@ async function Pt(e, n = /* @__PURE__ */ new Set(), s = !1) {
|
|
|
531
524
|
];
|
|
532
525
|
d && (h.push(`import __schema from "${m}"`), h.push("__oknoSetRoutes(__schema)"));
|
|
533
526
|
const y = [];
|
|
534
|
-
for (const
|
|
535
|
-
const g = _(i,
|
|
527
|
+
for (const l of f) {
|
|
528
|
+
const g = _(i, l), k = Ae(await ie(g), X, t[l]), b = l.replace(/-/g, "_"), S = s && !r.has(l), w = s && !o.has(l), O = [];
|
|
536
529
|
for (const j of k) {
|
|
537
|
-
const A = `_${b}_${
|
|
530
|
+
const A = `_${b}_${le(j)}`, C = X(j), P = _(g, j);
|
|
538
531
|
if (p.length === 0)
|
|
539
532
|
h.push(`import ${A} from "${P}"`);
|
|
540
533
|
else {
|
|
541
534
|
const I = [`import ${A}_default from "${P}"`], M = [];
|
|
542
535
|
for (const x of p) {
|
|
543
|
-
const V = _(i, x,
|
|
536
|
+
const V = _(i, x, l, j);
|
|
544
537
|
if ($(V)) {
|
|
545
538
|
const z = Q(x);
|
|
546
539
|
I.push(`import ${A}_${z} from "${V}"`), M.push(`"${x}": ${A}_${z}`);
|
|
@@ -550,24 +543,24 @@ async function Pt(e, n = /* @__PURE__ */ new Set(), s = !1) {
|
|
|
550
543
|
}
|
|
551
544
|
O.push({ varName: A, itemName: C });
|
|
552
545
|
}
|
|
553
|
-
h.push(`const __oknoRaw_${b} = [${O.map((j) => j.varName).join(", ")}]`), y.push({ name:
|
|
546
|
+
h.push(`const __oknoRaw_${b} = [${O.map((j) => j.varName).join(", ")}]`), y.push({ name: l, safe: b, draftsOn: S, schedulingOn: w, items: O });
|
|
554
547
|
}
|
|
555
|
-
d && h.push(`const __oknoNs = { ${y.map((
|
|
556
|
-
for (const
|
|
557
|
-
const g = `__schema?.collections?.["${
|
|
558
|
-
|
|
559
|
-
const S = b.length ? `[${
|
|
560
|
-
h.push(`export const ${
|
|
548
|
+
d && h.push(`const __oknoNs = { ${y.map((l) => `${l.safe}: __oknoRaw_${l.safe}`).join(", ")} }`);
|
|
549
|
+
for (const l of y) {
|
|
550
|
+
const g = `__schema?.collections?.["${l.name}"]?.fields`, k = (w) => d ? `__oknoResolveEnums(__oknoResolveRefs(${w.varName}, ${g}, __oknoNs, ${a}), ${g}, ${a})` : w.varName, b = [];
|
|
551
|
+
l.draftsOn && b.push('e[0]?.status !== "draft"'), l.schedulingOn && b.push("__oknoVisible(e[0])");
|
|
552
|
+
const S = b.length ? `[${l.items.map((w) => `[${w.varName}, ${k(w)}, ${JSON.stringify(w.itemName)}]`).join(", ")}].filter((e) => ${b.join(" && ")}).map((e, __i) => __oknoWrap(e[1], "${l.name}." + e[2], "${l.name}." + __i))` : `[${l.items.map((w, O) => `__oknoWrap(${k(w)}, "${l.name}.${w.itemName}", "${l.name}.${O}")`).join(", ")}]`;
|
|
553
|
+
h.push(`export const ${l.safe} = ${S}`);
|
|
561
554
|
}
|
|
562
555
|
return h.join(`
|
|
563
556
|
`);
|
|
564
557
|
}
|
|
565
|
-
async function
|
|
566
|
-
const s = _(e, "globals"), i = _(e, "schema.ts"), u = $(i),
|
|
558
|
+
async function Pt(e, n = /* @__PURE__ */ new Set()) {
|
|
559
|
+
const s = _(e, "globals"), i = _(e, "schema.ts"), u = $(i), c = [
|
|
567
560
|
'import { __oknoWrap, __oknoLocalize, __oknoResolveRefs, __oknoResolveEnums, __oknoSetImages, __oknoSetRoutes } from "okno:runtime"',
|
|
568
561
|
ae
|
|
569
562
|
];
|
|
570
|
-
u && (
|
|
563
|
+
u && (c.push('import * as __collections from "okno:collections"'), c.push(`import __schema from "${i}"`), c.push("__oknoSetRoutes(__schema)"));
|
|
571
564
|
let p = "[]";
|
|
572
565
|
const f = (t, r) => {
|
|
573
566
|
if (!u) return `_${t}`;
|
|
@@ -579,9 +572,9 @@ async function Et(e, n = /* @__PURE__ */ new Set()) {
|
|
|
579
572
|
p = JSON.stringify(o);
|
|
580
573
|
const m = await ie(s);
|
|
581
574
|
for (const d of m) {
|
|
582
|
-
const h =
|
|
575
|
+
const h = le(d), y = ye(d), l = X(d), g = _(s, d);
|
|
583
576
|
if (o.length === 0) {
|
|
584
|
-
|
|
577
|
+
c.push(`import _${h} from "${g}"`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
|
|
585
578
|
continue;
|
|
586
579
|
}
|
|
587
580
|
const k = [`import _${h}_default from "${g}"`], b = [];
|
|
@@ -592,20 +585,20 @@ async function Et(e, n = /* @__PURE__ */ new Set()) {
|
|
|
592
585
|
k.push(`import _${h}_${O} from "${w}"`), b.push(`"${S}": _${h}_${O}`);
|
|
593
586
|
}
|
|
594
587
|
}
|
|
595
|
-
|
|
588
|
+
c.push(...k), c.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
|
|
596
589
|
}
|
|
597
590
|
}
|
|
598
591
|
for (const t of n)
|
|
599
|
-
a.has(t) ||
|
|
600
|
-
return
|
|
592
|
+
a.has(t) || c.push(`export const ${t} = __oknoWrap(null, "${t}")`);
|
|
593
|
+
return c.join(`
|
|
601
594
|
`);
|
|
602
595
|
}
|
|
603
|
-
const
|
|
596
|
+
const $e = /* @__PURE__ */ new Map();
|
|
604
597
|
function L(e) {
|
|
605
|
-
|
|
598
|
+
$e.set(e, Date.now());
|
|
606
599
|
}
|
|
607
|
-
function
|
|
608
|
-
const n =
|
|
600
|
+
function Et(e) {
|
|
601
|
+
const n = $e.get(e);
|
|
609
602
|
return n !== void 0 && Date.now() - n < 3e3;
|
|
610
603
|
}
|
|
611
604
|
const at = ["pages", "collections", "globals"];
|
|
@@ -622,10 +615,10 @@ function J(e, n) {
|
|
|
622
615
|
function it(e) {
|
|
623
616
|
const n = {}, s = (u) => {
|
|
624
617
|
if ($(u))
|
|
625
|
-
for (const
|
|
626
|
-
const p = _(u,
|
|
627
|
-
if (
|
|
628
|
-
else if (
|
|
618
|
+
for (const c of se(u, { withFileTypes: !0 })) {
|
|
619
|
+
const p = _(u, c.name);
|
|
620
|
+
if (c.isDirectory()) s(p);
|
|
621
|
+
else if (c.name.endsWith(".ts") && c.name !== "index.ts") {
|
|
629
622
|
const f = H(e, p).split(U).join("/");
|
|
630
623
|
n[f] = v(p, "utf-8");
|
|
631
624
|
}
|
|
@@ -635,28 +628,28 @@ function it(e) {
|
|
|
635
628
|
const i = _(e, "strings.ts");
|
|
636
629
|
return $(i) && (n["strings.ts"] = v(i, "utf-8")), s(_(e, "strings")), n;
|
|
637
630
|
}
|
|
638
|
-
function
|
|
631
|
+
function ke(e) {
|
|
639
632
|
const n = _(e, "files"), s = [], i = (u) => {
|
|
640
633
|
if ($(u))
|
|
641
|
-
for (const
|
|
642
|
-
const p = _(u,
|
|
643
|
-
if (
|
|
644
|
-
else if (
|
|
634
|
+
for (const c of se(u, { withFileTypes: !0 })) {
|
|
635
|
+
const p = _(u, c.name);
|
|
636
|
+
if (c.isDirectory()) i(p);
|
|
637
|
+
else if (c.name !== ".okno-tree.json") {
|
|
645
638
|
const f = H(n, p).split(U).join("/");
|
|
646
|
-
s.push({ path: `files/${f}`, filename:
|
|
639
|
+
s.push({ path: `files/${f}`, filename: c.name, size: Se(p).size });
|
|
647
640
|
}
|
|
648
641
|
}
|
|
649
642
|
};
|
|
650
643
|
return i(n), s;
|
|
651
644
|
}
|
|
652
|
-
function
|
|
645
|
+
function lt(e) {
|
|
653
646
|
const n = _(e, "schema.ts"), s = _(e, "users.json"), i = _(e, "origins.json");
|
|
654
647
|
return {
|
|
655
648
|
schema: $(n) ? v(n, "utf-8") : null,
|
|
656
649
|
users: $(s) ? v(s, "utf-8") : null,
|
|
657
650
|
origins: $(i) ? v(i, "utf-8") : null,
|
|
658
651
|
content: it(e),
|
|
659
|
-
files:
|
|
652
|
+
files: ke(e)
|
|
660
653
|
};
|
|
661
654
|
}
|
|
662
655
|
const he = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "-"), ge = (e) => e.split("/").map((n) => n.replace(/[^a-zA-Z0-9._-]/g, "-")).filter((n) => n && n !== "-" && n !== "..").join("/");
|
|
@@ -666,8 +659,8 @@ function T(e) {
|
|
|
666
659
|
|
|
667
660
|
`, i = {};
|
|
668
661
|
if ($(n)) {
|
|
669
|
-
const u = v(n, "utf-8"),
|
|
670
|
-
|
|
662
|
+
const u = v(n, "utf-8"), c = u.indexOf("export default");
|
|
663
|
+
c > 0 && (s = u.slice(0, c));
|
|
671
664
|
try {
|
|
672
665
|
i = Z(u) ?? {};
|
|
673
666
|
} catch {
|
|
@@ -676,19 +669,19 @@ function T(e) {
|
|
|
676
669
|
}
|
|
677
670
|
return { schema: i, header: s };
|
|
678
671
|
}
|
|
679
|
-
function
|
|
680
|
-
R(_(e, "schema.ts"),
|
|
672
|
+
function ct(e, n, s) {
|
|
673
|
+
R(_(e, "schema.ts"), Te(n, s));
|
|
681
674
|
}
|
|
682
675
|
function ut(e, n, s, i, u) {
|
|
683
|
-
const
|
|
684
|
-
if (!$(
|
|
676
|
+
const c = _(e, n), p = new Set(u), f = [];
|
|
677
|
+
if (!$(c) || Object.keys(i).length === 0 && p.size === 0) return f;
|
|
685
678
|
const a = [], t = (r) => {
|
|
686
679
|
for (const o of se(r, { withFileTypes: !0 })) {
|
|
687
680
|
const m = _(r, o.name);
|
|
688
681
|
o.isDirectory() ? t(m) : o.name === `${s}.ts` && a.push(m);
|
|
689
682
|
}
|
|
690
683
|
};
|
|
691
|
-
t(
|
|
684
|
+
t(c);
|
|
692
685
|
for (const r of a) {
|
|
693
686
|
let o;
|
|
694
687
|
try {
|
|
@@ -700,8 +693,8 @@ function ut(e, n, s, i, u) {
|
|
|
700
693
|
if (Array.isArray(o))
|
|
701
694
|
m = o.map((y) => {
|
|
702
695
|
if (y && typeof y == "object" && !Array.isArray(y)) {
|
|
703
|
-
const
|
|
704
|
-
return
|
|
696
|
+
const l = me(y, i, p);
|
|
697
|
+
return l.changed && (d = !0), l.out;
|
|
705
698
|
}
|
|
706
699
|
return y;
|
|
707
700
|
});
|
|
@@ -722,7 +715,7 @@ function ne(e) {
|
|
|
722
715
|
return D || (D = oe("git rev-parse --show-toplevel", { cwd: e, encoding: "utf-8" }).trim()), D;
|
|
723
716
|
}
|
|
724
717
|
function _e(e) {
|
|
725
|
-
return H(ne(e),
|
|
718
|
+
return H(ne(e), Oe(e)).split(U).join("/");
|
|
726
719
|
}
|
|
727
720
|
let G;
|
|
728
721
|
function ft(e) {
|
|
@@ -734,28 +727,28 @@ function ft(e) {
|
|
|
734
727
|
}
|
|
735
728
|
return G;
|
|
736
729
|
}
|
|
737
|
-
async function
|
|
738
|
-
const { method: s, route: i } = n, u = { files: [], modules: [] },
|
|
730
|
+
async function Mt(e, n) {
|
|
731
|
+
const { method: s, route: i } = n, u = { files: [], modules: [] }, c = (t, r) => {
|
|
739
732
|
const o = t.split("/")[0];
|
|
740
733
|
o !== "pages" && o !== "collections" && o !== "globals" || (u.modules.push(o), u.files.push(r));
|
|
741
734
|
}, p = () => u.modules.push("pages", "collections", "globals"), f = (t, r) => {
|
|
742
|
-
|
|
735
|
+
ct(e, t, r), p();
|
|
743
736
|
}, a = (t, r) => ({ status: t, body: r, invalidation: u });
|
|
744
737
|
try {
|
|
745
|
-
if (s === "GET" && i === "content") return a(200,
|
|
738
|
+
if (s === "GET" && i === "content") return a(200, lt(e));
|
|
746
739
|
if (s === "POST" && i === "content/save") {
|
|
747
740
|
const { path: t, content: r, created: o, author: m } = await n.json();
|
|
748
741
|
if (!t || !r) return a(400, { error: "Missing path or content" });
|
|
749
742
|
const d = F(e, t);
|
|
750
743
|
if (!d) return a(400, { error: "Invalid path" });
|
|
751
|
-
const h =
|
|
752
|
-
return W(N(d), { recursive: !0 }), L(d), R(d, h),
|
|
744
|
+
const h = xe(r, { now: (/* @__PURE__ */ new Date()).toISOString(), author: m || ft(e), created: o });
|
|
745
|
+
return W(N(d), { recursive: !0 }), L(d), R(d, h), c(t, d), a(200, { ok: !0, commit: { fileSha: "" } });
|
|
753
746
|
}
|
|
754
747
|
if (s === "POST" && i === "content/delete") {
|
|
755
748
|
const t = (await n.json())?.path;
|
|
756
749
|
if (!t) return a(400, { error: "Missing path" });
|
|
757
750
|
const r = F(e, t);
|
|
758
|
-
return r ? ($(r) && (B(r),
|
|
751
|
+
return r ? ($(r) && (B(r), c(t, r)), a(200, { ok: !0 })) : a(400, { error: "Invalid path" });
|
|
759
752
|
}
|
|
760
753
|
if (s === "POST" && i === "strings/save") {
|
|
761
754
|
const { path: t, content: r } = await n.json();
|
|
@@ -768,11 +761,11 @@ async function Nt(e, n) {
|
|
|
768
761
|
const { strings: t } = await n.json();
|
|
769
762
|
if (t != null && (typeof t != "object" || Array.isArray(t))) return a(400, { error: "Invalid strings" });
|
|
770
763
|
const { schema: r, header: o } = T(e);
|
|
771
|
-
return
|
|
764
|
+
return Re(r, t), f(r, o), u.modules.push("strings", "content"), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
|
|
772
765
|
}
|
|
773
766
|
if (s === "GET" && i === "publish-state")
|
|
774
767
|
try {
|
|
775
|
-
const t = fe(ne(e)), r = await t.status(), o = _e(e), m = (
|
|
768
|
+
const t = fe(ne(e)), r = await t.status(), o = _e(e), m = (l) => l.startsWith(o + "/"), d = r.files.map((l) => l.path).filter(m);
|
|
776
769
|
let h = [];
|
|
777
770
|
if (r.ahead > 0)
|
|
778
771
|
try {
|
|
@@ -794,9 +787,9 @@ async function Nt(e, n) {
|
|
|
794
787
|
let h = !1, y = null;
|
|
795
788
|
try {
|
|
796
789
|
(d || o.ahead > 0) && (await t.push(), h = !0);
|
|
797
|
-
} catch (
|
|
798
|
-
y =
|
|
799
|
-
`)[0] : String(
|
|
790
|
+
} catch (l) {
|
|
791
|
+
y = l instanceof Error ? l.message.split(`
|
|
792
|
+
`)[0] : String(l);
|
|
800
793
|
}
|
|
801
794
|
return a(200, { ok: !0, alreadyUpToDate: !d && o.ahead === 0, committed: d, pushed: h, pushError: y });
|
|
802
795
|
}
|
|
@@ -804,79 +797,79 @@ async function Nt(e, n) {
|
|
|
804
797
|
const { kind: t, name: r, fields: o, renames: m, deletes: d } = await n.json();
|
|
805
798
|
if (!t || !r || !o) return a(400, { error: "Missing kind, name or fields" });
|
|
806
799
|
const { schema: h, header: y } = T(e);
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
if (Object.keys(
|
|
810
|
-
for (const { rel: k, abs: b } of ut(e, t, r,
|
|
800
|
+
Pe(h, t, r, o), f(h, y);
|
|
801
|
+
const l = m && typeof m == "object" ? m : {}, g = Array.isArray(d) ? d : [];
|
|
802
|
+
if (Object.keys(l).length > 0 || g.length > 0)
|
|
803
|
+
for (const { rel: k, abs: b } of ut(e, t, r, l, g)) c(k, b);
|
|
811
804
|
return a(200, { ok: !0, commit: { fileSha: "" }, schema: h });
|
|
812
805
|
}
|
|
813
806
|
if (s === "POST" && i === "schema/set-locales") {
|
|
814
807
|
const t = (await n.json())?.locales, { schema: r, header: o } = T(e);
|
|
815
|
-
return
|
|
808
|
+
return Ee(r, t), f(r, o), a(200, { ok: !0, commit: { fileSha: "" } });
|
|
816
809
|
}
|
|
817
810
|
if (s === "POST" && i === "schema/set-name") {
|
|
818
811
|
const { kind: t, slug: r, name: o } = await n.json();
|
|
819
812
|
if (!t || !r || !o) return a(400, { error: "Missing kind, slug or name" });
|
|
820
813
|
const { schema: m, header: d } = T(e);
|
|
821
|
-
return
|
|
814
|
+
return Me(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
|
|
822
815
|
}
|
|
823
816
|
if (s === "POST" && i === "schema/set-url") {
|
|
824
817
|
const { kind: t, slug: r, url: o } = await n.json();
|
|
825
818
|
if (!t || !r) return a(400, { error: "Missing kind or slug" });
|
|
826
819
|
const { schema: m, header: d } = T(e);
|
|
827
|
-
return
|
|
820
|
+
return Ne(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
|
|
828
821
|
}
|
|
829
822
|
if (s === "POST" && i === "schema/rename-slug") {
|
|
830
823
|
const { kind: t, from: r, to: o } = await n.json();
|
|
831
824
|
if (!t || !r || !o) return a(400, { error: "Missing kind, from or to" });
|
|
832
|
-
const { schema: m, header: d } = T(e), { unchanged: h } =
|
|
825
|
+
const { schema: m, header: d } = T(e), { unchanged: h } = Ie(m, t, r, o);
|
|
833
826
|
if (h) return a(200, { ok: !0, unchanged: !0 });
|
|
834
827
|
f(m, d);
|
|
835
|
-
const y = `${t}/${r}.ts`,
|
|
836
|
-
return g && k && $(g) && (W(N(k), { recursive: !0 }), L(g), L(k), R(k, v(g)), B(g),
|
|
828
|
+
const y = `${t}/${r}.ts`, l = `${t}/${o}.ts`, g = F(e, y), k = F(e, l);
|
|
829
|
+
return g && k && $(g) && (W(N(k), { recursive: !0 }), L(g), L(k), R(k, v(g)), B(g), c(y, g), c(l, k)), a(200, { ok: !0, commit: { fileSha: "" }, schema: m, from: r, to: o, kind: t });
|
|
837
830
|
}
|
|
838
831
|
if (s === "POST" && i === "schema/reorder") {
|
|
839
832
|
const { kind: t, order: r } = await n.json();
|
|
840
833
|
if (!t || !Array.isArray(r)) return a(400, { error: "Missing kind or order" });
|
|
841
834
|
const { schema: o, header: m } = T(e);
|
|
842
|
-
return
|
|
835
|
+
return We(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
|
|
843
836
|
}
|
|
844
837
|
if (s === "POST" && i === "schema/set-layout") {
|
|
845
838
|
const { kind: t, layout: r } = await n.json();
|
|
846
839
|
if (!t || !Array.isArray(r)) return a(400, { error: "Missing kind or layout" });
|
|
847
840
|
const { schema: o, header: m } = T(e);
|
|
848
|
-
return
|
|
841
|
+
return Fe(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
|
|
849
842
|
}
|
|
850
843
|
if (s === "POST" && i === "collections/set-order") {
|
|
851
844
|
const { name: t, order: r } = await n.json();
|
|
852
845
|
if (!t || !Array.isArray(r)) return a(400, { error: "Missing name or order" });
|
|
853
846
|
const { schema: o, header: m } = T(e);
|
|
854
|
-
return
|
|
847
|
+
return Le(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
|
|
855
848
|
}
|
|
856
849
|
if (s === "POST" && i === "collections/set-drafts") {
|
|
857
850
|
const { name: t, drafts: r } = await n.json();
|
|
858
851
|
if (!t || typeof r != "boolean") return a(400, { error: "Missing name or drafts" });
|
|
859
852
|
const { schema: o, header: m } = T(e);
|
|
860
|
-
return
|
|
853
|
+
return Ue(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
|
|
861
854
|
}
|
|
862
855
|
if (s === "POST" && i === "schema/delete-entry") {
|
|
863
856
|
const { kind: t, name: r } = await n.json();
|
|
864
857
|
if (!t || !r) return a(400, { error: "Missing kind or name" });
|
|
865
858
|
const { schema: o, header: m } = T(e);
|
|
866
|
-
|
|
859
|
+
Ce(o, t, r), f(o, m);
|
|
867
860
|
const d = `${t}/${r}.ts`, h = F(e, d);
|
|
868
|
-
return h && $(h) && (L(h), B(h),
|
|
861
|
+
return h && $(h) && (L(h), B(h), c(d, h)), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
|
|
869
862
|
}
|
|
870
863
|
if (s === "POST" && i === "setup/scaffold-page") {
|
|
871
864
|
const { name: t, kind: r, fields: o, label: m } = await n.json();
|
|
872
865
|
if (!t || !r) return a(400, { error: "Missing name or kind" });
|
|
873
866
|
const d = o ?? [], { schema: h, header: y } = T(e);
|
|
874
|
-
if (
|
|
875
|
-
const
|
|
867
|
+
if (ze(h, t, r, d, m), f(h, y), r !== "blocks") {
|
|
868
|
+
const l = `${r}/${t}.ts`, g = F(e, l);
|
|
876
869
|
if (g) {
|
|
877
870
|
const k = r === "collections" ? `export default []
|
|
878
|
-
` : ee(
|
|
879
|
-
W(N(g), { recursive: !0 }), L(g), R(g, k), l
|
|
871
|
+
` : ee(Je(d));
|
|
872
|
+
W(N(g), { recursive: !0 }), L(g), R(g, k), c(l, g);
|
|
880
873
|
}
|
|
881
874
|
}
|
|
882
875
|
return a(200, { ok: !0 });
|
|
@@ -884,7 +877,7 @@ async function Nt(e, n) {
|
|
|
884
877
|
if (s === "GET" && i === "files") {
|
|
885
878
|
const t = _(e, "files", ".okno-tree.json");
|
|
886
879
|
return a(200, {
|
|
887
|
-
files:
|
|
880
|
+
files: ke(e),
|
|
888
881
|
manifest: $(t) ? v(t, "utf-8") : null
|
|
889
882
|
});
|
|
890
883
|
}
|
|
@@ -924,7 +917,7 @@ async function Nt(e, n) {
|
|
|
924
917
|
const { from: t, to: r } = await n.json();
|
|
925
918
|
if (!t || !r) return a(400, { error: "Missing from or to" });
|
|
926
919
|
const o = J(e, t), m = J(e, r);
|
|
927
|
-
return !o || !m ? a(400, { error: "Invalid path" }) : $(o) ? (W(N(m), { recursive: !0 }),
|
|
920
|
+
return !o || !m ? a(400, { error: "Invalid path" }) : $(o) ? (W(N(m), { recursive: !0 }), ve(o, m), a(200, { ok: !0, commit: { fileSha: "" } })) : a(404, { error: "Source not found" });
|
|
928
921
|
}
|
|
929
922
|
if (s === "POST" && i === "users/save") {
|
|
930
923
|
const t = (await n.json())?.users;
|
|
@@ -940,28 +933,23 @@ async function Nt(e, n) {
|
|
|
940
933
|
}
|
|
941
934
|
return null;
|
|
942
935
|
} catch (t) {
|
|
943
|
-
return t instanceof
|
|
936
|
+
return t instanceof Ve ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
|
|
944
937
|
}
|
|
945
938
|
}
|
|
946
939
|
export {
|
|
947
940
|
ae as I,
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
941
|
+
Rt as a,
|
|
942
|
+
xt as b,
|
|
943
|
+
Pt as c,
|
|
944
|
+
Tt as d,
|
|
945
|
+
At as e,
|
|
946
|
+
jt as f,
|
|
954
947
|
vt as g,
|
|
955
948
|
Ot as h,
|
|
956
949
|
St as i,
|
|
957
950
|
bt as j,
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
Mt as o,
|
|
963
|
-
ct as p,
|
|
964
|
-
ot as r,
|
|
965
|
-
Y as s,
|
|
966
|
-
X as t
|
|
951
|
+
Mt as k,
|
|
952
|
+
Et as l,
|
|
953
|
+
lt as m,
|
|
954
|
+
Y as s
|
|
967
955
|
};
|