@velastack/patterns 0.0.7 → 0.0.10
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-BaY_bexm.js → collections-Bo7ZRBqp.js} +3 -3
- package/dist/chunks/{collections-BaY_bexm.js.map → collections-Bo7ZRBqp.js.map} +1 -1
- package/dist/chunks/{env.runtime-C0w1qoWl.js → env.runtime-DhK42aCc.js} +2 -2
- package/dist/chunks/{env.runtime-C0w1qoWl.js.map → env.runtime-DhK42aCc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-vKonp83V.js → generate.runtime-BhWmEK-_.js} +3 -3
- package/dist/chunks/{generate.runtime-vKonp83V.js.map → generate.runtime-BhWmEK-_.js.map} +1 -1
- package/dist/chunks/{index-CDgw5XzM.js → index-DrD7d78j.js} +741 -1110
- package/dist/chunks/index-DrD7d78j.js.map +1 -0
- package/dist/chunks/{pocketbase-B1HjIB8v.js → pocketbase-ByyTgVI6.js} +2 -2
- package/dist/chunks/{pocketbase-B1HjIB8v.js.map → pocketbase-ByyTgVI6.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 +205 -19
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/index-CDgw5XzM.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
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 I(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">
|
|
@@ -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,18 +385,18 @@ 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:
|
|
394
394
|
return t;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
function
|
|
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,7 +404,7 @@ function Tt(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;
|
|
@@ -417,24 +417,24 @@ function O(t) {
|
|
|
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,12 +570,12 @@ 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}
|
|
@@ -588,9 +588,9 @@ function Fe(t, e) {
|
|
|
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 Fe(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 Fe(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,10 +636,10 @@ 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
|
-
const r = e[n], o =
|
|
642
|
+
const r = e[n], o = _e.exec(r);
|
|
643
643
|
if (o) {
|
|
644
644
|
const s = o.index + (o[1] ?? o[2]).length;
|
|
645
645
|
e.splice(n, 1, r.slice(0, s), r.slice(s));
|
|
@@ -647,27 +647,27 @@ 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
|
|
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 =
|
|
654
|
+
function A(t, e) {
|
|
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
|
|
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 =
|
|
658
|
+
function Pe(t, e) {
|
|
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
|
}
|
|
662
662
|
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
|
-
return n + r.map(
|
|
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);
|
|
@@ -675,17 +675,17 @@ function H(t) {
|
|
|
675
675
|
function at(t) {
|
|
676
676
|
return (e) => e.toLocaleUpperCase(t);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function Ie(t, e) {
|
|
679
679
|
return (n) => `${e(n[0])}${t(n.slice(1))}`;
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function Dt(t, e) {
|
|
682
682
|
return (n, r) => {
|
|
683
683
|
const o = n[0];
|
|
684
684
|
return (r > 0 && o >= "0" && o <= "9" ? "_" + o : e(o)) + t(n.slice(1));
|
|
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
|
|
719
|
-
})(
|
|
718
|
+
typeof Be == "function" ? t.exports = r() : n.pluralize = r();
|
|
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 F = m(
|
|
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 F = w[
|
|
743
|
-
if (F[0].test(
|
|
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 F =
|
|
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
|
|
753
|
+
function $(l, p, w, x) {
|
|
754
754
|
return function(F) {
|
|
755
|
-
var
|
|
756
|
-
return
|
|
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 De() {
|
|
|
1009
1009
|
/sheep$/i
|
|
1010
1010
|
].forEach(u.addUncountableRule), u;
|
|
1011
1011
|
});
|
|
1012
|
-
})(
|
|
1012
|
+
})(U)), U.exports;
|
|
1013
1013
|
}
|
|
1014
|
-
var
|
|
1015
|
-
const
|
|
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",
|
|
@@ -1113,28 +1113,28 @@ const S = /* @__PURE__ */ ze(Ne), $a = "data", Fa = "migrations", Be = "(app)",
|
|
|
1113
1113
|
arguments: "args",
|
|
1114
1114
|
constructor: "ctor"
|
|
1115
1115
|
};
|
|
1116
|
-
function
|
|
1116
|
+
function K(t) {
|
|
1117
1117
|
return je.has(t) ? Le[t] ?? `${t}_` : t;
|
|
1118
1118
|
}
|
|
1119
|
-
function
|
|
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
1125
|
function Oe(t) {
|
|
1126
|
-
return t.features.auth ? `src/routes/${
|
|
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 =
|
|
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
1139
|
routesDir: Oe(e)
|
|
1140
1140
|
};
|
|
@@ -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",
|
|
@@ -1217,10 +1217,10 @@ const We = [
|
|
|
1217
1217
|
"account",
|
|
1218
1218
|
"creator"
|
|
1219
1219
|
];
|
|
1220
|
-
function
|
|
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,15 +1228,15 @@ function gt(t) {
|
|
|
1228
1228
|
operator: "="
|
|
1229
1229
|
};
|
|
1230
1230
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const r = new Set((n.authCollections ?? ["users"]).map(
|
|
1233
|
-
(n.userFieldHints ??
|
|
1231
|
+
function Ze(t, e, n = {}) {
|
|
1232
|
+
const r = new Set((n.authCollections ?? ["users"]).map(D)), o = new Set(
|
|
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
|
|
1239
|
-
if (r.has(
|
|
1238
|
+
return ht(e);
|
|
1239
|
+
if (r.has(D(e)))
|
|
1240
1240
|
return {
|
|
1241
1241
|
rule: "@request.auth.id = id",
|
|
1242
1242
|
ownershipChainCollections: [e],
|
|
@@ -1244,68 +1244,68 @@ function Xe(t, e, n = {}) {
|
|
|
1244
1244
|
operator: "="
|
|
1245
1245
|
};
|
|
1246
1246
|
function c(b) {
|
|
1247
|
-
const v =
|
|
1247
|
+
const v = D(b);
|
|
1248
1248
|
return v === "user" ? 50 : o.has(v) ? 20 : 0;
|
|
1249
1249
|
}
|
|
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
|
|
1268
|
-
return r.has(
|
|
1267
|
+
function g(b) {
|
|
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} ${
|
|
1302
|
+
rule: `@request.auth.id ${lt} ${Xt}${Zt}.id`,
|
|
1303
1303
|
ownershipChainCollections: F,
|
|
1304
|
-
ownershipChainFields:
|
|
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,42 +1418,42 @@ 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
|
}
|
|
1430
1430
|
function yt(t) {
|
|
1431
|
-
const e =
|
|
1431
|
+
const e = _.singular(t), n = _.plural(e);
|
|
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
|
);
|
|
@@ -1497,16 +1497,16 @@ function Qe(t, e, n, r, o) {
|
|
|
1497
1497
|
maxSelect: yt(t)
|
|
1498
1498
|
};
|
|
1499
1499
|
if (i === "relation") {
|
|
1500
|
-
const u =
|
|
1500
|
+
const u = _.singular(t), l = _.plural(u);
|
|
1501
1501
|
if (!m.includes(l))
|
|
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 (
|
|
1541
|
-
const u =
|
|
1540
|
+
if (h.includes(i)) {
|
|
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-DhK42aCc.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,20 +1987,18 @@ 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
|
-
pagePath:
|
|
1995
|
-
pageUrl:
|
|
1994
|
+
pagePath: r,
|
|
1995
|
+
pageUrl: o
|
|
1996
1996
|
};
|
|
1997
1997
|
}
|
|
1998
1998
|
function fn(t) {
|
|
1999
1999
|
const [e, ...n] = t;
|
|
2000
2000
|
if (!e)
|
|
2001
|
-
throw new Error(
|
|
2002
|
-
"Invalid command arguments. Expected: <model> <fields...>"
|
|
2003
|
-
);
|
|
2001
|
+
throw new Error("Invalid command arguments. Expected: <model> <fields...>");
|
|
2004
2002
|
if (n.length === 0)
|
|
2005
2003
|
throw new Error("At least one field definition is required.");
|
|
2006
2004
|
return { modelPath: e, fields: n };
|
|
@@ -2008,10 +2006,10 @@ function fn(t) {
|
|
|
2008
2006
|
function jt(t) {
|
|
2009
2007
|
return t.some((e) => e.type === "file");
|
|
2010
2008
|
}
|
|
2011
|
-
function
|
|
2009
|
+
function gn(t) {
|
|
2012
2010
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2013
2011
|
}
|
|
2014
|
-
function
|
|
2012
|
+
function St(t) {
|
|
2015
2013
|
const e = t.type === "select" ? `[${t.options.map((o) => JSON.stringify(o.value)).join(", ")}]` : "";
|
|
2016
2014
|
let n;
|
|
2017
2015
|
switch (t.type) {
|
|
@@ -2067,13 +2065,13 @@ function Ct(t) {
|
|
|
2067
2065
|
}
|
|
2068
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()`;
|
|
2069
2067
|
}
|
|
2070
|
-
function
|
|
2068
|
+
function hn(t) {
|
|
2071
2069
|
const e = [];
|
|
2072
2070
|
for (const n of t) {
|
|
2073
2071
|
if (n.type === "file" && n.maxSelect > 1) {
|
|
2074
2072
|
e.push({
|
|
2075
2073
|
name: n.name,
|
|
2076
|
-
schema:
|
|
2074
|
+
schema: St({ ...n, required: !1 })
|
|
2077
2075
|
}), e.push({
|
|
2078
2076
|
name: `${n.name}+`,
|
|
2079
2077
|
schema: "z.instanceof(File).array().optional()"
|
|
@@ -2083,14 +2081,14 @@ function gn(t) {
|
|
|
2083
2081
|
});
|
|
2084
2082
|
continue;
|
|
2085
2083
|
}
|
|
2086
|
-
e.push({ name: n.name, schema:
|
|
2084
|
+
e.push({ name: n.name, schema: St(n) });
|
|
2087
2085
|
}
|
|
2088
2086
|
return e;
|
|
2089
2087
|
}
|
|
2090
2088
|
function bn(t, e) {
|
|
2091
|
-
const n =
|
|
2089
|
+
const n = hn(e).map((r) => `${gn(r.name)}: ${r.schema}`).join(`,
|
|
2092
2090
|
`);
|
|
2093
|
-
return
|
|
2091
|
+
return d`
|
|
2094
2092
|
import { z } from "zod/v3";
|
|
2095
2093
|
|
|
2096
2094
|
export const ${t.schemaName} = z.object({
|
|
@@ -2111,10 +2109,10 @@ function vn(t, e) {
|
|
|
2111
2109
|
function wn(t, e) {
|
|
2112
2110
|
const r = e.filter(
|
|
2113
2111
|
(o) => o.type === "select"
|
|
2114
|
-
).map((o) =>
|
|
2112
|
+
).map((o) => It(o)).join(`
|
|
2115
2113
|
|
|
2116
2114
|
`);
|
|
2117
|
-
return
|
|
2115
|
+
return d`
|
|
2118
2116
|
${r}
|
|
2119
2117
|
|
|
2120
2118
|
const form = superForm(untrack(() => data.form), {
|
|
@@ -2128,7 +2126,7 @@ function yn(t, e) {
|
|
|
2128
2126
|
const n = vn(t, e).join(`
|
|
2129
2127
|
`), r = wn(t, e), o = e.map((i) => et(i)).join(`
|
|
2130
2128
|
`), s = jt(e) ? ' enctype="multipart/form-data"' : "";
|
|
2131
|
-
return
|
|
2129
|
+
return d(Ft || (Ft = dn([`
|
|
2132
2130
|
<script lang="ts">
|
|
2133
2131
|
`, `
|
|
2134
2132
|
|
|
@@ -2153,14 +2151,14 @@ function yn(t, e) {
|
|
|
2153
2151
|
</section>
|
|
2154
2152
|
`])), n, r, t.displayName, s, o);
|
|
2155
2153
|
}
|
|
2156
|
-
function
|
|
2157
|
-
const n = jt(e), r =
|
|
2154
|
+
function $n(t, e) {
|
|
2155
|
+
const n = jt(e), r = d`
|
|
2158
2156
|
import { fail, superValidate${n ? ", withFiles" : ""} } from "sveltekit-superforms";
|
|
2159
2157
|
import { zod } from "sveltekit-superforms/adapters";
|
|
2160
2158
|
import { ${t.schemaName} } from "$lib/schemas/${t.name}";
|
|
2161
2159
|
import { setFlash } from "sveltekit-flash-message/server";
|
|
2162
2160
|
`;
|
|
2163
|
-
return
|
|
2161
|
+
return d`
|
|
2164
2162
|
${r}
|
|
2165
2163
|
|
|
2166
2164
|
export const load = async () => {
|
|
@@ -2183,46 +2181,62 @@ function xn(t, e) {
|
|
|
2183
2181
|
};
|
|
2184
2182
|
`;
|
|
2185
2183
|
}
|
|
2186
|
-
function
|
|
2184
|
+
function V(t, e) {
|
|
2187
2185
|
return {
|
|
2188
2186
|
path: t,
|
|
2189
2187
|
language: j(t),
|
|
2190
2188
|
content: e
|
|
2191
2189
|
};
|
|
2192
2190
|
}
|
|
2193
|
-
async function
|
|
2191
|
+
async function xn(t) {
|
|
2194
2192
|
const { modelPath: e, fields: n } = fn(t.argv);
|
|
2195
|
-
|
|
2196
|
-
const r =
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
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-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
2195
|
+
t
|
|
2196
|
+
), m = [
|
|
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
|
-
mn(
|
|
2201
|
+
mn(
|
|
2202
|
+
r,
|
|
2203
|
+
a,
|
|
2204
|
+
s,
|
|
2205
|
+
t,
|
|
2206
|
+
c
|
|
2207
|
+
)
|
|
2202
2208
|
),
|
|
2203
|
-
|
|
2204
|
-
],
|
|
2209
|
+
V(`src/lib/schemas/${r.name}.ts`, bn(r, s))
|
|
2210
|
+
], g = O(s);
|
|
2205
2211
|
return {
|
|
2206
2212
|
creates: m,
|
|
2207
2213
|
modifies: [],
|
|
2208
2214
|
deletes: [],
|
|
2209
|
-
components:
|
|
2215
|
+
components: g,
|
|
2210
2216
|
packages: [],
|
|
2211
2217
|
collections: []
|
|
2212
2218
|
};
|
|
2213
2219
|
}
|
|
2214
|
-
const Fn = "generate-form";
|
|
2215
|
-
async function
|
|
2216
|
-
const e = await
|
|
2220
|
+
const Fn = "generate-form", Sn = "1.0.7", Cn = "src/patterns/generate/form", _n = "/generate/form";
|
|
2221
|
+
async function kn(t) {
|
|
2222
|
+
const e = await xn(t);
|
|
2217
2223
|
if (t.env !== "runtime")
|
|
2218
2224
|
return k(e);
|
|
2219
|
-
const { writeResult: n } = await import("./write-result-
|
|
2225
|
+
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
2220
2226
|
return n(await k(e), t);
|
|
2221
2227
|
}
|
|
2222
|
-
const
|
|
2228
|
+
const Rn = {
|
|
2229
|
+
version: Sn,
|
|
2223
2230
|
slug: Fn,
|
|
2231
|
+
source: Cn,
|
|
2232
|
+
docs: _n,
|
|
2233
|
+
plan: "open",
|
|
2224
2234
|
title: "Generate a form",
|
|
2225
2235
|
summary: "Generates a form.",
|
|
2236
|
+
requires: {
|
|
2237
|
+
auth: !1,
|
|
2238
|
+
payments: !1
|
|
2239
|
+
},
|
|
2226
2240
|
categories: ["forms"],
|
|
2227
2241
|
tags: ["sveltekit", "superforms", "validation", "zod"],
|
|
2228
2242
|
command: {
|
|
@@ -2231,8 +2245,8 @@ const _n = {
|
|
|
2231
2245
|
argv: ["contact", "name:text", "email:email", "message:editor"]
|
|
2232
2246
|
},
|
|
2233
2247
|
baseline: "velastack",
|
|
2234
|
-
generate:
|
|
2235
|
-
},
|
|
2248
|
+
generate: kn
|
|
2249
|
+
}, Pn = ["text"], zn = {
|
|
2236
2250
|
string: "text",
|
|
2237
2251
|
boolean: "bool",
|
|
2238
2252
|
geopoint: "geoPoint",
|
|
@@ -2259,10 +2273,10 @@ const _n = {
|
|
|
2259
2273
|
geoPoint: "geoPoint",
|
|
2260
2274
|
relation: "relation"
|
|
2261
2275
|
};
|
|
2262
|
-
function
|
|
2276
|
+
function Mn(t) {
|
|
2263
2277
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2264
2278
|
}
|
|
2265
|
-
function
|
|
2279
|
+
function In(t, e) {
|
|
2266
2280
|
const n = t.type === "select" ? `[${(t.options ?? []).map((o) => JSON.stringify(o.value)).join(", ")}]` : "";
|
|
2267
2281
|
let r;
|
|
2268
2282
|
switch (t.type) {
|
|
@@ -2308,7 +2322,7 @@ function Mn(t, e) {
|
|
|
2308
2322
|
return val;
|
|
2309
2323
|
}
|
|
2310
2324
|
return JSON.stringify(val);
|
|
2311
|
-
}, 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`
|
|
2312
2326
|
z.object({
|
|
2313
2327
|
lat: z.number().min(-90).max(90),
|
|
2314
2328
|
lon: z.number().min(-180).max(180)
|
|
@@ -2321,7 +2335,7 @@ function Mn(t, e) {
|
|
|
2321
2335
|
default:
|
|
2322
2336
|
return t.type;
|
|
2323
2337
|
}
|
|
2324
|
-
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()`;
|
|
2325
2339
|
}
|
|
2326
2340
|
function ot(t, e, n) {
|
|
2327
2341
|
const r = [];
|
|
@@ -2333,10 +2347,10 @@ function ot(t, e, n) {
|
|
|
2333
2347
|
}
|
|
2334
2348
|
r.push(a);
|
|
2335
2349
|
}
|
|
2336
|
-
const o = r.map((a) => `${
|
|
2350
|
+
const o = r.map((a) => `${Mn(a.name)}: ${In(a, n)}`).join(`,
|
|
2337
2351
|
`), s = n.includeModelFields ? `
|
|
2338
2352
|
import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelFields ? ` satisfies Schemas["${t.tableName}"]` : "";
|
|
2339
|
-
return
|
|
2353
|
+
return d`
|
|
2340
2354
|
import { z } from "zod/v3";${s}
|
|
2341
2355
|
|
|
2342
2356
|
export const ${t.schemaName} = z.object({
|
|
@@ -2344,8 +2358,8 @@ import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelField
|
|
|
2344
2358
|
})${i};
|
|
2345
2359
|
`;
|
|
2346
2360
|
}
|
|
2347
|
-
function
|
|
2348
|
-
const e =
|
|
2361
|
+
function En(t) {
|
|
2362
|
+
const e = zn[t];
|
|
2349
2363
|
if (!e)
|
|
2350
2364
|
throw new Error(`Unsupported collection field type "${t}" when generating from collection`);
|
|
2351
2365
|
return e;
|
|
@@ -2354,30 +2368,30 @@ function st(t, e, n) {
|
|
|
2354
2368
|
const r = e.find((a) => a.name === t.tableName);
|
|
2355
2369
|
if (!r)
|
|
2356
2370
|
throw new Error(`Collection "${t.tableName}" not found`);
|
|
2357
|
-
const o =
|
|
2371
|
+
const o = Tt(e), s = new Map(e.map((a) => [a.id, a])), i = [];
|
|
2358
2372
|
for (const a of r.fields) {
|
|
2359
2373
|
if (a.name === "id" || a.system)
|
|
2360
2374
|
continue;
|
|
2361
|
-
const c =
|
|
2375
|
+
const c = En(a.type), m = !!a.required, g = rt(a.name);
|
|
2362
2376
|
if (c === "relation") {
|
|
2363
2377
|
const f = a.collectionId ? s.get(a.collectionId) : void 0;
|
|
2364
2378
|
if (!f)
|
|
2365
2379
|
continue;
|
|
2366
|
-
const
|
|
2380
|
+
const h = M(f.name, n);
|
|
2367
2381
|
i.push({
|
|
2368
2382
|
name: a.name,
|
|
2369
|
-
title:
|
|
2383
|
+
title: g,
|
|
2370
2384
|
type: "relation",
|
|
2371
2385
|
required: m,
|
|
2372
2386
|
collectionId: f.id,
|
|
2373
2387
|
maxSelect: a.maxSelect ?? 1,
|
|
2374
2388
|
displayField: o[f.name] ?? "id",
|
|
2375
|
-
relatedModel:
|
|
2376
|
-
singularRelationName:
|
|
2377
|
-
`${t.displayName} ${
|
|
2389
|
+
relatedModel: h,
|
|
2390
|
+
singularRelationName: A(
|
|
2391
|
+
`${t.displayName} ${h.displayName}`
|
|
2378
2392
|
),
|
|
2379
|
-
pluralRelationName:
|
|
2380
|
-
`${t.displayName} ${
|
|
2393
|
+
pluralRelationName: A(
|
|
2394
|
+
`${t.displayName} ${h.pluralDisplayName}`
|
|
2381
2395
|
),
|
|
2382
2396
|
isCurrentUser: n.features.auth && f.name === "users" && /user|owner|author/i.test(a.name)
|
|
2383
2397
|
});
|
|
@@ -2386,7 +2400,7 @@ function st(t, e, n) {
|
|
|
2386
2400
|
if (c === "select") {
|
|
2387
2401
|
i.push({
|
|
2388
2402
|
name: a.name,
|
|
2389
|
-
title:
|
|
2403
|
+
title: g,
|
|
2390
2404
|
type: "select",
|
|
2391
2405
|
required: m,
|
|
2392
2406
|
maxSelect: a.maxSelect ?? 1,
|
|
@@ -2397,7 +2411,7 @@ function st(t, e, n) {
|
|
|
2397
2411
|
if (c === "file") {
|
|
2398
2412
|
i.push({
|
|
2399
2413
|
name: a.name,
|
|
2400
|
-
title:
|
|
2414
|
+
title: g,
|
|
2401
2415
|
type: "file",
|
|
2402
2416
|
required: m,
|
|
2403
2417
|
maxSelect: a.maxSelect ?? 1
|
|
@@ -2407,7 +2421,7 @@ function st(t, e, n) {
|
|
|
2407
2421
|
if (c === "autodate") {
|
|
2408
2422
|
i.push({
|
|
2409
2423
|
name: a.name,
|
|
2410
|
-
title:
|
|
2424
|
+
title: g,
|
|
2411
2425
|
type: "autodate",
|
|
2412
2426
|
required: m,
|
|
2413
2427
|
onCreate: a.onCreate ?? a.name.includes("create"),
|
|
@@ -2417,7 +2431,7 @@ function st(t, e, n) {
|
|
|
2417
2431
|
}
|
|
2418
2432
|
i.push({
|
|
2419
2433
|
name: a.name,
|
|
2420
|
-
title:
|
|
2434
|
+
title: g,
|
|
2421
2435
|
type: c,
|
|
2422
2436
|
required: m
|
|
2423
2437
|
});
|
|
@@ -2434,7 +2448,7 @@ function Ot(t) {
|
|
|
2434
2448
|
r.type === "relation" && (e.has(r.relatedModel.tableName) || (e.add(r.relatedModel.tableName), n.push(r.relatedModel)));
|
|
2435
2449
|
return n;
|
|
2436
2450
|
}
|
|
2437
|
-
function
|
|
2451
|
+
function Bn(t) {
|
|
2438
2452
|
const e = {
|
|
2439
2453
|
name: t.name,
|
|
2440
2454
|
type: t.type,
|
|
@@ -2469,10 +2483,10 @@ function qt(t, e, n) {
|
|
|
2469
2483
|
name: t.tableName,
|
|
2470
2484
|
type: "base",
|
|
2471
2485
|
...r,
|
|
2472
|
-
fields: e.map(
|
|
2486
|
+
fields: e.map(Bn)
|
|
2473
2487
|
};
|
|
2474
2488
|
}
|
|
2475
|
-
function
|
|
2489
|
+
function Dn(t) {
|
|
2476
2490
|
const [e, ...n] = t;
|
|
2477
2491
|
if (!e)
|
|
2478
2492
|
throw new Error(
|
|
@@ -2480,25 +2494,25 @@ function Tn(t) {
|
|
|
2480
2494
|
);
|
|
2481
2495
|
return { modelPath: e, fields: n };
|
|
2482
2496
|
}
|
|
2483
|
-
function
|
|
2497
|
+
function Tn(t, e) {
|
|
2484
2498
|
return {
|
|
2485
2499
|
path: t,
|
|
2486
2500
|
language: j(t),
|
|
2487
2501
|
content: e
|
|
2488
2502
|
};
|
|
2489
2503
|
}
|
|
2490
|
-
async function
|
|
2491
|
-
|
|
2492
|
-
const r =
|
|
2504
|
+
async function An(t, e, n) {
|
|
2505
|
+
W(e);
|
|
2506
|
+
const r = M(e, t);
|
|
2493
2507
|
if (n.length > 0) {
|
|
2494
|
-
const i = await
|
|
2508
|
+
const i = await J(n, r, t);
|
|
2495
2509
|
return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
|
|
2496
2510
|
}
|
|
2497
|
-
const o = t.env === "runtime" ? await (await import("./env.runtime-
|
|
2511
|
+
const o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
|
|
2498
2512
|
return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
|
|
2499
2513
|
}
|
|
2500
|
-
async function
|
|
2501
|
-
const { modelPath: e, fields: n } =
|
|
2514
|
+
async function Nn(t) {
|
|
2515
|
+
const { modelPath: e, fields: n } = Dn(t.argv), { model: r, fields: o, auth: s, shouldCreateCollection: i } = await An(
|
|
2502
2516
|
t,
|
|
2503
2517
|
e,
|
|
2504
2518
|
n
|
|
@@ -2507,7 +2521,7 @@ async function An(t) {
|
|
|
2507
2521
|
forForm: !0
|
|
2508
2522
|
});
|
|
2509
2523
|
return {
|
|
2510
|
-
creates: [
|
|
2524
|
+
creates: [Tn(a, c)],
|
|
2511
2525
|
modifies: [],
|
|
2512
2526
|
deletes: [],
|
|
2513
2527
|
components: [],
|
|
@@ -2515,21 +2529,32 @@ async function An(t) {
|
|
|
2515
2529
|
collections: i ? [qt(r, o, s)] : []
|
|
2516
2530
|
};
|
|
2517
2531
|
}
|
|
2518
|
-
const
|
|
2519
|
-
async function
|
|
2520
|
-
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);
|
|
2521
2535
|
if (t.env !== "runtime")
|
|
2522
2536
|
return k(e);
|
|
2523
|
-
const { createCollections: n } = await import("./collections-
|
|
2537
|
+
const { createCollections: n } = await import("./collections-Bo7ZRBqp.js"), r = await n(
|
|
2538
|
+
e.collections,
|
|
2539
|
+
t
|
|
2540
|
+
), o = {
|
|
2524
2541
|
...e,
|
|
2525
2542
|
creates: [...e.creates, ...r]
|
|
2526
|
-
}, { writeResult: s } = await import("./write-result-
|
|
2543
|
+
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
2527
2544
|
return s(await k(o), t);
|
|
2528
2545
|
}
|
|
2529
|
-
const
|
|
2530
|
-
|
|
2546
|
+
const Un = {
|
|
2547
|
+
version: Ln,
|
|
2548
|
+
slug: jn,
|
|
2549
|
+
source: On,
|
|
2550
|
+
docs: qn,
|
|
2551
|
+
plan: "open",
|
|
2531
2552
|
title: "Generate a resource",
|
|
2532
2553
|
summary: "Generates model schema resources.",
|
|
2554
|
+
requires: {
|
|
2555
|
+
auth: !1,
|
|
2556
|
+
payments: !1
|
|
2557
|
+
},
|
|
2533
2558
|
categories: ["data"],
|
|
2534
2559
|
tags: ["pocketbase", "resource", "schema"],
|
|
2535
2560
|
command: {
|
|
@@ -2538,34 +2563,32 @@ const Bn = {
|
|
|
2538
2563
|
argv: ["contact", "name:text", "email:email"]
|
|
2539
2564
|
},
|
|
2540
2565
|
baseline: "velastack",
|
|
2541
|
-
generate:
|
|
2566
|
+
generate: Vn
|
|
2542
2567
|
};
|
|
2543
|
-
var
|
|
2544
|
-
function
|
|
2568
|
+
var Ct = Object.freeze, Hn = Object.defineProperty, Z = (t, e) => Ct(Hn(t, "raw", { value: Ct(e || t.slice()) })), _t, kt, Rt, Pt;
|
|
2569
|
+
function Gn(t) {
|
|
2545
2570
|
const [e, ...n] = t;
|
|
2546
2571
|
if (!e)
|
|
2547
|
-
throw new Error(
|
|
2548
|
-
"Invalid command arguments. Expected: <model> [fields...]"
|
|
2549
|
-
);
|
|
2572
|
+
throw new Error("Invalid command arguments. Expected: <model> [fields...]");
|
|
2550
2573
|
return { modelPath: e, fields: n };
|
|
2551
2574
|
}
|
|
2552
|
-
function
|
|
2575
|
+
function C(t, e) {
|
|
2553
2576
|
return {
|
|
2554
2577
|
path: t,
|
|
2555
2578
|
language: j(t),
|
|
2556
2579
|
content: e
|
|
2557
2580
|
};
|
|
2558
2581
|
}
|
|
2559
|
-
function
|
|
2582
|
+
function Vt(t) {
|
|
2560
2583
|
return t.some((e) => e.type === "file");
|
|
2561
2584
|
}
|
|
2562
|
-
function
|
|
2585
|
+
function Ut(t) {
|
|
2563
2586
|
return [...new Set(t.filter(Boolean))];
|
|
2564
2587
|
}
|
|
2565
2588
|
function it(t) {
|
|
2566
2589
|
return t.filter(
|
|
2567
2590
|
(e) => e.type === "select"
|
|
2568
|
-
).map((e) =>
|
|
2591
|
+
).map((e) => It(e)).join(`
|
|
2569
2592
|
|
|
2570
2593
|
`);
|
|
2571
2594
|
}
|
|
@@ -2578,12 +2601,12 @@ function Ht(t, e) {
|
|
|
2578
2601
|
function Gt(t) {
|
|
2579
2602
|
return Ot(t).map((e) => e.pluralName).join(", ");
|
|
2580
2603
|
}
|
|
2581
|
-
function
|
|
2604
|
+
function Wn(t) {
|
|
2582
2605
|
return t.features.auth ? "locals.pb" : "locals.admin";
|
|
2583
2606
|
}
|
|
2584
|
-
function
|
|
2607
|
+
function Wt(t, e, n = !1) {
|
|
2585
2608
|
const r = it(e);
|
|
2586
|
-
return
|
|
2609
|
+
return d`
|
|
2587
2610
|
${r}
|
|
2588
2611
|
${n ? "let { data, params } = $props();" : "let { data } = $props();"}
|
|
2589
2612
|
|
|
@@ -2594,8 +2617,8 @@ function Kt(t, e, n = !1) {
|
|
|
2594
2617
|
const { form: formData } = form;
|
|
2595
2618
|
`;
|
|
2596
2619
|
}
|
|
2597
|
-
function
|
|
2598
|
-
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([
|
|
2599
2622
|
'import { untrack } from "svelte";',
|
|
2600
2623
|
'import { superForm } from "sveltekit-superforms";',
|
|
2601
2624
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
@@ -2607,8 +2630,8 @@ function qn(t, e, n) {
|
|
|
2607
2630
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2608
2631
|
]).join(`
|
|
2609
2632
|
`), s = n.map((a) => et(a)).join(`
|
|
2610
|
-
`), i =
|
|
2611
|
-
return
|
|
2633
|
+
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2634
|
+
return d(_t || (_t = Z([`
|
|
2612
2635
|
<script lang="ts">
|
|
2613
2636
|
`, `
|
|
2614
2637
|
`, `
|
|
@@ -2635,10 +2658,10 @@ function qn(t, e, n) {
|
|
|
2635
2658
|
</form>
|
|
2636
2659
|
</div>
|
|
2637
2660
|
</section>
|
|
2638
|
-
`])), o,
|
|
2661
|
+
`])), o, Wt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2639
2662
|
}
|
|
2640
|
-
function
|
|
2641
|
-
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([
|
|
2642
2665
|
'import { untrack } from "svelte";',
|
|
2643
2666
|
'import { superForm } from "sveltekit-superforms";',
|
|
2644
2667
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
@@ -2650,8 +2673,8 @@ function Un(t, e, n) {
|
|
|
2650
2673
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2651
2674
|
]).join(`
|
|
2652
2675
|
`), s = n.map((a) => et(a)).join(`
|
|
2653
|
-
`), i =
|
|
2654
|
-
return
|
|
2676
|
+
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2677
|
+
return d(kt || (kt = Z([`
|
|
2655
2678
|
<script lang="ts">
|
|
2656
2679
|
`, `
|
|
2657
2680
|
`, `
|
|
@@ -2705,12 +2728,12 @@ function Un(t, e, n) {
|
|
|
2705
2728
|
</form>
|
|
2706
2729
|
</div>
|
|
2707
2730
|
</section>
|
|
2708
|
-
`])), o,
|
|
2731
|
+
`])), o, Wt(t, n, !0), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2709
2732
|
}
|
|
2710
|
-
function
|
|
2733
|
+
function Xn(t, e, n) {
|
|
2711
2734
|
const r = n.some((a) => a.type === "select"), o = r ? `${it(n)}` : "", s = n.map((a) => {
|
|
2712
2735
|
let c = "{ getValue }", m = "{ value: getValue() }";
|
|
2713
|
-
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`
|
|
2714
2737
|
columnHelper.accessor("${a.name}", {
|
|
2715
2738
|
header: ({ column }) => renderComponent(ColumnHeader, { column, title: "${a.title}" }),
|
|
2716
2739
|
cell: (${c}) => renderComponent(Cells.${a.type.charAt(0).toUpperCase() + a.type.slice(1)}Cell, ${m})
|
|
@@ -2721,7 +2744,7 @@ function Vn(t, e, n) {
|
|
|
2721
2744
|
(a) => `<FacetedFilter column={table.getColumn("${a.name}")!} title="${a.title}" options={Object.values(${a.name}Labels)} />`
|
|
2722
2745
|
).join(`
|
|
2723
2746
|
`);
|
|
2724
|
-
return
|
|
2747
|
+
return d(Rt || (Rt = Z([`
|
|
2725
2748
|
<script lang="ts">
|
|
2726
2749
|
import {
|
|
2727
2750
|
type ColumnFiltersState,
|
|
@@ -3097,25 +3120,25 @@ function Vn(t, e, n) {
|
|
|
3097
3120
|
</section>
|
|
3098
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());
|
|
3099
3122
|
}
|
|
3100
|
-
function
|
|
3123
|
+
function Yn(t, e, n) {
|
|
3101
3124
|
const r = Lt(e), o = r ? `{ expand: "${r}" }` : "";
|
|
3102
|
-
return
|
|
3125
|
+
return d`
|
|
3103
3126
|
export const load = async ({ locals }) => {
|
|
3104
3127
|
const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${o});
|
|
3105
3128
|
return { ${t.pluralName} };
|
|
3106
3129
|
};
|
|
3107
3130
|
`;
|
|
3108
3131
|
}
|
|
3109
|
-
function
|
|
3132
|
+
function Kn(t, e, n, r, o) {
|
|
3110
3133
|
const s = Ht(n, r), i = Gt(n), a = i ? `, ${i}` : "", c = n.find(
|
|
3111
|
-
(
|
|
3112
|
-
), m = o && c ?
|
|
3134
|
+
(g) => g.type === "relation" && g.isCurrentUser
|
|
3135
|
+
), m = o && c ? d`
|
|
3113
3136
|
{
|
|
3114
3137
|
...form.data,
|
|
3115
3138
|
${c.name}: locals.pb.authStore.record?.id
|
|
3116
3139
|
}
|
|
3117
3140
|
` : "form.data";
|
|
3118
|
-
return
|
|
3141
|
+
return d`
|
|
3119
3142
|
import { fail, redirect } from "@sveltejs/kit";
|
|
3120
3143
|
import { superValidate } from "sveltekit-superforms";
|
|
3121
3144
|
import { zod } from "sveltekit-superforms/adapters";
|
|
@@ -3148,9 +3171,9 @@ function Gn(t, e, n, r, o) {
|
|
|
3148
3171
|
};
|
|
3149
3172
|
`;
|
|
3150
3173
|
}
|
|
3151
|
-
function
|
|
3174
|
+
function Qn(t, e, n, r) {
|
|
3152
3175
|
const o = Lt(n), s = o ? `, { expand: "${o}" }` : "";
|
|
3153
|
-
return
|
|
3176
|
+
return d`
|
|
3154
3177
|
import { error, redirect } from "@sveltejs/kit";
|
|
3155
3178
|
|
|
3156
3179
|
export const load = async ({ locals, params }) => {
|
|
@@ -3170,7 +3193,7 @@ function Kn(t, e, n, r) {
|
|
|
3170
3193
|
};
|
|
3171
3194
|
`;
|
|
3172
3195
|
}
|
|
3173
|
-
function
|
|
3196
|
+
function tr(t, e, n) {
|
|
3174
3197
|
const r = n.some((m) => m.type === "select"), o = n.some((m) => m.type === "relation"), s = n.some((m) => m.type === "file"), i = [
|
|
3175
3198
|
'import { Button } from "$lib/components/ui/button";',
|
|
3176
3199
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
@@ -3180,7 +3203,7 @@ function Wn(t, e, n) {
|
|
|
3180
3203
|
].filter(Boolean).join(`
|
|
3181
3204
|
`), a = it(n), c = n.map((m) => Fe(t, m)).join(`
|
|
3182
3205
|
`);
|
|
3183
|
-
return
|
|
3206
|
+
return d(Pt || (Pt = Z([`
|
|
3184
3207
|
<script lang="ts">
|
|
3185
3208
|
`, `
|
|
3186
3209
|
`, `
|
|
@@ -3214,9 +3237,9 @@ function Wn(t, e, n) {
|
|
|
3214
3237
|
</section>
|
|
3215
3238
|
`])), i, a, t.displayName, e.list, c, e.list, t.name);
|
|
3216
3239
|
}
|
|
3217
|
-
function
|
|
3240
|
+
function er(t, e, n, r) {
|
|
3218
3241
|
const o = Ht(n, r), s = Gt(n), i = s ? `, ${s}` : "";
|
|
3219
|
-
return
|
|
3242
|
+
return d`
|
|
3220
3243
|
import { error, fail, redirect } from "@sveltejs/kit";
|
|
3221
3244
|
import { setPocketbaseErrors, setDefaultData } from "@velastack/pocketbase";
|
|
3222
3245
|
import { superValidate } from "sveltekit-superforms";
|
|
@@ -3256,11 +3279,13 @@ function Xn(t, e, n, r) {
|
|
|
3256
3279
|
};
|
|
3257
3280
|
`;
|
|
3258
3281
|
}
|
|
3259
|
-
async function
|
|
3260
|
-
|
|
3261
|
-
const r =
|
|
3282
|
+
async function nr(t, e, n) {
|
|
3283
|
+
W(e);
|
|
3284
|
+
const r = M(e, t), o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
3285
|
+
t
|
|
3286
|
+
);
|
|
3262
3287
|
if (n.length > 0) {
|
|
3263
|
-
const i = await
|
|
3288
|
+
const i = await J(n, r, t);
|
|
3264
3289
|
return {
|
|
3265
3290
|
model: r,
|
|
3266
3291
|
fields: i.fields,
|
|
@@ -3278,51 +3303,57 @@ async function Yn(t, e, n) {
|
|
|
3278
3303
|
collections: o
|
|
3279
3304
|
};
|
|
3280
3305
|
}
|
|
3281
|
-
async function
|
|
3282
|
-
const { modelPath: e, fields: n } =
|
|
3306
|
+
async function rr(t) {
|
|
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(
|
|
3283
3308
|
(u) => !(u.type === "relation" && u.isCurrentUser)
|
|
3284
|
-
),
|
|
3285
|
-
|
|
3309
|
+
), h = [
|
|
3310
|
+
C(
|
|
3286
3311
|
`src/lib/schemas/${r.name}.ts`,
|
|
3287
3312
|
ot(r, o, {
|
|
3288
3313
|
includeModelFields: !0,
|
|
3289
3314
|
forForm: !0
|
|
3290
3315
|
})
|
|
3291
3316
|
),
|
|
3292
|
-
|
|
3317
|
+
C(
|
|
3293
3318
|
`${c.list}/+page.server.ts`,
|
|
3294
|
-
|
|
3319
|
+
Yn(r, f, g)
|
|
3295
3320
|
),
|
|
3296
|
-
|
|
3321
|
+
C(
|
|
3297
3322
|
`${c.list}/+page.svelte`,
|
|
3298
|
-
|
|
3323
|
+
Xn(r, m, f)
|
|
3299
3324
|
),
|
|
3300
|
-
|
|
3325
|
+
C(
|
|
3301
3326
|
`${c.new}/+page.server.ts`,
|
|
3302
|
-
|
|
3327
|
+
Kn(r, m, f, g, t.features.auth)
|
|
3303
3328
|
),
|
|
3304
|
-
|
|
3305
|
-
|
|
3329
|
+
C(`${c.new}/+page.svelte`, Jn(r, m, f)),
|
|
3330
|
+
C(
|
|
3306
3331
|
`${c.show}/+page.server.ts`,
|
|
3307
|
-
|
|
3332
|
+
Qn(r, m, f, g)
|
|
3308
3333
|
),
|
|
3309
|
-
|
|
3334
|
+
C(
|
|
3310
3335
|
`${c.show}/+page.svelte`,
|
|
3311
|
-
|
|
3336
|
+
tr(r, m, f)
|
|
3312
3337
|
),
|
|
3313
|
-
|
|
3338
|
+
C(
|
|
3314
3339
|
`${c.edit}/+page.server.ts`,
|
|
3315
|
-
|
|
3340
|
+
er(r, m, f, g)
|
|
3316
3341
|
),
|
|
3317
|
-
|
|
3342
|
+
C(
|
|
3318
3343
|
`${c.edit}/+page.svelte`,
|
|
3319
|
-
|
|
3344
|
+
Zn(r, m, f)
|
|
3320
3345
|
),
|
|
3321
|
-
|
|
3346
|
+
C(
|
|
3322
3347
|
`${c.list}/server.test.ts`,
|
|
3323
|
-
cn(
|
|
3348
|
+
cn(
|
|
3349
|
+
r,
|
|
3350
|
+
m,
|
|
3351
|
+
o,
|
|
3352
|
+
t,
|
|
3353
|
+
a
|
|
3354
|
+
)
|
|
3324
3355
|
)
|
|
3325
|
-
],
|
|
3356
|
+
], $ = [
|
|
3326
3357
|
...O(f),
|
|
3327
3358
|
"button",
|
|
3328
3359
|
"table",
|
|
@@ -3341,29 +3372,40 @@ async function Jn(t) {
|
|
|
3341
3372
|
"row-actions"
|
|
3342
3373
|
];
|
|
3343
3374
|
return {
|
|
3344
|
-
creates:
|
|
3375
|
+
creates: h,
|
|
3345
3376
|
modifies: [],
|
|
3346
3377
|
deletes: [],
|
|
3347
|
-
components: [...new Set(
|
|
3348
|
-
packages: [],
|
|
3378
|
+
components: [...new Set($)],
|
|
3379
|
+
packages: ["@tanstack/table-core"],
|
|
3349
3380
|
collections: i ? [qt(r, o, s)] : []
|
|
3350
3381
|
};
|
|
3351
3382
|
}
|
|
3352
|
-
const
|
|
3353
|
-
async function
|
|
3354
|
-
const e = await
|
|
3383
|
+
const ar = "generate-scaffold", or = "1.0.7", sr = "src/patterns/generate/scaffold", ir = "/generate/scaffold";
|
|
3384
|
+
async function lr(t) {
|
|
3385
|
+
const e = await rr(t);
|
|
3355
3386
|
if (t.env !== "runtime")
|
|
3356
3387
|
return k(e);
|
|
3357
|
-
const { createCollections: n } = await import("./collections-
|
|
3388
|
+
const { createCollections: n } = await import("./collections-Bo7ZRBqp.js"), r = await n(
|
|
3389
|
+
e.collections,
|
|
3390
|
+
t
|
|
3391
|
+
), o = {
|
|
3358
3392
|
...e,
|
|
3359
3393
|
creates: [...e.creates, ...r]
|
|
3360
|
-
}, { writeResult: s } = await import("./write-result-
|
|
3394
|
+
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
3361
3395
|
return s(await k(o), t);
|
|
3362
3396
|
}
|
|
3363
|
-
const
|
|
3364
|
-
|
|
3397
|
+
const cr = {
|
|
3398
|
+
version: or,
|
|
3399
|
+
slug: ar,
|
|
3400
|
+
source: sr,
|
|
3401
|
+
docs: ir,
|
|
3402
|
+
plan: "open",
|
|
3365
3403
|
title: "Generate a scaffold",
|
|
3366
3404
|
summary: "Generates CRUD routes and schema.",
|
|
3405
|
+
requires: {
|
|
3406
|
+
auth: !1,
|
|
3407
|
+
payments: !1
|
|
3408
|
+
},
|
|
3367
3409
|
categories: ["data", "forms"],
|
|
3368
3410
|
tags: ["crud", "scaffold", "pocketbase", "sveltekit"],
|
|
3369
3411
|
command: {
|
|
@@ -3372,9 +3414,9 @@ const tr = {
|
|
|
3372
3414
|
argv: ["contact", "name:text", "email:email"]
|
|
3373
3415
|
},
|
|
3374
3416
|
baseline: "velastack",
|
|
3375
|
-
generate:
|
|
3417
|
+
generate: lr
|
|
3376
3418
|
};
|
|
3377
|
-
function
|
|
3419
|
+
function mr(t) {
|
|
3378
3420
|
const [e, ...n] = t;
|
|
3379
3421
|
if (!e)
|
|
3380
3422
|
throw new Error(
|
|
@@ -3382,25 +3424,25 @@ function er(t) {
|
|
|
3382
3424
|
);
|
|
3383
3425
|
return { modelPath: e, fields: n };
|
|
3384
3426
|
}
|
|
3385
|
-
function
|
|
3427
|
+
function ur(t, e) {
|
|
3386
3428
|
return {
|
|
3387
3429
|
path: t,
|
|
3388
3430
|
language: j(t),
|
|
3389
3431
|
content: e
|
|
3390
3432
|
};
|
|
3391
3433
|
}
|
|
3392
|
-
async function
|
|
3393
|
-
|
|
3394
|
-
const r =
|
|
3434
|
+
async function dr(t, e, n) {
|
|
3435
|
+
W(e);
|
|
3436
|
+
const r = M(e, t);
|
|
3395
3437
|
if (n.length > 0) {
|
|
3396
|
-
const i = await
|
|
3438
|
+
const i = await J(n, r, t);
|
|
3397
3439
|
return { model: r, fields: i.fields, includeModelFields: !1 };
|
|
3398
3440
|
}
|
|
3399
|
-
const o = t.env === "runtime" ? await (await import("./env.runtime-
|
|
3441
|
+
const o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
|
|
3400
3442
|
return { model: r, fields: s, includeModelFields: !0 };
|
|
3401
3443
|
}
|
|
3402
|
-
async function
|
|
3403
|
-
const { modelPath: e, fields: n } =
|
|
3444
|
+
async function pr(t) {
|
|
3445
|
+
const { modelPath: e, fields: n } = mr(t.argv), { model: r, fields: o, includeModelFields: s } = await dr(
|
|
3404
3446
|
t,
|
|
3405
3447
|
e,
|
|
3406
3448
|
n
|
|
@@ -3409,7 +3451,7 @@ async function ar(t) {
|
|
|
3409
3451
|
forForm: !0
|
|
3410
3452
|
});
|
|
3411
3453
|
return {
|
|
3412
|
-
creates: [
|
|
3454
|
+
creates: [ur(i, a)],
|
|
3413
3455
|
modifies: [],
|
|
3414
3456
|
deletes: [],
|
|
3415
3457
|
components: [],
|
|
@@ -3417,18 +3459,26 @@ async function ar(t) {
|
|
|
3417
3459
|
collections: []
|
|
3418
3460
|
};
|
|
3419
3461
|
}
|
|
3420
|
-
const
|
|
3421
|
-
async function
|
|
3422
|
-
const e = await
|
|
3462
|
+
const fr = "generate-schema", gr = "1.0.7", hr = "src/patterns/generate/schema", br = "/generate/schema";
|
|
3463
|
+
async function vr(t) {
|
|
3464
|
+
const e = await pr(t);
|
|
3423
3465
|
if (t.env !== "runtime")
|
|
3424
3466
|
return k(e);
|
|
3425
|
-
const { writeResult: n } = await import("./write-result-
|
|
3467
|
+
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
3426
3468
|
return n(await k(e), t);
|
|
3427
3469
|
}
|
|
3428
|
-
const
|
|
3429
|
-
|
|
3470
|
+
const wr = {
|
|
3471
|
+
version: gr,
|
|
3472
|
+
slug: fr,
|
|
3473
|
+
source: hr,
|
|
3474
|
+
docs: br,
|
|
3475
|
+
plan: "open",
|
|
3430
3476
|
title: "Generate a schema",
|
|
3431
3477
|
summary: "Generates a zod schema.",
|
|
3478
|
+
requires: {
|
|
3479
|
+
auth: !1,
|
|
3480
|
+
payments: !1
|
|
3481
|
+
},
|
|
3432
3482
|
categories: ["data"],
|
|
3433
3483
|
tags: ["zod", "schema", "pocketbase"],
|
|
3434
3484
|
command: {
|
|
@@ -3437,9 +3487,13 @@ const ir = {
|
|
|
3437
3487
|
argv: ["contact", "name:text", "email:email"]
|
|
3438
3488
|
},
|
|
3439
3489
|
baseline: "velastack",
|
|
3440
|
-
generate:
|
|
3441
|
-
},
|
|
3490
|
+
generate: vr
|
|
3491
|
+
}, yr = `<script lang="ts">
|
|
3492
|
+
import type { ComponentProps } from 'svelte';
|
|
3442
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';
|
|
3443
3497
|
|
|
3444
3498
|
let data = {
|
|
3445
3499
|
navMain: [
|
|
@@ -3450,13 +3504,6 @@ const ir = {
|
|
|
3450
3504
|
}
|
|
3451
3505
|
]
|
|
3452
3506
|
};
|
|
3453
|
-
<\/script>
|
|
3454
|
-
|
|
3455
|
-
<script lang="ts">
|
|
3456
|
-
import NavMain from './nav-main.svelte';
|
|
3457
|
-
import NavUser from './nav-user.svelte';
|
|
3458
|
-
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3459
|
-
import type { ComponentProps } from 'svelte';
|
|
3460
3507
|
|
|
3461
3508
|
let {
|
|
3462
3509
|
user,
|
|
@@ -3494,7 +3541,7 @@ const ir = {
|
|
|
3494
3541
|
<NavUser {user} />
|
|
3495
3542
|
</Sidebar.Footer>
|
|
3496
3543
|
</Sidebar.Root>
|
|
3497
|
-
`,
|
|
3544
|
+
`, $r = `<script lang="ts">
|
|
3498
3545
|
import type { Component } from 'svelte';
|
|
3499
3546
|
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3500
3547
|
import { page } from '$app/state';
|
|
@@ -3534,9 +3581,17 @@ const ir = {
|
|
|
3534
3581
|
{/each}
|
|
3535
3582
|
</Sidebar.Menu>
|
|
3536
3583
|
</Sidebar.Group>
|
|
3537
|
-
`,
|
|
3584
|
+
`, xr = `<script lang="ts">
|
|
3585
|
+
import { toggleMode, mode } from 'mode-watcher';
|
|
3586
|
+
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
3538
3587
|
import Settings2Icon from '@lucide/svelte/icons/settings-2';
|
|
3539
|
-
|
|
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
|
+
|
|
3540
3595
|
let data = {
|
|
3541
3596
|
navUser: [
|
|
3542
3597
|
{
|
|
@@ -3546,17 +3601,6 @@ const ir = {
|
|
|
3546
3601
|
}
|
|
3547
3602
|
]
|
|
3548
3603
|
};
|
|
3549
|
-
<\/script>
|
|
3550
|
-
|
|
3551
|
-
<script lang="ts">
|
|
3552
|
-
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
3553
|
-
import LogOutIcon from '@lucide/svelte/icons/log-out';
|
|
3554
|
-
import MoonIcon from '@lucide/svelte/icons/moon';
|
|
3555
|
-
import SunIcon from '@lucide/svelte/icons/sun';
|
|
3556
|
-
import * as Avatar from '$lib/components/ui/avatar';
|
|
3557
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
3558
|
-
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3559
|
-
import { toggleMode, mode } from 'mode-watcher';
|
|
3560
3604
|
|
|
3561
3605
|
let {
|
|
3562
3606
|
user
|
|
@@ -3653,192 +3697,12 @@ const ir = {
|
|
|
3653
3697
|
</DropdownMenu.Root>
|
|
3654
3698
|
</Sidebar.MenuItem>
|
|
3655
3699
|
</Sidebar.Menu>
|
|
3656
|
-
`,
|
|
3657
|
-
import { cn } from '$lib/utils';
|
|
3658
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3659
|
-
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3660
|
-
import { getContext } from 'svelte';
|
|
3661
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3662
|
-
|
|
3663
|
-
let {
|
|
3664
|
-
children,
|
|
3665
|
-
class: className,
|
|
3666
|
-
...restProps
|
|
3667
|
-
}: DropdownMenuPrimitive.ContentProps & {
|
|
3668
|
-
portalProps?: DropdownMenuPrimitive.PortalProps;
|
|
3669
|
-
} = $props();
|
|
3670
|
-
|
|
3671
|
-
let { isDesktop } =
|
|
3672
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3673
|
-
<\/script>
|
|
3674
|
-
|
|
3675
|
-
{#if isDesktop}
|
|
3676
|
-
<DropdownMenu.Content class={className} {...restProps}>
|
|
3677
|
-
{@render children?.()}
|
|
3678
|
-
</DropdownMenu.Content>
|
|
3679
|
-
{:else}
|
|
3680
|
-
<div class={cn('flex flex-col w-full', className)}>
|
|
3681
|
-
{@render children?.()}
|
|
3682
|
-
</div>
|
|
3683
|
-
{/if}
|
|
3684
|
-
`, pr = `<script lang="ts">
|
|
3685
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3686
|
-
import { getContext } from 'svelte';
|
|
3687
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3688
|
-
let { isDesktop } =
|
|
3689
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3690
|
-
let { children, ...restProps } = $props();
|
|
3691
|
-
<\/script>
|
|
3692
|
-
|
|
3693
|
-
{#if isDesktop}
|
|
3694
|
-
<DropdownMenu.Group {...restProps}>
|
|
3695
|
-
{@render children?.()}
|
|
3696
|
-
</DropdownMenu.Group>
|
|
3697
|
-
{:else}
|
|
3698
|
-
{@render children?.()}
|
|
3699
|
-
{/if}
|
|
3700
|
-
`, dr = `<script lang="ts">
|
|
3701
|
-
import { goto } from '$app/navigation';
|
|
3702
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
3703
|
-
import { Button } from '$lib/components/ui/button';
|
|
3704
|
-
import { getContext } from 'svelte';
|
|
3705
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3706
|
-
let { children, href = undefined, ...restProps } = $props();
|
|
3707
|
-
|
|
3708
|
-
const { isDesktop } =
|
|
3709
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3710
|
-
|
|
3711
|
-
const handleClick = () => {
|
|
3712
|
-
if (restProps.onclick) {
|
|
3713
|
-
restProps.onclick();
|
|
3714
|
-
} else {
|
|
3715
|
-
if (href) {
|
|
3716
|
-
goto(href);
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
};
|
|
3720
|
-
<\/script>
|
|
3721
|
-
|
|
3722
|
-
{#if isDesktop}
|
|
3723
|
-
<DropdownMenu.Item {...restProps} onclick={handleClick}>
|
|
3724
|
-
{@render children?.()}
|
|
3725
|
-
</DropdownMenu.Item>
|
|
3726
|
-
{:else}
|
|
3727
|
-
<Button
|
|
3728
|
-
class="w-full justify-start md:justify-center md:w-auto"
|
|
3729
|
-
variant="ghost"
|
|
3730
|
-
{href}
|
|
3731
|
-
{...restProps}
|
|
3732
|
-
>
|
|
3733
|
-
{@render children?.()}
|
|
3734
|
-
</Button>
|
|
3735
|
-
{/if}
|
|
3736
|
-
`, fr = `<script lang="ts">
|
|
3737
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3738
|
-
import { getContext } from 'svelte';
|
|
3739
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3740
|
-
const { isDesktop } =
|
|
3741
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3742
|
-
let { children, ...restProps } = $props();
|
|
3743
|
-
<\/script>
|
|
3744
|
-
|
|
3745
|
-
{#if isDesktop}
|
|
3746
|
-
<DropdownMenu.Label {...restProps}>
|
|
3747
|
-
{@render children?.()}
|
|
3748
|
-
</DropdownMenu.Label>
|
|
3749
|
-
{/if}
|
|
3750
|
-
`, hr = `<script lang="ts">
|
|
3751
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3752
|
-
import { getContext } from 'svelte';
|
|
3753
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3754
|
-
const { isDesktop } =
|
|
3755
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3756
|
-
let restProps = $props();
|
|
3757
|
-
<\/script>
|
|
3758
|
-
|
|
3759
|
-
{#if isDesktop}
|
|
3760
|
-
<DropdownMenu.Separator {...restProps} />
|
|
3761
|
-
{/if}
|
|
3762
|
-
`, gr = `<script lang="ts">
|
|
3763
|
-
import { cn } from '$lib/utils';
|
|
3764
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3765
|
-
import { getContext } from 'svelte';
|
|
3766
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3767
|
-
let { class: className = '', ...restProps } = $props();
|
|
3768
|
-
|
|
3769
|
-
const { isDesktop } =
|
|
3770
|
-
getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);
|
|
3771
|
-
<\/script>
|
|
3772
|
-
|
|
3773
|
-
{#if isDesktop}
|
|
3774
|
-
<DropdownMenu.Trigger class={cn('inline-flex', className)} {...restProps} />
|
|
3775
|
-
{/if}
|
|
3776
|
-
`, br = `<script lang="ts">
|
|
3777
|
-
import { page } from '$app/state';
|
|
3778
|
-
import { browser } from '$app/environment';
|
|
3779
|
-
import { onMount, setContext } from 'svelte';
|
|
3780
|
-
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
|
3781
|
-
import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';
|
|
3782
|
-
|
|
3783
|
-
let { user, guest } = $props();
|
|
3784
|
-
|
|
3785
|
-
const breakpoint = 768;
|
|
3786
|
-
const breakpointQuery = \`(min-width: \${breakpoint}px)\`;
|
|
3787
|
-
|
|
3788
|
-
let hasMounted = $state(false);
|
|
3789
|
-
let authMenuContext = $state<AuthMenuContext>({ isDesktop: true });
|
|
3790
|
-
|
|
3791
|
-
setContext(AUTH_MENU_CONTEXT_KEY, authMenuContext);
|
|
3792
|
-
|
|
3793
|
-
function updateIsDesktop() {
|
|
3794
|
-
if (!browser) return;
|
|
3795
|
-
authMenuContext.isDesktop = window.matchMedia(breakpointQuery).matches;
|
|
3796
|
-
}
|
|
3797
|
-
|
|
3798
|
-
onMount(() => {
|
|
3799
|
-
updateIsDesktop();
|
|
3800
|
-
hasMounted = true;
|
|
3801
|
-
const mq = window.matchMedia(breakpointQuery);
|
|
3802
|
-
const listener = () => (authMenuContext.isDesktop = mq.matches);
|
|
3803
|
-
mq.addEventListener('change', listener);
|
|
3804
|
-
return () => mq.removeEventListener('change', listener);
|
|
3805
|
-
});
|
|
3806
|
-
<\/script>
|
|
3807
|
-
|
|
3808
|
-
{#if page.data.user}
|
|
3809
|
-
{#if authMenuContext.isDesktop}
|
|
3810
|
-
<DropdownMenu.Root>
|
|
3811
|
-
{@render user?.()}
|
|
3812
|
-
</DropdownMenu.Root>
|
|
3813
|
-
{:else}
|
|
3814
|
-
<!-- This prevents the menu from being rendered twice before we know if we're on desktop or not -->
|
|
3815
|
-
{#if hasMounted}
|
|
3816
|
-
{@render user?.()}
|
|
3817
|
-
{/if}
|
|
3818
|
-
{/if}
|
|
3819
|
-
{:else}
|
|
3820
|
-
{@render guest?.()}
|
|
3821
|
-
{/if}
|
|
3822
|
-
`, vr = `export type AuthMenuContext = {
|
|
3823
|
-
isDesktop: boolean;
|
|
3824
|
-
};
|
|
3825
|
-
|
|
3826
|
-
export const AUTH_MENU_CONTEXT_KEY = Symbol('auth-menu-context');
|
|
3827
|
-
`, wr = `import Root from './auth-menu.svelte';
|
|
3828
|
-
import Content from './auth-menu-content.svelte';
|
|
3829
|
-
import Trigger from './auth-menu-trigger.svelte';
|
|
3830
|
-
import Group from './auth-menu-group.svelte';
|
|
3831
|
-
import Label from './auth-menu-label.svelte';
|
|
3832
|
-
import Separator from './auth-menu-separator.svelte';
|
|
3833
|
-
import Item from './auth-menu-item.svelte';
|
|
3834
|
-
|
|
3835
|
-
export { Root, Content, Trigger, Group, Label, Separator, Item };
|
|
3836
|
-
`, yr = `import { z } from 'zod/v3';
|
|
3700
|
+
`, Fr = `import { z } from 'zod/v3';
|
|
3837
3701
|
|
|
3838
3702
|
export const changeEmailSchema = z.object({
|
|
3839
3703
|
email: z.string().email()
|
|
3840
3704
|
});
|
|
3841
|
-
`,
|
|
3705
|
+
`, Sr = `import { z } from 'zod/v3';
|
|
3842
3706
|
|
|
3843
3707
|
export const changePasswordSchema = z
|
|
3844
3708
|
.object({
|
|
@@ -3849,16 +3713,18 @@ export const changePasswordSchema = z
|
|
|
3849
3713
|
message: "Passwords don't match",
|
|
3850
3714
|
path: ['passwordConfirm']
|
|
3851
3715
|
});
|
|
3852
|
-
`,
|
|
3716
|
+
`, Cr = `import { z } from 'zod/v3';
|
|
3717
|
+
|
|
3853
3718
|
export const confirmEmailChangeSchema = z.object({
|
|
3854
3719
|
password: z.string()
|
|
3855
3720
|
});
|
|
3856
|
-
`,
|
|
3721
|
+
`, _r = `import { z } from 'zod/v3';
|
|
3722
|
+
|
|
3857
3723
|
export const confirmResetSchema = z.object({
|
|
3858
3724
|
password: z.string(),
|
|
3859
3725
|
passwordConfirm: z.string()
|
|
3860
3726
|
});
|
|
3861
|
-
`,
|
|
3727
|
+
`, kr = `import { z } from 'zod/v3';
|
|
3862
3728
|
|
|
3863
3729
|
const otpSchema = z.object({
|
|
3864
3730
|
type: z.literal('otp'),
|
|
@@ -3877,35 +3743,37 @@ const oAuth2Schema = z.object({
|
|
|
3877
3743
|
});
|
|
3878
3744
|
|
|
3879
3745
|
export const loginSchema = z.discriminatedUnion('type', [otpSchema, passwordSchema, oAuth2Schema]);
|
|
3880
|
-
`,
|
|
3746
|
+
`, Rr = `import { z } from 'zod/v3';
|
|
3747
|
+
|
|
3881
3748
|
export const otpSchema = z.object({
|
|
3882
3749
|
otp: z.string()
|
|
3883
3750
|
});
|
|
3884
|
-
`,
|
|
3751
|
+
`, Pr = `import { z } from 'zod/v3';
|
|
3885
3752
|
|
|
3886
3753
|
export const profileSchema = z.object({
|
|
3887
3754
|
name: z.string().optional(),
|
|
3888
3755
|
avatar: z.union([z.instanceof(File), z.string()]).optional(),
|
|
3889
3756
|
emailVisibility: z.boolean().optional()
|
|
3890
3757
|
});
|
|
3891
|
-
`,
|
|
3758
|
+
`, zr = `import { z } from 'zod/v3';
|
|
3759
|
+
|
|
3892
3760
|
export const resetSchema = z.object({
|
|
3893
3761
|
email: z.string().email()
|
|
3894
3762
|
});
|
|
3895
|
-
`,
|
|
3763
|
+
`, Mr = `import { z } from 'zod/v3';
|
|
3896
3764
|
|
|
3897
3765
|
export const signupSchema = z.object({
|
|
3898
3766
|
email: z.string().email(),
|
|
3899
3767
|
password: z.string(),
|
|
3900
3768
|
passwordConfirm: z.string()
|
|
3901
3769
|
});
|
|
3902
|
-
`,
|
|
3770
|
+
`, Ir = `export const load = ({ locals }) => {
|
|
3903
3771
|
const user = locals.pb.authStore.record!;
|
|
3904
3772
|
const breadcrumbs = [{ title: 'Home', url: '/dashboard' }];
|
|
3905
3773
|
|
|
3906
3774
|
return { user, breadcrumbs };
|
|
3907
3775
|
};
|
|
3908
|
-
`,
|
|
3776
|
+
`, Er = `<script lang="ts">
|
|
3909
3777
|
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3910
3778
|
import { Separator } from '$lib/components/ui/separator';
|
|
3911
3779
|
import AppSidebar from '$lib/components/app-sidebar.svelte';
|
|
@@ -3955,7 +3823,7 @@ export const signupSchema = z.object({
|
|
|
3955
3823
|
background-color: var(--color-sidebar);
|
|
3956
3824
|
}
|
|
3957
3825
|
</style>
|
|
3958
|
-
`,
|
|
3826
|
+
`, Br = "", Dr = `import { describe, it, expect } from 'vitest';
|
|
3959
3827
|
import type { Match } from '@velastack/pocketbase';
|
|
3960
3828
|
import type { RouteId } from './$types';
|
|
3961
3829
|
|
|
@@ -3972,14 +3840,14 @@ describe('dashboard', () => {
|
|
|
3972
3840
|
expect(response.status).toBe(200);
|
|
3973
3841
|
});
|
|
3974
3842
|
});
|
|
3975
|
-
`,
|
|
3843
|
+
`, Tr = `export const load = async ({ parent }) => {
|
|
3976
3844
|
const { breadcrumbs } = await parent();
|
|
3977
3845
|
|
|
3978
3846
|
return {
|
|
3979
3847
|
breadcrumbs: [...breadcrumbs, { title: 'Settings', url: '/settings' }]
|
|
3980
3848
|
};
|
|
3981
3849
|
};
|
|
3982
|
-
`,
|
|
3850
|
+
`, Ar = `import { superValidate, fail, withFiles } from 'sveltekit-superforms';
|
|
3983
3851
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
3984
3852
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
3985
3853
|
import { profileSchema } from '$lib/schemas/profile';
|
|
@@ -4048,7 +3916,7 @@ export const actions = {
|
|
|
4048
3916
|
return {};
|
|
4049
3917
|
}
|
|
4050
3918
|
};
|
|
4051
|
-
`,
|
|
3919
|
+
`, Nr = `<script lang="ts">
|
|
4052
3920
|
import { untrack } from 'svelte';
|
|
4053
3921
|
import { superForm } from 'sveltekit-superforms';
|
|
4054
3922
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
|
@@ -4326,7 +4194,7 @@ export const actions = {
|
|
|
4326
4194
|
</form>
|
|
4327
4195
|
</div>
|
|
4328
4196
|
</div>
|
|
4329
|
-
`,
|
|
4197
|
+
`, jr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
4330
4198
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4331
4199
|
import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';
|
|
4332
4200
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4353,7 +4221,7 @@ export const actions = {
|
|
|
4353
4221
|
return redirect(303, '/login');
|
|
4354
4222
|
}
|
|
4355
4223
|
};
|
|
4356
|
-
`,
|
|
4224
|
+
`, Lr = `<script lang="ts">
|
|
4357
4225
|
import { untrack } from 'svelte';
|
|
4358
4226
|
import { Button } from '$lib/components/ui/button';
|
|
4359
4227
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4421,7 +4289,7 @@ export const actions = {
|
|
|
4421
4289
|
</div>
|
|
4422
4290
|
</div>
|
|
4423
4291
|
</div>
|
|
4424
|
-
`,
|
|
4292
|
+
`, Or = `import { describe, it, expect } from 'vitest';
|
|
4425
4293
|
import type { Match } from '@velastack/pocketbase';
|
|
4426
4294
|
import type { RouteId } from './$types';
|
|
4427
4295
|
|
|
@@ -4433,7 +4301,7 @@ describe('GET /confirm-email-change/[token]', () => {
|
|
|
4433
4301
|
expect(response.status).toBe(200);
|
|
4434
4302
|
});
|
|
4435
4303
|
});
|
|
4436
|
-
`,
|
|
4304
|
+
`, qr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
4437
4305
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4438
4306
|
import { confirmResetSchema } from '$lib/schemas/confirmReset';
|
|
4439
4307
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4462,7 +4330,7 @@ export const actions = {
|
|
|
4462
4330
|
return redirect(303, '/login');
|
|
4463
4331
|
}
|
|
4464
4332
|
};
|
|
4465
|
-
`,
|
|
4333
|
+
`, Vr = `<script lang="ts">
|
|
4466
4334
|
import { untrack } from 'svelte';
|
|
4467
4335
|
import { Button } from '$lib/components/ui/button';
|
|
4468
4336
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4546,7 +4414,7 @@ export const actions = {
|
|
|
4546
4414
|
</div>
|
|
4547
4415
|
</div>
|
|
4548
4416
|
</div>
|
|
4549
|
-
`,
|
|
4417
|
+
`, Ur = `import { describe, it, expect } from 'vitest';
|
|
4550
4418
|
import type { Match } from '@velastack/pocketbase';
|
|
4551
4419
|
import type { RouteId } from './$types';
|
|
4552
4420
|
|
|
@@ -4556,7 +4424,7 @@ describe('GET /confirm-reset/[token]', () => {
|
|
|
4556
4424
|
expect(response.status).toBe(200);
|
|
4557
4425
|
});
|
|
4558
4426
|
});
|
|
4559
|
-
`,
|
|
4427
|
+
`, Hr = `import { redirect } from '@sveltejs/kit';
|
|
4560
4428
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
4561
4429
|
|
|
4562
4430
|
export const GET = async ({ params, locals, cookies }) => {
|
|
@@ -4575,7 +4443,7 @@ export const GET = async ({ params, locals, cookies }) => {
|
|
|
4575
4443
|
setFlash({ type: 'toast', message }, cookies);
|
|
4576
4444
|
redirect(303, redirectPath);
|
|
4577
4445
|
};
|
|
4578
|
-
`,
|
|
4446
|
+
`, Gr = `import { describe, it, expect } from 'vitest';
|
|
4579
4447
|
import type { Match } from '@velastack/pocketbase';
|
|
4580
4448
|
import type { RouteId } from './$types';
|
|
4581
4449
|
|
|
@@ -4588,7 +4456,7 @@ describe('GET /confirm-verification/[token]', () => {
|
|
|
4588
4456
|
expect(response.headers['location']).toBe('/login');
|
|
4589
4457
|
});
|
|
4590
4458
|
});
|
|
4591
|
-
`,
|
|
4459
|
+
`, Wr = `import { fail, superValidate, message } from 'sveltekit-superforms';
|
|
4592
4460
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4593
4461
|
import { loginSchema } from '$lib/schemas/login';
|
|
4594
4462
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4649,7 +4517,7 @@ export const actions = {
|
|
|
4649
4517
|
redirect(303, redirectUrl);
|
|
4650
4518
|
}
|
|
4651
4519
|
};
|
|
4652
|
-
`,
|
|
4520
|
+
`, Jr = `<script lang="ts">
|
|
4653
4521
|
import { untrack } from 'svelte';
|
|
4654
4522
|
import { Button } from '$lib/components/ui/button';
|
|
4655
4523
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4832,7 +4700,7 @@ export const actions = {
|
|
|
4832
4700
|
</div>
|
|
4833
4701
|
</div>
|
|
4834
4702
|
</div>
|
|
4835
|
-
`,
|
|
4703
|
+
`, Zr = `import { describe, it, expect } from 'vitest';
|
|
4836
4704
|
import * as devalue from 'devalue';
|
|
4837
4705
|
import type { Match } from '@velastack/pocketbase';
|
|
4838
4706
|
import type { RouteId } from './$types';
|
|
@@ -4879,14 +4747,14 @@ describe('POST /login', () => {
|
|
|
4879
4747
|
expect(data.form.message.text).toBe('Failed to authenticate.');
|
|
4880
4748
|
});
|
|
4881
4749
|
});
|
|
4882
|
-
`,
|
|
4750
|
+
`, Xr = `import { redirect } from '@sveltejs/kit';
|
|
4883
4751
|
|
|
4884
4752
|
export const POST = ({ cookies, locals }) => {
|
|
4885
4753
|
locals.pb.authStore.clear();
|
|
4886
4754
|
locals.pb.authStore.clearCookie(cookies);
|
|
4887
4755
|
throw redirect(303, '/');
|
|
4888
4756
|
};
|
|
4889
|
-
`,
|
|
4757
|
+
`, Yr = `import { describe, it, expect } from 'vitest';
|
|
4890
4758
|
import type { Match } from '@velastack/pocketbase';
|
|
4891
4759
|
import type { RouteId } from './$types';
|
|
4892
4760
|
|
|
@@ -4898,7 +4766,7 @@ describe('POST /logout', () => {
|
|
|
4898
4766
|
expect(response.headers.location).toBe('/');
|
|
4899
4767
|
});
|
|
4900
4768
|
});
|
|
4901
|
-
`,
|
|
4769
|
+
`, Kr = `import { fail, message, superValidate } from 'sveltekit-superforms';
|
|
4902
4770
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4903
4771
|
import { otpSchema } from '$lib/schemas/otp';
|
|
4904
4772
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4939,7 +4807,7 @@ export const actions = {
|
|
|
4939
4807
|
redirect(303, redirectUrl);
|
|
4940
4808
|
}
|
|
4941
4809
|
};
|
|
4942
|
-
`,
|
|
4810
|
+
`, Qr = `<script lang="ts">
|
|
4943
4811
|
import { untrack } from 'svelte';
|
|
4944
4812
|
import { Button } from '$lib/components/ui/button';
|
|
4945
4813
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5005,7 +4873,7 @@ export const actions = {
|
|
|
5005
4873
|
</div>
|
|
5006
4874
|
</div>
|
|
5007
4875
|
</div>
|
|
5008
|
-
`,
|
|
4876
|
+
`, ta = `import { describe, it, expect } from 'vitest';
|
|
5009
4877
|
import type { Match } from '@velastack/pocketbase';
|
|
5010
4878
|
import type { RouteId } from './$types';
|
|
5011
4879
|
|
|
@@ -5025,7 +4893,7 @@ describe('POST /otp/[token]', () => {
|
|
|
5025
4893
|
expect(response.body.status).toBe(400);
|
|
5026
4894
|
});
|
|
5027
4895
|
});
|
|
5028
|
-
`,
|
|
4896
|
+
`, ea = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
5029
4897
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
5030
4898
|
import { resetSchema } from '$lib/schemas/reset';
|
|
5031
4899
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -5053,7 +4921,7 @@ export const actions = {
|
|
|
5053
4921
|
return { form };
|
|
5054
4922
|
}
|
|
5055
4923
|
};
|
|
5056
|
-
`,
|
|
4924
|
+
`, na = `<script lang="ts">
|
|
5057
4925
|
import { untrack } from 'svelte';
|
|
5058
4926
|
import { Button } from '$lib/components/ui/button';
|
|
5059
4927
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5120,7 +4988,7 @@ export const actions = {
|
|
|
5120
4988
|
</div>
|
|
5121
4989
|
</div>
|
|
5122
4990
|
</div>
|
|
5123
|
-
`,
|
|
4991
|
+
`, ra = `import { describe, it, expect } from 'vitest';
|
|
5124
4992
|
import type { Match } from '@velastack/pocketbase';
|
|
5125
4993
|
import type { RouteId } from './$types';
|
|
5126
4994
|
|
|
@@ -5140,7 +5008,7 @@ describe('POST /reset', () => {
|
|
|
5140
5008
|
expect(response.body.status).toBe(200);
|
|
5141
5009
|
});
|
|
5142
5010
|
});
|
|
5143
|
-
`,
|
|
5011
|
+
`, aa = `import { redirect } from '@sveltejs/kit';
|
|
5144
5012
|
import { fail, superValidate } from 'sveltekit-superforms';
|
|
5145
5013
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
5146
5014
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
@@ -5196,7 +5064,7 @@ export const actions = {
|
|
|
5196
5064
|
return redirect(303, redirectUrl);
|
|
5197
5065
|
}
|
|
5198
5066
|
};
|
|
5199
|
-
`,
|
|
5067
|
+
`, oa = `<script lang="ts">
|
|
5200
5068
|
import { untrack } from 'svelte';
|
|
5201
5069
|
import { Button } from '$lib/components/ui/button';
|
|
5202
5070
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -5363,7 +5231,7 @@ export const actions = {
|
|
|
5363
5231
|
</div>
|
|
5364
5232
|
</div>
|
|
5365
5233
|
</div>
|
|
5366
|
-
`,
|
|
5234
|
+
`, sa = `import { describe, it, expect } from 'vitest';
|
|
5367
5235
|
import type { Match } from '@velastack/pocketbase';
|
|
5368
5236
|
import * as devalue from 'devalue';
|
|
5369
5237
|
import type { RouteId } from './$types';
|
|
@@ -5419,61 +5287,52 @@ describe('POST /signup', () => {
|
|
|
5419
5287
|
expect(data.form.errors.email[0]).toBe('Value must be unique.');
|
|
5420
5288
|
});
|
|
5421
5289
|
});
|
|
5422
|
-
`,
|
|
5423
|
-
"./creates/src/lib/components/app-sidebar.svelte":
|
|
5424
|
-
"./creates/src/lib/components/nav-main.svelte":
|
|
5425
|
-
"./creates/src/lib/components/nav-user.svelte":
|
|
5426
|
-
"./creates/src/lib/
|
|
5427
|
-
"./creates/src/lib/
|
|
5428
|
-
"./creates/src/lib/
|
|
5429
|
-
"./creates/src/lib/
|
|
5430
|
-
"./creates/src/lib/
|
|
5431
|
-
"./creates/src/lib/
|
|
5432
|
-
"./creates/src/lib/
|
|
5433
|
-
"./creates/src/lib/
|
|
5434
|
-
"./creates/src/lib/
|
|
5435
|
-
"./creates/src/
|
|
5436
|
-
"./creates/src/
|
|
5437
|
-
"./creates/src/
|
|
5438
|
-
"./creates/src/
|
|
5439
|
-
"./creates/src/
|
|
5440
|
-
"./creates/src/
|
|
5441
|
-
"./creates/src/
|
|
5442
|
-
"./creates/src/
|
|
5443
|
-
"./creates/src/
|
|
5444
|
-
"./creates/src/routes/(
|
|
5445
|
-
"./creates/src/routes/(
|
|
5446
|
-
"./creates/src/routes/(
|
|
5447
|
-
"./creates/src/routes/(
|
|
5448
|
-
"./creates/src/routes/(
|
|
5449
|
-
"./creates/src/routes/(
|
|
5450
|
-
"./creates/src/routes/(
|
|
5451
|
-
"./creates/src/routes/(public)/
|
|
5452
|
-
"./creates/src/routes/(public)/
|
|
5453
|
-
"./creates/src/routes/(public)/
|
|
5454
|
-
"./creates/src/routes/(public)/
|
|
5455
|
-
"./creates/src/routes/(public)/
|
|
5456
|
-
"./creates/src/routes/(public)/
|
|
5457
|
-
"./creates/src/routes/(public)/
|
|
5458
|
-
"./creates/src/routes/(public)/
|
|
5459
|
-
"./creates/src/routes/(public)/
|
|
5460
|
-
"./creates/src/routes/(public)/
|
|
5461
|
-
"./creates/src/routes/(public)/
|
|
5462
|
-
"./creates/src/routes/(public)/
|
|
5463
|
-
"./creates/src/routes/(public)/
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
"./creates/src/routes/(public)/reset/+page.svelte": Qr,
|
|
5469
|
-
"./creates/src/routes/(public)/reset/server.test.ts": ta,
|
|
5470
|
-
"./creates/src/routes/(public)/signup/+page.server.ts": ea,
|
|
5471
|
-
"./creates/src/routes/(public)/signup/+page.svelte": na,
|
|
5472
|
-
"./creates/src/routes/(public)/signup/server.test.ts": ra
|
|
5473
|
-
}), oa = "./creates/";
|
|
5474
|
-
async function sa(t) {
|
|
5475
|
-
const e = Object.entries(aa).map(([o, s]) => {
|
|
5476
|
-
const i = Et(o, oa);
|
|
5290
|
+
`, ia = /* @__PURE__ */ Object.assign({
|
|
5291
|
+
"./creates/src/lib/components/app-sidebar.svelte": yr,
|
|
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);
|
|
5477
5336
|
return {
|
|
5478
5337
|
path: i,
|
|
5479
5338
|
language: j(i),
|
|
@@ -5564,379 +5423,141 @@ async function sa(t) {
|
|
|
5564
5423
|
]
|
|
5565
5424
|
};
|
|
5566
5425
|
}
|
|
5567
|
-
const
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
fields: [
|
|
5574
|
-
{
|
|
5575
|
-
autogeneratePattern: '[a-z0-9]{15}',
|
|
5576
|
-
hidden: false,
|
|
5577
|
-
id: 'text3208210256',
|
|
5578
|
-
max: 15,
|
|
5579
|
-
min: 15,
|
|
5580
|
-
name: 'id',
|
|
5581
|
-
pattern: '^[a-z0-9]+$',
|
|
5582
|
-
presentable: false,
|
|
5583
|
-
primaryKey: true,
|
|
5584
|
-
required: true,
|
|
5585
|
-
system: true,
|
|
5586
|
-
type: 'text'
|
|
5587
|
-
},
|
|
5588
|
-
{
|
|
5589
|
-
cascadeDelete: false,
|
|
5590
|
-
collectionId: '_pb_users_auth_',
|
|
5591
|
-
hidden: false,
|
|
5592
|
-
id: 'relation2375276105',
|
|
5593
|
-
maxSelect: 1,
|
|
5594
|
-
minSelect: 0,
|
|
5595
|
-
name: 'user',
|
|
5596
|
-
presentable: false,
|
|
5597
|
-
required: true,
|
|
5598
|
-
system: false,
|
|
5599
|
-
type: 'relation'
|
|
5600
|
-
},
|
|
5601
|
-
{
|
|
5602
|
-
autogeneratePattern: '',
|
|
5603
|
-
hidden: false,
|
|
5604
|
-
id: 'text1044722854',
|
|
5605
|
-
max: 0,
|
|
5606
|
-
min: 0,
|
|
5607
|
-
name: 'providerId',
|
|
5608
|
-
pattern: '',
|
|
5609
|
-
presentable: false,
|
|
5610
|
-
primaryKey: false,
|
|
5611
|
-
required: true,
|
|
5612
|
-
system: false,
|
|
5613
|
-
type: 'text'
|
|
5614
|
-
},
|
|
5615
|
-
{
|
|
5616
|
-
autogeneratePattern: '',
|
|
5617
|
-
hidden: false,
|
|
5618
|
-
id: 'text2462348188',
|
|
5619
|
-
max: 0,
|
|
5620
|
-
min: 0,
|
|
5621
|
-
name: 'provider',
|
|
5622
|
-
pattern: '',
|
|
5623
|
-
presentable: false,
|
|
5624
|
-
primaryKey: false,
|
|
5625
|
-
required: true,
|
|
5626
|
-
system: false,
|
|
5627
|
-
type: 'text'
|
|
5628
|
-
},
|
|
5629
|
-
{
|
|
5630
|
-
autogeneratePattern: '',
|
|
5631
|
-
hidden: false,
|
|
5632
|
-
id: 'text889886754',
|
|
5633
|
-
max: 0,
|
|
5634
|
-
min: 0,
|
|
5635
|
-
name: 'accessToken',
|
|
5636
|
-
pattern: '',
|
|
5637
|
-
presentable: false,
|
|
5638
|
-
primaryKey: false,
|
|
5639
|
-
required: false,
|
|
5640
|
-
system: false,
|
|
5641
|
-
type: 'text'
|
|
5642
|
-
},
|
|
5643
|
-
{
|
|
5644
|
-
autogeneratePattern: '',
|
|
5645
|
-
hidden: false,
|
|
5646
|
-
id: 'text1769204838',
|
|
5647
|
-
max: 0,
|
|
5648
|
-
min: 0,
|
|
5649
|
-
name: 'refreshToken',
|
|
5650
|
-
pattern: '',
|
|
5651
|
-
presentable: false,
|
|
5652
|
-
primaryKey: false,
|
|
5653
|
-
required: false,
|
|
5654
|
-
system: false,
|
|
5655
|
-
type: 'text'
|
|
5656
|
-
},
|
|
5657
|
-
{
|
|
5658
|
-
autogeneratePattern: '',
|
|
5659
|
-
hidden: false,
|
|
5660
|
-
id: 'text2192111876',
|
|
5661
|
-
max: 0,
|
|
5662
|
-
min: 0,
|
|
5663
|
-
name: 'avatarURL',
|
|
5664
|
-
pattern: '',
|
|
5665
|
-
presentable: false,
|
|
5666
|
-
primaryKey: false,
|
|
5667
|
-
required: false,
|
|
5668
|
-
system: false,
|
|
5669
|
-
type: 'text'
|
|
5670
|
-
},
|
|
5671
|
-
{
|
|
5672
|
-
hidden: false,
|
|
5673
|
-
id: 'date951064219',
|
|
5674
|
-
max: '',
|
|
5675
|
-
min: '',
|
|
5676
|
-
name: 'expiry',
|
|
5677
|
-
presentable: false,
|
|
5678
|
-
required: false,
|
|
5679
|
-
system: false,
|
|
5680
|
-
type: 'date'
|
|
5681
|
-
},
|
|
5682
|
-
{
|
|
5683
|
-
autogeneratePattern: '',
|
|
5684
|
-
hidden: false,
|
|
5685
|
-
id: 'text3885137012',
|
|
5686
|
-
max: 0,
|
|
5687
|
-
min: 0,
|
|
5688
|
-
name: 'email',
|
|
5689
|
-
pattern: '',
|
|
5690
|
-
presentable: false,
|
|
5691
|
-
primaryKey: false,
|
|
5692
|
-
required: false,
|
|
5693
|
-
system: false,
|
|
5694
|
-
type: 'text'
|
|
5695
|
-
},
|
|
5696
|
-
{
|
|
5697
|
-
autogeneratePattern: '',
|
|
5698
|
-
hidden: false,
|
|
5699
|
-
id: 'text1579384326',
|
|
5700
|
-
max: 0,
|
|
5701
|
-
min: 0,
|
|
5702
|
-
name: 'name',
|
|
5703
|
-
pattern: '',
|
|
5704
|
-
presentable: false,
|
|
5705
|
-
primaryKey: false,
|
|
5706
|
-
required: false,
|
|
5707
|
-
system: false,
|
|
5708
|
-
type: 'text'
|
|
5709
|
-
},
|
|
5710
|
-
{
|
|
5711
|
-
autogeneratePattern: '',
|
|
5712
|
-
hidden: false,
|
|
5713
|
-
id: 'text4166911607',
|
|
5714
|
-
max: 0,
|
|
5715
|
-
min: 0,
|
|
5716
|
-
name: 'username',
|
|
5717
|
-
pattern: '',
|
|
5718
|
-
presentable: false,
|
|
5719
|
-
primaryKey: false,
|
|
5720
|
-
required: false,
|
|
5721
|
-
system: false,
|
|
5722
|
-
type: 'text'
|
|
5723
|
-
},
|
|
5724
|
-
{
|
|
5725
|
-
hidden: false,
|
|
5726
|
-
id: 'json1646549047',
|
|
5727
|
-
maxSize: 0,
|
|
5728
|
-
name: 'rawUser',
|
|
5729
|
-
presentable: false,
|
|
5730
|
-
required: false,
|
|
5731
|
-
system: false,
|
|
5732
|
-
type: 'json'
|
|
5733
|
-
}
|
|
5734
|
-
],
|
|
5735
|
-
id: 'pbc_3445581863',
|
|
5736
|
-
indexes: [],
|
|
5737
|
-
listRule: '@request.auth.id = user.id',
|
|
5738
|
-
name: 'oauth_accounts',
|
|
5739
|
-
system: false,
|
|
5740
|
-
type: 'base',
|
|
5741
|
-
updateRule: null,
|
|
5742
|
-
viewRule: '@request.auth.id = user.id'
|
|
5743
|
-
});
|
|
5744
|
-
|
|
5745
|
-
return app.save(collection);
|
|
5746
|
-
},
|
|
5747
|
-
(app) => {
|
|
5748
|
-
const collection = app.findCollectionByNameOrId('pbc_3445581863');
|
|
5749
|
-
|
|
5750
|
-
return app.delete(collection);
|
|
5751
|
-
}
|
|
5752
|
-
);
|
|
5753
|
-
`, la = `/// <reference path="../pb_data/types.d.ts" />
|
|
5754
|
-
migrate(
|
|
5755
|
-
(app) => {
|
|
5756
|
-
const collection = app.findCollectionByNameOrId('_pb_users_auth_');
|
|
5757
|
-
|
|
5758
|
-
// update collection data
|
|
5759
|
-
unmarshal(
|
|
5760
|
-
{
|
|
5761
|
-
confirmEmailChangeTemplate: {
|
|
5762
|
-
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>'
|
|
5763
|
-
},
|
|
5764
|
-
createRule: '@request.auth.id = id',
|
|
5765
|
-
deleteRule: '@request.auth.id = id',
|
|
5766
|
-
listRule: '@request.auth.id = id',
|
|
5767
|
-
resetPasswordTemplate: {
|
|
5768
|
-
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>'
|
|
5769
|
-
},
|
|
5770
|
-
updateRule: '@request.auth.id = id',
|
|
5771
|
-
verificationTemplate: {
|
|
5772
|
-
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>'
|
|
5773
|
-
},
|
|
5774
|
-
viewRule: '@request.auth.id = id'
|
|
5775
|
-
},
|
|
5776
|
-
collection
|
|
5777
|
-
);
|
|
5778
|
-
|
|
5779
|
-
return app.save(collection);
|
|
5780
|
-
},
|
|
5781
|
-
(app) => {
|
|
5782
|
-
const collection = app.findCollectionByNameOrId('_pb_users_auth_');
|
|
5783
|
-
|
|
5784
|
-
// update collection data
|
|
5785
|
-
unmarshal(
|
|
5786
|
-
{
|
|
5787
|
-
confirmEmailChangeTemplate: {
|
|
5788
|
-
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>'
|
|
5789
|
-
},
|
|
5790
|
-
createRule: '',
|
|
5791
|
-
deleteRule: 'id = @request.auth.id',
|
|
5792
|
-
listRule: 'id = @request.auth.id',
|
|
5793
|
-
resetPasswordTemplate: {
|
|
5794
|
-
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>'
|
|
5795
|
-
},
|
|
5796
|
-
updateRule: 'id = @request.auth.id',
|
|
5797
|
-
verificationTemplate: {
|
|
5798
|
-
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>'
|
|
5799
|
-
},
|
|
5800
|
-
viewRule: 'id = @request.auth.id'
|
|
5801
|
-
},
|
|
5802
|
-
collection
|
|
5803
|
-
);
|
|
5804
|
-
|
|
5805
|
-
return app.save(collection);
|
|
5806
|
-
}
|
|
5807
|
-
);
|
|
5808
|
-
`, ca = `import {
|
|
5809
|
-
POCKETBASE_URL,
|
|
5810
|
-
POCKETBASE_SUPERUSER_EMAIL,
|
|
5811
|
-
POCKETBASE_SUPERUSER_PASSWORD
|
|
5812
|
-
} from '$env/static/private';
|
|
5813
|
-
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";
|
|
5814
5432
|
|
|
5815
5433
|
export const handle = handlePocketbase({
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5434
|
+
pocketbaseUrl: POCKETBASE_URL,
|
|
5435
|
+
superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
|
|
5436
|
+
superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,
|
|
5437
|
+
auth: { protectedRoutes: ["/(app)"] }, // [!code ++]
|
|
5820
5438
|
});
|
|
5821
|
-
`,
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
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";
|
|
5445
|
+
|
|
5446
|
+
let { children, data } = $props();
|
|
5829
5447
|
<\/script>
|
|
5830
5448
|
|
|
5831
5449
|
<div class="min-h-dvh grid grid-rows-[max-content_1fr_max-content] root-layout">
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
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
|
-
|
|
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>
|
|
5914
5537
|
</div>
|
|
5915
5538
|
|
|
5916
5539
|
<style lang="postcss">
|
|
5917
|
-
|
|
5540
|
+
@reference "tailwindcss";
|
|
5918
5541
|
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5542
|
+
.root-layout :global(section[data-role="content"]) {
|
|
5543
|
+
@apply container mx-auto max-w-7xl px-4 py-8 w-full;
|
|
5544
|
+
}
|
|
5922
5545
|
</style>
|
|
5923
|
-
`,
|
|
5546
|
+
`, da = `import { loadFlash } from "sveltekit-flash-message/server";
|
|
5924
5547
|
|
|
5925
5548
|
export const load = loadFlash(async ({ locals }) => {
|
|
5926
5549
|
return {
|
|
5927
|
-
user: locals.pb.authStore.record,
|
|
5550
|
+
user: locals.pb.authStore.record, // [!code ++]
|
|
5928
5551
|
};
|
|
5929
5552
|
});
|
|
5930
5553
|
`, pa = /* @__PURE__ */ Object.assign({
|
|
5931
|
-
"./preview-modifies/
|
|
5932
|
-
"./preview-modifies/
|
|
5933
|
-
"./preview-modifies/src/
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
}), da = "./preview-modifies/";
|
|
5937
|
-
async function fa(t) {
|
|
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) {
|
|
5938
5559
|
const e = Object.entries(pa).map(([n, r]) => {
|
|
5939
|
-
const o =
|
|
5560
|
+
const o = Mt(n, fa);
|
|
5940
5561
|
return {
|
|
5941
5562
|
path: o,
|
|
5942
5563
|
language: j(o),
|
|
@@ -5952,20 +5573,31 @@ async function fa(t) {
|
|
|
5952
5573
|
collections: []
|
|
5953
5574
|
};
|
|
5954
5575
|
}
|
|
5955
|
-
const ha = "enable-auth";
|
|
5956
|
-
async function
|
|
5957
|
-
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);
|
|
5958
5579
|
if (t.env === "preview") {
|
|
5959
|
-
const s = await
|
|
5960
|
-
return k(
|
|
5580
|
+
const s = await ga();
|
|
5581
|
+
return k(dt([e, s]));
|
|
5961
5582
|
}
|
|
5962
|
-
const { generate: n } = await import("./generate.runtime-
|
|
5963
|
-
return o(
|
|
5583
|
+
const { generate: n } = await import("./generate.runtime-BhWmEK-_.js"), r = await n(t), { writeResult: o } = await import("./write-result-CbUTMeAc.js");
|
|
5584
|
+
return o(
|
|
5585
|
+
await k(dt([e, r])),
|
|
5586
|
+
t
|
|
5587
|
+
);
|
|
5964
5588
|
}
|
|
5965
|
-
const
|
|
5589
|
+
const $a = {
|
|
5590
|
+
version: ba,
|
|
5966
5591
|
slug: ha,
|
|
5592
|
+
source: va,
|
|
5593
|
+
docs: wa,
|
|
5594
|
+
plan: "open",
|
|
5967
5595
|
title: "Enable authentication",
|
|
5968
5596
|
summary: "Enables authentication.",
|
|
5597
|
+
requires: {
|
|
5598
|
+
auth: !1,
|
|
5599
|
+
payments: !1
|
|
5600
|
+
},
|
|
5969
5601
|
categories: ["authentication"],
|
|
5970
5602
|
tags: [
|
|
5971
5603
|
"sveltekit",
|
|
@@ -5981,26 +5613,25 @@ const ba = {
|
|
|
5981
5613
|
argv: []
|
|
5982
5614
|
},
|
|
5983
5615
|
baseline: "velastack",
|
|
5984
|
-
generate:
|
|
5985
|
-
},
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
],
|
|
5992
|
-
(t
|
|
5993
|
-
|
|
5994
|
-
), Ca = {
|
|
5616
|
+
generate: ya
|
|
5617
|
+
}, Jt = [
|
|
5618
|
+
Rn,
|
|
5619
|
+
wr,
|
|
5620
|
+
Un,
|
|
5621
|
+
cr,
|
|
5622
|
+
$a
|
|
5623
|
+
], xa = Object.fromEntries(
|
|
5624
|
+
Jt.map((t) => [t.slug, t])
|
|
5625
|
+
), Ra = {
|
|
5995
5626
|
version: "0.1.0",
|
|
5996
|
-
patterns:
|
|
5997
|
-
bySlug:
|
|
5627
|
+
patterns: Jt,
|
|
5628
|
+
bySlug: xa
|
|
5998
5629
|
};
|
|
5999
5630
|
export {
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
5631
|
+
_a as D,
|
|
5632
|
+
ka as M,
|
|
5633
|
+
d,
|
|
5634
|
+
Ra as i,
|
|
6004
5635
|
j as l
|
|
6005
5636
|
};
|
|
6006
|
-
//# sourceMappingURL=index-
|
|
5637
|
+
//# sourceMappingURL=index-DrD7d78j.js.map
|