@velastack/patterns 0.0.8 → 0.0.11
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-BIx6tDrV.js → collections-CVHa6B6X.js} +3 -3
- package/dist/chunks/{collections-BIx6tDrV.js.map → collections-CVHa6B6X.js.map} +1 -1
- package/dist/chunks/{env.runtime-sHetoQ7B.js → env.runtime-DSiCFHzi.js} +2 -2
- package/dist/chunks/{env.runtime-sHetoQ7B.js.map → env.runtime-DSiCFHzi.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B5wEl4BS.js → generate.runtime-Q3r4DJ7e.js} +5 -5
- package/dist/chunks/generate.runtime-Q3r4DJ7e.js.map +1 -0
- package/dist/chunks/{index-BP2ybpuw.js → index-Dv0XurQu.js} +687 -1090
- package/dist/chunks/index-Dv0XurQu.js.map +1 -0
- package/dist/chunks/{pocketbase-BFCpPJlW.js → pocketbase-CpbH-4-D.js} +2 -2
- package/dist/chunks/{pocketbase-BFCpPJlW.js.map → pocketbase-CpbH-4-D.js.map} +1 -1
- package/dist/chunks/{write-result-DG5OAbe1.js → write-result-CbUTMeAc.js} +370 -180
- package/dist/chunks/write-result-CbUTMeAc.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate.runtime-B5wEl4BS.js.map +0 -1
- package/dist/chunks/index-BP2ybpuw.js.map +0 -1
- package/dist/chunks/write-result-DG5OAbe1.js.map +0 -1
|
@@ -71,9 +71,9 @@ function oe(t, e) {
|
|
|
71
71
|
}
|
|
72
72
|
return (e === "string" ? String : Number)(t);
|
|
73
73
|
}
|
|
74
|
-
const
|
|
75
|
-
function
|
|
76
|
-
return e.withOptions = (n) =>
|
|
74
|
+
const d = zt({});
|
|
75
|
+
function zt(t) {
|
|
76
|
+
return e.withOptions = (n) => zt(ut(ut({}, t), n)), e;
|
|
77
77
|
function e(n, ...r) {
|
|
78
78
|
const o = typeof n == "string" ? [n] : n.raw, {
|
|
79
79
|
alignValues: s = !1,
|
|
@@ -82,34 +82,34 @@ function Rt(t) {
|
|
|
82
82
|
} = t;
|
|
83
83
|
let c = "";
|
|
84
84
|
for (let f = 0; f < o.length; f++) {
|
|
85
|
-
let
|
|
86
|
-
if (i && (
|
|
87
|
-
const
|
|
88
|
-
c +=
|
|
85
|
+
let h = o[f];
|
|
86
|
+
if (i && (h = h.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{")), c += h, f < r.length) {
|
|
87
|
+
const $ = s ? se(r[f], c) : r[f];
|
|
88
|
+
c += $;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
const m = c.split(`
|
|
92
92
|
`);
|
|
93
|
-
let
|
|
93
|
+
let g = null;
|
|
94
94
|
for (const f of m) {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
|
|
95
|
+
const h = f.match(/^(\s+)\S+/);
|
|
96
|
+
if (h) {
|
|
97
|
+
const $ = h[1].length;
|
|
98
|
+
g ? g = Math.min(g, $) : g = $;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
const f =
|
|
103
|
-
c = m.map((
|
|
101
|
+
if (g !== null) {
|
|
102
|
+
const f = g;
|
|
103
|
+
c = m.map((h) => h[0] === " " || h[0] === " " ? h.slice(f) : h).join(`
|
|
104
104
|
`);
|
|
105
105
|
}
|
|
106
106
|
return a && (c = c.trim()), i && (c = c.replace(/\\n/g, `
|
|
107
|
-
`).replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (f,
|
|
107
|
+
`).replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (f, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (f, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (f, h) => String.fromCharCode(parseInt(h, 16)))), typeof Bun < "u" && (c = c.replace(
|
|
108
108
|
// Matches e.g. \\u{1f60a} or \\u5F1F
|
|
109
109
|
/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,
|
|
110
|
-
(f,
|
|
110
|
+
(f, h, $) => {
|
|
111
111
|
var u;
|
|
112
|
-
const l = (u =
|
|
112
|
+
const l = (u = h ?? $) !== null && u !== void 0 ? u : "";
|
|
113
113
|
return String.fromCodePoint(parseInt(l, 16));
|
|
114
114
|
}
|
|
115
115
|
)), c;
|
|
@@ -128,13 +128,13 @@ ${o}`);
|
|
|
128
128
|
}
|
|
129
129
|
return t;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function Mt(t, e) {
|
|
132
132
|
return t.startsWith(e) ? t.slice(e.length) : t.replace(/^\.\//, "");
|
|
133
133
|
}
|
|
134
134
|
function j(t) {
|
|
135
135
|
return t.endsWith(".svelte") ? "svelte" : t.endsWith(".tsx") || t.endsWith(".ts") ? "ts" : t.endsWith(".jsx") || t.endsWith(".js") ? "js" : "text";
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function dt(t) {
|
|
138
138
|
return t.reduce(
|
|
139
139
|
(e, n) => (e.creates.push(...n.creates), e.modifies.push(...n.modifies), e.deletes.push(...n.deletes), e.components.push(...n.components), e.packages.push(...n.packages), e.collections.push(...n.collections), e),
|
|
140
140
|
{
|
|
@@ -176,28 +176,28 @@ const ie = {
|
|
|
176
176
|
geopoint: ['import { GeopointInput } from "$lib/components/ui/geopoint";'],
|
|
177
177
|
button: ['import { Button } from "$lib/components/ui/button";']
|
|
178
178
|
};
|
|
179
|
-
function
|
|
179
|
+
function P(t) {
|
|
180
180
|
return `$formData.${t.name}`;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function L(t) {
|
|
183
183
|
return t.inputProps ? Object.entries(t.inputProps).flatMap(([e, n]) => n == null || n === !1 ? [] : n === !0 ? [` ${e}`] : [` ${e}=${JSON.stringify(String(n))}`]).join("") : "";
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
return t.labelAside ?
|
|
185
|
+
function z(t) {
|
|
186
|
+
return t.labelAside ? d`
|
|
187
187
|
<div class="flex justify-between">
|
|
188
188
|
<Form.Label>${t.title}</Form.Label>
|
|
189
189
|
${t.labelAside}
|
|
190
190
|
</div>
|
|
191
191
|
` : `<Form.Label>${t.title}</Form.Label>`;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function B(t, e) {
|
|
194
194
|
const n = t.required ? " required" : "";
|
|
195
|
-
return
|
|
195
|
+
return d`
|
|
196
196
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
197
197
|
<Form.Control>
|
|
198
198
|
{#snippet children({ props })}
|
|
199
|
-
${
|
|
200
|
-
<Input {...props} type="${e}" bind:value={${
|
|
199
|
+
${z(t)}
|
|
200
|
+
<Input {...props} type="${e}" bind:value={${P(t)}}${n}${L(t)} />
|
|
201
201
|
{/snippet}
|
|
202
202
|
</Form.Control>
|
|
203
203
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -206,12 +206,12 @@ function T(t, e) {
|
|
|
206
206
|
}
|
|
207
207
|
function ce(t) {
|
|
208
208
|
const e = t.required ? " required" : "";
|
|
209
|
-
return
|
|
209
|
+
return d`
|
|
210
210
|
<Form.Field {form} name="${t.name}" class="col-span-2">
|
|
211
211
|
<Form.Control>
|
|
212
212
|
{#snippet children({ props })}
|
|
213
|
-
${
|
|
214
|
-
<Textarea {...props} bind:value={${
|
|
213
|
+
${z(t)}
|
|
214
|
+
<Textarea {...props} bind:value={${P(t)}}${e}${L(t)} />
|
|
215
215
|
{/snippet}
|
|
216
216
|
</Form.Control>
|
|
217
217
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -220,12 +220,12 @@ function ce(t) {
|
|
|
220
220
|
}
|
|
221
221
|
function me(t) {
|
|
222
222
|
const e = t.required ? " required" : "";
|
|
223
|
-
return
|
|
223
|
+
return d`
|
|
224
224
|
<Form.Field {form} name="${t.name}" class="col-span-1 flex items-start space-x-2">
|
|
225
225
|
<Form.Control>
|
|
226
226
|
{#snippet children({ props })}
|
|
227
|
-
<Checkbox {...props} bind:checked={${
|
|
228
|
-
${
|
|
227
|
+
<Checkbox {...props} bind:checked={${P(t)}}${e}${L(t)} />
|
|
228
|
+
${z(t)}
|
|
229
229
|
{/snippet}
|
|
230
230
|
</Form.Control>
|
|
231
231
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -233,25 +233,25 @@ function me(t) {
|
|
|
233
233
|
`;
|
|
234
234
|
}
|
|
235
235
|
function ue(t) {
|
|
236
|
-
return
|
|
236
|
+
return d`
|
|
237
237
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
238
238
|
<Form.Control>
|
|
239
239
|
{#snippet children({ props })}
|
|
240
|
-
${
|
|
241
|
-
<GeopointInput {...props} bind:value={${
|
|
240
|
+
${z(t)}
|
|
241
|
+
<GeopointInput {...props} bind:value={${P(t)}} />
|
|
242
242
|
{/snippet}
|
|
243
243
|
</Form.Control>
|
|
244
244
|
<Form.FieldErrors class="contents text-destructive" />
|
|
245
245
|
</Form.Field>
|
|
246
246
|
`;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function de(t) {
|
|
249
249
|
const e = t.required ? " required" : "", n = t.maxSelect > 1 ? "Multiple" : "Single";
|
|
250
|
-
return
|
|
250
|
+
return d`
|
|
251
251
|
<FileForm.Field {form} name="${t.name}" class="col-span-1">
|
|
252
252
|
<Form.Control>
|
|
253
253
|
{#snippet children({ props })}
|
|
254
|
-
${
|
|
254
|
+
${z(t)}
|
|
255
255
|
<FileForm.${n}>
|
|
256
256
|
{#snippet display({ file, filename, onremove })}
|
|
257
257
|
<div class="flex gap-2 justify-between items-center">
|
|
@@ -263,7 +263,7 @@ function pe(t) {
|
|
|
263
263
|
</div>
|
|
264
264
|
{/snippet}
|
|
265
265
|
{#snippet input()}
|
|
266
|
-
<FileForm.Input {...props}${e}${
|
|
266
|
+
<FileForm.Input {...props}${e}${L(t)} />
|
|
267
267
|
{/snippet}
|
|
268
268
|
</FileForm.${n}>
|
|
269
269
|
{/snippet}
|
|
@@ -272,18 +272,18 @@ function pe(t) {
|
|
|
272
272
|
</FileForm.Field>
|
|
273
273
|
`;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function pe(t) {
|
|
276
276
|
const e = t.maxSelect > 1 ? "multiple" : "single", n = t.required ? " required" : "", r = t.maxSelect > 1 ? "Select options" : "Select an option", o = t.options.map(
|
|
277
277
|
(s) => `<MultiSelect.Item value=${JSON.stringify(s.value)} label={${t.name}Labels[${JSON.stringify(s.value)}].label} />`
|
|
278
278
|
).join(`
|
|
279
279
|
`);
|
|
280
|
-
return
|
|
280
|
+
return d`
|
|
281
281
|
<MultiSelect.Field {form} type="${e}" name="${t.name}"${n} class="col-span-1">
|
|
282
282
|
<Form.Control>
|
|
283
283
|
{#snippet children({ props })}
|
|
284
|
-
${
|
|
284
|
+
${z(t)}
|
|
285
285
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
286
|
-
<MultiSelect.Input bind:value={${
|
|
286
|
+
<MultiSelect.Input bind:value={${P(t)}} placeholder="${r}" {...props}>
|
|
287
287
|
{#snippet children({ selected })}
|
|
288
288
|
<div class="flex flex-wrap gap-1">
|
|
289
289
|
{#each selected as value}
|
|
@@ -312,13 +312,13 @@ function de(t) {
|
|
|
312
312
|
}
|
|
313
313
|
function fe(t) {
|
|
314
314
|
const e = t.maxSelect > 1 ? "multiple" : "single", n = t.maxSelect > 1 ? `Select ${t.relatedModel.pluralDisplayName.toLowerCase()}` : `Select ${t.relatedModel.displayName.toLowerCase()}`, r = `Search ${t.relatedModel.pluralDisplayName.toLowerCase()}...`, o = `No ${t.relatedModel.pluralDisplayName.toLowerCase()} found`, s = t.relatedModel.name, i = t.relatedModel.pluralName;
|
|
315
|
-
return
|
|
315
|
+
return d`
|
|
316
316
|
<MultiSelect.Field {form} type="${e}" name="${t.name}" class="col-span-1">
|
|
317
317
|
<Form.Control>
|
|
318
318
|
{#snippet children({ props })}
|
|
319
319
|
<Form.Label>${t.title}</Form.Label>
|
|
320
320
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
321
|
-
<MultiSelect.Input bind:value={${
|
|
321
|
+
<MultiSelect.Input bind:value={${P(t)}} placeholder="${n}" {...props}>
|
|
322
322
|
{#snippet children({ selected })}
|
|
323
323
|
<div class="flex flex-wrap gap-1">
|
|
324
324
|
{#each selected as value}
|
|
@@ -348,13 +348,13 @@ function fe(t) {
|
|
|
348
348
|
</MultiSelect.Field>
|
|
349
349
|
`;
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
return
|
|
351
|
+
function ge(t) {
|
|
352
|
+
return d`
|
|
353
353
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
354
354
|
<Form.Control>
|
|
355
355
|
{#snippet children({ props })}
|
|
356
|
-
${
|
|
357
|
-
<Input {...props} type="text" value={${
|
|
356
|
+
${z(t)}
|
|
357
|
+
<Input {...props} type="text" value={${P(t)}}${L(t)} readonly />
|
|
358
358
|
{/snippet}
|
|
359
359
|
</Form.Control>
|
|
360
360
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -364,19 +364,19 @@ function he(t) {
|
|
|
364
364
|
function et(t) {
|
|
365
365
|
switch (t.type) {
|
|
366
366
|
case "text":
|
|
367
|
-
return
|
|
367
|
+
return B(t, "text");
|
|
368
368
|
case "number":
|
|
369
|
-
return
|
|
369
|
+
return B(t, "number");
|
|
370
370
|
case "date":
|
|
371
|
-
return
|
|
371
|
+
return B(t, "date");
|
|
372
372
|
case "email":
|
|
373
|
-
return
|
|
373
|
+
return B(t, "email");
|
|
374
374
|
case "password":
|
|
375
|
-
return
|
|
375
|
+
return B(t, "password");
|
|
376
376
|
case "url":
|
|
377
|
-
return
|
|
377
|
+
return B(t, "url");
|
|
378
378
|
case "autodate":
|
|
379
|
-
return
|
|
379
|
+
return ge(t);
|
|
380
380
|
case "editor":
|
|
381
381
|
case "json":
|
|
382
382
|
return ce(t);
|
|
@@ -385,9 +385,9 @@ function et(t) {
|
|
|
385
385
|
case "geoPoint":
|
|
386
386
|
return ue(t);
|
|
387
387
|
case "file":
|
|
388
|
-
return pe(t);
|
|
389
|
-
case "select":
|
|
390
388
|
return de(t);
|
|
389
|
+
case "select":
|
|
390
|
+
return pe(t);
|
|
391
391
|
case "relation":
|
|
392
392
|
return fe(t);
|
|
393
393
|
default:
|
|
@@ -396,7 +396,7 @@ function et(t) {
|
|
|
396
396
|
}
|
|
397
397
|
function It(t) {
|
|
398
398
|
const e = t.options.map(
|
|
399
|
-
(n) =>
|
|
399
|
+
(n) => d`
|
|
400
400
|
${JSON.stringify(n.value)}: {
|
|
401
401
|
label: ${JSON.stringify(n.label)},
|
|
402
402
|
value: ${JSON.stringify(n.value)}
|
|
@@ -404,37 +404,37 @@ function It(t) {
|
|
|
404
404
|
`
|
|
405
405
|
).join(`,
|
|
406
406
|
`);
|
|
407
|
-
return
|
|
407
|
+
return d`
|
|
408
408
|
const ${t.name}Labels = {
|
|
409
409
|
${e}
|
|
410
410
|
} as const;
|
|
411
411
|
`;
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function O(t) {
|
|
414
414
|
const e = t.flatMap((n) => ie[n.type]);
|
|
415
415
|
return [...new Set(e)];
|
|
416
416
|
}
|
|
417
417
|
function nt(t) {
|
|
418
418
|
return [...new Set(t.flatMap((e) => le[e]))];
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function R(t, e) {
|
|
421
421
|
return `data.${t.name}.${e.name}`;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
return
|
|
423
|
+
function Y(t, e, n) {
|
|
424
|
+
return d`
|
|
425
425
|
<div class="space-y-2">
|
|
426
426
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
427
427
|
<p class="text-muted-foreground">${n}</p>
|
|
428
428
|
</div>
|
|
429
429
|
`;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
const n =
|
|
431
|
+
function he(t, e) {
|
|
432
|
+
const n = R(t, e), r = `<p class="text-muted-foreground">{new Date(${n}).toLocaleDateString()}</p>`, o = e.required ? r : d`
|
|
433
433
|
{#if ${n}}
|
|
434
434
|
${r}
|
|
435
435
|
{/if}
|
|
436
436
|
`;
|
|
437
|
-
return
|
|
437
|
+
return d`
|
|
438
438
|
<div class="space-y-2">
|
|
439
439
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
440
440
|
${o}
|
|
@@ -442,16 +442,16 @@ function ge(t, e) {
|
|
|
442
442
|
`;
|
|
443
443
|
}
|
|
444
444
|
function be(t, e) {
|
|
445
|
-
const n =
|
|
445
|
+
const n = R(t, e), r = d`
|
|
446
446
|
<a href={${n}} target="_blank" rel="noopener noreferrer">
|
|
447
447
|
{${n}}
|
|
448
448
|
</a>
|
|
449
|
-
`, o = e.required ? r :
|
|
449
|
+
`, o = e.required ? r : d`
|
|
450
450
|
{#if ${n}}
|
|
451
451
|
${r}
|
|
452
452
|
{/if}
|
|
453
453
|
`;
|
|
454
|
-
return
|
|
454
|
+
return d`
|
|
455
455
|
<div class="space-y-2">
|
|
456
456
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
457
457
|
<p class="text-muted-foreground">
|
|
@@ -461,9 +461,9 @@ function be(t, e) {
|
|
|
461
461
|
`;
|
|
462
462
|
}
|
|
463
463
|
function ve(t, e) {
|
|
464
|
-
const n =
|
|
464
|
+
const n = R(t, e);
|
|
465
465
|
if (e.maxSelect > 1)
|
|
466
|
-
return
|
|
466
|
+
return d`
|
|
467
467
|
<div class="space-y-2">
|
|
468
468
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
469
469
|
{#each ${n} as ${e.name}}
|
|
@@ -471,12 +471,12 @@ function ve(t, e) {
|
|
|
471
471
|
{/each}
|
|
472
472
|
</div>
|
|
473
473
|
`;
|
|
474
|
-
const r = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, o = e.required ? r :
|
|
474
|
+
const r = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, o = e.required ? r : d`
|
|
475
475
|
{#if ${n}}
|
|
476
476
|
${r}
|
|
477
477
|
{/if}
|
|
478
478
|
`;
|
|
479
|
-
return
|
|
479
|
+
return d`
|
|
480
480
|
<div class="space-y-2">
|
|
481
481
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
482
482
|
${o}
|
|
@@ -484,8 +484,8 @@ function ve(t, e) {
|
|
|
484
484
|
`;
|
|
485
485
|
}
|
|
486
486
|
function we(t, e) {
|
|
487
|
-
const n =
|
|
488
|
-
return e.maxSelect > 1 ?
|
|
487
|
+
const n = R(t, e);
|
|
488
|
+
return e.maxSelect > 1 ? d`
|
|
489
489
|
<div class="space-y-2">
|
|
490
490
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
491
491
|
{#if ${n}}
|
|
@@ -507,7 +507,7 @@ function we(t, e) {
|
|
|
507
507
|
{/each}
|
|
508
508
|
{/if}
|
|
509
509
|
</div>
|
|
510
|
-
` :
|
|
510
|
+
` : d`
|
|
511
511
|
<div class="space-y-2">
|
|
512
512
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
513
513
|
{#if ${n}}
|
|
@@ -532,9 +532,9 @@ function we(t, e) {
|
|
|
532
532
|
function ye(t) {
|
|
533
533
|
return `/${t.relatedModel.routeSegment}`;
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function $e(t, e) {
|
|
536
536
|
const n = `data.${t.name}.expand?.${e.name}`, r = ye(e);
|
|
537
|
-
return e.maxSelect > 1 ?
|
|
537
|
+
return e.maxSelect > 1 ? d`
|
|
538
538
|
<div class="space-y-2">
|
|
539
539
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
540
540
|
{#each ${n} ?? [] as ${e.singularRelationName}}
|
|
@@ -546,7 +546,7 @@ function xe(t, e) {
|
|
|
546
546
|
</a>
|
|
547
547
|
{/each}
|
|
548
548
|
</div>
|
|
549
|
-
` :
|
|
549
|
+
` : d`
|
|
550
550
|
<div class="space-y-2">
|
|
551
551
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
552
552
|
{#if ${n}}
|
|
@@ -560,8 +560,8 @@ function xe(t, e) {
|
|
|
560
560
|
</div>
|
|
561
561
|
`;
|
|
562
562
|
}
|
|
563
|
-
function
|
|
564
|
-
const n =
|
|
563
|
+
function xe(t, e) {
|
|
564
|
+
const n = R(t, e), r = d`
|
|
565
565
|
{#await import("$lib/components/ui/leaflet/leaflet.svelte")}
|
|
566
566
|
<div class="h-56.25 w-full bg-input rounded-md"></div>
|
|
567
567
|
{:then { default: Leaflet }}
|
|
@@ -570,27 +570,27 @@ function $e(t, e) {
|
|
|
570
570
|
<p class="text-muted-foreground">
|
|
571
571
|
{${n}?.lat.toFixed(6)}, {${n}?.lon.toFixed(6)}
|
|
572
572
|
</p>
|
|
573
|
-
`, o = e.required ? r :
|
|
573
|
+
`, o = e.required ? r : d`
|
|
574
574
|
{#if ${n}}
|
|
575
575
|
${r}
|
|
576
576
|
{/if}
|
|
577
577
|
`;
|
|
578
|
-
return
|
|
578
|
+
return d`
|
|
579
579
|
<div class="space-y-2">
|
|
580
580
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
581
581
|
${o}
|
|
582
582
|
</div>
|
|
583
583
|
`;
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function Fe(t, e) {
|
|
586
586
|
switch (e.type) {
|
|
587
587
|
case "text":
|
|
588
588
|
case "number":
|
|
589
589
|
case "email":
|
|
590
590
|
case "editor":
|
|
591
|
-
return
|
|
591
|
+
return Y(t, e, `{${R(t, e)}}`);
|
|
592
592
|
case "password":
|
|
593
|
-
return
|
|
593
|
+
return d`
|
|
594
594
|
<div class="space-y-2">
|
|
595
595
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
596
596
|
<p class="text-muted-foreground">
|
|
@@ -599,14 +599,14 @@ function Ce(t, e) {
|
|
|
599
599
|
</div>
|
|
600
600
|
`;
|
|
601
601
|
case "bool":
|
|
602
|
-
return
|
|
602
|
+
return Y(
|
|
603
603
|
t,
|
|
604
604
|
e,
|
|
605
|
-
`{${
|
|
605
|
+
`{${R(t, e)} ? "Yes" : "No"}`
|
|
606
606
|
);
|
|
607
607
|
case "date":
|
|
608
608
|
case "autodate":
|
|
609
|
-
return
|
|
609
|
+
return he(t, e);
|
|
610
610
|
case "url":
|
|
611
611
|
return be(t, e);
|
|
612
612
|
case "select":
|
|
@@ -614,19 +614,19 @@ function Ce(t, e) {
|
|
|
614
614
|
case "file":
|
|
615
615
|
return we(t, e);
|
|
616
616
|
case "json":
|
|
617
|
-
return
|
|
617
|
+
return Y(t, e, `{JSON.stringify(${R(t, e)})}`);
|
|
618
618
|
case "geoPoint":
|
|
619
|
-
return $e(t, e);
|
|
620
|
-
case "relation":
|
|
621
619
|
return xe(t, e);
|
|
620
|
+
case "relation":
|
|
621
|
+
return $e(t, e);
|
|
622
622
|
default:
|
|
623
623
|
return e;
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
const
|
|
627
|
-
function
|
|
626
|
+
const Se = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), Ce = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), _e = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), ke = /[^\p{L}\d]+/giu, pt = "$1\0$2", ft = "";
|
|
627
|
+
function Et(t) {
|
|
628
628
|
let e = t.trim();
|
|
629
|
-
e = e.replace(
|
|
629
|
+
e = e.replace(Se, pt).replace(Ce, pt), e = e.replace(ke, "\0");
|
|
630
630
|
let n = 0, r = e.length;
|
|
631
631
|
for (; e.charAt(n) === "\0"; )
|
|
632
632
|
n++;
|
|
@@ -636,8 +636,8 @@ function zt(t) {
|
|
|
636
636
|
r--;
|
|
637
637
|
return e.slice(n, r).split(/\0/g);
|
|
638
638
|
}
|
|
639
|
-
function
|
|
640
|
-
const e =
|
|
639
|
+
function Re(t) {
|
|
640
|
+
const e = Et(t);
|
|
641
641
|
for (let n = 0; n < e.length; n++) {
|
|
642
642
|
const r = e[n], o = _e.exec(r);
|
|
643
643
|
if (o) {
|
|
@@ -647,15 +647,15 @@ function Pe(t) {
|
|
|
647
647
|
}
|
|
648
648
|
return e;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function Bt(t, e) {
|
|
651
651
|
const [n, r, o] = G(t, e);
|
|
652
652
|
return n + r.map(H(e == null ? void 0 : e.locale)).join((e == null ? void 0 : e.delimiter) ?? " ") + o;
|
|
653
653
|
}
|
|
654
|
-
function
|
|
654
|
+
function A(t, e) {
|
|
655
655
|
const [n, r, o] = G(t, e), s = H(e == null ? void 0 : e.locale), i = at(e == null ? void 0 : e.locale), a = Dt(s, i);
|
|
656
656
|
return n + r.map((c, m) => m === 0 ? s(c) : a(c, m)).join("") + o;
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function Pe(t, e) {
|
|
659
659
|
const [n, r, o] = G(t, e), s = H(e == null ? void 0 : e.locale), i = at(e == null ? void 0 : e.locale), a = Dt(s, i);
|
|
660
660
|
return n + r.map(a).join("") + o;
|
|
661
661
|
}
|
|
@@ -663,11 +663,11 @@ function rt(t, e) {
|
|
|
663
663
|
const [n, r, o] = G(t, e), s = H(e == null ? void 0 : e.locale), i = at(e == null ? void 0 : e.locale);
|
|
664
664
|
return n + r.map(Ie(s, i)).join(" ") + o;
|
|
665
665
|
}
|
|
666
|
-
function
|
|
667
|
-
return
|
|
666
|
+
function ze(t, e) {
|
|
667
|
+
return Bt(t, { delimiter: "-", ...e });
|
|
668
668
|
}
|
|
669
|
-
function
|
|
670
|
-
return
|
|
669
|
+
function Me(t, e) {
|
|
670
|
+
return Bt(t, { delimiter: "_", ...e });
|
|
671
671
|
}
|
|
672
672
|
function H(t) {
|
|
673
673
|
return t === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(t);
|
|
@@ -685,7 +685,7 @@ function Dt(t, e) {
|
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
687
|
function G(t, e = {}) {
|
|
688
|
-
const n = e.split ?? (e.separateNumbers ?
|
|
688
|
+
const n = e.split ?? (e.separateNumbers ? Re : Et), r = e.prefixCharacters ?? ft, o = e.suffixCharacters ?? ft;
|
|
689
689
|
let s = 0, i = t.length;
|
|
690
690
|
for (; s < t.length; ) {
|
|
691
691
|
const a = t.charAt(s);
|
|
@@ -705,89 +705,89 @@ function G(t, e = {}) {
|
|
|
705
705
|
t.slice(i)
|
|
706
706
|
];
|
|
707
707
|
}
|
|
708
|
-
function
|
|
708
|
+
function Ee(t) {
|
|
709
709
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function Be(t) {
|
|
712
712
|
throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
713
713
|
}
|
|
714
|
-
var
|
|
715
|
-
function
|
|
716
|
-
return
|
|
714
|
+
var U = { exports: {} }, De = U.exports, gt;
|
|
715
|
+
function Te() {
|
|
716
|
+
return gt || (gt = 1, (function(t, e) {
|
|
717
717
|
(function(n, r) {
|
|
718
|
-
typeof
|
|
718
|
+
typeof Be == "function" ? t.exports = r() : n.pluralize = r();
|
|
719
719
|
})(De, function() {
|
|
720
720
|
var n = [], r = [], o = {}, s = {}, i = {};
|
|
721
721
|
function a(l) {
|
|
722
722
|
return typeof l == "string" ? new RegExp("^" + l + "$", "i") : l;
|
|
723
723
|
}
|
|
724
|
-
function c(l,
|
|
725
|
-
return l ===
|
|
724
|
+
function c(l, p) {
|
|
725
|
+
return l === p ? p : l === l.toLowerCase() ? p.toLowerCase() : l === l.toUpperCase() ? p.toUpperCase() : l[0] === l[0].toUpperCase() ? p.charAt(0).toUpperCase() + p.substr(1).toLowerCase() : p.toLowerCase();
|
|
726
726
|
}
|
|
727
|
-
function m(l,
|
|
728
|
-
return l.replace(/\$(\d{1,2})/g, function(w,
|
|
729
|
-
return
|
|
727
|
+
function m(l, p) {
|
|
728
|
+
return l.replace(/\$(\d{1,2})/g, function(w, x) {
|
|
729
|
+
return p[x] || "";
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
-
function
|
|
733
|
-
return l.replace(
|
|
734
|
-
var
|
|
735
|
-
return c(w === "" ? l[
|
|
732
|
+
function g(l, p) {
|
|
733
|
+
return l.replace(p[0], function(w, x) {
|
|
734
|
+
var F = m(p[1], arguments);
|
|
735
|
+
return c(w === "" ? l[x - 1] : w, F);
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
|
-
function f(l,
|
|
738
|
+
function f(l, p, w) {
|
|
739
739
|
if (!l.length || o.hasOwnProperty(l))
|
|
740
|
-
return
|
|
741
|
-
for (var
|
|
742
|
-
var
|
|
743
|
-
if (
|
|
740
|
+
return p;
|
|
741
|
+
for (var x = w.length; x--; ) {
|
|
742
|
+
var F = w[x];
|
|
743
|
+
if (F[0].test(p)) return g(p, F);
|
|
744
744
|
}
|
|
745
|
-
return
|
|
745
|
+
return p;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
return function(
|
|
749
|
-
var
|
|
750
|
-
return
|
|
747
|
+
function h(l, p, w) {
|
|
748
|
+
return function(x) {
|
|
749
|
+
var F = x.toLowerCase();
|
|
750
|
+
return p.hasOwnProperty(F) ? c(x, F) : l.hasOwnProperty(F) ? c(x, l[F]) : f(F, x, w);
|
|
751
751
|
};
|
|
752
752
|
}
|
|
753
|
-
function
|
|
754
|
-
return function(
|
|
755
|
-
var I =
|
|
756
|
-
return
|
|
753
|
+
function $(l, p, w, x) {
|
|
754
|
+
return function(F) {
|
|
755
|
+
var I = F.toLowerCase();
|
|
756
|
+
return p.hasOwnProperty(I) ? !0 : l.hasOwnProperty(I) ? !1 : f(I, I, w) === I;
|
|
757
757
|
};
|
|
758
758
|
}
|
|
759
|
-
function u(l,
|
|
760
|
-
var
|
|
761
|
-
return (w ?
|
|
759
|
+
function u(l, p, w) {
|
|
760
|
+
var x = p === 1 ? u.singular(l) : u.plural(l);
|
|
761
|
+
return (w ? p + " " : "") + x;
|
|
762
762
|
}
|
|
763
|
-
return u.plural =
|
|
763
|
+
return u.plural = h(
|
|
764
764
|
i,
|
|
765
765
|
s,
|
|
766
766
|
n
|
|
767
|
-
), u.isPlural =
|
|
767
|
+
), u.isPlural = $(
|
|
768
768
|
i,
|
|
769
769
|
s,
|
|
770
770
|
n
|
|
771
|
-
), u.singular =
|
|
771
|
+
), u.singular = h(
|
|
772
772
|
s,
|
|
773
773
|
i,
|
|
774
774
|
r
|
|
775
|
-
), u.isSingular =
|
|
775
|
+
), u.isSingular = $(
|
|
776
776
|
s,
|
|
777
777
|
i,
|
|
778
778
|
r
|
|
779
|
-
), u.addPluralRule = function(l,
|
|
780
|
-
n.push([a(l),
|
|
781
|
-
}, u.addSingularRule = function(l,
|
|
782
|
-
r.push([a(l),
|
|
779
|
+
), u.addPluralRule = function(l, p) {
|
|
780
|
+
n.push([a(l), p]);
|
|
781
|
+
}, u.addSingularRule = function(l, p) {
|
|
782
|
+
r.push([a(l), p]);
|
|
783
783
|
}, u.addUncountableRule = function(l) {
|
|
784
784
|
if (typeof l == "string") {
|
|
785
785
|
o[l.toLowerCase()] = !0;
|
|
786
786
|
return;
|
|
787
787
|
}
|
|
788
788
|
u.addPluralRule(l, "$0"), u.addSingularRule(l, "$0");
|
|
789
|
-
}, u.addIrregularRule = function(l,
|
|
790
|
-
|
|
789
|
+
}, u.addIrregularRule = function(l, p) {
|
|
790
|
+
p = p.toLowerCase(), l = l.toLowerCase(), i[l] = p, s[p] = l;
|
|
791
791
|
}, [
|
|
792
792
|
// Pronouns.
|
|
793
793
|
["I", "we"],
|
|
@@ -1009,10 +1009,10 @@ function Ae() {
|
|
|
1009
1009
|
/sheep$/i
|
|
1010
1010
|
].forEach(u.addUncountableRule), u;
|
|
1011
1011
|
});
|
|
1012
|
-
})(
|
|
1012
|
+
})(U)), U.exports;
|
|
1013
1013
|
}
|
|
1014
|
-
var
|
|
1015
|
-
const _ = /* @__PURE__ */
|
|
1014
|
+
var Ae = Te();
|
|
1015
|
+
const _ = /* @__PURE__ */ Ee(Ae), _a = "data", ka = "migrations", Ne = "(app)", je = /* @__PURE__ */ new Set([
|
|
1016
1016
|
"break",
|
|
1017
1017
|
"case",
|
|
1018
1018
|
"catch",
|
|
@@ -1064,7 +1064,7 @@ const _ = /* @__PURE__ */ ze(Ne), Na = "data", Ba = "migrations", Be = "(app)",
|
|
|
1064
1064
|
"async",
|
|
1065
1065
|
"arguments",
|
|
1066
1066
|
"constructor"
|
|
1067
|
-
]),
|
|
1067
|
+
]), Le = {
|
|
1068
1068
|
function: "fn",
|
|
1069
1069
|
interface: "iface",
|
|
1070
1070
|
type: "type_",
|
|
@@ -1113,30 +1113,30 @@ const _ = /* @__PURE__ */ ze(Ne), Na = "data", Ba = "migrations", Be = "(app)",
|
|
|
1113
1113
|
arguments: "args",
|
|
1114
1114
|
constructor: "ctor"
|
|
1115
1115
|
};
|
|
1116
|
-
function Z(t) {
|
|
1117
|
-
return je.has(t) ? Oe[t] ?? `${t}_` : t;
|
|
1118
|
-
}
|
|
1119
1116
|
function K(t) {
|
|
1117
|
+
return je.has(t) ? Le[t] ?? `${t}_` : t;
|
|
1118
|
+
}
|
|
1119
|
+
function W(t) {
|
|
1120
1120
|
if (!/^[a-zA-Z][a-zA-Z0-9-_/]*$/.test(t))
|
|
1121
1121
|
throw new Error(
|
|
1122
1122
|
"Model path must start with a letter and contain only alphanumeric characters, dash, slash, or underscore"
|
|
1123
1123
|
);
|
|
1124
1124
|
}
|
|
1125
|
-
function
|
|
1126
|
-
return t.features.auth ? `src/routes/${
|
|
1125
|
+
function Oe(t) {
|
|
1126
|
+
return t.features.auth ? `src/routes/${Ne}` : "src/routes";
|
|
1127
1127
|
}
|
|
1128
|
-
function
|
|
1129
|
-
const n = t.split("/"), r = n[n.length - 1], o = n.slice(0, -1), s = _.singular(rt(r)), i = _.plural(s), a =
|
|
1128
|
+
function M(t, e) {
|
|
1129
|
+
const n = t.split("/"), r = n[n.length - 1], o = n.slice(0, -1), s = _.singular(rt(r)), i = _.plural(s), a = A(s), c = ze(i), m = [...o, c].join("/");
|
|
1130
1130
|
return {
|
|
1131
|
-
name:
|
|
1132
|
-
pluralName:
|
|
1133
|
-
typeName:
|
|
1134
|
-
tableName:
|
|
1131
|
+
name: K(a),
|
|
1132
|
+
pluralName: K(A(i)),
|
|
1133
|
+
typeName: Pe(s),
|
|
1134
|
+
tableName: Me(i),
|
|
1135
1135
|
displayName: s,
|
|
1136
1136
|
pluralDisplayName: i,
|
|
1137
|
-
schemaName: `${
|
|
1137
|
+
schemaName: `${K(a)}Schema`,
|
|
1138
1138
|
routeSegment: m,
|
|
1139
|
-
routesDir:
|
|
1139
|
+
routesDir: Oe(e)
|
|
1140
1140
|
};
|
|
1141
1141
|
}
|
|
1142
1142
|
function qe(t) {
|
|
@@ -1148,7 +1148,7 @@ function qe(t) {
|
|
|
1148
1148
|
edit: `${e}/[id]/edit`
|
|
1149
1149
|
};
|
|
1150
1150
|
}
|
|
1151
|
-
function
|
|
1151
|
+
function Ve(t) {
|
|
1152
1152
|
const e = `/${t.routeSegment}`;
|
|
1153
1153
|
return {
|
|
1154
1154
|
list: e,
|
|
@@ -1157,7 +1157,7 @@ function Ue(t) {
|
|
|
1157
1157
|
edit: `${e}/[id]/edit`
|
|
1158
1158
|
};
|
|
1159
1159
|
}
|
|
1160
|
-
const
|
|
1160
|
+
const Ue = [
|
|
1161
1161
|
"title",
|
|
1162
1162
|
"name",
|
|
1163
1163
|
"label",
|
|
@@ -1192,7 +1192,7 @@ const Ve = [
|
|
|
1192
1192
|
"id"
|
|
1193
1193
|
];
|
|
1194
1194
|
function He(t) {
|
|
1195
|
-
for (const e of
|
|
1195
|
+
for (const e of Ue)
|
|
1196
1196
|
if (t.some((n) => n.name === e))
|
|
1197
1197
|
return e;
|
|
1198
1198
|
return "id";
|
|
@@ -1200,15 +1200,15 @@ function He(t) {
|
|
|
1200
1200
|
function Ge(t) {
|
|
1201
1201
|
return t.map((e) => e.name).filter((e) => !e.startsWith("_"));
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function We(t) {
|
|
1204
1204
|
return Object.fromEntries(t.map((e) => [e.name, e.id]));
|
|
1205
1205
|
}
|
|
1206
|
-
function
|
|
1206
|
+
function Tt(t) {
|
|
1207
1207
|
return Object.fromEntries(
|
|
1208
1208
|
t.map((e) => [e.name, He(e.fields)])
|
|
1209
1209
|
);
|
|
1210
1210
|
}
|
|
1211
|
-
const
|
|
1211
|
+
const Je = [
|
|
1212
1212
|
"user",
|
|
1213
1213
|
"owner",
|
|
1214
1214
|
"created_by",
|
|
@@ -1220,7 +1220,7 @@ const We = [
|
|
|
1220
1220
|
function D(t) {
|
|
1221
1221
|
return t.toLowerCase();
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1223
|
+
function ht(t) {
|
|
1224
1224
|
return {
|
|
1225
1225
|
rule: '@request.auth.id != ""',
|
|
1226
1226
|
ownershipChainCollections: [t],
|
|
@@ -1228,14 +1228,14 @@ function gt(t) {
|
|
|
1228
1228
|
operator: "="
|
|
1229
1229
|
};
|
|
1230
1230
|
}
|
|
1231
|
-
function
|
|
1231
|
+
function Ze(t, e, n = {}) {
|
|
1232
1232
|
const r = new Set((n.authCollections ?? ["users"]).map(D)), o = new Set(
|
|
1233
|
-
(n.userFieldHints ??
|
|
1233
|
+
(n.userFieldHints ?? Je).map(D)
|
|
1234
1234
|
), s = n.maxDepth ?? 8, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
1235
1235
|
for (const b of t)
|
|
1236
1236
|
i.set(b.name, b), a.set(b.id, b);
|
|
1237
1237
|
if (!i.has(e))
|
|
1238
|
-
return
|
|
1238
|
+
return ht(e);
|
|
1239
1239
|
if (r.has(D(e)))
|
|
1240
1240
|
return {
|
|
1241
1241
|
rule: "@request.auth.id = id",
|
|
@@ -1250,62 +1250,62 @@ function Xe(t, e, n = {}) {
|
|
|
1250
1250
|
function m(b) {
|
|
1251
1251
|
const v = i.get(b);
|
|
1252
1252
|
if (!(v != null && v.fields)) return [];
|
|
1253
|
-
const
|
|
1253
|
+
const S = [];
|
|
1254
1254
|
for (const y of v.fields) {
|
|
1255
1255
|
if (y.type !== "relation" || !y.collectionId) continue;
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1256
|
+
const E = a.get(y.collectionId);
|
|
1257
|
+
E && S.push({
|
|
1258
1258
|
from: b,
|
|
1259
1259
|
fieldName: y.name,
|
|
1260
|
-
to:
|
|
1260
|
+
to: E.name,
|
|
1261
1261
|
isMulti: !!(y.maxSelect && y.maxSelect > 1),
|
|
1262
1262
|
hintScore: c(y.name)
|
|
1263
1263
|
});
|
|
1264
1264
|
}
|
|
1265
|
-
return
|
|
1265
|
+
return S.sort((y, E) => y.fieldName.localeCompare(E.fieldName)), S;
|
|
1266
1266
|
}
|
|
1267
|
-
function
|
|
1267
|
+
function g(b) {
|
|
1268
1268
|
return r.has(D(b));
|
|
1269
1269
|
}
|
|
1270
1270
|
function f(b) {
|
|
1271
1271
|
if (b.length === 0) return !1;
|
|
1272
1272
|
for (let v = 0; v < b.length - 1; v++)
|
|
1273
1273
|
if (b[v].isMulti) return !1;
|
|
1274
|
-
return
|
|
1274
|
+
return g(b[b.length - 1].to);
|
|
1275
1275
|
}
|
|
1276
|
-
function
|
|
1277
|
-
const v = b[b.length - 1],
|
|
1278
|
-
return 100 * b.length + 50 *
|
|
1276
|
+
function h(b) {
|
|
1277
|
+
const v = b[b.length - 1], S = v.isMulti ? 1 : 0, y = b.every((X) => !X.isMulti) ? 1 : 0, E = b.reduce((X, Kt) => X + Kt.hintScore, 0), Yt = D(v.fieldName) === "user" ? 1 : 0;
|
|
1278
|
+
return 100 * b.length + 50 * S - 40 * Yt - 15 * y - E;
|
|
1279
1279
|
}
|
|
1280
|
-
function
|
|
1280
|
+
function $(b) {
|
|
1281
1281
|
return b.map((v) => `${v.from}.${v.fieldName}->${v.to}`).join("|");
|
|
1282
1282
|
}
|
|
1283
1283
|
const u = [], l = /* @__PURE__ */ new Set([e]);
|
|
1284
|
-
function
|
|
1285
|
-
if (!(
|
|
1286
|
-
if (v.length > 0 &&
|
|
1284
|
+
function p(b, v, S) {
|
|
1285
|
+
if (!(S > s)) {
|
|
1286
|
+
if (v.length > 0 && g(v[v.length - 1].to) && f(v)) {
|
|
1287
1287
|
u.push([...v]);
|
|
1288
1288
|
return;
|
|
1289
1289
|
}
|
|
1290
1290
|
for (const y of m(b))
|
|
1291
|
-
l.has(y.to) || y.isMulti && !
|
|
1291
|
+
l.has(y.to) || y.isMulti && !g(y.to) || (l.add(y.to), v.push(y), p(y.to, v, S + 1), v.pop(), l.delete(y.to));
|
|
1292
1292
|
}
|
|
1293
1293
|
}
|
|
1294
|
-
if (
|
|
1295
|
-
return
|
|
1294
|
+
if (p(e, [], 0), u.length === 0)
|
|
1295
|
+
return ht(e);
|
|
1296
1296
|
u.sort((b, v) => {
|
|
1297
|
-
const
|
|
1298
|
-
return
|
|
1297
|
+
const S = h(b) - h(v);
|
|
1298
|
+
return S !== 0 ? S : $(b).localeCompare($(v));
|
|
1299
1299
|
});
|
|
1300
|
-
const w = u[0],
|
|
1300
|
+
const w = u[0], x = w.map((b) => b.fieldName), F = [e, ...w.map((b) => b.to)], lt = w[w.length - 1].isMulti ? "?=" : "=", Zt = x.join("."), Xt = n.includeRootPrefix ? (n.rootPrefix ?? e) + "." : "";
|
|
1301
1301
|
return {
|
|
1302
|
-
rule: `@request.auth.id ${lt} ${
|
|
1303
|
-
ownershipChainCollections:
|
|
1304
|
-
ownershipChainFields:
|
|
1302
|
+
rule: `@request.auth.id ${lt} ${Xt}${Zt}.id`,
|
|
1303
|
+
ownershipChainCollections: F,
|
|
1304
|
+
ownershipChainFields: x,
|
|
1305
1305
|
operator: lt
|
|
1306
1306
|
};
|
|
1307
1307
|
}
|
|
1308
|
-
function
|
|
1308
|
+
function Xe(t) {
|
|
1309
1309
|
let e = null, n = !1, r = 0;
|
|
1310
1310
|
for (let o = 0; o < t.length; o++) {
|
|
1311
1311
|
const s = t[o];
|
|
@@ -1370,7 +1370,7 @@ function vt(t) {
|
|
|
1370
1370
|
let o, s;
|
|
1371
1371
|
return e >= 0 ? (o = t.slice(0, e).trim(), s = t.slice(e + 1).trim()) : (o = t.trim(), s = o), { label: bt(s), value: bt(o) };
|
|
1372
1372
|
}
|
|
1373
|
-
function
|
|
1373
|
+
function Ye(t) {
|
|
1374
1374
|
const e = [];
|
|
1375
1375
|
let n = "", r = null, o = !1;
|
|
1376
1376
|
for (let i = 0; i < t.length; i++) {
|
|
@@ -1418,12 +1418,12 @@ const wt = {
|
|
|
1418
1418
|
datetime: "date",
|
|
1419
1419
|
timestamp: "date"
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1421
|
+
function Ke(t) {
|
|
1422
1422
|
const e = t.endsWith("!");
|
|
1423
1423
|
let n = e ? t.slice(0, -1) : t, r = [];
|
|
1424
1424
|
if (n.startsWith("select(") && n.endsWith(")")) {
|
|
1425
1425
|
const o = n.slice(7, -1);
|
|
1426
|
-
r =
|
|
1426
|
+
r = Ye(o), n = "select";
|
|
1427
1427
|
}
|
|
1428
1428
|
return n === "files" ? { type: "file", required: e, selectOptions: r } : (n in wt && (n = wt[n]), { type: n, required: e, selectOptions: r });
|
|
1429
1429
|
}
|
|
@@ -1432,28 +1432,28 @@ function yt(t) {
|
|
|
1432
1432
|
return t === n ? 99 : 1;
|
|
1433
1433
|
}
|
|
1434
1434
|
function q(t, e, n, r, o, s) {
|
|
1435
|
-
const i =
|
|
1435
|
+
const i = M(e, s), a = _.singular(t), c = _.plural(a);
|
|
1436
1436
|
return {
|
|
1437
1437
|
collectionId: r[e],
|
|
1438
1438
|
displayField: o[e] ?? "id",
|
|
1439
1439
|
relatedModel: i,
|
|
1440
|
-
singularRelationName:
|
|
1440
|
+
singularRelationName: A(
|
|
1441
1441
|
`${n.displayName} ${i.displayName}`
|
|
1442
1442
|
),
|
|
1443
|
-
pluralRelationName:
|
|
1443
|
+
pluralRelationName: A(
|
|
1444
1444
|
`${n.displayName} ${i.pluralDisplayName}`
|
|
1445
1445
|
),
|
|
1446
1446
|
maxSelect: t === c ? 999 : 1
|
|
1447
1447
|
};
|
|
1448
1448
|
}
|
|
1449
1449
|
function Qe(t, e, n, r, o) {
|
|
1450
|
-
const s = rt(t), { type: i, required: a, selectOptions: c } = e, m = Ge(r),
|
|
1451
|
-
if (o.features.auth && i === "current_user" &&
|
|
1450
|
+
const s = rt(t), { type: i, required: a, selectOptions: c } = e, m = Ge(r), g = We(r), f = Tt(r), h = m.map((u) => _.singular(u));
|
|
1451
|
+
if (o.features.auth && i === "current_user" && g.users) {
|
|
1452
1452
|
const u = q(
|
|
1453
1453
|
t,
|
|
1454
1454
|
"users",
|
|
1455
1455
|
n,
|
|
1456
|
-
|
|
1456
|
+
g,
|
|
1457
1457
|
f,
|
|
1458
1458
|
o
|
|
1459
1459
|
);
|
|
@@ -1502,11 +1502,11 @@ function Qe(t, e, n, r, o) {
|
|
|
1502
1502
|
throw new Error(
|
|
1503
1503
|
`Invalid relation field: ${t}. Must be one of ${m.join(", ")} (singular or plural)`
|
|
1504
1504
|
);
|
|
1505
|
-
const
|
|
1505
|
+
const p = q(
|
|
1506
1506
|
t,
|
|
1507
1507
|
l,
|
|
1508
1508
|
n,
|
|
1509
|
-
|
|
1509
|
+
g,
|
|
1510
1510
|
f,
|
|
1511
1511
|
o
|
|
1512
1512
|
);
|
|
@@ -1515,7 +1515,7 @@ function Qe(t, e, n, r, o) {
|
|
|
1515
1515
|
name: t,
|
|
1516
1516
|
title: s,
|
|
1517
1517
|
required: a,
|
|
1518
|
-
...
|
|
1518
|
+
...p,
|
|
1519
1519
|
isCurrentUser: !1
|
|
1520
1520
|
};
|
|
1521
1521
|
}
|
|
@@ -1524,7 +1524,7 @@ function Qe(t, e, n, r, o) {
|
|
|
1524
1524
|
t,
|
|
1525
1525
|
i,
|
|
1526
1526
|
n,
|
|
1527
|
-
|
|
1527
|
+
g,
|
|
1528
1528
|
f,
|
|
1529
1529
|
o
|
|
1530
1530
|
);
|
|
@@ -1537,14 +1537,14 @@ function Qe(t, e, n, r, o) {
|
|
|
1537
1537
|
isCurrentUser: !1
|
|
1538
1538
|
};
|
|
1539
1539
|
}
|
|
1540
|
-
if (
|
|
1540
|
+
if (h.includes(i)) {
|
|
1541
1541
|
const u = _.plural(i);
|
|
1542
1542
|
if (m.includes(u)) {
|
|
1543
1543
|
const l = q(
|
|
1544
1544
|
t,
|
|
1545
1545
|
u,
|
|
1546
1546
|
n,
|
|
1547
|
-
|
|
1547
|
+
g,
|
|
1548
1548
|
f,
|
|
1549
1549
|
o
|
|
1550
1550
|
);
|
|
@@ -1563,7 +1563,7 @@ function Qe(t, e, n, r, o) {
|
|
|
1563
1563
|
};
|
|
1564
1564
|
}
|
|
1565
1565
|
}
|
|
1566
|
-
const
|
|
1566
|
+
const $ = [
|
|
1567
1567
|
.../* @__PURE__ */ new Set([
|
|
1568
1568
|
"text",
|
|
1569
1569
|
"number",
|
|
@@ -1596,14 +1596,14 @@ function Qe(t, e, n, r, o) {
|
|
|
1596
1596
|
"geoPoint"
|
|
1597
1597
|
].includes(i))
|
|
1598
1598
|
throw new Error(
|
|
1599
|
-
`Invalid field type: ${i}. Valid types are: ${
|
|
1599
|
+
`Invalid field type: ${i}. Valid types are: ${$.join(", ").replace("relation", "references")}`
|
|
1600
1600
|
);
|
|
1601
1601
|
return { type: i, name: t, title: s, required: a };
|
|
1602
1602
|
}
|
|
1603
1603
|
function tn(t, e, n, r) {
|
|
1604
1604
|
const o = [];
|
|
1605
1605
|
for (const i of t) {
|
|
1606
|
-
const [a, c] =
|
|
1606
|
+
const [a, c] = Xe(i);
|
|
1607
1607
|
if (!a || !c)
|
|
1608
1608
|
throw new Error(
|
|
1609
1609
|
`Invalid field format: ${i}. Expected format: name:type or name:type!`
|
|
@@ -1612,10 +1612,10 @@ function tn(t, e, n, r) {
|
|
|
1612
1612
|
throw new Error(
|
|
1613
1613
|
`Invalid field name: ${a}. Must start with a letter and contain only alphanumeric characters`
|
|
1614
1614
|
);
|
|
1615
|
-
const m =
|
|
1615
|
+
const m = Ke(c);
|
|
1616
1616
|
o.push(Qe(a, m, e, n, r));
|
|
1617
1617
|
}
|
|
1618
|
-
const s = r.features.auth ?
|
|
1618
|
+
const s = r.features.auth ? Ze(
|
|
1619
1619
|
[
|
|
1620
1620
|
...n,
|
|
1621
1621
|
{
|
|
@@ -1634,10 +1634,10 @@ function tn(t, e, n, r) {
|
|
|
1634
1634
|
) : void 0;
|
|
1635
1635
|
return { fields: o, auth: s };
|
|
1636
1636
|
}
|
|
1637
|
-
async function
|
|
1637
|
+
async function J(t, e, n) {
|
|
1638
1638
|
let r;
|
|
1639
1639
|
if (n.env === "runtime") {
|
|
1640
|
-
const { getCollections: o } = await import("./env.runtime-
|
|
1640
|
+
const { getCollections: o } = await import("./env.runtime-DSiCFHzi.js");
|
|
1641
1641
|
r = await o();
|
|
1642
1642
|
} else {
|
|
1643
1643
|
const { getPreviewCollections: o } = await import("./env.preview-HlXZOEL4.js");
|
|
@@ -1646,13 +1646,13 @@ async function W(t, e, n) {
|
|
|
1646
1646
|
return tn(t, e, r, n);
|
|
1647
1647
|
}
|
|
1648
1648
|
const en = "2024-01-01T00:00:00.000Z";
|
|
1649
|
-
class
|
|
1649
|
+
class N {
|
|
1650
1650
|
constructor(e) {
|
|
1651
1651
|
this.expression = e;
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
1654
|
function tt(t) {
|
|
1655
|
-
return t instanceof
|
|
1655
|
+
return t instanceof N ? t.expression : Array.isArray(t) ? `[${t.map((e) => tt(e)).join(", ")}]` : t && typeof t == "object" ? `{ ${Object.entries(t).map(([n, r]) => `${JSON.stringify(n)}: ${tt(r)}`).join(", ")} }` : JSON.stringify(t);
|
|
1656
1656
|
}
|
|
1657
1657
|
function Q(t) {
|
|
1658
1658
|
return `{ ${Object.entries(t).map(
|
|
@@ -1695,10 +1695,10 @@ function nn(t) {
|
|
|
1695
1695
|
return;
|
|
1696
1696
|
}
|
|
1697
1697
|
}
|
|
1698
|
-
function
|
|
1698
|
+
function T(t, e) {
|
|
1699
1699
|
return t.replace("[id]", `\${${e}}`);
|
|
1700
1700
|
}
|
|
1701
|
-
function
|
|
1701
|
+
function At(t, e, n) {
|
|
1702
1702
|
var r, o, s;
|
|
1703
1703
|
switch (t.type) {
|
|
1704
1704
|
case "text":
|
|
@@ -1726,9 +1726,9 @@ function Nt(t, e, n) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
case "relation": {
|
|
1728
1728
|
if (n.authEnabled && (t.isCurrentUser || ((s = t.relatedModel) == null ? void 0 : s.tableName) === "users"))
|
|
1729
|
-
return new
|
|
1729
|
+
return new N("context.user.id");
|
|
1730
1730
|
const i = t.collectionId ? e[t.collectionId] : void 0;
|
|
1731
|
-
return i ? new
|
|
1731
|
+
return i ? new N(i) : "missing-relation-id";
|
|
1732
1732
|
}
|
|
1733
1733
|
case "file":
|
|
1734
1734
|
case "autodate":
|
|
@@ -1737,16 +1737,16 @@ function Nt(t, e, n) {
|
|
|
1737
1737
|
return;
|
|
1738
1738
|
}
|
|
1739
1739
|
}
|
|
1740
|
-
function
|
|
1740
|
+
function $t(t, e, n) {
|
|
1741
1741
|
const r = {};
|
|
1742
1742
|
for (const o of t) {
|
|
1743
1743
|
if (o.type === "file" || o.type === "autodate")
|
|
1744
1744
|
continue;
|
|
1745
1745
|
if (n.authEnabled && o.type === "relation" && o.isCurrentUser) {
|
|
1746
|
-
n.forForm || (r[o.name] = new
|
|
1746
|
+
n.forForm || (r[o.name] = new N("context.user.id"));
|
|
1747
1747
|
continue;
|
|
1748
1748
|
}
|
|
1749
|
-
const s =
|
|
1749
|
+
const s = At(o, e, n);
|
|
1750
1750
|
s !== void 0 && (r[o.name] = s);
|
|
1751
1751
|
}
|
|
1752
1752
|
return r;
|
|
@@ -1762,14 +1762,14 @@ function rn(t, e, n) {
|
|
|
1762
1762
|
continue;
|
|
1763
1763
|
let a;
|
|
1764
1764
|
if (i === "relation")
|
|
1765
|
-
a = s.collectionId ? new
|
|
1765
|
+
a = s.collectionId ? new N(
|
|
1766
1766
|
e[s.collectionId] ?? '"missing-relation-id"'
|
|
1767
1767
|
) : void 0;
|
|
1768
1768
|
else if (i === "select") {
|
|
1769
1769
|
const c = ((o = s.values) == null ? void 0 : o[0]) ?? "default";
|
|
1770
1770
|
a = (s.maxSelect ?? 1) > 1 ? [c] : c;
|
|
1771
1771
|
} else
|
|
1772
|
-
a =
|
|
1772
|
+
a = At(
|
|
1773
1773
|
{ name: s.name, type: i },
|
|
1774
1774
|
e,
|
|
1775
1775
|
{ forForm: !1, authEnabled: n.features.auth }
|
|
@@ -1779,7 +1779,7 @@ function rn(t, e, n) {
|
|
|
1779
1779
|
return r;
|
|
1780
1780
|
}
|
|
1781
1781
|
function an(t) {
|
|
1782
|
-
t.email = new
|
|
1782
|
+
t.email = new N(
|
|
1783
1783
|
"`test-${Math.random().toString(36).slice(2)}@example.com`"
|
|
1784
1784
|
), t.password = "password", t.passwordConfirm = "password";
|
|
1785
1785
|
}
|
|
@@ -1832,37 +1832,37 @@ function ln(t, e) {
|
|
|
1832
1832
|
} : { name: n.name, type: n.type })
|
|
1833
1833
|
};
|
|
1834
1834
|
}
|
|
1835
|
-
function
|
|
1835
|
+
function Nt(t, e, n, r) {
|
|
1836
1836
|
const o = r.find((l) => l.name === t.tableName) ?? ln(t, e), s = on(o, r).filter(
|
|
1837
1837
|
(l) => !(n.features.auth && l.name === "users")
|
|
1838
1838
|
), i = {}, a = [], c = /* @__PURE__ */ new Set();
|
|
1839
1839
|
for (const l of s) {
|
|
1840
|
-
const
|
|
1841
|
-
a.push({ varName:
|
|
1840
|
+
const p = sn(M(l.name, n).name, c);
|
|
1841
|
+
a.push({ varName: p, collection: l }), i[l.id] = `${p}.id`;
|
|
1842
1842
|
}
|
|
1843
1843
|
const m = a.length ? `${a.map((l) => `let ${l.varName}: { id: string };`).join(`
|
|
1844
1844
|
`)}
|
|
1845
1845
|
|
|
1846
|
-
` : "",
|
|
1846
|
+
` : "", g = a.map(({ varName: l, collection: p }) => {
|
|
1847
1847
|
const w = rn(
|
|
1848
|
-
|
|
1848
|
+
p.fields,
|
|
1849
1849
|
i,
|
|
1850
1850
|
n
|
|
1851
1851
|
);
|
|
1852
|
-
return
|
|
1852
|
+
return p.type === "auth" && an(w), `${l} = await context.admin.collection("${p.name}").create(${Q(w)});`;
|
|
1853
1853
|
}), f = a.slice().reverse().map(
|
|
1854
|
-
({ varName: l, collection:
|
|
1855
|
-
),
|
|
1854
|
+
({ varName: l, collection: p }) => `await context.admin.collection("${p.name}").delete(${l}.id);`
|
|
1855
|
+
), h = n.features.auth ? "context.agent" : "context.request", $ = n.features.auth ? `await context.agent.authenticateUser();
|
|
1856
1856
|
` : "";
|
|
1857
1857
|
let u = "";
|
|
1858
|
-
return (
|
|
1858
|
+
return (g.length > 0 || n.features.auth) && (u += d`
|
|
1859
1859
|
beforeEach(async (context) => {
|
|
1860
|
-
${
|
|
1860
|
+
${$}${g.join(`
|
|
1861
1861
|
`)}
|
|
1862
1862
|
});
|
|
1863
1863
|
`), f.length > 0 && (u += `
|
|
1864
1864
|
|
|
1865
|
-
` +
|
|
1865
|
+
` + d`
|
|
1866
1866
|
afterEach(async (context) => {
|
|
1867
1867
|
${f.join(`
|
|
1868
1868
|
`)}
|
|
@@ -1870,15 +1870,15 @@ function Bt(t, e, n, r) {
|
|
|
1870
1870
|
`), {
|
|
1871
1871
|
declarations: m,
|
|
1872
1872
|
setupSection: u,
|
|
1873
|
-
requestAgent:
|
|
1873
|
+
requestAgent: h,
|
|
1874
1874
|
modelDbData: Q(
|
|
1875
|
-
|
|
1875
|
+
$t(e, i, {
|
|
1876
1876
|
forForm: !1,
|
|
1877
1877
|
authEnabled: n.features.auth
|
|
1878
1878
|
})
|
|
1879
1879
|
),
|
|
1880
1880
|
modelFormData: Q(
|
|
1881
|
-
|
|
1881
|
+
$t(e, i, {
|
|
1882
1882
|
forForm: !0,
|
|
1883
1883
|
authEnabled: n.features.auth
|
|
1884
1884
|
})
|
|
@@ -1886,8 +1886,8 @@ function Bt(t, e, n, r) {
|
|
|
1886
1886
|
};
|
|
1887
1887
|
}
|
|
1888
1888
|
function cn(t, e, n, r, o) {
|
|
1889
|
-
const { declarations: s, setupSection: i, requestAgent: a, modelDbData: c, modelFormData: m } =
|
|
1890
|
-
return
|
|
1889
|
+
const { declarations: s, setupSection: i, requestAgent: a, modelDbData: c, modelFormData: m } = Nt(t, n, r, o);
|
|
1890
|
+
return d`
|
|
1891
1891
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1892
1892
|
|
|
1893
1893
|
describe("${t.pluralName}", () => {
|
|
@@ -1920,7 +1920,7 @@ function cn(t, e, n, r, o) {
|
|
|
1920
1920
|
describe("GET ${e.show}", () => {
|
|
1921
1921
|
it("should return a 200 status code", async (context) => {
|
|
1922
1922
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1923
|
-
const response = await ${a}.get(\`${
|
|
1923
|
+
const response = await ${a}.get(\`${T(e.show, "id")}\`);
|
|
1924
1924
|
expect(response.status).toBe(200);
|
|
1925
1925
|
});
|
|
1926
1926
|
|
|
@@ -1933,10 +1933,10 @@ function cn(t, e, n, r, o) {
|
|
|
1933
1933
|
describe("POST ${e.show}", () => {
|
|
1934
1934
|
it("should delete a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1935
1935
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1936
|
-
const response = await ${a}.post(\`${
|
|
1936
|
+
const response = await ${a}.post(\`${T(e.show, "id")}\`).type("form");
|
|
1937
1937
|
expect(response.body.status).toBe(303);
|
|
1938
1938
|
|
|
1939
|
-
const response2 = await ${a}.get(\`${
|
|
1939
|
+
const response2 = await ${a}.get(\`${T(e.show, "id")}\`);
|
|
1940
1940
|
expect(response2.status).toBe(404);
|
|
1941
1941
|
});
|
|
1942
1942
|
});
|
|
@@ -1944,7 +1944,7 @@ function cn(t, e, n, r, o) {
|
|
|
1944
1944
|
describe("GET ${e.edit}", () => {
|
|
1945
1945
|
it("should return a 200 status code", async (context) => {
|
|
1946
1946
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1947
|
-
const response = await ${a}.get(\`${
|
|
1947
|
+
const response = await ${a}.get(\`${T(e.edit, "id")}\`);
|
|
1948
1948
|
expect(response.status).toBe(200);
|
|
1949
1949
|
});
|
|
1950
1950
|
});
|
|
@@ -1953,19 +1953,19 @@ function cn(t, e, n, r, o) {
|
|
|
1953
1953
|
it("should update a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1954
1954
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1955
1955
|
const response = await ${a}
|
|
1956
|
-
.post(\`${
|
|
1956
|
+
.post(\`${T(e.edit, "id")}\`)
|
|
1957
1957
|
.type("form")
|
|
1958
1958
|
.send(${m});
|
|
1959
1959
|
expect(response.body.status).toBe(303);
|
|
1960
|
-
expect(response.body.location).toBe(\`${
|
|
1960
|
+
expect(response.body.location).toBe(\`${T(e.show, "id")}\`);
|
|
1961
1961
|
});
|
|
1962
1962
|
});
|
|
1963
1963
|
});
|
|
1964
1964
|
`;
|
|
1965
1965
|
}
|
|
1966
1966
|
function mn(t, e, n, r, o) {
|
|
1967
|
-
const { declarations: s, setupSection: i, requestAgent: a, modelFormData: c } =
|
|
1968
|
-
return
|
|
1967
|
+
const { declarations: s, setupSection: i, requestAgent: a, modelFormData: c } = Nt(t, n, r, o);
|
|
1968
|
+
return d`
|
|
1969
1969
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1970
1970
|
|
|
1971
1971
|
describe("${e}", () => {
|
|
@@ -1987,8 +1987,8 @@ function mn(t, e, n, r, o) {
|
|
|
1987
1987
|
});
|
|
1988
1988
|
`;
|
|
1989
1989
|
}
|
|
1990
|
-
var
|
|
1991
|
-
function
|
|
1990
|
+
var xt = Object.freeze, un = Object.defineProperty, dn = (t, e) => xt(un(t, "raw", { value: xt(t.slice()) })), Ft;
|
|
1991
|
+
function pn(t, e) {
|
|
1992
1992
|
const n = t.replace(/^\/+|\/+$/g, ""), r = `${e}/${n}`, o = `/${n}`;
|
|
1993
1993
|
return {
|
|
1994
1994
|
pagePath: r,
|
|
@@ -2006,10 +2006,10 @@ function fn(t) {
|
|
|
2006
2006
|
function jt(t) {
|
|
2007
2007
|
return t.some((e) => e.type === "file");
|
|
2008
2008
|
}
|
|
2009
|
-
function
|
|
2009
|
+
function gn(t) {
|
|
2010
2010
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2011
2011
|
}
|
|
2012
|
-
function
|
|
2012
|
+
function St(t) {
|
|
2013
2013
|
const e = t.type === "select" ? `[${t.options.map((o) => JSON.stringify(o.value)).join(", ")}]` : "";
|
|
2014
2014
|
let n;
|
|
2015
2015
|
switch (t.type) {
|
|
@@ -2065,13 +2065,13 @@ function Ft(t) {
|
|
|
2065
2065
|
}
|
|
2066
2066
|
return ["text"].includes(t.type) ? t.required ? `${n}.nonempty()` : `${n}.optional()` : t.required || t.type === "geoPoint" ? n : t.type === "file" && t.maxSelect <= 1 ? `${n}.optional().default("")` : `${n}.optional()`;
|
|
2067
2067
|
}
|
|
2068
|
-
function
|
|
2068
|
+
function hn(t) {
|
|
2069
2069
|
const e = [];
|
|
2070
2070
|
for (const n of t) {
|
|
2071
2071
|
if (n.type === "file" && n.maxSelect > 1) {
|
|
2072
2072
|
e.push({
|
|
2073
2073
|
name: n.name,
|
|
2074
|
-
schema:
|
|
2074
|
+
schema: St({ ...n, required: !1 })
|
|
2075
2075
|
}), e.push({
|
|
2076
2076
|
name: `${n.name}+`,
|
|
2077
2077
|
schema: "z.instanceof(File).array().optional()"
|
|
@@ -2081,14 +2081,14 @@ function gn(t) {
|
|
|
2081
2081
|
});
|
|
2082
2082
|
continue;
|
|
2083
2083
|
}
|
|
2084
|
-
e.push({ name: n.name, schema:
|
|
2084
|
+
e.push({ name: n.name, schema: St(n) });
|
|
2085
2085
|
}
|
|
2086
2086
|
return e;
|
|
2087
2087
|
}
|
|
2088
2088
|
function bn(t, e) {
|
|
2089
|
-
const n =
|
|
2089
|
+
const n = hn(e).map((r) => `${gn(r.name)}: ${r.schema}`).join(`,
|
|
2090
2090
|
`);
|
|
2091
|
-
return
|
|
2091
|
+
return d`
|
|
2092
2092
|
import { z } from "zod/v3";
|
|
2093
2093
|
|
|
2094
2094
|
export const ${t.schemaName} = z.object({
|
|
@@ -2097,7 +2097,7 @@ function bn(t, e) {
|
|
|
2097
2097
|
`;
|
|
2098
2098
|
}
|
|
2099
2099
|
function vn(t, e) {
|
|
2100
|
-
const n =
|
|
2100
|
+
const n = O(e), r = [
|
|
2101
2101
|
'import { untrack } from "svelte";',
|
|
2102
2102
|
'import { superForm } from "sveltekit-superforms";',
|
|
2103
2103
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
@@ -2112,7 +2112,7 @@ function wn(t, e) {
|
|
|
2112
2112
|
).map((o) => It(o)).join(`
|
|
2113
2113
|
|
|
2114
2114
|
`);
|
|
2115
|
-
return
|
|
2115
|
+
return d`
|
|
2116
2116
|
${r}
|
|
2117
2117
|
|
|
2118
2118
|
const form = superForm(untrack(() => data.form), {
|
|
@@ -2126,7 +2126,7 @@ function yn(t, e) {
|
|
|
2126
2126
|
const n = vn(t, e).join(`
|
|
2127
2127
|
`), r = wn(t, e), o = e.map((i) => et(i)).join(`
|
|
2128
2128
|
`), s = jt(e) ? ' enctype="multipart/form-data"' : "";
|
|
2129
|
-
return
|
|
2129
|
+
return d(Ft || (Ft = dn([`
|
|
2130
2130
|
<script lang="ts">
|
|
2131
2131
|
`, `
|
|
2132
2132
|
|
|
@@ -2151,14 +2151,14 @@ function yn(t, e) {
|
|
|
2151
2151
|
</section>
|
|
2152
2152
|
`])), n, r, t.displayName, s, o);
|
|
2153
2153
|
}
|
|
2154
|
-
function
|
|
2155
|
-
const n = jt(e), r =
|
|
2154
|
+
function $n(t, e) {
|
|
2155
|
+
const n = jt(e), r = d`
|
|
2156
2156
|
import { fail, superValidate${n ? ", withFiles" : ""} } from "sveltekit-superforms";
|
|
2157
2157
|
import { zod } from "sveltekit-superforms/adapters";
|
|
2158
2158
|
import { ${t.schemaName} } from "$lib/schemas/${t.name}";
|
|
2159
2159
|
import { setFlash } from "sveltekit-flash-message/server";
|
|
2160
2160
|
`;
|
|
2161
|
-
return
|
|
2161
|
+
return d`
|
|
2162
2162
|
${r}
|
|
2163
2163
|
|
|
2164
2164
|
export const load = async () => {
|
|
@@ -2181,22 +2181,22 @@ function xn(t, e) {
|
|
|
2181
2181
|
};
|
|
2182
2182
|
`;
|
|
2183
2183
|
}
|
|
2184
|
-
function
|
|
2184
|
+
function V(t, e) {
|
|
2185
2185
|
return {
|
|
2186
2186
|
path: t,
|
|
2187
2187
|
language: j(t),
|
|
2188
2188
|
content: e
|
|
2189
2189
|
};
|
|
2190
2190
|
}
|
|
2191
|
-
async function
|
|
2191
|
+
async function xn(t) {
|
|
2192
2192
|
const { modelPath: e, fields: n } = fn(t.argv);
|
|
2193
|
-
|
|
2194
|
-
const r =
|
|
2193
|
+
W(e);
|
|
2194
|
+
const r = M(e, t), s = (await J(n, r, t)).fields, { pagePath: i, pageUrl: a } = pn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
2195
2195
|
t
|
|
2196
2196
|
), m = [
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2197
|
+
V(`${i}/+page.svelte`, yn(r, s)),
|
|
2198
|
+
V(`${i}/+page.server.ts`, $n(r, s)),
|
|
2199
|
+
V(
|
|
2200
2200
|
`${i}/server.test.ts`,
|
|
2201
2201
|
mn(
|
|
2202
2202
|
r,
|
|
@@ -2206,33 +2206,37 @@ async function $n(t) {
|
|
|
2206
2206
|
c
|
|
2207
2207
|
)
|
|
2208
2208
|
),
|
|
2209
|
-
|
|
2210
|
-
],
|
|
2209
|
+
V(`src/lib/schemas/${r.name}.ts`, bn(r, s))
|
|
2210
|
+
], g = O(s);
|
|
2211
2211
|
return {
|
|
2212
2212
|
creates: m,
|
|
2213
2213
|
modifies: [],
|
|
2214
2214
|
deletes: [],
|
|
2215
|
-
components:
|
|
2215
|
+
components: g,
|
|
2216
2216
|
packages: [],
|
|
2217
2217
|
collections: []
|
|
2218
2218
|
};
|
|
2219
2219
|
}
|
|
2220
|
-
const
|
|
2220
|
+
const Fn = "generate-form", Sn = "1.0.7", Cn = "src/patterns/generate/form", _n = "/generate/form";
|
|
2221
2221
|
async function kn(t) {
|
|
2222
|
-
const e = await
|
|
2222
|
+
const e = await xn(t);
|
|
2223
2223
|
if (t.env !== "runtime")
|
|
2224
2224
|
return k(e);
|
|
2225
|
-
const { writeResult: n } = await import("./write-result-
|
|
2225
|
+
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
2226
2226
|
return n(await k(e), t);
|
|
2227
2227
|
}
|
|
2228
|
-
const
|
|
2229
|
-
version:
|
|
2230
|
-
slug:
|
|
2231
|
-
source:
|
|
2228
|
+
const Rn = {
|
|
2229
|
+
version: Sn,
|
|
2230
|
+
slug: Fn,
|
|
2231
|
+
source: Cn,
|
|
2232
2232
|
docs: _n,
|
|
2233
2233
|
plan: "open",
|
|
2234
2234
|
title: "Generate a form",
|
|
2235
2235
|
summary: "Generates a form.",
|
|
2236
|
+
requires: {
|
|
2237
|
+
auth: !1,
|
|
2238
|
+
payments: !1
|
|
2239
|
+
},
|
|
2236
2240
|
categories: ["forms"],
|
|
2237
2241
|
tags: ["sveltekit", "superforms", "validation", "zod"],
|
|
2238
2242
|
command: {
|
|
@@ -2242,7 +2246,7 @@ const Pn = {
|
|
|
2242
2246
|
},
|
|
2243
2247
|
baseline: "velastack",
|
|
2244
2248
|
generate: kn
|
|
2245
|
-
},
|
|
2249
|
+
}, Pn = ["text"], zn = {
|
|
2246
2250
|
string: "text",
|
|
2247
2251
|
boolean: "bool",
|
|
2248
2252
|
geopoint: "geoPoint",
|
|
@@ -2269,7 +2273,7 @@ const Pn = {
|
|
|
2269
2273
|
geoPoint: "geoPoint",
|
|
2270
2274
|
relation: "relation"
|
|
2271
2275
|
};
|
|
2272
|
-
function
|
|
2276
|
+
function Mn(t) {
|
|
2273
2277
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2274
2278
|
}
|
|
2275
2279
|
function In(t, e) {
|
|
@@ -2318,7 +2322,7 @@ function In(t, e) {
|
|
|
2318
2322
|
return val;
|
|
2319
2323
|
}
|
|
2320
2324
|
return JSON.stringify(val);
|
|
2321
|
-
}, z.string()${t.required ? "" : ".optional()"}) as z.ZodEffects<${t.required ? "" : "z.ZodOptional<"}z.ZodString${t.required ? "" : ">"}, any, any>` :
|
|
2325
|
+
}, z.string()${t.required ? "" : ".optional()"}) as z.ZodEffects<${t.required ? "" : "z.ZodOptional<"}z.ZodString${t.required ? "" : ">"}, any, any>` : d`
|
|
2322
2326
|
z.object({
|
|
2323
2327
|
lat: z.number().min(-90).max(90),
|
|
2324
2328
|
lon: z.number().min(-180).max(180)
|
|
@@ -2331,7 +2335,7 @@ function In(t, e) {
|
|
|
2331
2335
|
default:
|
|
2332
2336
|
return t.type;
|
|
2333
2337
|
}
|
|
2334
|
-
return
|
|
2338
|
+
return Pn.includes(t.type) ? t.required ? `${r}.nonempty()` : `${r}.optional()` : t.required || t.type === "geoPoint" ? r : t.type === "file" && (t.maxSelect ?? 1) <= 1 ? `${r}.optional().default("")` : `${r}.optional()`;
|
|
2335
2339
|
}
|
|
2336
2340
|
function ot(t, e, n) {
|
|
2337
2341
|
const r = [];
|
|
@@ -2343,10 +2347,10 @@ function ot(t, e, n) {
|
|
|
2343
2347
|
}
|
|
2344
2348
|
r.push(a);
|
|
2345
2349
|
}
|
|
2346
|
-
const o = r.map((a) => `${
|
|
2350
|
+
const o = r.map((a) => `${Mn(a.name)}: ${In(a, n)}`).join(`,
|
|
2347
2351
|
`), s = n.includeModelFields ? `
|
|
2348
2352
|
import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelFields ? ` satisfies Schemas["${t.tableName}"]` : "";
|
|
2349
|
-
return
|
|
2353
|
+
return d`
|
|
2350
2354
|
import { z } from "zod/v3";${s}
|
|
2351
2355
|
|
|
2352
2356
|
export const ${t.schemaName} = z.object({
|
|
@@ -2354,8 +2358,8 @@ import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelField
|
|
|
2354
2358
|
})${i};
|
|
2355
2359
|
`;
|
|
2356
2360
|
}
|
|
2357
|
-
function
|
|
2358
|
-
const e =
|
|
2361
|
+
function En(t) {
|
|
2362
|
+
const e = zn[t];
|
|
2359
2363
|
if (!e)
|
|
2360
2364
|
throw new Error(`Unsupported collection field type "${t}" when generating from collection`);
|
|
2361
2365
|
return e;
|
|
@@ -2364,30 +2368,30 @@ function st(t, e, n) {
|
|
|
2364
2368
|
const r = e.find((a) => a.name === t.tableName);
|
|
2365
2369
|
if (!r)
|
|
2366
2370
|
throw new Error(`Collection "${t.tableName}" not found`);
|
|
2367
|
-
const o =
|
|
2371
|
+
const o = Tt(e), s = new Map(e.map((a) => [a.id, a])), i = [];
|
|
2368
2372
|
for (const a of r.fields) {
|
|
2369
2373
|
if (a.name === "id" || a.system)
|
|
2370
2374
|
continue;
|
|
2371
|
-
const c =
|
|
2375
|
+
const c = En(a.type), m = !!a.required, g = rt(a.name);
|
|
2372
2376
|
if (c === "relation") {
|
|
2373
2377
|
const f = a.collectionId ? s.get(a.collectionId) : void 0;
|
|
2374
2378
|
if (!f)
|
|
2375
2379
|
continue;
|
|
2376
|
-
const
|
|
2380
|
+
const h = M(f.name, n);
|
|
2377
2381
|
i.push({
|
|
2378
2382
|
name: a.name,
|
|
2379
|
-
title:
|
|
2383
|
+
title: g,
|
|
2380
2384
|
type: "relation",
|
|
2381
2385
|
required: m,
|
|
2382
2386
|
collectionId: f.id,
|
|
2383
2387
|
maxSelect: a.maxSelect ?? 1,
|
|
2384
2388
|
displayField: o[f.name] ?? "id",
|
|
2385
|
-
relatedModel:
|
|
2386
|
-
singularRelationName:
|
|
2387
|
-
`${t.displayName} ${
|
|
2389
|
+
relatedModel: h,
|
|
2390
|
+
singularRelationName: A(
|
|
2391
|
+
`${t.displayName} ${h.displayName}`
|
|
2388
2392
|
),
|
|
2389
|
-
pluralRelationName:
|
|
2390
|
-
`${t.displayName} ${
|
|
2393
|
+
pluralRelationName: A(
|
|
2394
|
+
`${t.displayName} ${h.pluralDisplayName}`
|
|
2391
2395
|
),
|
|
2392
2396
|
isCurrentUser: n.features.auth && f.name === "users" && /user|owner|author/i.test(a.name)
|
|
2393
2397
|
});
|
|
@@ -2396,7 +2400,7 @@ function st(t, e, n) {
|
|
|
2396
2400
|
if (c === "select") {
|
|
2397
2401
|
i.push({
|
|
2398
2402
|
name: a.name,
|
|
2399
|
-
title:
|
|
2403
|
+
title: g,
|
|
2400
2404
|
type: "select",
|
|
2401
2405
|
required: m,
|
|
2402
2406
|
maxSelect: a.maxSelect ?? 1,
|
|
@@ -2407,7 +2411,7 @@ function st(t, e, n) {
|
|
|
2407
2411
|
if (c === "file") {
|
|
2408
2412
|
i.push({
|
|
2409
2413
|
name: a.name,
|
|
2410
|
-
title:
|
|
2414
|
+
title: g,
|
|
2411
2415
|
type: "file",
|
|
2412
2416
|
required: m,
|
|
2413
2417
|
maxSelect: a.maxSelect ?? 1
|
|
@@ -2417,7 +2421,7 @@ function st(t, e, n) {
|
|
|
2417
2421
|
if (c === "autodate") {
|
|
2418
2422
|
i.push({
|
|
2419
2423
|
name: a.name,
|
|
2420
|
-
title:
|
|
2424
|
+
title: g,
|
|
2421
2425
|
type: "autodate",
|
|
2422
2426
|
required: m,
|
|
2423
2427
|
onCreate: a.onCreate ?? a.name.includes("create"),
|
|
@@ -2427,24 +2431,24 @@ function st(t, e, n) {
|
|
|
2427
2431
|
}
|
|
2428
2432
|
i.push({
|
|
2429
2433
|
name: a.name,
|
|
2430
|
-
title:
|
|
2434
|
+
title: g,
|
|
2431
2435
|
type: c,
|
|
2432
2436
|
required: m
|
|
2433
2437
|
});
|
|
2434
2438
|
}
|
|
2435
2439
|
return i.filter((a) => a.name !== "id");
|
|
2436
2440
|
}
|
|
2437
|
-
function
|
|
2441
|
+
function Lt(t) {
|
|
2438
2442
|
const e = t.filter((n) => n.type === "relation").map((n) => n.name);
|
|
2439
2443
|
return e.length > 0 ? e.join(",") : void 0;
|
|
2440
2444
|
}
|
|
2441
|
-
function
|
|
2445
|
+
function Ot(t) {
|
|
2442
2446
|
const e = /* @__PURE__ */ new Set(), n = [];
|
|
2443
2447
|
for (const r of t)
|
|
2444
2448
|
r.type === "relation" && (e.has(r.relatedModel.tableName) || (e.add(r.relatedModel.tableName), n.push(r.relatedModel)));
|
|
2445
2449
|
return n;
|
|
2446
2450
|
}
|
|
2447
|
-
function
|
|
2451
|
+
function Bn(t) {
|
|
2448
2452
|
const e = {
|
|
2449
2453
|
name: t.name,
|
|
2450
2454
|
type: t.type,
|
|
@@ -2479,7 +2483,7 @@ function qt(t, e, n) {
|
|
|
2479
2483
|
name: t.tableName,
|
|
2480
2484
|
type: "base",
|
|
2481
2485
|
...r,
|
|
2482
|
-
fields: e.map(
|
|
2486
|
+
fields: e.map(Bn)
|
|
2483
2487
|
};
|
|
2484
2488
|
}
|
|
2485
2489
|
function Dn(t) {
|
|
@@ -2490,25 +2494,25 @@ function Dn(t) {
|
|
|
2490
2494
|
);
|
|
2491
2495
|
return { modelPath: e, fields: n };
|
|
2492
2496
|
}
|
|
2493
|
-
function
|
|
2497
|
+
function Tn(t, e) {
|
|
2494
2498
|
return {
|
|
2495
2499
|
path: t,
|
|
2496
2500
|
language: j(t),
|
|
2497
2501
|
content: e
|
|
2498
2502
|
};
|
|
2499
2503
|
}
|
|
2500
|
-
async function
|
|
2501
|
-
|
|
2502
|
-
const r =
|
|
2504
|
+
async function An(t, e, n) {
|
|
2505
|
+
W(e);
|
|
2506
|
+
const r = M(e, t);
|
|
2503
2507
|
if (n.length > 0) {
|
|
2504
|
-
const i = await
|
|
2508
|
+
const i = await J(n, r, t);
|
|
2505
2509
|
return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
|
|
2506
2510
|
}
|
|
2507
|
-
const o = t.env === "runtime" ? await (await import("./env.runtime-
|
|
2511
|
+
const o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
|
|
2508
2512
|
return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
|
|
2509
2513
|
}
|
|
2510
|
-
async function
|
|
2511
|
-
const { modelPath: e, fields: n } = Dn(t.argv), { model: r, fields: o, auth: s, shouldCreateCollection: i } = await
|
|
2514
|
+
async function Nn(t) {
|
|
2515
|
+
const { modelPath: e, fields: n } = Dn(t.argv), { model: r, fields: o, auth: s, shouldCreateCollection: i } = await An(
|
|
2512
2516
|
t,
|
|
2513
2517
|
e,
|
|
2514
2518
|
n
|
|
@@ -2517,7 +2521,7 @@ async function Bn(t) {
|
|
|
2517
2521
|
forForm: !0
|
|
2518
2522
|
});
|
|
2519
2523
|
return {
|
|
2520
|
-
creates: [
|
|
2524
|
+
creates: [Tn(a, c)],
|
|
2521
2525
|
modifies: [],
|
|
2522
2526
|
deletes: [],
|
|
2523
2527
|
components: [],
|
|
@@ -2525,28 +2529,32 @@ async function Bn(t) {
|
|
|
2525
2529
|
collections: i ? [qt(r, o, s)] : []
|
|
2526
2530
|
};
|
|
2527
2531
|
}
|
|
2528
|
-
const jn = "generate-resource",
|
|
2529
|
-
async function
|
|
2530
|
-
const e = await
|
|
2532
|
+
const jn = "generate-resource", Ln = "1.0.7", On = "src/patterns/generate/resource", qn = "/generate/resource";
|
|
2533
|
+
async function Vn(t) {
|
|
2534
|
+
const e = await Nn(t);
|
|
2531
2535
|
if (t.env !== "runtime")
|
|
2532
2536
|
return k(e);
|
|
2533
|
-
const { createCollections: n } = await import("./collections-
|
|
2537
|
+
const { createCollections: n } = await import("./collections-CVHa6B6X.js"), r = await n(
|
|
2534
2538
|
e.collections,
|
|
2535
2539
|
t
|
|
2536
2540
|
), o = {
|
|
2537
2541
|
...e,
|
|
2538
2542
|
creates: [...e.creates, ...r]
|
|
2539
|
-
}, { writeResult: s } = await import("./write-result-
|
|
2543
|
+
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
2540
2544
|
return s(await k(o), t);
|
|
2541
2545
|
}
|
|
2542
|
-
const
|
|
2543
|
-
version:
|
|
2546
|
+
const Un = {
|
|
2547
|
+
version: Ln,
|
|
2544
2548
|
slug: jn,
|
|
2545
|
-
source:
|
|
2549
|
+
source: On,
|
|
2546
2550
|
docs: qn,
|
|
2547
2551
|
plan: "open",
|
|
2548
2552
|
title: "Generate a resource",
|
|
2549
2553
|
summary: "Generates model schema resources.",
|
|
2554
|
+
requires: {
|
|
2555
|
+
auth: !1,
|
|
2556
|
+
payments: !1
|
|
2557
|
+
},
|
|
2550
2558
|
categories: ["data"],
|
|
2551
2559
|
tags: ["pocketbase", "resource", "schema"],
|
|
2552
2560
|
command: {
|
|
@@ -2555,28 +2563,26 @@ const Vn = {
|
|
|
2555
2563
|
argv: ["contact", "name:text", "email:email"]
|
|
2556
2564
|
},
|
|
2557
2565
|
baseline: "velastack",
|
|
2558
|
-
generate:
|
|
2566
|
+
generate: Vn
|
|
2559
2567
|
};
|
|
2560
|
-
var
|
|
2568
|
+
var Ct = Object.freeze, Hn = Object.defineProperty, Z = (t, e) => Ct(Hn(t, "raw", { value: Ct(e || t.slice()) })), _t, kt, Rt, Pt;
|
|
2561
2569
|
function Gn(t) {
|
|
2562
2570
|
const [e, ...n] = t;
|
|
2563
2571
|
if (!e)
|
|
2564
|
-
throw new Error(
|
|
2565
|
-
"Invalid command arguments. Expected: <model> [fields...]"
|
|
2566
|
-
);
|
|
2572
|
+
throw new Error("Invalid command arguments. Expected: <model> [fields...]");
|
|
2567
2573
|
return { modelPath: e, fields: n };
|
|
2568
2574
|
}
|
|
2569
|
-
function
|
|
2575
|
+
function C(t, e) {
|
|
2570
2576
|
return {
|
|
2571
2577
|
path: t,
|
|
2572
2578
|
language: j(t),
|
|
2573
2579
|
content: e
|
|
2574
2580
|
};
|
|
2575
2581
|
}
|
|
2576
|
-
function
|
|
2582
|
+
function Vt(t) {
|
|
2577
2583
|
return t.some((e) => e.type === "file");
|
|
2578
2584
|
}
|
|
2579
|
-
function
|
|
2585
|
+
function Ut(t) {
|
|
2580
2586
|
return [...new Set(t.filter(Boolean))];
|
|
2581
2587
|
}
|
|
2582
2588
|
function it(t) {
|
|
@@ -2587,20 +2593,20 @@ function it(t) {
|
|
|
2587
2593
|
`);
|
|
2588
2594
|
}
|
|
2589
2595
|
function Ht(t, e) {
|
|
2590
|
-
return
|
|
2596
|
+
return Ot(t).map(
|
|
2591
2597
|
(n) => `const ${n.pluralName} = await ${e}.collection("${n.tableName}").getFullList();`
|
|
2592
2598
|
).join(`
|
|
2593
2599
|
`);
|
|
2594
2600
|
}
|
|
2595
2601
|
function Gt(t) {
|
|
2596
|
-
return
|
|
2602
|
+
return Ot(t).map((e) => e.pluralName).join(", ");
|
|
2597
2603
|
}
|
|
2598
|
-
function
|
|
2604
|
+
function Wn(t) {
|
|
2599
2605
|
return t.features.auth ? "locals.pb" : "locals.admin";
|
|
2600
2606
|
}
|
|
2601
|
-
function
|
|
2607
|
+
function Wt(t, e, n = !1) {
|
|
2602
2608
|
const r = it(e);
|
|
2603
|
-
return
|
|
2609
|
+
return d`
|
|
2604
2610
|
${r}
|
|
2605
2611
|
${n ? "let { data, params } = $props();" : "let { data } = $props();"}
|
|
2606
2612
|
|
|
@@ -2611,21 +2617,21 @@ function Kt(t, e, n = !1) {
|
|
|
2611
2617
|
const { form: formData } = form;
|
|
2612
2618
|
`;
|
|
2613
2619
|
}
|
|
2614
|
-
function
|
|
2615
|
-
const r = n.some((a) => a.type === "select"), o =
|
|
2620
|
+
function Jn(t, e, n) {
|
|
2621
|
+
const r = n.some((a) => a.type === "select"), o = Ut([
|
|
2616
2622
|
'import { untrack } from "svelte";',
|
|
2617
2623
|
'import { superForm } from "sveltekit-superforms";',
|
|
2618
2624
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
2619
2625
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2620
|
-
...nt(
|
|
2626
|
+
...nt(O(n)),
|
|
2621
2627
|
'import { Button } from "$lib/components/ui/button";',
|
|
2622
2628
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
2623
2629
|
'import * as Form from "$lib/components/ui/form";',
|
|
2624
2630
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2625
2631
|
]).join(`
|
|
2626
2632
|
`), s = n.map((a) => et(a)).join(`
|
|
2627
|
-
`), i =
|
|
2628
|
-
return
|
|
2633
|
+
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2634
|
+
return d(_t || (_t = Z([`
|
|
2629
2635
|
<script lang="ts">
|
|
2630
2636
|
`, `
|
|
2631
2637
|
`, `
|
|
@@ -2652,23 +2658,23 @@ function Wn(t, e, n) {
|
|
|
2652
2658
|
</form>
|
|
2653
2659
|
</div>
|
|
2654
2660
|
</section>
|
|
2655
|
-
`])), o,
|
|
2661
|
+
`])), o, Wt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2656
2662
|
}
|
|
2657
|
-
function
|
|
2658
|
-
const r = n.some((a) => a.type === "select"), o =
|
|
2663
|
+
function Zn(t, e, n) {
|
|
2664
|
+
const r = n.some((a) => a.type === "select"), o = Ut([
|
|
2659
2665
|
'import { untrack } from "svelte";',
|
|
2660
2666
|
'import { superForm } from "sveltekit-superforms";',
|
|
2661
2667
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
2662
2668
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2663
|
-
...nt(
|
|
2669
|
+
...nt(O(n)),
|
|
2664
2670
|
'import { Button } from "$lib/components/ui/button";',
|
|
2665
2671
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
2666
2672
|
'import * as Form from "$lib/components/ui/form";',
|
|
2667
2673
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2668
2674
|
]).join(`
|
|
2669
2675
|
`), s = n.map((a) => et(a)).join(`
|
|
2670
|
-
`), i =
|
|
2671
|
-
return
|
|
2676
|
+
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2677
|
+
return d(kt || (kt = Z([`
|
|
2672
2678
|
<script lang="ts">
|
|
2673
2679
|
`, `
|
|
2674
2680
|
`, `
|
|
@@ -2722,12 +2728,12 @@ function Xn(t, e, n) {
|
|
|
2722
2728
|
</form>
|
|
2723
2729
|
</div>
|
|
2724
2730
|
</section>
|
|
2725
|
-
`])), o,
|
|
2731
|
+
`])), o, Wt(t, n, !0), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2726
2732
|
}
|
|
2727
|
-
function
|
|
2733
|
+
function Xn(t, e, n) {
|
|
2728
2734
|
const r = n.some((a) => a.type === "select"), o = r ? `${it(n)}` : "", s = n.map((a) => {
|
|
2729
2735
|
let c = "{ getValue }", m = "{ value: getValue() }";
|
|
2730
|
-
return a.type === "relation" && (c = "{ getValue, row }", m = `{ value: getValue(), expanded: row.original.expand?.${a.name}, displayField: "${a.displayField}" }`), a.type === "select" && (m = `{ value: getValue(), options: ${a.name}Labels }`), a.type === "file" && (c = "{ getValue, row }", m = "{ value: getValue(), collectionId: row.original.collectionId, id: row.original.id }"),
|
|
2736
|
+
return a.type === "relation" && (c = "{ getValue, row }", m = `{ value: getValue(), expanded: row.original.expand?.${a.name}, displayField: "${a.displayField}" }`), a.type === "select" && (m = `{ value: getValue(), options: ${a.name}Labels }`), a.type === "file" && (c = "{ getValue, row }", m = "{ value: getValue(), collectionId: row.original.collectionId, id: row.original.id }"), d`
|
|
2731
2737
|
columnHelper.accessor("${a.name}", {
|
|
2732
2738
|
header: ({ column }) => renderComponent(ColumnHeader, { column, title: "${a.title}" }),
|
|
2733
2739
|
cell: (${c}) => renderComponent(Cells.${a.type.charAt(0).toUpperCase() + a.type.slice(1)}Cell, ${m})
|
|
@@ -2738,7 +2744,7 @@ function Yn(t, e, n) {
|
|
|
2738
2744
|
(a) => `<FacetedFilter column={table.getColumn("${a.name}")!} title="${a.title}" options={Object.values(${a.name}Labels)} />`
|
|
2739
2745
|
).join(`
|
|
2740
2746
|
`);
|
|
2741
|
-
return
|
|
2747
|
+
return d(Rt || (Rt = Z([`
|
|
2742
2748
|
<script lang="ts">
|
|
2743
2749
|
import {
|
|
2744
2750
|
type ColumnFiltersState,
|
|
@@ -3114,25 +3120,25 @@ function Yn(t, e, n) {
|
|
|
3114
3120
|
</section>
|
|
3115
3121
|
`])), r ? 'import { FacetedFilter } from "$lib/components/ui/faceted-filter";' : "", o, t.tableName, s, n.length > 0 ? "," : "", e.list, e.list, e.list, t.pluralName, t.pluralDisplayName, e.new, t.displayName.toLowerCase(), t.pluralDisplayName.toLowerCase(), i, e.new, t.displayName.toLowerCase());
|
|
3116
3122
|
}
|
|
3117
|
-
function
|
|
3118
|
-
const r =
|
|
3119
|
-
return
|
|
3123
|
+
function Yn(t, e, n) {
|
|
3124
|
+
const r = Lt(e), o = r ? `{ expand: "${r}" }` : "";
|
|
3125
|
+
return d`
|
|
3120
3126
|
export const load = async ({ locals }) => {
|
|
3121
3127
|
const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${o});
|
|
3122
3128
|
return { ${t.pluralName} };
|
|
3123
3129
|
};
|
|
3124
3130
|
`;
|
|
3125
3131
|
}
|
|
3126
|
-
function
|
|
3132
|
+
function Kn(t, e, n, r, o) {
|
|
3127
3133
|
const s = Ht(n, r), i = Gt(n), a = i ? `, ${i}` : "", c = n.find(
|
|
3128
|
-
(
|
|
3129
|
-
), m = o && c ?
|
|
3134
|
+
(g) => g.type === "relation" && g.isCurrentUser
|
|
3135
|
+
), m = o && c ? d`
|
|
3130
3136
|
{
|
|
3131
3137
|
...form.data,
|
|
3132
3138
|
${c.name}: locals.pb.authStore.record?.id
|
|
3133
3139
|
}
|
|
3134
3140
|
` : "form.data";
|
|
3135
|
-
return
|
|
3141
|
+
return d`
|
|
3136
3142
|
import { fail, redirect } from "@sveltejs/kit";
|
|
3137
3143
|
import { superValidate } from "sveltekit-superforms";
|
|
3138
3144
|
import { zod } from "sveltekit-superforms/adapters";
|
|
@@ -3166,8 +3172,8 @@ function Zn(t, e, n, r, o) {
|
|
|
3166
3172
|
`;
|
|
3167
3173
|
}
|
|
3168
3174
|
function Qn(t, e, n, r) {
|
|
3169
|
-
const o =
|
|
3170
|
-
return
|
|
3175
|
+
const o = Lt(n), s = o ? `, { expand: "${o}" }` : "";
|
|
3176
|
+
return d`
|
|
3171
3177
|
import { error, redirect } from "@sveltejs/kit";
|
|
3172
3178
|
|
|
3173
3179
|
export const load = async ({ locals, params }) => {
|
|
@@ -3195,9 +3201,9 @@ function tr(t, e, n) {
|
|
|
3195
3201
|
o ? 'import CircleArrowRightIcon from "@lucide/svelte/icons/circle-arrow-right";' : "",
|
|
3196
3202
|
s ? 'import FileIcon from "@lucide/svelte/icons/file";' : ""
|
|
3197
3203
|
].filter(Boolean).join(`
|
|
3198
|
-
`), a = it(n), c = n.map((m) =>
|
|
3204
|
+
`), a = it(n), c = n.map((m) => Fe(t, m)).join(`
|
|
3199
3205
|
`);
|
|
3200
|
-
return
|
|
3206
|
+
return d(Pt || (Pt = Z([`
|
|
3201
3207
|
<script lang="ts">
|
|
3202
3208
|
`, `
|
|
3203
3209
|
`, `
|
|
@@ -3233,7 +3239,7 @@ function tr(t, e, n) {
|
|
|
3233
3239
|
}
|
|
3234
3240
|
function er(t, e, n, r) {
|
|
3235
3241
|
const o = Ht(n, r), s = Gt(n), i = s ? `, ${s}` : "";
|
|
3236
|
-
return
|
|
3242
|
+
return d`
|
|
3237
3243
|
import { error, fail, redirect } from "@sveltejs/kit";
|
|
3238
3244
|
import { setPocketbaseErrors, setDefaultData } from "@velastack/pocketbase";
|
|
3239
3245
|
import { superValidate } from "sveltekit-superforms";
|
|
@@ -3274,10 +3280,12 @@ function er(t, e, n, r) {
|
|
|
3274
3280
|
`;
|
|
3275
3281
|
}
|
|
3276
3282
|
async function nr(t, e, n) {
|
|
3277
|
-
|
|
3278
|
-
const r =
|
|
3283
|
+
W(e);
|
|
3284
|
+
const r = M(e, t), o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
3285
|
+
t
|
|
3286
|
+
);
|
|
3279
3287
|
if (n.length > 0) {
|
|
3280
|
-
const i = await
|
|
3288
|
+
const i = await J(n, r, t);
|
|
3281
3289
|
return {
|
|
3282
3290
|
model: r,
|
|
3283
3291
|
fields: i.fields,
|
|
@@ -3296,51 +3304,57 @@ async function nr(t, e, n) {
|
|
|
3296
3304
|
};
|
|
3297
3305
|
}
|
|
3298
3306
|
async function rr(t) {
|
|
3299
|
-
const { modelPath: e, fields: n } = Gn(t.argv), { model: r, fields: o, auth: s, shouldCreateCollection: i, collections: a } = await nr(t, e, n), c = qe(r), m =
|
|
3307
|
+
const { modelPath: e, fields: n } = Gn(t.argv), { model: r, fields: o, auth: s, shouldCreateCollection: i, collections: a } = await nr(t, e, n), c = qe(r), m = Ve(r), g = Wn(t), f = o.filter(
|
|
3300
3308
|
(u) => !(u.type === "relation" && u.isCurrentUser)
|
|
3301
|
-
),
|
|
3302
|
-
|
|
3309
|
+
), h = [
|
|
3310
|
+
C(
|
|
3303
3311
|
`src/lib/schemas/${r.name}.ts`,
|
|
3304
3312
|
ot(r, o, {
|
|
3305
3313
|
includeModelFields: !0,
|
|
3306
3314
|
forForm: !0
|
|
3307
3315
|
})
|
|
3308
3316
|
),
|
|
3309
|
-
|
|
3317
|
+
C(
|
|
3310
3318
|
`${c.list}/+page.server.ts`,
|
|
3311
|
-
|
|
3319
|
+
Yn(r, f, g)
|
|
3312
3320
|
),
|
|
3313
|
-
|
|
3321
|
+
C(
|
|
3314
3322
|
`${c.list}/+page.svelte`,
|
|
3315
|
-
|
|
3323
|
+
Xn(r, m, f)
|
|
3316
3324
|
),
|
|
3317
|
-
|
|
3325
|
+
C(
|
|
3318
3326
|
`${c.new}/+page.server.ts`,
|
|
3319
|
-
|
|
3327
|
+
Kn(r, m, f, g, t.features.auth)
|
|
3320
3328
|
),
|
|
3321
|
-
|
|
3322
|
-
|
|
3329
|
+
C(`${c.new}/+page.svelte`, Jn(r, m, f)),
|
|
3330
|
+
C(
|
|
3323
3331
|
`${c.show}/+page.server.ts`,
|
|
3324
|
-
Qn(r, m, f,
|
|
3332
|
+
Qn(r, m, f, g)
|
|
3325
3333
|
),
|
|
3326
|
-
|
|
3334
|
+
C(
|
|
3327
3335
|
`${c.show}/+page.svelte`,
|
|
3328
3336
|
tr(r, m, f)
|
|
3329
3337
|
),
|
|
3330
|
-
|
|
3338
|
+
C(
|
|
3331
3339
|
`${c.edit}/+page.server.ts`,
|
|
3332
|
-
er(r, m, f,
|
|
3340
|
+
er(r, m, f, g)
|
|
3333
3341
|
),
|
|
3334
|
-
|
|
3342
|
+
C(
|
|
3335
3343
|
`${c.edit}/+page.svelte`,
|
|
3336
|
-
|
|
3344
|
+
Zn(r, m, f)
|
|
3337
3345
|
),
|
|
3338
|
-
|
|
3346
|
+
C(
|
|
3339
3347
|
`${c.list}/server.test.ts`,
|
|
3340
|
-
cn(
|
|
3348
|
+
cn(
|
|
3349
|
+
r,
|
|
3350
|
+
m,
|
|
3351
|
+
o,
|
|
3352
|
+
t,
|
|
3353
|
+
a
|
|
3354
|
+
)
|
|
3341
3355
|
)
|
|
3342
|
-
],
|
|
3343
|
-
...
|
|
3356
|
+
], $ = [
|
|
3357
|
+
...O(f),
|
|
3344
3358
|
"button",
|
|
3345
3359
|
"table",
|
|
3346
3360
|
"data-table",
|
|
@@ -3358,11 +3372,11 @@ async function rr(t) {
|
|
|
3358
3372
|
"row-actions"
|
|
3359
3373
|
];
|
|
3360
3374
|
return {
|
|
3361
|
-
creates:
|
|
3375
|
+
creates: h,
|
|
3362
3376
|
modifies: [],
|
|
3363
3377
|
deletes: [],
|
|
3364
|
-
components: [...new Set(
|
|
3365
|
-
packages: [],
|
|
3378
|
+
components: [...new Set($)],
|
|
3379
|
+
packages: ["@tanstack/table-core"],
|
|
3366
3380
|
collections: i ? [qt(r, o, s)] : []
|
|
3367
3381
|
};
|
|
3368
3382
|
}
|
|
@@ -3371,13 +3385,13 @@ async function lr(t) {
|
|
|
3371
3385
|
const e = await rr(t);
|
|
3372
3386
|
if (t.env !== "runtime")
|
|
3373
3387
|
return k(e);
|
|
3374
|
-
const { createCollections: n } = await import("./collections-
|
|
3388
|
+
const { createCollections: n } = await import("./collections-CVHa6B6X.js"), r = await n(
|
|
3375
3389
|
e.collections,
|
|
3376
3390
|
t
|
|
3377
3391
|
), o = {
|
|
3378
3392
|
...e,
|
|
3379
3393
|
creates: [...e.creates, ...r]
|
|
3380
|
-
}, { writeResult: s } = await import("./write-result-
|
|
3394
|
+
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
3381
3395
|
return s(await k(o), t);
|
|
3382
3396
|
}
|
|
3383
3397
|
const cr = {
|
|
@@ -3388,6 +3402,10 @@ const cr = {
|
|
|
3388
3402
|
plan: "open",
|
|
3389
3403
|
title: "Generate a scaffold",
|
|
3390
3404
|
summary: "Generates CRUD routes and schema.",
|
|
3405
|
+
requires: {
|
|
3406
|
+
auth: !1,
|
|
3407
|
+
payments: !1
|
|
3408
|
+
},
|
|
3391
3409
|
categories: ["data", "forms"],
|
|
3392
3410
|
tags: ["crud", "scaffold", "pocketbase", "sveltekit"],
|
|
3393
3411
|
command: {
|
|
@@ -3413,18 +3431,18 @@ function ur(t, e) {
|
|
|
3413
3431
|
content: e
|
|
3414
3432
|
};
|
|
3415
3433
|
}
|
|
3416
|
-
async function
|
|
3417
|
-
|
|
3418
|
-
const r =
|
|
3434
|
+
async function dr(t, e, n) {
|
|
3435
|
+
W(e);
|
|
3436
|
+
const r = M(e, t);
|
|
3419
3437
|
if (n.length > 0) {
|
|
3420
|
-
const i = await
|
|
3438
|
+
const i = await J(n, r, t);
|
|
3421
3439
|
return { model: r, fields: i.fields, includeModelFields: !1 };
|
|
3422
3440
|
}
|
|
3423
|
-
const o = t.env === "runtime" ? await (await import("./env.runtime-
|
|
3441
|
+
const o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
|
|
3424
3442
|
return { model: r, fields: s, includeModelFields: !0 };
|
|
3425
3443
|
}
|
|
3426
|
-
async function
|
|
3427
|
-
const { modelPath: e, fields: n } = mr(t.argv), { model: r, fields: o, includeModelFields: s } = await
|
|
3444
|
+
async function pr(t) {
|
|
3445
|
+
const { modelPath: e, fields: n } = mr(t.argv), { model: r, fields: o, includeModelFields: s } = await dr(
|
|
3428
3446
|
t,
|
|
3429
3447
|
e,
|
|
3430
3448
|
n
|
|
@@ -3441,22 +3459,26 @@ async function dr(t) {
|
|
|
3441
3459
|
collections: []
|
|
3442
3460
|
};
|
|
3443
3461
|
}
|
|
3444
|
-
const fr = "generate-schema",
|
|
3462
|
+
const fr = "generate-schema", gr = "1.0.7", hr = "src/patterns/generate/schema", br = "/generate/schema";
|
|
3445
3463
|
async function vr(t) {
|
|
3446
|
-
const e = await
|
|
3464
|
+
const e = await pr(t);
|
|
3447
3465
|
if (t.env !== "runtime")
|
|
3448
3466
|
return k(e);
|
|
3449
|
-
const { writeResult: n } = await import("./write-result-
|
|
3467
|
+
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
3450
3468
|
return n(await k(e), t);
|
|
3451
3469
|
}
|
|
3452
3470
|
const wr = {
|
|
3453
|
-
version:
|
|
3471
|
+
version: gr,
|
|
3454
3472
|
slug: fr,
|
|
3455
|
-
source:
|
|
3473
|
+
source: hr,
|
|
3456
3474
|
docs: br,
|
|
3457
3475
|
plan: "open",
|
|
3458
3476
|
title: "Generate a schema",
|
|
3459
3477
|
summary: "Generates a zod schema.",
|
|
3478
|
+
requires: {
|
|
3479
|
+
auth: !1,
|
|
3480
|
+
payments: !1
|
|
3481
|
+
},
|
|
3460
3482
|
categories: ["data"],
|
|
3461
3483
|
tags: ["zod", "schema", "pocketbase"],
|
|
3462
3484
|
command: {
|
|
@@ -3466,8 +3488,12 @@ const wr = {
|
|
|
3466
3488
|
},
|
|
3467
3489
|
baseline: "velastack",
|
|
3468
3490
|
generate: vr
|
|
3469
|
-
}, yr = `<script lang="ts"
|
|
3491
|
+
}, yr = `<script lang="ts">
|
|
3492
|
+
import type { ComponentProps } from 'svelte';
|
|
3470
3493
|
import HomeIcon from '@lucide/svelte/icons/home';
|
|
3494
|
+
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3495
|
+
import NavMain from './nav-main.svelte';
|
|
3496
|
+
import NavUser from './nav-user.svelte';
|
|
3471
3497
|
|
|
3472
3498
|
let data = {
|
|
3473
3499
|
navMain: [
|
|
@@ -3478,13 +3504,6 @@ const wr = {
|
|
|
3478
3504
|
}
|
|
3479
3505
|
]
|
|
3480
3506
|
};
|
|
3481
|
-
<\/script>
|
|
3482
|
-
|
|
3483
|
-
<script lang="ts">
|
|
3484
|
-
import NavMain from './nav-main.svelte';
|
|
3485
|
-
import NavUser from './nav-user.svelte';
|
|
3486
|
-
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3487
|
-
import type { ComponentProps } from 'svelte';
|
|
3488
3507
|
|
|
3489
3508
|
let {
|
|
3490
3509
|
user,
|
|
@@ -3522,7 +3541,7 @@ const wr = {
|
|
|
3522
3541
|
<NavUser {user} />
|
|
3523
3542
|
</Sidebar.Footer>
|
|
3524
3543
|
</Sidebar.Root>
|
|
3525
|
-
`,
|
|
3544
|
+
`, $r = `<script lang="ts">
|
|
3526
3545
|
import type { Component } from 'svelte';
|
|
3527
3546
|
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3528
3547
|
import { page } from '$app/state';
|
|
@@ -3562,9 +3581,17 @@ const wr = {
|
|
|
3562
3581
|
{/each}
|
|
3563
3582
|
</Sidebar.Menu>
|
|
3564
3583
|
</Sidebar.Group>
|
|
3565
|
-
`,
|
|
3584
|
+
`, xr = `<script lang="ts">
|
|
3585
|
+
import { toggleMode, mode } from 'mode-watcher';
|
|
3586
|
+
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
3566
3587
|
import Settings2Icon from '@lucide/svelte/icons/settings-2';
|
|
3567
|
-
|
|
3588
|
+
import LogOutIcon from '@lucide/svelte/icons/log-out';
|
|
3589
|
+
import MoonIcon from '@lucide/svelte/icons/moon';
|
|
3590
|
+
import SunIcon from '@lucide/svelte/icons/sun';
|
|
3591
|
+
import * as Avatar from '$lib/components/ui/avatar';
|
|
3592
|
+
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
3593
|
+
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3594
|
+
|
|
3568
3595
|
let data = {
|
|
3569
3596
|
navUser: [
|
|
3570
3597
|
{
|
|
@@ -3574,17 +3601,6 @@ const wr = {
|
|
|
3574
3601
|
}
|
|
3575
3602
|
]
|
|
3576
3603
|
};
|
|
3577
|
-
<\/script>
|
|
3578
|
-
|
|
3579
|
-
<script lang="ts">
|
|
3580
|
-
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
3581
|
-
import LogOutIcon from '@lucide/svelte/icons/log-out';
|
|
3582
|
-
import MoonIcon from '@lucide/svelte/icons/moon';
|
|
3583
|
-
import SunIcon from '@lucide/svelte/icons/sun';
|
|
3584
|
-
import * as Avatar from '$lib/components/ui/avatar';
|
|
3585
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
3586
|
-
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3587
|
-
import { toggleMode, mode } from 'mode-watcher';
|
|
3588
3604
|
|
|
3589
3605
|
let {
|
|
3590
3606
|
user
|
|
@@ -3681,192 +3697,12 @@ const wr = {
|
|
|
3681
3697
|
</DropdownMenu.Root>
|
|
3682
3698
|
</Sidebar.MenuItem>
|
|
3683
3699
|
</Sidebar.Menu>
|
|
3684
|
-
`,
|
|
3685
|
-
import { cn } from '$lib/utils';
|
|
3686
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3687
|
-
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3688
|
-
import { getContext } from 'svelte';
|
|
3689
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3690
|
-
|
|
3691
|
-
let {
|
|
3692
|
-
children,
|
|
3693
|
-
class: className,
|
|
3694
|
-
...restProps
|
|
3695
|
-
}: DropdownMenuPrimitive.ContentProps & {
|
|
3696
|
-
portalProps?: DropdownMenuPrimitive.PortalProps;
|
|
3697
|
-
} = $props();
|
|
3698
|
-
|
|
3699
|
-
let { isDesktop } =
|
|
3700
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3701
|
-
<\/script>
|
|
3702
|
-
|
|
3703
|
-
{#if isDesktop}
|
|
3704
|
-
<DropdownMenu.Content class={className} {...restProps}>
|
|
3705
|
-
{@render children?.()}
|
|
3706
|
-
</DropdownMenu.Content>
|
|
3707
|
-
{:else}
|
|
3708
|
-
<div class={cn('flex flex-col w-full', className)}>
|
|
3709
|
-
{@render children?.()}
|
|
3710
|
-
</div>
|
|
3711
|
-
{/if}
|
|
3712
|
-
`, Fr = `<script lang="ts">
|
|
3713
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3714
|
-
import { getContext } from 'svelte';
|
|
3715
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3716
|
-
let { isDesktop } =
|
|
3717
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3718
|
-
let { children, ...restProps } = $props();
|
|
3719
|
-
<\/script>
|
|
3720
|
-
|
|
3721
|
-
{#if isDesktop}
|
|
3722
|
-
<DropdownMenu.Group {...restProps}>
|
|
3723
|
-
{@render children?.()}
|
|
3724
|
-
</DropdownMenu.Group>
|
|
3725
|
-
{:else}
|
|
3726
|
-
{@render children?.()}
|
|
3727
|
-
{/if}
|
|
3728
|
-
`, Sr = `<script lang="ts">
|
|
3729
|
-
import { goto } from '$app/navigation';
|
|
3730
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
3731
|
-
import { Button } from '$lib/components/ui/button';
|
|
3732
|
-
import { getContext } from 'svelte';
|
|
3733
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3734
|
-
let { children, href = undefined, ...restProps } = $props();
|
|
3735
|
-
|
|
3736
|
-
const { isDesktop } =
|
|
3737
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3738
|
-
|
|
3739
|
-
const handleClick = () => {
|
|
3740
|
-
if (restProps.onclick) {
|
|
3741
|
-
restProps.onclick();
|
|
3742
|
-
} else {
|
|
3743
|
-
if (href) {
|
|
3744
|
-
goto(href);
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
};
|
|
3748
|
-
<\/script>
|
|
3749
|
-
|
|
3750
|
-
{#if isDesktop}
|
|
3751
|
-
<DropdownMenu.Item {...restProps} onclick={handleClick}>
|
|
3752
|
-
{@render children?.()}
|
|
3753
|
-
</DropdownMenu.Item>
|
|
3754
|
-
{:else}
|
|
3755
|
-
<Button
|
|
3756
|
-
class="w-full justify-start md:justify-center md:w-auto"
|
|
3757
|
-
variant="ghost"
|
|
3758
|
-
{href}
|
|
3759
|
-
{...restProps}
|
|
3760
|
-
>
|
|
3761
|
-
{@render children?.()}
|
|
3762
|
-
</Button>
|
|
3763
|
-
{/if}
|
|
3764
|
-
`, _r = `<script lang="ts">
|
|
3765
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3766
|
-
import { getContext } from 'svelte';
|
|
3767
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3768
|
-
const { isDesktop } =
|
|
3769
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3770
|
-
let { children, ...restProps } = $props();
|
|
3771
|
-
<\/script>
|
|
3772
|
-
|
|
3773
|
-
{#if isDesktop}
|
|
3774
|
-
<DropdownMenu.Label {...restProps}>
|
|
3775
|
-
{@render children?.()}
|
|
3776
|
-
</DropdownMenu.Label>
|
|
3777
|
-
{/if}
|
|
3778
|
-
`, kr = `<script lang="ts">
|
|
3779
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3780
|
-
import { getContext } from 'svelte';
|
|
3781
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3782
|
-
const { isDesktop } =
|
|
3783
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3784
|
-
let restProps = $props();
|
|
3785
|
-
<\/script>
|
|
3786
|
-
|
|
3787
|
-
{#if isDesktop}
|
|
3788
|
-
<DropdownMenu.Separator {...restProps} />
|
|
3789
|
-
{/if}
|
|
3790
|
-
`, Pr = `<script lang="ts">
|
|
3791
|
-
import { cn } from '$lib/utils';
|
|
3792
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3793
|
-
import { getContext } from 'svelte';
|
|
3794
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3795
|
-
let { class: className = '', ...restProps } = $props();
|
|
3796
|
-
|
|
3797
|
-
const { isDesktop } =
|
|
3798
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3799
|
-
<\/script>
|
|
3800
|
-
|
|
3801
|
-
{#if isDesktop}
|
|
3802
|
-
<DropdownMenu.Trigger class={cn('inline-flex', className)} {...restProps} />
|
|
3803
|
-
{/if}
|
|
3804
|
-
`, Mr = `<script lang="ts">
|
|
3805
|
-
import { page } from '$app/state';
|
|
3806
|
-
import { browser } from '$app/environment';
|
|
3807
|
-
import { onMount, setContext } from 'svelte';
|
|
3808
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3809
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3810
|
-
|
|
3811
|
-
let { user, guest } = $props();
|
|
3812
|
-
|
|
3813
|
-
const breakpoint = 768;
|
|
3814
|
-
const breakpointQuery = \`(min-width: \${breakpoint}px)\`;
|
|
3815
|
-
|
|
3816
|
-
let hasMounted = $state(false);
|
|
3817
|
-
let authMenuContext = $state<AuthMenuContext>({ isDesktop: true });
|
|
3818
|
-
|
|
3819
|
-
setContext(AUTH_MENU_CONTEXT_KEY, authMenuContext);
|
|
3820
|
-
|
|
3821
|
-
function updateIsDesktop() {
|
|
3822
|
-
if (!browser) return;
|
|
3823
|
-
authMenuContext.isDesktop = window.matchMedia(breakpointQuery).matches;
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3826
|
-
onMount(() => {
|
|
3827
|
-
updateIsDesktop();
|
|
3828
|
-
hasMounted = true;
|
|
3829
|
-
const mq = window.matchMedia(breakpointQuery);
|
|
3830
|
-
const listener = () => (authMenuContext.isDesktop = mq.matches);
|
|
3831
|
-
mq.addEventListener('change', listener);
|
|
3832
|
-
return () => mq.removeEventListener('change', listener);
|
|
3833
|
-
});
|
|
3834
|
-
<\/script>
|
|
3835
|
-
|
|
3836
|
-
{#if page.data.user}
|
|
3837
|
-
{#if authMenuContext.isDesktop}
|
|
3838
|
-
<DropdownMenu.Root>
|
|
3839
|
-
{@render user?.()}
|
|
3840
|
-
</DropdownMenu.Root>
|
|
3841
|
-
{:else}
|
|
3842
|
-
<!-- This prevents the menu from being rendered twice before we know if we're on desktop or not -->
|
|
3843
|
-
{#if hasMounted}
|
|
3844
|
-
{@render user?.()}
|
|
3845
|
-
{/if}
|
|
3846
|
-
{/if}
|
|
3847
|
-
{:else}
|
|
3848
|
-
{@render guest?.()}
|
|
3849
|
-
{/if}
|
|
3850
|
-
`, Rr = `export type AuthMenuContext = {
|
|
3851
|
-
isDesktop: boolean;
|
|
3852
|
-
};
|
|
3853
|
-
|
|
3854
|
-
export const AUTH_MENU_CONTEXT_KEY = Symbol('auth-menu-context');
|
|
3855
|
-
`, Er = `import Root from './auth-menu.svelte';
|
|
3856
|
-
import Content from './auth-menu-content.svelte';
|
|
3857
|
-
import Trigger from './auth-menu-trigger.svelte';
|
|
3858
|
-
import Group from './auth-menu-group.svelte';
|
|
3859
|
-
import Label from './auth-menu-label.svelte';
|
|
3860
|
-
import Separator from './auth-menu-separator.svelte';
|
|
3861
|
-
import Item from './auth-menu-item.svelte';
|
|
3862
|
-
|
|
3863
|
-
export { Root, Content, Trigger, Group, Label, Separator, Item };
|
|
3864
|
-
`, Ir = `import { z } from 'zod/v3';
|
|
3700
|
+
`, Fr = `import { z } from 'zod/v3';
|
|
3865
3701
|
|
|
3866
3702
|
export const changeEmailSchema = z.object({
|
|
3867
3703
|
email: z.string().email()
|
|
3868
3704
|
});
|
|
3869
|
-
`,
|
|
3705
|
+
`, Sr = `import { z } from 'zod/v3';
|
|
3870
3706
|
|
|
3871
3707
|
export const changePasswordSchema = z
|
|
3872
3708
|
.object({
|
|
@@ -3877,16 +3713,18 @@ export const changePasswordSchema = z
|
|
|
3877
3713
|
message: "Passwords don't match",
|
|
3878
3714
|
path: ['passwordConfirm']
|
|
3879
3715
|
});
|
|
3880
|
-
`,
|
|
3716
|
+
`, Cr = `import { z } from 'zod/v3';
|
|
3717
|
+
|
|
3881
3718
|
export const confirmEmailChangeSchema = z.object({
|
|
3882
3719
|
password: z.string()
|
|
3883
3720
|
});
|
|
3884
|
-
`,
|
|
3721
|
+
`, _r = `import { z } from 'zod/v3';
|
|
3722
|
+
|
|
3885
3723
|
export const confirmResetSchema = z.object({
|
|
3886
3724
|
password: z.string(),
|
|
3887
3725
|
passwordConfirm: z.string()
|
|
3888
3726
|
});
|
|
3889
|
-
`,
|
|
3727
|
+
`, kr = `import { z } from 'zod/v3';
|
|
3890
3728
|
|
|
3891
3729
|
const otpSchema = z.object({
|
|
3892
3730
|
type: z.literal('otp'),
|
|
@@ -3905,35 +3743,37 @@ const oAuth2Schema = z.object({
|
|
|
3905
3743
|
});
|
|
3906
3744
|
|
|
3907
3745
|
export const loginSchema = z.discriminatedUnion('type', [otpSchema, passwordSchema, oAuth2Schema]);
|
|
3908
|
-
`,
|
|
3746
|
+
`, Rr = `import { z } from 'zod/v3';
|
|
3747
|
+
|
|
3909
3748
|
export const otpSchema = z.object({
|
|
3910
3749
|
otp: z.string()
|
|
3911
3750
|
});
|
|
3912
|
-
`,
|
|
3751
|
+
`, Pr = `import { z } from 'zod/v3';
|
|
3913
3752
|
|
|
3914
3753
|
export const profileSchema = z.object({
|
|
3915
3754
|
name: z.string().optional(),
|
|
3916
3755
|
avatar: z.union([z.instanceof(File), z.string()]).optional(),
|
|
3917
3756
|
emailVisibility: z.boolean().optional()
|
|
3918
3757
|
});
|
|
3919
|
-
`,
|
|
3758
|
+
`, zr = `import { z } from 'zod/v3';
|
|
3759
|
+
|
|
3920
3760
|
export const resetSchema = z.object({
|
|
3921
3761
|
email: z.string().email()
|
|
3922
3762
|
});
|
|
3923
|
-
`,
|
|
3763
|
+
`, Mr = `import { z } from 'zod/v3';
|
|
3924
3764
|
|
|
3925
3765
|
export const signupSchema = z.object({
|
|
3926
3766
|
email: z.string().email(),
|
|
3927
3767
|
password: z.string(),
|
|
3928
3768
|
passwordConfirm: z.string()
|
|
3929
3769
|
});
|
|
3930
|
-
`,
|
|
3770
|
+
`, Ir = `export const load = ({ locals }) => {
|
|
3931
3771
|
const user = locals.pb.authStore.record!;
|
|
3932
3772
|
const breadcrumbs = [{ title: 'Home', url: '/dashboard' }];
|
|
3933
3773
|
|
|
3934
3774
|
return { user, breadcrumbs };
|
|
3935
3775
|
};
|
|
3936
|
-
`,
|
|
3776
|
+
`, Er = `<script lang="ts">
|
|
3937
3777
|
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3938
3778
|
import { Separator } from '$lib/components/ui/separator';
|
|
3939
3779
|
import AppSidebar from '$lib/components/app-sidebar.svelte';
|
|
@@ -3983,7 +3823,7 @@ export const signupSchema = z.object({
|
|
|
3983
3823
|
background-color: var(--color-sidebar);
|
|
3984
3824
|
}
|
|
3985
3825
|
</style>
|
|
3986
|
-
`,
|
|
3826
|
+
`, Br = "", Dr = `import { describe, it, expect } from 'vitest';
|
|
3987
3827
|
import type { Match } from '@velastack/pocketbase';
|
|
3988
3828
|
import type { RouteId } from './$types';
|
|
3989
3829
|
|
|
@@ -4000,14 +3840,14 @@ describe('dashboard', () => {
|
|
|
4000
3840
|
expect(response.status).toBe(200);
|
|
4001
3841
|
});
|
|
4002
3842
|
});
|
|
4003
|
-
`,
|
|
3843
|
+
`, Tr = `export const load = async ({ parent }) => {
|
|
4004
3844
|
const { breadcrumbs } = await parent();
|
|
4005
3845
|
|
|
4006
3846
|
return {
|
|
4007
3847
|
breadcrumbs: [...breadcrumbs, { title: 'Settings', url: '/settings' }]
|
|
4008
3848
|
};
|
|
4009
3849
|
};
|
|
4010
|
-
`,
|
|
3850
|
+
`, Ar = `import { superValidate, fail, withFiles } from 'sveltekit-superforms';
|
|
4011
3851
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4012
3852
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
4013
3853
|
import { profileSchema } from '$lib/schemas/profile';
|
|
@@ -4076,7 +3916,7 @@ export const actions = {
|
|
|
4076
3916
|
return {};
|
|
4077
3917
|
}
|
|
4078
3918
|
};
|
|
4079
|
-
`,
|
|
3919
|
+
`, Nr = `<script lang="ts">
|
|
4080
3920
|
import { untrack } from 'svelte';
|
|
4081
3921
|
import { superForm } from 'sveltekit-superforms';
|
|
4082
3922
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
|
@@ -4354,7 +4194,7 @@ export const actions = {
|
|
|
4354
4194
|
</form>
|
|
4355
4195
|
</div>
|
|
4356
4196
|
</div>
|
|
4357
|
-
`,
|
|
4197
|
+
`, jr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
4358
4198
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4359
4199
|
import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';
|
|
4360
4200
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4381,7 +4221,7 @@ export const actions = {
|
|
|
4381
4221
|
return redirect(303, '/login');
|
|
4382
4222
|
}
|
|
4383
4223
|
};
|
|
4384
|
-
`,
|
|
4224
|
+
`, Lr = `<script lang="ts">
|
|
4385
4225
|
import { untrack } from 'svelte';
|
|
4386
4226
|
import { Button } from '$lib/components/ui/button';
|
|
4387
4227
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4449,7 +4289,7 @@ export const actions = {
|
|
|
4449
4289
|
</div>
|
|
4450
4290
|
</div>
|
|
4451
4291
|
</div>
|
|
4452
|
-
`,
|
|
4292
|
+
`, Or = `import { describe, it, expect } from 'vitest';
|
|
4453
4293
|
import type { Match } from '@velastack/pocketbase';
|
|
4454
4294
|
import type { RouteId } from './$types';
|
|
4455
4295
|
|
|
@@ -4461,7 +4301,7 @@ describe('GET /confirm-email-change/[token]', () => {
|
|
|
4461
4301
|
expect(response.status).toBe(200);
|
|
4462
4302
|
});
|
|
4463
4303
|
});
|
|
4464
|
-
`,
|
|
4304
|
+
`, qr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
4465
4305
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4466
4306
|
import { confirmResetSchema } from '$lib/schemas/confirmReset';
|
|
4467
4307
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4490,7 +4330,7 @@ export const actions = {
|
|
|
4490
4330
|
return redirect(303, '/login');
|
|
4491
4331
|
}
|
|
4492
4332
|
};
|
|
4493
|
-
`,
|
|
4333
|
+
`, Vr = `<script lang="ts">
|
|
4494
4334
|
import { untrack } from 'svelte';
|
|
4495
4335
|
import { Button } from '$lib/components/ui/button';
|
|
4496
4336
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4574,7 +4414,7 @@ export const actions = {
|
|
|
4574
4414
|
</div>
|
|
4575
4415
|
</div>
|
|
4576
4416
|
</div>
|
|
4577
|
-
`,
|
|
4417
|
+
`, Ur = `import { describe, it, expect } from 'vitest';
|
|
4578
4418
|
import type { Match } from '@velastack/pocketbase';
|
|
4579
4419
|
import type { RouteId } from './$types';
|
|
4580
4420
|
|
|
@@ -4584,7 +4424,7 @@ describe('GET /confirm-reset/[token]', () => {
|
|
|
4584
4424
|
expect(response.status).toBe(200);
|
|
4585
4425
|
});
|
|
4586
4426
|
});
|
|
4587
|
-
`,
|
|
4427
|
+
`, Hr = `import { redirect } from '@sveltejs/kit';
|
|
4588
4428
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
4589
4429
|
|
|
4590
4430
|
export const GET = async ({ params, locals, cookies }) => {
|
|
@@ -4603,7 +4443,7 @@ export const GET = async ({ params, locals, cookies }) => {
|
|
|
4603
4443
|
setFlash({ type: 'toast', message }, cookies);
|
|
4604
4444
|
redirect(303, redirectPath);
|
|
4605
4445
|
};
|
|
4606
|
-
`,
|
|
4446
|
+
`, Gr = `import { describe, it, expect } from 'vitest';
|
|
4607
4447
|
import type { Match } from '@velastack/pocketbase';
|
|
4608
4448
|
import type { RouteId } from './$types';
|
|
4609
4449
|
|
|
@@ -4616,7 +4456,7 @@ describe('GET /confirm-verification/[token]', () => {
|
|
|
4616
4456
|
expect(response.headers['location']).toBe('/login');
|
|
4617
4457
|
});
|
|
4618
4458
|
});
|
|
4619
|
-
`,
|
|
4459
|
+
`, Wr = `import { fail, superValidate, message } from 'sveltekit-superforms';
|
|
4620
4460
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4621
4461
|
import { loginSchema } from '$lib/schemas/login';
|
|
4622
4462
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4677,7 +4517,7 @@ export const actions = {
|
|
|
4677
4517
|
redirect(303, redirectUrl);
|
|
4678
4518
|
}
|
|
4679
4519
|
};
|
|
4680
|
-
`,
|
|
4520
|
+
`, Jr = `<script lang="ts">
|
|
4681
4521
|
import { untrack } from 'svelte';
|
|
4682
4522
|
import { Button } from '$lib/components/ui/button';
|
|
4683
4523
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4860,7 +4700,7 @@ export const actions = {
|
|
|
4860
4700
|
</div>
|
|
4861
4701
|
</div>
|
|
4862
4702
|
</div>
|
|
4863
|
-
`,
|
|
4703
|
+
`, Zr = `import { describe, it, expect } from 'vitest';
|
|
4864
4704
|
import * as devalue from 'devalue';
|
|
4865
4705
|
import type { Match } from '@velastack/pocketbase';
|
|
4866
4706
|
import type { RouteId } from './$types';
|
|
@@ -4907,14 +4747,14 @@ describe('POST /login', () => {
|
|
|
4907
4747
|
expect(data.form.message.text).toBe('Failed to authenticate.');
|
|
4908
4748
|
});
|
|
4909
4749
|
});
|
|
4910
|
-
`,
|
|
4750
|
+
`, Xr = `import { redirect } from '@sveltejs/kit';
|
|
4911
4751
|
|
|
4912
4752
|
export const POST = ({ cookies, locals }) => {
|
|
4913
4753
|
locals.pb.authStore.clear();
|
|
4914
4754
|
locals.pb.authStore.clearCookie(cookies);
|
|
4915
4755
|
throw redirect(303, '/');
|
|
4916
4756
|
};
|
|
4917
|
-
`,
|
|
4757
|
+
`, Yr = `import { describe, it, expect } from 'vitest';
|
|
4918
4758
|
import type { Match } from '@velastack/pocketbase';
|
|
4919
4759
|
import type { RouteId } from './$types';
|
|
4920
4760
|
|
|
@@ -4926,7 +4766,7 @@ describe('POST /logout', () => {
|
|
|
4926
4766
|
expect(response.headers.location).toBe('/');
|
|
4927
4767
|
});
|
|
4928
4768
|
});
|
|
4929
|
-
`,
|
|
4769
|
+
`, Kr = `import { fail, message, superValidate } from 'sveltekit-superforms';
|
|
4930
4770
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4931
4771
|
import { otpSchema } from '$lib/schemas/otp';
|
|
4932
4772
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4967,7 +4807,7 @@ export const actions = {
|
|
|
4967
4807
|
redirect(303, redirectUrl);
|
|
4968
4808
|
}
|
|
4969
4809
|
};
|
|
4970
|
-
`,
|
|
4810
|
+
`, Qr = `<script lang="ts">
|
|
4971
4811
|
import { untrack } from 'svelte';
|
|
4972
4812
|
import { Button } from '$lib/components/ui/button';
|
|
4973
4813
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5033,7 +4873,7 @@ export const actions = {
|
|
|
5033
4873
|
</div>
|
|
5034
4874
|
</div>
|
|
5035
4875
|
</div>
|
|
5036
|
-
`,
|
|
4876
|
+
`, ta = `import { describe, it, expect } from 'vitest';
|
|
5037
4877
|
import type { Match } from '@velastack/pocketbase';
|
|
5038
4878
|
import type { RouteId } from './$types';
|
|
5039
4879
|
|
|
@@ -5053,7 +4893,7 @@ describe('POST /otp/[token]', () => {
|
|
|
5053
4893
|
expect(response.body.status).toBe(400);
|
|
5054
4894
|
});
|
|
5055
4895
|
});
|
|
5056
|
-
`,
|
|
4896
|
+
`, ea = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
5057
4897
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
5058
4898
|
import { resetSchema } from '$lib/schemas/reset';
|
|
5059
4899
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -5081,7 +4921,7 @@ export const actions = {
|
|
|
5081
4921
|
return { form };
|
|
5082
4922
|
}
|
|
5083
4923
|
};
|
|
5084
|
-
`,
|
|
4924
|
+
`, na = `<script lang="ts">
|
|
5085
4925
|
import { untrack } from 'svelte';
|
|
5086
4926
|
import { Button } from '$lib/components/ui/button';
|
|
5087
4927
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5148,7 +4988,7 @@ export const actions = {
|
|
|
5148
4988
|
</div>
|
|
5149
4989
|
</div>
|
|
5150
4990
|
</div>
|
|
5151
|
-
`,
|
|
4991
|
+
`, ra = `import { describe, it, expect } from 'vitest';
|
|
5152
4992
|
import type { Match } from '@velastack/pocketbase';
|
|
5153
4993
|
import type { RouteId } from './$types';
|
|
5154
4994
|
|
|
@@ -5168,7 +5008,7 @@ describe('POST /reset', () => {
|
|
|
5168
5008
|
expect(response.body.status).toBe(200);
|
|
5169
5009
|
});
|
|
5170
5010
|
});
|
|
5171
|
-
`,
|
|
5011
|
+
`, aa = `import { redirect } from '@sveltejs/kit';
|
|
5172
5012
|
import { fail, superValidate } from 'sveltekit-superforms';
|
|
5173
5013
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
5174
5014
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
@@ -5224,7 +5064,7 @@ export const actions = {
|
|
|
5224
5064
|
return redirect(303, redirectUrl);
|
|
5225
5065
|
}
|
|
5226
5066
|
};
|
|
5227
|
-
`,
|
|
5067
|
+
`, oa = `<script lang="ts">
|
|
5228
5068
|
import { untrack } from 'svelte';
|
|
5229
5069
|
import { Button } from '$lib/components/ui/button';
|
|
5230
5070
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5391,7 +5231,7 @@ export const actions = {
|
|
|
5391
5231
|
</div>
|
|
5392
5232
|
</div>
|
|
5393
5233
|
</div>
|
|
5394
|
-
`,
|
|
5234
|
+
`, sa = `import { describe, it, expect } from 'vitest';
|
|
5395
5235
|
import type { Match } from '@velastack/pocketbase';
|
|
5396
5236
|
import * as devalue from 'devalue';
|
|
5397
5237
|
import type { RouteId } from './$types';
|
|
@@ -5447,61 +5287,52 @@ describe('POST /signup', () => {
|
|
|
5447
5287
|
expect(data.form.errors.email[0]).toBe('Value must be unique.');
|
|
5448
5288
|
});
|
|
5449
5289
|
});
|
|
5450
|
-
`,
|
|
5290
|
+
`, ia = /* @__PURE__ */ Object.assign({
|
|
5451
5291
|
"./creates/src/lib/components/app-sidebar.svelte": yr,
|
|
5452
|
-
"./creates/src/lib/components/nav-main.svelte":
|
|
5453
|
-
"./creates/src/lib/components/nav-user.svelte":
|
|
5454
|
-
"./creates/src/lib/
|
|
5455
|
-
"./creates/src/lib/
|
|
5456
|
-
"./creates/src/lib/
|
|
5457
|
-
"./creates/src/lib/
|
|
5458
|
-
"./creates/src/lib/
|
|
5459
|
-
"./creates/src/lib/
|
|
5460
|
-
"./creates/src/lib/
|
|
5461
|
-
"./creates/src/lib/
|
|
5462
|
-
"./creates/src/lib/
|
|
5463
|
-
"./creates/src/
|
|
5464
|
-
"./creates/src/
|
|
5465
|
-
"./creates/src/
|
|
5466
|
-
"./creates/src/
|
|
5467
|
-
"./creates/src/
|
|
5468
|
-
"./creates/src/
|
|
5469
|
-
"./creates/src/
|
|
5470
|
-
"./creates/src/
|
|
5471
|
-
"./creates/src/
|
|
5472
|
-
"./creates/src/routes/(
|
|
5473
|
-
"./creates/src/routes/(
|
|
5474
|
-
"./creates/src/routes/(
|
|
5475
|
-
"./creates/src/routes/(
|
|
5476
|
-
"./creates/src/routes/(
|
|
5477
|
-
"./creates/src/routes/(
|
|
5478
|
-
"./creates/src/routes/(
|
|
5479
|
-
"./creates/src/routes/(public)/
|
|
5480
|
-
"./creates/src/routes/(public)/
|
|
5481
|
-
"./creates/src/routes/(public)/
|
|
5482
|
-
"./creates/src/routes/(public)/
|
|
5483
|
-
"./creates/src/routes/(public)/
|
|
5484
|
-
"./creates/src/routes/(public)/
|
|
5485
|
-
"./creates/src/routes/(public)/
|
|
5486
|
-
"./creates/src/routes/(public)/
|
|
5487
|
-
"./creates/src/routes/(public)/
|
|
5488
|
-
"./creates/src/routes/(public)/
|
|
5489
|
-
"./creates/src/routes/(public)/
|
|
5490
|
-
"./creates/src/routes/(public)/
|
|
5491
|
-
"./creates/src/routes/(public)/
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
"./creates/src/routes/(public)/reset/+page.svelte": ua,
|
|
5497
|
-
"./creates/src/routes/(public)/reset/server.test.ts": pa,
|
|
5498
|
-
"./creates/src/routes/(public)/signup/+page.server.ts": da,
|
|
5499
|
-
"./creates/src/routes/(public)/signup/+page.svelte": fa,
|
|
5500
|
-
"./creates/src/routes/(public)/signup/server.test.ts": ha
|
|
5501
|
-
}), ba = "./creates/";
|
|
5502
|
-
async function va(t) {
|
|
5503
|
-
const e = Object.entries(ga).map(([o, s]) => {
|
|
5504
|
-
const i = Et(o, ba);
|
|
5292
|
+
"./creates/src/lib/components/nav-main.svelte": $r,
|
|
5293
|
+
"./creates/src/lib/components/nav-user.svelte": xr,
|
|
5294
|
+
"./creates/src/lib/schemas/changeEmail.ts": Fr,
|
|
5295
|
+
"./creates/src/lib/schemas/changePassword.ts": Sr,
|
|
5296
|
+
"./creates/src/lib/schemas/confirmEmailChange.ts": Cr,
|
|
5297
|
+
"./creates/src/lib/schemas/confirmReset.ts": _r,
|
|
5298
|
+
"./creates/src/lib/schemas/login.ts": kr,
|
|
5299
|
+
"./creates/src/lib/schemas/otp.ts": Rr,
|
|
5300
|
+
"./creates/src/lib/schemas/profile.ts": Pr,
|
|
5301
|
+
"./creates/src/lib/schemas/reset.ts": zr,
|
|
5302
|
+
"./creates/src/lib/schemas/signup.ts": Mr,
|
|
5303
|
+
"./creates/src/routes/(app)/+layout.server.ts": Ir,
|
|
5304
|
+
"./creates/src/routes/(app)/+layout.svelte": Er,
|
|
5305
|
+
"./creates/src/routes/(app)/dashboard/+page.svelte": Br,
|
|
5306
|
+
"./creates/src/routes/(app)/dashboard/server.test.ts": Dr,
|
|
5307
|
+
"./creates/src/routes/(app)/settings/+layout.server.ts": Tr,
|
|
5308
|
+
"./creates/src/routes/(app)/settings/+page.server.ts": Ar,
|
|
5309
|
+
"./creates/src/routes/(app)/settings/+page.svelte": Nr,
|
|
5310
|
+
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.server.ts": jr,
|
|
5311
|
+
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.svelte": Lr,
|
|
5312
|
+
"./creates/src/routes/(public)/confirm-email-change/[token]/server.test.ts": Or,
|
|
5313
|
+
"./creates/src/routes/(public)/confirm-reset/[token]/+page.server.ts": qr,
|
|
5314
|
+
"./creates/src/routes/(public)/confirm-reset/[token]/+page.svelte": Vr,
|
|
5315
|
+
"./creates/src/routes/(public)/confirm-reset/[token]/server.test.ts": Ur,
|
|
5316
|
+
"./creates/src/routes/(public)/confirm-verification/[token]/+server.ts": Hr,
|
|
5317
|
+
"./creates/src/routes/(public)/confirm-verification/[token]/server.test.ts": Gr,
|
|
5318
|
+
"./creates/src/routes/(public)/login/+page.server.ts": Wr,
|
|
5319
|
+
"./creates/src/routes/(public)/login/+page.svelte": Jr,
|
|
5320
|
+
"./creates/src/routes/(public)/login/server.test.ts": Zr,
|
|
5321
|
+
"./creates/src/routes/(public)/logout/+server.ts": Xr,
|
|
5322
|
+
"./creates/src/routes/(public)/logout/server.test.ts": Yr,
|
|
5323
|
+
"./creates/src/routes/(public)/otp/[token]/+page.server.ts": Kr,
|
|
5324
|
+
"./creates/src/routes/(public)/otp/[token]/+page.svelte": Qr,
|
|
5325
|
+
"./creates/src/routes/(public)/otp/[token]/server.test.ts": ta,
|
|
5326
|
+
"./creates/src/routes/(public)/reset/+page.server.ts": ea,
|
|
5327
|
+
"./creates/src/routes/(public)/reset/+page.svelte": na,
|
|
5328
|
+
"./creates/src/routes/(public)/reset/server.test.ts": ra,
|
|
5329
|
+
"./creates/src/routes/(public)/signup/+page.server.ts": aa,
|
|
5330
|
+
"./creates/src/routes/(public)/signup/+page.svelte": oa,
|
|
5331
|
+
"./creates/src/routes/(public)/signup/server.test.ts": sa
|
|
5332
|
+
}), la = "./creates/";
|
|
5333
|
+
async function ca(t) {
|
|
5334
|
+
const e = Object.entries(ia).map(([o, s]) => {
|
|
5335
|
+
const i = Mt(o, la);
|
|
5505
5336
|
return {
|
|
5506
5337
|
path: i,
|
|
5507
5338
|
language: j(i),
|
|
@@ -5592,379 +5423,141 @@ async function va(t) {
|
|
|
5592
5423
|
]
|
|
5593
5424
|
};
|
|
5594
5425
|
}
|
|
5595
|
-
const
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
fields: [
|
|
5602
|
-
{
|
|
5603
|
-
autogeneratePattern: '[a-z0-9]{15}',
|
|
5604
|
-
hidden: false,
|
|
5605
|
-
id: 'text3208210256',
|
|
5606
|
-
max: 15,
|
|
5607
|
-
min: 15,
|
|
5608
|
-
name: 'id',
|
|
5609
|
-
pattern: '^[a-z0-9]+$',
|
|
5610
|
-
presentable: false,
|
|
5611
|
-
primaryKey: true,
|
|
5612
|
-
required: true,
|
|
5613
|
-
system: true,
|
|
5614
|
-
type: 'text'
|
|
5615
|
-
},
|
|
5616
|
-
{
|
|
5617
|
-
cascadeDelete: false,
|
|
5618
|
-
collectionId: '_pb_users_auth_',
|
|
5619
|
-
hidden: false,
|
|
5620
|
-
id: 'relation2375276105',
|
|
5621
|
-
maxSelect: 1,
|
|
5622
|
-
minSelect: 0,
|
|
5623
|
-
name: 'user',
|
|
5624
|
-
presentable: false,
|
|
5625
|
-
required: true,
|
|
5626
|
-
system: false,
|
|
5627
|
-
type: 'relation'
|
|
5628
|
-
},
|
|
5629
|
-
{
|
|
5630
|
-
autogeneratePattern: '',
|
|
5631
|
-
hidden: false,
|
|
5632
|
-
id: 'text1044722854',
|
|
5633
|
-
max: 0,
|
|
5634
|
-
min: 0,
|
|
5635
|
-
name: 'providerId',
|
|
5636
|
-
pattern: '',
|
|
5637
|
-
presentable: false,
|
|
5638
|
-
primaryKey: false,
|
|
5639
|
-
required: true,
|
|
5640
|
-
system: false,
|
|
5641
|
-
type: 'text'
|
|
5642
|
-
},
|
|
5643
|
-
{
|
|
5644
|
-
autogeneratePattern: '',
|
|
5645
|
-
hidden: false,
|
|
5646
|
-
id: 'text2462348188',
|
|
5647
|
-
max: 0,
|
|
5648
|
-
min: 0,
|
|
5649
|
-
name: 'provider',
|
|
5650
|
-
pattern: '',
|
|
5651
|
-
presentable: false,
|
|
5652
|
-
primaryKey: false,
|
|
5653
|
-
required: true,
|
|
5654
|
-
system: false,
|
|
5655
|
-
type: 'text'
|
|
5656
|
-
},
|
|
5657
|
-
{
|
|
5658
|
-
autogeneratePattern: '',
|
|
5659
|
-
hidden: false,
|
|
5660
|
-
id: 'text889886754',
|
|
5661
|
-
max: 0,
|
|
5662
|
-
min: 0,
|
|
5663
|
-
name: 'accessToken',
|
|
5664
|
-
pattern: '',
|
|
5665
|
-
presentable: false,
|
|
5666
|
-
primaryKey: false,
|
|
5667
|
-
required: false,
|
|
5668
|
-
system: false,
|
|
5669
|
-
type: 'text'
|
|
5670
|
-
},
|
|
5671
|
-
{
|
|
5672
|
-
autogeneratePattern: '',
|
|
5673
|
-
hidden: false,
|
|
5674
|
-
id: 'text1769204838',
|
|
5675
|
-
max: 0,
|
|
5676
|
-
min: 0,
|
|
5677
|
-
name: 'refreshToken',
|
|
5678
|
-
pattern: '',
|
|
5679
|
-
presentable: false,
|
|
5680
|
-
primaryKey: false,
|
|
5681
|
-
required: false,
|
|
5682
|
-
system: false,
|
|
5683
|
-
type: 'text'
|
|
5684
|
-
},
|
|
5685
|
-
{
|
|
5686
|
-
autogeneratePattern: '',
|
|
5687
|
-
hidden: false,
|
|
5688
|
-
id: 'text2192111876',
|
|
5689
|
-
max: 0,
|
|
5690
|
-
min: 0,
|
|
5691
|
-
name: 'avatarURL',
|
|
5692
|
-
pattern: '',
|
|
5693
|
-
presentable: false,
|
|
5694
|
-
primaryKey: false,
|
|
5695
|
-
required: false,
|
|
5696
|
-
system: false,
|
|
5697
|
-
type: 'text'
|
|
5698
|
-
},
|
|
5699
|
-
{
|
|
5700
|
-
hidden: false,
|
|
5701
|
-
id: 'date951064219',
|
|
5702
|
-
max: '',
|
|
5703
|
-
min: '',
|
|
5704
|
-
name: 'expiry',
|
|
5705
|
-
presentable: false,
|
|
5706
|
-
required: false,
|
|
5707
|
-
system: false,
|
|
5708
|
-
type: 'date'
|
|
5709
|
-
},
|
|
5710
|
-
{
|
|
5711
|
-
autogeneratePattern: '',
|
|
5712
|
-
hidden: false,
|
|
5713
|
-
id: 'text3885137012',
|
|
5714
|
-
max: 0,
|
|
5715
|
-
min: 0,
|
|
5716
|
-
name: 'email',
|
|
5717
|
-
pattern: '',
|
|
5718
|
-
presentable: false,
|
|
5719
|
-
primaryKey: false,
|
|
5720
|
-
required: false,
|
|
5721
|
-
system: false,
|
|
5722
|
-
type: 'text'
|
|
5723
|
-
},
|
|
5724
|
-
{
|
|
5725
|
-
autogeneratePattern: '',
|
|
5726
|
-
hidden: false,
|
|
5727
|
-
id: 'text1579384326',
|
|
5728
|
-
max: 0,
|
|
5729
|
-
min: 0,
|
|
5730
|
-
name: 'name',
|
|
5731
|
-
pattern: '',
|
|
5732
|
-
presentable: false,
|
|
5733
|
-
primaryKey: false,
|
|
5734
|
-
required: false,
|
|
5735
|
-
system: false,
|
|
5736
|
-
type: 'text'
|
|
5737
|
-
},
|
|
5738
|
-
{
|
|
5739
|
-
autogeneratePattern: '',
|
|
5740
|
-
hidden: false,
|
|
5741
|
-
id: 'text4166911607',
|
|
5742
|
-
max: 0,
|
|
5743
|
-
min: 0,
|
|
5744
|
-
name: 'username',
|
|
5745
|
-
pattern: '',
|
|
5746
|
-
presentable: false,
|
|
5747
|
-
primaryKey: false,
|
|
5748
|
-
required: false,
|
|
5749
|
-
system: false,
|
|
5750
|
-
type: 'text'
|
|
5751
|
-
},
|
|
5752
|
-
{
|
|
5753
|
-
hidden: false,
|
|
5754
|
-
id: 'json1646549047',
|
|
5755
|
-
maxSize: 0,
|
|
5756
|
-
name: 'rawUser',
|
|
5757
|
-
presentable: false,
|
|
5758
|
-
required: false,
|
|
5759
|
-
system: false,
|
|
5760
|
-
type: 'json'
|
|
5761
|
-
}
|
|
5762
|
-
],
|
|
5763
|
-
id: 'pbc_3445581863',
|
|
5764
|
-
indexes: [],
|
|
5765
|
-
listRule: '@request.auth.id = user.id',
|
|
5766
|
-
name: 'oauth_accounts',
|
|
5767
|
-
system: false,
|
|
5768
|
-
type: 'base',
|
|
5769
|
-
updateRule: null,
|
|
5770
|
-
viewRule: '@request.auth.id = user.id'
|
|
5771
|
-
});
|
|
5772
|
-
|
|
5773
|
-
return app.save(collection);
|
|
5774
|
-
},
|
|
5775
|
-
(app) => {
|
|
5776
|
-
const collection = app.findCollectionByNameOrId('pbc_3445581863');
|
|
5777
|
-
|
|
5778
|
-
return app.delete(collection);
|
|
5779
|
-
}
|
|
5780
|
-
);
|
|
5781
|
-
`, ya = `/// <reference path="../pb_data/types.d.ts" />
|
|
5782
|
-
migrate(
|
|
5783
|
-
(app) => {
|
|
5784
|
-
const collection = app.findCollectionByNameOrId('_pb_users_auth_');
|
|
5785
|
-
|
|
5786
|
-
// update collection data
|
|
5787
|
-
unmarshal(
|
|
5788
|
-
{
|
|
5789
|
-
confirmEmailChangeTemplate: {
|
|
5790
|
-
body: '<p>Hello,</p>\\n<p>Click on the button below to confirm your new email address.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/confirm-email-change/{TOKEN}" target="_blank" rel="noopener">Confirm new email</a>\\n</p>\\n<p><i>If you didn\\'t ask to change your email address, you can ignore this email.</i></p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5791
|
-
},
|
|
5792
|
-
createRule: '@request.auth.id = id',
|
|
5793
|
-
deleteRule: '@request.auth.id = id',
|
|
5794
|
-
listRule: '@request.auth.id = id',
|
|
5795
|
-
resetPasswordTemplate: {
|
|
5796
|
-
body: '<p>Hello,</p>\\n<p>Click on the button below to reset your password.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/confirm-password-reset/{TOKEN}" target="_blank" rel="noopener">Reset password</a>\\n</p>\\n<p><i>If you didn\\'t ask to reset your password, you can ignore this email.</i></p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5797
|
-
},
|
|
5798
|
-
updateRule: '@request.auth.id = id',
|
|
5799
|
-
verificationTemplate: {
|
|
5800
|
-
body: '<p>Hello,</p>\\n<p>Thank you for joining us at {APP_NAME}.</p>\\n<p>Click on the button below to verify your email address.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/confirm-verification/{TOKEN}" target="_blank" rel="noopener">Verify</a>\\n</p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5801
|
-
},
|
|
5802
|
-
viewRule: '@request.auth.id = id'
|
|
5803
|
-
},
|
|
5804
|
-
collection
|
|
5805
|
-
);
|
|
5806
|
-
|
|
5807
|
-
return app.save(collection);
|
|
5808
|
-
},
|
|
5809
|
-
(app) => {
|
|
5810
|
-
const collection = app.findCollectionByNameOrId('_pb_users_auth_');
|
|
5811
|
-
|
|
5812
|
-
// update collection data
|
|
5813
|
-
unmarshal(
|
|
5814
|
-
{
|
|
5815
|
-
confirmEmailChangeTemplate: {
|
|
5816
|
-
body: '<p>Hello,</p>\\n<p>Click on the button below to confirm your new email address.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}" target="_blank" rel="noopener">Confirm new email</a>\\n</p>\\n<p><i>If you didn\\'t ask to change your email address, you can ignore this email.</i></p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5817
|
-
},
|
|
5818
|
-
createRule: '',
|
|
5819
|
-
deleteRule: 'id = @request.auth.id',
|
|
5820
|
-
listRule: 'id = @request.auth.id',
|
|
5821
|
-
resetPasswordTemplate: {
|
|
5822
|
-
body: '<p>Hello,</p>\\n<p>Click on the button below to reset your password.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/_/#/auth/confirm-password-reset/{TOKEN}" target="_blank" rel="noopener">Reset password</a>\\n</p>\\n<p><i>If you didn\\'t ask to reset your password, you can ignore this email.</i></p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5823
|
-
},
|
|
5824
|
-
updateRule: 'id = @request.auth.id',
|
|
5825
|
-
verificationTemplate: {
|
|
5826
|
-
body: '<p>Hello,</p>\\n<p>Thank you for joining us at {APP_NAME}.</p>\\n<p>Click on the button below to verify your email address.</p>\\n<p>\\n <a class="btn" href="{APP_URL}/_/#/auth/confirm-verification/{TOKEN}" target="_blank" rel="noopener">Verify</a>\\n</p>\\n<p>\\n Thanks,<br/>\\n {APP_NAME} team\\n</p>'
|
|
5827
|
-
},
|
|
5828
|
-
viewRule: 'id = @request.auth.id'
|
|
5829
|
-
},
|
|
5830
|
-
collection
|
|
5831
|
-
);
|
|
5832
|
-
|
|
5833
|
-
return app.save(collection);
|
|
5834
|
-
}
|
|
5835
|
-
);
|
|
5836
|
-
`, xa = `import {
|
|
5837
|
-
POCKETBASE_URL,
|
|
5838
|
-
POCKETBASE_SUPERUSER_EMAIL,
|
|
5839
|
-
POCKETBASE_SUPERUSER_PASSWORD
|
|
5840
|
-
} from '$env/static/private';
|
|
5841
|
-
import { handlePocketbase } from '@velastack/pocketbase';
|
|
5426
|
+
const ma = `import {
|
|
5427
|
+
POCKETBASE_URL,
|
|
5428
|
+
POCKETBASE_SUPERUSER_EMAIL,
|
|
5429
|
+
POCKETBASE_SUPERUSER_PASSWORD,
|
|
5430
|
+
} from "$env/static/private";
|
|
5431
|
+
import { handlePocketbase } from "@velastack/pocketbase";
|
|
5842
5432
|
|
|
5843
5433
|
export const handle = handlePocketbase({
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5434
|
+
pocketbaseUrl: POCKETBASE_URL,
|
|
5435
|
+
superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
|
|
5436
|
+
superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,
|
|
5437
|
+
+ auth: { protectedRoutes: ["/(app)"] },
|
|
5848
5438
|
});
|
|
5849
|
-
`,
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5439
|
+
`, ua = `<script lang="ts">
|
|
5440
|
+
import { toggleMode } from "mode-watcher";
|
|
5441
|
+
import * as Navbar from "$lib/components/ui/navbar";
|
|
5442
|
+
import { Button } from "$lib/components/ui/button";
|
|
5443
|
+
+ import * as AuthMenu from "$lib/components/ui/auth-menu";
|
|
5444
|
+
+ import * as Avatar from "$lib/components/ui/avatar";
|
|
5855
5445
|
|
|
5856
|
-
|
|
5446
|
+
let { children, data } = $props();
|
|
5857
5447
|
<\/script>
|
|
5858
5448
|
|
|
5859
5449
|
<div class="min-h-dvh grid grid-rows-[max-content_1fr_max-content] root-layout">
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5450
|
+
<Navbar.Root>
|
|
5451
|
+
<Navbar.Brand href="/">
|
|
5452
|
+
<Navbar.Logo src="/favicon.svg" alt="Logo" />
|
|
5453
|
+
</Navbar.Brand>
|
|
5454
|
+
|
|
5455
|
+
<Navbar.MobileToggle />
|
|
5456
|
+
|
|
5457
|
+
<Navbar.List>
|
|
5458
|
+
<Navbar.Item>
|
|
5459
|
+
<Button
|
|
5460
|
+
class="w-full justify-start md:justify-center md:w-auto"
|
|
5461
|
+
href="/"
|
|
5462
|
+
variant="ghost"
|
|
5463
|
+
>
|
|
5464
|
+
Home
|
|
5465
|
+
</Button>
|
|
5466
|
+
</Navbar.Item>
|
|
5467
|
+
|
|
5468
|
+
+ <Navbar.Item
|
|
5469
|
+
+ class="flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4"
|
|
5470
|
+
+ >
|
|
5471
|
+
+ <AuthMenu.Root>
|
|
5472
|
+
+ {#snippet user()}
|
|
5473
|
+
+ <AuthMenu.Trigger>
|
|
5474
|
+
+ <Avatar.Root>
|
|
5475
|
+
+ {#if data.user?.avatar}
|
|
5476
|
+
+ <Avatar.Image
|
|
5477
|
+
+ src="/api/files/users/{data.user?.id}/{data.user?.avatar}"
|
|
5478
|
+
+ alt={data.user?.email}
|
|
5479
|
+
+ />
|
|
5480
|
+
+ {/if}
|
|
5481
|
+
+ <Avatar.Fallback>
|
|
5482
|
+
+ {data.user?.email?.charAt(0).toUpperCase()}
|
|
5483
|
+
+ </Avatar.Fallback>
|
|
5484
|
+
+ </Avatar.Root>
|
|
5485
|
+
+ </AuthMenu.Trigger>
|
|
5486
|
+
+
|
|
5487
|
+
+ <AuthMenu.Content align="end">
|
|
5488
|
+
+ <AuthMenu.Item href="/dashboard">Dashboard</AuthMenu.Item>
|
|
5489
|
+
+ <AuthMenu.Group>
|
|
5490
|
+
+ <AuthMenu.Item href="/settings">Settings</AuthMenu.Item>
|
|
5491
|
+
+ <AuthMenu.Item>
|
|
5492
|
+
+ <form action="/logout" method="post">
|
|
5493
|
+
+ <button type="submit" class="contents">Logout</button>
|
|
5494
|
+
+ </form>
|
|
5495
|
+
+ </AuthMenu.Item>
|
|
5496
|
+
+ </AuthMenu.Group>
|
|
5497
|
+
+ </AuthMenu.Content>
|
|
5498
|
+
+ {/snippet}
|
|
5499
|
+
+
|
|
5500
|
+
+ {#snippet guest()}
|
|
5501
|
+
+ <Button
|
|
5502
|
+
+ class="w-full justify-start md:justify-center md:w-auto"
|
|
5503
|
+
+ variant="ghost"
|
|
5504
|
+
+ href="/login">Login</Button
|
|
5505
|
+
+ >
|
|
5506
|
+
+ <Button
|
|
5507
|
+
+ class="w-full justify-start md:justify-center md:w-auto"
|
|
5508
|
+
+ variant="outline"
|
|
5509
|
+
+ href="/signup">Sign up</Button
|
|
5510
|
+
+ >
|
|
5511
|
+
+ {/snippet}
|
|
5512
|
+
+ </AuthMenu.Root>
|
|
5513
|
+
+ </Navbar.Item>
|
|
5514
|
+
</Navbar.List>
|
|
5515
|
+
</Navbar.Root>
|
|
5516
|
+
|
|
5517
|
+
{@render children?.()}
|
|
5518
|
+
|
|
5519
|
+
<footer class="border-t border-border py-4">
|
|
5520
|
+
<div
|
|
5521
|
+
class="mx-auto flex max-w-7xl px-4 flex-col items-center justify-between gap-3 sm:flex-row"
|
|
5522
|
+
>
|
|
5523
|
+
<p class="text-muted-foreground text-sm">
|
|
5524
|
+
© {new Date().getFullYear()}
|
|
5525
|
+
{data.meta.appName}. All rights reserved.
|
|
5526
|
+
</p>
|
|
5527
|
+
<nav class="flex items-center gap-4 text-sm">
|
|
5528
|
+
<Button onclick={toggleMode} variant="ghost" size="icon">
|
|
5529
|
+
<Navbar.Mode />
|
|
5530
|
+
</Button>
|
|
5531
|
+
<a href="/privacy" class="underline-offset-4 hover:underline">Privacy</a
|
|
5532
|
+
>
|
|
5533
|
+
<a href="/terms" class="underline-offset-4 hover:underline">Terms</a>
|
|
5534
|
+
</nav>
|
|
5535
|
+
</div>
|
|
5536
|
+
</footer>
|
|
5942
5537
|
</div>
|
|
5943
5538
|
|
|
5944
5539
|
<style lang="postcss">
|
|
5945
|
-
|
|
5540
|
+
@reference "tailwindcss";
|
|
5946
5541
|
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5542
|
+
.root-layout :global(section[data-role="content"]) {
|
|
5543
|
+
@apply container mx-auto max-w-7xl px-4 py-8 w-full;
|
|
5544
|
+
}
|
|
5950
5545
|
</style>
|
|
5951
|
-
`,
|
|
5546
|
+
`, da = `import { loadFlash } from "sveltekit-flash-message/server";
|
|
5952
5547
|
|
|
5953
5548
|
export const load = loadFlash(async ({ locals }) => {
|
|
5954
5549
|
return {
|
|
5955
|
-
user: locals.pb.authStore.record,
|
|
5550
|
+
+ user: locals.pb.authStore.record,
|
|
5956
5551
|
};
|
|
5957
5552
|
});
|
|
5958
|
-
`,
|
|
5959
|
-
"./preview-modifies/
|
|
5960
|
-
"./preview-modifies/
|
|
5961
|
-
"./preview-modifies/src/
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
const e = Object.entries(Fa).map(([n, r]) => {
|
|
5967
|
-
const o = Et(n, Sa);
|
|
5553
|
+
`, pa = /* @__PURE__ */ Object.assign({
|
|
5554
|
+
"./preview-modifies/src/hooks.server.ts": ma,
|
|
5555
|
+
"./preview-modifies/src/routes/(public)/root-layout.svelte": ua,
|
|
5556
|
+
"./preview-modifies/src/routes/+layout.server.ts": da
|
|
5557
|
+
}), fa = "./preview-modifies/";
|
|
5558
|
+
async function ga(t) {
|
|
5559
|
+
const e = Object.entries(pa).map(([n, r]) => {
|
|
5560
|
+
const o = Mt(n, fa);
|
|
5968
5561
|
return {
|
|
5969
5562
|
path: o,
|
|
5970
5563
|
language: j(o),
|
|
@@ -5980,27 +5573,31 @@ async function _a(t) {
|
|
|
5980
5573
|
collections: []
|
|
5981
5574
|
};
|
|
5982
5575
|
}
|
|
5983
|
-
const
|
|
5984
|
-
async function
|
|
5985
|
-
const e = await
|
|
5576
|
+
const ha = "enable-auth", ba = "1.0.7", va = "src/patterns/enable/auth", wa = "/enable/auth";
|
|
5577
|
+
async function ya(t) {
|
|
5578
|
+
const e = await ca(t);
|
|
5986
5579
|
if (t.env === "preview") {
|
|
5987
|
-
const s = await
|
|
5988
|
-
return k(
|
|
5580
|
+
const s = await ga();
|
|
5581
|
+
return k(dt([e, s]));
|
|
5989
5582
|
}
|
|
5990
|
-
const { generate: n } = await import("./generate.runtime-
|
|
5583
|
+
const { generate: n } = await import("./generate.runtime-Q3r4DJ7e.js"), r = await n(t), { writeResult: o } = await import("./write-result-CbUTMeAc.js");
|
|
5991
5584
|
return o(
|
|
5992
|
-
await k(
|
|
5585
|
+
await k(dt([e, r])),
|
|
5993
5586
|
t
|
|
5994
5587
|
);
|
|
5995
5588
|
}
|
|
5996
|
-
const
|
|
5997
|
-
version:
|
|
5998
|
-
slug:
|
|
5999
|
-
source:
|
|
6000
|
-
docs:
|
|
5589
|
+
const $a = {
|
|
5590
|
+
version: ba,
|
|
5591
|
+
slug: ha,
|
|
5592
|
+
source: va,
|
|
5593
|
+
docs: wa,
|
|
6001
5594
|
plan: "open",
|
|
6002
5595
|
title: "Enable authentication",
|
|
6003
5596
|
summary: "Enables authentication.",
|
|
5597
|
+
requires: {
|
|
5598
|
+
auth: !1,
|
|
5599
|
+
payments: !1
|
|
5600
|
+
},
|
|
6004
5601
|
categories: ["authentication"],
|
|
6005
5602
|
tags: [
|
|
6006
5603
|
"sveltekit",
|
|
@@ -6016,25 +5613,25 @@ const Ia = {
|
|
|
6016
5613
|
argv: []
|
|
6017
5614
|
},
|
|
6018
5615
|
baseline: "velastack",
|
|
6019
|
-
generate:
|
|
6020
|
-
},
|
|
6021
|
-
|
|
5616
|
+
generate: ya
|
|
5617
|
+
}, Jt = [
|
|
5618
|
+
Rn,
|
|
6022
5619
|
wr,
|
|
6023
|
-
|
|
5620
|
+
Un,
|
|
6024
5621
|
cr,
|
|
6025
|
-
|
|
6026
|
-
],
|
|
6027
|
-
|
|
6028
|
-
),
|
|
5622
|
+
$a
|
|
5623
|
+
], xa = Object.fromEntries(
|
|
5624
|
+
Jt.map((t) => [t.slug, t])
|
|
5625
|
+
), Ra = {
|
|
6029
5626
|
version: "0.1.0",
|
|
6030
|
-
patterns:
|
|
6031
|
-
bySlug:
|
|
5627
|
+
patterns: Jt,
|
|
5628
|
+
bySlug: xa
|
|
6032
5629
|
};
|
|
6033
5630
|
export {
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
5631
|
+
_a as D,
|
|
5632
|
+
ka as M,
|
|
5633
|
+
d,
|
|
5634
|
+
Ra as i,
|
|
6038
5635
|
j as l
|
|
6039
5636
|
};
|
|
6040
|
-
//# sourceMappingURL=index-
|
|
5637
|
+
//# sourceMappingURL=index-Dv0XurQu.js.map
|