@velastack/patterns 0.0.15 → 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.
@@ -1,13 +1,13 @@
1
1
  import Qt from "prettier";
2
2
  import te from "prettier-plugin-svelte";
3
- const ee = "0.0.14", ne = {
3
+ const ee = "0.0.16", ne = {
4
4
  version: ee
5
5
  };
6
- function re(t) {
6
+ function ae(t) {
7
7
  return t.language === "ts" || t.language === "svelte" || t.path.endsWith(".json");
8
8
  }
9
- async function ae(t) {
10
- if (!re(t))
9
+ async function re(t) {
10
+ if (!ae(t))
11
11
  return t;
12
12
  try {
13
13
  const e = await Qt.format(t.content, {
@@ -22,13 +22,13 @@ async function ae(t) {
22
22
  return t;
23
23
  }
24
24
  }
25
- async function ut(t) {
26
- return Promise.all(t.map((e) => ae(e)));
25
+ async function pt(t) {
26
+ return Promise.all(t.map((e) => re(e)));
27
27
  }
28
- async function S(t) {
28
+ async function F(t) {
29
29
  const [e, n] = await Promise.all([
30
- ut(t.creates),
31
- ut(t.modifies)
30
+ pt(t.creates),
31
+ pt(t.modifies)
32
32
  ]);
33
33
  return {
34
34
  ...t,
@@ -36,23 +36,23 @@ async function S(t) {
36
36
  modifies: n
37
37
  };
38
38
  }
39
- function dt(t, e) {
39
+ function ut(t, e) {
40
40
  var n = Object.keys(t);
41
41
  if (Object.getOwnPropertySymbols) {
42
- var r = Object.getOwnPropertySymbols(t);
43
- e && (r = r.filter(function(a) {
44
- return Object.getOwnPropertyDescriptor(t, a).enumerable;
45
- })), n.push.apply(n, r);
42
+ var a = Object.getOwnPropertySymbols(t);
43
+ e && (a = a.filter(function(r) {
44
+ return Object.getOwnPropertyDescriptor(t, r).enumerable;
45
+ })), n.push.apply(n, a);
46
46
  }
47
47
  return n;
48
48
  }
49
- function pt(t) {
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 ? dt(Object(n), !0).forEach(function(r) {
53
- oe(t, r, n[r]);
54
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : dt(Object(n)).forEach(function(r) {
55
- Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
52
+ e % 2 ? ut(Object(n), !0).forEach(function(a) {
53
+ oe(t, a, n[a]);
54
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ut(Object(n)).forEach(function(a) {
55
+ Object.defineProperty(t, a, Object.getOwnPropertyDescriptor(n, a));
56
56
  });
57
57
  }
58
58
  return t;
@@ -68,26 +68,26 @@ function ie(t, e) {
68
68
  if (typeof t != "object" || t === null) return t;
69
69
  var n = t[Symbol.toPrimitive];
70
70
  if (n !== void 0) {
71
- var r = n.call(t, e);
72
- if (typeof r != "object") return r;
71
+ var a = n.call(t, e);
72
+ if (typeof a != "object") return a;
73
73
  throw new TypeError("@@toPrimitive must return a primitive value.");
74
74
  }
75
75
  return (e === "string" ? String : Number)(t);
76
76
  }
77
- const d = It({});
77
+ const u = It({});
78
78
  function It(t) {
79
- return e.withOptions = (n) => It(pt(pt({}, t), n)), e;
80
- function e(n, ...r) {
81
- const a = typeof n == "string" ? [n] : n.raw, {
79
+ return e.withOptions = (n) => It(dt(dt({}, t), n)), e;
80
+ function e(n, ...a) {
81
+ const r = typeof n == "string" ? [n] : n.raw, {
82
82
  alignValues: s = !1,
83
83
  escapeSpecialCharacters: i = Array.isArray(n),
84
84
  trimWhitespace: o = !0
85
85
  } = t;
86
86
  let c = "";
87
- for (let f = 0; f < a.length; f++) {
88
- let h = a[f];
89
- if (i && (h = h.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{")), c += h, f < r.length) {
90
- const $ = s ? le(r[f], c) : r[f];
87
+ for (let f = 0; f < r.length; f++) {
88
+ let h = r[f];
89
+ if (i && (h = h.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{")), c += h, f < a.length) {
90
+ const $ = s ? le(a[f], c) : a[f];
91
91
  c += $;
92
92
  }
93
93
  }
@@ -111,8 +111,8 @@ function It(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 u;
115
- const l = (u = h ?? $) !== null && u !== void 0 ? u : "";
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;
@@ -122,22 +122,22 @@ function le(t, e) {
122
122
  if (typeof t != "string" || !t.includes(`
123
123
  `))
124
124
  return t;
125
- const r = e.slice(e.lastIndexOf(`
125
+ const a = e.slice(e.lastIndexOf(`
126
126
  `) + 1).match(/^(\s+)/);
127
- if (r) {
128
- const a = r[1];
127
+ if (a) {
128
+ const r = a[1];
129
129
  return t.replace(/\n/g, `
130
- ${a}`);
130
+ ${r}`);
131
131
  }
132
132
  return t;
133
133
  }
134
- function G(t, e) {
134
+ function I(t, e) {
135
135
  return t.startsWith(e) ? t.slice(e.length) : t.replace(/^\.\//, "");
136
136
  }
137
- function P(t) {
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 H(t) {
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,69 +179,69 @@ 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 E(t) {
182
+ function z(t) {
183
183
  return `$formData.${t.name}`;
184
184
  }
185
- function O(t) {
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 I(t) {
189
- return t.labelAside ? d`
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 D(t, e) {
196
+ function T(t, e) {
197
197
  const n = t.required ? " required" : "";
198
- return d`
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
- ${I(t)}
203
- <Input {...props} type="${e}" bind:value={${E(t)}}${n}${O(t)} />
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 ue(t) {
210
+ function pe(t) {
211
211
  const e = t.required ? " required" : "";
212
- return d`
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
- ${I(t)}
217
- <Textarea {...props} bind:value={${E(t)}}${e}${O(t)} />
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 de(t) {
224
+ function ue(t) {
225
225
  const e = t.required ? " required" : "";
226
- return d`
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={${E(t)}}${e}${O(t)} />
231
- ${I(t)}
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" />
235
235
  </Form.Field>
236
236
  `;
237
237
  }
238
- function pe(t) {
239
- return d`
238
+ function de(t) {
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
- ${I(t)}
244
- <GeopointInput {...props} bind:value={${E(t)}} />
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 pe(t) {
250
250
  }
251
251
  function fe(t) {
252
252
  const e = t.required ? " required" : "", n = t.maxSelect > 1 ? "Multiple" : "Single";
253
- return d`
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
- ${I(t)}
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">
@@ -266,7 +266,7 @@ function fe(t) {
266
266
  </div>
267
267
  {/snippet}
268
268
  {#snippet input()}
269
- <FileForm.Input {...props}${e}${O(t)} />
269
+ <FileForm.Input {...props}${e}${q(t)} />
270
270
  {/snippet}
271
271
  </FileForm.${n}>
272
272
  {/snippet}
@@ -276,17 +276,17 @@ function fe(t) {
276
276
  `;
277
277
  }
278
278
  function ge(t) {
279
- const e = t.maxSelect > 1 ? "multiple" : "single", n = t.required ? " required" : "", r = t.maxSelect > 1 ? "Select options" : "Select an option", a = t.options.map(
279
+ const e = t.maxSelect > 1 ? "multiple" : "single", n = t.required ? " required" : "", a = t.maxSelect > 1 ? "Select options" : "Select an option", r = t.options.map(
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 d`
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
- ${I(t)}
287
+ ${M(t)}
288
288
  <MultiSelect.Trigger class="w-full justify-between">
289
- <MultiSelect.Input bind:value={${E(t)}} placeholder="${r}" {...props}>
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}
@@ -304,7 +304,7 @@ function ge(t) {
304
304
  <Command.Input autofocus placeholder="Search..." />
305
305
  <Command.Empty>No options found</Command.Empty>
306
306
  <Command.Group>
307
- ${a}
307
+ ${r}
308
308
  </Command.Group>
309
309
  </Command.Root>
310
310
  </MultiSelect.Content>
@@ -314,14 +314,14 @@ function ge(t) {
314
314
  `;
315
315
  }
316
316
  function he(t) {
317
- const e = t.maxSelect > 1 ? "multiple" : "single", n = t.maxSelect > 1 ? `Select ${t.relatedModel.pluralDisplayName.toLowerCase()}` : `Select ${t.relatedModel.displayName.toLowerCase()}`, r = `Search ${t.relatedModel.pluralDisplayName.toLowerCase()}...`, a = `No ${t.relatedModel.pluralDisplayName.toLowerCase()} found`, s = t.relatedModel.name, i = t.relatedModel.pluralName;
318
- return d`
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 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={${E(t)}} placeholder="${n}" {...props}>
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}
@@ -337,8 +337,8 @@ function he(t) {
337
337
 
338
338
  <MultiSelect.Content class="p-0">
339
339
  <Command.Root>
340
- <Command.Input autofocus placeholder="${r}" />
341
- <Command.Empty>${a}</Command.Empty>
340
+ <Command.Input autofocus placeholder="${a}" />
341
+ <Command.Empty>${r}</Command.Empty>
342
342
  <Command.Group>
343
343
  {#each data.${i} as ${s}}
344
344
  <MultiSelect.Item value={${s}.id} label={${s}.${t.displayField}} />
@@ -352,41 +352,41 @@ function he(t) {
352
352
  `;
353
353
  }
354
354
  function be(t) {
355
- return d`
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
- ${I(t)}
360
- <Input {...props} type="text" value={${E(t)}}${O(t)} readonly />
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" />
364
364
  </Form.Field>
365
365
  `;
366
366
  }
367
- function rt(t) {
367
+ function at(t) {
368
368
  switch (t.type) {
369
369
  case "text":
370
- return D(t, "text");
370
+ return T(t, "text");
371
371
  case "number":
372
- return D(t, "number");
372
+ return T(t, "number");
373
373
  case "date":
374
- return D(t, "date");
374
+ return T(t, "date");
375
375
  case "email":
376
- return D(t, "email");
376
+ return T(t, "email");
377
377
  case "password":
378
- return D(t, "password");
378
+ return T(t, "password");
379
379
  case "url":
380
- return D(t, "url");
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);
385
+ return pe(t);
386
386
  case "bool":
387
- return de(t);
387
+ return ue(t);
388
388
  case "geoPoint":
389
- return pe(t);
389
+ return de(t);
390
390
  case "file":
391
391
  return fe(t);
392
392
  case "select":
@@ -399,7 +399,7 @@ function rt(t) {
399
399
  }
400
400
  function zt(t) {
401
401
  const e = t.options.map(
402
- (n) => d`
402
+ (n) => u`
403
403
  ${JSON.stringify(n.value)}: {
404
404
  label: ${JSON.stringify(n.label)},
405
405
  value: ${JSON.stringify(n.value)}
@@ -407,24 +407,24 @@ function zt(t) {
407
407
  `
408
408
  ).join(`,
409
409
  `);
410
- return d`
410
+ return u`
411
411
  const ${t.name}Labels = {
412
412
  ${e}
413
413
  } as const;
414
414
  `;
415
415
  }
416
- function L(t) {
416
+ function U(t) {
417
417
  const e = t.flatMap((n) => ce[n.type]);
418
418
  return [...new Set(e)];
419
419
  }
420
- function at(t) {
420
+ function rt(t) {
421
421
  return [...new Set(t.flatMap((e) => me[e]))];
422
422
  }
423
- function R(t, e) {
423
+ function P(t, e) {
424
424
  return `data.${t.name}.${e.name}`;
425
425
  }
426
426
  function Q(t, e, n) {
427
- return d`
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,41 +432,41 @@ function Q(t, e, n) {
432
432
  `;
433
433
  }
434
434
  function ve(t, e) {
435
- const n = R(t, e), r = `<p class="text-muted-foreground">{new Date(${n}).toLocaleDateString()}</p>`, a = e.required ? r : d`
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
- ${r}
437
+ ${a}
438
438
  {/if}
439
439
  `;
440
- return d`
440
+ return u`
441
441
  <div class="space-y-2">
442
442
  <h3 class="font-medium leading-none">${e.title}</h3>
443
- ${a}
443
+ ${r}
444
444
  </div>
445
445
  `;
446
446
  }
447
- function we(t, e) {
448
- const n = R(t, e), r = d`
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
- `, a = e.required ? r : d`
452
+ `, r = e.required ? a : u`
453
453
  {#if ${n}}
454
- ${r}
454
+ ${a}
455
455
  {/if}
456
456
  `;
457
- return d`
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">
461
- ${a}
461
+ ${r}
462
462
  </p>
463
463
  </div>
464
464
  `;
465
465
  }
466
- function ye(t, e) {
467
- const n = R(t, e);
466
+ function we(t, e) {
467
+ const n = P(t, e);
468
468
  if (e.maxSelect > 1)
469
- return d`
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,21 +474,21 @@ function ye(t, e) {
474
474
  {/each}
475
475
  </div>
476
476
  `;
477
- const r = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, a = e.required ? r : d`
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
- ${r}
479
+ ${a}
480
480
  {/if}
481
481
  `;
482
- return d`
482
+ return u`
483
483
  <div class="space-y-2">
484
484
  <h3 class="font-medium leading-none">${e.title}</h3>
485
- ${a}
485
+ ${r}
486
486
  </div>
487
487
  `;
488
488
  }
489
489
  function $e(t, e) {
490
- const n = R(t, e);
491
- return e.maxSelect > 1 ? d`
490
+ const n = P(t, e);
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
- ` : d`
513
+ ` : u`
514
514
  <div class="space-y-2">
515
515
  <h3 class="font-medium leading-none">${e.title}</h3>
516
516
  {#if ${n}}
@@ -536,12 +536,12 @@ function xe(t) {
536
536
  return `/${t.relatedModel.routeSegment}`;
537
537
  }
538
538
  function Fe(t, e) {
539
- const n = `data.${t.name}.expand?.${e.name}`, r = xe(e);
540
- return e.maxSelect > 1 ? d`
539
+ const n = `data.${t.name}.expand?.${e.name}`, a = xe(e);
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}}
544
- <a href="${r}/{${e.singularRelationName}.id}">
544
+ <a href="${a}/{${e.singularRelationName}.id}">
545
545
  <Badge variant="outline" class="text-muted-foreground">
546
546
  {${e.singularRelationName}.${e.displayField}}
547
547
  <CircleArrowRightIcon class="w-4 h-4" />
@@ -549,11 +549,11 @@ function Fe(t, e) {
549
549
  </a>
550
550
  {/each}
551
551
  </div>
552
- ` : d`
552
+ ` : u`
553
553
  <div class="space-y-2">
554
554
  <h3 class="font-medium leading-none">${e.title}</h3>
555
555
  {#if ${n}}
556
- <a href="${r}/{${n}.id}">
556
+ <a href="${a}/{${n}.id}">
557
557
  <Badge variant="outline" class="text-muted-foreground">
558
558
  {${n}.${e.displayField}}
559
559
  <CircleArrowRightIcon class="w-4 h-4" />
@@ -564,7 +564,7 @@ function Fe(t, e) {
564
564
  `;
565
565
  }
566
566
  function Se(t, e) {
567
- const n = R(t, e), r = d`
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,15 +573,15 @@ 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
- `, a = e.required ? r : d`
576
+ `, r = e.required ? a : u`
577
577
  {#if ${n}}
578
- ${r}
578
+ ${a}
579
579
  {/if}
580
580
  `;
581
- return d`
581
+ return u`
582
582
  <div class="space-y-2">
583
583
  <h3 class="font-medium leading-none">${e.title}</h3>
584
- ${a}
584
+ ${r}
585
585
  </div>
586
586
  `;
587
587
  }
@@ -591,9 +591,9 @@ function Ce(t, e) {
591
591
  case "number":
592
592
  case "email":
593
593
  case "editor":
594
- return Q(t, e, `{${R(t, e)}}`);
594
+ return Q(t, e, `{${P(t, e)}}`);
595
595
  case "password":
596
- return d`
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">
@@ -605,19 +605,19 @@ function Ce(t, e) {
605
605
  return Q(
606
606
  t,
607
607
  e,
608
- `{${R(t, e)} ? "Yes" : "No"}`
608
+ `{${P(t, e)} ? "Yes" : "No"}`
609
609
  );
610
610
  case "date":
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":
620
- return Q(t, e, `{JSON.stringify(${R(t, e)})}`);
620
+ return Q(t, e, `{JSON.stringify(${P(t, e)})}`);
621
621
  case "geoPoint":
622
622
  return Se(t, e);
623
623
  case "relation":
@@ -630,75 +630,75 @@ const _e = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), ke = new RegExp("(\\p{Lu
630
630
  function Mt(t) {
631
631
  let e = t.trim();
632
632
  e = e.replace(_e, ft).replace(ke, ft), e = e.replace(Pe, "\0");
633
- let n = 0, r = e.length;
633
+ let n = 0, a = e.length;
634
634
  for (; e.charAt(n) === "\0"; )
635
635
  n++;
636
- if (n === r)
636
+ if (n === a)
637
637
  return [];
638
- for (; e.charAt(r - 1) === "\0"; )
639
- r--;
640
- return e.slice(n, r).split(/\0/g);
638
+ for (; e.charAt(a - 1) === "\0"; )
639
+ a--;
640
+ return e.slice(n, a).split(/\0/g);
641
641
  }
642
642
  function Ee(t) {
643
643
  const e = Mt(t);
644
644
  for (let n = 0; n < e.length; n++) {
645
- const r = e[n], a = Re.exec(r);
646
- if (a) {
647
- const s = a.index + (a[1] ?? a[2]).length;
648
- e.splice(n, 1, r.slice(0, s), r.slice(s));
645
+ const a = e[n], r = Re.exec(a);
646
+ if (r) {
647
+ const s = r.index + (r[1] ?? r[2]).length;
648
+ e.splice(n, 1, a.slice(0, s), a.slice(s));
649
649
  }
650
650
  }
651
651
  return e;
652
652
  }
653
- function Bt(t, e) {
654
- const [n, r, a] = J(t, e);
655
- return n + r.map(W(e == null ? void 0 : e.locale)).join((e == null ? void 0 : e.delimiter) ?? " ") + a;
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 j(t, e) {
658
- const [n, r, a] = J(t, e), s = W(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale), o = Dt(s, i);
659
- return n + r.map((c, m) => m === 0 ? s(c) : o(c, m)).join("") + a;
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
+ return n + a.map((c, m) => m === 0 ? s(c) : o(c, m)).join("") + r;
660
660
  }
661
661
  function Ie(t, e) {
662
- const [n, r, a] = J(t, e), s = W(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale), o = Dt(s, i);
663
- return n + r.map(o).join("") + a;
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
+ return n + a.map(o).join("") + r;
664
664
  }
665
665
  function ot(t, e) {
666
- const [n, r, a] = J(t, e), s = W(e == null ? void 0 : e.locale), i = st(e == null ? void 0 : e.locale);
667
- return n + r.map(Be(s, i)).join(" ") + a;
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
669
  function ze(t, e) {
670
- return Bt(t, { delimiter: "-", ...e });
670
+ return At(t, { delimiter: "-", ...e });
671
671
  }
672
672
  function Me(t, e) {
673
- return Bt(t, { delimiter: "_", ...e });
673
+ return At(t, { delimiter: "_", ...e });
674
674
  }
675
- function W(t) {
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 Be(t, e) {
681
+ function Ae(t, e) {
682
682
  return (n) => `${e(n[0])}${t(n.slice(1))}`;
683
683
  }
684
- function Dt(t, e) {
685
- return (n, r) => {
686
- const a = n[0];
687
- return (r > 0 && a >= "0" && a <= "9" ? "_" + a : e(a)) + t(n.slice(1));
684
+ function Bt(t, e) {
685
+ return (n, a) => {
686
+ const r = n[0];
687
+ return (a > 0 && r >= "0" && r <= "9" ? "_" + r : e(r)) + t(n.slice(1));
688
688
  };
689
689
  }
690
- function J(t, e = {}) {
691
- const n = e.split ?? (e.separateNumbers ? Ee : Mt), r = e.prefixCharacters ?? gt, a = e.suffixCharacters ?? gt;
690
+ function W(t, e = {}) {
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; ) {
694
694
  const o = t.charAt(s);
695
- if (!r.includes(o))
695
+ if (!a.includes(o))
696
696
  break;
697
697
  s++;
698
698
  }
699
699
  for (; i > s; ) {
700
700
  const o = i - 1, c = t.charAt(o);
701
- if (!a.includes(c))
701
+ if (!r.includes(c))
702
702
  break;
703
703
  i = o;
704
704
  }
@@ -708,89 +708,89 @@ function J(t, e = {}) {
708
708
  t.slice(i)
709
709
  ];
710
710
  }
711
- function De(t) {
711
+ function Be(t) {
712
712
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
713
713
  }
714
- function Te(t) {
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 U = { exports: {} }, Ae = U.exports, ht;
718
- function je() {
717
+ var H = { exports: {} }, Te = H.exports, ht;
718
+ function Le() {
719
719
  return ht || (ht = 1, (function(t, e) {
720
- (function(n, r) {
721
- typeof Te == "function" ? t.exports = r() : n.pluralize = r();
722
- })(Ae, function() {
723
- var n = [], r = [], a = {}, s = {}, i = {};
720
+ (function(n, a) {
721
+ typeof De == "function" ? t.exports = a() : n.pluralize = a();
722
+ })(Te, function() {
723
+ var n = [], a = [], r = {}, s = {}, i = {};
724
724
  function o(l) {
725
725
  return typeof l == "string" ? new RegExp("^" + l + "$", "i") : l;
726
726
  }
727
- function c(l, p) {
728
- return l === p ? p : l === l.toLowerCase() ? p.toLowerCase() : l === l.toUpperCase() ? p.toUpperCase() : l[0] === l[0].toUpperCase() ? p.charAt(0).toUpperCase() + p.substr(1).toLowerCase() : p.toLowerCase();
727
+ function c(l, d) {
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
- function m(l, p) {
731
- return l.replace(/\$(\d{1,2})/g, function(w, x) {
732
- return p[x] || "";
730
+ function m(l, d) {
731
+ return l.replace(/\$(\d{1,2})/g, function(y, x) {
732
+ return d[x] || "";
733
733
  });
734
734
  }
735
- function g(l, p) {
736
- return l.replace(p[0], function(w, x) {
737
- var F = m(p[1], arguments);
738
- return c(w === "" ? l[x - 1] : w, F);
735
+ function g(l, d) {
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, p, w) {
742
- if (!l.length || a.hasOwnProperty(l))
743
- return p;
744
- for (var x = w.length; x--; ) {
745
- var F = w[x];
746
- if (F[0].test(p)) return g(p, F);
741
+ function f(l, d, y) {
742
+ if (!l.length || r.hasOwnProperty(l))
743
+ return d;
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
- return p;
748
+ return d;
749
749
  }
750
- function h(l, p, w) {
750
+ function h(l, d, y) {
751
751
  return function(x) {
752
- var F = x.toLowerCase();
753
- return p.hasOwnProperty(F) ? c(x, F) : l.hasOwnProperty(F) ? c(x, l[F]) : f(F, x, w);
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, p, w, x) {
757
- return function(F) {
758
- var M = F.toLowerCase();
759
- return p.hasOwnProperty(M) ? !0 : l.hasOwnProperty(M) ? !1 : f(M, M, w) === M;
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 u(l, p, w) {
763
- var x = p === 1 ? u.singular(l) : u.plural(l);
764
- return (w ? p + " " : "") + x;
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 u.plural = h(
766
+ return p.plural = h(
767
767
  i,
768
768
  s,
769
769
  n
770
- ), u.isPlural = $(
770
+ ), p.isPlural = $(
771
771
  i,
772
772
  s,
773
773
  n
774
- ), u.singular = h(
774
+ ), p.singular = h(
775
775
  s,
776
776
  i,
777
- r
778
- ), u.isSingular = $(
777
+ a
778
+ ), p.isSingular = $(
779
779
  s,
780
780
  i,
781
- r
782
- ), u.addPluralRule = function(l, p) {
783
- n.push([o(l), p]);
784
- }, u.addSingularRule = function(l, p) {
785
- r.push([o(l), p]);
786
- }, u.addUncountableRule = function(l) {
781
+ a
782
+ ), p.addPluralRule = function(l, d) {
783
+ n.push([o(l), d]);
784
+ }, p.addSingularRule = function(l, d) {
785
+ a.push([o(l), d]);
786
+ }, p.addUncountableRule = function(l) {
787
787
  if (typeof l == "string") {
788
- a[l.toLowerCase()] = !0;
788
+ r[l.toLowerCase()] = !0;
789
789
  return;
790
790
  }
791
- u.addPluralRule(l, "$0"), u.addSingularRule(l, "$0");
792
- }, u.addIrregularRule = function(l, p) {
793
- p = p.toLowerCase(), l = l.toLowerCase(), i[l] = p, s[p] = l;
791
+ p.addPluralRule(l, "$0"), p.addSingularRule(l, "$0");
792
+ }, p.addIrregularRule = function(l, d) {
793
+ d = d.toLowerCase(), l = l.toLowerCase(), i[l] = d, s[d] = l;
794
794
  }, [
795
795
  // Pronouns.
796
796
  ["I", "we"],
@@ -845,7 +845,7 @@ function je() {
845
845
  ["pickaxe", "pickaxes"],
846
846
  ["passerby", "passersby"]
847
847
  ].forEach(function(l) {
848
- return u.addIrregularRule(l[0], l[1]);
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 je() {
873
873
  [/m[ae]n$/i, "men"],
874
874
  ["thou", "you"]
875
875
  ].forEach(function(l) {
876
- return u.addPluralRule(l[0], l[1]);
876
+ return p.addPluralRule(l[0], l[1]);
877
877
  }), [
878
878
  [/s$/i, ""],
879
879
  [/(ss)$/i, "$1"],
@@ -899,7 +899,7 @@ function je() {
899
899
  [/(eau)x?$/i, "$1"],
900
900
  [/men$/i, "man"]
901
901
  ].forEach(function(l) {
902
- return u.addSingularRule(l[0], l[1]);
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 je() {
1010
1010
  /pox$/i,
1011
1011
  // "chickpox", "smallpox"
1012
1012
  /sheep$/i
1013
- ].forEach(u.addUncountableRule), u;
1013
+ ].forEach(p.addUncountableRule), p;
1014
1014
  });
1015
- })(U)), U.exports;
1015
+ })(H)), H.exports;
1016
1016
  }
1017
- var Ne = je();
1018
- const k = /* @__PURE__ */ De(Ne), La = "data", qa = "migrations", Oe = "(app)", Le = /* @__PURE__ */ new Set([
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",
@@ -1117,32 +1117,32 @@ const k = /* @__PURE__ */ De(Ne), La = "data", qa = "migrations", Oe = "(app)",
1117
1117
  constructor: "ctor"
1118
1118
  };
1119
1119
  function tt(t) {
1120
- return Le.has(t) ? qe[t] ?? `${t}_` : t;
1120
+ return Ne.has(t) ? qe[t] ?? `${t}_` : t;
1121
1121
  }
1122
- function Z(t) {
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"
1126
1126
  );
1127
1127
  }
1128
- function Ve(t) {
1128
+ function Ue(t) {
1129
1129
  return t.features.auth ? `src/routes/${Oe}` : "src/routes";
1130
1130
  }
1131
- function z(t, e) {
1132
- const n = t.split("/"), r = n[n.length - 1], a = n.slice(0, -1), s = k.singular(ot(r)), i = k.plural(s), o = j(s), c = ze(i), m = [...a, c].join("/");
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(j(i)),
1135
+ pluralName: tt(O(i)),
1136
1136
  typeName: Ie(s),
1137
1137
  tableName: Me(i),
1138
1138
  displayName: s,
1139
1139
  pluralDisplayName: i,
1140
1140
  schemaName: `${tt(o)}Schema`,
1141
1141
  routeSegment: m,
1142
- routesDir: Ve(e)
1142
+ routesDir: Ue(e)
1143
1143
  };
1144
1144
  }
1145
- function Ue(t) {
1145
+ function Ve(t) {
1146
1146
  const e = `${t.routesDir}/${t.routeSegment}`;
1147
1147
  return {
1148
1148
  list: e,
@@ -1151,7 +1151,7 @@ function Ue(t) {
1151
1151
  edit: `${e}/[id]/edit`
1152
1152
  };
1153
1153
  }
1154
- function He(t) {
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 Ge = [
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 We(t) {
1198
- for (const e of Ge)
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 Je(t) {
1203
+ function We(t) {
1204
1204
  return t.map((e) => e.name).filter((e) => !e.startsWith("_"));
1205
1205
  }
1206
- function Ze(t) {
1206
+ function Je(t) {
1207
1207
  return Object.fromEntries(t.map((e) => [e.name, e.id]));
1208
1208
  }
1209
- function Tt(t) {
1209
+ function Dt(t) {
1210
1210
  return Object.fromEntries(
1211
- t.map((e) => [e.name, We(e.fields)])
1211
+ t.map((e) => [e.name, Ge(e.fields)])
1212
1212
  );
1213
1213
  }
1214
- const Ke = [
1214
+ const Xe = [
1215
1215
  "user",
1216
1216
  "owner",
1217
1217
  "created_by",
@@ -1220,7 +1220,7 @@ const Ke = [
1220
1220
  "account",
1221
1221
  "creator"
1222
1222
  ];
1223
- function T(t) {
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 Xe(t, e, n = {}) {
1235
- const r = new Set((n.authCollections ?? ["users"]).map(T)), a = new Set(
1236
- (n.userFieldHints ?? Ke).map(T)
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 (r.has(T(e)))
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 = T(b);
1251
- return v === "user" ? 50 : a.has(v) ? 20 : 0;
1250
+ const v = L(b);
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 C = [];
1257
- for (const y of v.fields) {
1258
- if (y.type !== "relation" || !y.collectionId) continue;
1259
- const B = o.get(y.collectionId);
1260
- B && C.push({
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: y.name,
1263
- to: B.name,
1264
- isMulti: !!(y.maxSelect && y.maxSelect > 1),
1265
- hintScore: c(y.name)
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 C.sort((y, B) => y.fieldName.localeCompare(B.fieldName)), C;
1268
+ return _.sort((w, D) => w.fieldName.localeCompare(D.fieldName)), _;
1269
1269
  }
1270
1270
  function g(b) {
1271
- return r.has(T(b));
1271
+ return a.has(L(b));
1272
1272
  }
1273
1273
  function f(b) {
1274
1274
  if (b.length === 0) return !1;
@@ -1277,41 +1277,41 @@ 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], C = v.isMulti ? 1 : 0, y = b.every((Y) => !Y.isMulti) ? 1 : 0, B = b.reduce((Y, Yt) => Y + Yt.hintScore, 0), Xt = T(v.fieldName) === "user" ? 1 : 0;
1281
- return 100 * b.length + 50 * C - 40 * Xt - 15 * y - B;
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 u = [], l = /* @__PURE__ */ new Set([e]);
1287
- function p(b, v, C) {
1288
- if (!(C > s)) {
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
- u.push([...v]);
1290
+ p.push([...v]);
1291
1291
  return;
1292
1292
  }
1293
- for (const y of m(b))
1294
- l.has(y.to) || y.isMulti && !g(y.to) || (l.add(y.to), v.push(y), p(y.to, v, C + 1), v.pop(), l.delete(y.to));
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 (p(e, [], 0), u.length === 0)
1297
+ if (d(e, [], 0), p.length === 0)
1298
1298
  return bt(e);
1299
- u.sort((b, v) => {
1300
- const C = h(b) - h(v);
1301
- return C !== 0 ? C : $(b).localeCompare($(v));
1299
+ p.sort((b, v) => {
1300
+ const _ = h(b) - h(v);
1301
+ return _ !== 0 ? _ : $(b).localeCompare($(v));
1302
1302
  });
1303
- const w = u[0], x = w.map((b) => b.fieldName), F = [e, ...w.map((b) => b.to)], mt = w[w.length - 1].isMulti ? "?=" : "=", Zt = x.join("."), Kt = n.includeRootPrefix ? (n.rootPrefix ?? e) + "." : "";
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} ${Kt}${Zt}.id`,
1306
- ownershipChainCollections: F,
1305
+ rule: `@request.auth.id ${mt} ${Xt}${Jt}.id`,
1306
+ ownershipChainCollections: S,
1307
1307
  ownershipChainFields: x,
1308
1308
  operator: mt
1309
1309
  };
1310
1310
  }
1311
1311
  function Ye(t) {
1312
- let e = null, n = !1, r = 0;
1313
- for (let a = 0; a < t.length; a++) {
1314
- const s = t[a];
1312
+ let e = null, n = !1, a = 0;
1313
+ for (let r = 0; r < t.length; r++) {
1314
+ const s = t[r];
1315
1315
  if (n) {
1316
1316
  n = !1;
1317
1317
  continue;
@@ -1329,15 +1329,15 @@ function Ye(t) {
1329
1329
  continue;
1330
1330
  }
1331
1331
  if (s === "(") {
1332
- r++;
1332
+ a++;
1333
1333
  continue;
1334
1334
  }
1335
1335
  if (s === ")") {
1336
- r = Math.max(0, r - 1);
1336
+ a = Math.max(0, a - 1);
1337
1337
  continue;
1338
1338
  }
1339
- if (s === ":" && r === 0)
1340
- return [t.slice(0, a), t.slice(a + 1)];
1339
+ if (s === ":" && a === 0)
1340
+ return [t.slice(0, r), t.slice(r + 1)];
1341
1341
  }
1342
1342
  return [t, ""];
1343
1343
  }
@@ -1345,17 +1345,17 @@ 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 wt(t) {
1349
- let e = -1, n = null, r = !1;
1348
+ function yt(t) {
1349
+ let e = -1, n = null, a = !1;
1350
1350
  for (let i = 0; i < t.length; i++) {
1351
1351
  const o = t[i];
1352
- if (r) {
1353
- r = !1;
1352
+ if (a) {
1353
+ a = !1;
1354
1354
  continue;
1355
1355
  }
1356
1356
  if (n) {
1357
1357
  if (o === "\\") {
1358
- r = !0;
1358
+ a = !0;
1359
1359
  continue;
1360
1360
  }
1361
1361
  o === n && (n = null);
@@ -1370,45 +1370,45 @@ function wt(t) {
1370
1370
  break;
1371
1371
  }
1372
1372
  }
1373
- let a, s;
1374
- return e >= 0 ? (a = t.slice(0, e).trim(), s = t.slice(e + 1).trim()) : (a = t.trim(), s = a), { label: vt(s), value: vt(a) };
1373
+ let r, s;
1374
+ return e >= 0 ? (r = t.slice(0, e).trim(), s = t.slice(e + 1).trim()) : (r = t.trim(), s = r), { label: vt(s), value: vt(r) };
1375
1375
  }
1376
1376
  function Qe(t) {
1377
1377
  const e = [];
1378
- let n = "", r = null, a = !1;
1378
+ let n = "", a = null, r = !1;
1379
1379
  for (let i = 0; i < t.length; i++) {
1380
1380
  const o = t[i];
1381
- if (a) {
1382
- n += o, a = !1;
1381
+ if (r) {
1382
+ n += o, r = !1;
1383
1383
  continue;
1384
1384
  }
1385
- if (r) {
1385
+ if (a) {
1386
1386
  if (o === "\\") {
1387
- a = !0, n += o;
1387
+ r = !0, n += o;
1388
1388
  continue;
1389
1389
  }
1390
- if (o === r) {
1391
- r = null, n += o;
1390
+ if (o === a) {
1391
+ a = null, n += o;
1392
1392
  continue;
1393
1393
  }
1394
1394
  n += o;
1395
1395
  continue;
1396
1396
  }
1397
1397
  if (o === '"' || o === "'") {
1398
- r = o, n += o;
1398
+ a = o, n += o;
1399
1399
  continue;
1400
1400
  }
1401
1401
  if (o === ",") {
1402
1402
  const c = n.trim();
1403
- c.length > 0 && e.push(wt(c)), n = "";
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(wt(s)), e;
1409
+ return s.length > 0 && e.push(yt(s)), e;
1410
1410
  }
1411
- const yt = {
1411
+ const wt = {
1412
1412
  string: "text",
1413
1413
  boolean: "bool",
1414
1414
  geopoint: "geoPoint",
@@ -1423,64 +1423,64 @@ const yt = {
1423
1423
  };
1424
1424
  function tn(t) {
1425
1425
  const e = t.endsWith("!");
1426
- let n = e ? t.slice(0, -1) : t, r = [];
1426
+ let n = e ? t.slice(0, -1) : t, a = [];
1427
1427
  if (n.startsWith("select(") && n.endsWith(")")) {
1428
- const a = n.slice(7, -1);
1429
- r = Qe(a), n = "select";
1428
+ const r = n.slice(7, -1);
1429
+ a = Qe(r), n = "select";
1430
1430
  }
1431
- return n === "files" ? { type: "file", required: e, selectOptions: r } : (n in yt && (n = yt[n]), { type: n, required: e, selectOptions: r });
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 = k.singular(t), n = k.plural(e);
1434
+ const e = R.singular(t), n = R.plural(e);
1435
1435
  return t === n ? 99 : 1;
1436
1436
  }
1437
- function q(t, e, n, r, a, s) {
1438
- const i = z(e, s), o = k.singular(t), c = k.plural(o);
1437
+ function V(t, e, n, a, r, s) {
1438
+ const i = A(e, s), o = R.singular(t), c = R.plural(o);
1439
1439
  return {
1440
- collectionId: r[e],
1441
- displayField: a[e] ?? "id",
1440
+ collectionId: a[e],
1441
+ displayField: r[e] ?? "id",
1442
1442
  relatedModel: i,
1443
- singularRelationName: j(
1443
+ singularRelationName: O(
1444
1444
  `${n.displayName} ${i.displayName}`
1445
1445
  ),
1446
- pluralRelationName: j(
1446
+ pluralRelationName: O(
1447
1447
  `${n.displayName} ${i.pluralDisplayName}`
1448
1448
  ),
1449
1449
  maxSelect: t === c ? 999 : 1
1450
1450
  };
1451
1451
  }
1452
- function en(t, e, n, r, a) {
1453
- const s = ot(t), { type: i, required: o, selectOptions: c } = e, m = Je(r), g = Ze(r), f = Tt(r), h = m.map((u) => k.singular(u));
1454
- if (a.features.auth && i === "current_user" && g.users) {
1455
- const u = q(
1452
+ function en(t, e, n, a, r) {
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
+ if (r.features.auth && i === "current_user" && g.users) {
1455
+ const p = V(
1456
1456
  t,
1457
1457
  "users",
1458
1458
  n,
1459
1459
  g,
1460
1460
  f,
1461
- a
1461
+ r
1462
1462
  );
1463
1463
  return {
1464
1464
  type: "relation",
1465
1465
  name: t,
1466
1466
  title: s,
1467
1467
  required: o,
1468
- collectionId: u.collectionId,
1468
+ collectionId: p.collectionId,
1469
1469
  maxSelect: 1,
1470
- displayField: u.displayField,
1471
- relatedModel: u.relatedModel,
1472
- singularRelationName: u.singularRelationName,
1473
- pluralRelationName: u.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 u = t.includes("create"), l = t.includes("update");
1479
- if (!u && !l)
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: u, onUpdate: l };
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,56 +1500,56 @@ function en(t, e, n, r, a) {
1500
1500
  maxSelect: $t(t)
1501
1501
  };
1502
1502
  if (i === "relation") {
1503
- const u = k.singular(t), l = k.plural(u);
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)`
1507
1507
  );
1508
- const p = q(
1508
+ const d = V(
1509
1509
  t,
1510
1510
  l,
1511
1511
  n,
1512
1512
  g,
1513
1513
  f,
1514
- a
1514
+ r
1515
1515
  );
1516
1516
  return {
1517
1517
  type: "relation",
1518
1518
  name: t,
1519
1519
  title: s,
1520
1520
  required: o,
1521
- ...p,
1521
+ ...d,
1522
1522
  isCurrentUser: !1
1523
1523
  };
1524
1524
  }
1525
1525
  if (m.includes(i)) {
1526
- const u = q(
1526
+ const p = V(
1527
1527
  t,
1528
1528
  i,
1529
1529
  n,
1530
1530
  g,
1531
1531
  f,
1532
- a
1532
+ r
1533
1533
  );
1534
1534
  return {
1535
1535
  type: "relation",
1536
1536
  name: t,
1537
1537
  title: s,
1538
1538
  required: o,
1539
- ...u,
1539
+ ...p,
1540
1540
  isCurrentUser: !1
1541
1541
  };
1542
1542
  }
1543
1543
  if (h.includes(i)) {
1544
- const u = k.plural(i);
1545
- if (m.includes(u)) {
1546
- const l = q(
1544
+ const p = R.plural(i);
1545
+ if (m.includes(p)) {
1546
+ const l = V(
1547
1547
  t,
1548
- u,
1548
+ p,
1549
1549
  n,
1550
1550
  g,
1551
1551
  f,
1552
- a
1552
+ r
1553
1553
  );
1554
1554
  return {
1555
1555
  type: "relation",
@@ -1582,7 +1582,7 @@ function en(t, e, n, r, a) {
1582
1582
  "select",
1583
1583
  "file",
1584
1584
  "relation",
1585
- ...a.features.auth ? ["current_user"] : [],
1585
+ ...r.features.auth ? ["current_user"] : [],
1586
1586
  ...m
1587
1587
  ])
1588
1588
  ];
@@ -1603,8 +1603,8 @@ function en(t, e, n, r, a) {
1603
1603
  );
1604
1604
  return { type: i, name: t, title: s, required: o };
1605
1605
  }
1606
- function nn(t, e, n, r) {
1607
- const a = [];
1606
+ function nn(t, e, n, a) {
1607
+ const r = [];
1608
1608
  for (const i of t) {
1609
1609
  const [o, c] = Ye(i);
1610
1610
  if (!o || !c)
@@ -1616,16 +1616,16 @@ function nn(t, e, n, r) {
1616
1616
  `Invalid field name: ${o}. Must start with a letter and contain only alphanumeric characters`
1617
1617
  );
1618
1618
  const m = tn(c);
1619
- a.push(en(o, m, e, n, r));
1619
+ r.push(en(o, m, e, n, a));
1620
1620
  }
1621
- const s = r.features.auth ? Xe(
1621
+ const s = a.features.auth ? Ze(
1622
1622
  [
1623
1623
  ...n,
1624
1624
  {
1625
1625
  id: "new",
1626
1626
  name: e.tableName,
1627
1627
  type: "base",
1628
- fields: a.map((i) => ({
1628
+ fields: r.map((i) => ({
1629
1629
  name: i.name,
1630
1630
  type: i.type,
1631
1631
  collectionId: i.type === "relation" ? i.collectionId : void 0,
@@ -1635,34 +1635,34 @@ function nn(t, e, n, r) {
1635
1635
  ],
1636
1636
  e.tableName
1637
1637
  ) : void 0;
1638
- return { fields: a, auth: s };
1638
+ return { fields: r, auth: s };
1639
1639
  }
1640
- async function K(t, e, n) {
1641
- let r;
1640
+ async function X(t, e, n) {
1641
+ let a;
1642
1642
  if (n.env === "runtime") {
1643
- const { getCollections: a } = await import("./env.runtime-BTggk_Vb.js");
1644
- r = await a();
1643
+ const { getCollections: r } = await import("./env.runtime-BGG6V4qg.js");
1644
+ a = await r();
1645
1645
  } else {
1646
- const { getPreviewCollections: a } = await import("./env.preview-HlXZOEL4.js");
1647
- r = a(n);
1646
+ const { getPreviewCollections: r } = await import("./env.preview-HlXZOEL4.js");
1647
+ a = r(n);
1648
1648
  }
1649
- return nn(t, e, r, n);
1649
+ return nn(t, e, a, n);
1650
1650
  }
1651
- const rn = "2024-01-01T00:00:00.000Z";
1651
+ const an = "2024-01-01T00:00:00.000Z";
1652
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 N ? t.expression : Array.isArray(t) ? `[${t.map((e) => nt(e)).join(", ")}]` : t && typeof t == "object" ? `{ ${Object.entries(t).map(([n, r]) => `${JSON.stringify(n)}: ${nt(r)}`).join(", ")} }` : JSON.stringify(t);
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(
1662
- ([n, r]) => `${JSON.stringify(n)}: ${nt(r)}`
1662
+ ([n, a]) => `${JSON.stringify(n)}: ${nt(a)}`
1663
1663
  ).join(", ")} }`;
1664
1664
  }
1665
- function an(t) {
1665
+ function rn(t) {
1666
1666
  switch (t) {
1667
1667
  case "text":
1668
1668
  case "number":
@@ -1698,11 +1698,11 @@ function an(t) {
1698
1698
  return;
1699
1699
  }
1700
1700
  }
1701
- function A(t, e) {
1701
+ function j(t, e) {
1702
1702
  return t.replace("[id]", `\${${e}}`);
1703
1703
  }
1704
- function At(t, e, n) {
1705
- var r, a, s;
1704
+ function Tt(t, e, n) {
1705
+ var a, r, s;
1706
1706
  switch (t.type) {
1707
1707
  case "text":
1708
1708
  case "editor":
@@ -1712,7 +1712,7 @@ function At(t, e, n) {
1712
1712
  case "bool":
1713
1713
  return !0;
1714
1714
  case "date":
1715
- return rn;
1715
+ return an;
1716
1716
  case "email":
1717
1717
  return `test-${t.name}@example.com`;
1718
1718
  case "password":
@@ -1724,7 +1724,7 @@ function At(t, e, n) {
1724
1724
  case "geoPoint":
1725
1725
  return n.forForm ? JSON.stringify({ lat: 40.7128, lon: -74.006 }) : { lat: 40.7128, lon: -74.006 };
1726
1726
  case "select": {
1727
- const i = ((a = (r = t.options) == null ? void 0 : r[0]) == null ? void 0 : a.value) ?? "default";
1727
+ const i = ((r = (a = t.options) == null ? void 0 : a[0]) == null ? void 0 : r.value) ?? "default";
1728
1728
  return t.maxSelect && t.maxSelect > 1 ? [i] : i;
1729
1729
  }
1730
1730
  case "relation": {
@@ -1741,26 +1741,26 @@ function At(t, e, n) {
1741
1741
  }
1742
1742
  }
1743
1743
  function xt(t, e, n) {
1744
- const r = {};
1745
- for (const a of t) {
1746
- if (a.type === "file" || a.type === "autodate")
1744
+ const a = {};
1745
+ for (const r of t) {
1746
+ if (r.type === "file" || r.type === "autodate")
1747
1747
  continue;
1748
- if (n.authEnabled && a.type === "relation" && a.isCurrentUser) {
1749
- n.forForm || (r[a.name] = new N("context.user.id"));
1748
+ if (n.authEnabled && r.type === "relation" && r.isCurrentUser) {
1749
+ n.forForm || (a[r.name] = new N("context.user.id"));
1750
1750
  continue;
1751
1751
  }
1752
- const s = At(a, e, n);
1753
- s !== void 0 && (r[a.name] = s);
1752
+ const s = Tt(r, e, n);
1753
+ s !== void 0 && (a[r.name] = s);
1754
1754
  }
1755
- return r;
1755
+ return a;
1756
1756
  }
1757
1757
  function on(t, e, n) {
1758
- var a;
1759
- const r = {};
1758
+ var r;
1759
+ const a = {};
1760
1760
  for (const s of t) {
1761
1761
  if (s.system || s.name === "id")
1762
1762
  continue;
1763
- const i = an(s.type);
1763
+ const i = rn(s.type);
1764
1764
  if (!i || i === "file" || i === "autodate" || i === "relation" && !s.collectionId)
1765
1765
  continue;
1766
1766
  let o;
@@ -1769,17 +1769,17 @@ function on(t, e, n) {
1769
1769
  e[s.collectionId] ?? '"missing-relation-id"'
1770
1770
  ) : void 0;
1771
1771
  else if (i === "select") {
1772
- const c = ((a = s.values) == null ? void 0 : a[0]) ?? "default";
1772
+ const c = ((r = s.values) == null ? void 0 : r[0]) ?? "default";
1773
1773
  o = (s.maxSelect ?? 1) > 1 ? [c] : c;
1774
1774
  } else
1775
- o = At(
1775
+ o = Tt(
1776
1776
  { name: s.name, type: i },
1777
1777
  e,
1778
1778
  { forForm: !1, authEnabled: n.features.auth }
1779
1779
  );
1780
- o !== void 0 && (r[s.name] = o);
1780
+ o !== void 0 && (a[s.name] = o);
1781
1781
  }
1782
- return r;
1782
+ return a;
1783
1783
  }
1784
1784
  function sn(t) {
1785
1785
  t.email = new N(
@@ -1789,15 +1789,15 @@ function sn(t) {
1789
1789
  function ln(t, e) {
1790
1790
  if (!t)
1791
1791
  return [];
1792
- const n = new Map(e.map((o) => [o.id, o])), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = [], i = (o) => {
1793
- if (r.has(o) || a.has(o))
1792
+ const n = new Map(e.map((o) => [o.id, o])), a = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], i = (o) => {
1793
+ if (a.has(o) || r.has(o))
1794
1794
  return;
1795
1795
  const c = n.get(o);
1796
1796
  if (c) {
1797
- a.add(o);
1797
+ r.add(o);
1798
1798
  for (const m of c.fields)
1799
1799
  m.type !== "relation" || !m.collectionId || i(m.collectionId);
1800
- a.delete(o), r.add(o), s.push(c);
1800
+ r.delete(o), a.add(o), s.push(c);
1801
1801
  }
1802
1802
  };
1803
1803
  for (const o of t.fields)
@@ -1810,8 +1810,8 @@ function cn(t, e) {
1810
1810
  let n = 2;
1811
1811
  for (; e.has(`${t}${n}`); )
1812
1812
  n += 1;
1813
- const r = `${t}${n}`;
1814
- return e.add(r), r;
1813
+ const a = `${t}${n}`;
1814
+ return e.add(a), a;
1815
1815
  }
1816
1816
  function mn(t, e) {
1817
1817
  return {
@@ -1827,7 +1827,7 @@ function mn(t, e) {
1827
1827
  name: n.name,
1828
1828
  type: n.type,
1829
1829
  maxSelect: n.maxSelect,
1830
- values: n.options.map((r) => r.value)
1830
+ values: n.options.map((a) => a.value)
1831
1831
  } : n.type === "file" || n.type === "autodate" ? {
1832
1832
  name: n.name,
1833
1833
  type: n.type,
@@ -1835,44 +1835,44 @@ function mn(t, e) {
1835
1835
  } : { name: n.name, type: n.type })
1836
1836
  };
1837
1837
  }
1838
- function jt(t, e, n, r) {
1839
- const a = r.find((l) => l.name === t.tableName) ?? mn(t, e), s = ln(a, r).filter(
1838
+ function Lt(t, e, n, a) {
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 p = cn(z(l.name, n).name, c);
1844
- o.push({ varName: p, collection: l }), i[l.id] = `${p}.id`;
1843
+ const d = cn(A(l.name, n).name, c);
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
- ` : "", g = o.map(({ varName: l, collection: p }) => {
1850
- const w = on(
1851
- p.fields,
1849
+ ` : "", g = o.map(({ varName: l, collection: d }) => {
1850
+ const y = on(
1851
+ d.fields,
1852
1852
  i,
1853
1853
  n
1854
1854
  );
1855
- return p.type === "auth" && sn(w), `${l} = await context.admin.collection("${p.name}").create(${et(w)});`;
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
- ({ varName: l, collection: p }) => `await context.admin.collection("${p.name}").delete(${l}.id);`
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 u = "";
1861
- return (g.length > 0 || n.features.auth) && (u += d`
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 && (u += `
1866
+ `), f.length > 0 && (p += `
1867
1867
 
1868
- ` + d`
1868
+ ` + u`
1869
1869
  afterEach(async (context) => {
1870
1870
  ${f.join(`
1871
1871
  `)}
1872
1872
  });
1873
1873
  `), {
1874
1874
  declarations: m,
1875
- setupSection: u,
1875
+ setupSection: p,
1876
1876
  requestAgent: h,
1877
1877
  modelDbData: et(
1878
1878
  xt(e, i, {
@@ -1888,9 +1888,9 @@ function jt(t, e, n, r) {
1888
1888
  )
1889
1889
  };
1890
1890
  }
1891
- function un(t, e, n, r, a) {
1892
- const { declarations: s, setupSection: i, requestAgent: o, modelDbData: c, modelFormData: m } = jt(t, n, r, a);
1893
- return d`
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, r, a) {
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(\`${A(e.show, "id")}\`);
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, r, a) {
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(\`${A(e.show, "id")}\`).type("form");
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(\`${A(e.show, "id")}\`);
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, r, a) {
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(\`${A(e.edit, "id")}\`);
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, r, a) {
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(\`${A(e.edit, "id")}\`)
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(\`${A(e.show, "id")}\`);
1963
+ expect(response.body.location).toBe(\`${j(e.show, "id")}\`);
1964
1964
  });
1965
1965
  });
1966
1966
  });
1967
1967
  `;
1968
1968
  }
1969
- function dn(t, e, n, r, a) {
1970
- const { declarations: s, setupSection: i, requestAgent: o, modelFormData: c } = jt(t, n, r, a);
1971
- return d`
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}", () => {
@@ -1990,12 +1990,12 @@ function dn(t, e, n, r, a) {
1990
1990
  });
1991
1991
  `;
1992
1992
  }
1993
- var Ft = Object.freeze, pn = Object.defineProperty, fn = (t, e) => Ft(pn(t, "raw", { value: Ft(t.slice()) })), St;
1993
+ var Ft = Object.freeze, dn = Object.defineProperty, fn = (t, e) => Ft(dn(t, "raw", { value: Ft(t.slice()) })), St;
1994
1994
  function gn(t, e) {
1995
- const n = t.replace(/^\/+|\/+$/g, ""), r = `${e}/${n}`, a = `/${n}`;
1995
+ const n = t.replace(/^\/+|\/+$/g, ""), a = `${e}/${n}`, r = `/${n}`;
1996
1996
  return {
1997
- pagePath: r,
1998
- pageUrl: a
1997
+ pagePath: a,
1998
+ pageUrl: r
1999
1999
  };
2000
2000
  }
2001
2001
  function hn(t) {
@@ -2006,14 +2006,14 @@ 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 Nt(t) {
2009
+ function jt(t) {
2010
2010
  return t.some((e) => e.type === "file");
2011
2011
  }
2012
2012
  function bn(t) {
2013
2013
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
2014
2014
  }
2015
2015
  function Ct(t) {
2016
- const e = t.type === "select" ? `[${t.options.map((a) => JSON.stringify(a.value)).join(", ")}]` : "";
2016
+ const e = t.type === "select" ? `[${t.options.map((r) => JSON.stringify(r.value)).join(", ")}]` : "";
2017
2017
  let n;
2018
2018
  switch (t.type) {
2019
2019
  case "text":
@@ -2088,10 +2088,10 @@ function vn(t) {
2088
2088
  }
2089
2089
  return e;
2090
2090
  }
2091
- function wn(t, e) {
2092
- const n = vn(e).map((r) => `${bn(r.name)}: ${r.schema}`).join(`,
2091
+ function yn(t, e) {
2092
+ const n = vn(e).map((a) => `${bn(a.name)}: ${a.schema}`).join(`,
2093
2093
  `);
2094
- return d`
2094
+ return u`
2095
2095
  import { z } from "zod/v3";
2096
2096
 
2097
2097
  export const ${t.schemaName} = z.object({
@@ -2099,24 +2099,24 @@ function wn(t, e) {
2099
2099
  });
2100
2100
  `;
2101
2101
  }
2102
- function yn(t, e) {
2103
- const n = L(e), r = [
2102
+ function wn(t, e) {
2103
+ const n = U(e), a = [
2104
2104
  'import { untrack } from "svelte";',
2105
2105
  'import { superForm } from "sveltekit-superforms";',
2106
2106
  'import { zodClient } from "sveltekit-superforms/adapters";',
2107
2107
  `import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
2108
- ...at(n)
2108
+ ...rt(n)
2109
2109
  ];
2110
- return [...new Set(r)];
2110
+ return [...new Set(a)];
2111
2111
  }
2112
2112
  function $n(t, e) {
2113
- const r = e.filter(
2114
- (a) => a.type === "select"
2115
- ).map((a) => zt(a)).join(`
2113
+ const a = e.filter(
2114
+ (r) => r.type === "select"
2115
+ ).map((r) => zt(r)).join(`
2116
2116
 
2117
2117
  `);
2118
- return d`
2119
- ${r}
2118
+ return u`
2119
+ ${a}
2120
2120
 
2121
2121
  const form = superForm(untrack(() => data.form), {
2122
2122
  validators: zodClient(${t.schemaName}),
@@ -2126,10 +2126,10 @@ function $n(t, e) {
2126
2126
  `;
2127
2127
  }
2128
2128
  function xn(t, e) {
2129
- const n = yn(t, e).join(`
2130
- `), r = $n(t, e), a = e.map((i) => rt(i)).join(`
2131
- `), s = Nt(e) ? ' enctype="multipart/form-data"' : "";
2132
- return d(St || (St = fn([`
2129
+ const n = wn(t, e).join(`
2130
+ `), a = $n(t, e), r = e.map((i) => at(i)).join(`
2131
+ `), s = jt(e) ? ' enctype="multipart/form-data"' : "";
2132
+ return u(St || (St = fn([`
2133
2133
  <script lang="ts">
2134
2134
  `, `
2135
2135
 
@@ -2152,17 +2152,17 @@ function xn(t, e) {
2152
2152
  </form>
2153
2153
  </div>
2154
2154
  </section>
2155
- `])), n, r, t.displayName, s, a);
2155
+ `])), n, a, t.displayName, s, r);
2156
2156
  }
2157
2157
  function Fn(t, e) {
2158
- const n = Nt(e), r = d`
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 d`
2165
- ${r}
2164
+ return u`
2165
+ ${a}
2166
2166
 
2167
2167
  export const load = async () => {
2168
2168
  const form = await superValidate(zod(${t.schemaName}));
@@ -2184,33 +2184,33 @@ function Fn(t, e) {
2184
2184
  };
2185
2185
  `;
2186
2186
  }
2187
- function V(t, e) {
2187
+ function K(t, e) {
2188
2188
  return {
2189
2189
  path: t,
2190
- language: P(t),
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
- Z(e);
2197
- const r = z(e, t), s = (await K(n, r, t)).fields, { pagePath: i, pageUrl: o } = gn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-BTggk_Vb.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
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
- V(`${i}/+page.svelte`, xn(r, s)),
2201
- V(`${i}/+page.server.ts`, Fn(r, s)),
2202
- V(
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
- dn(
2205
- r,
2204
+ un(
2205
+ a,
2206
2206
  o,
2207
2207
  s,
2208
2208
  t,
2209
2209
  c
2210
2210
  )
2211
2211
  ),
2212
- V(`src/lib/schemas/${r.name}.ts`, wn(r, s))
2213
- ], g = L(s);
2212
+ K(`src/lib/schemas/${a.name}.ts`, yn(a, s))
2213
+ ], g = U(s);
2214
2214
  return {
2215
2215
  creates: m,
2216
2216
  modifies: [],
@@ -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 S(e);
2227
+ return F(e);
2228
2228
  const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
2229
- return n(await S(e), t);
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",
@@ -2279,53 +2280,53 @@ 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 Bn(t, e) {
2283
- const n = t.type === "select" ? `[${(t.options ?? []).map((a) => JSON.stringify(a.value)).join(", ")}]` : "";
2284
- let r;
2283
+ function An(t, e) {
2284
+ const n = t.type === "select" ? `[${(t.options ?? []).map((r) => JSON.stringify(r.value)).join(", ")}]` : "";
2285
+ let a;
2285
2286
  switch (t.type) {
2286
2287
  case "text":
2287
- r = "z.string()";
2288
+ a = "z.string()";
2288
2289
  break;
2289
2290
  case "number":
2290
- r = "z.number()";
2291
+ a = "z.number()";
2291
2292
  break;
2292
2293
  case "bool":
2293
- r = "z.boolean().default(false)";
2294
+ a = "z.boolean().default(false)";
2294
2295
  break;
2295
2296
  case "date":
2296
- r = e.forForm ? "z.string()" : "z.date()";
2297
+ a = e.forForm ? "z.string()" : "z.date()";
2297
2298
  break;
2298
2299
  case "email":
2299
- r = "z.string().email()";
2300
+ a = "z.string().email()";
2300
2301
  break;
2301
2302
  case "password":
2302
- r = "z.string()";
2303
+ a = "z.string()";
2303
2304
  break;
2304
2305
  case "url":
2305
- r = "z.string().url()";
2306
+ a = "z.string().url()";
2306
2307
  break;
2307
2308
  case "editor":
2308
- r = "z.string()";
2309
+ a = "z.string()";
2309
2310
  break;
2310
2311
  case "autodate":
2311
- r = e.forForm ? "z.string()" : "z.date()";
2312
+ a = e.forForm ? "z.string()" : "z.date()";
2312
2313
  break;
2313
2314
  case "select":
2314
- n ? r = (t.maxSelect ?? 1) > 1 ? `z.array(z.enum(${n}))` : `z.enum(${n})` : r = "z.string()";
2315
+ n ? a = (t.maxSelect ?? 1) > 1 ? `z.array(z.enum(${n}))` : `z.enum(${n})` : a = "z.string()";
2315
2316
  break;
2316
2317
  case "file":
2317
- r = (t.maxSelect ?? 1) > 1 ? "z.string().array()" : "z.union([z.instanceof(File), z.string()])";
2318
+ a = (t.maxSelect ?? 1) > 1 ? "z.string().array()" : "z.union([z.instanceof(File), z.string()])";
2318
2319
  break;
2319
2320
  case "json":
2320
- r = "z.any()";
2321
+ a = "z.any()";
2321
2322
  break;
2322
2323
  case "geoPoint":
2323
- r = e.forForm ? `z.preprocess((val) => {
2324
+ a = e.forForm ? `z.preprocess((val) => {
2324
2325
  if (typeof val === "string") {
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>` : d`
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)
@@ -2333,54 +2334,54 @@ function Bn(t, e) {
2333
2334
  `;
2334
2335
  break;
2335
2336
  case "relation":
2336
- r = (t.maxSelect ?? 1) > 1 ? "z.array(z.string())" : "z.string()";
2337
+ a = (t.maxSelect ?? 1) > 1 ? "z.array(z.string())" : "z.string()";
2337
2338
  break;
2338
2339
  default:
2339
2340
  return t.type;
2340
2341
  }
2341
- return In.includes(t.type) ? t.required ? `${r}.nonempty()` : `${r}.optional()` : t.required || t.type === "geoPoint" ? r : t.type === "file" && (t.maxSelect ?? 1) <= 1 ? `${r}.optional().default("")` : `${r}.optional()`;
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
- const r = [];
2345
- n.includeModelFields && (r.push({ name: "id", type: "text", required: !1 }), r.push({ name: "collectionId", type: "text", required: !1 }));
2345
+ const a = [];
2346
+ n.includeModelFields && (a.push({ name: "id", type: "text", required: !1 }), a.push({ name: "collectionId", type: "text", required: !1 }));
2346
2347
  for (const o of e) {
2347
2348
  if (o.type === "file" && o.maxSelect > 1) {
2348
- r.push({ ...o, required: !1 }), r.push({ name: `${o.name}+`, type: "file", required: !1, maxSelect: 999 }), r.push({ name: `${o.name}-`, type: "file", required: !1, maxSelect: 999 });
2349
+ a.push({ ...o, required: !1 }), a.push({ name: `${o.name}+`, type: "file", required: !1, maxSelect: 999 }), a.push({ name: `${o.name}-`, type: "file", required: !1, maxSelect: 999 });
2349
2350
  continue;
2350
2351
  }
2351
- r.push(o);
2352
+ a.push(o);
2352
2353
  }
2353
- const a = r.map((o) => `${Mn(o.name)}: ${Bn(o, n)}`).join(`,
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 d`
2357
+ return u`
2357
2358
  import { z } from "zod/v3";${s}
2358
2359
 
2359
2360
  export const ${t.schemaName} = z.object({
2360
- ${a}
2361
+ ${r}
2361
2362
  })${i};
2362
2363
  `;
2363
2364
  }
2364
- function Dn(t) {
2365
+ function Bn(t) {
2365
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;
2369
2370
  }
2370
2371
  function lt(t, e, n) {
2371
- const r = e.find((o) => o.name === t.tableName);
2372
- if (!r)
2372
+ const a = e.find((o) => o.name === t.tableName);
2373
+ if (!a)
2373
2374
  throw new Error(`Collection "${t.tableName}" not found`);
2374
- const a = Tt(e), s = new Map(e.map((o) => [o.id, o])), i = [];
2375
- for (const o of r.fields) {
2375
+ const r = Dt(e), s = new Map(e.map((o) => [o.id, o])), i = [];
2376
+ for (const o of a.fields) {
2376
2377
  if (o.name === "id" || o.system)
2377
2378
  continue;
2378
- const c = Dn(o.type), m = !!o.required, g = ot(o.name);
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 = z(f.name, n);
2384
+ const h = A(f.name, n);
2384
2385
  i.push({
2385
2386
  name: o.name,
2386
2387
  title: g,
@@ -2388,12 +2389,12 @@ function lt(t, e, n) {
2388
2389
  required: m,
2389
2390
  collectionId: f.id,
2390
2391
  maxSelect: o.maxSelect ?? 1,
2391
- displayField: a[f.name] ?? "id",
2392
+ displayField: r[f.name] ?? "id",
2392
2393
  relatedModel: h,
2393
- singularRelationName: j(
2394
+ singularRelationName: O(
2394
2395
  `${t.displayName} ${h.displayName}`
2395
2396
  ),
2396
- pluralRelationName: j(
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)
@@ -2445,13 +2446,13 @@ function Ot(t) {
2445
2446
  const e = t.filter((n) => n.type === "relation").map((n) => n.name);
2446
2447
  return e.length > 0 ? e.join(",") : void 0;
2447
2448
  }
2448
- function Lt(t) {
2449
+ function Nt(t) {
2449
2450
  const e = /* @__PURE__ */ new Set(), n = [];
2450
- for (const r of t)
2451
- r.type === "relation" && (e.has(r.relatedModel.tableName) || (e.add(r.relatedModel.tableName), n.push(r.relatedModel)));
2451
+ for (const a of t)
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 Tn(t) {
2455
+ function Dn(t) {
2455
2456
  const e = {
2456
2457
  name: t.name,
2457
2458
  type: t.type,
@@ -2475,7 +2476,7 @@ function Tn(t) {
2475
2476
  } : e;
2476
2477
  }
2477
2478
  function qt(t, e, n) {
2478
- const r = n ? {
2479
+ const a = n ? {
2479
2480
  listRule: n.rule,
2480
2481
  viewRule: n.rule,
2481
2482
  createRule: n.rule,
@@ -2485,11 +2486,11 @@ function qt(t, e, n) {
2485
2486
  return {
2486
2487
  name: t.tableName,
2487
2488
  type: "base",
2488
- ...r,
2489
- fields: e.map(Tn)
2489
+ ...a,
2490
+ fields: e.map(Dn)
2490
2491
  };
2491
2492
  }
2492
- function An(t) {
2493
+ function Tn(t) {
2493
2494
  const [e, ...n] = t;
2494
2495
  if (!e)
2495
2496
  throw new Error(
@@ -2497,65 +2498,66 @@ function An(t) {
2497
2498
  );
2498
2499
  return { modelPath: e, fields: n };
2499
2500
  }
2500
- function jn(t, e) {
2501
+ function Ln(t, e) {
2501
2502
  return {
2502
2503
  path: t,
2503
- language: P(t),
2504
+ language: C(t),
2504
2505
  content: e
2505
2506
  };
2506
2507
  }
2507
- async function Nn(t, e, n) {
2508
- Z(e);
2509
- const r = z(e, t);
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 K(n, r, t);
2512
- return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
2512
+ const i = await X(n, a, t);
2513
+ return { model: a, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
2513
2514
  }
2514
- const a = t.env === "runtime" ? await (await import("./env.runtime-BTggk_Vb.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = lt(r, a, t);
2515
- return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
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);
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 } = An(t.argv), { model: r, fields: a, auth: s, shouldCreateCollection: i } = await Nn(
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
2522
- ), o = `src/lib/schemas/${r.name}.ts`, c = it(r, a, {
2523
+ ), o = `src/lib/schemas/${a.name}.ts`, c = it(a, r, {
2523
2524
  includeModelFields: !0,
2524
2525
  forForm: !0
2525
2526
  });
2526
2527
  return {
2527
- creates: [jn(o, c)],
2528
+ creates: [Ln(o, c)],
2528
2529
  modifies: [],
2529
2530
  deletes: [],
2530
2531
  components: [],
2531
2532
  packages: [],
2532
- collections: i ? [qt(r, a, s)] : []
2533
+ collections: i ? [qt(a, r, s)] : []
2533
2534
  };
2534
2535
  }
2535
- const Ln = "generate-resource", qn = "1.0.7", Vn = "src/patterns/generate/resource", Un = "/generate/resource";
2536
- async function Hn(t) {
2536
+ const Nn = "generate-resource", qn = "1.0.7", Un = "src/patterns/generate/resource", Vn = "/generate/resource";
2537
+ async function Kn(t) {
2537
2538
  const e = await On(t);
2538
2539
  if (t.env !== "runtime")
2539
- return S(e);
2540
- const { createCollections: n } = await import("./collections-t61Ot2Ax.js"), r = await n(
2540
+ return F(e);
2541
+ const { createCollections: n } = await import("./collections-BQ2vnlIE.js"), a = await n(
2541
2542
  e.collections,
2542
2543
  t
2543
- ), a = {
2544
+ ), r = {
2544
2545
  ...e,
2545
- creates: [...e.creates, ...r]
2546
+ creates: [...e.creates, ...a]
2546
2547
  }, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
2547
- return s(await S(a), t);
2548
+ return s(await F(r), t);
2548
2549
  }
2549
- const Gn = {
2550
+ const Hn = {
2550
2551
  version: qn,
2551
- slug: Ln,
2552
- source: Vn,
2553
- docs: Un,
2552
+ slug: Nn,
2553
+ source: Un,
2554
+ docs: Vn,
2554
2555
  plan: "open",
2555
2556
  title: "Generate a resource",
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,26 +2568,26 @@ const Gn = {
2566
2568
  argv: ["contact", "name:text", "email:email"]
2567
2569
  },
2568
2570
  baseline: "velastack",
2569
- generate: Hn
2571
+ generate: Kn
2570
2572
  };
2571
- var _t = Object.freeze, Wn = Object.defineProperty, X = (t, e) => _t(Wn(t, "raw", { value: _t(e || t.slice()) })), kt, Rt, Pt, Et;
2572
- function Jn(t) {
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 _(t, e) {
2580
+ function k(t, e) {
2579
2581
  return {
2580
2582
  path: t,
2581
- language: P(t),
2583
+ language: C(t),
2582
2584
  content: e
2583
2585
  };
2584
2586
  }
2585
- function Vt(t) {
2587
+ function Ut(t) {
2586
2588
  return t.some((e) => e.type === "file");
2587
2589
  }
2588
- function Ut(t) {
2590
+ function Vt(t) {
2589
2591
  return [...new Set(t.filter(Boolean))];
2590
2592
  }
2591
2593
  function ct(t) {
@@ -2595,22 +2597,22 @@ function ct(t) {
2595
2597
 
2596
2598
  `);
2597
2599
  }
2598
- function Ht(t, e) {
2599
- return Lt(t).map(
2600
+ function Kt(t, e) {
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 Gt(t) {
2605
- return Lt(t).map((e) => e.pluralName).join(", ");
2606
+ function Ht(t) {
2607
+ return Nt(t).map((e) => e.pluralName).join(", ");
2606
2608
  }
2607
- function Zn(t) {
2609
+ function Jn(t) {
2608
2610
  return t.features.auth ? "locals.pb" : "locals.admin";
2609
2611
  }
2610
- function Wt(t, e, n = !1) {
2611
- const r = ct(e);
2612
- return d`
2613
- ${r}
2612
+ function Gt(t, e, n = !1) {
2613
+ const a = ct(e);
2614
+ return u`
2615
+ ${a}
2614
2616
  ${n ? "let { data, params } = $props();" : "let { data } = $props();"}
2615
2617
 
2616
2618
  const form = superForm(untrack(() => data.form), {
@@ -2620,21 +2622,21 @@ function Wt(t, e, n = !1) {
2620
2622
  const { form: formData } = form;
2621
2623
  `;
2622
2624
  }
2623
- function Kn(t, e, n) {
2624
- const r = n.some((o) => o.type === "select"), a = Ut([
2625
+ function Xn(t, e, n) {
2626
+ const a = n.some((o) => o.type === "select"), r = Vt([
2625
2627
  'import { untrack } from "svelte";',
2626
2628
  'import { superForm } from "sveltekit-superforms";',
2627
2629
  'import { zodClient } from "sveltekit-superforms/adapters";',
2628
2630
  `import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
2629
- ...at(L(n)),
2631
+ ...rt(U(n)),
2630
2632
  'import { Button } from "$lib/components/ui/button";',
2631
2633
  'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
2632
2634
  'import * as Form from "$lib/components/ui/form";',
2633
- r ? 'import type { Models } from "pocketbase-svelte";' : ""
2635
+ a ? 'import type { Models } from "pocketbase-svelte";' : ""
2634
2636
  ]).join(`
2635
- `), s = n.map((o) => rt(o)).join(`
2636
- `), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
2637
- return d(kt || (kt = X([`
2637
+ `), s = n.map((o) => at(o)).join(`
2638
+ `), i = Ut(n) ? ' enctype="multipart/form-data"' : "";
2639
+ return u(kt || (kt = Z([`
2638
2640
  <script lang="ts">
2639
2641
  `, `
2640
2642
  `, `
@@ -2661,23 +2663,23 @@ function Kn(t, e, n) {
2661
2663
  </form>
2662
2664
  </div>
2663
2665
  </section>
2664
- `])), a, Wt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
2666
+ `])), r, Gt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
2665
2667
  }
2666
- function Xn(t, e, n) {
2667
- const r = n.some((o) => o.type === "select"), a = Ut([
2668
+ function Zn(t, e, n) {
2669
+ const a = n.some((o) => o.type === "select"), r = Vt([
2668
2670
  'import { untrack } from "svelte";',
2669
2671
  'import { superForm } from "sveltekit-superforms";',
2670
2672
  'import { zodClient } from "sveltekit-superforms/adapters";',
2671
2673
  `import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
2672
- ...at(L(n)),
2674
+ ...rt(U(n)),
2673
2675
  'import { Button } from "$lib/components/ui/button";',
2674
2676
  'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
2675
2677
  'import * as Form from "$lib/components/ui/form";',
2676
- r ? 'import type { Models } from "pocketbase-svelte";' : ""
2678
+ a ? 'import type { Models } from "pocketbase-svelte";' : ""
2677
2679
  ]).join(`
2678
- `), s = n.map((o) => rt(o)).join(`
2679
- `), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
2680
- return d(Rt || (Rt = X([`
2680
+ `), s = n.map((o) => at(o)).join(`
2681
+ `), i = Ut(n) ? ' enctype="multipart/form-data"' : "";
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
- `])), a, Wt(t, n, !0), t.displayName.toLowerCase(), e.list, i, s, e.list);
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
- const r = n.some((o) => o.type === "select"), a = r ? `${ct(n)}` : "", s = n.map((o) => {
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 }"), d`
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 d(Pt || (Pt = X([`
2752
+ return u(Pt || (Pt = Z([`
2751
2753
  <script lang="ts">
2752
2754
  import {
2753
2755
  type ColumnFiltersState,
@@ -3121,27 +3123,27 @@ function Yn(t, e, n) {
3121
3123
  <Pagination {table} />
3122
3124
  </div>
3123
3125
  </section>
3124
- `])), r ? 'import { FacetedFilter } from "$lib/components/ui/faceted-filter";' : "", a, t.tableName, s, n.length > 0 ? "," : "", e.list, e.list, e.list, t.pluralName, t.pluralDisplayName, e.new, t.displayName.toLowerCase(), t.pluralDisplayName.toLowerCase(), i, e.new, t.displayName.toLowerCase());
3126
+ `])), a ? 'import { FacetedFilter } from "$lib/components/ui/faceted-filter";' : "", r, t.tableName, s, n.length > 0 ? "," : "", e.list, e.list, e.list, t.pluralName, t.pluralDisplayName, e.new, t.displayName.toLowerCase(), t.pluralDisplayName.toLowerCase(), i, e.new, t.displayName.toLowerCase());
3125
3127
  }
3126
3128
  function Qn(t, e, n) {
3127
- const r = Ot(e), a = r ? `{ expand: "${r}" }` : "";
3128
- return d`
3129
+ const a = Ot(e), r = a ? `{ expand: "${a}" }` : "";
3130
+ return u`
3129
3131
  export const load = async ({ locals }) => {
3130
- const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${a});
3132
+ const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${r});
3131
3133
  return { ${t.pluralName} };
3132
3134
  };
3133
3135
  `;
3134
3136
  }
3135
- function tr(t, e, n, r, a) {
3136
- const s = Ht(n, r), i = Gt(n), o = i ? `, ${i}` : "", c = n.find(
3137
+ function ta(t, e, n, a, r) {
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 = a && c ? d`
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 d`
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";
@@ -3162,7 +3164,7 @@ function tr(t, e, n, r, a) {
3162
3164
  }
3163
3165
 
3164
3166
  try {
3165
- const ${t.name} = await ${r}.collection("${t.tableName}").create(
3167
+ const ${t.name} = await ${a}.collection("${t.tableName}").create(
3166
3168
  ${m}
3167
3169
  );
3168
3170
  return redirect(303, \`${e.list}/\${${t.name}.id}\`);
@@ -3174,14 +3176,14 @@ function tr(t, e, n, r, a) {
3174
3176
  };
3175
3177
  `;
3176
3178
  }
3177
- function er(t, e, n, r) {
3178
- const a = Ot(n), s = a ? `, { expand: "${a}" }` : "";
3179
- return d`
3179
+ function ea(t, e, n, a) {
3180
+ const r = Ot(n), s = r ? `, { expand: "${r}" }` : "";
3181
+ return u`
3180
3182
  import { error, redirect } from "@sveltejs/kit";
3181
3183
 
3182
3184
  export const load = async ({ locals, params }) => {
3183
3185
  try {
3184
- const ${t.name} = await ${r}.collection("${t.tableName}").getOne(params.id${s});
3186
+ const ${t.name} = await ${a}.collection("${t.tableName}").getOne(params.id${s});
3185
3187
  return { ${t.name} };
3186
3188
  } catch {
3187
3189
  throw error(404, "Not found");
@@ -3190,23 +3192,23 @@ function er(t, e, n, r) {
3190
3192
 
3191
3193
  export const actions = {
3192
3194
  default: async ({ locals, params }) => {
3193
- await ${r}.collection("${t.tableName}").delete(params.id);
3195
+ await ${a}.collection("${t.tableName}").delete(params.id);
3194
3196
  throw redirect(303, "${e.list}");
3195
3197
  },
3196
3198
  };
3197
3199
  `;
3198
3200
  }
3199
- function nr(t, e, n) {
3200
- const r = n.some((m) => m.type === "select"), a = n.some((m) => m.type === "relation"), s = n.some((m) => m.type === "file"), i = [
3201
+ function na(t, e, n) {
3202
+ const a = n.some((m) => m.type === "select"), r = n.some((m) => m.type === "relation"), s = n.some((m) => m.type === "file"), i = [
3201
3203
  'import { Button } from "$lib/components/ui/button";',
3202
3204
  'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
3203
- r || a ? 'import { Badge } from "$lib/components/ui/badge";' : "",
3204
- a ? 'import CircleArrowRightIcon from "@lucide/svelte/icons/circle-arrow-right";' : "",
3205
+ a || r ? 'import { Badge } from "$lib/components/ui/badge";' : "",
3206
+ r ? 'import CircleArrowRightIcon from "@lucide/svelte/icons/circle-arrow-right";' : "",
3205
3207
  s ? 'import FileIcon from "@lucide/svelte/icons/file";' : ""
3206
3208
  ].filter(Boolean).join(`
3207
3209
  `), o = ct(n), c = n.map((m) => Ce(t, m)).join(`
3208
3210
  `);
3209
- return d(Et || (Et = X([`
3211
+ return u(Et || (Et = Z([`
3210
3212
  <script lang="ts">
3211
3213
  `, `
3212
3214
  `, `
@@ -3240,9 +3242,9 @@ function nr(t, e, n) {
3240
3242
  </section>
3241
3243
  `])), i, o, t.displayName, e.list, c, e.list, t.name);
3242
3244
  }
3243
- function rr(t, e, n, r) {
3244
- const a = Ht(n, r), s = Gt(n), i = s ? `, ${s}` : "";
3245
- return d`
3245
+ function aa(t, e, n, a) {
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";
@@ -3252,17 +3254,17 @@ function rr(t, e, n, r) {
3252
3254
  export const load = async ({ locals, params }) => {
3253
3255
  let ${t.name};
3254
3256
  try {
3255
- ${t.name} = await ${r}.collection("${t.tableName}").getOne(params.id);
3257
+ ${t.name} = await ${a}.collection("${t.tableName}").getOne(params.id);
3256
3258
  } catch {
3257
3259
  throw error(404, "Not found");
3258
3260
  }
3259
- ${a}
3261
+ ${r}
3260
3262
  return { form: await superValidate(${t.name}, zod(${t.schemaName}))${i} };
3261
3263
  };
3262
3264
 
3263
3265
  export const actions = {
3264
3266
  default: async ({ locals, params, request }) => {
3265
- const ${t.name} = await ${r}.collection("${t.tableName}").getOne(params.id);
3267
+ const ${t.name} = await ${a}.collection("${t.tableName}").getOne(params.id);
3266
3268
  const form = await superValidate(request, zod(${t.schemaName}));
3267
3269
 
3268
3270
  if (!form.valid) {
@@ -3271,7 +3273,7 @@ function rr(t, e, n, r) {
3271
3273
  }
3272
3274
 
3273
3275
  try {
3274
- await ${r}.collection("${t.tableName}").update(params.id, form.data);
3276
+ await ${a}.collection("${t.tableName}").update(params.id, form.data);
3275
3277
  return redirect(303, \`${e.list}/\${params.id}\`);
3276
3278
  } catch (error) {
3277
3279
  setPocketbaseErrors(form, error);
@@ -3282,82 +3284,82 @@ function rr(t, e, n, r) {
3282
3284
  };
3283
3285
  `;
3284
3286
  }
3285
- async function ar(t, e, n) {
3286
- Z(e);
3287
- const r = z(e, t), a = t.env === "runtime" ? await (await import("./env.runtime-BTggk_Vb.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
3287
+ async function ra(t, e, n) {
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 K(n, r, t);
3293
+ const i = await X(n, a, t);
3292
3294
  return {
3293
- model: r,
3295
+ model: a,
3294
3296
  fields: i.fields,
3295
3297
  auth: i.auth,
3296
3298
  shouldCreateCollection: !0,
3297
- collections: a
3299
+ collections: r
3298
3300
  };
3299
3301
  }
3300
- const s = lt(r, a, t);
3302
+ const s = lt(a, r, t);
3301
3303
  return {
3302
- model: r,
3304
+ model: a,
3303
3305
  fields: s,
3304
3306
  auth: void 0,
3305
3307
  shouldCreateCollection: !1,
3306
- collections: a
3308
+ collections: r
3307
3309
  };
3308
3310
  }
3309
- async function or(t) {
3310
- const { modelPath: e, fields: n } = Jn(t.argv), { model: r, fields: a, auth: s, shouldCreateCollection: i, collections: o } = await ar(t, e, n), c = Ue(r), m = He(r), g = Zn(t), f = a.filter(
3311
- (u) => !(u.type === "relation" && u.isCurrentUser)
3311
+ async function oa(t) {
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
- _(
3314
- `src/lib/schemas/${r.name}.ts`,
3315
- it(r, a, {
3315
+ k(
3316
+ `src/lib/schemas/${a.name}.ts`,
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
- Qn(r, f, g)
3324
+ Qn(a, f, g)
3323
3325
  ),
3324
- _(
3326
+ k(
3325
3327
  `${c.list}/+page.svelte`,
3326
- Yn(r, m, f)
3328
+ Yn(a, m, f)
3327
3329
  ),
3328
- _(
3330
+ k(
3329
3331
  `${c.new}/+page.server.ts`,
3330
- tr(r, m, f, g, t.features.auth)
3332
+ ta(a, m, f, g, t.features.auth)
3331
3333
  ),
3332
- _(`${c.new}/+page.svelte`, Kn(r, m, f)),
3333
- _(
3334
+ k(`${c.new}/+page.svelte`, Xn(a, m, f)),
3335
+ k(
3334
3336
  `${c.show}/+page.server.ts`,
3335
- er(r, m, f, g)
3337
+ ea(a, m, f, g)
3336
3338
  ),
3337
- _(
3339
+ k(
3338
3340
  `${c.show}/+page.svelte`,
3339
- nr(r, m, f)
3341
+ na(a, m, f)
3340
3342
  ),
3341
- _(
3343
+ k(
3342
3344
  `${c.edit}/+page.server.ts`,
3343
- rr(r, m, f, g)
3345
+ aa(a, m, f, g)
3344
3346
  ),
3345
- _(
3347
+ k(
3346
3348
  `${c.edit}/+page.svelte`,
3347
- Xn(r, m, f)
3349
+ Zn(a, m, f)
3348
3350
  ),
3349
- _(
3351
+ k(
3350
3352
  `${c.list}/server.test.ts`,
3351
- un(
3352
- r,
3353
- m,
3353
+ pn(
3354
3354
  a,
3355
+ m,
3356
+ r,
3355
3357
  t,
3356
3358
  o
3357
3359
  )
3358
3360
  )
3359
3361
  ], $ = [
3360
- ...L(f),
3362
+ ...U(f),
3361
3363
  "button",
3362
3364
  "table",
3363
3365
  "data-table",
@@ -3380,33 +3382,34 @@ async function or(t) {
3380
3382
  deletes: [],
3381
3383
  components: [...new Set($)],
3382
3384
  packages: ["@tanstack/table-core"],
3383
- collections: i ? [qt(r, a, s)] : []
3385
+ collections: i ? [qt(a, r, s)] : []
3384
3386
  };
3385
3387
  }
3386
- const sr = "generate-scaffold", ir = "1.0.7", lr = "src/patterns/generate/scaffold", cr = "/generate/scaffold";
3387
- async function mr(t) {
3388
- const e = await or(t);
3388
+ const sa = "generate-scaffold", ia = "1.0.7", la = "src/patterns/generate/scaffold", ca = "/generate/scaffold";
3389
+ async function ma(t) {
3390
+ const e = await oa(t);
3389
3391
  if (t.env !== "runtime")
3390
- return S(e);
3391
- const { createCollections: n } = await import("./collections-t61Ot2Ax.js"), r = await n(
3392
+ return F(e);
3393
+ const { createCollections: n } = await import("./collections-BQ2vnlIE.js"), a = await n(
3392
3394
  e.collections,
3393
3395
  t
3394
- ), a = {
3396
+ ), r = {
3395
3397
  ...e,
3396
- creates: [...e.creates, ...r]
3398
+ creates: [...e.creates, ...a]
3397
3399
  }, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
3398
- return s(await S(a), t);
3400
+ return s(await F(r), t);
3399
3401
  }
3400
- const ur = {
3401
- version: ir,
3402
- slug: sr,
3403
- source: lr,
3404
- docs: cr,
3402
+ const pa = {
3403
+ version: ia,
3404
+ slug: sa,
3405
+ source: la,
3406
+ docs: ca,
3405
3407
  plan: "open",
3406
3408
  title: "Generate a scaffold",
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",
@@ -3417,9 +3420,9 @@ const ur = {
3417
3420
  argv: ["contact", "name:text", "email:email"]
3418
3421
  },
3419
3422
  baseline: "velastack",
3420
- generate: mr
3423
+ generate: ma
3421
3424
  };
3422
- function dr(t) {
3425
+ function ua(t) {
3423
3426
  const [e, ...n] = t;
3424
3427
  if (!e)
3425
3428
  throw new Error(
@@ -3427,34 +3430,34 @@ function dr(t) {
3427
3430
  );
3428
3431
  return { modelPath: e, fields: n };
3429
3432
  }
3430
- function pr(t, e) {
3433
+ function da(t, e) {
3431
3434
  return {
3432
3435
  path: t,
3433
- language: P(t),
3436
+ language: C(t),
3434
3437
  content: e
3435
3438
  };
3436
3439
  }
3437
- async function fr(t, e, n) {
3438
- Z(e);
3439
- const r = z(e, t);
3440
+ async function fa(t, e, n) {
3441
+ J(e);
3442
+ const a = A(e, t);
3440
3443
  if (n.length > 0) {
3441
- const i = await K(n, r, t);
3442
- return { model: r, fields: i.fields, includeModelFields: !1 };
3444
+ const i = await X(n, a, t);
3445
+ return { model: a, fields: i.fields, includeModelFields: !1 };
3443
3446
  }
3444
- const a = t.env === "runtime" ? await (await import("./env.runtime-BTggk_Vb.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = lt(r, a, t);
3445
- return { model: r, fields: s, includeModelFields: !0 };
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);
3448
+ return { model: a, fields: s, includeModelFields: !0 };
3446
3449
  }
3447
- async function gr(t) {
3448
- const { modelPath: e, fields: n } = dr(t.argv), { model: r, fields: a, includeModelFields: s } = await fr(
3450
+ async function ga(t) {
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
3452
- ), i = `src/lib/schemas/${r.name}.ts`, o = it(r, a, {
3455
+ ), i = `src/lib/schemas/${a.name}.ts`, o = it(a, r, {
3453
3456
  includeModelFields: s,
3454
3457
  forForm: !0
3455
3458
  });
3456
3459
  return {
3457
- creates: [pr(i, o)],
3460
+ creates: [da(i, o)],
3458
3461
  modifies: [],
3459
3462
  deletes: [],
3460
3463
  components: [],
@@ -3462,24 +3465,25 @@ async function gr(t) {
3462
3465
  collections: []
3463
3466
  };
3464
3467
  }
3465
- const hr = "generate-schema", br = "1.0.7", vr = "src/patterns/generate/schema", wr = "/generate/schema";
3466
- async function yr(t) {
3467
- const e = await gr(t);
3468
+ const ha = "generate-schema", ba = "1.0.7", va = "src/patterns/generate/schema", ya = "/generate/schema";
3469
+ async function wa(t) {
3470
+ const e = await ga(t);
3468
3471
  if (t.env !== "runtime")
3469
- return S(e);
3472
+ return F(e);
3470
3473
  const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
3471
- return n(await S(e), t);
3474
+ return n(await F(e), t);
3472
3475
  }
3473
- const $r = {
3474
- version: br,
3475
- slug: hr,
3476
- source: vr,
3477
- docs: wr,
3476
+ const $a = {
3477
+ version: ba,
3478
+ slug: ha,
3479
+ source: va,
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,8 +3494,8 @@ const $r = {
3490
3494
  argv: ["contact", "name:text", "email:email"]
3491
3495
  },
3492
3496
  baseline: "velastack",
3493
- generate: yr
3494
- }, xr = `<script lang="ts">
3497
+ generate: wa
3498
+ }, xa = `<script lang="ts">
3495
3499
  import type { ComponentProps } from 'svelte';
3496
3500
  import HomeIcon from '@lucide/svelte/icons/home';
3497
3501
  import * as Sidebar from '$lib/components/ui/sidebar';
@@ -3544,7 +3548,7 @@ const $r = {
3544
3548
  <NavUser {user} />
3545
3549
  </Sidebar.Footer>
3546
3550
  </Sidebar.Root>
3547
- `, Fr = `<script lang="ts">
3551
+ `, Fa = `<script lang="ts">
3548
3552
  import type { Component } from 'svelte';
3549
3553
  import * as Sidebar from '$lib/components/ui/sidebar';
3550
3554
  import { page } from '$app/state';
@@ -3584,7 +3588,7 @@ const $r = {
3584
3588
  {/each}
3585
3589
  </Sidebar.Menu>
3586
3590
  </Sidebar.Group>
3587
- `, Sr = `<script lang="ts">
3591
+ `, Sa = `<script lang="ts">
3588
3592
  import { toggleMode, mode } from 'mode-watcher';
3589
3593
  import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
3590
3594
  import Settings2Icon from '@lucide/svelte/icons/settings-2';
@@ -3700,12 +3704,12 @@ const $r = {
3700
3704
  </DropdownMenu.Root>
3701
3705
  </Sidebar.MenuItem>
3702
3706
  </Sidebar.Menu>
3703
- `, Cr = `import { z } from 'zod/v3';
3707
+ `, Ca = `import { z } from 'zod/v3';
3704
3708
 
3705
3709
  export const changeEmailSchema = z.object({
3706
3710
  email: z.string().email()
3707
3711
  });
3708
- `, _r = `import { z } from 'zod/v3';
3712
+ `, _a = `import { z } from 'zod/v3';
3709
3713
 
3710
3714
  export const changePasswordSchema = z
3711
3715
  .object({
@@ -3716,18 +3720,18 @@ export const changePasswordSchema = z
3716
3720
  message: "Passwords don't match",
3717
3721
  path: ['passwordConfirm']
3718
3722
  });
3719
- `, kr = `import { z } from 'zod/v3';
3723
+ `, ka = `import { z } from 'zod/v3';
3720
3724
 
3721
3725
  export const confirmEmailChangeSchema = z.object({
3722
3726
  password: z.string()
3723
3727
  });
3724
- `, Rr = `import { z } from 'zod/v3';
3728
+ `, Ra = `import { z } from 'zod/v3';
3725
3729
 
3726
3730
  export const confirmResetSchema = z.object({
3727
3731
  password: z.string(),
3728
3732
  passwordConfirm: z.string()
3729
3733
  });
3730
- `, Pr = `import { z } from 'zod/v3';
3734
+ `, Pa = `import { z } from 'zod/v3';
3731
3735
 
3732
3736
  const otpSchema = z.object({
3733
3737
  type: z.literal('otp'),
@@ -3746,37 +3750,37 @@ const oAuth2Schema = z.object({
3746
3750
  });
3747
3751
 
3748
3752
  export const loginSchema = z.discriminatedUnion('type', [otpSchema, passwordSchema, oAuth2Schema]);
3749
- `, Er = `import { z } from 'zod/v3';
3753
+ `, Ea = `import { z } from 'zod/v3';
3750
3754
 
3751
3755
  export const otpSchema = z.object({
3752
3756
  otp: z.string()
3753
3757
  });
3754
- `, Ir = `import { z } from 'zod/v3';
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
- `, zr = `import { z } from 'zod/v3';
3765
+ `, za = `import { z } from 'zod/v3';
3762
3766
 
3763
3767
  export const resetSchema = z.object({
3764
3768
  email: z.string().email()
3765
3769
  });
3766
- `, Mr = `import { z } from 'zod/v3';
3770
+ `, Ma = `import { z } from 'zod/v3';
3767
3771
 
3768
3772
  export const signupSchema = z.object({
3769
3773
  email: z.string().email(),
3770
3774
  password: z.string(),
3771
3775
  passwordConfirm: z.string()
3772
3776
  });
3773
- `, Br = `export const load = ({ locals }) => {
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
- `, Dr = `<script lang="ts">
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
- `, Tr = "", Ar = `import { describe, it, expect } from 'vitest';
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
- `, jr = `export const load = async ({ parent }) => {
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
- `, Nr = `import { superValidate, fail, withFiles } from 'sveltekit-superforms';
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';
@@ -3919,7 +3923,7 @@ export const actions = {
3919
3923
  return {};
3920
3924
  }
3921
3925
  };
3922
- `, Or = `<script lang="ts">
3926
+ `, Oa = `<script lang="ts">
3923
3927
  import { untrack } from 'svelte';
3924
3928
  import { superForm } from 'sveltekit-superforms';
3925
3929
  import { zodClient } from 'sveltekit-superforms/adapters';
@@ -4197,7 +4201,7 @@ export const actions = {
4197
4201
  </form>
4198
4202
  </div>
4199
4203
  </div>
4200
- `, Lr = `import { fail, superValidate } from 'sveltekit-superforms';
4204
+ `, Na = `import { fail, superValidate } from 'sveltekit-superforms';
4201
4205
  import { zod } from 'sveltekit-superforms/adapters';
4202
4206
  import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';
4203
4207
  import { redirect } from '@sveltejs/kit';
@@ -4224,7 +4228,7 @@ export const actions = {
4224
4228
  return redirect(303, '/login');
4225
4229
  }
4226
4230
  };
4227
- `, qr = `<script lang="ts">
4231
+ `, qa = `<script lang="ts">
4228
4232
  import { untrack } from 'svelte';
4229
4233
  import { Button } from '$lib/components/ui/button';
4230
4234
  import * as Card from '$lib/components/ui/card';
@@ -4292,7 +4296,7 @@ export const actions = {
4292
4296
  </div>
4293
4297
  </div>
4294
4298
  </div>
4295
- `, Vr = `import { describe, it, expect } from 'vitest';
4299
+ `, Ua = `import { describe, it, expect } from 'vitest';
4296
4300
  import type { Match } from '@velastack/pocketbase';
4297
4301
  import type { RouteId } from './$types';
4298
4302
 
@@ -4304,7 +4308,7 @@ describe('GET /confirm-email-change/[token]', () => {
4304
4308
  expect(response.status).toBe(200);
4305
4309
  });
4306
4310
  });
4307
- `, Ur = `import { fail, superValidate } from 'sveltekit-superforms';
4311
+ `, Va = `import { fail, superValidate } from 'sveltekit-superforms';
4308
4312
  import { zod } from 'sveltekit-superforms/adapters';
4309
4313
  import { confirmResetSchema } from '$lib/schemas/confirmReset';
4310
4314
  import { redirect } from '@sveltejs/kit';
@@ -4333,7 +4337,7 @@ export const actions = {
4333
4337
  return redirect(303, '/login');
4334
4338
  }
4335
4339
  };
4336
- `, Hr = `<script lang="ts">
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
- `, Gr = `import { describe, it, expect } from 'vitest';
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
- `, Wr = `import { redirect } from '@sveltejs/kit';
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
- `, Jr = `import { describe, it, expect } from 'vitest';
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
- `, Zr = `import { fail, superValidate, message } from 'sveltekit-superforms';
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
- `, Kr = `<script lang="ts">
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
- `, Xr = `import { describe, it, expect } from 'vitest';
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';
@@ -4750,14 +4754,14 @@ describe('POST /login', () => {
4750
4754
  expect(data.form.message.text).toBe('Failed to authenticate.');
4751
4755
  });
4752
4756
  });
4753
- `, Yr = `import { redirect } from '@sveltejs/kit';
4757
+ `, Ya = `import { redirect } from '@sveltejs/kit';
4754
4758
 
4755
4759
  export const POST = ({ cookies, locals }) => {
4756
4760
  locals.pb.authStore.clear();
4757
4761
  locals.pb.authStore.clearCookie(cookies);
4758
4762
  throw redirect(303, '/');
4759
4763
  };
4760
- `, Qr = `import { describe, it, expect } from 'vitest';
4764
+ `, Qa = `import { describe, it, expect } from 'vitest';
4761
4765
  import type { Match } from '@velastack/pocketbase';
4762
4766
  import type { RouteId } from './$types';
4763
4767
 
@@ -4769,7 +4773,7 @@ describe('POST /logout', () => {
4769
4773
  expect(response.headers.location).toBe('/');
4770
4774
  });
4771
4775
  });
4772
- `, ta = `import { fail, message, superValidate } from 'sveltekit-superforms';
4776
+ `, tr = `import { fail, message, superValidate } from 'sveltekit-superforms';
4773
4777
  import { zod } from 'sveltekit-superforms/adapters';
4774
4778
  import { otpSchema } from '$lib/schemas/otp';
4775
4779
  import { redirect } from '@sveltejs/kit';
@@ -4810,7 +4814,7 @@ export const actions = {
4810
4814
  redirect(303, redirectUrl);
4811
4815
  }
4812
4816
  };
4813
- `, ea = `<script lang="ts">
4817
+ `, er = `<script lang="ts">
4814
4818
  import { untrack } from 'svelte';
4815
4819
  import { Button } from '$lib/components/ui/button';
4816
4820
  import * as Card from '$lib/components/ui/card';
@@ -4876,7 +4880,7 @@ export const actions = {
4876
4880
  </div>
4877
4881
  </div>
4878
4882
  </div>
4879
- `, na = `import { describe, it, expect } from 'vitest';
4883
+ `, nr = `import { describe, it, expect } from 'vitest';
4880
4884
  import type { Match } from '@velastack/pocketbase';
4881
4885
  import type { RouteId } from './$types';
4882
4886
 
@@ -4896,7 +4900,7 @@ describe('POST /otp/[token]', () => {
4896
4900
  expect(response.body.status).toBe(400);
4897
4901
  });
4898
4902
  });
4899
- `, ra = `import { fail, superValidate } from 'sveltekit-superforms';
4903
+ `, ar = `import { fail, superValidate } from 'sveltekit-superforms';
4900
4904
  import { zod } from 'sveltekit-superforms/adapters';
4901
4905
  import { resetSchema } from '$lib/schemas/reset';
4902
4906
  import { redirect } from '@sveltejs/kit';
@@ -4924,7 +4928,7 @@ export const actions = {
4924
4928
  return { form };
4925
4929
  }
4926
4930
  };
4927
- `, aa = `<script lang="ts">
4931
+ `, rr = `<script lang="ts">
4928
4932
  import { untrack } from 'svelte';
4929
4933
  import { Button } from '$lib/components/ui/button';
4930
4934
  import * as Card from '$lib/components/ui/card';
@@ -4991,7 +4995,7 @@ export const actions = {
4991
4995
  </div>
4992
4996
  </div>
4993
4997
  </div>
4994
- `, oa = `import { describe, it, expect } from 'vitest';
4998
+ `, or = `import { describe, it, expect } from 'vitest';
4995
4999
  import type { Match } from '@velastack/pocketbase';
4996
5000
  import type { RouteId } from './$types';
4997
5001
 
@@ -5011,7 +5015,7 @@ describe('POST /reset', () => {
5011
5015
  expect(response.body.status).toBe(200);
5012
5016
  });
5013
5017
  });
5014
- `, sa = `import { redirect } from '@sveltejs/kit';
5018
+ `, sr = `import { redirect } from '@sveltejs/kit';
5015
5019
  import { fail, superValidate } from 'sveltekit-superforms';
5016
5020
  import { zod } from 'sveltekit-superforms/adapters';
5017
5021
  import { setFlash } from 'sveltekit-flash-message/server';
@@ -5067,7 +5071,7 @@ export const actions = {
5067
5071
  return redirect(303, redirectUrl);
5068
5072
  }
5069
5073
  };
5070
- `, ia = `<script lang="ts">
5074
+ `, ir = `<script lang="ts">
5071
5075
  import { untrack } from 'svelte';
5072
5076
  import { Button } from '$lib/components/ui/button';
5073
5077
  import * as Card from '$lib/components/ui/card';
@@ -5234,7 +5238,7 @@ export const actions = {
5234
5238
  </div>
5235
5239
  </div>
5236
5240
  </div>
5237
- `, la = `import { describe, it, expect } from 'vitest';
5241
+ `, lr = `import { describe, it, expect } from 'vitest';
5238
5242
  import type { Match } from '@velastack/pocketbase';
5239
5243
  import * as devalue from 'devalue';
5240
5244
  import type { RouteId } from './$types';
@@ -5290,58 +5294,58 @@ describe('POST /signup', () => {
5290
5294
  expect(data.form.errors.email[0]).toBe('Value must be unique.');
5291
5295
  });
5292
5296
  });
5293
- `, ca = /* @__PURE__ */ Object.assign({
5294
- "./creates/src/lib/components/app-sidebar.svelte": xr,
5295
- "./creates/src/lib/components/nav-main.svelte": Fr,
5296
- "./creates/src/lib/components/nav-user.svelte": Sr,
5297
- "./creates/src/lib/schemas/changeEmail.ts": Cr,
5298
- "./creates/src/lib/schemas/changePassword.ts": _r,
5299
- "./creates/src/lib/schemas/confirmEmailChange.ts": kr,
5300
- "./creates/src/lib/schemas/confirmReset.ts": Rr,
5301
- "./creates/src/lib/schemas/login.ts": Pr,
5302
- "./creates/src/lib/schemas/otp.ts": Er,
5303
- "./creates/src/lib/schemas/profile.ts": Ir,
5304
- "./creates/src/lib/schemas/reset.ts": zr,
5305
- "./creates/src/lib/schemas/signup.ts": Mr,
5306
- "./creates/src/routes/(app)/+layout.server.ts": Br,
5307
- "./creates/src/routes/(app)/+layout.svelte": Dr,
5308
- "./creates/src/routes/(app)/dashboard/+page.svelte": Tr,
5309
- "./creates/src/routes/(app)/dashboard/server.test.ts": Ar,
5310
- "./creates/src/routes/(app)/settings/+layout.server.ts": jr,
5311
- "./creates/src/routes/(app)/settings/+page.server.ts": Nr,
5312
- "./creates/src/routes/(app)/settings/+page.svelte": Or,
5313
- "./creates/src/routes/(public)/confirm-email-change/[token]/+page.server.ts": Lr,
5314
- "./creates/src/routes/(public)/confirm-email-change/[token]/+page.svelte": qr,
5315
- "./creates/src/routes/(public)/confirm-email-change/[token]/server.test.ts": Vr,
5316
- "./creates/src/routes/(public)/confirm-reset/[token]/+page.server.ts": Ur,
5317
- "./creates/src/routes/(public)/confirm-reset/[token]/+page.svelte": Hr,
5318
- "./creates/src/routes/(public)/confirm-reset/[token]/server.test.ts": Gr,
5319
- "./creates/src/routes/(public)/confirm-verification/[token]/+server.ts": Wr,
5320
- "./creates/src/routes/(public)/confirm-verification/[token]/server.test.ts": Jr,
5321
- "./creates/src/routes/(public)/login/+page.server.ts": Zr,
5322
- "./creates/src/routes/(public)/login/+page.svelte": Kr,
5323
- "./creates/src/routes/(public)/login/server.test.ts": Xr,
5324
- "./creates/src/routes/(public)/logout/+server.ts": Yr,
5325
- "./creates/src/routes/(public)/logout/server.test.ts": Qr,
5326
- "./creates/src/routes/(public)/otp/[token]/+page.server.ts": ta,
5327
- "./creates/src/routes/(public)/otp/[token]/+page.svelte": ea,
5328
- "./creates/src/routes/(public)/otp/[token]/server.test.ts": na,
5329
- "./creates/src/routes/(public)/reset/+page.server.ts": ra,
5330
- "./creates/src/routes/(public)/reset/+page.svelte": aa,
5331
- "./creates/src/routes/(public)/reset/server.test.ts": oa,
5332
- "./creates/src/routes/(public)/signup/+page.server.ts": sa,
5333
- "./creates/src/routes/(public)/signup/+page.svelte": ia,
5334
- "./creates/src/routes/(public)/signup/server.test.ts": la
5335
- }), ma = "./creates/";
5336
- async function ua(t) {
5337
- const e = Object.entries(ca).map(([a, s]) => {
5338
- const i = G(a, ma);
5297
+ `, cr = /* @__PURE__ */ Object.assign({
5298
+ "./creates/src/lib/components/app-sidebar.svelte": xa,
5299
+ "./creates/src/lib/components/nav-main.svelte": Fa,
5300
+ "./creates/src/lib/components/nav-user.svelte": Sa,
5301
+ "./creates/src/lib/schemas/changeEmail.ts": Ca,
5302
+ "./creates/src/lib/schemas/changePassword.ts": _a,
5303
+ "./creates/src/lib/schemas/confirmEmailChange.ts": ka,
5304
+ "./creates/src/lib/schemas/confirmReset.ts": Ra,
5305
+ "./creates/src/lib/schemas/login.ts": Pa,
5306
+ "./creates/src/lib/schemas/otp.ts": Ea,
5307
+ "./creates/src/lib/schemas/profile.ts": Ia,
5308
+ "./creates/src/lib/schemas/reset.ts": za,
5309
+ "./creates/src/lib/schemas/signup.ts": Ma,
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,
5313
+ "./creates/src/routes/(app)/dashboard/server.test.ts": Ta,
5314
+ "./creates/src/routes/(app)/settings/+layout.server.ts": La,
5315
+ "./creates/src/routes/(app)/settings/+page.server.ts": ja,
5316
+ "./creates/src/routes/(app)/settings/+page.svelte": Oa,
5317
+ "./creates/src/routes/(public)/confirm-email-change/[token]/+page.server.ts": Na,
5318
+ "./creates/src/routes/(public)/confirm-email-change/[token]/+page.svelte": qa,
5319
+ "./creates/src/routes/(public)/confirm-email-change/[token]/server.test.ts": Ua,
5320
+ "./creates/src/routes/(public)/confirm-reset/[token]/+page.server.ts": Va,
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,
5328
+ "./creates/src/routes/(public)/logout/+server.ts": Ya,
5329
+ "./creates/src/routes/(public)/logout/server.test.ts": Qa,
5330
+ "./creates/src/routes/(public)/otp/[token]/+page.server.ts": tr,
5331
+ "./creates/src/routes/(public)/otp/[token]/+page.svelte": er,
5332
+ "./creates/src/routes/(public)/otp/[token]/server.test.ts": nr,
5333
+ "./creates/src/routes/(public)/reset/+page.server.ts": ar,
5334
+ "./creates/src/routes/(public)/reset/+page.svelte": rr,
5335
+ "./creates/src/routes/(public)/reset/server.test.ts": or,
5336
+ "./creates/src/routes/(public)/signup/+page.server.ts": sr,
5337
+ "./creates/src/routes/(public)/signup/+page.svelte": ir,
5338
+ "./creates/src/routes/(public)/signup/server.test.ts": lr
5339
+ }), mr = "./creates/";
5340
+ async function pr(t) {
5341
+ const e = Object.entries(cr).map(([r, s]) => {
5342
+ const i = I(r, mr);
5339
5343
  return {
5340
5344
  path: i,
5341
- language: P(i),
5345
+ language: C(i),
5342
5346
  content: s
5343
5347
  };
5344
- }).sort((a, s) => a.path.localeCompare(s.path)), n = [
5348
+ }).sort((r, s) => r.path.localeCompare(s.path)), n = [
5345
5349
  "sidebar",
5346
5350
  "breadcrumb",
5347
5351
  "separator",
@@ -5426,7 +5430,7 @@ async function ua(t) {
5426
5430
  ]
5427
5431
  };
5428
5432
  }
5429
- const da = `import {
5433
+ const ur = `import {
5430
5434
  POCKETBASE_URL,
5431
5435
  POCKETBASE_SUPERUSER_EMAIL,
5432
5436
  POCKETBASE_SUPERUSER_PASSWORD,
@@ -5440,7 +5444,7 @@ export const handle = handlePocketbase({
5440
5444
  // [!code highlight:1]
5441
5445
  auth: { protectedRoutes: ["/(app)"] },
5442
5446
  });
5443
- `, pa = `<script lang="ts">
5447
+ `, dr = `<script lang="ts">
5444
5448
  import { toggleMode } from "mode-watcher";
5445
5449
  import * as Navbar from "$lib/components/ui/navbar";
5446
5450
  import { Button } from "$lib/components/ui/button";
@@ -5547,7 +5551,7 @@ export const handle = handlePocketbase({
5547
5551
  @apply container mx-auto max-w-7xl px-4 py-8 w-full;
5548
5552
  }
5549
5553
  </style>
5550
- `, fa = `import { loadFlash } from "sveltekit-flash-message/server";
5554
+ `, fr = `import { loadFlash } from "sveltekit-flash-message/server";
5551
5555
 
5552
5556
  export const load = loadFlash(async ({ locals }) => {
5553
5557
  return {
@@ -5555,20 +5559,20 @@ export const load = loadFlash(async ({ locals }) => {
5555
5559
  user: locals.pb.authStore.record,
5556
5560
  };
5557
5561
  });
5558
- `, ga = /* @__PURE__ */ Object.assign({
5559
- "./preview-modifies/src/hooks.server.ts": da,
5560
- "./preview-modifies/src/routes/(public)/root-layout.svelte": pa,
5561
- "./preview-modifies/src/routes/+layout.server.ts": fa
5562
- }), ha = "./preview-modifies/";
5563
- async function ba(t) {
5564
- const e = Object.entries(ga).map(([n, r]) => {
5565
- const a = G(n, ha);
5562
+ `, gr = /* @__PURE__ */ Object.assign({
5563
+ "./preview-modifies/src/hooks.server.ts": ur,
5564
+ "./preview-modifies/src/routes/(public)/root-layout.svelte": dr,
5565
+ "./preview-modifies/src/routes/+layout.server.ts": fr
5566
+ }), hr = "./preview-modifies/";
5567
+ async function br(t) {
5568
+ const e = Object.entries(gr).map(([n, a]) => {
5569
+ const r = I(n, hr);
5566
5570
  return {
5567
- path: a,
5568
- language: P(a),
5569
- content: r
5571
+ path: r,
5572
+ language: C(r),
5573
+ content: a
5570
5574
  };
5571
- }).sort((n, r) => n.path.localeCompare(r.path));
5575
+ }).sort((n, a) => n.path.localeCompare(a.path));
5572
5576
  return {
5573
5577
  creates: [],
5574
5578
  modifies: e,
@@ -5578,29 +5582,30 @@ async function ba(t) {
5578
5582
  collections: []
5579
5583
  };
5580
5584
  }
5581
- const va = "enable-auth", wa = "1.0.7", ya = "src/patterns/enable/auth", $a = "/enable/auth";
5582
- async function xa(t) {
5583
- const e = await ua(t);
5585
+ const vr = "enable-auth", yr = "1.0.7", wr = "src/patterns/enable/auth", $r = "/enable/auth";
5586
+ async function xr(t) {
5587
+ const e = await pr(t);
5584
5588
  if (t.env === "preview") {
5585
- const s = await ba();
5586
- return S(H([e, s]));
5589
+ const s = await br();
5590
+ return F(E([e, s]));
5587
5591
  }
5588
- const { generate: n } = await import("./generate.runtime-5EvPE9YS.js"), r = await n(t), { writeResult: a } = await import("./write-result-CbUTMeAc.js");
5589
- return a(
5590
- await S(H([e, r])),
5592
+ const { generate: n } = await import("./generate.runtime-CL_SU1wV.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
5593
+ return r(
5594
+ await F(E([e, a])),
5591
5595
  t
5592
5596
  );
5593
5597
  }
5594
- const Fa = {
5595
- version: wa,
5596
- slug: va,
5597
- source: ya,
5598
- docs: $a,
5598
+ const Fr = {
5599
+ version: yr,
5600
+ slug: vr,
5601
+ source: wr,
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",
@@ -5618,8 +5623,8 @@ const Fa = {
5618
5623
  argv: []
5619
5624
  },
5620
5625
  baseline: "velastack",
5621
- generate: xa
5622
- }, Sa = `import { describe, expect, it } from "vitest";
5626
+ generate: xr
5627
+ }, Sr = `import { describe, expect, it } from "vitest";
5623
5628
 
5624
5629
  describe("GET /api/health", () => {
5625
5630
  it("should return a 200 status code", async (context) => {
@@ -5627,19 +5632,19 @@ describe("GET /api/health", () => {
5627
5632
  expect(response.status).toBe(200);
5628
5633
  });
5629
5634
  });
5630
- `, Ca = /* @__PURE__ */ Object.assign({
5631
- "./creates/src/routes/api/server.test.ts": Sa
5632
- }), _a = "./creates/";
5633
- async function ka(t) {
5635
+ `, Cr = /* @__PURE__ */ Object.assign({
5636
+ "./creates/src/routes/api/server.test.ts": Sr
5637
+ }), _r = "./creates/";
5638
+ async function kr(t) {
5634
5639
  return {
5635
- creates: Object.entries(Ca).map(([n, r]) => {
5636
- const a = G(n, _a);
5640
+ creates: Object.entries(Cr).map(([n, a]) => {
5641
+ const r = I(n, _r);
5637
5642
  return {
5638
- path: a,
5639
- language: P(a),
5640
- content: r
5643
+ path: r,
5644
+ language: C(r),
5645
+ content: a
5641
5646
  };
5642
- }).sort((n, r) => n.path.localeCompare(r.path)),
5647
+ }).sort((n, a) => n.path.localeCompare(a.path)),
5643
5648
  modifies: [],
5644
5649
  deletes: [],
5645
5650
  components: [],
@@ -5647,7 +5652,7 @@ async function ka(t) {
5647
5652
  collections: []
5648
5653
  };
5649
5654
  }
5650
- const Ra = `import {
5655
+ const Rr = `import {
5651
5656
  POCKETBASE_URL,
5652
5657
  POCKETBASE_SUPERUSER_EMAIL,
5653
5658
  POCKETBASE_SUPERUSER_PASSWORD,
@@ -5661,18 +5666,18 @@ export const handle = handlePocketbase({
5661
5666
  // [!code highlight:1]
5662
5667
  api: { enabled: true },
5663
5668
  });
5664
- `, Pa = /* @__PURE__ */ Object.assign({
5665
- "./preview-modifies/src/hooks.server.ts": Ra
5666
- }), Ea = "./preview-modifies/";
5667
- async function Ia(t) {
5668
- const e = Object.entries(Pa).map(([n, r]) => {
5669
- const a = G(n, Ea);
5669
+ `, Pr = /* @__PURE__ */ Object.assign({
5670
+ "./preview-modifies/src/hooks.server.ts": Rr
5671
+ }), Er = "./preview-modifies/";
5672
+ async function Ir(t) {
5673
+ const e = Object.entries(Pr).map(([n, a]) => {
5674
+ const r = I(n, Er);
5670
5675
  return {
5671
- path: a,
5672
- language: P(a),
5673
- content: r
5676
+ path: r,
5677
+ language: C(r),
5678
+ content: a
5674
5679
  };
5675
- }).sort((n, r) => n.path.localeCompare(r.path));
5680
+ }).sort((n, a) => n.path.localeCompare(a.path));
5676
5681
  return {
5677
5682
  creates: [],
5678
5683
  modifies: e,
@@ -5682,29 +5687,30 @@ async function Ia(t) {
5682
5687
  collections: []
5683
5688
  };
5684
5689
  }
5685
- const za = "enable-api", Ma = "1.0.7", Ba = "src/patterns/enable/api", Da = "/enable/api";
5686
- async function Ta(t) {
5687
- const e = await ka();
5690
+ const zr = "enable-api", Mr = "1.0.7", Ar = "src/patterns/enable/api", Br = "/enable/api";
5691
+ async function Dr(t) {
5692
+ const e = await kr();
5688
5693
  if (t.env === "preview") {
5689
- const s = await Ia();
5690
- return S(H([e, s]));
5694
+ const s = await Ir();
5695
+ return F(E([e, s]));
5691
5696
  }
5692
- const { generate: n } = await import("./generate.runtime-C7g-zL0o.js"), r = await n(t), { writeResult: a } = await import("./write-result-CbUTMeAc.js");
5693
- return a(
5694
- await S(H([e, r])),
5697
+ const { generate: n } = await import("./generate.runtime-C7g-zL0o.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
5698
+ return r(
5699
+ await F(E([e, a])),
5695
5700
  t
5696
5701
  );
5697
5702
  }
5698
- const Aa = {
5699
- version: Ma,
5700
- slug: za,
5701
- source: Ba,
5702
- docs: Da,
5703
+ const Tr = {
5704
+ version: Mr,
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,17 +5721,666 @@ const Aa = {
5715
5721
  argv: []
5716
5722
  },
5717
5723
  baseline: "velastack",
5718
- generate: Ta
5719
- }, Va = ne.version, Jt = [
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";
6154
+ import { matchUrl } from "$locales/main.url";
6155
+ import { locales } from "$locales/data";
6156
+
6157
+ export const reroute = ({ url }) => {
6158
+ const [upath, locale] = deLocalizeDefault(url.pathname, locales);
6159
+ const { path } = matchUrl(upath, locale);
6160
+ return path ?? url.pathname;
6161
+ };
6162
+ `, io = `import { deLocalizeDefault, fillParams } from "wuchale/url";
6163
+ import type { Locale } from "../locales/data";
6164
+ import { matchUrl } from "../locales/main.url";
6165
+ import { locales } from "../locales/data";
6166
+
6167
+ export const defaultLocale = "en";
6168
+
6169
+ export function localize(path: string, locale: Locale) {
6170
+ if (locale === defaultLocale) {
6171
+ return path;
6172
+ }
6173
+
6174
+ return \`/\${locale}\${path}\`;
6175
+ }
6176
+
6177
+ export function translateUrl(url: string, fromLocale: Locale, toLocale: Locale) {
6178
+ const [pathOnly] = deLocalizeDefault(url, locales);
6179
+ const result = matchUrl(pathOnly, fromLocale);
6180
+ if (result.path !== null) {
6181
+ const targetPath = fillParams(result.params, result.altPatterns[toLocale]);
6182
+ return localize(targetPath, toLocale);
6183
+ }
6184
+ return localize(url, toLocale);
6185
+ }
6186
+ `, lo = `// @ts-check
6187
+ import { adapter as svelte } from "@wuchale/svelte";
6188
+ import { adapter as js } from "wuchale/adapter-vanilla";
6189
+ import { defineConfig } from "wuchale";
6190
+
6191
+ export default defineConfig({
6192
+ locales: ["en", "es"],
6193
+ adapters: {
6194
+ main: svelte({ loader: "sveltekit", url: { localize: true, patterns: ["/"] } }),
6195
+ js: js({
6196
+ loader: "vite",
6197
+ files: ["src/**/+{page,layout}.{js,ts}", "src/**/+{page,layout}.server.{js,ts}"],
6198
+ }),
6199
+ },
6200
+ });
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) {
6207
+ return {
6208
+ creates: Object.entries(co).map(([n, a]) => {
6209
+ const r = I(n, mo);
6210
+ return {
6211
+ path: r,
6212
+ language: C(r),
6213
+ content: a
6214
+ };
6215
+ }).sort((n, a) => n.path.localeCompare(a.path)),
6216
+ modifies: [],
6217
+ deletes: [],
6218
+ components: [],
6219
+ packages: ["wuchale", "@wuchale/svelte"],
6220
+ collections: []
6221
+ };
6222
+ }
6223
+ const uo = `<!doctype html>
6224
+ <!-- [!code highlight:1] -->
6225
+ <html lang="%sveltekit.lang%">
6226
+
6227
+ <head>
6228
+ <meta charset="utf-8" />
6229
+ </head>
6230
+
6231
+ <body>
6232
+ <div style="display: contents">%sveltekit.body%</div>
6233
+ </body>
6234
+
6235
+ </html>
6236
+ `, fo = `import { env } from "$env/dynamic/private";
6237
+ import { handlePocketbase } from "@velastack/pocketbase";
6238
+ // [!code highlight:6]
6239
+ import { sequence } from "@sveltejs/kit/hooks";
6240
+ import { runWithLocale, loadLocales } from "wuchale/load-utils/server";
6241
+ import { getLocale } from "$locales/main.url";
6242
+ import { locales } from "$locales/data";
6243
+ import * as main from "$locales/main.loader.server.svelte.js";
6244
+ import * as js from "$locales/js.loader.server.js";
6245
+
6246
+ // [!code highlight:2]
6247
+ loadLocales(main.key, main.loadIDs, main.loadCatalog, locales);
6248
+ loadLocales(js.key, js.loadIDs, js.loadCatalog, locales);
6249
+
6250
+ // [!code highlight:9]
6251
+ const handleWuchale = async ({ event, resolve }: any) => {
6252
+ const locale = getLocale(event.url);
6253
+ return await runWithLocale(locale, () =>
6254
+ resolve(event, {
6255
+ transformPageChunk: ({ html }: { html: string }) =>
6256
+ html.replace("%sveltekit.lang%", locale),
6257
+ }),
6258
+ );
6259
+ };
6260
+
6261
+ export const handle = sequence(
6262
+ // [!code highlight:1]
6263
+ handleWuchale,
6264
+ handlePocketbase({
6265
+ pocketbaseUrl: env.POCKETBASE_URL,
6266
+ superuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,
6267
+ superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD,
6268
+ }),
6269
+ );
6270
+ `, go = `import { browser } from "$app/environment";
6271
+ // [!code highlight:4]
6272
+ import { loadLocale } from "wuchale/load-utils";
6273
+ import { getLocale } from "$locales/main.url";
6274
+ import "$locales/main.loader.svelte";
6275
+ import "$locales/js.loader";
6276
+
6277
+ export const load = async ({ url, data }) => {
6278
+ // [!code highlight:5]
6279
+ const locale = getLocale(url);
6280
+
6281
+ if (browser) {
6282
+ await loadLocale(locale);
6283
+ }
6284
+
6285
+ return data;
6286
+ };
6287
+ `, ho = `import adapter from "@sveltejs/adapter-auto";
6288
+ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
6289
+
6290
+ const config = {
6291
+ preprocess: vitePreprocess(),
6292
+ kit: {
6293
+ adapter,
6294
+ // [!code highlight:3]
6295
+ alias: {
6296
+ $locales: "src/locales",
6297
+ },
6298
+ },
6299
+ };
6300
+
6301
+ export default config;
6302
+ `, bo = `import { defineConfig } from "vite";
6303
+ import { sveltekit } from "@sveltejs/kit/vite";
6304
+ import tailwindcss from "@tailwindcss/vite";
6305
+ // [!code highlight:1]
6306
+ import { wuchale } from "wuchale/vite";
6307
+
6308
+ export default defineConfig({
6309
+ // [!code highlight:1]
6310
+ plugins: [wuchale(), tailwindcss(), sveltekit()],
6311
+ });
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);
6322
+ return {
6323
+ path: r,
6324
+ language: C(r),
6325
+ content: a
6326
+ };
6327
+ }).sort((n, a) => n.path.localeCompare(a.path));
6328
+ return {
6329
+ creates: [],
6330
+ modifies: e,
6331
+ deletes: [],
6332
+ components: [],
6333
+ packages: [],
6334
+ collections: []
6335
+ };
6336
+ }
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();
6340
+ if (t.env === "preview") {
6341
+ const s = await wo();
6342
+ return F(E([e, s]));
6343
+ }
6344
+ const { generate: n } = await import("./generate.runtime-DDZCukG0.js"), a = await n(t), { writeResult: r } = await import("./write-result-CbUTMeAc.js");
6345
+ return r(
6346
+ await F(E([e, a])),
6347
+ t
6348
+ );
6349
+ }
6350
+ const _o = {
6351
+ version: xo,
6352
+ slug: $o,
6353
+ source: Fo,
6354
+ docs: So,
6355
+ plan: "open",
6356
+ title: "Enable i18n",
6357
+ summary: "Enables i18n with Wuchale and locale-aware routing.",
6358
+ requires: {
6359
+ auth: !1,
6360
+ api: !1,
6361
+ payments: !1
6362
+ },
6363
+ category: "i18n",
6364
+ tags: ["sveltekit", "i18n", "localization", "wuchale", "velastack"],
6365
+ command: {
6366
+ raw: "vela enable i18n",
6367
+ base: "vela enable i18n",
6368
+ argv: []
6369
+ },
6370
+ baseline: "velastack",
6371
+ generate: Co
6372
+ }, zo = ne.version, Wt = [
5720
6373
  En,
5721
- $r,
5722
- Gn,
5723
- ur,
5724
- Fa,
5725
- Aa
5726
- ], Ua = Object.fromEntries(
5727
- Jt.map((t) => [t.slug, t])
5728
- ), Ha = Jt.reduce(
6374
+ $a,
6375
+ Hn,
6376
+ pa,
6377
+ Fr,
6378
+ Tr,
6379
+ oo,
6380
+ _o
6381
+ ], Mo = Object.fromEntries(
6382
+ Wt.map((t) => [t.slug, t])
6383
+ ), Ao = Wt.reduce(
5729
6384
  (t, e) => {
5730
6385
  const n = e.category;
5731
6386
  return t[n] ?? (t[n] = []), t[n].push(e), t;
@@ -5733,13 +6388,13 @@ const Aa = {
5733
6388
  {}
5734
6389
  );
5735
6390
  export {
5736
- La as D,
5737
- qa as M,
5738
- Ua as a,
5739
- Ha as b,
5740
- d,
5741
- P as l,
5742
- Jt as p,
5743
- Va as v
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
5744
6399
  };
5745
- //# sourceMappingURL=index-Dav9F9Qf.js.map
6400
+ //# sourceMappingURL=index-ZTxLoBuU.js.map