@velastack/patterns 0.0.16 → 0.0.17
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-g6OYst1X.js → collections-BQ2vnlIE.js} +3 -3
- package/dist/chunks/{collections-g6OYst1X.js.map → collections-BQ2vnlIE.js.map} +1 -1
- package/dist/chunks/{env.runtime-BTICtvm9.js → env.runtime-BGG6V4qg.js} +2 -2
- package/dist/chunks/{env.runtime-BTICtvm9.js.map → env.runtime-BGG6V4qg.js.map} +1 -1
- package/dist/chunks/generate.runtime-BjFzQdEe.js +227 -0
- package/dist/chunks/generate.runtime-BjFzQdEe.js.map +1 -0
- package/dist/chunks/{generate.runtime-AE_6Wd2H.js → generate.runtime-CL_SU1wV.js} +3 -3
- package/dist/chunks/{generate.runtime-AE_6Wd2H.js.map → generate.runtime-CL_SU1wV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B_lW3Sj0.js → generate.runtime-DDZCukG0.js} +2 -2
- package/dist/chunks/{generate.runtime-B_lW3Sj0.js.map → generate.runtime-DDZCukG0.js.map} +1 -1
- package/dist/chunks/{index-BOXPYvqZ.js → index-ZTxLoBuU.js} +894 -458
- package/dist/chunks/index-ZTxLoBuU.js.map +1 -0
- package/dist/chunks/{pocketbase-boRXWhip.js → pocketbase-CtWkx70o.js} +2 -2
- package/dist/chunks/{pocketbase-boRXWhip.js.map → pocketbase-CtWkx70o.js.map} +1 -1
- package/dist/index.d.ts +63 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-BOXPYvqZ.js.map +0 -1
|
@@ -22,13 +22,13 @@ async function re(t) {
|
|
|
22
22
|
return t;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function pt(t) {
|
|
26
26
|
return Promise.all(t.map((e) => re(e)));
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function F(t) {
|
|
29
29
|
const [e, n] = await Promise.all([
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
pt(t.creates),
|
|
31
|
+
pt(t.modifies)
|
|
32
32
|
]);
|
|
33
33
|
return {
|
|
34
34
|
...t,
|
|
@@ -36,7 +36,7 @@ async function S(t) {
|
|
|
36
36
|
modifies: n
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ut(t, e) {
|
|
40
40
|
var n = Object.keys(t);
|
|
41
41
|
if (Object.getOwnPropertySymbols) {
|
|
42
42
|
var a = Object.getOwnPropertySymbols(t);
|
|
@@ -49,9 +49,9 @@ function pt(t, e) {
|
|
|
49
49
|
function dt(t) {
|
|
50
50
|
for (var e = 1; e < arguments.length; e++) {
|
|
51
51
|
var n = arguments[e] != null ? arguments[e] : {};
|
|
52
|
-
e % 2 ?
|
|
52
|
+
e % 2 ? ut(Object(n), !0).forEach(function(a) {
|
|
53
53
|
oe(t, a, n[a]);
|
|
54
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) :
|
|
54
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ut(Object(n)).forEach(function(a) {
|
|
55
55
|
Object.defineProperty(t, a, Object.getOwnPropertyDescriptor(n, a));
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -74,9 +74,9 @@ function ie(t, e) {
|
|
|
74
74
|
}
|
|
75
75
|
return (e === "string" ? String : Number)(t);
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
function
|
|
79
|
-
return e.withOptions = (n) =>
|
|
77
|
+
const u = It({});
|
|
78
|
+
function It(t) {
|
|
79
|
+
return e.withOptions = (n) => It(dt(dt({}, t), n)), e;
|
|
80
80
|
function e(n, ...a) {
|
|
81
81
|
const r = typeof n == "string" ? [n] : n.raw, {
|
|
82
82
|
alignValues: s = !1,
|
|
@@ -111,8 +111,8 @@ function zt(t) {
|
|
|
111
111
|
// Matches e.g. \\u{1f60a} or \\u5F1F
|
|
112
112
|
/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,
|
|
113
113
|
(f, h, $) => {
|
|
114
|
-
var
|
|
115
|
-
const l = (
|
|
114
|
+
var p;
|
|
115
|
+
const l = (p = h ?? $) !== null && p !== void 0 ? p : "";
|
|
116
116
|
return String.fromCodePoint(parseInt(l, 16));
|
|
117
117
|
}
|
|
118
118
|
)), c;
|
|
@@ -131,13 +131,13 @@ ${r}`);
|
|
|
131
131
|
}
|
|
132
132
|
return t;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function I(t, e) {
|
|
135
135
|
return t.startsWith(e) ? t.slice(e.length) : t.replace(/^\.\//, "");
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function C(t) {
|
|
138
138
|
return t.endsWith(".svelte") ? "svelte" : t.endsWith(".tsx") || t.endsWith(".ts") ? "ts" : t.endsWith(".jsx") || t.endsWith(".js") ? "js" : "text";
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function E(t) {
|
|
141
141
|
return t.reduce(
|
|
142
142
|
(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),
|
|
143
143
|
{
|
|
@@ -179,56 +179,56 @@ const ce = {
|
|
|
179
179
|
geopoint: ['import { GeopointInput } from "$lib/components/ui/geopoint";'],
|
|
180
180
|
button: ['import { Button } from "$lib/components/ui/button";']
|
|
181
181
|
};
|
|
182
|
-
function
|
|
182
|
+
function z(t) {
|
|
183
183
|
return `$formData.${t.name}`;
|
|
184
184
|
}
|
|
185
185
|
function q(t) {
|
|
186
186
|
return t.inputProps ? Object.entries(t.inputProps).flatMap(([e, n]) => n == null || n === !1 ? [] : n === !0 ? [` ${e}`] : [` ${e}=${JSON.stringify(String(n))}`]).join("") : "";
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
return t.labelAside ?
|
|
188
|
+
function M(t) {
|
|
189
|
+
return t.labelAside ? u`
|
|
190
190
|
<div class="flex justify-between">
|
|
191
191
|
<Form.Label>${t.title}</Form.Label>
|
|
192
192
|
${t.labelAside}
|
|
193
193
|
</div>
|
|
194
194
|
` : `<Form.Label>${t.title}</Form.Label>`;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function T(t, e) {
|
|
197
197
|
const n = t.required ? " required" : "";
|
|
198
|
-
return
|
|
198
|
+
return u`
|
|
199
199
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
200
200
|
<Form.Control>
|
|
201
201
|
{#snippet children({ props })}
|
|
202
|
-
${
|
|
203
|
-
<Input {...props} type="${e}" bind:value={${
|
|
202
|
+
${M(t)}
|
|
203
|
+
<Input {...props} type="${e}" bind:value={${z(t)}}${n}${q(t)} />
|
|
204
204
|
{/snippet}
|
|
205
205
|
</Form.Control>
|
|
206
206
|
<Form.FieldErrors class="contents text-destructive" />
|
|
207
207
|
</Form.Field>
|
|
208
208
|
`;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function pe(t) {
|
|
211
211
|
const e = t.required ? " required" : "";
|
|
212
|
-
return
|
|
212
|
+
return u`
|
|
213
213
|
<Form.Field {form} name="${t.name}" class="col-span-2">
|
|
214
214
|
<Form.Control>
|
|
215
215
|
{#snippet children({ props })}
|
|
216
|
-
${
|
|
217
|
-
<Textarea {...props} bind:value={${
|
|
216
|
+
${M(t)}
|
|
217
|
+
<Textarea {...props} bind:value={${z(t)}}${e}${q(t)} />
|
|
218
218
|
{/snippet}
|
|
219
219
|
</Form.Control>
|
|
220
220
|
<Form.FieldErrors class="contents text-destructive" />
|
|
221
221
|
</Form.Field>
|
|
222
222
|
`;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function ue(t) {
|
|
225
225
|
const e = t.required ? " required" : "";
|
|
226
|
-
return
|
|
226
|
+
return u`
|
|
227
227
|
<Form.Field {form} name="${t.name}" class="col-span-1 flex items-start space-x-2">
|
|
228
228
|
<Form.Control>
|
|
229
229
|
{#snippet children({ props })}
|
|
230
|
-
<Checkbox {...props} bind:checked={${
|
|
231
|
-
${
|
|
230
|
+
<Checkbox {...props} bind:checked={${z(t)}}${e}${q(t)} />
|
|
231
|
+
${M(t)}
|
|
232
232
|
{/snippet}
|
|
233
233
|
</Form.Control>
|
|
234
234
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -236,12 +236,12 @@ function pe(t) {
|
|
|
236
236
|
`;
|
|
237
237
|
}
|
|
238
238
|
function de(t) {
|
|
239
|
-
return
|
|
239
|
+
return u`
|
|
240
240
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
241
241
|
<Form.Control>
|
|
242
242
|
{#snippet children({ props })}
|
|
243
|
-
${
|
|
244
|
-
<GeopointInput {...props} bind:value={${
|
|
243
|
+
${M(t)}
|
|
244
|
+
<GeopointInput {...props} bind:value={${z(t)}} />
|
|
245
245
|
{/snippet}
|
|
246
246
|
</Form.Control>
|
|
247
247
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -250,11 +250,11 @@ function de(t) {
|
|
|
250
250
|
}
|
|
251
251
|
function fe(t) {
|
|
252
252
|
const e = t.required ? " required" : "", n = t.maxSelect > 1 ? "Multiple" : "Single";
|
|
253
|
-
return
|
|
253
|
+
return u`
|
|
254
254
|
<FileForm.Field {form} name="${t.name}" class="col-span-1">
|
|
255
255
|
<Form.Control>
|
|
256
256
|
{#snippet children({ props })}
|
|
257
|
-
${
|
|
257
|
+
${M(t)}
|
|
258
258
|
<FileForm.${n}>
|
|
259
259
|
{#snippet display({ file, filename, onremove })}
|
|
260
260
|
<div class="flex gap-2 justify-between items-center">
|
|
@@ -280,13 +280,13 @@ function ge(t) {
|
|
|
280
280
|
(s) => `<MultiSelect.Item value=${JSON.stringify(s.value)} label={${t.name}Labels[${JSON.stringify(s.value)}].label} />`
|
|
281
281
|
).join(`
|
|
282
282
|
`);
|
|
283
|
-
return
|
|
283
|
+
return u`
|
|
284
284
|
<MultiSelect.Field {form} type="${e}" name="${t.name}"${n} class="col-span-1">
|
|
285
285
|
<Form.Control>
|
|
286
286
|
{#snippet children({ props })}
|
|
287
|
-
${
|
|
287
|
+
${M(t)}
|
|
288
288
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
289
|
-
<MultiSelect.Input bind:value={${
|
|
289
|
+
<MultiSelect.Input bind:value={${z(t)}} placeholder="${a}" {...props}>
|
|
290
290
|
{#snippet children({ selected })}
|
|
291
291
|
<div class="flex flex-wrap gap-1">
|
|
292
292
|
{#each selected as value}
|
|
@@ -315,13 +315,13 @@ function ge(t) {
|
|
|
315
315
|
}
|
|
316
316
|
function he(t) {
|
|
317
317
|
const e = t.maxSelect > 1 ? "multiple" : "single", n = t.maxSelect > 1 ? `Select ${t.relatedModel.pluralDisplayName.toLowerCase()}` : `Select ${t.relatedModel.displayName.toLowerCase()}`, a = `Search ${t.relatedModel.pluralDisplayName.toLowerCase()}...`, r = `No ${t.relatedModel.pluralDisplayName.toLowerCase()} found`, s = t.relatedModel.name, i = t.relatedModel.pluralName;
|
|
318
|
-
return
|
|
318
|
+
return u`
|
|
319
319
|
<MultiSelect.Field {form} type="${e}" name="${t.name}" class="col-span-1">
|
|
320
320
|
<Form.Control>
|
|
321
321
|
{#snippet children({ props })}
|
|
322
322
|
<Form.Label>${t.title}</Form.Label>
|
|
323
323
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
324
|
-
<MultiSelect.Input bind:value={${
|
|
324
|
+
<MultiSelect.Input bind:value={${z(t)}} placeholder="${n}" {...props}>
|
|
325
325
|
{#snippet children({ selected })}
|
|
326
326
|
<div class="flex flex-wrap gap-1">
|
|
327
327
|
{#each selected as value}
|
|
@@ -352,12 +352,12 @@ function he(t) {
|
|
|
352
352
|
`;
|
|
353
353
|
}
|
|
354
354
|
function be(t) {
|
|
355
|
-
return
|
|
355
|
+
return u`
|
|
356
356
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
357
357
|
<Form.Control>
|
|
358
358
|
{#snippet children({ props })}
|
|
359
|
-
${
|
|
360
|
-
<Input {...props} type="text" value={${
|
|
359
|
+
${M(t)}
|
|
360
|
+
<Input {...props} type="text" value={${z(t)}}${q(t)} readonly />
|
|
361
361
|
{/snippet}
|
|
362
362
|
</Form.Control>
|
|
363
363
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -367,24 +367,24 @@ function be(t) {
|
|
|
367
367
|
function at(t) {
|
|
368
368
|
switch (t.type) {
|
|
369
369
|
case "text":
|
|
370
|
-
return
|
|
370
|
+
return T(t, "text");
|
|
371
371
|
case "number":
|
|
372
|
-
return
|
|
372
|
+
return T(t, "number");
|
|
373
373
|
case "date":
|
|
374
|
-
return
|
|
374
|
+
return T(t, "date");
|
|
375
375
|
case "email":
|
|
376
|
-
return
|
|
376
|
+
return T(t, "email");
|
|
377
377
|
case "password":
|
|
378
|
-
return
|
|
378
|
+
return T(t, "password");
|
|
379
379
|
case "url":
|
|
380
|
-
return
|
|
380
|
+
return T(t, "url");
|
|
381
381
|
case "autodate":
|
|
382
382
|
return be(t);
|
|
383
383
|
case "editor":
|
|
384
384
|
case "json":
|
|
385
|
-
return ue(t);
|
|
386
|
-
case "bool":
|
|
387
385
|
return pe(t);
|
|
386
|
+
case "bool":
|
|
387
|
+
return ue(t);
|
|
388
388
|
case "geoPoint":
|
|
389
389
|
return de(t);
|
|
390
390
|
case "file":
|
|
@@ -397,9 +397,9 @@ function at(t) {
|
|
|
397
397
|
return t;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function zt(t) {
|
|
401
401
|
const e = t.options.map(
|
|
402
|
-
(n) =>
|
|
402
|
+
(n) => u`
|
|
403
403
|
${JSON.stringify(n.value)}: {
|
|
404
404
|
label: ${JSON.stringify(n.label)},
|
|
405
405
|
value: ${JSON.stringify(n.value)}
|
|
@@ -407,7 +407,7 @@ function It(t) {
|
|
|
407
407
|
`
|
|
408
408
|
).join(`,
|
|
409
409
|
`);
|
|
410
|
-
return
|
|
410
|
+
return u`
|
|
411
411
|
const ${t.name}Labels = {
|
|
412
412
|
${e}
|
|
413
413
|
} as const;
|
|
@@ -424,7 +424,7 @@ function P(t, e) {
|
|
|
424
424
|
return `data.${t.name}.${e.name}`;
|
|
425
425
|
}
|
|
426
426
|
function Q(t, e, n) {
|
|
427
|
-
return
|
|
427
|
+
return u`
|
|
428
428
|
<div class="space-y-2">
|
|
429
429
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
430
430
|
<p class="text-muted-foreground">${n}</p>
|
|
@@ -432,29 +432,29 @@ function Q(t, e, n) {
|
|
|
432
432
|
`;
|
|
433
433
|
}
|
|
434
434
|
function ve(t, e) {
|
|
435
|
-
const n = P(t, e), a = `<p class="text-muted-foreground">{new Date(${n}).toLocaleDateString()}</p>`, r = e.required ? a :
|
|
435
|
+
const n = P(t, e), a = `<p class="text-muted-foreground">{new Date(${n}).toLocaleDateString()}</p>`, r = e.required ? a : u`
|
|
436
436
|
{#if ${n}}
|
|
437
437
|
${a}
|
|
438
438
|
{/if}
|
|
439
439
|
`;
|
|
440
|
-
return
|
|
440
|
+
return u`
|
|
441
441
|
<div class="space-y-2">
|
|
442
442
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
443
443
|
${r}
|
|
444
444
|
</div>
|
|
445
445
|
`;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
448
|
-
const n = P(t, e), a =
|
|
447
|
+
function ye(t, e) {
|
|
448
|
+
const n = P(t, e), a = u`
|
|
449
449
|
<a href={${n}} target="_blank" rel="noopener noreferrer">
|
|
450
450
|
{${n}}
|
|
451
451
|
</a>
|
|
452
|
-
`, r = e.required ? a :
|
|
452
|
+
`, r = e.required ? a : u`
|
|
453
453
|
{#if ${n}}
|
|
454
454
|
${a}
|
|
455
455
|
{/if}
|
|
456
456
|
`;
|
|
457
|
-
return
|
|
457
|
+
return u`
|
|
458
458
|
<div class="space-y-2">
|
|
459
459
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
460
460
|
<p class="text-muted-foreground">
|
|
@@ -463,10 +463,10 @@ function we(t, e) {
|
|
|
463
463
|
</div>
|
|
464
464
|
`;
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function we(t, e) {
|
|
467
467
|
const n = P(t, e);
|
|
468
468
|
if (e.maxSelect > 1)
|
|
469
|
-
return
|
|
469
|
+
return u`
|
|
470
470
|
<div class="space-y-2">
|
|
471
471
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
472
472
|
{#each ${n} as ${e.name}}
|
|
@@ -474,12 +474,12 @@ function ye(t, e) {
|
|
|
474
474
|
{/each}
|
|
475
475
|
</div>
|
|
476
476
|
`;
|
|
477
|
-
const a = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, r = e.required ? a :
|
|
477
|
+
const a = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, r = e.required ? a : u`
|
|
478
478
|
{#if ${n}}
|
|
479
479
|
${a}
|
|
480
480
|
{/if}
|
|
481
481
|
`;
|
|
482
|
-
return
|
|
482
|
+
return u`
|
|
483
483
|
<div class="space-y-2">
|
|
484
484
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
485
485
|
${r}
|
|
@@ -488,7 +488,7 @@ function ye(t, e) {
|
|
|
488
488
|
}
|
|
489
489
|
function $e(t, e) {
|
|
490
490
|
const n = P(t, e);
|
|
491
|
-
return e.maxSelect > 1 ?
|
|
491
|
+
return e.maxSelect > 1 ? u`
|
|
492
492
|
<div class="space-y-2">
|
|
493
493
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
494
494
|
{#if ${n}}
|
|
@@ -510,7 +510,7 @@ function $e(t, e) {
|
|
|
510
510
|
{/each}
|
|
511
511
|
{/if}
|
|
512
512
|
</div>
|
|
513
|
-
` :
|
|
513
|
+
` : u`
|
|
514
514
|
<div class="space-y-2">
|
|
515
515
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
516
516
|
{#if ${n}}
|
|
@@ -537,7 +537,7 @@ function xe(t) {
|
|
|
537
537
|
}
|
|
538
538
|
function Fe(t, e) {
|
|
539
539
|
const n = `data.${t.name}.expand?.${e.name}`, a = xe(e);
|
|
540
|
-
return e.maxSelect > 1 ?
|
|
540
|
+
return e.maxSelect > 1 ? u`
|
|
541
541
|
<div class="space-y-2">
|
|
542
542
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
543
543
|
{#each ${n} ?? [] as ${e.singularRelationName}}
|
|
@@ -549,7 +549,7 @@ function Fe(t, e) {
|
|
|
549
549
|
</a>
|
|
550
550
|
{/each}
|
|
551
551
|
</div>
|
|
552
|
-
` :
|
|
552
|
+
` : u`
|
|
553
553
|
<div class="space-y-2">
|
|
554
554
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
555
555
|
{#if ${n}}
|
|
@@ -564,7 +564,7 @@ function Fe(t, e) {
|
|
|
564
564
|
`;
|
|
565
565
|
}
|
|
566
566
|
function Se(t, e) {
|
|
567
|
-
const n = P(t, e), a =
|
|
567
|
+
const n = P(t, e), a = u`
|
|
568
568
|
{#await import("$lib/components/ui/leaflet/leaflet.svelte")}
|
|
569
569
|
<div class="h-56.25 w-full bg-input rounded-md"></div>
|
|
570
570
|
{:then { default: Leaflet }}
|
|
@@ -573,12 +573,12 @@ function Se(t, e) {
|
|
|
573
573
|
<p class="text-muted-foreground">
|
|
574
574
|
{${n}?.lat.toFixed(6)}, {${n}?.lon.toFixed(6)}
|
|
575
575
|
</p>
|
|
576
|
-
`, r = e.required ? a :
|
|
576
|
+
`, r = e.required ? a : u`
|
|
577
577
|
{#if ${n}}
|
|
578
578
|
${a}
|
|
579
579
|
{/if}
|
|
580
580
|
`;
|
|
581
|
-
return
|
|
581
|
+
return u`
|
|
582
582
|
<div class="space-y-2">
|
|
583
583
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
584
584
|
${r}
|
|
@@ -593,7 +593,7 @@ function Ce(t, e) {
|
|
|
593
593
|
case "editor":
|
|
594
594
|
return Q(t, e, `{${P(t, e)}}`);
|
|
595
595
|
case "password":
|
|
596
|
-
return
|
|
596
|
+
return u`
|
|
597
597
|
<div class="space-y-2">
|
|
598
598
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
599
599
|
<p class="text-muted-foreground">
|
|
@@ -611,9 +611,9 @@ function Ce(t, e) {
|
|
|
611
611
|
case "autodate":
|
|
612
612
|
return ve(t, e);
|
|
613
613
|
case "url":
|
|
614
|
-
return we(t, e);
|
|
615
|
-
case "select":
|
|
616
614
|
return ye(t, e);
|
|
615
|
+
case "select":
|
|
616
|
+
return we(t, e);
|
|
617
617
|
case "file":
|
|
618
618
|
return $e(t, e);
|
|
619
619
|
case "json":
|
|
@@ -650,44 +650,44 @@ function Ee(t) {
|
|
|
650
650
|
}
|
|
651
651
|
return e;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
654
|
-
const [n, a, r] =
|
|
655
|
-
return n + a.map(
|
|
653
|
+
function At(t, e) {
|
|
654
|
+
const [n, a, r] = W(t, e);
|
|
655
|
+
return n + a.map(G(e == null ? void 0 : e.locale)).join((e == null ? void 0 : e.delimiter) ?? " ") + r;
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
const [n, a, r] =
|
|
657
|
+
function O(t, e) {
|
|
658
|
+
const [n, a, r] = W(t, e), s = G(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale), o = Bt(s, i);
|
|
659
659
|
return n + a.map((c, m) => m === 0 ? s(c) : o(c, m)).join("") + r;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
const [n, a, r] =
|
|
661
|
+
function Ie(t, e) {
|
|
662
|
+
const [n, a, r] = W(t, e), s = G(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale), o = Bt(s, i);
|
|
663
663
|
return n + a.map(o).join("") + r;
|
|
664
664
|
}
|
|
665
665
|
function ot(t, e) {
|
|
666
|
-
const [n, a, r] =
|
|
667
|
-
return n + a.map(
|
|
666
|
+
const [n, a, r] = W(t, e), s = G(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale);
|
|
667
|
+
return n + a.map(Ae(s, i)).join(" ") + r;
|
|
668
668
|
}
|
|
669
|
-
function
|
|
670
|
-
return
|
|
669
|
+
function ze(t, e) {
|
|
670
|
+
return At(t, { delimiter: "-", ...e });
|
|
671
671
|
}
|
|
672
672
|
function Me(t, e) {
|
|
673
|
-
return
|
|
673
|
+
return At(t, { delimiter: "_", ...e });
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function G(t) {
|
|
676
676
|
return t === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(t);
|
|
677
677
|
}
|
|
678
678
|
function st(t) {
|
|
679
679
|
return (e) => e.toLocaleUpperCase(t);
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function Ae(t, e) {
|
|
682
682
|
return (n) => `${e(n[0])}${t(n.slice(1))}`;
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function Bt(t, e) {
|
|
685
685
|
return (n, a) => {
|
|
686
686
|
const r = n[0];
|
|
687
687
|
return (a > 0 && r >= "0" && r <= "9" ? "_" + r : e(r)) + t(n.slice(1));
|
|
688
688
|
};
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function W(t, e = {}) {
|
|
691
691
|
const n = e.split ?? (e.separateNumbers ? Ee : Mt), a = e.prefixCharacters ?? gt, r = e.suffixCharacters ?? gt;
|
|
692
692
|
let s = 0, i = t.length;
|
|
693
693
|
for (; s < t.length; ) {
|
|
@@ -708,17 +708,17 @@ function J(t, e = {}) {
|
|
|
708
708
|
t.slice(i)
|
|
709
709
|
];
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function Be(t) {
|
|
712
712
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
713
713
|
}
|
|
714
|
-
function
|
|
714
|
+
function De(t) {
|
|
715
715
|
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.');
|
|
716
716
|
}
|
|
717
|
-
var
|
|
718
|
-
function
|
|
717
|
+
var H = { exports: {} }, Te = H.exports, ht;
|
|
718
|
+
function Le() {
|
|
719
719
|
return ht || (ht = 1, (function(t, e) {
|
|
720
720
|
(function(n, a) {
|
|
721
|
-
typeof
|
|
721
|
+
typeof De == "function" ? t.exports = a() : n.pluralize = a();
|
|
722
722
|
})(Te, function() {
|
|
723
723
|
var n = [], a = [], r = {}, s = {}, i = {};
|
|
724
724
|
function o(l) {
|
|
@@ -728,68 +728,68 @@ function Ae() {
|
|
|
728
728
|
return l === d ? d : l === l.toLowerCase() ? d.toLowerCase() : l === l.toUpperCase() ? d.toUpperCase() : l[0] === l[0].toUpperCase() ? d.charAt(0).toUpperCase() + d.substr(1).toLowerCase() : d.toLowerCase();
|
|
729
729
|
}
|
|
730
730
|
function m(l, d) {
|
|
731
|
-
return l.replace(/\$(\d{1,2})/g, function(
|
|
731
|
+
return l.replace(/\$(\d{1,2})/g, function(y, x) {
|
|
732
732
|
return d[x] || "";
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
735
|
function g(l, d) {
|
|
736
|
-
return l.replace(d[0], function(
|
|
737
|
-
var
|
|
738
|
-
return c(
|
|
736
|
+
return l.replace(d[0], function(y, x) {
|
|
737
|
+
var S = m(d[1], arguments);
|
|
738
|
+
return c(y === "" ? l[x - 1] : y, S);
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
|
-
function f(l, d,
|
|
741
|
+
function f(l, d, y) {
|
|
742
742
|
if (!l.length || r.hasOwnProperty(l))
|
|
743
743
|
return d;
|
|
744
|
-
for (var x =
|
|
745
|
-
var
|
|
746
|
-
if (
|
|
744
|
+
for (var x = y.length; x--; ) {
|
|
745
|
+
var S = y[x];
|
|
746
|
+
if (S[0].test(d)) return g(d, S);
|
|
747
747
|
}
|
|
748
748
|
return d;
|
|
749
749
|
}
|
|
750
|
-
function h(l, d,
|
|
750
|
+
function h(l, d, y) {
|
|
751
751
|
return function(x) {
|
|
752
|
-
var
|
|
753
|
-
return d.hasOwnProperty(
|
|
752
|
+
var S = x.toLowerCase();
|
|
753
|
+
return d.hasOwnProperty(S) ? c(x, S) : l.hasOwnProperty(S) ? c(x, l[S]) : f(S, x, y);
|
|
754
754
|
};
|
|
755
755
|
}
|
|
756
|
-
function $(l, d,
|
|
757
|
-
return function(
|
|
758
|
-
var
|
|
759
|
-
return d.hasOwnProperty(
|
|
756
|
+
function $(l, d, y, x) {
|
|
757
|
+
return function(S) {
|
|
758
|
+
var B = S.toLowerCase();
|
|
759
|
+
return d.hasOwnProperty(B) ? !0 : l.hasOwnProperty(B) ? !1 : f(B, B, y) === B;
|
|
760
760
|
};
|
|
761
761
|
}
|
|
762
|
-
function
|
|
763
|
-
var x = d === 1 ?
|
|
764
|
-
return (
|
|
762
|
+
function p(l, d, y) {
|
|
763
|
+
var x = d === 1 ? p.singular(l) : p.plural(l);
|
|
764
|
+
return (y ? d + " " : "") + x;
|
|
765
765
|
}
|
|
766
|
-
return
|
|
766
|
+
return p.plural = h(
|
|
767
767
|
i,
|
|
768
768
|
s,
|
|
769
769
|
n
|
|
770
|
-
),
|
|
770
|
+
), p.isPlural = $(
|
|
771
771
|
i,
|
|
772
772
|
s,
|
|
773
773
|
n
|
|
774
|
-
),
|
|
774
|
+
), p.singular = h(
|
|
775
775
|
s,
|
|
776
776
|
i,
|
|
777
777
|
a
|
|
778
|
-
),
|
|
778
|
+
), p.isSingular = $(
|
|
779
779
|
s,
|
|
780
780
|
i,
|
|
781
781
|
a
|
|
782
|
-
),
|
|
782
|
+
), p.addPluralRule = function(l, d) {
|
|
783
783
|
n.push([o(l), d]);
|
|
784
|
-
},
|
|
784
|
+
}, p.addSingularRule = function(l, d) {
|
|
785
785
|
a.push([o(l), d]);
|
|
786
|
-
},
|
|
786
|
+
}, p.addUncountableRule = function(l) {
|
|
787
787
|
if (typeof l == "string") {
|
|
788
788
|
r[l.toLowerCase()] = !0;
|
|
789
789
|
return;
|
|
790
790
|
}
|
|
791
|
-
|
|
792
|
-
},
|
|
791
|
+
p.addPluralRule(l, "$0"), p.addSingularRule(l, "$0");
|
|
792
|
+
}, p.addIrregularRule = function(l, d) {
|
|
793
793
|
d = d.toLowerCase(), l = l.toLowerCase(), i[l] = d, s[d] = l;
|
|
794
794
|
}, [
|
|
795
795
|
// Pronouns.
|
|
@@ -845,7 +845,7 @@ function Ae() {
|
|
|
845
845
|
["pickaxe", "pickaxes"],
|
|
846
846
|
["passerby", "passersby"]
|
|
847
847
|
].forEach(function(l) {
|
|
848
|
-
return
|
|
848
|
+
return p.addIrregularRule(l[0], l[1]);
|
|
849
849
|
}), [
|
|
850
850
|
[/s?$/i, "s"],
|
|
851
851
|
[/[^\u0000-\u007F]$/i, "$0"],
|
|
@@ -873,7 +873,7 @@ function Ae() {
|
|
|
873
873
|
[/m[ae]n$/i, "men"],
|
|
874
874
|
["thou", "you"]
|
|
875
875
|
].forEach(function(l) {
|
|
876
|
-
return
|
|
876
|
+
return p.addPluralRule(l[0], l[1]);
|
|
877
877
|
}), [
|
|
878
878
|
[/s$/i, ""],
|
|
879
879
|
[/(ss)$/i, "$1"],
|
|
@@ -899,7 +899,7 @@ function Ae() {
|
|
|
899
899
|
[/(eau)x?$/i, "$1"],
|
|
900
900
|
[/men$/i, "man"]
|
|
901
901
|
].forEach(function(l) {
|
|
902
|
-
return
|
|
902
|
+
return p.addSingularRule(l[0], l[1]);
|
|
903
903
|
}), [
|
|
904
904
|
// Singular words with no plurals.
|
|
905
905
|
"adulthood",
|
|
@@ -1010,12 +1010,12 @@ function Ae() {
|
|
|
1010
1010
|
/pox$/i,
|
|
1011
1011
|
// "chickpox", "smallpox"
|
|
1012
1012
|
/sheep$/i
|
|
1013
|
-
].forEach(
|
|
1013
|
+
].forEach(p.addUncountableRule), p;
|
|
1014
1014
|
});
|
|
1015
|
-
})(
|
|
1015
|
+
})(H)), H.exports;
|
|
1016
1016
|
}
|
|
1017
|
-
var
|
|
1018
|
-
const
|
|
1017
|
+
var je = Le();
|
|
1018
|
+
const R = /* @__PURE__ */ Be(je), Eo = "data", Io = "migrations", Oe = "(app)", Ne = /* @__PURE__ */ new Set([
|
|
1019
1019
|
"break",
|
|
1020
1020
|
"case",
|
|
1021
1021
|
"catch",
|
|
@@ -1119,7 +1119,7 @@ const k = /* @__PURE__ */ De(Le), io = "data", lo = "migrations", Oe = "(app)",
|
|
|
1119
1119
|
function tt(t) {
|
|
1120
1120
|
return Ne.has(t) ? qe[t] ?? `${t}_` : t;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function J(t) {
|
|
1123
1123
|
if (!/^[a-zA-Z][a-zA-Z0-9-_/]*$/.test(t))
|
|
1124
1124
|
throw new Error(
|
|
1125
1125
|
"Model path must start with a letter and contain only alphanumeric characters, dash, slash, or underscore"
|
|
@@ -1128,12 +1128,12 @@ function K(t) {
|
|
|
1128
1128
|
function Ue(t) {
|
|
1129
1129
|
return t.features.auth ? `src/routes/${Oe}` : "src/routes";
|
|
1130
1130
|
}
|
|
1131
|
-
function
|
|
1132
|
-
const n = t.split("/"), a = n[n.length - 1], r = n.slice(0, -1), s =
|
|
1131
|
+
function A(t, e) {
|
|
1132
|
+
const n = t.split("/"), a = n[n.length - 1], r = n.slice(0, -1), s = R.singular(ot(a)), i = R.plural(s), o = O(s), c = ze(i), m = [...r, c].join("/");
|
|
1133
1133
|
return {
|
|
1134
1134
|
name: tt(o),
|
|
1135
|
-
pluralName: tt(
|
|
1136
|
-
typeName:
|
|
1135
|
+
pluralName: tt(O(i)),
|
|
1136
|
+
typeName: Ie(s),
|
|
1137
1137
|
tableName: Me(i),
|
|
1138
1138
|
displayName: s,
|
|
1139
1139
|
pluralDisplayName: i,
|
|
@@ -1151,7 +1151,7 @@ function Ve(t) {
|
|
|
1151
1151
|
edit: `${e}/[id]/edit`
|
|
1152
1152
|
};
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1154
|
+
function Ke(t) {
|
|
1155
1155
|
const e = `/${t.routeSegment}`;
|
|
1156
1156
|
return {
|
|
1157
1157
|
list: e,
|
|
@@ -1160,7 +1160,7 @@ function He(t) {
|
|
|
1160
1160
|
edit: `${e}/[id]/edit`
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
const
|
|
1163
|
+
const He = [
|
|
1164
1164
|
"title",
|
|
1165
1165
|
"name",
|
|
1166
1166
|
"label",
|
|
@@ -1194,24 +1194,24 @@ const Ge = [
|
|
|
1194
1194
|
"url",
|
|
1195
1195
|
"id"
|
|
1196
1196
|
];
|
|
1197
|
-
function
|
|
1198
|
-
for (const e of
|
|
1197
|
+
function Ge(t) {
|
|
1198
|
+
for (const e of He)
|
|
1199
1199
|
if (t.some((n) => n.name === e))
|
|
1200
1200
|
return e;
|
|
1201
1201
|
return "id";
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function We(t) {
|
|
1204
1204
|
return t.map((e) => e.name).filter((e) => !e.startsWith("_"));
|
|
1205
1205
|
}
|
|
1206
|
-
function
|
|
1206
|
+
function Je(t) {
|
|
1207
1207
|
return Object.fromEntries(t.map((e) => [e.name, e.id]));
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1209
|
+
function Dt(t) {
|
|
1210
1210
|
return Object.fromEntries(
|
|
1211
|
-
t.map((e) => [e.name,
|
|
1211
|
+
t.map((e) => [e.name, Ge(e.fields)])
|
|
1212
1212
|
);
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1214
|
+
const Xe = [
|
|
1215
1215
|
"user",
|
|
1216
1216
|
"owner",
|
|
1217
1217
|
"created_by",
|
|
@@ -1220,7 +1220,7 @@ const Ze = [
|
|
|
1220
1220
|
"account",
|
|
1221
1221
|
"creator"
|
|
1222
1222
|
];
|
|
1223
|
-
function
|
|
1223
|
+
function L(t) {
|
|
1224
1224
|
return t.toLowerCase();
|
|
1225
1225
|
}
|
|
1226
1226
|
function bt(t) {
|
|
@@ -1231,15 +1231,15 @@ function bt(t) {
|
|
|
1231
1231
|
operator: "="
|
|
1232
1232
|
};
|
|
1233
1233
|
}
|
|
1234
|
-
function
|
|
1235
|
-
const a = new Set((n.authCollections ?? ["users"]).map(
|
|
1236
|
-
(n.userFieldHints ??
|
|
1234
|
+
function Ze(t, e, n = {}) {
|
|
1235
|
+
const a = new Set((n.authCollections ?? ["users"]).map(L)), r = new Set(
|
|
1236
|
+
(n.userFieldHints ?? Xe).map(L)
|
|
1237
1237
|
), s = n.maxDepth ?? 8, i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
1238
1238
|
for (const b of t)
|
|
1239
1239
|
i.set(b.name, b), o.set(b.id, b);
|
|
1240
1240
|
if (!i.has(e))
|
|
1241
1241
|
return bt(e);
|
|
1242
|
-
if (a.has(
|
|
1242
|
+
if (a.has(L(e)))
|
|
1243
1243
|
return {
|
|
1244
1244
|
rule: "@request.auth.id = id",
|
|
1245
1245
|
ownershipChainCollections: [e],
|
|
@@ -1247,28 +1247,28 @@ function Xe(t, e, n = {}) {
|
|
|
1247
1247
|
operator: "="
|
|
1248
1248
|
};
|
|
1249
1249
|
function c(b) {
|
|
1250
|
-
const v =
|
|
1250
|
+
const v = L(b);
|
|
1251
1251
|
return v === "user" ? 50 : r.has(v) ? 20 : 0;
|
|
1252
1252
|
}
|
|
1253
1253
|
function m(b) {
|
|
1254
1254
|
const v = i.get(b);
|
|
1255
1255
|
if (!(v != null && v.fields)) return [];
|
|
1256
|
-
const
|
|
1257
|
-
for (const
|
|
1258
|
-
if (
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1256
|
+
const _ = [];
|
|
1257
|
+
for (const w of v.fields) {
|
|
1258
|
+
if (w.type !== "relation" || !w.collectionId) continue;
|
|
1259
|
+
const D = o.get(w.collectionId);
|
|
1260
|
+
D && _.push({
|
|
1261
1261
|
from: b,
|
|
1262
|
-
fieldName:
|
|
1263
|
-
to:
|
|
1264
|
-
isMulti: !!(
|
|
1265
|
-
hintScore: c(
|
|
1262
|
+
fieldName: w.name,
|
|
1263
|
+
to: D.name,
|
|
1264
|
+
isMulti: !!(w.maxSelect && w.maxSelect > 1),
|
|
1265
|
+
hintScore: c(w.name)
|
|
1266
1266
|
});
|
|
1267
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return _.sort((w, D) => w.fieldName.localeCompare(D.fieldName)), _;
|
|
1269
1269
|
}
|
|
1270
1270
|
function g(b) {
|
|
1271
|
-
return a.has(
|
|
1271
|
+
return a.has(L(b));
|
|
1272
1272
|
}
|
|
1273
1273
|
function f(b) {
|
|
1274
1274
|
if (b.length === 0) return !1;
|
|
@@ -1277,33 +1277,33 @@ function Xe(t, e, n = {}) {
|
|
|
1277
1277
|
return g(b[b.length - 1].to);
|
|
1278
1278
|
}
|
|
1279
1279
|
function h(b) {
|
|
1280
|
-
const v = b[b.length - 1],
|
|
1281
|
-
return 100 * b.length + 50 *
|
|
1280
|
+
const v = b[b.length - 1], _ = v.isMulti ? 1 : 0, w = b.every((Y) => !Y.isMulti) ? 1 : 0, D = b.reduce((Y, Yt) => Y + Yt.hintScore, 0), Zt = L(v.fieldName) === "user" ? 1 : 0;
|
|
1281
|
+
return 100 * b.length + 50 * _ - 40 * Zt - 15 * w - D;
|
|
1282
1282
|
}
|
|
1283
1283
|
function $(b) {
|
|
1284
1284
|
return b.map((v) => `${v.from}.${v.fieldName}->${v.to}`).join("|");
|
|
1285
1285
|
}
|
|
1286
|
-
const
|
|
1287
|
-
function d(b, v,
|
|
1288
|
-
if (!(
|
|
1286
|
+
const p = [], l = /* @__PURE__ */ new Set([e]);
|
|
1287
|
+
function d(b, v, _) {
|
|
1288
|
+
if (!(_ > s)) {
|
|
1289
1289
|
if (v.length > 0 && g(v[v.length - 1].to) && f(v)) {
|
|
1290
|
-
|
|
1290
|
+
p.push([...v]);
|
|
1291
1291
|
return;
|
|
1292
1292
|
}
|
|
1293
|
-
for (const
|
|
1294
|
-
l.has(
|
|
1293
|
+
for (const w of m(b))
|
|
1294
|
+
l.has(w.to) || w.isMulti && !g(w.to) || (l.add(w.to), v.push(w), d(w.to, v, _ + 1), v.pop(), l.delete(w.to));
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
|
-
if (d(e, [], 0),
|
|
1297
|
+
if (d(e, [], 0), p.length === 0)
|
|
1298
1298
|
return bt(e);
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
return
|
|
1299
|
+
p.sort((b, v) => {
|
|
1300
|
+
const _ = h(b) - h(v);
|
|
1301
|
+
return _ !== 0 ? _ : $(b).localeCompare($(v));
|
|
1302
1302
|
});
|
|
1303
|
-
const
|
|
1303
|
+
const y = p[0], x = y.map((b) => b.fieldName), S = [e, ...y.map((b) => b.to)], mt = y[y.length - 1].isMulti ? "?=" : "=", Jt = x.join("."), Xt = n.includeRootPrefix ? (n.rootPrefix ?? e) + "." : "";
|
|
1304
1304
|
return {
|
|
1305
|
-
rule: `@request.auth.id ${mt} ${
|
|
1306
|
-
ownershipChainCollections:
|
|
1305
|
+
rule: `@request.auth.id ${mt} ${Xt}${Jt}.id`,
|
|
1306
|
+
ownershipChainCollections: S,
|
|
1307
1307
|
ownershipChainFields: x,
|
|
1308
1308
|
operator: mt
|
|
1309
1309
|
};
|
|
@@ -1345,7 +1345,7 @@ function vt(t) {
|
|
|
1345
1345
|
const e = t.trim();
|
|
1346
1346
|
return e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'") ? e.slice(1, -1).replace(/\\(["'])/g, "$1") : e;
|
|
1347
1347
|
}
|
|
1348
|
-
function
|
|
1348
|
+
function yt(t) {
|
|
1349
1349
|
let e = -1, n = null, a = !1;
|
|
1350
1350
|
for (let i = 0; i < t.length; i++) {
|
|
1351
1351
|
const o = t[i];
|
|
@@ -1400,15 +1400,15 @@ function Qe(t) {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
if (o === ",") {
|
|
1402
1402
|
const c = n.trim();
|
|
1403
|
-
c.length > 0 && e.push(
|
|
1403
|
+
c.length > 0 && e.push(yt(c)), n = "";
|
|
1404
1404
|
continue;
|
|
1405
1405
|
}
|
|
1406
1406
|
n += o;
|
|
1407
1407
|
}
|
|
1408
1408
|
const s = n.trim();
|
|
1409
|
-
return s.length > 0 && e.push(
|
|
1409
|
+
return s.length > 0 && e.push(yt(s)), e;
|
|
1410
1410
|
}
|
|
1411
|
-
const
|
|
1411
|
+
const wt = {
|
|
1412
1412
|
string: "text",
|
|
1413
1413
|
boolean: "bool",
|
|
1414
1414
|
geopoint: "geoPoint",
|
|
@@ -1428,31 +1428,31 @@ function tn(t) {
|
|
|
1428
1428
|
const r = n.slice(7, -1);
|
|
1429
1429
|
a = Qe(r), n = "select";
|
|
1430
1430
|
}
|
|
1431
|
-
return n === "files" ? { type: "file", required: e, selectOptions: a } : (n in
|
|
1431
|
+
return n === "files" ? { type: "file", required: e, selectOptions: a } : (n in wt && (n = wt[n]), { type: n, required: e, selectOptions: a });
|
|
1432
1432
|
}
|
|
1433
1433
|
function $t(t) {
|
|
1434
|
-
const e =
|
|
1434
|
+
const e = R.singular(t), n = R.plural(e);
|
|
1435
1435
|
return t === n ? 99 : 1;
|
|
1436
1436
|
}
|
|
1437
1437
|
function V(t, e, n, a, r, s) {
|
|
1438
|
-
const i =
|
|
1438
|
+
const i = A(e, s), o = R.singular(t), c = R.plural(o);
|
|
1439
1439
|
return {
|
|
1440
1440
|
collectionId: a[e],
|
|
1441
1441
|
displayField: r[e] ?? "id",
|
|
1442
1442
|
relatedModel: i,
|
|
1443
|
-
singularRelationName:
|
|
1443
|
+
singularRelationName: O(
|
|
1444
1444
|
`${n.displayName} ${i.displayName}`
|
|
1445
1445
|
),
|
|
1446
|
-
pluralRelationName:
|
|
1446
|
+
pluralRelationName: O(
|
|
1447
1447
|
`${n.displayName} ${i.pluralDisplayName}`
|
|
1448
1448
|
),
|
|
1449
1449
|
maxSelect: t === c ? 999 : 1
|
|
1450
1450
|
};
|
|
1451
1451
|
}
|
|
1452
1452
|
function en(t, e, n, a, r) {
|
|
1453
|
-
const s = ot(t), { type: i, required: o, selectOptions: c } = e, m =
|
|
1453
|
+
const s = ot(t), { type: i, required: o, selectOptions: c } = e, m = We(a), g = Je(a), f = Dt(a), h = m.map((p) => R.singular(p));
|
|
1454
1454
|
if (r.features.auth && i === "current_user" && g.users) {
|
|
1455
|
-
const
|
|
1455
|
+
const p = V(
|
|
1456
1456
|
t,
|
|
1457
1457
|
"users",
|
|
1458
1458
|
n,
|
|
@@ -1465,22 +1465,22 @@ function en(t, e, n, a, r) {
|
|
|
1465
1465
|
name: t,
|
|
1466
1466
|
title: s,
|
|
1467
1467
|
required: o,
|
|
1468
|
-
collectionId:
|
|
1468
|
+
collectionId: p.collectionId,
|
|
1469
1469
|
maxSelect: 1,
|
|
1470
|
-
displayField:
|
|
1471
|
-
relatedModel:
|
|
1472
|
-
singularRelationName:
|
|
1473
|
-
pluralRelationName:
|
|
1470
|
+
displayField: p.displayField,
|
|
1471
|
+
relatedModel: p.relatedModel,
|
|
1472
|
+
singularRelationName: p.singularRelationName,
|
|
1473
|
+
pluralRelationName: p.pluralRelationName,
|
|
1474
1474
|
isCurrentUser: !0
|
|
1475
1475
|
};
|
|
1476
1476
|
}
|
|
1477
1477
|
if (i === "autodate") {
|
|
1478
|
-
const
|
|
1479
|
-
if (!
|
|
1478
|
+
const p = t.includes("create"), l = t.includes("update");
|
|
1479
|
+
if (!p && !l)
|
|
1480
1480
|
throw new Error(
|
|
1481
1481
|
`Invalid autodate field: ${t}. Must be one of created/created_at/updated/updated_at.`
|
|
1482
1482
|
);
|
|
1483
|
-
return { type: "autodate", name: t, title: s, required: o, onCreate:
|
|
1483
|
+
return { type: "autodate", name: t, title: s, required: o, onCreate: p, onUpdate: l };
|
|
1484
1484
|
}
|
|
1485
1485
|
if (i === "select")
|
|
1486
1486
|
return {
|
|
@@ -1500,7 +1500,7 @@ function en(t, e, n, a, r) {
|
|
|
1500
1500
|
maxSelect: $t(t)
|
|
1501
1501
|
};
|
|
1502
1502
|
if (i === "relation") {
|
|
1503
|
-
const
|
|
1503
|
+
const p = R.singular(t), l = R.plural(p);
|
|
1504
1504
|
if (!m.includes(l))
|
|
1505
1505
|
throw new Error(
|
|
1506
1506
|
`Invalid relation field: ${t}. Must be one of ${m.join(", ")} (singular or plural)`
|
|
@@ -1523,7 +1523,7 @@ function en(t, e, n, a, r) {
|
|
|
1523
1523
|
};
|
|
1524
1524
|
}
|
|
1525
1525
|
if (m.includes(i)) {
|
|
1526
|
-
const
|
|
1526
|
+
const p = V(
|
|
1527
1527
|
t,
|
|
1528
1528
|
i,
|
|
1529
1529
|
n,
|
|
@@ -1536,16 +1536,16 @@ function en(t, e, n, a, r) {
|
|
|
1536
1536
|
name: t,
|
|
1537
1537
|
title: s,
|
|
1538
1538
|
required: o,
|
|
1539
|
-
...
|
|
1539
|
+
...p,
|
|
1540
1540
|
isCurrentUser: !1
|
|
1541
1541
|
};
|
|
1542
1542
|
}
|
|
1543
1543
|
if (h.includes(i)) {
|
|
1544
|
-
const
|
|
1545
|
-
if (m.includes(
|
|
1544
|
+
const p = R.plural(i);
|
|
1545
|
+
if (m.includes(p)) {
|
|
1546
1546
|
const l = V(
|
|
1547
1547
|
t,
|
|
1548
|
-
|
|
1548
|
+
p,
|
|
1549
1549
|
n,
|
|
1550
1550
|
g,
|
|
1551
1551
|
f,
|
|
@@ -1618,7 +1618,7 @@ function nn(t, e, n, a) {
|
|
|
1618
1618
|
const m = tn(c);
|
|
1619
1619
|
r.push(en(o, m, e, n, a));
|
|
1620
1620
|
}
|
|
1621
|
-
const s = a.features.auth ?
|
|
1621
|
+
const s = a.features.auth ? Ze(
|
|
1622
1622
|
[
|
|
1623
1623
|
...n,
|
|
1624
1624
|
{
|
|
@@ -1637,10 +1637,10 @@ function nn(t, e, n, a) {
|
|
|
1637
1637
|
) : void 0;
|
|
1638
1638
|
return { fields: r, auth: s };
|
|
1639
1639
|
}
|
|
1640
|
-
async function
|
|
1640
|
+
async function X(t, e, n) {
|
|
1641
1641
|
let a;
|
|
1642
1642
|
if (n.env === "runtime") {
|
|
1643
|
-
const { getCollections: r } = await import("./env.runtime-
|
|
1643
|
+
const { getCollections: r } = await import("./env.runtime-BGG6V4qg.js");
|
|
1644
1644
|
a = await r();
|
|
1645
1645
|
} else {
|
|
1646
1646
|
const { getPreviewCollections: r } = await import("./env.preview-HlXZOEL4.js");
|
|
@@ -1649,13 +1649,13 @@ async function Z(t, e, n) {
|
|
|
1649
1649
|
return nn(t, e, a, n);
|
|
1650
1650
|
}
|
|
1651
1651
|
const an = "2024-01-01T00:00:00.000Z";
|
|
1652
|
-
class
|
|
1652
|
+
class N {
|
|
1653
1653
|
constructor(e) {
|
|
1654
1654
|
this.expression = e;
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
1657
|
function nt(t) {
|
|
1658
|
-
return t instanceof
|
|
1658
|
+
return t instanceof N ? t.expression : Array.isArray(t) ? `[${t.map((e) => nt(e)).join(", ")}]` : t && typeof t == "object" ? `{ ${Object.entries(t).map(([n, a]) => `${JSON.stringify(n)}: ${nt(a)}`).join(", ")} }` : JSON.stringify(t);
|
|
1659
1659
|
}
|
|
1660
1660
|
function et(t) {
|
|
1661
1661
|
return `{ ${Object.entries(t).map(
|
|
@@ -1698,7 +1698,7 @@ function rn(t) {
|
|
|
1698
1698
|
return;
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
1701
|
-
function
|
|
1701
|
+
function j(t, e) {
|
|
1702
1702
|
return t.replace("[id]", `\${${e}}`);
|
|
1703
1703
|
}
|
|
1704
1704
|
function Tt(t, e, n) {
|
|
@@ -1729,9 +1729,9 @@ function Tt(t, e, n) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
case "relation": {
|
|
1731
1731
|
if (n.authEnabled && (t.isCurrentUser || ((s = t.relatedModel) == null ? void 0 : s.tableName) === "users"))
|
|
1732
|
-
return new
|
|
1732
|
+
return new N("context.user.id");
|
|
1733
1733
|
const i = t.collectionId ? e[t.collectionId] : void 0;
|
|
1734
|
-
return i ? new
|
|
1734
|
+
return i ? new N(i) : "missing-relation-id";
|
|
1735
1735
|
}
|
|
1736
1736
|
case "file":
|
|
1737
1737
|
case "autodate":
|
|
@@ -1746,7 +1746,7 @@ function xt(t, e, n) {
|
|
|
1746
1746
|
if (r.type === "file" || r.type === "autodate")
|
|
1747
1747
|
continue;
|
|
1748
1748
|
if (n.authEnabled && r.type === "relation" && r.isCurrentUser) {
|
|
1749
|
-
n.forForm || (a[r.name] = new
|
|
1749
|
+
n.forForm || (a[r.name] = new N("context.user.id"));
|
|
1750
1750
|
continue;
|
|
1751
1751
|
}
|
|
1752
1752
|
const s = Tt(r, e, n);
|
|
@@ -1765,7 +1765,7 @@ function on(t, e, n) {
|
|
|
1765
1765
|
continue;
|
|
1766
1766
|
let o;
|
|
1767
1767
|
if (i === "relation")
|
|
1768
|
-
o = s.collectionId ? new
|
|
1768
|
+
o = s.collectionId ? new N(
|
|
1769
1769
|
e[s.collectionId] ?? '"missing-relation-id"'
|
|
1770
1770
|
) : void 0;
|
|
1771
1771
|
else if (i === "select") {
|
|
@@ -1782,7 +1782,7 @@ function on(t, e, n) {
|
|
|
1782
1782
|
return a;
|
|
1783
1783
|
}
|
|
1784
1784
|
function sn(t) {
|
|
1785
|
-
t.email = new
|
|
1785
|
+
t.email = new N(
|
|
1786
1786
|
"`test-${Math.random().toString(36).slice(2)}@example.com`"
|
|
1787
1787
|
), t.password = "password", t.passwordConfirm = "password";
|
|
1788
1788
|
}
|
|
@@ -1835,44 +1835,44 @@ function mn(t, e) {
|
|
|
1835
1835
|
} : { name: n.name, type: n.type })
|
|
1836
1836
|
};
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1838
|
+
function Lt(t, e, n, a) {
|
|
1839
1839
|
const r = a.find((l) => l.name === t.tableName) ?? mn(t, e), s = ln(r, a).filter(
|
|
1840
1840
|
(l) => !(n.features.auth && l.name === "users")
|
|
1841
1841
|
), i = {}, o = [], c = /* @__PURE__ */ new Set();
|
|
1842
1842
|
for (const l of s) {
|
|
1843
|
-
const d = cn(
|
|
1843
|
+
const d = cn(A(l.name, n).name, c);
|
|
1844
1844
|
o.push({ varName: d, collection: l }), i[l.id] = `${d}.id`;
|
|
1845
1845
|
}
|
|
1846
1846
|
const m = o.length ? `${o.map((l) => `let ${l.varName}: { id: string };`).join(`
|
|
1847
1847
|
`)}
|
|
1848
1848
|
|
|
1849
1849
|
` : "", g = o.map(({ varName: l, collection: d }) => {
|
|
1850
|
-
const
|
|
1850
|
+
const y = on(
|
|
1851
1851
|
d.fields,
|
|
1852
1852
|
i,
|
|
1853
1853
|
n
|
|
1854
1854
|
);
|
|
1855
|
-
return d.type === "auth" && sn(
|
|
1855
|
+
return d.type === "auth" && sn(y), `${l} = await context.admin.collection("${d.name}").create(${et(y)});`;
|
|
1856
1856
|
}), f = o.slice().reverse().map(
|
|
1857
1857
|
({ varName: l, collection: d }) => `await context.admin.collection("${d.name}").delete(${l}.id);`
|
|
1858
1858
|
), h = n.features.auth ? "context.agent" : "context.request", $ = n.features.auth ? `await context.agent.authenticateUser();
|
|
1859
1859
|
` : "";
|
|
1860
|
-
let
|
|
1861
|
-
return (g.length > 0 || n.features.auth) && (
|
|
1860
|
+
let p = "";
|
|
1861
|
+
return (g.length > 0 || n.features.auth) && (p += u`
|
|
1862
1862
|
beforeEach(async (context) => {
|
|
1863
1863
|
${$}${g.join(`
|
|
1864
1864
|
`)}
|
|
1865
1865
|
});
|
|
1866
|
-
`), f.length > 0 && (
|
|
1866
|
+
`), f.length > 0 && (p += `
|
|
1867
1867
|
|
|
1868
|
-
` +
|
|
1868
|
+
` + u`
|
|
1869
1869
|
afterEach(async (context) => {
|
|
1870
1870
|
${f.join(`
|
|
1871
1871
|
`)}
|
|
1872
1872
|
});
|
|
1873
1873
|
`), {
|
|
1874
1874
|
declarations: m,
|
|
1875
|
-
setupSection:
|
|
1875
|
+
setupSection: p,
|
|
1876
1876
|
requestAgent: h,
|
|
1877
1877
|
modelDbData: et(
|
|
1878
1878
|
xt(e, i, {
|
|
@@ -1888,9 +1888,9 @@ function At(t, e, n, a) {
|
|
|
1888
1888
|
)
|
|
1889
1889
|
};
|
|
1890
1890
|
}
|
|
1891
|
-
function
|
|
1892
|
-
const { declarations: s, setupSection: i, requestAgent: o, modelDbData: c, modelFormData: m } =
|
|
1893
|
-
return
|
|
1891
|
+
function pn(t, e, n, a, r) {
|
|
1892
|
+
const { declarations: s, setupSection: i, requestAgent: o, modelDbData: c, modelFormData: m } = Lt(t, n, a, r);
|
|
1893
|
+
return u`
|
|
1894
1894
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1895
1895
|
|
|
1896
1896
|
describe("${t.pluralName}", () => {
|
|
@@ -1923,7 +1923,7 @@ function un(t, e, n, a, r) {
|
|
|
1923
1923
|
describe("GET ${e.show}", () => {
|
|
1924
1924
|
it("should return a 200 status code", async (context) => {
|
|
1925
1925
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1926
|
-
const response = await ${o}.get(\`${
|
|
1926
|
+
const response = await ${o}.get(\`${j(e.show, "id")}\`);
|
|
1927
1927
|
expect(response.status).toBe(200);
|
|
1928
1928
|
});
|
|
1929
1929
|
|
|
@@ -1936,10 +1936,10 @@ function un(t, e, n, a, r) {
|
|
|
1936
1936
|
describe("POST ${e.show}", () => {
|
|
1937
1937
|
it("should delete a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1938
1938
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1939
|
-
const response = await ${o}.post(\`${
|
|
1939
|
+
const response = await ${o}.post(\`${j(e.show, "id")}\`).type("form");
|
|
1940
1940
|
expect(response.body.status).toBe(303);
|
|
1941
1941
|
|
|
1942
|
-
const response2 = await ${o}.get(\`${
|
|
1942
|
+
const response2 = await ${o}.get(\`${j(e.show, "id")}\`);
|
|
1943
1943
|
expect(response2.status).toBe(404);
|
|
1944
1944
|
});
|
|
1945
1945
|
});
|
|
@@ -1947,7 +1947,7 @@ function un(t, e, n, a, r) {
|
|
|
1947
1947
|
describe("GET ${e.edit}", () => {
|
|
1948
1948
|
it("should return a 200 status code", async (context) => {
|
|
1949
1949
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1950
|
-
const response = await ${o}.get(\`${
|
|
1950
|
+
const response = await ${o}.get(\`${j(e.edit, "id")}\`);
|
|
1951
1951
|
expect(response.status).toBe(200);
|
|
1952
1952
|
});
|
|
1953
1953
|
});
|
|
@@ -1956,19 +1956,19 @@ function un(t, e, n, a, r) {
|
|
|
1956
1956
|
it("should update a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1957
1957
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1958
1958
|
const response = await ${o}
|
|
1959
|
-
.post(\`${
|
|
1959
|
+
.post(\`${j(e.edit, "id")}\`)
|
|
1960
1960
|
.type("form")
|
|
1961
1961
|
.send(${m});
|
|
1962
1962
|
expect(response.body.status).toBe(303);
|
|
1963
|
-
expect(response.body.location).toBe(\`${
|
|
1963
|
+
expect(response.body.location).toBe(\`${j(e.show, "id")}\`);
|
|
1964
1964
|
});
|
|
1965
1965
|
});
|
|
1966
1966
|
});
|
|
1967
1967
|
`;
|
|
1968
1968
|
}
|
|
1969
|
-
function
|
|
1970
|
-
const { declarations: s, setupSection: i, requestAgent: o, modelFormData: c } =
|
|
1971
|
-
return
|
|
1969
|
+
function un(t, e, n, a, r) {
|
|
1970
|
+
const { declarations: s, setupSection: i, requestAgent: o, modelFormData: c } = Lt(t, n, a, r);
|
|
1971
|
+
return u`
|
|
1972
1972
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1973
1973
|
|
|
1974
1974
|
describe("${e}", () => {
|
|
@@ -2006,7 +2006,7 @@ function hn(t) {
|
|
|
2006
2006
|
throw new Error("At least one field definition is required.");
|
|
2007
2007
|
return { modelPath: e, fields: n };
|
|
2008
2008
|
}
|
|
2009
|
-
function
|
|
2009
|
+
function jt(t) {
|
|
2010
2010
|
return t.some((e) => e.type === "file");
|
|
2011
2011
|
}
|
|
2012
2012
|
function bn(t) {
|
|
@@ -2088,10 +2088,10 @@ function vn(t) {
|
|
|
2088
2088
|
}
|
|
2089
2089
|
return e;
|
|
2090
2090
|
}
|
|
2091
|
-
function
|
|
2091
|
+
function yn(t, e) {
|
|
2092
2092
|
const n = vn(e).map((a) => `${bn(a.name)}: ${a.schema}`).join(`,
|
|
2093
2093
|
`);
|
|
2094
|
-
return
|
|
2094
|
+
return u`
|
|
2095
2095
|
import { z } from "zod/v3";
|
|
2096
2096
|
|
|
2097
2097
|
export const ${t.schemaName} = z.object({
|
|
@@ -2099,7 +2099,7 @@ function wn(t, e) {
|
|
|
2099
2099
|
});
|
|
2100
2100
|
`;
|
|
2101
2101
|
}
|
|
2102
|
-
function
|
|
2102
|
+
function wn(t, e) {
|
|
2103
2103
|
const n = U(e), a = [
|
|
2104
2104
|
'import { untrack } from "svelte";',
|
|
2105
2105
|
'import { superForm } from "sveltekit-superforms";',
|
|
@@ -2112,10 +2112,10 @@ function yn(t, e) {
|
|
|
2112
2112
|
function $n(t, e) {
|
|
2113
2113
|
const a = e.filter(
|
|
2114
2114
|
(r) => r.type === "select"
|
|
2115
|
-
).map((r) =>
|
|
2115
|
+
).map((r) => zt(r)).join(`
|
|
2116
2116
|
|
|
2117
2117
|
`);
|
|
2118
|
-
return
|
|
2118
|
+
return u`
|
|
2119
2119
|
${a}
|
|
2120
2120
|
|
|
2121
2121
|
const form = superForm(untrack(() => data.form), {
|
|
@@ -2126,10 +2126,10 @@ function $n(t, e) {
|
|
|
2126
2126
|
`;
|
|
2127
2127
|
}
|
|
2128
2128
|
function xn(t, e) {
|
|
2129
|
-
const n =
|
|
2129
|
+
const n = wn(t, e).join(`
|
|
2130
2130
|
`), a = $n(t, e), r = e.map((i) => at(i)).join(`
|
|
2131
|
-
`), s =
|
|
2132
|
-
return
|
|
2131
|
+
`), s = jt(e) ? ' enctype="multipart/form-data"' : "";
|
|
2132
|
+
return u(St || (St = fn([`
|
|
2133
2133
|
<script lang="ts">
|
|
2134
2134
|
`, `
|
|
2135
2135
|
|
|
@@ -2155,13 +2155,13 @@ function xn(t, e) {
|
|
|
2155
2155
|
`])), n, a, t.displayName, s, r);
|
|
2156
2156
|
}
|
|
2157
2157
|
function Fn(t, e) {
|
|
2158
|
-
const n =
|
|
2158
|
+
const n = jt(e), a = u`
|
|
2159
2159
|
import { fail, superValidate${n ? ", withFiles" : ""} } from "sveltekit-superforms";
|
|
2160
2160
|
import { zod } from "sveltekit-superforms/adapters";
|
|
2161
2161
|
import { ${t.schemaName} } from "$lib/schemas/${t.name}";
|
|
2162
2162
|
import { setFlash } from "sveltekit-flash-message/server";
|
|
2163
2163
|
`;
|
|
2164
|
-
return
|
|
2164
|
+
return u`
|
|
2165
2165
|
${a}
|
|
2166
2166
|
|
|
2167
2167
|
export const load = async () => {
|
|
@@ -2184,24 +2184,24 @@ function Fn(t, e) {
|
|
|
2184
2184
|
};
|
|
2185
2185
|
`;
|
|
2186
2186
|
}
|
|
2187
|
-
function
|
|
2187
|
+
function K(t, e) {
|
|
2188
2188
|
return {
|
|
2189
2189
|
path: t,
|
|
2190
|
-
language:
|
|
2190
|
+
language: C(t),
|
|
2191
2191
|
content: e
|
|
2192
2192
|
};
|
|
2193
2193
|
}
|
|
2194
2194
|
async function Sn(t) {
|
|
2195
2195
|
const { modelPath: e, fields: n } = hn(t.argv);
|
|
2196
|
-
|
|
2197
|
-
const a =
|
|
2196
|
+
J(e);
|
|
2197
|
+
const a = A(e, t), s = (await X(n, a, t)).fields, { pagePath: i, pageUrl: o } = gn(e, a.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-BGG6V4qg.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
2198
2198
|
t
|
|
2199
2199
|
), m = [
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2200
|
+
K(`${i}/+page.svelte`, xn(a, s)),
|
|
2201
|
+
K(`${i}/+page.server.ts`, Fn(a, s)),
|
|
2202
|
+
K(
|
|
2203
2203
|
`${i}/server.test.ts`,
|
|
2204
|
-
|
|
2204
|
+
un(
|
|
2205
2205
|
a,
|
|
2206
2206
|
o,
|
|
2207
2207
|
s,
|
|
@@ -2209,7 +2209,7 @@ async function Sn(t) {
|
|
|
2209
2209
|
c
|
|
2210
2210
|
)
|
|
2211
2211
|
),
|
|
2212
|
-
|
|
2212
|
+
K(`src/lib/schemas/${a.name}.ts`, yn(a, s))
|
|
2213
2213
|
], g = U(s);
|
|
2214
2214
|
return {
|
|
2215
2215
|
creates: m,
|
|
@@ -2224,9 +2224,9 @@ const Cn = "generate-form", _n = "1.0.7", kn = "src/patterns/generate/form", Rn
|
|
|
2224
2224
|
async function Pn(t) {
|
|
2225
2225
|
const e = await Sn(t);
|
|
2226
2226
|
if (t.env !== "runtime")
|
|
2227
|
-
return
|
|
2227
|
+
return F(e);
|
|
2228
2228
|
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
2229
|
-
return n(await
|
|
2229
|
+
return n(await F(e), t);
|
|
2230
2230
|
}
|
|
2231
2231
|
const En = {
|
|
2232
2232
|
version: _n,
|
|
@@ -2238,6 +2238,7 @@ const En = {
|
|
|
2238
2238
|
summary: "Generates a form.",
|
|
2239
2239
|
requires: {
|
|
2240
2240
|
auth: !1,
|
|
2241
|
+
api: !1,
|
|
2241
2242
|
payments: !1
|
|
2242
2243
|
},
|
|
2243
2244
|
category: "generators",
|
|
@@ -2249,7 +2250,7 @@ const En = {
|
|
|
2249
2250
|
},
|
|
2250
2251
|
baseline: "velastack",
|
|
2251
2252
|
generate: Pn
|
|
2252
|
-
},
|
|
2253
|
+
}, In = ["text"], zn = {
|
|
2253
2254
|
string: "text",
|
|
2254
2255
|
boolean: "bool",
|
|
2255
2256
|
geopoint: "geoPoint",
|
|
@@ -2279,7 +2280,7 @@ const En = {
|
|
|
2279
2280
|
function Mn(t) {
|
|
2280
2281
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2281
2282
|
}
|
|
2282
|
-
function
|
|
2283
|
+
function An(t, e) {
|
|
2283
2284
|
const n = t.type === "select" ? `[${(t.options ?? []).map((r) => JSON.stringify(r.value)).join(", ")}]` : "";
|
|
2284
2285
|
let a;
|
|
2285
2286
|
switch (t.type) {
|
|
@@ -2325,7 +2326,7 @@ function Bn(t, e) {
|
|
|
2325
2326
|
return val;
|
|
2326
2327
|
}
|
|
2327
2328
|
return JSON.stringify(val);
|
|
2328
|
-
}, z.string()${t.required ? "" : ".optional()"}) as z.ZodEffects<${t.required ? "" : "z.ZodOptional<"}z.ZodString${t.required ? "" : ">"}, any, any>` :
|
|
2329
|
+
}, z.string()${t.required ? "" : ".optional()"}) as z.ZodEffects<${t.required ? "" : "z.ZodOptional<"}z.ZodString${t.required ? "" : ">"}, any, any>` : u`
|
|
2329
2330
|
z.object({
|
|
2330
2331
|
lat: z.number().min(-90).max(90),
|
|
2331
2332
|
lon: z.number().min(-180).max(180)
|
|
@@ -2338,7 +2339,7 @@ function Bn(t, e) {
|
|
|
2338
2339
|
default:
|
|
2339
2340
|
return t.type;
|
|
2340
2341
|
}
|
|
2341
|
-
return
|
|
2342
|
+
return In.includes(t.type) ? t.required ? `${a}.nonempty()` : `${a}.optional()` : t.required || t.type === "geoPoint" ? a : t.type === "file" && (t.maxSelect ?? 1) <= 1 ? `${a}.optional().default("")` : `${a}.optional()`;
|
|
2342
2343
|
}
|
|
2343
2344
|
function it(t, e, n) {
|
|
2344
2345
|
const a = [];
|
|
@@ -2350,10 +2351,10 @@ function it(t, e, n) {
|
|
|
2350
2351
|
}
|
|
2351
2352
|
a.push(o);
|
|
2352
2353
|
}
|
|
2353
|
-
const r = a.map((o) => `${Mn(o.name)}: ${
|
|
2354
|
+
const r = a.map((o) => `${Mn(o.name)}: ${An(o, n)}`).join(`,
|
|
2354
2355
|
`), s = n.includeModelFields ? `
|
|
2355
2356
|
import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelFields ? ` satisfies Schemas["${t.tableName}"]` : "";
|
|
2356
|
-
return
|
|
2357
|
+
return u`
|
|
2357
2358
|
import { z } from "zod/v3";${s}
|
|
2358
2359
|
|
|
2359
2360
|
export const ${t.schemaName} = z.object({
|
|
@@ -2361,8 +2362,8 @@ import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelField
|
|
|
2361
2362
|
})${i};
|
|
2362
2363
|
`;
|
|
2363
2364
|
}
|
|
2364
|
-
function
|
|
2365
|
-
const e =
|
|
2365
|
+
function Bn(t) {
|
|
2366
|
+
const e = zn[t];
|
|
2366
2367
|
if (!e)
|
|
2367
2368
|
throw new Error(`Unsupported collection field type "${t}" when generating from collection`);
|
|
2368
2369
|
return e;
|
|
@@ -2371,16 +2372,16 @@ function lt(t, e, n) {
|
|
|
2371
2372
|
const a = e.find((o) => o.name === t.tableName);
|
|
2372
2373
|
if (!a)
|
|
2373
2374
|
throw new Error(`Collection "${t.tableName}" not found`);
|
|
2374
|
-
const r =
|
|
2375
|
+
const r = Dt(e), s = new Map(e.map((o) => [o.id, o])), i = [];
|
|
2375
2376
|
for (const o of a.fields) {
|
|
2376
2377
|
if (o.name === "id" || o.system)
|
|
2377
2378
|
continue;
|
|
2378
|
-
const c =
|
|
2379
|
+
const c = Bn(o.type), m = !!o.required, g = ot(o.name);
|
|
2379
2380
|
if (c === "relation") {
|
|
2380
2381
|
const f = o.collectionId ? s.get(o.collectionId) : void 0;
|
|
2381
2382
|
if (!f)
|
|
2382
2383
|
continue;
|
|
2383
|
-
const h =
|
|
2384
|
+
const h = A(f.name, n);
|
|
2384
2385
|
i.push({
|
|
2385
2386
|
name: o.name,
|
|
2386
2387
|
title: g,
|
|
@@ -2390,10 +2391,10 @@ function lt(t, e, n) {
|
|
|
2390
2391
|
maxSelect: o.maxSelect ?? 1,
|
|
2391
2392
|
displayField: r[f.name] ?? "id",
|
|
2392
2393
|
relatedModel: h,
|
|
2393
|
-
singularRelationName:
|
|
2394
|
+
singularRelationName: O(
|
|
2394
2395
|
`${t.displayName} ${h.displayName}`
|
|
2395
2396
|
),
|
|
2396
|
-
pluralRelationName:
|
|
2397
|
+
pluralRelationName: O(
|
|
2397
2398
|
`${t.displayName} ${h.pluralDisplayName}`
|
|
2398
2399
|
),
|
|
2399
2400
|
isCurrentUser: n.features.auth && f.name === "users" && /user|owner|author/i.test(o.name)
|
|
@@ -2451,7 +2452,7 @@ function Nt(t) {
|
|
|
2451
2452
|
a.type === "relation" && (e.has(a.relatedModel.tableName) || (e.add(a.relatedModel.tableName), n.push(a.relatedModel)));
|
|
2452
2453
|
return n;
|
|
2453
2454
|
}
|
|
2454
|
-
function
|
|
2455
|
+
function Dn(t) {
|
|
2455
2456
|
const e = {
|
|
2456
2457
|
name: t.name,
|
|
2457
2458
|
type: t.type,
|
|
@@ -2486,7 +2487,7 @@ function qt(t, e, n) {
|
|
|
2486
2487
|
name: t.tableName,
|
|
2487
2488
|
type: "base",
|
|
2488
2489
|
...a,
|
|
2489
|
-
fields: e.map(
|
|
2490
|
+
fields: e.map(Dn)
|
|
2490
2491
|
};
|
|
2491
2492
|
}
|
|
2492
2493
|
function Tn(t) {
|
|
@@ -2497,25 +2498,25 @@ function Tn(t) {
|
|
|
2497
2498
|
);
|
|
2498
2499
|
return { modelPath: e, fields: n };
|
|
2499
2500
|
}
|
|
2500
|
-
function
|
|
2501
|
+
function Ln(t, e) {
|
|
2501
2502
|
return {
|
|
2502
2503
|
path: t,
|
|
2503
|
-
language:
|
|
2504
|
+
language: C(t),
|
|
2504
2505
|
content: e
|
|
2505
2506
|
};
|
|
2506
2507
|
}
|
|
2507
|
-
async function
|
|
2508
|
-
|
|
2509
|
-
const a =
|
|
2508
|
+
async function jn(t, e, n) {
|
|
2509
|
+
J(e);
|
|
2510
|
+
const a = A(e, t);
|
|
2510
2511
|
if (n.length > 0) {
|
|
2511
|
-
const i = await
|
|
2512
|
+
const i = await X(n, a, t);
|
|
2512
2513
|
return { model: a, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
|
|
2513
2514
|
}
|
|
2514
|
-
const r = t.env === "runtime" ? await (await import("./env.runtime-
|
|
2515
|
+
const r = t.env === "runtime" ? await (await import("./env.runtime-BGG6V4qg.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = lt(a, r, t);
|
|
2515
2516
|
return { model: a, fields: s, auth: void 0, shouldCreateCollection: !1 };
|
|
2516
2517
|
}
|
|
2517
2518
|
async function On(t) {
|
|
2518
|
-
const { modelPath: e, fields: n } = Tn(t.argv), { model: a, fields: r, auth: s, shouldCreateCollection: i } = await
|
|
2519
|
+
const { modelPath: e, fields: n } = Tn(t.argv), { model: a, fields: r, auth: s, shouldCreateCollection: i } = await jn(
|
|
2519
2520
|
t,
|
|
2520
2521
|
e,
|
|
2521
2522
|
n
|
|
@@ -2524,7 +2525,7 @@ async function On(t) {
|
|
|
2524
2525
|
forForm: !0
|
|
2525
2526
|
});
|
|
2526
2527
|
return {
|
|
2527
|
-
creates: [
|
|
2528
|
+
creates: [Ln(o, c)],
|
|
2528
2529
|
modifies: [],
|
|
2529
2530
|
deletes: [],
|
|
2530
2531
|
components: [],
|
|
@@ -2533,20 +2534,20 @@ async function On(t) {
|
|
|
2533
2534
|
};
|
|
2534
2535
|
}
|
|
2535
2536
|
const Nn = "generate-resource", qn = "1.0.7", Un = "src/patterns/generate/resource", Vn = "/generate/resource";
|
|
2536
|
-
async function
|
|
2537
|
+
async function Kn(t) {
|
|
2537
2538
|
const e = await On(t);
|
|
2538
2539
|
if (t.env !== "runtime")
|
|
2539
|
-
return
|
|
2540
|
-
const { createCollections: n } = await import("./collections-
|
|
2540
|
+
return F(e);
|
|
2541
|
+
const { createCollections: n } = await import("./collections-BQ2vnlIE.js"), a = await n(
|
|
2541
2542
|
e.collections,
|
|
2542
2543
|
t
|
|
2543
2544
|
), r = {
|
|
2544
2545
|
...e,
|
|
2545
2546
|
creates: [...e.creates, ...a]
|
|
2546
2547
|
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
2547
|
-
return s(await
|
|
2548
|
+
return s(await F(r), t);
|
|
2548
2549
|
}
|
|
2549
|
-
const
|
|
2550
|
+
const Hn = {
|
|
2550
2551
|
version: qn,
|
|
2551
2552
|
slug: Nn,
|
|
2552
2553
|
source: Un,
|
|
@@ -2556,6 +2557,7 @@ const Gn = {
|
|
|
2556
2557
|
summary: "Generates model schema resources.",
|
|
2557
2558
|
requires: {
|
|
2558
2559
|
auth: !1,
|
|
2560
|
+
api: !1,
|
|
2559
2561
|
payments: !1
|
|
2560
2562
|
},
|
|
2561
2563
|
category: "generators",
|
|
@@ -2566,19 +2568,19 @@ const Gn = {
|
|
|
2566
2568
|
argv: ["contact", "name:text", "email:email"]
|
|
2567
2569
|
},
|
|
2568
2570
|
baseline: "velastack",
|
|
2569
|
-
generate:
|
|
2571
|
+
generate: Kn
|
|
2570
2572
|
};
|
|
2571
|
-
var _t = Object.freeze,
|
|
2572
|
-
function
|
|
2573
|
+
var _t = Object.freeze, Gn = Object.defineProperty, Z = (t, e) => _t(Gn(t, "raw", { value: _t(e || t.slice()) })), kt, Rt, Pt, Et;
|
|
2574
|
+
function Wn(t) {
|
|
2573
2575
|
const [e, ...n] = t;
|
|
2574
2576
|
if (!e)
|
|
2575
2577
|
throw new Error("Invalid command arguments. Expected: <model> [fields...]");
|
|
2576
2578
|
return { modelPath: e, fields: n };
|
|
2577
2579
|
}
|
|
2578
|
-
function
|
|
2580
|
+
function k(t, e) {
|
|
2579
2581
|
return {
|
|
2580
2582
|
path: t,
|
|
2581
|
-
language:
|
|
2583
|
+
language: C(t),
|
|
2582
2584
|
content: e
|
|
2583
2585
|
};
|
|
2584
2586
|
}
|
|
@@ -2591,25 +2593,25 @@ function Vt(t) {
|
|
|
2591
2593
|
function ct(t) {
|
|
2592
2594
|
return t.filter(
|
|
2593
2595
|
(e) => e.type === "select"
|
|
2594
|
-
).map((e) =>
|
|
2596
|
+
).map((e) => zt(e)).join(`
|
|
2595
2597
|
|
|
2596
2598
|
`);
|
|
2597
2599
|
}
|
|
2598
|
-
function
|
|
2600
|
+
function Kt(t, e) {
|
|
2599
2601
|
return Nt(t).map(
|
|
2600
2602
|
(n) => `const ${n.pluralName} = await ${e}.collection("${n.tableName}").getFullList();`
|
|
2601
2603
|
).join(`
|
|
2602
2604
|
`);
|
|
2603
2605
|
}
|
|
2604
|
-
function
|
|
2606
|
+
function Ht(t) {
|
|
2605
2607
|
return Nt(t).map((e) => e.pluralName).join(", ");
|
|
2606
2608
|
}
|
|
2607
|
-
function
|
|
2609
|
+
function Jn(t) {
|
|
2608
2610
|
return t.features.auth ? "locals.pb" : "locals.admin";
|
|
2609
2611
|
}
|
|
2610
|
-
function
|
|
2612
|
+
function Gt(t, e, n = !1) {
|
|
2611
2613
|
const a = ct(e);
|
|
2612
|
-
return
|
|
2614
|
+
return u`
|
|
2613
2615
|
${a}
|
|
2614
2616
|
${n ? "let { data, params } = $props();" : "let { data } = $props();"}
|
|
2615
2617
|
|
|
@@ -2620,7 +2622,7 @@ function Wt(t, e, n = !1) {
|
|
|
2620
2622
|
const { form: formData } = form;
|
|
2621
2623
|
`;
|
|
2622
2624
|
}
|
|
2623
|
-
function
|
|
2625
|
+
function Xn(t, e, n) {
|
|
2624
2626
|
const a = n.some((o) => o.type === "select"), r = Vt([
|
|
2625
2627
|
'import { untrack } from "svelte";',
|
|
2626
2628
|
'import { superForm } from "sveltekit-superforms";',
|
|
@@ -2634,7 +2636,7 @@ function Zn(t, e, n) {
|
|
|
2634
2636
|
]).join(`
|
|
2635
2637
|
`), s = n.map((o) => at(o)).join(`
|
|
2636
2638
|
`), i = Ut(n) ? ' enctype="multipart/form-data"' : "";
|
|
2637
|
-
return
|
|
2639
|
+
return u(kt || (kt = Z([`
|
|
2638
2640
|
<script lang="ts">
|
|
2639
2641
|
`, `
|
|
2640
2642
|
`, `
|
|
@@ -2661,9 +2663,9 @@ function Zn(t, e, n) {
|
|
|
2661
2663
|
</form>
|
|
2662
2664
|
</div>
|
|
2663
2665
|
</section>
|
|
2664
|
-
`])), r,
|
|
2666
|
+
`])), r, Gt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2665
2667
|
}
|
|
2666
|
-
function
|
|
2668
|
+
function Zn(t, e, n) {
|
|
2667
2669
|
const a = n.some((o) => o.type === "select"), r = Vt([
|
|
2668
2670
|
'import { untrack } from "svelte";',
|
|
2669
2671
|
'import { superForm } from "sveltekit-superforms";',
|
|
@@ -2677,7 +2679,7 @@ function Xn(t, e, n) {
|
|
|
2677
2679
|
]).join(`
|
|
2678
2680
|
`), s = n.map((o) => at(o)).join(`
|
|
2679
2681
|
`), i = Ut(n) ? ' enctype="multipart/form-data"' : "";
|
|
2680
|
-
return
|
|
2682
|
+
return u(Rt || (Rt = Z([`
|
|
2681
2683
|
<script lang="ts">
|
|
2682
2684
|
`, `
|
|
2683
2685
|
`, `
|
|
@@ -2731,12 +2733,12 @@ function Xn(t, e, n) {
|
|
|
2731
2733
|
</form>
|
|
2732
2734
|
</div>
|
|
2733
2735
|
</section>
|
|
2734
|
-
`])), r,
|
|
2736
|
+
`])), r, Gt(t, n, !0), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2735
2737
|
}
|
|
2736
2738
|
function Yn(t, e, n) {
|
|
2737
2739
|
const a = n.some((o) => o.type === "select"), r = a ? `${ct(n)}` : "", s = n.map((o) => {
|
|
2738
2740
|
let c = "{ getValue }", m = "{ value: getValue() }";
|
|
2739
|
-
return o.type === "relation" && (c = "{ getValue, row }", m = `{ value: getValue(), expanded: row.original.expand?.${o.name}, displayField: "${o.displayField}" }`), o.type === "select" && (m = `{ value: getValue(), options: ${o.name}Labels }`), o.type === "file" && (c = "{ getValue, row }", m = "{ value: getValue(), collectionId: row.original.collectionId, id: row.original.id }"),
|
|
2741
|
+
return o.type === "relation" && (c = "{ getValue, row }", m = `{ value: getValue(), expanded: row.original.expand?.${o.name}, displayField: "${o.displayField}" }`), o.type === "select" && (m = `{ value: getValue(), options: ${o.name}Labels }`), o.type === "file" && (c = "{ getValue, row }", m = "{ value: getValue(), collectionId: row.original.collectionId, id: row.original.id }"), u`
|
|
2740
2742
|
columnHelper.accessor("${o.name}", {
|
|
2741
2743
|
header: ({ column }) => renderComponent(ColumnHeader, { column, title: "${o.title}" }),
|
|
2742
2744
|
cell: (${c}) => renderComponent(Cells.${o.type.charAt(0).toUpperCase() + o.type.slice(1)}Cell, ${m})
|
|
@@ -2747,7 +2749,7 @@ function Yn(t, e, n) {
|
|
|
2747
2749
|
(o) => `<FacetedFilter column={table.getColumn("${o.name}")!} title="${o.title}" options={Object.values(${o.name}Labels)} />`
|
|
2748
2750
|
).join(`
|
|
2749
2751
|
`);
|
|
2750
|
-
return
|
|
2752
|
+
return u(Pt || (Pt = Z([`
|
|
2751
2753
|
<script lang="ts">
|
|
2752
2754
|
import {
|
|
2753
2755
|
type ColumnFiltersState,
|
|
@@ -3125,7 +3127,7 @@ function Yn(t, e, n) {
|
|
|
3125
3127
|
}
|
|
3126
3128
|
function Qn(t, e, n) {
|
|
3127
3129
|
const a = Ot(e), r = a ? `{ expand: "${a}" }` : "";
|
|
3128
|
-
return
|
|
3130
|
+
return u`
|
|
3129
3131
|
export const load = async ({ locals }) => {
|
|
3130
3132
|
const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${r});
|
|
3131
3133
|
return { ${t.pluralName} };
|
|
@@ -3133,15 +3135,15 @@ function Qn(t, e, n) {
|
|
|
3133
3135
|
`;
|
|
3134
3136
|
}
|
|
3135
3137
|
function ta(t, e, n, a, r) {
|
|
3136
|
-
const s =
|
|
3138
|
+
const s = Kt(n, a), i = Ht(n), o = i ? `, ${i}` : "", c = n.find(
|
|
3137
3139
|
(g) => g.type === "relation" && g.isCurrentUser
|
|
3138
|
-
), m = r && c ?
|
|
3140
|
+
), m = r && c ? u`
|
|
3139
3141
|
{
|
|
3140
3142
|
...form.data,
|
|
3141
3143
|
${c.name}: locals.pb.authStore.record?.id
|
|
3142
3144
|
}
|
|
3143
3145
|
` : "form.data";
|
|
3144
|
-
return
|
|
3146
|
+
return u`
|
|
3145
3147
|
import { fail, redirect } from "@sveltejs/kit";
|
|
3146
3148
|
import { superValidate } from "sveltekit-superforms";
|
|
3147
3149
|
import { zod } from "sveltekit-superforms/adapters";
|
|
@@ -3176,7 +3178,7 @@ function ta(t, e, n, a, r) {
|
|
|
3176
3178
|
}
|
|
3177
3179
|
function ea(t, e, n, a) {
|
|
3178
3180
|
const r = Ot(n), s = r ? `, { expand: "${r}" }` : "";
|
|
3179
|
-
return
|
|
3181
|
+
return u`
|
|
3180
3182
|
import { error, redirect } from "@sveltejs/kit";
|
|
3181
3183
|
|
|
3182
3184
|
export const load = async ({ locals, params }) => {
|
|
@@ -3206,7 +3208,7 @@ function na(t, e, n) {
|
|
|
3206
3208
|
].filter(Boolean).join(`
|
|
3207
3209
|
`), o = ct(n), c = n.map((m) => Ce(t, m)).join(`
|
|
3208
3210
|
`);
|
|
3209
|
-
return
|
|
3211
|
+
return u(Et || (Et = Z([`
|
|
3210
3212
|
<script lang="ts">
|
|
3211
3213
|
`, `
|
|
3212
3214
|
`, `
|
|
@@ -3241,8 +3243,8 @@ function na(t, e, n) {
|
|
|
3241
3243
|
`])), i, o, t.displayName, e.list, c, e.list, t.name);
|
|
3242
3244
|
}
|
|
3243
3245
|
function aa(t, e, n, a) {
|
|
3244
|
-
const r =
|
|
3245
|
-
return
|
|
3246
|
+
const r = Kt(n, a), s = Ht(n), i = s ? `, ${s}` : "";
|
|
3247
|
+
return u`
|
|
3246
3248
|
import { error, fail, redirect } from "@sveltejs/kit";
|
|
3247
3249
|
import { setPocketbaseErrors, setDefaultData } from "@velastack/pocketbase";
|
|
3248
3250
|
import { superValidate } from "sveltekit-superforms";
|
|
@@ -3283,12 +3285,12 @@ function aa(t, e, n, a) {
|
|
|
3283
3285
|
`;
|
|
3284
3286
|
}
|
|
3285
3287
|
async function ra(t, e, n) {
|
|
3286
|
-
|
|
3287
|
-
const a =
|
|
3288
|
+
J(e);
|
|
3289
|
+
const a = A(e, t), r = t.env === "runtime" ? await (await import("./env.runtime-BGG6V4qg.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
|
|
3288
3290
|
t
|
|
3289
3291
|
);
|
|
3290
3292
|
if (n.length > 0) {
|
|
3291
|
-
const i = await
|
|
3293
|
+
const i = await X(n, a, t);
|
|
3292
3294
|
return {
|
|
3293
3295
|
model: a,
|
|
3294
3296
|
fields: i.fields,
|
|
@@ -3307,48 +3309,48 @@ async function ra(t, e, n) {
|
|
|
3307
3309
|
};
|
|
3308
3310
|
}
|
|
3309
3311
|
async function oa(t) {
|
|
3310
|
-
const { modelPath: e, fields: n } =
|
|
3311
|
-
(
|
|
3312
|
+
const { modelPath: e, fields: n } = Wn(t.argv), { model: a, fields: r, auth: s, shouldCreateCollection: i, collections: o } = await ra(t, e, n), c = Ve(a), m = Ke(a), g = Jn(t), f = r.filter(
|
|
3313
|
+
(p) => !(p.type === "relation" && p.isCurrentUser)
|
|
3312
3314
|
), h = [
|
|
3313
|
-
|
|
3315
|
+
k(
|
|
3314
3316
|
`src/lib/schemas/${a.name}.ts`,
|
|
3315
3317
|
it(a, r, {
|
|
3316
3318
|
includeModelFields: !0,
|
|
3317
3319
|
forForm: !0
|
|
3318
3320
|
})
|
|
3319
3321
|
),
|
|
3320
|
-
|
|
3322
|
+
k(
|
|
3321
3323
|
`${c.list}/+page.server.ts`,
|
|
3322
3324
|
Qn(a, f, g)
|
|
3323
3325
|
),
|
|
3324
|
-
|
|
3326
|
+
k(
|
|
3325
3327
|
`${c.list}/+page.svelte`,
|
|
3326
3328
|
Yn(a, m, f)
|
|
3327
3329
|
),
|
|
3328
|
-
|
|
3330
|
+
k(
|
|
3329
3331
|
`${c.new}/+page.server.ts`,
|
|
3330
3332
|
ta(a, m, f, g, t.features.auth)
|
|
3331
3333
|
),
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
+
k(`${c.new}/+page.svelte`, Xn(a, m, f)),
|
|
3335
|
+
k(
|
|
3334
3336
|
`${c.show}/+page.server.ts`,
|
|
3335
3337
|
ea(a, m, f, g)
|
|
3336
3338
|
),
|
|
3337
|
-
|
|
3339
|
+
k(
|
|
3338
3340
|
`${c.show}/+page.svelte`,
|
|
3339
3341
|
na(a, m, f)
|
|
3340
3342
|
),
|
|
3341
|
-
|
|
3343
|
+
k(
|
|
3342
3344
|
`${c.edit}/+page.server.ts`,
|
|
3343
3345
|
aa(a, m, f, g)
|
|
3344
3346
|
),
|
|
3345
|
-
|
|
3347
|
+
k(
|
|
3346
3348
|
`${c.edit}/+page.svelte`,
|
|
3347
|
-
|
|
3349
|
+
Zn(a, m, f)
|
|
3348
3350
|
),
|
|
3349
|
-
|
|
3351
|
+
k(
|
|
3350
3352
|
`${c.list}/server.test.ts`,
|
|
3351
|
-
|
|
3353
|
+
pn(
|
|
3352
3354
|
a,
|
|
3353
3355
|
m,
|
|
3354
3356
|
r,
|
|
@@ -3387,17 +3389,17 @@ const sa = "generate-scaffold", ia = "1.0.7", la = "src/patterns/generate/scaffo
|
|
|
3387
3389
|
async function ma(t) {
|
|
3388
3390
|
const e = await oa(t);
|
|
3389
3391
|
if (t.env !== "runtime")
|
|
3390
|
-
return
|
|
3391
|
-
const { createCollections: n } = await import("./collections-
|
|
3392
|
+
return F(e);
|
|
3393
|
+
const { createCollections: n } = await import("./collections-BQ2vnlIE.js"), a = await n(
|
|
3392
3394
|
e.collections,
|
|
3393
3395
|
t
|
|
3394
3396
|
), r = {
|
|
3395
3397
|
...e,
|
|
3396
3398
|
creates: [...e.creates, ...a]
|
|
3397
3399
|
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
3398
|
-
return s(await
|
|
3400
|
+
return s(await F(r), t);
|
|
3399
3401
|
}
|
|
3400
|
-
const
|
|
3402
|
+
const pa = {
|
|
3401
3403
|
version: ia,
|
|
3402
3404
|
slug: sa,
|
|
3403
3405
|
source: la,
|
|
@@ -3407,6 +3409,7 @@ const ua = {
|
|
|
3407
3409
|
summary: "Generates CRUD routes and schema.",
|
|
3408
3410
|
requires: {
|
|
3409
3411
|
auth: !1,
|
|
3412
|
+
api: !1,
|
|
3410
3413
|
payments: !1
|
|
3411
3414
|
},
|
|
3412
3415
|
category: "generators",
|
|
@@ -3419,7 +3422,7 @@ const ua = {
|
|
|
3419
3422
|
baseline: "velastack",
|
|
3420
3423
|
generate: ma
|
|
3421
3424
|
};
|
|
3422
|
-
function
|
|
3425
|
+
function ua(t) {
|
|
3423
3426
|
const [e, ...n] = t;
|
|
3424
3427
|
if (!e)
|
|
3425
3428
|
throw new Error(
|
|
@@ -3430,22 +3433,22 @@ function pa(t) {
|
|
|
3430
3433
|
function da(t, e) {
|
|
3431
3434
|
return {
|
|
3432
3435
|
path: t,
|
|
3433
|
-
language:
|
|
3436
|
+
language: C(t),
|
|
3434
3437
|
content: e
|
|
3435
3438
|
};
|
|
3436
3439
|
}
|
|
3437
3440
|
async function fa(t, e, n) {
|
|
3438
|
-
|
|
3439
|
-
const a =
|
|
3441
|
+
J(e);
|
|
3442
|
+
const a = A(e, t);
|
|
3440
3443
|
if (n.length > 0) {
|
|
3441
|
-
const i = await
|
|
3444
|
+
const i = await X(n, a, t);
|
|
3442
3445
|
return { model: a, fields: i.fields, includeModelFields: !1 };
|
|
3443
3446
|
}
|
|
3444
|
-
const r = t.env === "runtime" ? await (await import("./env.runtime-
|
|
3447
|
+
const r = t.env === "runtime" ? await (await import("./env.runtime-BGG6V4qg.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = lt(a, r, t);
|
|
3445
3448
|
return { model: a, fields: s, includeModelFields: !0 };
|
|
3446
3449
|
}
|
|
3447
3450
|
async function ga(t) {
|
|
3448
|
-
const { modelPath: e, fields: n } =
|
|
3451
|
+
const { modelPath: e, fields: n } = ua(t.argv), { model: a, fields: r, includeModelFields: s } = await fa(
|
|
3449
3452
|
t,
|
|
3450
3453
|
e,
|
|
3451
3454
|
n
|
|
@@ -3462,24 +3465,25 @@ async function ga(t) {
|
|
|
3462
3465
|
collections: []
|
|
3463
3466
|
};
|
|
3464
3467
|
}
|
|
3465
|
-
const ha = "generate-schema", ba = "1.0.7", va = "src/patterns/generate/schema",
|
|
3466
|
-
async function
|
|
3468
|
+
const ha = "generate-schema", ba = "1.0.7", va = "src/patterns/generate/schema", ya = "/generate/schema";
|
|
3469
|
+
async function wa(t) {
|
|
3467
3470
|
const e = await ga(t);
|
|
3468
3471
|
if (t.env !== "runtime")
|
|
3469
|
-
return
|
|
3472
|
+
return F(e);
|
|
3470
3473
|
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
3471
|
-
return n(await
|
|
3474
|
+
return n(await F(e), t);
|
|
3472
3475
|
}
|
|
3473
3476
|
const $a = {
|
|
3474
3477
|
version: ba,
|
|
3475
3478
|
slug: ha,
|
|
3476
3479
|
source: va,
|
|
3477
|
-
docs:
|
|
3480
|
+
docs: ya,
|
|
3478
3481
|
plan: "open",
|
|
3479
3482
|
title: "Generate a schema",
|
|
3480
3483
|
summary: "Generates a zod schema.",
|
|
3481
3484
|
requires: {
|
|
3482
3485
|
auth: !1,
|
|
3486
|
+
api: !1,
|
|
3483
3487
|
payments: !1
|
|
3484
3488
|
},
|
|
3485
3489
|
category: "generators",
|
|
@@ -3490,7 +3494,7 @@ const $a = {
|
|
|
3490
3494
|
argv: ["contact", "name:text", "email:email"]
|
|
3491
3495
|
},
|
|
3492
3496
|
baseline: "velastack",
|
|
3493
|
-
generate:
|
|
3497
|
+
generate: wa
|
|
3494
3498
|
}, xa = `<script lang="ts">
|
|
3495
3499
|
import type { ComponentProps } from 'svelte';
|
|
3496
3500
|
import HomeIcon from '@lucide/svelte/icons/home';
|
|
@@ -3751,14 +3755,14 @@ export const loginSchema = z.discriminatedUnion('type', [otpSchema, passwordSche
|
|
|
3751
3755
|
export const otpSchema = z.object({
|
|
3752
3756
|
otp: z.string()
|
|
3753
3757
|
});
|
|
3754
|
-
`,
|
|
3758
|
+
`, Ia = `import { z } from 'zod/v3';
|
|
3755
3759
|
|
|
3756
3760
|
export const profileSchema = z.object({
|
|
3757
3761
|
name: z.string().optional(),
|
|
3758
3762
|
avatar: z.union([z.instanceof(File), z.string()]).optional(),
|
|
3759
3763
|
emailVisibility: z.boolean().optional()
|
|
3760
3764
|
});
|
|
3761
|
-
`,
|
|
3765
|
+
`, za = `import { z } from 'zod/v3';
|
|
3762
3766
|
|
|
3763
3767
|
export const resetSchema = z.object({
|
|
3764
3768
|
email: z.string().email()
|
|
@@ -3770,13 +3774,13 @@ export const signupSchema = z.object({
|
|
|
3770
3774
|
password: z.string(),
|
|
3771
3775
|
passwordConfirm: z.string()
|
|
3772
3776
|
});
|
|
3773
|
-
`,
|
|
3777
|
+
`, Aa = `export const load = ({ locals }) => {
|
|
3774
3778
|
const user = locals.pb.authStore.record!;
|
|
3775
3779
|
const breadcrumbs = [{ title: 'Home', url: '/dashboard' }];
|
|
3776
3780
|
|
|
3777
3781
|
return { user, breadcrumbs };
|
|
3778
3782
|
};
|
|
3779
|
-
`,
|
|
3783
|
+
`, Ba = `<script lang="ts">
|
|
3780
3784
|
import * as Sidebar from '$lib/components/ui/sidebar';
|
|
3781
3785
|
import { Separator } from '$lib/components/ui/separator';
|
|
3782
3786
|
import AppSidebar from '$lib/components/app-sidebar.svelte';
|
|
@@ -3826,7 +3830,7 @@ export const signupSchema = z.object({
|
|
|
3826
3830
|
background-color: var(--color-sidebar);
|
|
3827
3831
|
}
|
|
3828
3832
|
</style>
|
|
3829
|
-
`,
|
|
3833
|
+
`, Da = "", Ta = `import { describe, it, expect } from 'vitest';
|
|
3830
3834
|
import type { Match } from '@velastack/pocketbase';
|
|
3831
3835
|
import type { RouteId } from './$types';
|
|
3832
3836
|
|
|
@@ -3843,14 +3847,14 @@ describe('dashboard', () => {
|
|
|
3843
3847
|
expect(response.status).toBe(200);
|
|
3844
3848
|
});
|
|
3845
3849
|
});
|
|
3846
|
-
`,
|
|
3850
|
+
`, La = `export const load = async ({ parent }) => {
|
|
3847
3851
|
const { breadcrumbs } = await parent();
|
|
3848
3852
|
|
|
3849
3853
|
return {
|
|
3850
3854
|
breadcrumbs: [...breadcrumbs, { title: 'Settings', url: '/settings' }]
|
|
3851
3855
|
};
|
|
3852
3856
|
};
|
|
3853
|
-
`,
|
|
3857
|
+
`, ja = `import { superValidate, fail, withFiles } from 'sveltekit-superforms';
|
|
3854
3858
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
3855
3859
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
3856
3860
|
import { profileSchema } from '$lib/schemas/profile';
|
|
@@ -4333,7 +4337,7 @@ export const actions = {
|
|
|
4333
4337
|
return redirect(303, '/login');
|
|
4334
4338
|
}
|
|
4335
4339
|
};
|
|
4336
|
-
`,
|
|
4340
|
+
`, Ka = `<script lang="ts">
|
|
4337
4341
|
import { untrack } from 'svelte';
|
|
4338
4342
|
import { Button } from '$lib/components/ui/button';
|
|
4339
4343
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4417,7 +4421,7 @@ export const actions = {
|
|
|
4417
4421
|
</div>
|
|
4418
4422
|
</div>
|
|
4419
4423
|
</div>
|
|
4420
|
-
`,
|
|
4424
|
+
`, Ha = `import { describe, it, expect } from 'vitest';
|
|
4421
4425
|
import type { Match } from '@velastack/pocketbase';
|
|
4422
4426
|
import type { RouteId } from './$types';
|
|
4423
4427
|
|
|
@@ -4427,7 +4431,7 @@ describe('GET /confirm-reset/[token]', () => {
|
|
|
4427
4431
|
expect(response.status).toBe(200);
|
|
4428
4432
|
});
|
|
4429
4433
|
});
|
|
4430
|
-
`,
|
|
4434
|
+
`, Ga = `import { redirect } from '@sveltejs/kit';
|
|
4431
4435
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
4432
4436
|
|
|
4433
4437
|
export const GET = async ({ params, locals, cookies }) => {
|
|
@@ -4446,7 +4450,7 @@ export const GET = async ({ params, locals, cookies }) => {
|
|
|
4446
4450
|
setFlash({ type: 'toast', message }, cookies);
|
|
4447
4451
|
redirect(303, redirectPath);
|
|
4448
4452
|
};
|
|
4449
|
-
`,
|
|
4453
|
+
`, Wa = `import { describe, it, expect } from 'vitest';
|
|
4450
4454
|
import type { Match } from '@velastack/pocketbase';
|
|
4451
4455
|
import type { RouteId } from './$types';
|
|
4452
4456
|
|
|
@@ -4459,7 +4463,7 @@ describe('GET /confirm-verification/[token]', () => {
|
|
|
4459
4463
|
expect(response.headers['location']).toBe('/login');
|
|
4460
4464
|
});
|
|
4461
4465
|
});
|
|
4462
|
-
`,
|
|
4466
|
+
`, Ja = `import { fail, superValidate, message } from 'sveltekit-superforms';
|
|
4463
4467
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4464
4468
|
import { loginSchema } from '$lib/schemas/login';
|
|
4465
4469
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4520,7 +4524,7 @@ export const actions = {
|
|
|
4520
4524
|
redirect(303, redirectUrl);
|
|
4521
4525
|
}
|
|
4522
4526
|
};
|
|
4523
|
-
`,
|
|
4527
|
+
`, Xa = `<script lang="ts">
|
|
4524
4528
|
import { untrack } from 'svelte';
|
|
4525
4529
|
import { Button } from '$lib/components/ui/button';
|
|
4526
4530
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4703,7 +4707,7 @@ export const actions = {
|
|
|
4703
4707
|
</div>
|
|
4704
4708
|
</div>
|
|
4705
4709
|
</div>
|
|
4706
|
-
`,
|
|
4710
|
+
`, Za = `import { describe, it, expect } from 'vitest';
|
|
4707
4711
|
import * as devalue from 'devalue';
|
|
4708
4712
|
import type { Match } from '@velastack/pocketbase';
|
|
4709
4713
|
import type { RouteId } from './$types';
|
|
@@ -5300,27 +5304,27 @@ describe('POST /signup', () => {
|
|
|
5300
5304
|
"./creates/src/lib/schemas/confirmReset.ts": Ra,
|
|
5301
5305
|
"./creates/src/lib/schemas/login.ts": Pa,
|
|
5302
5306
|
"./creates/src/lib/schemas/otp.ts": Ea,
|
|
5303
|
-
"./creates/src/lib/schemas/profile.ts":
|
|
5304
|
-
"./creates/src/lib/schemas/reset.ts":
|
|
5307
|
+
"./creates/src/lib/schemas/profile.ts": Ia,
|
|
5308
|
+
"./creates/src/lib/schemas/reset.ts": za,
|
|
5305
5309
|
"./creates/src/lib/schemas/signup.ts": Ma,
|
|
5306
|
-
"./creates/src/routes/(app)/+layout.server.ts":
|
|
5307
|
-
"./creates/src/routes/(app)/+layout.svelte":
|
|
5308
|
-
"./creates/src/routes/(app)/dashboard/+page.svelte":
|
|
5310
|
+
"./creates/src/routes/(app)/+layout.server.ts": Aa,
|
|
5311
|
+
"./creates/src/routes/(app)/+layout.svelte": Ba,
|
|
5312
|
+
"./creates/src/routes/(app)/dashboard/+page.svelte": Da,
|
|
5309
5313
|
"./creates/src/routes/(app)/dashboard/server.test.ts": Ta,
|
|
5310
|
-
"./creates/src/routes/(app)/settings/+layout.server.ts":
|
|
5311
|
-
"./creates/src/routes/(app)/settings/+page.server.ts":
|
|
5314
|
+
"./creates/src/routes/(app)/settings/+layout.server.ts": La,
|
|
5315
|
+
"./creates/src/routes/(app)/settings/+page.server.ts": ja,
|
|
5312
5316
|
"./creates/src/routes/(app)/settings/+page.svelte": Oa,
|
|
5313
5317
|
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.server.ts": Na,
|
|
5314
5318
|
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.svelte": qa,
|
|
5315
5319
|
"./creates/src/routes/(public)/confirm-email-change/[token]/server.test.ts": Ua,
|
|
5316
5320
|
"./creates/src/routes/(public)/confirm-reset/[token]/+page.server.ts": Va,
|
|
5317
|
-
"./creates/src/routes/(public)/confirm-reset/[token]/+page.svelte":
|
|
5318
|
-
"./creates/src/routes/(public)/confirm-reset/[token]/server.test.ts":
|
|
5319
|
-
"./creates/src/routes/(public)/confirm-verification/[token]/+server.ts":
|
|
5320
|
-
"./creates/src/routes/(public)/confirm-verification/[token]/server.test.ts":
|
|
5321
|
-
"./creates/src/routes/(public)/login/+page.server.ts":
|
|
5322
|
-
"./creates/src/routes/(public)/login/+page.svelte":
|
|
5323
|
-
"./creates/src/routes/(public)/login/server.test.ts":
|
|
5321
|
+
"./creates/src/routes/(public)/confirm-reset/[token]/+page.svelte": Ka,
|
|
5322
|
+
"./creates/src/routes/(public)/confirm-reset/[token]/server.test.ts": Ha,
|
|
5323
|
+
"./creates/src/routes/(public)/confirm-verification/[token]/+server.ts": Ga,
|
|
5324
|
+
"./creates/src/routes/(public)/confirm-verification/[token]/server.test.ts": Wa,
|
|
5325
|
+
"./creates/src/routes/(public)/login/+page.server.ts": Ja,
|
|
5326
|
+
"./creates/src/routes/(public)/login/+page.svelte": Xa,
|
|
5327
|
+
"./creates/src/routes/(public)/login/server.test.ts": Za,
|
|
5324
5328
|
"./creates/src/routes/(public)/logout/+server.ts": Ya,
|
|
5325
5329
|
"./creates/src/routes/(public)/logout/server.test.ts": Qa,
|
|
5326
5330
|
"./creates/src/routes/(public)/otp/[token]/+page.server.ts": tr,
|
|
@@ -5333,12 +5337,12 @@ describe('POST /signup', () => {
|
|
|
5333
5337
|
"./creates/src/routes/(public)/signup/+page.svelte": ir,
|
|
5334
5338
|
"./creates/src/routes/(public)/signup/server.test.ts": lr
|
|
5335
5339
|
}), mr = "./creates/";
|
|
5336
|
-
async function
|
|
5340
|
+
async function pr(t) {
|
|
5337
5341
|
const e = Object.entries(cr).map(([r, s]) => {
|
|
5338
|
-
const i =
|
|
5342
|
+
const i = I(r, mr);
|
|
5339
5343
|
return {
|
|
5340
5344
|
path: i,
|
|
5341
|
-
language:
|
|
5345
|
+
language: C(i),
|
|
5342
5346
|
content: s
|
|
5343
5347
|
};
|
|
5344
5348
|
}).sort((r, s) => r.path.localeCompare(s.path)), n = [
|
|
@@ -5426,7 +5430,7 @@ async function ur(t) {
|
|
|
5426
5430
|
]
|
|
5427
5431
|
};
|
|
5428
5432
|
}
|
|
5429
|
-
const
|
|
5433
|
+
const ur = `import {
|
|
5430
5434
|
POCKETBASE_URL,
|
|
5431
5435
|
POCKETBASE_SUPERUSER_EMAIL,
|
|
5432
5436
|
POCKETBASE_SUPERUSER_PASSWORD,
|
|
@@ -5556,16 +5560,16 @@ export const load = loadFlash(async ({ locals }) => {
|
|
|
5556
5560
|
};
|
|
5557
5561
|
});
|
|
5558
5562
|
`, gr = /* @__PURE__ */ Object.assign({
|
|
5559
|
-
"./preview-modifies/src/hooks.server.ts":
|
|
5563
|
+
"./preview-modifies/src/hooks.server.ts": ur,
|
|
5560
5564
|
"./preview-modifies/src/routes/(public)/root-layout.svelte": dr,
|
|
5561
5565
|
"./preview-modifies/src/routes/+layout.server.ts": fr
|
|
5562
5566
|
}), hr = "./preview-modifies/";
|
|
5563
5567
|
async function br(t) {
|
|
5564
5568
|
const e = Object.entries(gr).map(([n, a]) => {
|
|
5565
|
-
const r =
|
|
5569
|
+
const r = I(n, hr);
|
|
5566
5570
|
return {
|
|
5567
5571
|
path: r,
|
|
5568
|
-
language:
|
|
5572
|
+
language: C(r),
|
|
5569
5573
|
content: a
|
|
5570
5574
|
};
|
|
5571
5575
|
}).sort((n, a) => n.path.localeCompare(a.path));
|
|
@@ -5578,29 +5582,30 @@ async function br(t) {
|
|
|
5578
5582
|
collections: []
|
|
5579
5583
|
};
|
|
5580
5584
|
}
|
|
5581
|
-
const vr = "enable-auth",
|
|
5585
|
+
const vr = "enable-auth", yr = "1.0.7", wr = "src/patterns/enable/auth", $r = "/enable/auth";
|
|
5582
5586
|
async function xr(t) {
|
|
5583
|
-
const e = await
|
|
5587
|
+
const e = await pr(t);
|
|
5584
5588
|
if (t.env === "preview") {
|
|
5585
5589
|
const s = await br();
|
|
5586
|
-
return
|
|
5590
|
+
return F(E([e, s]));
|
|
5587
5591
|
}
|
|
5588
|
-
const { generate: n } = await import("./generate.runtime-
|
|
5592
|
+
const { generate: n } = await import("./generate.runtime-CL_SU1wV.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
|
|
5589
5593
|
return r(
|
|
5590
|
-
await
|
|
5594
|
+
await F(E([e, a])),
|
|
5591
5595
|
t
|
|
5592
5596
|
);
|
|
5593
5597
|
}
|
|
5594
5598
|
const Fr = {
|
|
5595
|
-
version:
|
|
5599
|
+
version: yr,
|
|
5596
5600
|
slug: vr,
|
|
5597
|
-
source:
|
|
5601
|
+
source: wr,
|
|
5598
5602
|
docs: $r,
|
|
5599
5603
|
plan: "open",
|
|
5600
5604
|
title: "Enable authentication",
|
|
5601
5605
|
summary: "Enables authentication.",
|
|
5602
5606
|
requires: {
|
|
5603
5607
|
auth: !1,
|
|
5608
|
+
api: !1,
|
|
5604
5609
|
payments: !1
|
|
5605
5610
|
},
|
|
5606
5611
|
category: "auth",
|
|
@@ -5633,10 +5638,10 @@ describe("GET /api/health", () => {
|
|
|
5633
5638
|
async function kr(t) {
|
|
5634
5639
|
return {
|
|
5635
5640
|
creates: Object.entries(Cr).map(([n, a]) => {
|
|
5636
|
-
const r =
|
|
5641
|
+
const r = I(n, _r);
|
|
5637
5642
|
return {
|
|
5638
5643
|
path: r,
|
|
5639
|
-
language:
|
|
5644
|
+
language: C(r),
|
|
5640
5645
|
content: a
|
|
5641
5646
|
};
|
|
5642
5647
|
}).sort((n, a) => n.path.localeCompare(a.path)),
|
|
@@ -5664,12 +5669,12 @@ export const handle = handlePocketbase({
|
|
|
5664
5669
|
`, Pr = /* @__PURE__ */ Object.assign({
|
|
5665
5670
|
"./preview-modifies/src/hooks.server.ts": Rr
|
|
5666
5671
|
}), Er = "./preview-modifies/";
|
|
5667
|
-
async function
|
|
5672
|
+
async function Ir(t) {
|
|
5668
5673
|
const e = Object.entries(Pr).map(([n, a]) => {
|
|
5669
|
-
const r =
|
|
5674
|
+
const r = I(n, Er);
|
|
5670
5675
|
return {
|
|
5671
5676
|
path: r,
|
|
5672
|
-
language:
|
|
5677
|
+
language: C(r),
|
|
5673
5678
|
content: a
|
|
5674
5679
|
};
|
|
5675
5680
|
}).sort((n, a) => n.path.localeCompare(a.path));
|
|
@@ -5682,29 +5687,30 @@ async function zr(t) {
|
|
|
5682
5687
|
collections: []
|
|
5683
5688
|
};
|
|
5684
5689
|
}
|
|
5685
|
-
const
|
|
5686
|
-
async function
|
|
5690
|
+
const zr = "enable-api", Mr = "1.0.7", Ar = "src/patterns/enable/api", Br = "/enable/api";
|
|
5691
|
+
async function Dr(t) {
|
|
5687
5692
|
const e = await kr();
|
|
5688
5693
|
if (t.env === "preview") {
|
|
5689
|
-
const s = await
|
|
5690
|
-
return
|
|
5694
|
+
const s = await Ir();
|
|
5695
|
+
return F(E([e, s]));
|
|
5691
5696
|
}
|
|
5692
5697
|
const { generate: n } = await import("./generate.runtime-C7g-zL0o.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
|
|
5693
5698
|
return r(
|
|
5694
|
-
await
|
|
5699
|
+
await F(E([e, a])),
|
|
5695
5700
|
t
|
|
5696
5701
|
);
|
|
5697
5702
|
}
|
|
5698
5703
|
const Tr = {
|
|
5699
5704
|
version: Mr,
|
|
5700
|
-
slug:
|
|
5701
|
-
source:
|
|
5702
|
-
docs:
|
|
5705
|
+
slug: zr,
|
|
5706
|
+
source: Ar,
|
|
5707
|
+
docs: Br,
|
|
5703
5708
|
plan: "open",
|
|
5704
5709
|
title: "Enable API",
|
|
5705
5710
|
summary: "Enables the PocketBase API.",
|
|
5706
5711
|
requires: {
|
|
5707
5712
|
auth: !1,
|
|
5713
|
+
api: !1,
|
|
5708
5714
|
payments: !1
|
|
5709
5715
|
},
|
|
5710
5716
|
category: "api",
|
|
@@ -5715,8 +5721,436 @@ const Tr = {
|
|
|
5715
5721
|
argv: []
|
|
5716
5722
|
},
|
|
5717
5723
|
baseline: "velastack",
|
|
5718
|
-
generate:
|
|
5719
|
-
},
|
|
5724
|
+
generate: Dr
|
|
5725
|
+
}, Lr = `import { z } from 'zod/v3';
|
|
5726
|
+
import type { Schemas } from 'pocketbase-svelte';
|
|
5727
|
+
|
|
5728
|
+
export const apiKeySchema = z.object({
|
|
5729
|
+
label: z.string().optional()
|
|
5730
|
+
}) satisfies Schemas['api_keys'];
|
|
5731
|
+
`, jr = `export const load = async ({ locals }) => {
|
|
5732
|
+
const apiKeys = await locals.pb.collection('api_keys').getFullList();
|
|
5733
|
+
return { apiKeys };
|
|
5734
|
+
};
|
|
5735
|
+
`, Or = `<script lang="ts">
|
|
5736
|
+
import { getFlash } from 'sveltekit-flash-message';
|
|
5737
|
+
import { page } from '$app/state';
|
|
5738
|
+
import * as AlertDialog from '$lib/components/ui/alert-dialog';
|
|
5739
|
+
import { Button } from '$lib/components/ui/button';
|
|
5740
|
+
import { Badge } from '$lib/components/ui/badge';
|
|
5741
|
+
import PlusIcon from '@lucide/svelte/icons/plus';
|
|
5742
|
+
import SquareDashedMousePointerIcon from '@lucide/svelte/icons/square-dashed-mouse-pointer';
|
|
5743
|
+
|
|
5744
|
+
const flash = getFlash(page);
|
|
5745
|
+
|
|
5746
|
+
let open = $state(false);
|
|
5747
|
+
let message = $state('');
|
|
5748
|
+
let title = $state('');
|
|
5749
|
+
let apiKey = $state('');
|
|
5750
|
+
|
|
5751
|
+
$effect(() => {
|
|
5752
|
+
if (!$flash) return;
|
|
5753
|
+
|
|
5754
|
+
if ($flash.type === 'success') {
|
|
5755
|
+
message = $flash.message;
|
|
5756
|
+
title = $flash.title;
|
|
5757
|
+
apiKey = $flash.apiKey;
|
|
5758
|
+
open = true;
|
|
5759
|
+
}
|
|
5760
|
+
|
|
5761
|
+
$flash = undefined;
|
|
5762
|
+
});
|
|
5763
|
+
|
|
5764
|
+
async function handleAction() {
|
|
5765
|
+
open = false;
|
|
5766
|
+
await navigator.clipboard.writeText(apiKey);
|
|
5767
|
+
}
|
|
5768
|
+
|
|
5769
|
+
let { data } = $props();
|
|
5770
|
+
<\/script>
|
|
5771
|
+
|
|
5772
|
+
<section data-role="content">
|
|
5773
|
+
<div class="flex justify-between items-center mb-4">
|
|
5774
|
+
<h1 class="text-3xl font-bold tracking-tight">API keys</h1>
|
|
5775
|
+
<Button href="/api-keys/new" variant="outline">
|
|
5776
|
+
<PlusIcon class="w-4 h-4" />
|
|
5777
|
+
New API key
|
|
5778
|
+
</Button>
|
|
5779
|
+
</div>
|
|
5780
|
+
|
|
5781
|
+
<AlertDialog.Root bind:open>
|
|
5782
|
+
<AlertDialog.Content>
|
|
5783
|
+
<AlertDialog.Header>
|
|
5784
|
+
<AlertDialog.Title>{title}</AlertDialog.Title>
|
|
5785
|
+
<AlertDialog.Description>
|
|
5786
|
+
<p>{@html message}</p>
|
|
5787
|
+
<Badge variant="outline" class="font-mono my-3 text-base">{apiKey}</Badge>
|
|
5788
|
+
</AlertDialog.Description>
|
|
5789
|
+
</AlertDialog.Header>
|
|
5790
|
+
<AlertDialog.Footer>
|
|
5791
|
+
<AlertDialog.Cancel>Close</AlertDialog.Cancel>
|
|
5792
|
+
<AlertDialog.Action onclick={handleAction}>Copy</AlertDialog.Action>
|
|
5793
|
+
</AlertDialog.Footer>
|
|
5794
|
+
</AlertDialog.Content>
|
|
5795
|
+
</AlertDialog.Root>
|
|
5796
|
+
|
|
5797
|
+
<div class="rounded-lg border bg-card overflow-hidden">
|
|
5798
|
+
<div class="relative w-full overflow-auto">
|
|
5799
|
+
{#if data.apiKeys.length === 0}
|
|
5800
|
+
<div class="p-4 text-center text-muted-foreground space-y-4 py-12">
|
|
5801
|
+
<SquareDashedMousePointerIcon strokeWidth={1.2} class="w-8 h-8 mx-auto mb-2" />
|
|
5802
|
+
<p>Seems like there are no API keys yet, but you can create the first one</p>
|
|
5803
|
+
<p class="text-sm text-muted-foreground">
|
|
5804
|
+
<Button href="/api-keys/new" variant="outline">
|
|
5805
|
+
<PlusIcon class="w-4 h-4" />
|
|
5806
|
+
New API key
|
|
5807
|
+
</Button>
|
|
5808
|
+
</p>
|
|
5809
|
+
</div>
|
|
5810
|
+
{:else}
|
|
5811
|
+
<table class="w-full caption-bottom text-sm">
|
|
5812
|
+
<thead>
|
|
5813
|
+
<tr class="border-b">
|
|
5814
|
+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground"
|
|
5815
|
+
>Label</th
|
|
5816
|
+
>
|
|
5817
|
+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground"
|
|
5818
|
+
>API key</th
|
|
5819
|
+
>
|
|
5820
|
+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground"
|
|
5821
|
+
>Created</th
|
|
5822
|
+
>
|
|
5823
|
+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground"
|
|
5824
|
+
>Last used</th
|
|
5825
|
+
>
|
|
5826
|
+
<th class="h-12 px-4 text-right align-middle font-medium text-muted-foreground"></th>
|
|
5827
|
+
</tr>
|
|
5828
|
+
</thead>
|
|
5829
|
+
<tbody>
|
|
5830
|
+
{#each data.apiKeys as apiKey}
|
|
5831
|
+
<tr
|
|
5832
|
+
class="border-t transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
|
|
5833
|
+
>
|
|
5834
|
+
<td class="p-4 align-middle font-medium">{apiKey.label}</td>
|
|
5835
|
+
|
|
5836
|
+
<td class="p-4 align-middle font-medium">
|
|
5837
|
+
<Badge variant="outline" class="font-mono">
|
|
5838
|
+
{apiKey.id}.***************
|
|
5839
|
+
</Badge>
|
|
5840
|
+
</td>
|
|
5841
|
+
|
|
5842
|
+
<td class="p-4 align-middle font-medium">
|
|
5843
|
+
{#if apiKey.created}
|
|
5844
|
+
{new Date(apiKey.created).toLocaleDateString()}
|
|
5845
|
+
{/if}
|
|
5846
|
+
</td>
|
|
5847
|
+
|
|
5848
|
+
<td class="p-4 align-middle font-medium">
|
|
5849
|
+
{#if apiKey.last_used}
|
|
5850
|
+
{new Date(apiKey.last_used).toLocaleDateString()}
|
|
5851
|
+
{:else}
|
|
5852
|
+
Never
|
|
5853
|
+
{/if}
|
|
5854
|
+
</td>
|
|
5855
|
+
|
|
5856
|
+
<td class="p-4 align-middle text-right">
|
|
5857
|
+
<form method="POST" action="/api-keys/{apiKey.id}?/delete" class="contents">
|
|
5858
|
+
<Button
|
|
5859
|
+
variant="ghost"
|
|
5860
|
+
class="h-8 px-2 text-destructive hover:text-destructive"
|
|
5861
|
+
type="submit">Delete</Button
|
|
5862
|
+
>
|
|
5863
|
+
</form>
|
|
5864
|
+
</td>
|
|
5865
|
+
</tr>
|
|
5866
|
+
{/each}
|
|
5867
|
+
</tbody>
|
|
5868
|
+
</table>
|
|
5869
|
+
{/if}
|
|
5870
|
+
</div>
|
|
5871
|
+
</div>
|
|
5872
|
+
</section>
|
|
5873
|
+
`, Nr = `import { redirect } from '@sveltejs/kit';
|
|
5874
|
+
|
|
5875
|
+
export const actions = {
|
|
5876
|
+
delete: async ({ locals, params }) => {
|
|
5877
|
+
await locals.pb.collection('api_keys').delete(params.id);
|
|
5878
|
+
redirect(303, '/api-keys');
|
|
5879
|
+
}
|
|
5880
|
+
};
|
|
5881
|
+
`, qr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
5882
|
+
import { zod } from 'sveltekit-superforms/adapters';
|
|
5883
|
+
import { redirect } from 'sveltekit-flash-message/server';
|
|
5884
|
+
import { apiKeySchema } from '$lib/schemas/apiKey';
|
|
5885
|
+
import { setPocketbaseErrors } from '@velastack/pocketbase';
|
|
5886
|
+
import { createApiKey } from './create-api-key';
|
|
5887
|
+
|
|
5888
|
+
export const load = async () => {
|
|
5889
|
+
return { form: await superValidate(zod(apiKeySchema)) };
|
|
5890
|
+
};
|
|
5891
|
+
|
|
5892
|
+
export const actions = {
|
|
5893
|
+
default: async ({ locals, request, cookies }) => {
|
|
5894
|
+
const form = await superValidate(request, zod(apiKeySchema));
|
|
5895
|
+
|
|
5896
|
+
if (!form.valid) {
|
|
5897
|
+
return fail(400, { form });
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5900
|
+
let apiKey: string;
|
|
5901
|
+
|
|
5902
|
+
try {
|
|
5903
|
+
apiKey = await createApiKey(locals.pb, locals.pb.authStore.record?.id, form.data.label);
|
|
5904
|
+
} catch (error) {
|
|
5905
|
+
setPocketbaseErrors(form, error);
|
|
5906
|
+
return fail(400, { form });
|
|
5907
|
+
}
|
|
5908
|
+
|
|
5909
|
+
return redirect(
|
|
5910
|
+
'/api-keys',
|
|
5911
|
+
{
|
|
5912
|
+
type: 'success',
|
|
5913
|
+
title: "You've created a new API key",
|
|
5914
|
+
message: \`Copy the following API key in a safe location. It will only be shown once.\`,
|
|
5915
|
+
apiKey
|
|
5916
|
+
},
|
|
5917
|
+
cookies
|
|
5918
|
+
);
|
|
5919
|
+
}
|
|
5920
|
+
};
|
|
5921
|
+
`, Ur = `<script lang="ts">
|
|
5922
|
+
import { untrack } from 'svelte';
|
|
5923
|
+
import { superForm } from 'sveltekit-superforms';
|
|
5924
|
+
import { zodClient } from 'sveltekit-superforms/adapters';
|
|
5925
|
+
import { apiKeySchema } from '$lib/schemas/apiKey';
|
|
5926
|
+
import * as Form from '$lib/components/ui/form';
|
|
5927
|
+
import { Input } from '$lib/components/ui/input';
|
|
5928
|
+
import { Button } from '$lib/components/ui/button';
|
|
5929
|
+
import ArrowLeftIcon from '@lucide/svelte/icons/arrow-left';
|
|
5930
|
+
|
|
5931
|
+
let { data } = $props();
|
|
5932
|
+
|
|
5933
|
+
const form = superForm(
|
|
5934
|
+
untrack(() => data.form),
|
|
5935
|
+
{
|
|
5936
|
+
validators: zodClient(apiKeySchema)
|
|
5937
|
+
}
|
|
5938
|
+
);
|
|
5939
|
+
|
|
5940
|
+
const { form: formData } = form;
|
|
5941
|
+
<\/script>
|
|
5942
|
+
|
|
5943
|
+
<section data-role="content">
|
|
5944
|
+
<div class="flex justify-between items-center mb-4">
|
|
5945
|
+
<h1 class="text-3xl font-bold tracking-tight">New API key</h1>
|
|
5946
|
+
<Button href="/api-keys" variant="outline">
|
|
5947
|
+
<ArrowLeftIcon class="w-4 h-4" />
|
|
5948
|
+
Back to list
|
|
5949
|
+
</Button>
|
|
5950
|
+
</div>
|
|
5951
|
+
|
|
5952
|
+
<div class="bg-card rounded-lg shadow-sm border p-4">
|
|
5953
|
+
<form method="POST">
|
|
5954
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
5955
|
+
<Form.Field {form} name="label" class="col-span-1">
|
|
5956
|
+
<Form.Control>
|
|
5957
|
+
{#snippet children({ props })}
|
|
5958
|
+
<Form.Label>Label</Form.Label>
|
|
5959
|
+
<Input {...props} type="text" bind:value={$formData.label} />
|
|
5960
|
+
{/snippet}
|
|
5961
|
+
</Form.Control>
|
|
5962
|
+
<Form.FieldErrors class="contents text-destructive" />
|
|
5963
|
+
</Form.Field>
|
|
5964
|
+
</div>
|
|
5965
|
+
|
|
5966
|
+
<div class="mt-4 flex gap-2 border-t pt-4 -mx-4 px-4">
|
|
5967
|
+
<Form.Button>Save</Form.Button>
|
|
5968
|
+
<Button href="/api-keys" variant="outline">Cancel</Button>
|
|
5969
|
+
</div>
|
|
5970
|
+
</form>
|
|
5971
|
+
</div>
|
|
5972
|
+
</section>
|
|
5973
|
+
`, Vr = `import PocketBase from 'pocketbase-svelte';
|
|
5974
|
+
import argon2 from 'argon2';
|
|
5975
|
+
import { randomBytes } from 'node:crypto';
|
|
5976
|
+
|
|
5977
|
+
export const createApiKey = async (pb: PocketBase, userId: string | undefined, label: string) => {
|
|
5978
|
+
const keySecret = randomBytes(10).toString('hex');
|
|
5979
|
+
const keyHash = await argon2.hash(keySecret, { type: argon2.argon2id });
|
|
5980
|
+
const apiKey = await pb.collection('api_keys').create({ key_hash: keyHash, user: userId, label });
|
|
5981
|
+
|
|
5982
|
+
return \`\${apiKey.id}.\${keySecret}\`;
|
|
5983
|
+
};
|
|
5984
|
+
`, Kr = `import { describe, it, expect, beforeEach } from 'vitest';
|
|
5985
|
+
import type { Match } from '@velastack/pocketbase';
|
|
5986
|
+
import { createApiKey } from './create-api-key';
|
|
5987
|
+
import type { RouteId } from './$types';
|
|
5988
|
+
|
|
5989
|
+
describe('GET /api-keys/new', () => {
|
|
5990
|
+
beforeEach(async (context) => {
|
|
5991
|
+
await context.agent.authenticateUser();
|
|
5992
|
+
});
|
|
5993
|
+
|
|
5994
|
+
it('should return a 200 status code', async (context) => {
|
|
5995
|
+
const response = await context.agent.get('/api-keys/new' satisfies Match<RouteId>);
|
|
5996
|
+
expect(response.status).toBe(200);
|
|
5997
|
+
});
|
|
5998
|
+
});
|
|
5999
|
+
|
|
6000
|
+
describe('POST /api-keys/new', () => {
|
|
6001
|
+
beforeEach(async (context) => {
|
|
6002
|
+
await context.agent.authenticateUser();
|
|
6003
|
+
});
|
|
6004
|
+
|
|
6005
|
+
it('should create a new API key', async (context) => {
|
|
6006
|
+
const response = await context.agent
|
|
6007
|
+
.post('/api-keys/new')
|
|
6008
|
+
.type('form')
|
|
6009
|
+
.send({ label: 'Test API Key' });
|
|
6010
|
+
expect(response.body.status).toBe(303);
|
|
6011
|
+
expect(response.body.location).toBe('/api-keys');
|
|
6012
|
+
});
|
|
6013
|
+
});
|
|
6014
|
+
|
|
6015
|
+
describe('api keys authenticate as a user', () => {
|
|
6016
|
+
it('should create a new api key', async (context) => {
|
|
6017
|
+
const apiKey = await createApiKey(context.pb, context.user.id, 'Test API Key');
|
|
6018
|
+
expect(apiKey).toBeDefined();
|
|
6019
|
+
});
|
|
6020
|
+
|
|
6021
|
+
it('should throw an error when creating for a non-existent user', async (context) => {
|
|
6022
|
+
await expect(async () => {
|
|
6023
|
+
await createApiKey(context.pb, 'non-existent-user-id', 'Test API Key');
|
|
6024
|
+
}).rejects.toThrow();
|
|
6025
|
+
});
|
|
6026
|
+
|
|
6027
|
+
it('should give access to the api', async (context) => {
|
|
6028
|
+
const response = await context.request.get(\`/api/collections/users/records/\${context.user.id}\`);
|
|
6029
|
+
expect(response.status).toBe(404);
|
|
6030
|
+
|
|
6031
|
+
const apiKey = await createApiKey(context.pb, context.user.id, 'Test API Key');
|
|
6032
|
+
const response2 = await context.request
|
|
6033
|
+
.get(\`/api/collections/users/records/\${context.user.id}\`)
|
|
6034
|
+
.set('Authorization', \`Bearer \${apiKey}\`);
|
|
6035
|
+
expect(response2.status).toBe(200);
|
|
6036
|
+
});
|
|
6037
|
+
});
|
|
6038
|
+
`, Hr = `import { describe, it, expect, beforeEach } from 'vitest';
|
|
6039
|
+
import type { Match } from '@velastack/pocketbase';
|
|
6040
|
+
import type { RouteId } from './$types';
|
|
6041
|
+
|
|
6042
|
+
describe('GET /api-keys', () => {
|
|
6043
|
+
beforeEach(async (context) => {
|
|
6044
|
+
await context.agent.authenticateUser();
|
|
6045
|
+
});
|
|
6046
|
+
|
|
6047
|
+
it('should return a 200 status code', async (context) => {
|
|
6048
|
+
const response = await context.agent.get('/api-keys' satisfies Match<RouteId>);
|
|
6049
|
+
expect(response.status).toBe(200);
|
|
6050
|
+
});
|
|
6051
|
+
});
|
|
6052
|
+
`, Gr = /* @__PURE__ */ Object.assign({
|
|
6053
|
+
"./creates/src/lib/schemas/apiKey.ts": Lr,
|
|
6054
|
+
"./creates/src/routes/(app)/api-keys/+page.server.ts": jr,
|
|
6055
|
+
"./creates/src/routes/(app)/api-keys/+page.svelte": Or,
|
|
6056
|
+
"./creates/src/routes/(app)/api-keys/[id]/+page.server.ts": Nr,
|
|
6057
|
+
"./creates/src/routes/(app)/api-keys/new/+page.server.ts": qr,
|
|
6058
|
+
"./creates/src/routes/(app)/api-keys/new/+page.svelte": Ur,
|
|
6059
|
+
"./creates/src/routes/(app)/api-keys/new/create-api-key.ts": Vr,
|
|
6060
|
+
"./creates/src/routes/(app)/api-keys/new/server.test.ts": Kr,
|
|
6061
|
+
"./creates/src/routes/(app)/api-keys/server.test.ts": Hr
|
|
6062
|
+
}), Wr = "./creates/";
|
|
6063
|
+
async function Jr(t) {
|
|
6064
|
+
return {
|
|
6065
|
+
creates: Object.entries(Gr).map(([n, a]) => {
|
|
6066
|
+
const r = I(n, Wr);
|
|
6067
|
+
return {
|
|
6068
|
+
path: r,
|
|
6069
|
+
language: C(r),
|
|
6070
|
+
content: a
|
|
6071
|
+
};
|
|
6072
|
+
}).sort((n, a) => n.path.localeCompare(a.path)),
|
|
6073
|
+
modifies: [],
|
|
6074
|
+
deletes: [],
|
|
6075
|
+
components: ["alert-dialog", "button", "badge"],
|
|
6076
|
+
packages: ["argon2", "@types/node"],
|
|
6077
|
+
collections: []
|
|
6078
|
+
};
|
|
6079
|
+
}
|
|
6080
|
+
const Xr = `import {
|
|
6081
|
+
POCKETBASE_URL,
|
|
6082
|
+
POCKETBASE_SUPERUSER_EMAIL,
|
|
6083
|
+
POCKETBASE_SUPERUSER_PASSWORD,
|
|
6084
|
+
} from "$env/static/private";
|
|
6085
|
+
import { handlePocketbase } from "@velastack/pocketbase";
|
|
6086
|
+
|
|
6087
|
+
export const handle = handlePocketbase({
|
|
6088
|
+
pocketbaseUrl: POCKETBASE_URL,
|
|
6089
|
+
superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
|
|
6090
|
+
superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,
|
|
6091
|
+
api: {
|
|
6092
|
+
enabled: true,
|
|
6093
|
+
// [!code highlight:1]
|
|
6094
|
+
apiKeys: { enabled: true },
|
|
6095
|
+
},
|
|
6096
|
+
});
|
|
6097
|
+
`, Zr = /* @__PURE__ */ Object.assign({
|
|
6098
|
+
"./preview-modifies/src/hooks.server.ts": Xr
|
|
6099
|
+
}), Yr = "./preview-modifies/";
|
|
6100
|
+
async function Qr(t) {
|
|
6101
|
+
const e = Object.entries(Zr).map(([n, a]) => {
|
|
6102
|
+
const r = I(n, Yr);
|
|
6103
|
+
return {
|
|
6104
|
+
path: r,
|
|
6105
|
+
language: C(r),
|
|
6106
|
+
content: a
|
|
6107
|
+
};
|
|
6108
|
+
}).sort((n, a) => n.path.localeCompare(a.path));
|
|
6109
|
+
return {
|
|
6110
|
+
creates: [],
|
|
6111
|
+
modifies: e,
|
|
6112
|
+
deletes: [],
|
|
6113
|
+
components: [],
|
|
6114
|
+
packages: [],
|
|
6115
|
+
collections: []
|
|
6116
|
+
};
|
|
6117
|
+
}
|
|
6118
|
+
const to = "enable-api-keys", eo = "1.0.0", no = "src/patterns/enable/api-keys", ao = "/enable/api-keys";
|
|
6119
|
+
async function ro(t) {
|
|
6120
|
+
const e = await Jr();
|
|
6121
|
+
if (t.env === "preview") {
|
|
6122
|
+
const s = await Qr();
|
|
6123
|
+
return F(E([e, s]));
|
|
6124
|
+
}
|
|
6125
|
+
const { generate: n } = await import("./generate.runtime-BjFzQdEe.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
|
|
6126
|
+
return r(
|
|
6127
|
+
await F(E([e, a])),
|
|
6128
|
+
t
|
|
6129
|
+
);
|
|
6130
|
+
}
|
|
6131
|
+
const oo = {
|
|
6132
|
+
version: eo,
|
|
6133
|
+
slug: to,
|
|
6134
|
+
source: no,
|
|
6135
|
+
docs: ao,
|
|
6136
|
+
plan: "open",
|
|
6137
|
+
title: "Enable API keys",
|
|
6138
|
+
summary: "Adds API key management for authenticated users and PocketBase API access.",
|
|
6139
|
+
requires: {
|
|
6140
|
+
auth: !0,
|
|
6141
|
+
api: !0,
|
|
6142
|
+
payments: !1
|
|
6143
|
+
},
|
|
6144
|
+
category: "api",
|
|
6145
|
+
tags: ["sveltekit", "api", "api-keys", "pocketbase", "velastack", "authentication"],
|
|
6146
|
+
command: {
|
|
6147
|
+
raw: "vela enable api-keys",
|
|
6148
|
+
base: "vela enable api-keys",
|
|
6149
|
+
argv: []
|
|
6150
|
+
},
|
|
6151
|
+
baseline: "velastack",
|
|
6152
|
+
generate: ro
|
|
6153
|
+
}, so = `import { deLocalizeDefault } from "wuchale/url";
|
|
5720
6154
|
import { matchUrl } from "$locales/main.url";
|
|
5721
6155
|
import { locales } from "$locales/data";
|
|
5722
6156
|
|
|
@@ -5725,7 +6159,7 @@ export const reroute = ({ url }) => {
|
|
|
5725
6159
|
const { path } = matchUrl(upath, locale);
|
|
5726
6160
|
return path ?? url.pathname;
|
|
5727
6161
|
};
|
|
5728
|
-
`,
|
|
6162
|
+
`, io = `import { deLocalizeDefault, fillParams } from "wuchale/url";
|
|
5729
6163
|
import type { Locale } from "../locales/data";
|
|
5730
6164
|
import { matchUrl } from "../locales/main.url";
|
|
5731
6165
|
import { locales } from "../locales/data";
|
|
@@ -5749,7 +6183,7 @@ export function translateUrl(url: string, fromLocale: Locale, toLocale: Locale)
|
|
|
5749
6183
|
}
|
|
5750
6184
|
return localize(url, toLocale);
|
|
5751
6185
|
}
|
|
5752
|
-
`,
|
|
6186
|
+
`, lo = `// @ts-check
|
|
5753
6187
|
import { adapter as svelte } from "@wuchale/svelte";
|
|
5754
6188
|
import { adapter as js } from "wuchale/adapter-vanilla";
|
|
5755
6189
|
import { defineConfig } from "wuchale";
|
|
@@ -5764,18 +6198,18 @@ export default defineConfig({
|
|
|
5764
6198
|
}),
|
|
5765
6199
|
},
|
|
5766
6200
|
});
|
|
5767
|
-
`,
|
|
5768
|
-
"./creates/src/hooks.ts":
|
|
5769
|
-
"./creates/src/lib/url.ts":
|
|
5770
|
-
"./creates/wuchale.config.js":
|
|
5771
|
-
}),
|
|
5772
|
-
async function
|
|
6201
|
+
`, co = /* @__PURE__ */ Object.assign({
|
|
6202
|
+
"./creates/src/hooks.ts": so,
|
|
6203
|
+
"./creates/src/lib/url.ts": io,
|
|
6204
|
+
"./creates/wuchale.config.js": lo
|
|
6205
|
+
}), mo = "./creates/";
|
|
6206
|
+
async function po(t) {
|
|
5773
6207
|
return {
|
|
5774
|
-
creates: Object.entries(
|
|
5775
|
-
const r =
|
|
6208
|
+
creates: Object.entries(co).map(([n, a]) => {
|
|
6209
|
+
const r = I(n, mo);
|
|
5776
6210
|
return {
|
|
5777
6211
|
path: r,
|
|
5778
|
-
language:
|
|
6212
|
+
language: C(r),
|
|
5779
6213
|
content: a
|
|
5780
6214
|
};
|
|
5781
6215
|
}).sort((n, a) => n.path.localeCompare(a.path)),
|
|
@@ -5786,7 +6220,7 @@ async function Ur(t) {
|
|
|
5786
6220
|
collections: []
|
|
5787
6221
|
};
|
|
5788
6222
|
}
|
|
5789
|
-
const
|
|
6223
|
+
const uo = `<!doctype html>
|
|
5790
6224
|
<!-- [!code highlight:1] -->
|
|
5791
6225
|
<html lang="%sveltekit.lang%">
|
|
5792
6226
|
|
|
@@ -5799,7 +6233,7 @@ const Vr = `<!doctype html>
|
|
|
5799
6233
|
</body>
|
|
5800
6234
|
|
|
5801
6235
|
</html>
|
|
5802
|
-
`,
|
|
6236
|
+
`, fo = `import { env } from "$env/dynamic/private";
|
|
5803
6237
|
import { handlePocketbase } from "@velastack/pocketbase";
|
|
5804
6238
|
// [!code highlight:6]
|
|
5805
6239
|
import { sequence } from "@sveltejs/kit/hooks";
|
|
@@ -5833,7 +6267,7 @@ export const handle = sequence(
|
|
|
5833
6267
|
superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD,
|
|
5834
6268
|
}),
|
|
5835
6269
|
);
|
|
5836
|
-
`,
|
|
6270
|
+
`, go = `import { browser } from "$app/environment";
|
|
5837
6271
|
// [!code highlight:4]
|
|
5838
6272
|
import { loadLocale } from "wuchale/load-utils";
|
|
5839
6273
|
import { getLocale } from "$locales/main.url";
|
|
@@ -5850,7 +6284,7 @@ export const load = async ({ url, data }) => {
|
|
|
5850
6284
|
|
|
5851
6285
|
return data;
|
|
5852
6286
|
};
|
|
5853
|
-
`,
|
|
6287
|
+
`, ho = `import adapter from "@sveltejs/adapter-auto";
|
|
5854
6288
|
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
|
5855
6289
|
|
|
5856
6290
|
const config = {
|
|
@@ -5865,7 +6299,7 @@ const config = {
|
|
|
5865
6299
|
};
|
|
5866
6300
|
|
|
5867
6301
|
export default config;
|
|
5868
|
-
`,
|
|
6302
|
+
`, bo = `import { defineConfig } from "vite";
|
|
5869
6303
|
import { sveltekit } from "@sveltejs/kit/vite";
|
|
5870
6304
|
import tailwindcss from "@tailwindcss/vite";
|
|
5871
6305
|
// [!code highlight:1]
|
|
@@ -5875,19 +6309,19 @@ export default defineConfig({
|
|
|
5875
6309
|
// [!code highlight:1]
|
|
5876
6310
|
plugins: [wuchale(), tailwindcss(), sveltekit()],
|
|
5877
6311
|
});
|
|
5878
|
-
`,
|
|
5879
|
-
"./preview-modifies/src/app.html":
|
|
5880
|
-
"./preview-modifies/src/hooks.server.ts":
|
|
5881
|
-
"./preview-modifies/src/routes/+layout.ts":
|
|
5882
|
-
"./preview-modifies/svelte.config.js":
|
|
5883
|
-
"./preview-modifies/vite.config.ts":
|
|
5884
|
-
}),
|
|
5885
|
-
async function
|
|
5886
|
-
const e = Object.entries(
|
|
5887
|
-
const r =
|
|
6312
|
+
`, vo = /* @__PURE__ */ Object.assign({
|
|
6313
|
+
"./preview-modifies/src/app.html": uo,
|
|
6314
|
+
"./preview-modifies/src/hooks.server.ts": fo,
|
|
6315
|
+
"./preview-modifies/src/routes/+layout.ts": go,
|
|
6316
|
+
"./preview-modifies/svelte.config.js": ho,
|
|
6317
|
+
"./preview-modifies/vite.config.ts": bo
|
|
6318
|
+
}), yo = "./preview-modifies/";
|
|
6319
|
+
async function wo(t) {
|
|
6320
|
+
const e = Object.entries(vo).map(([n, a]) => {
|
|
6321
|
+
const r = I(n, yo);
|
|
5888
6322
|
return {
|
|
5889
6323
|
path: r,
|
|
5890
|
-
language:
|
|
6324
|
+
language: C(r),
|
|
5891
6325
|
content: a
|
|
5892
6326
|
};
|
|
5893
6327
|
}).sort((n, a) => n.path.localeCompare(a.path));
|
|
@@ -5900,29 +6334,30 @@ async function Xr(t) {
|
|
|
5900
6334
|
collections: []
|
|
5901
6335
|
};
|
|
5902
6336
|
}
|
|
5903
|
-
const
|
|
5904
|
-
async function
|
|
5905
|
-
const e = await
|
|
6337
|
+
const $o = "enable-i18n", xo = "1.0.0", Fo = "src/patterns/enable/i18n", So = "/enable/i18n";
|
|
6338
|
+
async function Co(t) {
|
|
6339
|
+
const e = await po();
|
|
5906
6340
|
if (t.env === "preview") {
|
|
5907
|
-
const s = await
|
|
5908
|
-
return
|
|
6341
|
+
const s = await wo();
|
|
6342
|
+
return F(E([e, s]));
|
|
5909
6343
|
}
|
|
5910
|
-
const { generate: n } = await import("./generate.runtime-
|
|
6344
|
+
const { generate: n } = await import("./generate.runtime-DDZCukG0.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
|
|
5911
6345
|
return r(
|
|
5912
|
-
await
|
|
6346
|
+
await F(E([e, a])),
|
|
5913
6347
|
t
|
|
5914
6348
|
);
|
|
5915
6349
|
}
|
|
5916
|
-
const
|
|
5917
|
-
version:
|
|
5918
|
-
slug:
|
|
5919
|
-
source:
|
|
5920
|
-
docs:
|
|
6350
|
+
const _o = {
|
|
6351
|
+
version: xo,
|
|
6352
|
+
slug: $o,
|
|
6353
|
+
source: Fo,
|
|
6354
|
+
docs: So,
|
|
5921
6355
|
plan: "open",
|
|
5922
6356
|
title: "Enable i18n",
|
|
5923
6357
|
summary: "Enables i18n with Wuchale and locale-aware routing.",
|
|
5924
6358
|
requires: {
|
|
5925
6359
|
auth: !1,
|
|
6360
|
+
api: !1,
|
|
5926
6361
|
payments: !1
|
|
5927
6362
|
},
|
|
5928
6363
|
category: "i18n",
|
|
@@ -5933,18 +6368,19 @@ const ao = {
|
|
|
5933
6368
|
argv: []
|
|
5934
6369
|
},
|
|
5935
6370
|
baseline: "velastack",
|
|
5936
|
-
generate:
|
|
5937
|
-
},
|
|
6371
|
+
generate: Co
|
|
6372
|
+
}, zo = ne.version, Wt = [
|
|
5938
6373
|
En,
|
|
5939
6374
|
$a,
|
|
5940
|
-
|
|
5941
|
-
|
|
6375
|
+
Hn,
|
|
6376
|
+
pa,
|
|
5942
6377
|
Fr,
|
|
5943
6378
|
Tr,
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
)
|
|
6379
|
+
oo,
|
|
6380
|
+
_o
|
|
6381
|
+
], Mo = Object.fromEntries(
|
|
6382
|
+
Wt.map((t) => [t.slug, t])
|
|
6383
|
+
), Ao = Wt.reduce(
|
|
5948
6384
|
(t, e) => {
|
|
5949
6385
|
const n = e.category;
|
|
5950
6386
|
return t[n] ?? (t[n] = []), t[n].push(e), t;
|
|
@@ -5952,13 +6388,13 @@ const ao = {
|
|
|
5952
6388
|
{}
|
|
5953
6389
|
);
|
|
5954
6390
|
export {
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
6391
|
+
Eo as D,
|
|
6392
|
+
Io as M,
|
|
6393
|
+
Mo as a,
|
|
6394
|
+
Ao as b,
|
|
6395
|
+
u as d,
|
|
6396
|
+
C as l,
|
|
6397
|
+
Wt as p,
|
|
6398
|
+
zo as v
|
|
5963
6399
|
};
|
|
5964
|
-
//# sourceMappingURL=index-
|
|
6400
|
+
//# sourceMappingURL=index-ZTxLoBuU.js.map
|