okno 1.0.0-beta4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +138 -0
  2. package/dist/adapters/astro.d.ts +3 -0
  3. package/dist/adapters/astro.d.ts.map +1 -0
  4. package/dist/adapters/astro.js +32 -0
  5. package/dist/adapters/index.d.ts +3 -0
  6. package/dist/adapters/index.d.ts.map +1 -0
  7. package/dist/adapters/vite.d.ts +4 -0
  8. package/dist/adapters/vite.d.ts.map +1 -0
  9. package/dist/adapters/vite.js +21 -0
  10. package/dist/client-CeppRtrT.js +55 -0
  11. package/dist/core/__tests__/builders.test.d.ts +2 -0
  12. package/dist/core/__tests__/builders.test.d.ts.map +1 -0
  13. package/dist/core/__tests__/fields.test.d.ts +2 -0
  14. package/dist/core/__tests__/fields.test.d.ts.map +1 -0
  15. package/dist/core/__tests__/runtime.test.d.ts +2 -0
  16. package/dist/core/__tests__/runtime.test.d.ts.map +1 -0
  17. package/dist/core/builders/collection.d.ts +9 -0
  18. package/dist/core/builders/collection.d.ts.map +1 -0
  19. package/dist/core/builders/component.d.ts +26 -0
  20. package/dist/core/builders/component.d.ts.map +1 -0
  21. package/dist/core/builders/global.d.ts +8 -0
  22. package/dist/core/builders/global.d.ts.map +1 -0
  23. package/dist/core/builders/group.d.ts +18 -0
  24. package/dist/core/builders/group.d.ts.map +1 -0
  25. package/dist/core/builders/index.d.ts +8 -0
  26. package/dist/core/builders/index.d.ts.map +1 -0
  27. package/dist/core/builders/page.d.ts +9 -0
  28. package/dist/core/builders/page.d.ts.map +1 -0
  29. package/dist/core/builders/utils.d.ts +8 -0
  30. package/dist/core/builders/utils.d.ts.map +1 -0
  31. package/dist/core/components/index.d.ts +3 -0
  32. package/dist/core/components/index.d.ts.map +1 -0
  33. package/dist/core/components/link.d.ts +12 -0
  34. package/dist/core/components/link.d.ts.map +1 -0
  35. package/dist/core/components/meta.d.ts +12 -0
  36. package/dist/core/components/meta.d.ts.map +1 -0
  37. package/dist/core/field-result.d.ts +26 -0
  38. package/dist/core/field-result.d.ts.map +1 -0
  39. package/dist/core/fields/boolean.d.ts +12 -0
  40. package/dist/core/fields/boolean.d.ts.map +1 -0
  41. package/dist/core/fields/date.d.ts +14 -0
  42. package/dist/core/fields/date.d.ts.map +1 -0
  43. package/dist/core/fields/enum.d.ts +14 -0
  44. package/dist/core/fields/enum.d.ts.map +1 -0
  45. package/dist/core/fields/index.d.ts +12 -0
  46. package/dist/core/fields/index.d.ts.map +1 -0
  47. package/dist/core/fields/media.d.ts +33 -0
  48. package/dist/core/fields/media.d.ts.map +1 -0
  49. package/dist/core/fields/number.d.ts +16 -0
  50. package/dist/core/fields/number.d.ts.map +1 -0
  51. package/dist/core/fields/reference.d.ts +12 -0
  52. package/dist/core/fields/reference.d.ts.map +1 -0
  53. package/dist/core/fields/richtext.d.ts +13 -0
  54. package/dist/core/fields/richtext.d.ts.map +1 -0
  55. package/dist/core/fields/slug.d.ts +10 -0
  56. package/dist/core/fields/slug.d.ts.map +1 -0
  57. package/dist/core/fields/string.d.ts +21 -0
  58. package/dist/core/fields/string.d.ts.map +1 -0
  59. package/dist/core/fields/types.d.ts +101 -0
  60. package/dist/core/fields/types.d.ts.map +1 -0
  61. package/dist/core/fields/user.d.ts +13 -0
  62. package/dist/core/fields/user.d.ts.map +1 -0
  63. package/dist/core/index.d.ts +6 -0
  64. package/dist/core/index.d.ts.map +1 -0
  65. package/dist/core/index.js +23 -0
  66. package/dist/core/okno.d.ts +21 -0
  67. package/dist/core/okno.d.ts.map +1 -0
  68. package/dist/core/runtime.d.ts +9 -0
  69. package/dist/core/runtime.d.ts.map +1 -0
  70. package/dist/core/schema.d.ts +2 -0
  71. package/dist/core/schema.d.ts.map +1 -0
  72. package/dist/editor/index.js +1753 -0
  73. package/dist/index.d.ts +8 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +27 -0
  76. package/dist/meta-D-_nuC5Y.js +548 -0
  77. package/dist/server/client.d.ts +29 -0
  78. package/dist/server/client.d.ts.map +1 -0
  79. package/dist/server/index.d.ts +3 -0
  80. package/dist/server/index.d.ts.map +1 -0
  81. package/dist/server/index.js +6 -0
  82. package/dist/server/types.d.ts +48 -0
  83. package/dist/server/types.d.ts.map +1 -0
  84. package/dist/types/global.d.ts +54 -0
  85. package/dist/types/global.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +4 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/path.d.ts +35 -0
  89. package/dist/types/path.d.ts.map +1 -0
  90. package/dist/types/query.d.ts +31 -0
  91. package/dist/types/query.d.ts.map +1 -0
  92. package/dist/vite.config.d.ts +3 -0
  93. package/dist/vite.config.d.ts.map +1 -0
  94. package/dist/vite.dev.config.d.ts +3 -0
  95. package/dist/vite.dev.config.d.ts.map +1 -0
  96. package/package.json +71 -0
@@ -0,0 +1,8 @@
1
+ export { schema, collection, page, global, group, component } from "./core";
2
+ export type { GroupDefinition, ComponentDefinition } from "./core";
3
+ export { string, number, boolean, date, enumField, enumField as enum, select, richtext, media, slug, reference, user, } from "./core/fields";
4
+ export { link, meta } from "./core/components";
5
+ export type { Schema, ContentItem, QueryOptions, CollectionDefinition, PageDefinition, GlobalDefinition, MediaValue, AnyField, } from "./types";
6
+ export { OknoClient, fetchContent, fetchSchema } from "./server";
7
+ export type { OknoServerConfig } from "./server";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGnE,OAAO,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,IAAI,IAAI,EACjB,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,EACT,IAAI,GACJ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAG/C,YAAY,EACX,MAAM,EACN,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,QAAQ,GACR,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { e, c, b, f, h, h as h2, g, a, l, m, k, n, p, j, r, s, h as h3, i, d, u } from "./meta-D-_nuC5Y.js";
2
+ import { O, f as f2, a as a2 } from "./client-CeppRtrT.js";
3
+ export {
4
+ O as OknoClient,
5
+ e as boolean,
6
+ c as collection,
7
+ b as component,
8
+ f as date,
9
+ h as enum,
10
+ h2 as enumField,
11
+ f2 as fetchContent,
12
+ a2 as fetchSchema,
13
+ g as global,
14
+ a as group,
15
+ l as link,
16
+ m as media,
17
+ k as meta,
18
+ n as number,
19
+ p as page,
20
+ j as reference,
21
+ r as richtext,
22
+ s as schema,
23
+ h3 as select,
24
+ i as slug,
25
+ d as string,
26
+ u as user
27
+ };
@@ -0,0 +1,548 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { s as t } from "./client-CeppRtrT.js";
5
+ class e {
6
+ constructor(t2) {
7
+ __publicField(this, "schema");
8
+ __publicField(this, "content", {});
9
+ this.schema = t2;
10
+ }
11
+ setContent(t2) {
12
+ this.content = t2;
13
+ }
14
+ query(t2, e2) {
15
+ if (!t2 || "string" != typeof t2) throw new Error(`Invalid path: ${t2}. Path must be a non-empty string.`);
16
+ const r2 = t2.split("."), i2 = r2[0], n2 = r2.slice(1);
17
+ if (!i2) throw new Error(`Invalid path: ${t2}`);
18
+ const s2 = this.schema[i2];
19
+ if (!s2) throw new Error(`Unknown content: ${i2}`);
20
+ if ("collection" === s2.type) {
21
+ const t3 = this.content[i2] || [];
22
+ if (0 === n2.length) return !(e2 == null ? void 0 : e2.limit) && t3.length > 50 && console.warn(`[Okno] Collection "${i2}" returned ${t3.length} items without a limit. Consider using { limit: N } for better performance.`), this.filterItems(t3, e2);
23
+ const [r3, ...s3] = n2, o2 = t3.find((t4) => t4.id === r3 || t4.slug === r3);
24
+ if (!o2) throw new Error(`Item not found: ${r3}`);
25
+ return s3.length ? this.getFieldValue(o2, s3, e2) : o2;
26
+ }
27
+ if ("page" === s2.type || "global" === s2.type) {
28
+ const t3 = this.content[i2] || {};
29
+ return n2.length ? this.getFieldValue(t3, n2, e2) : this.withFallbacks(t3, s2.fields);
30
+ }
31
+ throw new Error(`Unknown schema type for: ${i2}`);
32
+ }
33
+ queryBySlug(t2, e2) {
34
+ const r2 = (this.content[t2] || []).find((t3) => t3.slug === e2);
35
+ if (!r2) throw new Error(`Item not found with slug: ${e2}`);
36
+ return r2;
37
+ }
38
+ queryById(t2, e2) {
39
+ const r2 = (this.content[t2] || []).find((t3) => t3.id === e2);
40
+ if (!r2) throw new Error(`Item not found with id: ${e2}`);
41
+ return r2;
42
+ }
43
+ hasContent(t2) {
44
+ const e2 = t2.split("."), r2 = e2[0], i2 = e2.slice(1);
45
+ if (!r2) return false;
46
+ const n2 = this.schema[r2];
47
+ if (!n2) return false;
48
+ if ("collection" === n2.type) {
49
+ const t3 = this.content[r2] || [];
50
+ if (0 === i2.length) return t3.length > 0;
51
+ const [e3, ...n3] = i2, s2 = t3.find((t4) => t4.id === e3 || t4.slug === e3);
52
+ return !!s2 && (0 === n3.length || this.hasNestedValue(s2, n3));
53
+ }
54
+ if ("page" === n2.type || "global" === n2.type) {
55
+ const t3 = this.content[r2];
56
+ return !!t3 && (0 === i2.length || this.hasNestedValue(t3, i2));
57
+ }
58
+ return false;
59
+ }
60
+ filterItems(t2, e2 = {}) {
61
+ let r2 = [...t2];
62
+ if ("only" === e2.drafts ? r2 = r2.filter((t3) => !t3.published) : e2.drafts || (r2 = r2.filter((t3) => t3.published)), e2.where && (r2 = r2.filter((t3) => Object.entries(e2.where).every(([e3, r3]) => t3[e3] === r3))), e2.sort) {
63
+ const t3 = e2.sort.startsWith("-"), i2 = t3 ? e2.sort.slice(1) : e2.sort;
64
+ r2.sort((e3, r3) => {
65
+ const n2 = e3[i2], s2 = r3[i2], o2 = n2 < s2 ? -1 : n2 > s2 ? 1 : 0;
66
+ return t3 ? -o2 : o2;
67
+ });
68
+ }
69
+ return e2.offset && (r2 = r2.slice(e2.offset)), e2.limit && (r2 = r2.slice(0, e2.limit)), e2.select && (r2 = r2.map((t3) => {
70
+ const r3 = { id: t3.id };
71
+ t3.slug && (r3.slug = t3.slug);
72
+ for (const i2 of e2.select) i2 in t3 && (r3[i2] = t3[i2]);
73
+ return r3;
74
+ })), r2;
75
+ }
76
+ withFallbacks(t2, e2) {
77
+ const r2 = {};
78
+ for (const i2 in e2) r2[i2] = t2[i2] ?? this.generateFallback(i2);
79
+ return r2;
80
+ }
81
+ generateFallback(t2) {
82
+ return t2.split(/(?=[A-Z])|_|-/).filter(Boolean).map((t3) => t3.charAt(0).toUpperCase() + t3.slice(1)).join(" ");
83
+ }
84
+ getFieldValue(t2, e2, r2) {
85
+ let i2 = t2;
86
+ for (let t3 = 0; t3 < e2.length; t3++) {
87
+ const r3 = e2[t3];
88
+ if (i2 = i2 == null ? void 0 : i2[r3], void 0 === i2) {
89
+ if (t3 === e2.length - 1) return this.generateFallback(r3);
90
+ throw new Error(`Field not found: ${e2.join(".")}`);
91
+ }
92
+ }
93
+ return (r2 == null ? void 0 : r2.slots) && "string" == typeof i2 && (i2 = this.processSlots(i2, r2.slots)), i2;
94
+ }
95
+ processSlots(t2, e2) {
96
+ return t2.replace(/\{\{(\w+)\}\}/g, (t3, r2) => void 0 !== e2[r2] ? String(e2[r2]) : `{{${r2}}}`);
97
+ }
98
+ hasNestedValue(t2, e2) {
99
+ let r2 = t2;
100
+ for (const t3 of e2) {
101
+ if (void 0 === (r2 == null ? void 0 : r2[t3])) return false;
102
+ r2 = r2[t3];
103
+ }
104
+ return true;
105
+ }
106
+ }
107
+ class r {
108
+ constructor(t2, e2, r2 = true, i2) {
109
+ this.value = t2, this.path = e2, this.isEmpty = r2, this.options = i2;
110
+ }
111
+ raw() {
112
+ return this.value;
113
+ }
114
+ default(t2) {
115
+ return new r(this.isEmpty ? t2 : this.value, this.path, false, this.options);
116
+ }
117
+ toString() {
118
+ var _a, _b;
119
+ if ((_a = this.options) == null ? void 0 : _a.plain) return String(this.value);
120
+ if ((_b = this.options) == null ? void 0 : _b.raw) return this.value;
121
+ if ("string" == typeof this.value || "number" == typeof this.value || "boolean" == typeof this.value) {
122
+ const t2 = this.isEmpty ? ' data-okno-empty=""' : "";
123
+ return `<span data-okno="${this.path}"${t2}>${this.value}</span>`;
124
+ }
125
+ return String(this.value);
126
+ }
127
+ toJSON() {
128
+ return this.value;
129
+ }
130
+ }
131
+ function i(i2) {
132
+ const n2 = (function(t2) {
133
+ const e2 = {};
134
+ for (const [r2, i3] of Object.entries(t2)) {
135
+ if (!i3 || "object" != typeof i3) throw new Error(`Invalid schema entry "${r2}": expected page(), collection(), or global()`);
136
+ if ("def" in i3) e2[r2] = i3.def;
137
+ else {
138
+ if (!("type" in i3)) throw new Error(`Invalid schema entry "${r2}": expected page(), collection(), or global()`);
139
+ e2[r2] = i3;
140
+ }
141
+ }
142
+ return e2;
143
+ })(i2), s2 = new e(n2), o2 = globalThis.__OKNO_CONTENT__;
144
+ o2 && s2.setContent(o2), globalThis.__OKNO_SCHEMA__ = n2;
145
+ const h2 = globalThis.__OKNO_CONFIG__;
146
+ h2 && "undefined" == typeof window && t(h2, n2).catch((t2) => {
147
+ console.error("[Okno] Schema sync failed:", t2);
148
+ });
149
+ const l2 = (t2, e2) => {
150
+ const i3 = globalThis.__OKNO_CONTENT__;
151
+ let o3;
152
+ if (i3 && s2.setContent(i3), o3 = e2 && "slug" in e2 ? s2.queryBySlug(t2, e2.slug) : e2 && "id" in e2 ? s2.queryById(t2, e2.id) : s2.query(t2, e2), (function(t3, e3, r2) {
153
+ const i4 = e3.split("."), n3 = i4[0], s3 = i4.slice(1);
154
+ if (!n3) return false;
155
+ const o4 = t3[n3];
156
+ return !(!o4 || "collection" === o4.type && r2 && ("where" in r2 || "limit" in r2 || "offset" in r2 || "sort" in r2) || "collection" === o4.type && 0 === s3.length || !("collection" === o4.type && s3.length >= 2 || ("page" === o4.type || "global" === o4.type) && s3.length > 0));
157
+ })(n2, t2, e2)) {
158
+ return (function(t3, e3, i4, n3) {
159
+ return (n3 == null ? void 0 : n3.plain) || (n3 == null ? void 0 : n3.raw) ? n3.plain ? String(t3) : t3 : "string" == typeof t3 || "number" == typeof t3 || "boolean" == typeof t3 ? new r(t3, e3, i4, n3) : t3;
160
+ })(o3, t2, !s2.hasContent(t2), e2);
161
+ }
162
+ return o3;
163
+ };
164
+ return l2.schema = n2, l2._instance = s2, l2;
165
+ }
166
+ function n(t2) {
167
+ const e2 = {};
168
+ for (const [r2, i2] of Object.entries(t2)) {
169
+ if (!i2 || "object" != typeof i2) throw new Error(`Invalid field "${r2}": expected a field builder or definition`);
170
+ if ("def" in i2) {
171
+ const t3 = i2.def;
172
+ "group" === t3.type ? e2[r2] = { ...t3, fields: n(t3.fields) } : e2[r2] = t3;
173
+ } else {
174
+ if (!("type" in i2)) throw new Error(`Invalid field "${r2}": expected a field builder or use group() for nested fields`);
175
+ {
176
+ const t3 = i2;
177
+ "group" === t3.type ? e2[r2] = { ...t3, fields: n(t3.fields) } : e2[r2] = t3;
178
+ }
179
+ }
180
+ }
181
+ return e2;
182
+ }
183
+ class s {
184
+ constructor(t2) {
185
+ __publicField(this, "def");
186
+ this.def = { type: "collection", fields: n(t2), draftable: false };
187
+ }
188
+ draftable() {
189
+ return this.def.draftable = true, this;
190
+ }
191
+ }
192
+ function o(t2) {
193
+ return new s(t2);
194
+ }
195
+ class h {
196
+ constructor(t2) {
197
+ __publicField(this, "def");
198
+ this.def = { type: "page", fields: n(t2) };
199
+ }
200
+ route(t2) {
201
+ return this.def.route = t2, this;
202
+ }
203
+ }
204
+ function l(t2) {
205
+ return new h(t2);
206
+ }
207
+ class u {
208
+ constructor(t2) {
209
+ __publicField(this, "def");
210
+ this.def = { type: "global", fields: n(t2) };
211
+ }
212
+ }
213
+ function d(t2) {
214
+ return new u(t2);
215
+ }
216
+ class f {
217
+ constructor(t2) {
218
+ __publicField(this, "def");
219
+ this.def = { type: "group", fields: t2 };
220
+ }
221
+ when(t2, e2) {
222
+ return this.def.when = { field: t2, value: e2 }, this;
223
+ }
224
+ }
225
+ function a(t2) {
226
+ return new f(t2);
227
+ }
228
+ class c {
229
+ constructor(t2, e2, r2 = []) {
230
+ __publicField(this, "def");
231
+ this.def = { type: "component", name: t2, fields: n(e2), preview: r2 };
232
+ }
233
+ when(t2, e2) {
234
+ return this.def.when = { field: t2, value: e2 }, this;
235
+ }
236
+ }
237
+ function p(t2, e2, r2 = []) {
238
+ return new c(t2, e2, r2);
239
+ }
240
+ class w {
241
+ constructor() {
242
+ __publicField(this, "def");
243
+ this.def = { type: "string", required: true };
244
+ }
245
+ optional() {
246
+ return this.def.required = false, this;
247
+ }
248
+ min(t2) {
249
+ return this.def.min = t2, this;
250
+ }
251
+ max(t2) {
252
+ return this.def.max = t2, this;
253
+ }
254
+ email() {
255
+ return this.def.validation = "email", this;
256
+ }
257
+ url() {
258
+ return this.def.validation = "url", this;
259
+ }
260
+ phone() {
261
+ return this.def.validation = "phone", this;
262
+ }
263
+ pattern(t2) {
264
+ return this.def.pattern = t2.source, this;
265
+ }
266
+ array() {
267
+ return this.def.array = true, this;
268
+ }
269
+ default(t2) {
270
+ return this.def.default = t2, this;
271
+ }
272
+ help(t2) {
273
+ return this.def.help = t2, this;
274
+ }
275
+ protected() {
276
+ return this.def.protected = true, this;
277
+ }
278
+ localized() {
279
+ return this.def.localized = true, this;
280
+ }
281
+ when(t2, e2) {
282
+ return this.def.when = { field: t2, value: e2 }, this;
283
+ }
284
+ }
285
+ function g() {
286
+ return new w();
287
+ }
288
+ class m {
289
+ constructor() {
290
+ __publicField(this, "def");
291
+ this.def = { type: "number", required: true };
292
+ }
293
+ optional() {
294
+ return this.def.required = false, this;
295
+ }
296
+ min(t2) {
297
+ return this.def.min = t2, this;
298
+ }
299
+ max(t2) {
300
+ return this.def.max = t2, this;
301
+ }
302
+ default(t2) {
303
+ return this.def.default = t2, this;
304
+ }
305
+ help(t2) {
306
+ return this.def.help = t2, this;
307
+ }
308
+ protected() {
309
+ return this.def.protected = true, this;
310
+ }
311
+ localized() {
312
+ return this.def.localized = true, this;
313
+ }
314
+ when(t2, e2) {
315
+ return this.def.when = { field: t2, value: e2 }, this;
316
+ }
317
+ }
318
+ function y() {
319
+ return new m();
320
+ }
321
+ class v {
322
+ constructor() {
323
+ __publicField(this, "def");
324
+ this.def = { type: "boolean" };
325
+ }
326
+ default(t2) {
327
+ return this.def.default = t2, this;
328
+ }
329
+ help(t2) {
330
+ return this.def.help = t2, this;
331
+ }
332
+ protected() {
333
+ return this.def.protected = true, this;
334
+ }
335
+ when(t2, e2) {
336
+ return this.def.when = { field: t2, value: e2 }, this;
337
+ }
338
+ }
339
+ function b() {
340
+ return new v();
341
+ }
342
+ class _ {
343
+ constructor() {
344
+ __publicField(this, "def");
345
+ this.def = { type: "date" };
346
+ }
347
+ optional() {
348
+ return this.def.required = false, this;
349
+ }
350
+ default(t2) {
351
+ return this.def.default = t2, this;
352
+ }
353
+ help(t2) {
354
+ return this.def.help = t2, this;
355
+ }
356
+ protected() {
357
+ return this.def.protected = true, this;
358
+ }
359
+ localized() {
360
+ return this.def.localized = true, this;
361
+ }
362
+ when(t2, e2) {
363
+ return this.def.when = { field: t2, value: e2 }, this;
364
+ }
365
+ }
366
+ function E() {
367
+ return new _();
368
+ }
369
+ class $ {
370
+ constructor(t2) {
371
+ __publicField(this, "def");
372
+ this.def = { type: "enum", values: t2 };
373
+ }
374
+ multiple() {
375
+ return this.def.multiple = true, this;
376
+ }
377
+ default(t2) {
378
+ return this.def.default = t2, this;
379
+ }
380
+ help(t2) {
381
+ return this.def.help = t2, this;
382
+ }
383
+ protected() {
384
+ return this.def.protected = true, this;
385
+ }
386
+ localized() {
387
+ return this.def.localized = true, this;
388
+ }
389
+ when(t2, e2) {
390
+ return this.def.when = { field: t2, value: e2 }, this;
391
+ }
392
+ }
393
+ function x(t2) {
394
+ return new $(t2);
395
+ }
396
+ class O {
397
+ constructor() {
398
+ __publicField(this, "def");
399
+ this.def = { type: "richtext" };
400
+ }
401
+ slots(t2) {
402
+ return this.def.slots = t2, this;
403
+ }
404
+ help(t2) {
405
+ return this.def.help = t2, this;
406
+ }
407
+ protected() {
408
+ return this.def.protected = true, this;
409
+ }
410
+ localized() {
411
+ return this.def.localized = true, this;
412
+ }
413
+ when(t2, e2) {
414
+ return this.def.when = { field: t2, value: e2 }, this;
415
+ }
416
+ }
417
+ function q() {
418
+ return new O();
419
+ }
420
+ class I {
421
+ constructor() {
422
+ __publicField(this, "def");
423
+ this.def = { type: "media" };
424
+ }
425
+ image(t2) {
426
+ return this.def.accept || (this.def.accept = []), this.def.accept.push("image"), t2 && (this.def.image = t2), this;
427
+ }
428
+ video(t2) {
429
+ return this.def.accept || (this.def.accept = []), this.def.accept.push("video"), t2 && (this.def.video = t2), this;
430
+ }
431
+ audio(t2) {
432
+ return this.def.accept || (this.def.accept = []), this.def.accept.push("audio"), t2 && (this.def.audio = t2), this;
433
+ }
434
+ document(t2) {
435
+ return this.def.accept || (this.def.accept = []), this.def.accept.push("document"), t2 && (this.def.document = t2), this;
436
+ }
437
+ optional() {
438
+ return this.def.required = false, this;
439
+ }
440
+ help(t2) {
441
+ return this.def.help = t2, this;
442
+ }
443
+ protected() {
444
+ return this.def.protected = true, this;
445
+ }
446
+ when(t2, e2) {
447
+ return this.def.when = { field: t2, value: e2 }, this;
448
+ }
449
+ }
450
+ function N() {
451
+ return new I();
452
+ }
453
+ class k {
454
+ constructor(t2) {
455
+ __publicField(this, "def");
456
+ this.def = { type: "slug", from: t2 };
457
+ }
458
+ help(t2) {
459
+ return this.def.help = t2, this;
460
+ }
461
+ protected() {
462
+ return this.def.protected = true, this;
463
+ }
464
+ }
465
+ function S(t2) {
466
+ return new k(t2);
467
+ }
468
+ class C {
469
+ constructor(t2) {
470
+ __publicField(this, "def");
471
+ this.def = { type: "reference", collection: t2 };
472
+ }
473
+ array() {
474
+ return this.def.array = true, this;
475
+ }
476
+ optional() {
477
+ return this.def.required = false, this;
478
+ }
479
+ help(t2) {
480
+ return this.def.help = t2, this;
481
+ }
482
+ when(t2, e2) {
483
+ return this.def.when = { field: t2, value: e2 }, this;
484
+ }
485
+ }
486
+ function z(t2) {
487
+ return new C(t2);
488
+ }
489
+ class F {
490
+ constructor() {
491
+ __publicField(this, "def");
492
+ this.def = { type: "user" };
493
+ }
494
+ multiple() {
495
+ return this.def.multiple = true, this;
496
+ }
497
+ default(t2) {
498
+ return this.def.default = t2, this;
499
+ }
500
+ optional() {
501
+ return this.def.required = false, this;
502
+ }
503
+ help(t2) {
504
+ return this.def.help = t2, this;
505
+ }
506
+ when(t2, e2) {
507
+ return this.def.when = { field: t2, value: e2 }, this;
508
+ }
509
+ }
510
+ function j() {
511
+ return new F();
512
+ }
513
+ class T extends c {
514
+ constructor() {
515
+ super("link", { text: g(), url: g().url(), external: b().default(false) }, ["text", "url"]);
516
+ }
517
+ }
518
+ function V() {
519
+ return new T();
520
+ }
521
+ class B extends c {
522
+ constructor() {
523
+ super("meta", { title: g().max(60).help("Appears in browser tab and search results"), description: g().max(160).help("Search result description"), image: N().image().optional() }, ["title"]);
524
+ }
525
+ }
526
+ function A() {
527
+ return new B();
528
+ }
529
+ export {
530
+ a,
531
+ p as b,
532
+ o as c,
533
+ g as d,
534
+ b as e,
535
+ E as f,
536
+ d as g,
537
+ x as h,
538
+ S as i,
539
+ z as j,
540
+ A as k,
541
+ V as l,
542
+ N as m,
543
+ y as n,
544
+ l as p,
545
+ q as r,
546
+ i as s,
547
+ j as u
548
+ };
@@ -0,0 +1,29 @@
1
+ import type { OknoServerConfig } from "./types";
2
+ export declare class OknoClient {
3
+ private apiUrl;
4
+ private token;
5
+ constructor(config: OknoServerConfig);
6
+ /**
7
+ * Fetch both schema and content in a single request
8
+ */
9
+ fetchAll(): Promise<{
10
+ schema: Record<string, any>;
11
+ content: Record<string, any>;
12
+ }>;
13
+ /**
14
+ * Fetch only content (for runtime queries)
15
+ */
16
+ fetchContent(): Promise<Record<string, any>>;
17
+ /**
18
+ * Fetch only schema (for editor)
19
+ */
20
+ fetchSchema(): Promise<Record<string, any>>;
21
+ /**
22
+ * Sync schema to PocketBase
23
+ */
24
+ syncSchema(schema: Record<string, any>): Promise<void>;
25
+ }
26
+ export declare function fetchContent(config: OknoServerConfig): Promise<Record<string, any>>;
27
+ export declare function fetchSchema(config: OknoServerConfig): Promise<Record<string, any>>;
28
+ export declare function syncSchema(config: OknoServerConfig, schema: Record<string, any>): Promise<void>;
29
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../server/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKhD,qBAAa,UAAU;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE,gBAAgB;IAMpC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC;IAmExF;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAKlD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAKjD;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB5D;AAGD,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAGzF;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAGxF;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrG"}
@@ -0,0 +1,3 @@
1
+ export { OknoClient, fetchContent, fetchSchema } from "./client";
2
+ export type { OknoServerConfig, ProjectRecord, CollectionRecord, ContentRecord, MediaRecord } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { O, f, a } from "../client-CeppRtrT.js";
2
+ export {
3
+ O as OknoClient,
4
+ f as fetchContent,
5
+ a as fetchSchema
6
+ };
@@ -0,0 +1,48 @@
1
+ import type { RecordModel } from "pocketbase";
2
+ export interface BaseRecord extends RecordModel {
3
+ id: string;
4
+ created: string;
5
+ updated: string;
6
+ created_by?: string;
7
+ updated_by?: string;
8
+ }
9
+ export interface ProjectRecord extends BaseRecord {
10
+ name: string;
11
+ token: string;
12
+ schema: Record<string, any>;
13
+ owner: string;
14
+ editors: string[];
15
+ }
16
+ export interface CollectionRecord extends BaseRecord {
17
+ project: string;
18
+ name: string;
19
+ type: "collection" | "page" | "global";
20
+ orphaned?: string;
21
+ }
22
+ export interface ContentRecord extends BaseRecord {
23
+ collection: string;
24
+ slug?: string;
25
+ locale?: string;
26
+ data: Record<string, any>;
27
+ draft?: Record<string, any>;
28
+ version?: number;
29
+ published?: string;
30
+ published_by?: string;
31
+ expand?: {
32
+ collection?: CollectionRecord;
33
+ };
34
+ }
35
+ export interface MediaRecord extends BaseRecord {
36
+ project: string;
37
+ parent?: string;
38
+ file?: string;
39
+ name?: string;
40
+ alt?: string;
41
+ metadata?: Record<string, any>;
42
+ }
43
+ export interface OknoServerConfig {
44
+ token: string;
45
+ /** Internal: override API URL for local development testing only */
46
+ _devApiUrl?: string;
47
+ }
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,gBAAgB,CAAC;KAC9B,CAAC;CACF;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAMD,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB"}