@velastack/patterns 0.0.24 → 0.0.26
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/chunks/{collections-Bzyt18yv.js → collections-DdGJC7Ip.js} +5 -3
- package/dist/chunks/collections-DdGJC7Ip.js.map +1 -0
- package/dist/chunks/{generate.runtime-uPCB71Ki.js → generate.runtime-B0EfMNMf.js} +212 -134
- package/dist/chunks/generate.runtime-B0EfMNMf.js.map +1 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js +289 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js.map +1 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js +81 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js.map +1 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js +430 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js.map +1 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js +207 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js.map +1 -0
- package/dist/chunks/modify-file-Dxow9QKT.js +22 -0
- package/dist/chunks/modify-file-Dxow9QKT.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js → ts-morph-helpers-DmD7iwna.js} +1 -1
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js.map → ts-morph-helpers-DmD7iwna.js.map} +1 -1
- package/dist/chunks/{write-result-CSxmq40z.js → write-result-DhQIE6kA.js} +4 -4
- package/dist/chunks/{write-result-CSxmq40z.js.map → write-result-DhQIE6kA.js.map} +1 -1
- package/dist/index.d.ts +50 -0
- package/dist/index.js +306 -227
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/collections-Bzyt18yv.js.map +0 -1
- package/dist/chunks/generate.runtime-BEuc5hDN.js +0 -225
- package/dist/chunks/generate.runtime-BEuc5hDN.js.map +0 -1
- package/dist/chunks/generate.runtime-CHmm4bBZ.js +0 -154
- package/dist/chunks/generate.runtime-CHmm4bBZ.js.map +0 -1
- package/dist/chunks/generate.runtime-DXkJgkP4.js +0 -232
- package/dist/chunks/generate.runtime-DXkJgkP4.js.map +0 -1
- package/dist/chunks/generate.runtime-egq8I3EA.js +0 -61
- package/dist/chunks/generate.runtime-egq8I3EA.js.map +0 -1
- package/dist/chunks/generate.runtime-uPCB71Ki.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var l = Object.create, u = Object.defineProperty, d = Object.getOwnPropertyDescr
|
|
|
19
19
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
20
20
|
}), ee = {
|
|
21
21
|
name: "@velastack/patterns",
|
|
22
|
-
version: "0.0.
|
|
22
|
+
version: "0.0.26",
|
|
23
23
|
type: "module",
|
|
24
24
|
private: !1,
|
|
25
25
|
main: "./dist/index.js",
|
|
@@ -80,6 +80,10 @@ var l = Object.create, u = Object.defineProperty, d = Object.getOwnPropertyDescr
|
|
|
80
80
|
"vite-plugin-dts": "^4.5.4",
|
|
81
81
|
vitest: "^4.1.4"
|
|
82
82
|
}
|
|
83
|
+
}, y = class extends Error {
|
|
84
|
+
constructor(e) {
|
|
85
|
+
super(e), this.name = "InvalidArgumentError";
|
|
86
|
+
}
|
|
83
87
|
};
|
|
84
88
|
//#endregion
|
|
85
89
|
//#region src/core/format-result.ts
|
|
@@ -87,7 +91,7 @@ function te(e) {
|
|
|
87
91
|
return e.language === "ts" || e.language === "svelte" || e.path.endsWith(".json");
|
|
88
92
|
}
|
|
89
93
|
async function ne(e) {
|
|
90
|
-
if (!te(e)) return e;
|
|
94
|
+
if (e.status !== "success" || !te(e)) return e;
|
|
91
95
|
try {
|
|
92
96
|
let t = await s.format(e.content, {
|
|
93
97
|
filepath: e.path,
|
|
@@ -104,7 +108,7 @@ async function ne(e) {
|
|
|
104
108
|
async function re(e) {
|
|
105
109
|
return Promise.all(e.map((e) => ne(e)));
|
|
106
110
|
}
|
|
107
|
-
async function
|
|
111
|
+
async function b(e) {
|
|
108
112
|
let [t, n] = await Promise.all([re(e.creates), re(e.modifies)]);
|
|
109
113
|
return {
|
|
110
114
|
...e,
|
|
@@ -145,13 +149,13 @@ var ie = {
|
|
|
145
149
|
geopoint: ["import { GeopointInput } from \"$lib/components/ui/geopoint\";"],
|
|
146
150
|
button: ["import { Button } from \"$lib/components/ui/button\";"]
|
|
147
151
|
};
|
|
148
|
-
function
|
|
152
|
+
function x(e) {
|
|
149
153
|
return `$formData.${e.name}`;
|
|
150
154
|
}
|
|
151
|
-
function
|
|
155
|
+
function S(e) {
|
|
152
156
|
return e.inputProps ? Object.entries(e.inputProps).flatMap(([e, t]) => t == null || t === !1 ? [] : t === !0 ? [` ${e}`] : [` ${e}=${JSON.stringify(String(t))}`]).join("") : "";
|
|
153
157
|
}
|
|
154
|
-
function
|
|
158
|
+
function C(t) {
|
|
155
159
|
return t.labelAside ? e`
|
|
156
160
|
<div class="flex justify-between">
|
|
157
161
|
<Form.Label>${t.title}</Form.Label>
|
|
@@ -159,14 +163,14 @@ function S(t) {
|
|
|
159
163
|
</div>
|
|
160
164
|
` : `<Form.Label>${t.title}</Form.Label>`;
|
|
161
165
|
}
|
|
162
|
-
function
|
|
166
|
+
function w(t, n) {
|
|
163
167
|
let r = t.required ? " required" : "";
|
|
164
168
|
return e`
|
|
165
169
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
166
170
|
<Form.Control>
|
|
167
171
|
{#snippet children({ props })}
|
|
168
|
-
${
|
|
169
|
-
<Input {...props} type="${n}" bind:value={${
|
|
172
|
+
${C(t)}
|
|
173
|
+
<Input {...props} type="${n}" bind:value={${x(t)}}${r}${S(t)} />
|
|
170
174
|
{/snippet}
|
|
171
175
|
</Form.Control>
|
|
172
176
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -179,8 +183,8 @@ function oe(t) {
|
|
|
179
183
|
<Form.Field {form} name="${t.name}" class="col-span-2">
|
|
180
184
|
<Form.Control>
|
|
181
185
|
{#snippet children({ props })}
|
|
182
|
-
${
|
|
183
|
-
<Textarea {...props} bind:value={${
|
|
186
|
+
${C(t)}
|
|
187
|
+
<Textarea {...props} bind:value={${x(t)}}${n}${S(t)} />
|
|
184
188
|
{/snippet}
|
|
185
189
|
</Form.Control>
|
|
186
190
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -193,8 +197,8 @@ function se(t) {
|
|
|
193
197
|
<Form.Field {form} name="${t.name}" class="col-span-1 flex items-start space-x-2">
|
|
194
198
|
<Form.Control>
|
|
195
199
|
{#snippet children({ props })}
|
|
196
|
-
<Checkbox {...props} bind:checked={${
|
|
197
|
-
${
|
|
200
|
+
<Checkbox {...props} bind:checked={${x(t)}}${n}${S(t)} />
|
|
201
|
+
${C(t)}
|
|
198
202
|
{/snippet}
|
|
199
203
|
</Form.Control>
|
|
200
204
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -206,8 +210,8 @@ function ce(t) {
|
|
|
206
210
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
207
211
|
<Form.Control>
|
|
208
212
|
{#snippet children({ props })}
|
|
209
|
-
${
|
|
210
|
-
<GeopointInput {...props} bind:value={${
|
|
213
|
+
${C(t)}
|
|
214
|
+
<GeopointInput {...props} bind:value={${x(t)}} />
|
|
211
215
|
{/snippet}
|
|
212
216
|
</Form.Control>
|
|
213
217
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -220,7 +224,7 @@ function le(t) {
|
|
|
220
224
|
<FileForm.Field {form} name="${t.name}" class="col-span-1">
|
|
221
225
|
<Form.Control>
|
|
222
226
|
{#snippet children({ props })}
|
|
223
|
-
${
|
|
227
|
+
${C(t)}
|
|
224
228
|
<FileForm.${r}>
|
|
225
229
|
{#snippet display({ file, filename, onremove })}
|
|
226
230
|
<div class="flex gap-2 justify-between items-center">
|
|
@@ -232,7 +236,7 @@ function le(t) {
|
|
|
232
236
|
</div>
|
|
233
237
|
{/snippet}
|
|
234
238
|
{#snippet input()}
|
|
235
|
-
<FileForm.Input {...props}${n}${
|
|
239
|
+
<FileForm.Input {...props}${n}${S(t)} />
|
|
236
240
|
{/snippet}
|
|
237
241
|
</FileForm.${r}>
|
|
238
242
|
{/snippet}
|
|
@@ -247,9 +251,9 @@ function ue(t) {
|
|
|
247
251
|
<MultiSelect.Field {form} type="${n}" name="${t.name}"${r} class="col-span-1">
|
|
248
252
|
<Form.Control>
|
|
249
253
|
{#snippet children({ props })}
|
|
250
|
-
${
|
|
254
|
+
${C(t)}
|
|
251
255
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
252
|
-
<MultiSelect.Input bind:value={${
|
|
256
|
+
<MultiSelect.Input bind:value={${x(t)}} placeholder="${i}" {...props}>
|
|
253
257
|
{#snippet children({ selected })}
|
|
254
258
|
<div class="flex flex-wrap gap-1">
|
|
255
259
|
{#each selected as value}
|
|
@@ -284,7 +288,7 @@ function de(t) {
|
|
|
284
288
|
{#snippet children({ props })}
|
|
285
289
|
<Form.Label>${t.title}</Form.Label>
|
|
286
290
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
287
|
-
<MultiSelect.Input bind:value={${
|
|
291
|
+
<MultiSelect.Input bind:value={${x(t)}} placeholder="${r}" {...props}>
|
|
288
292
|
{#snippet children({ selected })}
|
|
289
293
|
<div class="flex flex-wrap gap-1">
|
|
290
294
|
{#each selected as value}
|
|
@@ -319,22 +323,22 @@ function fe(t) {
|
|
|
319
323
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
320
324
|
<Form.Control>
|
|
321
325
|
{#snippet children({ props })}
|
|
322
|
-
${
|
|
323
|
-
<Input {...props} type="text" value={${
|
|
326
|
+
${C(t)}
|
|
327
|
+
<Input {...props} type="text" value={${x(t)}}${S(t)} readonly />
|
|
324
328
|
{/snippet}
|
|
325
329
|
</Form.Control>
|
|
326
330
|
<Form.FieldErrors class="contents text-destructive" />
|
|
327
331
|
</Form.Field>
|
|
328
332
|
`;
|
|
329
333
|
}
|
|
330
|
-
function
|
|
334
|
+
function T(e) {
|
|
331
335
|
switch (e.type) {
|
|
332
|
-
case "text": return
|
|
333
|
-
case "number": return
|
|
334
|
-
case "date": return
|
|
335
|
-
case "email": return
|
|
336
|
-
case "password": return
|
|
337
|
-
case "url": return
|
|
336
|
+
case "text": return w(e, "text");
|
|
337
|
+
case "number": return w(e, "number");
|
|
338
|
+
case "date": return w(e, "date");
|
|
339
|
+
case "email": return w(e, "email");
|
|
340
|
+
case "password": return w(e, "password");
|
|
341
|
+
case "url": return w(e, "url");
|
|
338
342
|
case "autodate": return fe(e);
|
|
339
343
|
case "editor":
|
|
340
344
|
case "json": return oe(e);
|
|
@@ -359,17 +363,17 @@ function pe(t) {
|
|
|
359
363
|
} as const;
|
|
360
364
|
`;
|
|
361
365
|
}
|
|
362
|
-
function
|
|
366
|
+
function E(e) {
|
|
363
367
|
let t = e.flatMap((e) => ie[e.type]);
|
|
364
368
|
return [...new Set(t)];
|
|
365
369
|
}
|
|
366
|
-
function
|
|
370
|
+
function D(e) {
|
|
367
371
|
return [...new Set(e.flatMap((e) => ae[e]))];
|
|
368
372
|
}
|
|
369
|
-
function
|
|
373
|
+
function O(e, t) {
|
|
370
374
|
return `data.${e.name}.${t.name}`;
|
|
371
375
|
}
|
|
372
|
-
function
|
|
376
|
+
function k(t, n, r) {
|
|
373
377
|
return e`
|
|
374
378
|
<div class="space-y-2">
|
|
375
379
|
<h3 class="font-medium leading-none">${n.title}</h3>
|
|
@@ -378,7 +382,7 @@ function O(t, n, r) {
|
|
|
378
382
|
`;
|
|
379
383
|
}
|
|
380
384
|
function me(t, n) {
|
|
381
|
-
let r =
|
|
385
|
+
let r = O(t, n), i = `<p class="text-muted-foreground">{new Date(${r}).toLocaleDateString()}</p>`, a = n.required ? i : e`
|
|
382
386
|
{#if ${r}}
|
|
383
387
|
${i}
|
|
384
388
|
{/if}
|
|
@@ -391,7 +395,7 @@ function me(t, n) {
|
|
|
391
395
|
`;
|
|
392
396
|
}
|
|
393
397
|
function he(t, n) {
|
|
394
|
-
let r =
|
|
398
|
+
let r = O(t, n), i = e`
|
|
395
399
|
<a href={${r}} target="_blank" rel="noopener noreferrer">
|
|
396
400
|
{${r}}
|
|
397
401
|
</a>
|
|
@@ -410,7 +414,7 @@ function he(t, n) {
|
|
|
410
414
|
`;
|
|
411
415
|
}
|
|
412
416
|
function ge(t, n) {
|
|
413
|
-
let r =
|
|
417
|
+
let r = O(t, n);
|
|
414
418
|
if (n.maxSelect > 1) return e`
|
|
415
419
|
<div class="space-y-2">
|
|
416
420
|
<h3 class="font-medium leading-none">${n.title}</h3>
|
|
@@ -432,7 +436,7 @@ function ge(t, n) {
|
|
|
432
436
|
`;
|
|
433
437
|
}
|
|
434
438
|
function _e(t, n) {
|
|
435
|
-
let r =
|
|
439
|
+
let r = O(t, n);
|
|
436
440
|
return n.maxSelect > 1 ? e`
|
|
437
441
|
<div class="space-y-2">
|
|
438
442
|
<h3 class="font-medium leading-none">${n.title}</h3>
|
|
@@ -509,7 +513,7 @@ function ye(t, n) {
|
|
|
509
513
|
`;
|
|
510
514
|
}
|
|
511
515
|
function be(t, n) {
|
|
512
|
-
let r =
|
|
516
|
+
let r = O(t, n), i = e`
|
|
513
517
|
{#await import("$lib/components/ui/leaflet/leaflet.svelte")}
|
|
514
518
|
<div class="h-56.25 w-full bg-input rounded-md"></div>
|
|
515
519
|
{:then { default: Leaflet }}
|
|
@@ -535,7 +539,7 @@ function xe(t, n) {
|
|
|
535
539
|
case "text":
|
|
536
540
|
case "number":
|
|
537
541
|
case "email":
|
|
538
|
-
case "editor": return
|
|
542
|
+
case "editor": return k(t, n, `{${O(t, n)}}`);
|
|
539
543
|
case "password": return e`
|
|
540
544
|
<div class="space-y-2">
|
|
541
545
|
<h3 class="font-medium leading-none">${n.title}</h3>
|
|
@@ -544,13 +548,13 @@ function xe(t, n) {
|
|
|
544
548
|
</p>
|
|
545
549
|
</div>
|
|
546
550
|
`;
|
|
547
|
-
case "bool": return
|
|
551
|
+
case "bool": return k(t, n, `{${O(t, n)} ? "Yes" : "No"}`);
|
|
548
552
|
case "date":
|
|
549
553
|
case "autodate": return me(t, n);
|
|
550
554
|
case "url": return he(t, n);
|
|
551
555
|
case "select": return ge(t, n);
|
|
552
556
|
case "file": return _e(t, n);
|
|
553
|
-
case "json": return
|
|
557
|
+
case "json": return k(t, n, `{JSON.stringify(${O(t, n)})}`);
|
|
554
558
|
case "geoPoint": return be(t, n);
|
|
555
559
|
case "relation": return ye(t, n);
|
|
556
560
|
default: return n;
|
|
@@ -580,20 +584,20 @@ function ke(e) {
|
|
|
580
584
|
return t;
|
|
581
585
|
}
|
|
582
586
|
function Ae(e, t) {
|
|
583
|
-
let [n, r, i] =
|
|
584
|
-
return n + r.map(
|
|
587
|
+
let [n, r, i] = P(e, t);
|
|
588
|
+
return n + r.map(M(t?.locale)).join(t?.delimiter ?? " ") + i;
|
|
585
589
|
}
|
|
586
|
-
function
|
|
587
|
-
let [n, r, i] =
|
|
590
|
+
function A(e, t) {
|
|
591
|
+
let [n, r, i] = P(e, t), a = M(t?.locale), o = Pe(t?.locale), s = t?.mergeAmbiguousCharacters ? N(a, o) : Fe(a, o);
|
|
588
592
|
return n + r.map((e, t) => t === 0 ? a(e) : s(e, t)).join(t?.delimiter ?? "") + i;
|
|
589
593
|
}
|
|
590
594
|
function je(e, t) {
|
|
591
|
-
let [n, r, i] =
|
|
595
|
+
let [n, r, i] = P(e, t), a = M(t?.locale), o = Pe(t?.locale), s = t?.mergeAmbiguousCharacters ? N(a, o) : Fe(a, o);
|
|
592
596
|
return n + r.map(s).join(t?.delimiter ?? "") + i;
|
|
593
597
|
}
|
|
594
|
-
function
|
|
595
|
-
let [n, r, i] =
|
|
596
|
-
return n + r.map(
|
|
598
|
+
function j(e, t) {
|
|
599
|
+
let [n, r, i] = P(e, t), a = M(t?.locale), o = Pe(t?.locale);
|
|
600
|
+
return n + r.map(N(a, o)).join(t?.delimiter ?? " ") + i;
|
|
597
601
|
}
|
|
598
602
|
function Me(e, t) {
|
|
599
603
|
return Ae(e, {
|
|
@@ -607,13 +611,13 @@ function Ne(e, t) {
|
|
|
607
611
|
...t
|
|
608
612
|
});
|
|
609
613
|
}
|
|
610
|
-
function
|
|
614
|
+
function M(e) {
|
|
611
615
|
return e === !1 ? (e) => e.toLowerCase() : (t) => t.toLocaleLowerCase(e);
|
|
612
616
|
}
|
|
613
|
-
function
|
|
617
|
+
function Pe(e) {
|
|
614
618
|
return e === !1 ? (e) => e.toUpperCase() : (t) => t.toLocaleUpperCase(e);
|
|
615
619
|
}
|
|
616
|
-
function
|
|
620
|
+
function N(e, t) {
|
|
617
621
|
return (n) => `${t(n[0])}${e(n.slice(1))}`;
|
|
618
622
|
}
|
|
619
623
|
function Fe(e, t) {
|
|
@@ -622,7 +626,7 @@ function Fe(e, t) {
|
|
|
622
626
|
return (r > 0 && i >= "0" && i <= "9" ? "_" + i : t(i)) + e(n.slice(1));
|
|
623
627
|
};
|
|
624
628
|
}
|
|
625
|
-
function
|
|
629
|
+
function P(e, t = {}) {
|
|
626
630
|
let n = t.split ?? (t.separateNumbers ? ke : Oe), r = t.prefixCharacters ?? De, i = t.suffixCharacters ?? De, a = 0, o = e.length;
|
|
627
631
|
for (; a < e.length;) {
|
|
628
632
|
let t = e.charAt(a);
|
|
@@ -642,7 +646,7 @@ function N(e, t = {}) {
|
|
|
642
646
|
}
|
|
643
647
|
//#endregion
|
|
644
648
|
//#region src/parse/model.ts
|
|
645
|
-
var
|
|
649
|
+
var F = /* @__PURE__ */ _((/* @__PURE__ */ h(((e, t) => {
|
|
646
650
|
(function(n, r) {
|
|
647
651
|
/* istanbul ignore else */
|
|
648
652
|
typeof v == "function" && typeof e == "object" && typeof t == "object" ? t.exports = r() : typeof define == "function" && define.amd ? define(function() {
|
|
@@ -961,25 +965,25 @@ var P = /* @__PURE__ */ _((/* @__PURE__ */ h(((e, t) => {
|
|
|
961
965
|
arguments: "args",
|
|
962
966
|
constructor: "ctor"
|
|
963
967
|
};
|
|
964
|
-
function
|
|
968
|
+
function I(e) {
|
|
965
969
|
return Ie.has(e) ? Le[e] ?? `${e}_` : e;
|
|
966
970
|
}
|
|
967
971
|
function Re(e) {
|
|
968
|
-
if (!/^[a-zA-Z][a-zA-Z0-9-_/]*$/.test(e)) throw
|
|
972
|
+
if (!/^[a-zA-Z][a-zA-Z0-9-_/]*$/.test(e)) throw new y("Model path must start with a letter and contain only alphanumeric characters, dash, slash, or underscore");
|
|
969
973
|
}
|
|
970
974
|
function ze(e) {
|
|
971
975
|
return e.features.auth ? `src/routes/${a}` : `src/routes/${i}`;
|
|
972
976
|
}
|
|
973
|
-
function
|
|
974
|
-
let n = e.split("/"), r = n[n.length - 1], i = n.slice(0, -1), a =
|
|
977
|
+
function L(e, t) {
|
|
978
|
+
let n = e.split("/"), r = n[n.length - 1], i = n.slice(0, -1), a = F.default.singular(j(r)), o = F.default.plural(a), s = A(a), c = Me(o), l = [...i, c].join("/");
|
|
975
979
|
return {
|
|
976
|
-
name:
|
|
977
|
-
pluralName:
|
|
980
|
+
name: I(s),
|
|
981
|
+
pluralName: I(A(o)),
|
|
978
982
|
typeName: je(a),
|
|
979
983
|
tableName: Ne(o),
|
|
980
984
|
displayName: a,
|
|
981
985
|
pluralDisplayName: o,
|
|
982
|
-
schemaName: `${
|
|
986
|
+
schemaName: `${I(s)}Schema`,
|
|
983
987
|
routeSegment: l,
|
|
984
988
|
routesDir: ze(t)
|
|
985
989
|
};
|
|
@@ -1029,7 +1033,7 @@ var qe = [
|
|
|
1029
1033
|
"account",
|
|
1030
1034
|
"creator"
|
|
1031
1035
|
];
|
|
1032
|
-
function
|
|
1036
|
+
function R(e) {
|
|
1033
1037
|
return e.toLowerCase();
|
|
1034
1038
|
}
|
|
1035
1039
|
function Je(e) {
|
|
@@ -1041,17 +1045,17 @@ function Je(e) {
|
|
|
1041
1045
|
};
|
|
1042
1046
|
}
|
|
1043
1047
|
function Ye(e, t, n = {}) {
|
|
1044
|
-
let r = new Set((n.authCollections ?? ["users"]).map(
|
|
1048
|
+
let r = new Set((n.authCollections ?? ["users"]).map(R)), i = new Set((n.userFieldHints ?? qe).map(R)), a = n.maxDepth ?? 8, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1045
1049
|
for (let t of e) o.set(t.name, t), s.set(t.id, t);
|
|
1046
1050
|
if (!o.has(t)) return Je(t);
|
|
1047
|
-
if (r.has(
|
|
1051
|
+
if (r.has(R(t))) return {
|
|
1048
1052
|
rule: "@request.auth.id = id",
|
|
1049
1053
|
ownershipChainCollections: [t],
|
|
1050
1054
|
ownershipChainFields: [],
|
|
1051
1055
|
operator: "="
|
|
1052
1056
|
};
|
|
1053
1057
|
function c(e) {
|
|
1054
|
-
let t =
|
|
1058
|
+
let t = R(e);
|
|
1055
1059
|
return t === "user" ? 50 : i.has(t) ? 20 : 0;
|
|
1056
1060
|
}
|
|
1057
1061
|
function l(e) {
|
|
@@ -1072,7 +1076,7 @@ function Ye(e, t, n = {}) {
|
|
|
1072
1076
|
return n.sort((e, t) => e.fieldName.localeCompare(t.fieldName)), n;
|
|
1073
1077
|
}
|
|
1074
1078
|
function u(e) {
|
|
1075
|
-
return r.has(
|
|
1079
|
+
return r.has(R(e));
|
|
1076
1080
|
}
|
|
1077
1081
|
function d(e) {
|
|
1078
1082
|
if (e.length === 0) return !1;
|
|
@@ -1080,7 +1084,7 @@ function Ye(e, t, n = {}) {
|
|
|
1080
1084
|
return u(e[e.length - 1].to);
|
|
1081
1085
|
}
|
|
1082
1086
|
function f(e) {
|
|
1083
|
-
let t = e[e.length - 1], n = +!!t.isMulti, r = +!!e.every((e) => !e.isMulti), i = e.reduce((e, t) => e + t.hintScore, 0), a = +(
|
|
1087
|
+
let t = e[e.length - 1], n = +!!t.isMulti, r = +!!e.every((e) => !e.isMulti), i = e.reduce((e, t) => e + t.hintScore, 0), a = +(R(t.fieldName) === "user");
|
|
1084
1088
|
return 100 * e.length + 50 * n - 40 * a - 15 * r - i;
|
|
1085
1089
|
}
|
|
1086
1090
|
function p(e) {
|
|
@@ -1101,12 +1105,12 @@ function Ye(e, t, n = {}) {
|
|
|
1101
1105
|
let n = f(e) - f(t);
|
|
1102
1106
|
return n === 0 ? p(e).localeCompare(p(t)) : n;
|
|
1103
1107
|
});
|
|
1104
|
-
let _ = m[0], v = _.map((e) => e.fieldName), ee = [t, ..._.map((e) => e.to)],
|
|
1108
|
+
let _ = m[0], v = _.map((e) => e.fieldName), ee = [t, ..._.map((e) => e.to)], y = _[_.length - 1].isMulti ? "?=" : "=", te = v.join(".");
|
|
1105
1109
|
return {
|
|
1106
|
-
rule: `@request.auth.id ${
|
|
1110
|
+
rule: `@request.auth.id ${y} ${n.includeRootPrefix ? (n.rootPrefix ?? t) + "." : ""}${te}.id`,
|
|
1107
1111
|
ownershipChainCollections: ee,
|
|
1108
1112
|
ownershipChainFields: v,
|
|
1109
|
-
operator:
|
|
1113
|
+
operator: y
|
|
1110
1114
|
};
|
|
1111
1115
|
}
|
|
1112
1116
|
//#endregion
|
|
@@ -1238,24 +1242,24 @@ function tt(e) {
|
|
|
1238
1242
|
});
|
|
1239
1243
|
}
|
|
1240
1244
|
function nt(e) {
|
|
1241
|
-
let t =
|
|
1242
|
-
return e ===
|
|
1245
|
+
let t = F.default.singular(e);
|
|
1246
|
+
return e === F.default.plural(t) ? 99 : 1;
|
|
1243
1247
|
}
|
|
1244
|
-
function
|
|
1245
|
-
let o =
|
|
1248
|
+
function z(e, t, n, r, i, a) {
|
|
1249
|
+
let o = L(t, a), s = F.default.singular(e), c = F.default.plural(s);
|
|
1246
1250
|
return {
|
|
1247
1251
|
collectionId: r[t],
|
|
1248
1252
|
displayField: i[t] ?? "id",
|
|
1249
1253
|
relatedModel: o,
|
|
1250
|
-
singularRelationName:
|
|
1251
|
-
pluralRelationName:
|
|
1254
|
+
singularRelationName: A(`${n.displayName} ${o.displayName}`),
|
|
1255
|
+
pluralRelationName: A(`${n.displayName} ${o.pluralDisplayName}`),
|
|
1252
1256
|
maxSelect: e === c ? 999 : 1
|
|
1253
1257
|
};
|
|
1254
1258
|
}
|
|
1255
1259
|
function rt(e, t, n, r, i) {
|
|
1256
|
-
let a =
|
|
1260
|
+
let a = j(e), { type: o, required: s, selectOptions: c } = t, l = We(r), u = Ge(r), d = Ke(r), f = l.map((e) => F.default.singular(e));
|
|
1257
1261
|
if (i.features.auth && o === "current_user" && u.users) {
|
|
1258
|
-
let t =
|
|
1262
|
+
let t = z(e, "users", n, u, d, i);
|
|
1259
1263
|
return {
|
|
1260
1264
|
type: "relation",
|
|
1261
1265
|
name: e,
|
|
@@ -1272,7 +1276,7 @@ function rt(e, t, n, r, i) {
|
|
|
1272
1276
|
}
|
|
1273
1277
|
if (o === "autodate") {
|
|
1274
1278
|
let t = e.includes("create"), n = e.includes("update");
|
|
1275
|
-
if (!t && !n) throw
|
|
1279
|
+
if (!t && !n) throw new y(`Invalid autodate field: ${e}. Must be one of created/created_at/updated/updated_at.`);
|
|
1276
1280
|
return {
|
|
1277
1281
|
type: "autodate",
|
|
1278
1282
|
name: e,
|
|
@@ -1298,14 +1302,14 @@ function rt(e, t, n, r, i) {
|
|
|
1298
1302
|
maxSelect: nt(e)
|
|
1299
1303
|
};
|
|
1300
1304
|
if (o === "relation") {
|
|
1301
|
-
let t =
|
|
1302
|
-
if (!l.includes(r)) throw
|
|
1305
|
+
let t = F.default.singular(e), r = F.default.plural(t);
|
|
1306
|
+
if (!l.includes(r)) throw new y(`Invalid relation field: ${e}. Must be one of ${l.join(", ")} (singular or plural)`);
|
|
1303
1307
|
return {
|
|
1304
1308
|
type: "relation",
|
|
1305
1309
|
name: e,
|
|
1306
1310
|
title: a,
|
|
1307
1311
|
required: s,
|
|
1308
|
-
...
|
|
1312
|
+
...z(e, r, n, u, d, i),
|
|
1309
1313
|
isCurrentUser: !1
|
|
1310
1314
|
};
|
|
1311
1315
|
}
|
|
@@ -1314,13 +1318,13 @@ function rt(e, t, n, r, i) {
|
|
|
1314
1318
|
name: e,
|
|
1315
1319
|
title: a,
|
|
1316
1320
|
required: s,
|
|
1317
|
-
...
|
|
1321
|
+
...z(e, o, n, u, d, i),
|
|
1318
1322
|
isCurrentUser: !1
|
|
1319
1323
|
};
|
|
1320
1324
|
if (f.includes(o)) {
|
|
1321
|
-
let t =
|
|
1325
|
+
let t = F.default.plural(o);
|
|
1322
1326
|
if (l.includes(t)) {
|
|
1323
|
-
let r =
|
|
1327
|
+
let r = z(e, t, n, u, d, i);
|
|
1324
1328
|
return {
|
|
1325
1329
|
type: "relation",
|
|
1326
1330
|
name: e,
|
|
@@ -1365,7 +1369,7 @@ function rt(e, t, n, r, i) {
|
|
|
1365
1369
|
"editor",
|
|
1366
1370
|
"json",
|
|
1367
1371
|
"geoPoint"
|
|
1368
|
-
].includes(o)) throw
|
|
1372
|
+
].includes(o)) throw new y(`Invalid field type: ${o}. Valid types are: ${p.join(", ").replace("relation", "references")}`);
|
|
1369
1373
|
return {
|
|
1370
1374
|
type: o,
|
|
1371
1375
|
name: e,
|
|
@@ -1377,8 +1381,8 @@ function it(e, t, n, r) {
|
|
|
1377
1381
|
let i = [];
|
|
1378
1382
|
for (let a of e) {
|
|
1379
1383
|
let [e, o] = Xe(a);
|
|
1380
|
-
if (!e || !o) throw
|
|
1381
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(e)) throw
|
|
1384
|
+
if (!e || !o) throw new y(`Invalid field format: ${a}. Expected format: name:type or name:type!`);
|
|
1385
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(e)) throw new y(`Invalid field name: ${e}. Must start with a letter and contain only alphanumeric characters`);
|
|
1382
1386
|
let s = tt(o);
|
|
1383
1387
|
i.push(rt(e, s, t, n, r));
|
|
1384
1388
|
}
|
|
@@ -1399,16 +1403,16 @@ function it(e, t, n, r) {
|
|
|
1399
1403
|
}
|
|
1400
1404
|
//#endregion
|
|
1401
1405
|
//#region src/core/tests.ts
|
|
1402
|
-
var at = "2024-01-01T00:00:00.000Z",
|
|
1406
|
+
var at = "2024-01-01T00:00:00.000Z", B = class {
|
|
1403
1407
|
constructor(e) {
|
|
1404
1408
|
this.expression = e;
|
|
1405
1409
|
}
|
|
1406
1410
|
};
|
|
1407
|
-
function B(e) {
|
|
1408
|
-
return e instanceof z ? e.expression : Array.isArray(e) ? `[${e.map((e) => B(e)).join(", ")}]` : e && typeof e == "object" ? `{ ${Object.entries(e).map(([e, t]) => `${JSON.stringify(e)}: ${B(t)}`).join(", ")} }` : JSON.stringify(e);
|
|
1409
|
-
}
|
|
1410
1411
|
function V(e) {
|
|
1411
|
-
return `{ ${Object.entries(e).map(([e, t]) => `${JSON.stringify(e)}: ${
|
|
1412
|
+
return e instanceof B ? e.expression : Array.isArray(e) ? `[${e.map((e) => V(e)).join(", ")}]` : e && typeof e == "object" ? `{ ${Object.entries(e).map(([e, t]) => `${JSON.stringify(e)}: ${V(t)}`).join(", ")} }` : JSON.stringify(e);
|
|
1413
|
+
}
|
|
1414
|
+
function H(e) {
|
|
1415
|
+
return `{ ${Object.entries(e).map(([e, t]) => `${JSON.stringify(e)}: ${V(t)}`).join(", ")} }`;
|
|
1412
1416
|
}
|
|
1413
1417
|
function ot(e) {
|
|
1414
1418
|
switch (e) {
|
|
@@ -1439,7 +1443,7 @@ function ot(e) {
|
|
|
1439
1443
|
default: return;
|
|
1440
1444
|
}
|
|
1441
1445
|
}
|
|
1442
|
-
function
|
|
1446
|
+
function U(e, t) {
|
|
1443
1447
|
return e.replace("[id]", `\${${t}}`);
|
|
1444
1448
|
}
|
|
1445
1449
|
function st(e, t, n) {
|
|
@@ -1465,9 +1469,9 @@ function st(e, t, n) {
|
|
|
1465
1469
|
return e.maxSelect && e.maxSelect > 1 ? [t] : t;
|
|
1466
1470
|
}
|
|
1467
1471
|
case "relation": {
|
|
1468
|
-
if (n.authEnabled && (e.isCurrentUser || e.relatedModel?.tableName === "users")) return new
|
|
1472
|
+
if (n.authEnabled && (e.isCurrentUser || e.relatedModel?.tableName === "users")) return new B("context.user.id");
|
|
1469
1473
|
let r = e.collectionId ? t[e.collectionId] : void 0;
|
|
1470
|
-
return r ? new
|
|
1474
|
+
return r ? new B(r) : "missing-relation-id";
|
|
1471
1475
|
}
|
|
1472
1476
|
case "file":
|
|
1473
1477
|
case "autodate": return;
|
|
@@ -1479,7 +1483,7 @@ function ct(e, t, n) {
|
|
|
1479
1483
|
for (let i of e) {
|
|
1480
1484
|
if (i.type === "file" || i.type === "autodate") continue;
|
|
1481
1485
|
if (n.authEnabled && i.type === "relation" && i.isCurrentUser) {
|
|
1482
|
-
n.forForm || (r[i.name] = new
|
|
1486
|
+
n.forForm || (r[i.name] = new B("context.user.id"));
|
|
1483
1487
|
continue;
|
|
1484
1488
|
}
|
|
1485
1489
|
let e = st(i, t, n);
|
|
@@ -1494,7 +1498,7 @@ function lt(e, t, n) {
|
|
|
1494
1498
|
let e = ot(i.type);
|
|
1495
1499
|
if (!e || e === "file" || e === "autodate" || e === "relation" && !i.collectionId) continue;
|
|
1496
1500
|
let a;
|
|
1497
|
-
if (e === "relation") a = i.collectionId ? new
|
|
1501
|
+
if (e === "relation") a = i.collectionId ? new B(t[i.collectionId] ?? "\"missing-relation-id\"") : void 0;
|
|
1498
1502
|
else if (e === "select") {
|
|
1499
1503
|
let e = i.values?.[0] ?? "default";
|
|
1500
1504
|
a = (i.maxSelect ?? 1) > 1 ? [e] : e;
|
|
@@ -1510,7 +1514,7 @@ function lt(e, t, n) {
|
|
|
1510
1514
|
return r;
|
|
1511
1515
|
}
|
|
1512
1516
|
function ut(e) {
|
|
1513
|
-
e.email = new
|
|
1517
|
+
e.email = new B("`test-${Math.random().toString(36).slice(2)}@example.com`"), e.password = "password", e.passwordConfirm = "password";
|
|
1514
1518
|
}
|
|
1515
1519
|
function dt(e, t) {
|
|
1516
1520
|
if (!e) return [];
|
|
@@ -1561,7 +1565,7 @@ function pt(e, t) {
|
|
|
1561
1565
|
function mt(t, n, r, i) {
|
|
1562
1566
|
let a = dt(i.find((e) => e.name === t.tableName) ?? pt(t, n), i).filter((e) => !(r.features.auth && e.name === "users")), o = {}, s = [], c = /* @__PURE__ */ new Set();
|
|
1563
1567
|
for (let e of a) {
|
|
1564
|
-
let t = ft(
|
|
1568
|
+
let t = ft(L(e.name, r).name, c);
|
|
1565
1569
|
s.push({
|
|
1566
1570
|
varName: t,
|
|
1567
1571
|
collection: e
|
|
@@ -1569,7 +1573,7 @@ function mt(t, n, r, i) {
|
|
|
1569
1573
|
}
|
|
1570
1574
|
let l = s.length ? `${s.map((e) => `let ${e.varName}: { id: string };`).join("\n")}\n\n` : "", u = s.map(({ varName: e, collection: t }) => {
|
|
1571
1575
|
let n = lt(t.fields, o, r);
|
|
1572
|
-
return t.type === "auth" && ut(n), `${e} = await context.admin.collection("${t.name}").create(${
|
|
1576
|
+
return t.type === "auth" && ut(n), `${e} = await context.admin.collection("${t.name}").create(${H(n)});`;
|
|
1573
1577
|
}), d = s.slice().reverse().map(({ varName: e, collection: t }) => `await context.admin.collection("${t.name}").delete(${e}.id);`), f = r.features.auth ? "context.agent" : "context.request", p = r.features.auth ? "await context.agent.authenticateUser();\n " : "", m = "";
|
|
1574
1578
|
return (u.length > 0 || r.features.auth) && (m += e`
|
|
1575
1579
|
beforeEach(async (context) => {
|
|
@@ -1583,11 +1587,11 @@ function mt(t, n, r, i) {
|
|
|
1583
1587
|
declarations: l,
|
|
1584
1588
|
setupSection: m,
|
|
1585
1589
|
requestAgent: f,
|
|
1586
|
-
modelDbData:
|
|
1590
|
+
modelDbData: H(ct(n, o, {
|
|
1587
1591
|
forForm: !1,
|
|
1588
1592
|
authEnabled: r.features.auth
|
|
1589
1593
|
})),
|
|
1590
|
-
modelFormData:
|
|
1594
|
+
modelFormData: H(ct(n, o, {
|
|
1591
1595
|
forForm: !0,
|
|
1592
1596
|
authEnabled: r.features.auth
|
|
1593
1597
|
}))
|
|
@@ -1628,7 +1632,7 @@ function ht(t, n, r, i, a) {
|
|
|
1628
1632
|
describe("GET ${n.show}", () => {
|
|
1629
1633
|
it("should return a 200 status code", async (context) => {
|
|
1630
1634
|
const { id } = await context.admin.collection("${t.tableName}").create(${l});
|
|
1631
|
-
const response = await ${c}.get(\`${
|
|
1635
|
+
const response = await ${c}.get(\`${U(n.show, "id")}\`);
|
|
1632
1636
|
expect(response.status).toBe(200);
|
|
1633
1637
|
});
|
|
1634
1638
|
|
|
@@ -1641,10 +1645,10 @@ function ht(t, n, r, i, a) {
|
|
|
1641
1645
|
describe("POST ${n.show}", () => {
|
|
1642
1646
|
it("should delete a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1643
1647
|
const { id } = await context.admin.collection("${t.tableName}").create(${l});
|
|
1644
|
-
const response = await ${c}.post(\`${
|
|
1648
|
+
const response = await ${c}.post(\`${U(n.show, "id")}\`).type("form");
|
|
1645
1649
|
expect(response.body.status).toBe(303);
|
|
1646
1650
|
|
|
1647
|
-
const response2 = await ${c}.get(\`${
|
|
1651
|
+
const response2 = await ${c}.get(\`${U(n.show, "id")}\`);
|
|
1648
1652
|
expect(response2.status).toBe(404);
|
|
1649
1653
|
});
|
|
1650
1654
|
});
|
|
@@ -1652,7 +1656,7 @@ function ht(t, n, r, i, a) {
|
|
|
1652
1656
|
describe("GET ${n.edit}", () => {
|
|
1653
1657
|
it("should return a 200 status code", async (context) => {
|
|
1654
1658
|
const { id } = await context.admin.collection("${t.tableName}").create(${l});
|
|
1655
|
-
const response = await ${c}.get(\`${
|
|
1659
|
+
const response = await ${c}.get(\`${U(n.edit, "id")}\`);
|
|
1656
1660
|
expect(response.status).toBe(200);
|
|
1657
1661
|
});
|
|
1658
1662
|
});
|
|
@@ -1661,11 +1665,11 @@ function ht(t, n, r, i, a) {
|
|
|
1661
1665
|
it("should update a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1662
1666
|
const { id } = await context.admin.collection("${t.tableName}").create(${l});
|
|
1663
1667
|
const response = await ${c}
|
|
1664
|
-
.post(\`${
|
|
1668
|
+
.post(\`${U(n.edit, "id")}\`)
|
|
1665
1669
|
.type("form")
|
|
1666
1670
|
.send(${u});
|
|
1667
1671
|
expect(response.body.status).toBe(303);
|
|
1668
|
-
expect(response.body.location).toBe(\`${
|
|
1672
|
+
expect(response.body.location).toBe(\`${U(n.show, "id")}\`);
|
|
1669
1673
|
});
|
|
1670
1674
|
});
|
|
1671
1675
|
});
|
|
@@ -1727,7 +1731,7 @@ var _t = ["text"], vt = {
|
|
|
1727
1731
|
function yt(e) {
|
|
1728
1732
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : `'${e}'`;
|
|
1729
1733
|
}
|
|
1730
|
-
function
|
|
1734
|
+
function W(t, n) {
|
|
1731
1735
|
let r = t.type === "select" ? `[${(t.options ?? []).map((e) => JSON.stringify(e.value)).join(", ")}]` : "", i;
|
|
1732
1736
|
switch (t.type) {
|
|
1733
1737
|
case "text":
|
|
@@ -1794,9 +1798,9 @@ async function bt(e) {
|
|
|
1794
1798
|
let { getPreviewCollections: t } = await import("./chunks/env.preview-Cpr4Im0G.js");
|
|
1795
1799
|
return t(e);
|
|
1796
1800
|
}
|
|
1797
|
-
async function
|
|
1801
|
+
async function G(e, t, n) {
|
|
1798
1802
|
Re(t);
|
|
1799
|
-
let r =
|
|
1803
|
+
let r = L(t, e), i = await bt(e);
|
|
1800
1804
|
if (n.length > 0) {
|
|
1801
1805
|
let { fields: t, auth: a } = it(n, r, i, e);
|
|
1802
1806
|
return {
|
|
@@ -1815,18 +1819,18 @@ async function W(e, t, n) {
|
|
|
1815
1819
|
collections: i
|
|
1816
1820
|
};
|
|
1817
1821
|
}
|
|
1818
|
-
function
|
|
1822
|
+
function K(t, n, r) {
|
|
1819
1823
|
let i = [];
|
|
1820
1824
|
r.includeModelFields && (i.push({
|
|
1821
1825
|
name: "id",
|
|
1822
|
-
schema:
|
|
1826
|
+
schema: W({
|
|
1823
1827
|
name: "id",
|
|
1824
1828
|
type: "text",
|
|
1825
1829
|
required: !1
|
|
1826
1830
|
}, r)
|
|
1827
1831
|
}), i.push({
|
|
1828
1832
|
name: "collectionId",
|
|
1829
|
-
schema:
|
|
1833
|
+
schema: W({
|
|
1830
1834
|
name: "collectionId",
|
|
1831
1835
|
type: "text",
|
|
1832
1836
|
required: !1
|
|
@@ -1836,7 +1840,7 @@ function G(t, n, r) {
|
|
|
1836
1840
|
if (e.type === "file" && e.maxSelect > 1) {
|
|
1837
1841
|
i.push({
|
|
1838
1842
|
name: e.name,
|
|
1839
|
-
schema:
|
|
1843
|
+
schema: W({
|
|
1840
1844
|
...e,
|
|
1841
1845
|
required: !1
|
|
1842
1846
|
}, r)
|
|
@@ -1851,7 +1855,7 @@ function G(t, n, r) {
|
|
|
1851
1855
|
}
|
|
1852
1856
|
i.push({
|
|
1853
1857
|
name: e.name,
|
|
1854
|
-
schema:
|
|
1858
|
+
schema: W(e, r)
|
|
1855
1859
|
});
|
|
1856
1860
|
}
|
|
1857
1861
|
let a = i.map((e) => `${yt(e.name)}: ${e.schema}`).join(",\n "), o = r.includeModelFields ? "\nimport type { Schemas } from \"pocketbase-svelte\";" : "", s = r.includeModelFields ? ` satisfies Schemas["${t.tableName}"]` : "";
|
|
@@ -1874,11 +1878,11 @@ function St(e, t, n) {
|
|
|
1874
1878
|
let i = Ke(t), a = new Map(t.map((e) => [e.id, e])), o = [];
|
|
1875
1879
|
for (let t of r.fields) {
|
|
1876
1880
|
if (t.name === "id" || t.system) continue;
|
|
1877
|
-
let r = xt(t.type), s = !!t.required, c =
|
|
1881
|
+
let r = xt(t.type), s = !!t.required, c = j(t.name);
|
|
1878
1882
|
if (r === "relation") {
|
|
1879
1883
|
let r = t.collectionId ? a.get(t.collectionId) : void 0;
|
|
1880
1884
|
if (!r) continue;
|
|
1881
|
-
let l =
|
|
1885
|
+
let l = L(r.name, n);
|
|
1882
1886
|
o.push({
|
|
1883
1887
|
name: t.name,
|
|
1884
1888
|
title: c,
|
|
@@ -1888,8 +1892,8 @@ function St(e, t, n) {
|
|
|
1888
1892
|
maxSelect: t.maxSelect ?? 1,
|
|
1889
1893
|
displayField: i[r.name] ?? "id",
|
|
1890
1894
|
relatedModel: l,
|
|
1891
|
-
singularRelationName:
|
|
1892
|
-
pluralRelationName:
|
|
1895
|
+
singularRelationName: A(`${e.displayName} ${l.displayName}`),
|
|
1896
|
+
pluralRelationName: A(`${e.displayName} ${l.pluralDisplayName}`),
|
|
1893
1897
|
isCurrentUser: n.features.auth && r.name === "users" && /user|owner|author/i.test(t.name)
|
|
1894
1898
|
});
|
|
1895
1899
|
continue;
|
|
@@ -1987,7 +1991,7 @@ function Et(e, t, n) {
|
|
|
1987
1991
|
}
|
|
1988
1992
|
//#endregion
|
|
1989
1993
|
//#region \0@oxc-project+runtime@0.124.0/helpers/taggedTemplateLiteral.js
|
|
1990
|
-
function
|
|
1994
|
+
function q(e, t) {
|
|
1991
1995
|
return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
1992
1996
|
}
|
|
1993
1997
|
//#endregion
|
|
@@ -2002,8 +2006,8 @@ function Ot(e, t) {
|
|
|
2002
2006
|
}
|
|
2003
2007
|
function kt(e) {
|
|
2004
2008
|
let [t, ...n] = e;
|
|
2005
|
-
if (!t) throw
|
|
2006
|
-
if (n.length === 0) throw
|
|
2009
|
+
if (!t) throw new y("Invalid command arguments. Expected: <model> <fields...>");
|
|
2010
|
+
if (n.length === 0) throw new y("At least one field definition is required.");
|
|
2007
2011
|
return {
|
|
2008
2012
|
modelPath: t,
|
|
2009
2013
|
fieldDefs: n
|
|
@@ -2013,12 +2017,12 @@ function At(e) {
|
|
|
2013
2017
|
return e.some((e) => e.type === "file");
|
|
2014
2018
|
}
|
|
2015
2019
|
function jt(e, t) {
|
|
2016
|
-
let n =
|
|
2020
|
+
let n = E(t), r = [
|
|
2017
2021
|
"import { untrack } from \"svelte\";",
|
|
2018
2022
|
"import { superForm } from \"sveltekit-superforms\";",
|
|
2019
2023
|
"import { zod4Client } from \"sveltekit-superforms/adapters\";",
|
|
2020
2024
|
`import { ${e.schemaName} } from "$lib/schemas/${e.name}";`,
|
|
2021
|
-
...
|
|
2025
|
+
...D(n)
|
|
2022
2026
|
];
|
|
2023
2027
|
return [...new Set(r)];
|
|
2024
2028
|
}
|
|
@@ -2034,8 +2038,8 @@ function Mt(t, n) {
|
|
|
2034
2038
|
`;
|
|
2035
2039
|
}
|
|
2036
2040
|
function Nt(t, n) {
|
|
2037
|
-
let r = jt(t, n).join("\n"), i = Mt(t, n), a = n.map((e) =>
|
|
2038
|
-
return e(Dt ||=
|
|
2041
|
+
let r = jt(t, n).join("\n"), i = Mt(t, n), a = n.map((e) => T(e)).join("\n"), o = At(n) ? " enctype=\"multipart/form-data\"" : "";
|
|
2042
|
+
return e(Dt ||= q([
|
|
2039
2043
|
"\n <script lang=\"ts\">\n ",
|
|
2040
2044
|
"\n\n let { data } = $props();\n ",
|
|
2041
2045
|
"\n <\/script>\n\n <section data-role=\"content\">\n <div class=\"flex justify-between items-center mb-4\">\n <h1 class=\"text-3xl font-bold tracking-tight\">",
|
|
@@ -2074,28 +2078,29 @@ function Pt(t, n) {
|
|
|
2074
2078
|
};
|
|
2075
2079
|
`;
|
|
2076
2080
|
}
|
|
2077
|
-
function
|
|
2081
|
+
function J(e, n) {
|
|
2078
2082
|
return {
|
|
2079
2083
|
path: e,
|
|
2080
2084
|
language: t(e),
|
|
2081
|
-
content: n
|
|
2085
|
+
content: n,
|
|
2086
|
+
status: "success"
|
|
2082
2087
|
};
|
|
2083
2088
|
}
|
|
2084
2089
|
async function Ft(e) {
|
|
2085
|
-
let { modelPath: t, fieldDefs: n } = kt(e.argv), { model: r, fields: i, collections: a } = await
|
|
2090
|
+
let { modelPath: t, fieldDefs: n } = kt(e.argv), { model: r, fields: i, collections: a } = await G(e, t, n), { pagePath: o, pageUrl: s } = Ot(t, r.routesDir);
|
|
2086
2091
|
return {
|
|
2087
2092
|
creates: [
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2093
|
+
J(`${o}/+page.svelte`, Nt(r, i)),
|
|
2094
|
+
J(`${o}/+page.server.ts`, Pt(r, i)),
|
|
2095
|
+
J(`${o}/server.test.ts`, gt(r, s, i, e, a)),
|
|
2096
|
+
J(`src/lib/schemas/${r.name}.ts`, K(r, i, {
|
|
2092
2097
|
includeModelFields: !1,
|
|
2093
2098
|
forForm: !0
|
|
2094
2099
|
}))
|
|
2095
2100
|
],
|
|
2096
2101
|
modifies: [],
|
|
2097
2102
|
deletes: [],
|
|
2098
|
-
components:
|
|
2103
|
+
components: E(i),
|
|
2099
2104
|
packages: [],
|
|
2100
2105
|
collections: []
|
|
2101
2106
|
};
|
|
@@ -2105,9 +2110,9 @@ async function Ft(e) {
|
|
|
2105
2110
|
var It = "generate-form", Lt = "1.0.7", Rt = "src/patterns/generate/form", zt = "/generate/form";
|
|
2106
2111
|
async function Bt(e) {
|
|
2107
2112
|
let t = await Ft(e);
|
|
2108
|
-
if (e.env !== "runtime") return
|
|
2109
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2110
|
-
return n(await
|
|
2113
|
+
if (e.env !== "runtime") return b(t);
|
|
2114
|
+
let { writeResult: n } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2115
|
+
return n(await b(t), e);
|
|
2111
2116
|
}
|
|
2112
2117
|
var Vt = {
|
|
2113
2118
|
version: Lt,
|
|
@@ -2142,6 +2147,20 @@ var Vt = {
|
|
|
2142
2147
|
"message:editor"
|
|
2143
2148
|
]
|
|
2144
2149
|
},
|
|
2150
|
+
examples: [
|
|
2151
|
+
{
|
|
2152
|
+
command: "contact name:text! email:email! message:editor",
|
|
2153
|
+
description: "Contact form with required text fields and a rich editor."
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
command: "profile avatar:file bio:editor website:url",
|
|
2157
|
+
description: "File upload, editor, and URL validation."
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
command: "feedback rating:select(1,2,3,4,5) comment:editor",
|
|
2161
|
+
description: "Select enum with a long-form comment."
|
|
2162
|
+
}
|
|
2163
|
+
],
|
|
2145
2164
|
tests: 2,
|
|
2146
2165
|
baseline: "velastack",
|
|
2147
2166
|
generate: Bt
|
|
@@ -2150,7 +2169,7 @@ var Vt = {
|
|
|
2150
2169
|
//#region src/patterns/generate/resource/generate.ts
|
|
2151
2170
|
function Ht(e) {
|
|
2152
2171
|
let [t, ...n] = e;
|
|
2153
|
-
if (!t) throw
|
|
2172
|
+
if (!t) throw new y("Invalid command arguments. Expected: <model> [fields...]");
|
|
2154
2173
|
return {
|
|
2155
2174
|
modelPath: t,
|
|
2156
2175
|
fields: n
|
|
@@ -2160,13 +2179,14 @@ function Ut(e, n) {
|
|
|
2160
2179
|
return {
|
|
2161
2180
|
path: e,
|
|
2162
2181
|
language: t(e),
|
|
2163
|
-
content: n
|
|
2182
|
+
content: n,
|
|
2183
|
+
status: "success"
|
|
2164
2184
|
};
|
|
2165
2185
|
}
|
|
2166
2186
|
async function Wt(e) {
|
|
2167
|
-
let { modelPath: t, fields: n } = Ht(e.argv), { model: r, fields: i, auth: a, shouldCreateCollection: o } = await
|
|
2187
|
+
let { modelPath: t, fields: n } = Ht(e.argv), { model: r, fields: i, auth: a, shouldCreateCollection: o } = await G(e, t, n);
|
|
2168
2188
|
return {
|
|
2169
|
-
creates: [Ut(`src/lib/schemas/${r.name}.ts`,
|
|
2189
|
+
creates: [Ut(`src/lib/schemas/${r.name}.ts`, K(r, i, {
|
|
2170
2190
|
includeModelFields: !0,
|
|
2171
2191
|
forForm: !0
|
|
2172
2192
|
}))],
|
|
@@ -2182,12 +2202,12 @@ async function Wt(e) {
|
|
|
2182
2202
|
var Gt = "generate-resource", Kt = "1.0.7", qt = "src/patterns/generate/resource", Jt = "/generate/resource";
|
|
2183
2203
|
async function Yt(e) {
|
|
2184
2204
|
let t = await Wt(e);
|
|
2185
|
-
if (e.env !== "runtime") return
|
|
2186
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
2205
|
+
if (e.env !== "runtime") return b(t);
|
|
2206
|
+
let { createCollections: n } = await import("./chunks/collections-DdGJC7Ip.js"), r = await n(t.collections, e), i = {
|
|
2187
2207
|
...t,
|
|
2188
2208
|
creates: [...t.creates, ...r]
|
|
2189
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2190
|
-
return a(await
|
|
2209
|
+
}, { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2210
|
+
return a(await b(i), e);
|
|
2191
2211
|
}
|
|
2192
2212
|
var Xt = {
|
|
2193
2213
|
version: Kt,
|
|
@@ -2220,32 +2240,47 @@ var Xt = {
|
|
|
2220
2240
|
"email:email"
|
|
2221
2241
|
]
|
|
2222
2242
|
},
|
|
2243
|
+
examples: [
|
|
2244
|
+
{
|
|
2245
|
+
command: "articles title:text! body:editor author:current_user",
|
|
2246
|
+
description: "Content model with an auth-bound author relation."
|
|
2247
|
+
},
|
|
2248
|
+
{
|
|
2249
|
+
command: "projects name:text! status:select(active:Active,done:Done)",
|
|
2250
|
+
description: "Resource with an enum status field."
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
command: "users/posts title:text! published:bool",
|
|
2254
|
+
description: "Nested resource scoped under users."
|
|
2255
|
+
}
|
|
2256
|
+
],
|
|
2223
2257
|
tests: 0,
|
|
2224
2258
|
baseline: "velastack",
|
|
2225
2259
|
generate: Yt
|
|
2226
2260
|
}, Zt, Qt, $t, en;
|
|
2227
2261
|
function tn(e) {
|
|
2228
2262
|
let [t, ...n] = e;
|
|
2229
|
-
if (!t) throw
|
|
2263
|
+
if (!t) throw new y("Invalid command arguments. Expected: <model> [fields...]");
|
|
2230
2264
|
return {
|
|
2231
2265
|
modelPath: t,
|
|
2232
2266
|
fields: n
|
|
2233
2267
|
};
|
|
2234
2268
|
}
|
|
2235
|
-
function
|
|
2269
|
+
function Y(e, n) {
|
|
2236
2270
|
return {
|
|
2237
2271
|
path: e,
|
|
2238
2272
|
language: t(e),
|
|
2239
|
-
content: n
|
|
2273
|
+
content: n,
|
|
2274
|
+
status: "success"
|
|
2240
2275
|
};
|
|
2241
2276
|
}
|
|
2242
|
-
function
|
|
2277
|
+
function X(e) {
|
|
2243
2278
|
return e.some((e) => e.type === "file");
|
|
2244
2279
|
}
|
|
2245
2280
|
function nn(e) {
|
|
2246
2281
|
return [...new Set(e.filter(Boolean))];
|
|
2247
2282
|
}
|
|
2248
|
-
function
|
|
2283
|
+
function Z(e) {
|
|
2249
2284
|
return e.filter((e) => e.type === "select").map((e) => pe(e)).join("\n\n");
|
|
2250
2285
|
}
|
|
2251
2286
|
function rn(e, t) {
|
|
@@ -2259,7 +2294,7 @@ function on(e) {
|
|
|
2259
2294
|
}
|
|
2260
2295
|
function sn(t, n, r = !1) {
|
|
2261
2296
|
return e`
|
|
2262
|
-
${
|
|
2297
|
+
${Z(n)}
|
|
2263
2298
|
${r ? "let { data, params } = $props();" : "let { data } = $props();"}
|
|
2264
2299
|
|
|
2265
2300
|
const form = superForm(untrack(() => data.form), {
|
|
@@ -2275,13 +2310,13 @@ function cn(t, n, r) {
|
|
|
2275
2310
|
"import { superForm } from \"sveltekit-superforms\";",
|
|
2276
2311
|
"import { zod4Client } from \"sveltekit-superforms/adapters\";",
|
|
2277
2312
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2278
|
-
...E(
|
|
2313
|
+
...D(E(r)),
|
|
2279
2314
|
"import { Button } from \"$lib/components/ui/button\";",
|
|
2280
2315
|
"import ArrowLeftIcon from \"@lucide/svelte/icons/arrow-left\";",
|
|
2281
2316
|
"import * as Form from \"$lib/components/ui/form\";",
|
|
2282
2317
|
i ? "import type { Models } from \"pocketbase-svelte\";" : ""
|
|
2283
|
-
]).join("\n"), o = r.map((e) =>
|
|
2284
|
-
return e(Zt ||=
|
|
2318
|
+
]).join("\n"), o = r.map((e) => T(e)).join("\n"), s = X(r) ? " enctype=\"multipart/form-data\"" : "";
|
|
2319
|
+
return e(Zt ||= q([
|
|
2285
2320
|
"\n <script lang=\"ts\">\n ",
|
|
2286
2321
|
"\n ",
|
|
2287
2322
|
"\n <\/script>\n\n <section data-role=\"content\">\n <div class=\"flex justify-between items-center mb-4\">\n <h1 class=\"text-3xl font-bold tracking-tight\">New ",
|
|
@@ -2298,13 +2333,13 @@ function ln(t, n, r) {
|
|
|
2298
2333
|
"import { superForm } from \"sveltekit-superforms\";",
|
|
2299
2334
|
"import { zod4Client } from \"sveltekit-superforms/adapters\";",
|
|
2300
2335
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2301
|
-
...E(
|
|
2336
|
+
...D(E(r)),
|
|
2302
2337
|
"import { Button } from \"$lib/components/ui/button\";",
|
|
2303
2338
|
"import ArrowLeftIcon from \"@lucide/svelte/icons/arrow-left\";",
|
|
2304
2339
|
"import * as Form from \"$lib/components/ui/form\";",
|
|
2305
2340
|
i ? "import type { Models } from \"pocketbase-svelte\";" : ""
|
|
2306
|
-
]).join("\n"), o = r.map((e) =>
|
|
2307
|
-
return e(Qt ||=
|
|
2341
|
+
]).join("\n"), o = r.map((e) => T(e)).join("\n"), s = X(r) ? " enctype=\"multipart/form-data\"" : "";
|
|
2342
|
+
return e(Qt ||= q([
|
|
2308
2343
|
"\n <script lang=\"ts\">\n ",
|
|
2309
2344
|
"\n ",
|
|
2310
2345
|
"\n <\/script>\n\n <section data-role=\"content\">\n <div class=\"flex justify-between items-center mb-4\">\n <h1 class=\"text-3xl font-bold tracking-tight\">Edit ",
|
|
@@ -2325,7 +2360,7 @@ function ln(t, n, r) {
|
|
|
2325
2360
|
]), a, sn(t, r, !0), t.displayName.toLowerCase(), n.list, s, o, n.list);
|
|
2326
2361
|
}
|
|
2327
2362
|
function un(t, n, r) {
|
|
2328
|
-
let i = r.some((e) => e.type === "select"), a = i ? `${
|
|
2363
|
+
let i = r.some((e) => e.type === "select"), a = i ? `${Z(r)}` : "", o = r.map((t) => {
|
|
2329
2364
|
let n = "{ getValue }", r = "{ value: getValue() }";
|
|
2330
2365
|
return t.type === "relation" && (n = "{ getValue, row }", r = `{ value: getValue(), expanded: row.original.expand?.${t.name}, displayField: "${t.displayField}" }`), t.type === "select" && (r = `{ value: getValue(), options: ${t.name}Labels }`), t.type === "file" && (n = "{ getValue, row }", r = "{ value: getValue(), collectionId: row.original.collectionId, id: row.original.id }"), e`
|
|
2331
2366
|
columnHelper.accessor("${t.name}", {
|
|
@@ -2334,7 +2369,7 @@ function un(t, n, r) {
|
|
|
2334
2369
|
})
|
|
2335
2370
|
`;
|
|
2336
2371
|
}).join(",\n"), s = r.filter((e) => e.type === "select").map((e) => `<FacetedFilter column={table.getColumn("${e.name}")!} title="${e.title}" options={Object.values(${e.name}Labels)} />`).join("\n");
|
|
2337
|
-
return e($t ||=
|
|
2372
|
+
return e($t ||= q([
|
|
2338
2373
|
"\n <script lang=\"ts\">\n import {\n type ColumnFiltersState,\n type PaginationState,\n type RowSelectionState,\n type SortingState,\n type VisibilityState,\n getCoreRowModel,\n getFacetedRowModel,\n getFacetedUniqueValues,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n createColumnHelper\n } from \"@tanstack/table-core\";\n import { createSvelteTable, FlexRender, renderComponent } from \"$lib/components/ui/data-table\";\n import * as Table from \"$lib/components/ui/table\";\n import { Checkbox } from \"$lib/components/ui/checkbox\";\n import { ColumnHeader } from \"$lib/components/ui/column-header\";\n import { Pagination } from \"$lib/components/ui/pagination\";\n import { RowActions } from \"$lib/components/ui/row-actions\";\n import * as Cells from \"$lib/components/ui/cells\";\n import { Button } from \"$lib/components/ui/button\";\n import { Input } from \"$lib/components/ui/input\";\n ",
|
|
2339
2374
|
"\n import XIcon from \"@lucide/svelte/icons/x\";\n import PlusIcon from \"@lucide/svelte/icons/plus\";\n import type { Models } from \"pocketbase-svelte\";\n\n let { data } = $props();\n let rowSelection = $state<RowSelectionState>({});\n let columnVisibility = $state<VisibilityState>({});\n let columnFilters = $state<ColumnFiltersState>([]);\n let sorting = $state<SortingState>([]);\n let pagination = $state<PaginationState>({ pageIndex: 0, pageSize: 10 });\n\n ",
|
|
2340
2375
|
"\n\n const columnHelper = createColumnHelper<Models[\"",
|
|
@@ -2378,7 +2413,7 @@ function dn(t, n, r) {
|
|
|
2378
2413
|
`;
|
|
2379
2414
|
}
|
|
2380
2415
|
function fn(t, n, r, i, a) {
|
|
2381
|
-
let o =
|
|
2416
|
+
let o = X(r), s = rn(r, i), c = an(r), l = c ? `, ${c}` : "", u = r.find((e) => e.type === "relation" && e.isCurrentUser), d = a && u ? e`
|
|
2382
2417
|
{
|
|
2383
2418
|
...form.data,
|
|
2384
2419
|
${u.name}: locals.pb.authStore.record?.id
|
|
@@ -2449,8 +2484,8 @@ function mn(t, n, r) {
|
|
|
2449
2484
|
i || a ? "import { Badge } from \"$lib/components/ui/badge\";" : "",
|
|
2450
2485
|
a ? "import CircleArrowRightIcon from \"@lucide/svelte/icons/circle-arrow-right\";" : "",
|
|
2451
2486
|
o ? "import FileIcon from \"@lucide/svelte/icons/file\";" : ""
|
|
2452
|
-
].filter(Boolean).join("\n"), c =
|
|
2453
|
-
return e(en ||=
|
|
2487
|
+
].filter(Boolean).join("\n"), c = Z(r), l = r.map((e) => xe(t, e)).join("\n");
|
|
2488
|
+
return e(en ||= q([
|
|
2454
2489
|
"\n <script lang=\"ts\">\n ",
|
|
2455
2490
|
"\n ",
|
|
2456
2491
|
"\n\n let { data } = $props();\n <\/script>\n\n <section data-role=\"content\">\n <div class=\"flex justify-between items-center mb-4\">\n <h1 class=\"text-3xl font-bold tracking-tight\">",
|
|
@@ -2462,7 +2497,7 @@ function mn(t, n, r) {
|
|
|
2462
2497
|
]), s, c, t.displayName, n.list, l, n.list, t.name);
|
|
2463
2498
|
}
|
|
2464
2499
|
function hn(t, n, r, i) {
|
|
2465
|
-
let a =
|
|
2500
|
+
let a = X(r), o = rn(r, i), s = an(r), c = s ? `, ${s}` : "";
|
|
2466
2501
|
return e`
|
|
2467
2502
|
import { error, fail, redirect } from "@sveltejs/kit";
|
|
2468
2503
|
import { setPocketbaseErrors, setDefaultData } from "@velastack/pocketbase";
|
|
@@ -2504,22 +2539,22 @@ function hn(t, n, r, i) {
|
|
|
2504
2539
|
`;
|
|
2505
2540
|
}
|
|
2506
2541
|
async function gn(e) {
|
|
2507
|
-
let { modelPath: t, fields: n } = tn(e.argv), { model: r, fields: i, auth: a, shouldCreateCollection: o, collections: s } = await
|
|
2508
|
-
|
|
2542
|
+
let { modelPath: t, fields: n } = tn(e.argv), { model: r, fields: i, auth: a, shouldCreateCollection: o, collections: s } = await G(e, t, n), c = Be(r), l = Ve(r), u = on(e), d = i.filter((e) => !(e.type === "relation" && e.isCurrentUser)), f = [
|
|
2543
|
+
Y(`src/lib/schemas/${r.name}.ts`, K(r, i, {
|
|
2509
2544
|
includeModelFields: !0,
|
|
2510
2545
|
forForm: !0
|
|
2511
2546
|
})),
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2547
|
+
Y(`${c.list}/+page.server.ts`, dn(r, d, u)),
|
|
2548
|
+
Y(`${c.list}/+page.svelte`, un(r, l, d)),
|
|
2549
|
+
Y(`${c.new}/+page.server.ts`, fn(r, l, d, u, e.features.auth)),
|
|
2550
|
+
Y(`${c.new}/+page.svelte`, cn(r, l, d)),
|
|
2551
|
+
Y(`${c.show}/+page.server.ts`, pn(r, l, d, u)),
|
|
2552
|
+
Y(`${c.show}/+page.svelte`, mn(r, l, d)),
|
|
2553
|
+
Y(`${c.edit}/+page.server.ts`, hn(r, l, d, u)),
|
|
2554
|
+
Y(`${c.edit}/+page.svelte`, ln(r, l, d)),
|
|
2555
|
+
Y(`${c.list}/server.test.ts`, ht(r, l, i, e, s))
|
|
2521
2556
|
], p = [
|
|
2522
|
-
...
|
|
2557
|
+
...E(d),
|
|
2523
2558
|
"button",
|
|
2524
2559
|
"table",
|
|
2525
2560
|
"data-table",
|
|
@@ -2550,12 +2585,12 @@ async function gn(e) {
|
|
|
2550
2585
|
var _n = "generate-scaffold", vn = "1.0.7", yn = "src/patterns/generate/scaffold", bn = "/generate/scaffold";
|
|
2551
2586
|
async function xn(e) {
|
|
2552
2587
|
let t = await gn(e);
|
|
2553
|
-
if (e.env !== "runtime") return
|
|
2554
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
2588
|
+
if (e.env !== "runtime") return b(t);
|
|
2589
|
+
let { createCollections: n } = await import("./chunks/collections-DdGJC7Ip.js"), r = await n(t.collections, e), i = {
|
|
2555
2590
|
...t,
|
|
2556
2591
|
creates: [...t.creates, ...r]
|
|
2557
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2558
|
-
return a(await
|
|
2592
|
+
}, { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2593
|
+
return a(await b(i), e);
|
|
2559
2594
|
}
|
|
2560
2595
|
var Sn = {
|
|
2561
2596
|
version: vn,
|
|
@@ -2589,6 +2624,20 @@ var Sn = {
|
|
|
2589
2624
|
"email:email"
|
|
2590
2625
|
]
|
|
2591
2626
|
},
|
|
2627
|
+
examples: [
|
|
2628
|
+
{
|
|
2629
|
+
command: "todos title:text! done:bool",
|
|
2630
|
+
description: "Todos with required title and boolean flag."
|
|
2631
|
+
},
|
|
2632
|
+
{
|
|
2633
|
+
command: "pets type:select(dog:Dog,cat:Cat) owner:user",
|
|
2634
|
+
description: "Enum field and a one-to-many relation to user."
|
|
2635
|
+
},
|
|
2636
|
+
{
|
|
2637
|
+
command: "users/pets name:text! author:current_user",
|
|
2638
|
+
description: "Nested resource with auth-bound author."
|
|
2639
|
+
}
|
|
2640
|
+
],
|
|
2592
2641
|
tests: 8,
|
|
2593
2642
|
baseline: "velastack",
|
|
2594
2643
|
generate: xn
|
|
@@ -2597,7 +2646,7 @@ var Sn = {
|
|
|
2597
2646
|
//#region src/patterns/generate/schema/generate.ts
|
|
2598
2647
|
function Cn(e) {
|
|
2599
2648
|
let [t, ...n] = e;
|
|
2600
|
-
if (!t) throw
|
|
2649
|
+
if (!t) throw new y("Invalid command arguments. Expected: <model> [fields...]");
|
|
2601
2650
|
return {
|
|
2602
2651
|
modelPath: t,
|
|
2603
2652
|
fields: n
|
|
@@ -2607,13 +2656,14 @@ function wn(e, n) {
|
|
|
2607
2656
|
return {
|
|
2608
2657
|
path: e,
|
|
2609
2658
|
language: t(e),
|
|
2610
|
-
content: n
|
|
2659
|
+
content: n,
|
|
2660
|
+
status: "success"
|
|
2611
2661
|
};
|
|
2612
2662
|
}
|
|
2613
2663
|
async function Tn(e) {
|
|
2614
|
-
let { modelPath: t, fields: n } = Cn(e.argv), { model: r, fields: i, shouldCreateCollection: a } = await
|
|
2664
|
+
let { modelPath: t, fields: n } = Cn(e.argv), { model: r, fields: i, shouldCreateCollection: a } = await G(e, t, n);
|
|
2615
2665
|
return {
|
|
2616
|
-
creates: [wn(`src/lib/schemas/${r.name}.ts`,
|
|
2666
|
+
creates: [wn(`src/lib/schemas/${r.name}.ts`, K(r, i, {
|
|
2617
2667
|
includeModelFields: !a,
|
|
2618
2668
|
forForm: !0
|
|
2619
2669
|
}))],
|
|
@@ -2629,9 +2679,9 @@ async function Tn(e) {
|
|
|
2629
2679
|
var En = "generate-schema", Dn = "1.0.7", On = "src/patterns/generate/schema", kn = "/generate/schema";
|
|
2630
2680
|
async function An(e) {
|
|
2631
2681
|
let t = await Tn(e);
|
|
2632
|
-
if (e.env !== "runtime") return
|
|
2633
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2634
|
-
return n(await
|
|
2682
|
+
if (e.env !== "runtime") return b(t);
|
|
2683
|
+
let { writeResult: n } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2684
|
+
return n(await b(t), e);
|
|
2635
2685
|
}
|
|
2636
2686
|
var jn = {
|
|
2637
2687
|
version: Dn,
|
|
@@ -2664,6 +2714,20 @@ var jn = {
|
|
|
2664
2714
|
"email:email"
|
|
2665
2715
|
]
|
|
2666
2716
|
},
|
|
2717
|
+
examples: [
|
|
2718
|
+
{
|
|
2719
|
+
command: "login email:email! password:text!",
|
|
2720
|
+
description: "Validation schema for a login form."
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
command: "settings theme:select(light:Light,dark:Dark) notifications:bool",
|
|
2724
|
+
description: "Schema with an enum and a boolean flag."
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
command: "address street:text! city:text! postal:text!",
|
|
2728
|
+
description: "Schema with all required text fields."
|
|
2729
|
+
}
|
|
2730
|
+
],
|
|
2667
2731
|
tests: 0,
|
|
2668
2732
|
baseline: "velastack",
|
|
2669
2733
|
generate: An
|
|
@@ -2716,7 +2780,8 @@ async function Pn(e) {
|
|
|
2716
2780
|
return {
|
|
2717
2781
|
path: i,
|
|
2718
2782
|
language: t(i),
|
|
2719
|
-
content: n
|
|
2783
|
+
content: n,
|
|
2784
|
+
status: "success"
|
|
2720
2785
|
};
|
|
2721
2786
|
}).sort((e, t) => e.path.localeCompare(t.path)), i = [
|
|
2722
2787
|
"sidebar",
|
|
@@ -2816,7 +2881,8 @@ async function Ln(e) {
|
|
|
2816
2881
|
return {
|
|
2817
2882
|
path: i,
|
|
2818
2883
|
language: t(i),
|
|
2819
|
-
content: n
|
|
2884
|
+
content: n,
|
|
2885
|
+
status: "success"
|
|
2820
2886
|
};
|
|
2821
2887
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
2822
2888
|
deletes: [],
|
|
@@ -2830,9 +2896,9 @@ async function Ln(e) {
|
|
|
2830
2896
|
var Rn = "enable-auth", zn = "1.0.7", Bn = "src/patterns/enable/auth", Vn = "/enable/auth";
|
|
2831
2897
|
async function Hn(e) {
|
|
2832
2898
|
let t = await Pn(e);
|
|
2833
|
-
if (e.env === "preview") return
|
|
2834
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
2835
|
-
return a(await
|
|
2899
|
+
if (e.env === "preview") return b(n([t, await Ln(e)]));
|
|
2900
|
+
let { generate: r } = await import("./chunks/generate.runtime-Bt6kbkWX.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2901
|
+
return a(await b(n([t, i])), e);
|
|
2836
2902
|
}
|
|
2837
2903
|
var Un = {
|
|
2838
2904
|
version: zn,
|
|
@@ -2864,6 +2930,7 @@ var Un = {
|
|
|
2864
2930
|
base: "vela enable auth",
|
|
2865
2931
|
argv: []
|
|
2866
2932
|
},
|
|
2933
|
+
examples: [],
|
|
2867
2934
|
tests: 18,
|
|
2868
2935
|
baseline: "velastack",
|
|
2869
2936
|
generate: Hn
|
|
@@ -2875,7 +2942,8 @@ async function Kn(e) {
|
|
|
2875
2942
|
return {
|
|
2876
2943
|
path: i,
|
|
2877
2944
|
language: t(i),
|
|
2878
|
-
content: n
|
|
2945
|
+
content: n,
|
|
2946
|
+
status: "success"
|
|
2879
2947
|
};
|
|
2880
2948
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
2881
2949
|
modifies: [],
|
|
@@ -2896,7 +2964,8 @@ async function Yn(e) {
|
|
|
2896
2964
|
return {
|
|
2897
2965
|
path: i,
|
|
2898
2966
|
language: t(i),
|
|
2899
|
-
content: n
|
|
2967
|
+
content: n,
|
|
2968
|
+
status: "success"
|
|
2900
2969
|
};
|
|
2901
2970
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
2902
2971
|
deletes: [],
|
|
@@ -2910,9 +2979,9 @@ async function Yn(e) {
|
|
|
2910
2979
|
var Xn = "enable-api", Zn = "1.0.7", Qn = "src/patterns/enable/api", $n = "/enable/api";
|
|
2911
2980
|
async function er(e) {
|
|
2912
2981
|
let t = await Kn(e);
|
|
2913
|
-
if (e.env === "preview") return
|
|
2914
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
2915
|
-
return a(await
|
|
2982
|
+
if (e.env === "preview") return b(n([t, await Yn(e)]));
|
|
2983
|
+
let { generate: r } = await import("./chunks/generate.runtime-BtGvtuWm.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
2984
|
+
return a(await b(n([t, i])), e);
|
|
2916
2985
|
}
|
|
2917
2986
|
var tr = {
|
|
2918
2987
|
version: Zn,
|
|
@@ -2944,6 +3013,7 @@ var tr = {
|
|
|
2944
3013
|
base: "vela enable api",
|
|
2945
3014
|
argv: []
|
|
2946
3015
|
},
|
|
3016
|
+
examples: [],
|
|
2947
3017
|
tests: 1,
|
|
2948
3018
|
baseline: "velastack",
|
|
2949
3019
|
generate: er
|
|
@@ -2965,7 +3035,8 @@ async function ir(e) {
|
|
|
2965
3035
|
return {
|
|
2966
3036
|
path: i,
|
|
2967
3037
|
language: t(i),
|
|
2968
|
-
content: n
|
|
3038
|
+
content: n,
|
|
3039
|
+
status: "success"
|
|
2969
3040
|
};
|
|
2970
3041
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
2971
3042
|
modifies: [],
|
|
@@ -2990,7 +3061,8 @@ async function sr(e) {
|
|
|
2990
3061
|
return {
|
|
2991
3062
|
path: i,
|
|
2992
3063
|
language: t(i),
|
|
2993
|
-
content: n
|
|
3064
|
+
content: n,
|
|
3065
|
+
status: "success"
|
|
2994
3066
|
};
|
|
2995
3067
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
2996
3068
|
deletes: [],
|
|
@@ -3004,9 +3076,9 @@ async function sr(e) {
|
|
|
3004
3076
|
var cr = "enable-api-keys", lr = "1.0.0", ur = "src/patterns/enable/api-keys", dr = "/enable/api-keys";
|
|
3005
3077
|
async function fr(e) {
|
|
3006
3078
|
let t = await ir(e);
|
|
3007
|
-
if (e.env === "preview") return
|
|
3008
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
3009
|
-
return a(await
|
|
3079
|
+
if (e.env === "preview") return b(n([t, await sr(e)]));
|
|
3080
|
+
let { generate: r } = await import("./chunks/generate.runtime-DiJDMdAq.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
3081
|
+
return a(await b(n([t, i])), e);
|
|
3010
3082
|
}
|
|
3011
3083
|
var pr = {
|
|
3012
3084
|
version: lr,
|
|
@@ -3038,6 +3110,7 @@ var pr = {
|
|
|
3038
3110
|
base: "vela enable api-keys",
|
|
3039
3111
|
argv: []
|
|
3040
3112
|
},
|
|
3113
|
+
examples: [],
|
|
3041
3114
|
tests: 6,
|
|
3042
3115
|
baseline: "velastack",
|
|
3043
3116
|
generate: fr
|
|
@@ -3053,7 +3126,8 @@ async function gr(e) {
|
|
|
3053
3126
|
return {
|
|
3054
3127
|
path: i,
|
|
3055
3128
|
language: t(i),
|
|
3056
|
-
content: n
|
|
3129
|
+
content: n,
|
|
3130
|
+
status: "success"
|
|
3057
3131
|
};
|
|
3058
3132
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
3059
3133
|
modifies: [],
|
|
@@ -3080,7 +3154,8 @@ async function yr(e) {
|
|
|
3080
3154
|
return {
|
|
3081
3155
|
path: i,
|
|
3082
3156
|
language: t(i),
|
|
3083
|
-
content: n
|
|
3157
|
+
content: n,
|
|
3158
|
+
status: "success"
|
|
3084
3159
|
};
|
|
3085
3160
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
3086
3161
|
deletes: [],
|
|
@@ -3094,9 +3169,9 @@ async function yr(e) {
|
|
|
3094
3169
|
var br = "enable-i18n", xr = "1.0.0", Sr = "src/patterns/enable/i18n", Cr = "/enable/i18n";
|
|
3095
3170
|
async function wr(e) {
|
|
3096
3171
|
let t = await gr(e);
|
|
3097
|
-
if (e.env === "preview") return
|
|
3098
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
3099
|
-
return a(await
|
|
3172
|
+
if (e.env === "preview") return b(n([t, await yr(e)]));
|
|
3173
|
+
let { generate: r } = await import("./chunks/generate.runtime-CcKMIm9M.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
3174
|
+
return a(await b(n([t, i])), e);
|
|
3100
3175
|
}
|
|
3101
3176
|
var Tr = {
|
|
3102
3177
|
version: xr,
|
|
@@ -3127,6 +3202,7 @@ var Tr = {
|
|
|
3127
3202
|
base: "vela enable i18n",
|
|
3128
3203
|
argv: []
|
|
3129
3204
|
},
|
|
3205
|
+
examples: [],
|
|
3130
3206
|
tests: 0,
|
|
3131
3207
|
baseline: "velastack",
|
|
3132
3208
|
generate: wr
|
|
@@ -3171,7 +3247,8 @@ async function Or(e) {
|
|
|
3171
3247
|
return {
|
|
3172
3248
|
path: i,
|
|
3173
3249
|
language: t(i),
|
|
3174
|
-
content: n
|
|
3250
|
+
content: n,
|
|
3251
|
+
status: "success"
|
|
3175
3252
|
};
|
|
3176
3253
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
3177
3254
|
modifies: [],
|
|
@@ -3195,8 +3272,8 @@ async function Or(e) {
|
|
|
3195
3272
|
}
|
|
3196
3273
|
//#endregion
|
|
3197
3274
|
//#region src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
3198
|
-
var kr = "<script lang=\"ts\">\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n // [!code highlight:3]\n import TeamSwitcher from '$lib/components/team-switcher.svelte';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import * as Avatar from '$lib/components/ui/avatar';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n team,\n teams = [],\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & {\n user: any;\n meta: any;\n team?: string | undefined;\n teams?: { id: string; name: string }[];\n } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", Ar = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import UsersIcon from '@lucide/svelte/icons/users';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Teams',\n url: '/teams',\n icon: UsersIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", jr = "export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n // [!code highlight:3]\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, team, teams, breadcrumbs };\n};\n", Mr = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <!-- [!code highlight:1] -->\n <AppSidebar user={data.user} meta={data.meta} team={data.team} teams={data.teams ?? []} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Nr = "users",
|
|
3199
|
-
function
|
|
3275
|
+
var kr = "<script lang=\"ts\">\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n // [!code highlight:3]\n import TeamSwitcher from '$lib/components/team-switcher.svelte';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import * as Avatar from '$lib/components/ui/avatar';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n team,\n teams = [],\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & {\n user: any;\n meta: any;\n team?: string | undefined;\n teams?: { id: string; name: string }[];\n } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", Ar = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import UsersIcon from '@lucide/svelte/icons/users';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Teams',\n url: '/teams',\n icon: UsersIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name}</span>\n <span class=\"truncate text-xs\">{user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", jr = "export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n // [!code highlight:3]\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, team, teams, breadcrumbs };\n};\n", Mr = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <!-- [!code highlight:1] -->\n <AppSidebar user={data.user} meta={data.meta} team={data.team} teams={data.teams ?? []} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Nr = "users", Q = "teams", Pr = "team_memberships";
|
|
3276
|
+
function $(e) {
|
|
3200
3277
|
let t = o.find((t) => t.collectionName === e);
|
|
3201
3278
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
3202
3279
|
return {
|
|
@@ -3211,7 +3288,7 @@ var Fr = [
|
|
|
3211
3288
|
{
|
|
3212
3289
|
name: "teams",
|
|
3213
3290
|
type: "base",
|
|
3214
|
-
|
|
3291
|
+
...$("teams"),
|
|
3215
3292
|
fields: [
|
|
3216
3293
|
{
|
|
3217
3294
|
name: "id",
|
|
@@ -3254,7 +3331,7 @@ var Fr = [
|
|
|
3254
3331
|
{
|
|
3255
3332
|
name: "team_memberships",
|
|
3256
3333
|
type: "base",
|
|
3257
|
-
|
|
3334
|
+
...$("team_memberships"),
|
|
3258
3335
|
fields: [
|
|
3259
3336
|
{
|
|
3260
3337
|
name: "id",
|
|
@@ -3269,7 +3346,7 @@ var Fr = [
|
|
|
3269
3346
|
{
|
|
3270
3347
|
name: "team",
|
|
3271
3348
|
cascadeDelete: !0,
|
|
3272
|
-
collectionId:
|
|
3349
|
+
collectionId: Q,
|
|
3273
3350
|
maxSelect: 1,
|
|
3274
3351
|
minSelect: 0,
|
|
3275
3352
|
required: !0,
|
|
@@ -3312,7 +3389,7 @@ var Fr = [
|
|
|
3312
3389
|
{
|
|
3313
3390
|
name: "team_users",
|
|
3314
3391
|
type: "view",
|
|
3315
|
-
|
|
3392
|
+
...$("team_users"),
|
|
3316
3393
|
viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;",
|
|
3317
3394
|
fields: [
|
|
3318
3395
|
{
|
|
@@ -3347,7 +3424,7 @@ var Fr = [
|
|
|
3347
3424
|
{
|
|
3348
3425
|
name: "team",
|
|
3349
3426
|
cascadeDelete: !0,
|
|
3350
|
-
collectionId:
|
|
3427
|
+
collectionId: Q,
|
|
3351
3428
|
maxSelect: 1,
|
|
3352
3429
|
minSelect: 0,
|
|
3353
3430
|
required: !0,
|
|
@@ -3369,7 +3446,7 @@ var Fr = [
|
|
|
3369
3446
|
{
|
|
3370
3447
|
name: "team_invites",
|
|
3371
3448
|
type: "base",
|
|
3372
|
-
|
|
3449
|
+
...$("team_invites"),
|
|
3373
3450
|
fields: [
|
|
3374
3451
|
{
|
|
3375
3452
|
name: "id",
|
|
@@ -3385,7 +3462,7 @@ var Fr = [
|
|
|
3385
3462
|
name: "team",
|
|
3386
3463
|
type: "relation",
|
|
3387
3464
|
cascadeDelete: !0,
|
|
3388
|
-
collectionId:
|
|
3465
|
+
collectionId: Q,
|
|
3389
3466
|
maxSelect: 1,
|
|
3390
3467
|
minSelect: 0,
|
|
3391
3468
|
required: !0
|
|
@@ -3412,7 +3489,7 @@ var Fr = [
|
|
|
3412
3489
|
{
|
|
3413
3490
|
name: "team_invite_links",
|
|
3414
3491
|
type: "base",
|
|
3415
|
-
|
|
3492
|
+
...$("team_invite_links"),
|
|
3416
3493
|
indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"],
|
|
3417
3494
|
fields: [
|
|
3418
3495
|
{
|
|
@@ -3428,7 +3505,7 @@ var Fr = [
|
|
|
3428
3505
|
{
|
|
3429
3506
|
name: "team",
|
|
3430
3507
|
cascadeDelete: !0,
|
|
3431
|
-
collectionId:
|
|
3508
|
+
collectionId: Q,
|
|
3432
3509
|
maxSelect: 1,
|
|
3433
3510
|
minSelect: 0,
|
|
3434
3511
|
required: !0,
|
|
@@ -3462,7 +3539,8 @@ async function Rr(e) {
|
|
|
3462
3539
|
return {
|
|
3463
3540
|
path: i,
|
|
3464
3541
|
language: t(i),
|
|
3465
|
-
content: n
|
|
3542
|
+
content: n,
|
|
3543
|
+
status: "success"
|
|
3466
3544
|
};
|
|
3467
3545
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
3468
3546
|
deletes: [],
|
|
@@ -3476,9 +3554,9 @@ async function Rr(e) {
|
|
|
3476
3554
|
var zr = "enable-teams", Br = "1.0.0", Vr = "src/patterns/enable/teams", Hr = "/enable/teams";
|
|
3477
3555
|
async function Ur(e) {
|
|
3478
3556
|
let t = await Or(e);
|
|
3479
|
-
if (e.env === "preview") return
|
|
3480
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
3481
|
-
return a(await
|
|
3557
|
+
if (e.env === "preview") return b(n([t, await Rr(e)]));
|
|
3558
|
+
let { generate: r } = await import("./chunks/generate.runtime-B0EfMNMf.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-DhQIE6kA.js");
|
|
3559
|
+
return a(await b(n([t, i])), e);
|
|
3482
3560
|
}
|
|
3483
3561
|
var Wr = {
|
|
3484
3562
|
version: Br,
|
|
@@ -3510,10 +3588,11 @@ var Wr = {
|
|
|
3510
3588
|
base: "vela enable teams",
|
|
3511
3589
|
argv: []
|
|
3512
3590
|
},
|
|
3591
|
+
examples: [],
|
|
3513
3592
|
tests: 36,
|
|
3514
3593
|
baseline: "velastack",
|
|
3515
3594
|
generate: Ur
|
|
3516
|
-
}, Gr = ee.version,
|
|
3595
|
+
}, Gr = ee.version, Kr = [
|
|
3517
3596
|
Vt,
|
|
3518
3597
|
jn,
|
|
3519
3598
|
Xt,
|
|
@@ -3523,11 +3602,11 @@ var Wr = {
|
|
|
3523
3602
|
pr,
|
|
3524
3603
|
Tr,
|
|
3525
3604
|
Wr
|
|
3526
|
-
],
|
|
3605
|
+
], qr = Object.fromEntries(Kr.map((e) => [e.slug, e])), Jr = Kr.reduce((e, t) => {
|
|
3527
3606
|
let n = t.category;
|
|
3528
3607
|
return e[n] ??= [], e[n].push(t), e;
|
|
3529
3608
|
}, {});
|
|
3530
3609
|
//#endregion
|
|
3531
|
-
export {
|
|
3610
|
+
export { y as InvalidArgumentError, Jr as byCategory, qr as bySlug, Kr as patterns, Gr as version };
|
|
3532
3611
|
|
|
3533
3612
|
//# sourceMappingURL=index.js.map
|