@velastack/patterns 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-C81jPRX2.js → collections-t61Ot2Ax.js} +3 -3
- package/dist/chunks/{collections-C81jPRX2.js.map → collections-t61Ot2Ax.js.map} +1 -1
- package/dist/chunks/{env.runtime-9ntayaBG.js → env.runtime-BTggk_Vb.js} +2 -2
- package/dist/chunks/{env.runtime-9ntayaBG.js.map → env.runtime-BTggk_Vb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C9KDy9UE.js → generate.runtime-5EvPE9YS.js} +3 -3
- package/dist/chunks/{generate.runtime-C9KDy9UE.js.map → generate.runtime-5EvPE9YS.js.map} +1 -1
- package/dist/chunks/generate.runtime-C7g-zL0o.js +55 -0
- package/dist/chunks/generate.runtime-C7g-zL0o.js.map +1 -0
- package/dist/chunks/{index-hHlIVU0l.js → index-Dav9F9Qf.js} +594 -496
- package/dist/chunks/index-Dav9F9Qf.js.map +1 -0
- package/dist/chunks/{pocketbase-BpZvjjRL.js → pocketbase-nb-YtqiX.js} +2 -2
- package/dist/chunks/{pocketbase-BpZvjjRL.js.map → pocketbase-nb-YtqiX.js.map} +1 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-hHlIVU0l.js.map +0 -1
|
@@ -22,13 +22,13 @@ async function ae(t) {
|
|
|
22
22
|
return t;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function ut(t) {
|
|
26
26
|
return Promise.all(t.map((e) => ae(e)));
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function S(t) {
|
|
29
29
|
const [e, n] = await Promise.all([
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
ut(t.creates),
|
|
31
|
+
ut(t.modifies)
|
|
32
32
|
]);
|
|
33
33
|
return {
|
|
34
34
|
...t,
|
|
@@ -36,22 +36,22 @@ async function k(t) {
|
|
|
36
36
|
modifies: n
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function dt(t, e) {
|
|
40
40
|
var n = Object.keys(t);
|
|
41
41
|
if (Object.getOwnPropertySymbols) {
|
|
42
42
|
var r = Object.getOwnPropertySymbols(t);
|
|
43
|
-
e && (r = r.filter(function(
|
|
44
|
-
return Object.getOwnPropertyDescriptor(t,
|
|
43
|
+
e && (r = r.filter(function(a) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(t, a).enumerable;
|
|
45
45
|
})), n.push.apply(n, r);
|
|
46
46
|
}
|
|
47
47
|
return n;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function pt(t) {
|
|
50
50
|
for (var e = 1; e < arguments.length; e++) {
|
|
51
51
|
var n = arguments[e] != null ? arguments[e] : {};
|
|
52
|
-
e % 2 ?
|
|
52
|
+
e % 2 ? dt(Object(n), !0).forEach(function(r) {
|
|
53
53
|
oe(t, r, n[r]);
|
|
54
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) :
|
|
54
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : dt(Object(n)).forEach(function(r) {
|
|
55
55
|
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -74,18 +74,18 @@ function ie(t, e) {
|
|
|
74
74
|
}
|
|
75
75
|
return (e === "string" ? String : Number)(t);
|
|
76
76
|
}
|
|
77
|
-
const d =
|
|
78
|
-
function
|
|
79
|
-
return e.withOptions = (n) =>
|
|
77
|
+
const d = It({});
|
|
78
|
+
function It(t) {
|
|
79
|
+
return e.withOptions = (n) => It(pt(pt({}, t), n)), e;
|
|
80
80
|
function e(n, ...r) {
|
|
81
|
-
const
|
|
81
|
+
const a = typeof n == "string" ? [n] : n.raw, {
|
|
82
82
|
alignValues: s = !1,
|
|
83
83
|
escapeSpecialCharacters: i = Array.isArray(n),
|
|
84
|
-
trimWhitespace:
|
|
84
|
+
trimWhitespace: o = !0
|
|
85
85
|
} = t;
|
|
86
86
|
let c = "";
|
|
87
|
-
for (let f = 0; f <
|
|
88
|
-
let h =
|
|
87
|
+
for (let f = 0; f < a.length; f++) {
|
|
88
|
+
let h = a[f];
|
|
89
89
|
if (i && (h = h.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{")), c += h, f < r.length) {
|
|
90
90
|
const $ = s ? le(r[f], c) : r[f];
|
|
91
91
|
c += $;
|
|
@@ -106,7 +106,7 @@ function zt(t) {
|
|
|
106
106
|
c = m.map((h) => h[0] === " " || h[0] === " " ? h.slice(f) : h).join(`
|
|
107
107
|
`);
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return o && (c = c.trim()), i && (c = c.replace(/\\n/g, `
|
|
110
110
|
`).replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (f, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (f, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (f, h) => String.fromCharCode(parseInt(h, 16)))), typeof Bun < "u" && (c = c.replace(
|
|
111
111
|
// Matches e.g. \\u{1f60a} or \\u5F1F
|
|
112
112
|
/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,
|
|
@@ -125,19 +125,19 @@ function le(t, e) {
|
|
|
125
125
|
const r = e.slice(e.lastIndexOf(`
|
|
126
126
|
`) + 1).match(/^(\s+)/);
|
|
127
127
|
if (r) {
|
|
128
|
-
const
|
|
128
|
+
const a = r[1];
|
|
129
129
|
return t.replace(/\n/g, `
|
|
130
|
-
${
|
|
130
|
+
${a}`);
|
|
131
131
|
}
|
|
132
132
|
return t;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function G(t, e) {
|
|
135
135
|
return t.startsWith(e) ? t.slice(e.length) : t.replace(/^\.\//, "");
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function P(t) {
|
|
138
138
|
return t.endsWith(".svelte") ? "svelte" : t.endsWith(".tsx") || t.endsWith(".ts") ? "ts" : t.endsWith(".jsx") || t.endsWith(".js") ? "js" : "text";
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function H(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,13 +179,13 @@ const ce = {
|
|
|
179
179
|
geopoint: ['import { GeopointInput } from "$lib/components/ui/geopoint";'],
|
|
180
180
|
button: ['import { Button } from "$lib/components/ui/button";']
|
|
181
181
|
};
|
|
182
|
-
function
|
|
182
|
+
function E(t) {
|
|
183
183
|
return `$formData.${t.name}`;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function O(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
|
|
188
|
+
function I(t) {
|
|
189
189
|
return t.labelAside ? d`
|
|
190
190
|
<div class="flex justify-between">
|
|
191
191
|
<Form.Label>${t.title}</Form.Label>
|
|
@@ -193,14 +193,14 @@ function z(t) {
|
|
|
193
193
|
</div>
|
|
194
194
|
` : `<Form.Label>${t.title}</Form.Label>`;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function D(t, e) {
|
|
197
197
|
const n = t.required ? " required" : "";
|
|
198
198
|
return d`
|
|
199
199
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
200
200
|
<Form.Control>
|
|
201
201
|
{#snippet children({ props })}
|
|
202
|
-
${
|
|
203
|
-
<Input {...props} type="${e}" bind:value={${
|
|
202
|
+
${I(t)}
|
|
203
|
+
<Input {...props} type="${e}" bind:value={${E(t)}}${n}${O(t)} />
|
|
204
204
|
{/snippet}
|
|
205
205
|
</Form.Control>
|
|
206
206
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -213,8 +213,8 @@ function ue(t) {
|
|
|
213
213
|
<Form.Field {form} name="${t.name}" class="col-span-2">
|
|
214
214
|
<Form.Control>
|
|
215
215
|
{#snippet children({ props })}
|
|
216
|
-
${
|
|
217
|
-
<Textarea {...props} bind:value={${
|
|
216
|
+
${I(t)}
|
|
217
|
+
<Textarea {...props} bind:value={${E(t)}}${e}${O(t)} />
|
|
218
218
|
{/snippet}
|
|
219
219
|
</Form.Control>
|
|
220
220
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -227,8 +227,8 @@ function de(t) {
|
|
|
227
227
|
<Form.Field {form} name="${t.name}" class="col-span-1 flex items-start space-x-2">
|
|
228
228
|
<Form.Control>
|
|
229
229
|
{#snippet children({ props })}
|
|
230
|
-
<Checkbox {...props} bind:checked={${
|
|
231
|
-
${
|
|
230
|
+
<Checkbox {...props} bind:checked={${E(t)}}${e}${O(t)} />
|
|
231
|
+
${I(t)}
|
|
232
232
|
{/snippet}
|
|
233
233
|
</Form.Control>
|
|
234
234
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -240,8 +240,8 @@ function pe(t) {
|
|
|
240
240
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
241
241
|
<Form.Control>
|
|
242
242
|
{#snippet children({ props })}
|
|
243
|
-
${
|
|
244
|
-
<GeopointInput {...props} bind:value={${
|
|
243
|
+
${I(t)}
|
|
244
|
+
<GeopointInput {...props} bind:value={${E(t)}} />
|
|
245
245
|
{/snippet}
|
|
246
246
|
</Form.Control>
|
|
247
247
|
<Form.FieldErrors class="contents text-destructive" />
|
|
@@ -254,7 +254,7 @@ function fe(t) {
|
|
|
254
254
|
<FileForm.Field {form} name="${t.name}" class="col-span-1">
|
|
255
255
|
<Form.Control>
|
|
256
256
|
{#snippet children({ props })}
|
|
257
|
-
${
|
|
257
|
+
${I(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}${
|
|
269
|
+
<FileForm.Input {...props}${e}${O(t)} />
|
|
270
270
|
{/snippet}
|
|
271
271
|
</FileForm.${n}>
|
|
272
272
|
{/snippet}
|
|
@@ -276,7 +276,7 @@ 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",
|
|
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(
|
|
280
280
|
(s) => `<MultiSelect.Item value=${JSON.stringify(s.value)} label={${t.name}Labels[${JSON.stringify(s.value)}].label} />`
|
|
281
281
|
).join(`
|
|
282
282
|
`);
|
|
@@ -284,9 +284,9 @@ function ge(t) {
|
|
|
284
284
|
<MultiSelect.Field {form} type="${e}" name="${t.name}"${n} class="col-span-1">
|
|
285
285
|
<Form.Control>
|
|
286
286
|
{#snippet children({ props })}
|
|
287
|
-
${
|
|
287
|
+
${I(t)}
|
|
288
288
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
289
|
-
<MultiSelect.Input bind:value={${
|
|
289
|
+
<MultiSelect.Input bind:value={${E(t)}} placeholder="${r}" {...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
|
-
${
|
|
307
|
+
${a}
|
|
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()}...`,
|
|
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
318
|
return d`
|
|
319
319
|
<MultiSelect.Field {form} type="${e}" name="${t.name}" class="col-span-1">
|
|
320
320
|
<Form.Control>
|
|
321
321
|
{#snippet children({ props })}
|
|
322
322
|
<Form.Label>${t.title}</Form.Label>
|
|
323
323
|
<MultiSelect.Trigger class="w-full justify-between">
|
|
324
|
-
<MultiSelect.Input bind:value={${
|
|
324
|
+
<MultiSelect.Input bind:value={${E(t)}} placeholder="${n}" {...props}>
|
|
325
325
|
{#snippet children({ selected })}
|
|
326
326
|
<div class="flex flex-wrap gap-1">
|
|
327
327
|
{#each selected as value}
|
|
@@ -338,7 +338,7 @@ function he(t) {
|
|
|
338
338
|
<MultiSelect.Content class="p-0">
|
|
339
339
|
<Command.Root>
|
|
340
340
|
<Command.Input autofocus placeholder="${r}" />
|
|
341
|
-
<Command.Empty>${
|
|
341
|
+
<Command.Empty>${a}</Command.Empty>
|
|
342
342
|
<Command.Group>
|
|
343
343
|
{#each data.${i} as ${s}}
|
|
344
344
|
<MultiSelect.Item value={${s}.id} label={${s}.${t.displayField}} />
|
|
@@ -356,28 +356,28 @@ function be(t) {
|
|
|
356
356
|
<Form.Field {form} name="${t.name}" class="col-span-1">
|
|
357
357
|
<Form.Control>
|
|
358
358
|
{#snippet children({ props })}
|
|
359
|
-
${
|
|
360
|
-
<Input {...props} type="text" value={${
|
|
359
|
+
${I(t)}
|
|
360
|
+
<Input {...props} type="text" value={${E(t)}}${O(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
|
|
367
|
+
function rt(t) {
|
|
368
368
|
switch (t.type) {
|
|
369
369
|
case "text":
|
|
370
|
-
return
|
|
370
|
+
return D(t, "text");
|
|
371
371
|
case "number":
|
|
372
|
-
return
|
|
372
|
+
return D(t, "number");
|
|
373
373
|
case "date":
|
|
374
|
-
return
|
|
374
|
+
return D(t, "date");
|
|
375
375
|
case "email":
|
|
376
|
-
return
|
|
376
|
+
return D(t, "email");
|
|
377
377
|
case "password":
|
|
378
|
-
return
|
|
378
|
+
return D(t, "password");
|
|
379
379
|
case "url":
|
|
380
|
-
return
|
|
380
|
+
return D(t, "url");
|
|
381
381
|
case "autodate":
|
|
382
382
|
return be(t);
|
|
383
383
|
case "editor":
|
|
@@ -397,7 +397,7 @@ function et(t) {
|
|
|
397
397
|
return t;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function zt(t) {
|
|
401
401
|
const e = t.options.map(
|
|
402
402
|
(n) => d`
|
|
403
403
|
${JSON.stringify(n.value)}: {
|
|
@@ -413,17 +413,17 @@ function It(t) {
|
|
|
413
413
|
} as const;
|
|
414
414
|
`;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function L(t) {
|
|
417
417
|
const e = t.flatMap((n) => ce[n.type]);
|
|
418
418
|
return [...new Set(e)];
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function at(t) {
|
|
421
421
|
return [...new Set(t.flatMap((e) => me[e]))];
|
|
422
422
|
}
|
|
423
423
|
function R(t, e) {
|
|
424
424
|
return `data.${t.name}.${e.name}`;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function Q(t, e, n) {
|
|
427
427
|
return d`
|
|
428
428
|
<div class="space-y-2">
|
|
429
429
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
@@ -432,7 +432,7 @@ function Y(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>`,
|
|
435
|
+
const n = R(t, e), r = `<p class="text-muted-foreground">{new Date(${n}).toLocaleDateString()}</p>`, a = e.required ? r : d`
|
|
436
436
|
{#if ${n}}
|
|
437
437
|
${r}
|
|
438
438
|
{/if}
|
|
@@ -440,7 +440,7 @@ function ve(t, e) {
|
|
|
440
440
|
return d`
|
|
441
441
|
<div class="space-y-2">
|
|
442
442
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
443
|
-
${
|
|
443
|
+
${a}
|
|
444
444
|
</div>
|
|
445
445
|
`;
|
|
446
446
|
}
|
|
@@ -449,7 +449,7 @@ function we(t, e) {
|
|
|
449
449
|
<a href={${n}} target="_blank" rel="noopener noreferrer">
|
|
450
450
|
{${n}}
|
|
451
451
|
</a>
|
|
452
|
-
`,
|
|
452
|
+
`, a = e.required ? r : d`
|
|
453
453
|
{#if ${n}}
|
|
454
454
|
${r}
|
|
455
455
|
{/if}
|
|
@@ -458,7 +458,7 @@ function we(t, e) {
|
|
|
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
|
-
${
|
|
461
|
+
${a}
|
|
462
462
|
</p>
|
|
463
463
|
</div>
|
|
464
464
|
`;
|
|
@@ -474,7 +474,7 @@ 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>`,
|
|
477
|
+
const r = `<Badge variant="outline" class="mr-1">{${e.name}Labels[${n}].label}</Badge>`, a = e.required ? r : d`
|
|
478
478
|
{#if ${n}}
|
|
479
479
|
${r}
|
|
480
480
|
{/if}
|
|
@@ -482,7 +482,7 @@ function ye(t, e) {
|
|
|
482
482
|
return d`
|
|
483
483
|
<div class="space-y-2">
|
|
484
484
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
485
|
-
${
|
|
485
|
+
${a}
|
|
486
486
|
</div>
|
|
487
487
|
`;
|
|
488
488
|
}
|
|
@@ -573,7 +573,7 @@ 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
|
-
`,
|
|
576
|
+
`, a = e.required ? r : d`
|
|
577
577
|
{#if ${n}}
|
|
578
578
|
${r}
|
|
579
579
|
{/if}
|
|
@@ -581,7 +581,7 @@ function Se(t, e) {
|
|
|
581
581
|
return d`
|
|
582
582
|
<div class="space-y-2">
|
|
583
583
|
<h3 class="font-medium leading-none">${e.title}</h3>
|
|
584
|
-
${
|
|
584
|
+
${a}
|
|
585
585
|
</div>
|
|
586
586
|
`;
|
|
587
587
|
}
|
|
@@ -591,7 +591,7 @@ function Ce(t, e) {
|
|
|
591
591
|
case "number":
|
|
592
592
|
case "email":
|
|
593
593
|
case "editor":
|
|
594
|
-
return
|
|
594
|
+
return Q(t, e, `{${R(t, e)}}`);
|
|
595
595
|
case "password":
|
|
596
596
|
return d`
|
|
597
597
|
<div class="space-y-2">
|
|
@@ -602,7 +602,7 @@ function Ce(t, e) {
|
|
|
602
602
|
</div>
|
|
603
603
|
`;
|
|
604
604
|
case "bool":
|
|
605
|
-
return
|
|
605
|
+
return Q(
|
|
606
606
|
t,
|
|
607
607
|
e,
|
|
608
608
|
`{${R(t, e)} ? "Yes" : "No"}`
|
|
@@ -617,7 +617,7 @@ function Ce(t, e) {
|
|
|
617
617
|
case "file":
|
|
618
618
|
return $e(t, e);
|
|
619
619
|
case "json":
|
|
620
|
-
return
|
|
620
|
+
return Q(t, e, `{JSON.stringify(${R(t, e)})}`);
|
|
621
621
|
case "geoPoint":
|
|
622
622
|
return Se(t, e);
|
|
623
623
|
case "relation":
|
|
@@ -626,10 +626,10 @@ function Ce(t, e) {
|
|
|
626
626
|
return e;
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
const _e = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), ke = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), Re = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), Pe = /[^\p{L}\d]+/giu,
|
|
630
|
-
function
|
|
629
|
+
const _e = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), ke = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), Re = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), Pe = /[^\p{L}\d]+/giu, ft = "$1\0$2", gt = "";
|
|
630
|
+
function Mt(t) {
|
|
631
631
|
let e = t.trim();
|
|
632
|
-
e = e.replace(_e,
|
|
632
|
+
e = e.replace(_e, ft).replace(ke, ft), e = e.replace(Pe, "\0");
|
|
633
633
|
let n = 0, r = e.length;
|
|
634
634
|
for (; e.charAt(n) === "\0"; )
|
|
635
635
|
n++;
|
|
@@ -639,43 +639,43 @@ function Et(t) {
|
|
|
639
639
|
r--;
|
|
640
640
|
return e.slice(n, r).split(/\0/g);
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
const e =
|
|
642
|
+
function Ee(t) {
|
|
643
|
+
const e = Mt(t);
|
|
644
644
|
for (let n = 0; n < e.length; n++) {
|
|
645
|
-
const r = e[n],
|
|
646
|
-
if (
|
|
647
|
-
const s =
|
|
645
|
+
const r = e[n], a = Re.exec(r);
|
|
646
|
+
if (a) {
|
|
647
|
+
const s = a.index + (a[1] ?? a[2]).length;
|
|
648
648
|
e.splice(n, 1, r.slice(0, s), r.slice(s));
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
651
|
return e;
|
|
652
652
|
}
|
|
653
653
|
function Bt(t, e) {
|
|
654
|
-
const [n, r,
|
|
655
|
-
return n + r.map(
|
|
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;
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
const [n, r,
|
|
659
|
-
return n + r.map((c, m) => m === 0 ? s(c) :
|
|
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;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
const [n, r,
|
|
663
|
-
return n + r.map(
|
|
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;
|
|
664
664
|
}
|
|
665
|
-
function
|
|
666
|
-
const [n, r,
|
|
667
|
-
return n + r.map(Be(s, i)).join(" ") +
|
|
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;
|
|
668
668
|
}
|
|
669
|
-
function
|
|
669
|
+
function ze(t, e) {
|
|
670
670
|
return Bt(t, { delimiter: "-", ...e });
|
|
671
671
|
}
|
|
672
|
-
function
|
|
672
|
+
function Me(t, e) {
|
|
673
673
|
return Bt(t, { delimiter: "_", ...e });
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function W(t) {
|
|
676
676
|
return t === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(t);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function st(t) {
|
|
679
679
|
return (e) => e.toLocaleUpperCase(t);
|
|
680
680
|
}
|
|
681
681
|
function Be(t, e) {
|
|
@@ -683,24 +683,24 @@ function Be(t, e) {
|
|
|
683
683
|
}
|
|
684
684
|
function Dt(t, e) {
|
|
685
685
|
return (n, r) => {
|
|
686
|
-
const
|
|
687
|
-
return (r > 0 &&
|
|
686
|
+
const a = n[0];
|
|
687
|
+
return (r > 0 && a >= "0" && a <= "9" ? "_" + a : e(a)) + t(n.slice(1));
|
|
688
688
|
};
|
|
689
689
|
}
|
|
690
|
-
function
|
|
691
|
-
const n = e.split ?? (e.separateNumbers ?
|
|
690
|
+
function J(t, e = {}) {
|
|
691
|
+
const n = e.split ?? (e.separateNumbers ? Ee : Mt), r = e.prefixCharacters ?? gt, a = e.suffixCharacters ?? gt;
|
|
692
692
|
let s = 0, i = t.length;
|
|
693
693
|
for (; s < t.length; ) {
|
|
694
|
-
const
|
|
695
|
-
if (!r.includes(
|
|
694
|
+
const o = t.charAt(s);
|
|
695
|
+
if (!r.includes(o))
|
|
696
696
|
break;
|
|
697
697
|
s++;
|
|
698
698
|
}
|
|
699
699
|
for (; i > s; ) {
|
|
700
|
-
const
|
|
701
|
-
if (!
|
|
700
|
+
const o = i - 1, c = t.charAt(o);
|
|
701
|
+
if (!a.includes(c))
|
|
702
702
|
break;
|
|
703
|
-
i =
|
|
703
|
+
i = o;
|
|
704
704
|
}
|
|
705
705
|
return [
|
|
706
706
|
t.slice(0, s),
|
|
@@ -714,14 +714,14 @@ function De(t) {
|
|
|
714
714
|
function Te(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,
|
|
718
|
-
function
|
|
719
|
-
return
|
|
717
|
+
var U = { exports: {} }, Ae = U.exports, ht;
|
|
718
|
+
function je() {
|
|
719
|
+
return ht || (ht = 1, (function(t, e) {
|
|
720
720
|
(function(n, r) {
|
|
721
721
|
typeof Te == "function" ? t.exports = r() : n.pluralize = r();
|
|
722
722
|
})(Ae, function() {
|
|
723
|
-
var n = [], r = [],
|
|
724
|
-
function
|
|
723
|
+
var n = [], r = [], a = {}, s = {}, i = {};
|
|
724
|
+
function o(l) {
|
|
725
725
|
return typeof l == "string" ? new RegExp("^" + l + "$", "i") : l;
|
|
726
726
|
}
|
|
727
727
|
function c(l, p) {
|
|
@@ -739,7 +739,7 @@ function Ne() {
|
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
function f(l, p, w) {
|
|
742
|
-
if (!l.length ||
|
|
742
|
+
if (!l.length || a.hasOwnProperty(l))
|
|
743
743
|
return p;
|
|
744
744
|
for (var x = w.length; x--; ) {
|
|
745
745
|
var F = w[x];
|
|
@@ -755,8 +755,8 @@ function Ne() {
|
|
|
755
755
|
}
|
|
756
756
|
function $(l, p, w, x) {
|
|
757
757
|
return function(F) {
|
|
758
|
-
var
|
|
759
|
-
return p.hasOwnProperty(
|
|
758
|
+
var M = F.toLowerCase();
|
|
759
|
+
return p.hasOwnProperty(M) ? !0 : l.hasOwnProperty(M) ? !1 : f(M, M, w) === M;
|
|
760
760
|
};
|
|
761
761
|
}
|
|
762
762
|
function u(l, p, w) {
|
|
@@ -780,12 +780,12 @@ function Ne() {
|
|
|
780
780
|
i,
|
|
781
781
|
r
|
|
782
782
|
), u.addPluralRule = function(l, p) {
|
|
783
|
-
n.push([
|
|
783
|
+
n.push([o(l), p]);
|
|
784
784
|
}, u.addSingularRule = function(l, p) {
|
|
785
|
-
r.push([
|
|
785
|
+
r.push([o(l), p]);
|
|
786
786
|
}, u.addUncountableRule = function(l) {
|
|
787
787
|
if (typeof l == "string") {
|
|
788
|
-
|
|
788
|
+
a[l.toLowerCase()] = !0;
|
|
789
789
|
return;
|
|
790
790
|
}
|
|
791
791
|
u.addPluralRule(l, "$0"), u.addSingularRule(l, "$0");
|
|
@@ -1014,8 +1014,8 @@ function Ne() {
|
|
|
1014
1014
|
});
|
|
1015
1015
|
})(U)), U.exports;
|
|
1016
1016
|
}
|
|
1017
|
-
var
|
|
1018
|
-
const
|
|
1017
|
+
var Ne = je();
|
|
1018
|
+
const k = /* @__PURE__ */ De(Ne), La = "data", qa = "migrations", Oe = "(app)", Le = /* @__PURE__ */ new Set([
|
|
1019
1019
|
"break",
|
|
1020
1020
|
"case",
|
|
1021
1021
|
"catch",
|
|
@@ -1116,28 +1116,28 @@ const _ = /* @__PURE__ */ De(je), ka = "data", Ra = "migrations", Le = "(app)",
|
|
|
1116
1116
|
arguments: "args",
|
|
1117
1117
|
constructor: "ctor"
|
|
1118
1118
|
};
|
|
1119
|
-
function
|
|
1120
|
-
return
|
|
1119
|
+
function tt(t) {
|
|
1120
|
+
return Le.has(t) ? qe[t] ?? `${t}_` : t;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function Z(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
1128
|
function Ve(t) {
|
|
1129
|
-
return t.features.auth ? `src/routes/${
|
|
1129
|
+
return t.features.auth ? `src/routes/${Oe}` : "src/routes";
|
|
1130
1130
|
}
|
|
1131
|
-
function
|
|
1132
|
-
const n = t.split("/"), r = n[n.length - 1],
|
|
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("/");
|
|
1133
1133
|
return {
|
|
1134
|
-
name:
|
|
1135
|
-
pluralName:
|
|
1136
|
-
typeName:
|
|
1137
|
-
tableName:
|
|
1134
|
+
name: tt(o),
|
|
1135
|
+
pluralName: tt(j(i)),
|
|
1136
|
+
typeName: Ie(s),
|
|
1137
|
+
tableName: Me(i),
|
|
1138
1138
|
displayName: s,
|
|
1139
1139
|
pluralDisplayName: i,
|
|
1140
|
-
schemaName: `${
|
|
1140
|
+
schemaName: `${tt(o)}Schema`,
|
|
1141
1141
|
routeSegment: m,
|
|
1142
1142
|
routesDir: Ve(e)
|
|
1143
1143
|
};
|
|
@@ -1211,7 +1211,7 @@ function Tt(t) {
|
|
|
1211
1211
|
t.map((e) => [e.name, We(e.fields)])
|
|
1212
1212
|
);
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1214
|
+
const Ke = [
|
|
1215
1215
|
"user",
|
|
1216
1216
|
"owner",
|
|
1217
1217
|
"created_by",
|
|
@@ -1220,10 +1220,10 @@ const Xe = [
|
|
|
1220
1220
|
"account",
|
|
1221
1221
|
"creator"
|
|
1222
1222
|
];
|
|
1223
|
-
function
|
|
1223
|
+
function T(t) {
|
|
1224
1224
|
return t.toLowerCase();
|
|
1225
1225
|
}
|
|
1226
|
-
function
|
|
1226
|
+
function bt(t) {
|
|
1227
1227
|
return {
|
|
1228
1228
|
rule: '@request.auth.id != ""',
|
|
1229
1229
|
ownershipChainCollections: [t],
|
|
@@ -1231,15 +1231,15 @@ function ht(t) {
|
|
|
1231
1231
|
operator: "="
|
|
1232
1232
|
};
|
|
1233
1233
|
}
|
|
1234
|
-
function
|
|
1235
|
-
const r = new Set((n.authCollections ?? ["users"]).map(
|
|
1236
|
-
(n.userFieldHints ??
|
|
1237
|
-
), s = n.maxDepth ?? 8, i = /* @__PURE__ */ new Map(),
|
|
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)
|
|
1237
|
+
), s = n.maxDepth ?? 8, i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
1238
1238
|
for (const b of t)
|
|
1239
|
-
i.set(b.name, b),
|
|
1239
|
+
i.set(b.name, b), o.set(b.id, b);
|
|
1240
1240
|
if (!i.has(e))
|
|
1241
|
-
return
|
|
1242
|
-
if (r.has(
|
|
1241
|
+
return bt(e);
|
|
1242
|
+
if (r.has(T(e)))
|
|
1243
1243
|
return {
|
|
1244
1244
|
rule: "@request.auth.id = id",
|
|
1245
1245
|
ownershipChainCollections: [e],
|
|
@@ -1247,28 +1247,28 @@ function Ye(t, e, n = {}) {
|
|
|
1247
1247
|
operator: "="
|
|
1248
1248
|
};
|
|
1249
1249
|
function c(b) {
|
|
1250
|
-
const v =
|
|
1251
|
-
return v === "user" ? 50 :
|
|
1250
|
+
const v = T(b);
|
|
1251
|
+
return v === "user" ? 50 : a.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
|
|
1256
|
+
const C = [];
|
|
1257
1257
|
for (const y of v.fields) {
|
|
1258
1258
|
if (y.type !== "relation" || !y.collectionId) continue;
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1259
|
+
const B = o.get(y.collectionId);
|
|
1260
|
+
B && C.push({
|
|
1261
1261
|
from: b,
|
|
1262
1262
|
fieldName: y.name,
|
|
1263
|
-
to:
|
|
1263
|
+
to: B.name,
|
|
1264
1264
|
isMulti: !!(y.maxSelect && y.maxSelect > 1),
|
|
1265
1265
|
hintScore: c(y.name)
|
|
1266
1266
|
});
|
|
1267
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return C.sort((y, B) => y.fieldName.localeCompare(B.fieldName)), C;
|
|
1269
1269
|
}
|
|
1270
1270
|
function g(b) {
|
|
1271
|
-
return r.has(
|
|
1271
|
+
return r.has(T(b));
|
|
1272
1272
|
}
|
|
1273
1273
|
function f(b) {
|
|
1274
1274
|
if (b.length === 0) return !1;
|
|
@@ -1277,41 +1277,41 @@ function Ye(t, e, n = {}) {
|
|
|
1277
1277
|
return g(b[b.length - 1].to);
|
|
1278
1278
|
}
|
|
1279
1279
|
function h(b) {
|
|
1280
|
-
const v = b[b.length - 1],
|
|
1281
|
-
return 100 * b.length + 50 *
|
|
1280
|
+
const v = b[b.length - 1], 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;
|
|
1282
1282
|
}
|
|
1283
1283
|
function $(b) {
|
|
1284
1284
|
return b.map((v) => `${v.from}.${v.fieldName}->${v.to}`).join("|");
|
|
1285
1285
|
}
|
|
1286
1286
|
const u = [], l = /* @__PURE__ */ new Set([e]);
|
|
1287
|
-
function p(b, v,
|
|
1288
|
-
if (!(
|
|
1287
|
+
function p(b, v, C) {
|
|
1288
|
+
if (!(C > s)) {
|
|
1289
1289
|
if (v.length > 0 && g(v[v.length - 1].to) && f(v)) {
|
|
1290
1290
|
u.push([...v]);
|
|
1291
1291
|
return;
|
|
1292
1292
|
}
|
|
1293
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,
|
|
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));
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
if (p(e, [], 0), u.length === 0)
|
|
1298
|
-
return
|
|
1298
|
+
return bt(e);
|
|
1299
1299
|
u.sort((b, v) => {
|
|
1300
|
-
const
|
|
1301
|
-
return
|
|
1300
|
+
const C = h(b) - h(v);
|
|
1301
|
+
return C !== 0 ? C : $(b).localeCompare($(v));
|
|
1302
1302
|
});
|
|
1303
|
-
const w = u[0], x = w.map((b) => b.fieldName), F = [e, ...w.map((b) => b.to)],
|
|
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) + "." : "";
|
|
1304
1304
|
return {
|
|
1305
|
-
rule: `@request.auth.id ${
|
|
1305
|
+
rule: `@request.auth.id ${mt} ${Kt}${Zt}.id`,
|
|
1306
1306
|
ownershipChainCollections: F,
|
|
1307
1307
|
ownershipChainFields: x,
|
|
1308
|
-
operator:
|
|
1308
|
+
operator: mt
|
|
1309
1309
|
};
|
|
1310
1310
|
}
|
|
1311
|
-
function
|
|
1311
|
+
function Ye(t) {
|
|
1312
1312
|
let e = null, n = !1, r = 0;
|
|
1313
|
-
for (let
|
|
1314
|
-
const s = t[
|
|
1313
|
+
for (let a = 0; a < t.length; a++) {
|
|
1314
|
+
const s = t[a];
|
|
1315
1315
|
if (n) {
|
|
1316
1316
|
n = !1;
|
|
1317
1317
|
continue;
|
|
@@ -1337,78 +1337,78 @@ function Ke(t) {
|
|
|
1337
1337
|
continue;
|
|
1338
1338
|
}
|
|
1339
1339
|
if (s === ":" && r === 0)
|
|
1340
|
-
return [t.slice(0,
|
|
1340
|
+
return [t.slice(0, a), t.slice(a + 1)];
|
|
1341
1341
|
}
|
|
1342
1342
|
return [t, ""];
|
|
1343
1343
|
}
|
|
1344
|
-
function
|
|
1344
|
+
function vt(t) {
|
|
1345
1345
|
const e = t.trim();
|
|
1346
1346
|
return e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'") ? e.slice(1, -1).replace(/\\(["'])/g, "$1") : e;
|
|
1347
1347
|
}
|
|
1348
|
-
function
|
|
1348
|
+
function wt(t) {
|
|
1349
1349
|
let e = -1, n = null, r = !1;
|
|
1350
1350
|
for (let i = 0; i < t.length; i++) {
|
|
1351
|
-
const
|
|
1351
|
+
const o = t[i];
|
|
1352
1352
|
if (r) {
|
|
1353
1353
|
r = !1;
|
|
1354
1354
|
continue;
|
|
1355
1355
|
}
|
|
1356
1356
|
if (n) {
|
|
1357
|
-
if (
|
|
1357
|
+
if (o === "\\") {
|
|
1358
1358
|
r = !0;
|
|
1359
1359
|
continue;
|
|
1360
1360
|
}
|
|
1361
|
-
|
|
1361
|
+
o === n && (n = null);
|
|
1362
1362
|
continue;
|
|
1363
1363
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
n =
|
|
1364
|
+
if (o === '"' || o === "'") {
|
|
1365
|
+
n = o;
|
|
1366
1366
|
continue;
|
|
1367
1367
|
}
|
|
1368
|
-
if (
|
|
1368
|
+
if (o === ":") {
|
|
1369
1369
|
e = i;
|
|
1370
1370
|
break;
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
|
-
let
|
|
1374
|
-
return e >= 0 ? (
|
|
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) };
|
|
1375
1375
|
}
|
|
1376
1376
|
function Qe(t) {
|
|
1377
1377
|
const e = [];
|
|
1378
|
-
let n = "", r = null,
|
|
1378
|
+
let n = "", r = null, a = !1;
|
|
1379
1379
|
for (let i = 0; i < t.length; i++) {
|
|
1380
|
-
const
|
|
1381
|
-
if (
|
|
1382
|
-
n +=
|
|
1380
|
+
const o = t[i];
|
|
1381
|
+
if (a) {
|
|
1382
|
+
n += o, a = !1;
|
|
1383
1383
|
continue;
|
|
1384
1384
|
}
|
|
1385
1385
|
if (r) {
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1386
|
+
if (o === "\\") {
|
|
1387
|
+
a = !0, n += o;
|
|
1388
1388
|
continue;
|
|
1389
1389
|
}
|
|
1390
|
-
if (
|
|
1391
|
-
r = null, n +=
|
|
1390
|
+
if (o === r) {
|
|
1391
|
+
r = null, n += o;
|
|
1392
1392
|
continue;
|
|
1393
1393
|
}
|
|
1394
|
-
n +=
|
|
1394
|
+
n += o;
|
|
1395
1395
|
continue;
|
|
1396
1396
|
}
|
|
1397
|
-
if (
|
|
1398
|
-
r =
|
|
1397
|
+
if (o === '"' || o === "'") {
|
|
1398
|
+
r = o, n += o;
|
|
1399
1399
|
continue;
|
|
1400
1400
|
}
|
|
1401
|
-
if (
|
|
1401
|
+
if (o === ",") {
|
|
1402
1402
|
const c = n.trim();
|
|
1403
|
-
c.length > 0 && e.push(
|
|
1403
|
+
c.length > 0 && e.push(wt(c)), n = "";
|
|
1404
1404
|
continue;
|
|
1405
1405
|
}
|
|
1406
|
-
n +=
|
|
1406
|
+
n += o;
|
|
1407
1407
|
}
|
|
1408
1408
|
const s = n.trim();
|
|
1409
|
-
return s.length > 0 && e.push(
|
|
1409
|
+
return s.length > 0 && e.push(wt(s)), e;
|
|
1410
1410
|
}
|
|
1411
|
-
const
|
|
1411
|
+
const yt = {
|
|
1412
1412
|
string: "text",
|
|
1413
1413
|
boolean: "bool",
|
|
1414
1414
|
geopoint: "geoPoint",
|
|
@@ -1425,46 +1425,46 @@ function tn(t) {
|
|
|
1425
1425
|
const e = t.endsWith("!");
|
|
1426
1426
|
let n = e ? t.slice(0, -1) : t, r = [];
|
|
1427
1427
|
if (n.startsWith("select(") && n.endsWith(")")) {
|
|
1428
|
-
const
|
|
1429
|
-
r = Qe(
|
|
1428
|
+
const a = n.slice(7, -1);
|
|
1429
|
+
r = Qe(a), n = "select";
|
|
1430
1430
|
}
|
|
1431
|
-
return n === "files" ? { type: "file", required: e, selectOptions: r } : (n in
|
|
1431
|
+
return n === "files" ? { type: "file", required: e, selectOptions: r } : (n in yt && (n = yt[n]), { type: n, required: e, selectOptions: r });
|
|
1432
1432
|
}
|
|
1433
|
-
function
|
|
1434
|
-
const e =
|
|
1433
|
+
function $t(t) {
|
|
1434
|
+
const e = k.singular(t), n = k.plural(e);
|
|
1435
1435
|
return t === n ? 99 : 1;
|
|
1436
1436
|
}
|
|
1437
|
-
function q(t, e, n, r,
|
|
1438
|
-
const i =
|
|
1437
|
+
function q(t, e, n, r, a, s) {
|
|
1438
|
+
const i = z(e, s), o = k.singular(t), c = k.plural(o);
|
|
1439
1439
|
return {
|
|
1440
1440
|
collectionId: r[e],
|
|
1441
|
-
displayField:
|
|
1441
|
+
displayField: a[e] ?? "id",
|
|
1442
1442
|
relatedModel: i,
|
|
1443
|
-
singularRelationName:
|
|
1443
|
+
singularRelationName: j(
|
|
1444
1444
|
`${n.displayName} ${i.displayName}`
|
|
1445
1445
|
),
|
|
1446
|
-
pluralRelationName:
|
|
1446
|
+
pluralRelationName: j(
|
|
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,
|
|
1453
|
-
const s =
|
|
1454
|
-
if (
|
|
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
1455
|
const u = q(
|
|
1456
1456
|
t,
|
|
1457
1457
|
"users",
|
|
1458
1458
|
n,
|
|
1459
1459
|
g,
|
|
1460
1460
|
f,
|
|
1461
|
-
|
|
1461
|
+
a
|
|
1462
1462
|
);
|
|
1463
1463
|
return {
|
|
1464
1464
|
type: "relation",
|
|
1465
1465
|
name: t,
|
|
1466
1466
|
title: s,
|
|
1467
|
-
required:
|
|
1467
|
+
required: o,
|
|
1468
1468
|
collectionId: u.collectionId,
|
|
1469
1469
|
maxSelect: 1,
|
|
1470
1470
|
displayField: u.displayField,
|
|
@@ -1480,15 +1480,15 @@ function en(t, e, n, r, o) {
|
|
|
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:
|
|
1483
|
+
return { type: "autodate", name: t, title: s, required: o, onCreate: u, onUpdate: l };
|
|
1484
1484
|
}
|
|
1485
1485
|
if (i === "select")
|
|
1486
1486
|
return {
|
|
1487
1487
|
type: "select",
|
|
1488
1488
|
name: t,
|
|
1489
1489
|
title: s,
|
|
1490
|
-
required:
|
|
1491
|
-
maxSelect:
|
|
1490
|
+
required: o,
|
|
1491
|
+
maxSelect: $t(t),
|
|
1492
1492
|
options: c
|
|
1493
1493
|
};
|
|
1494
1494
|
if (i === "file")
|
|
@@ -1496,11 +1496,11 @@ function en(t, e, n, r, o) {
|
|
|
1496
1496
|
type: "file",
|
|
1497
1497
|
name: t,
|
|
1498
1498
|
title: s,
|
|
1499
|
-
required:
|
|
1500
|
-
maxSelect:
|
|
1499
|
+
required: o,
|
|
1500
|
+
maxSelect: $t(t)
|
|
1501
1501
|
};
|
|
1502
1502
|
if (i === "relation") {
|
|
1503
|
-
const u =
|
|
1503
|
+
const u = k.singular(t), l = k.plural(u);
|
|
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)`
|
|
@@ -1511,13 +1511,13 @@ function en(t, e, n, r, o) {
|
|
|
1511
1511
|
n,
|
|
1512
1512
|
g,
|
|
1513
1513
|
f,
|
|
1514
|
-
|
|
1514
|
+
a
|
|
1515
1515
|
);
|
|
1516
1516
|
return {
|
|
1517
1517
|
type: "relation",
|
|
1518
1518
|
name: t,
|
|
1519
1519
|
title: s,
|
|
1520
|
-
required:
|
|
1520
|
+
required: o,
|
|
1521
1521
|
...p,
|
|
1522
1522
|
isCurrentUser: !1
|
|
1523
1523
|
};
|
|
@@ -1529,19 +1529,19 @@ function en(t, e, n, r, o) {
|
|
|
1529
1529
|
n,
|
|
1530
1530
|
g,
|
|
1531
1531
|
f,
|
|
1532
|
-
|
|
1532
|
+
a
|
|
1533
1533
|
);
|
|
1534
1534
|
return {
|
|
1535
1535
|
type: "relation",
|
|
1536
1536
|
name: t,
|
|
1537
1537
|
title: s,
|
|
1538
|
-
required:
|
|
1538
|
+
required: o,
|
|
1539
1539
|
...u,
|
|
1540
1540
|
isCurrentUser: !1
|
|
1541
1541
|
};
|
|
1542
1542
|
}
|
|
1543
1543
|
if (h.includes(i)) {
|
|
1544
|
-
const u =
|
|
1544
|
+
const u = k.plural(i);
|
|
1545
1545
|
if (m.includes(u)) {
|
|
1546
1546
|
const l = q(
|
|
1547
1547
|
t,
|
|
@@ -1549,13 +1549,13 @@ function en(t, e, n, r, o) {
|
|
|
1549
1549
|
n,
|
|
1550
1550
|
g,
|
|
1551
1551
|
f,
|
|
1552
|
-
|
|
1552
|
+
a
|
|
1553
1553
|
);
|
|
1554
1554
|
return {
|
|
1555
1555
|
type: "relation",
|
|
1556
1556
|
name: t,
|
|
1557
1557
|
title: s,
|
|
1558
|
-
required:
|
|
1558
|
+
required: o,
|
|
1559
1559
|
collectionId: l.collectionId,
|
|
1560
1560
|
displayField: l.displayField,
|
|
1561
1561
|
relatedModel: l.relatedModel,
|
|
@@ -1582,7 +1582,7 @@ function en(t, e, n, r, o) {
|
|
|
1582
1582
|
"select",
|
|
1583
1583
|
"file",
|
|
1584
1584
|
"relation",
|
|
1585
|
-
...
|
|
1585
|
+
...a.features.auth ? ["current_user"] : [],
|
|
1586
1586
|
...m
|
|
1587
1587
|
])
|
|
1588
1588
|
];
|
|
@@ -1601,31 +1601,31 @@ function en(t, e, n, r, o) {
|
|
|
1601
1601
|
throw new Error(
|
|
1602
1602
|
`Invalid field type: ${i}. Valid types are: ${$.join(", ").replace("relation", "references")}`
|
|
1603
1603
|
);
|
|
1604
|
-
return { type: i, name: t, title: s, required:
|
|
1604
|
+
return { type: i, name: t, title: s, required: o };
|
|
1605
1605
|
}
|
|
1606
1606
|
function nn(t, e, n, r) {
|
|
1607
|
-
const
|
|
1607
|
+
const a = [];
|
|
1608
1608
|
for (const i of t) {
|
|
1609
|
-
const [
|
|
1610
|
-
if (!
|
|
1609
|
+
const [o, c] = Ye(i);
|
|
1610
|
+
if (!o || !c)
|
|
1611
1611
|
throw new Error(
|
|
1612
1612
|
`Invalid field format: ${i}. Expected format: name:type or name:type!`
|
|
1613
1613
|
);
|
|
1614
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(
|
|
1614
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(o))
|
|
1615
1615
|
throw new Error(
|
|
1616
|
-
`Invalid field name: ${
|
|
1616
|
+
`Invalid field name: ${o}. Must start with a letter and contain only alphanumeric characters`
|
|
1617
1617
|
);
|
|
1618
1618
|
const m = tn(c);
|
|
1619
|
-
|
|
1619
|
+
a.push(en(o, m, e, n, r));
|
|
1620
1620
|
}
|
|
1621
|
-
const s = r.features.auth ?
|
|
1621
|
+
const s = r.features.auth ? Xe(
|
|
1622
1622
|
[
|
|
1623
1623
|
...n,
|
|
1624
1624
|
{
|
|
1625
1625
|
id: "new",
|
|
1626
1626
|
name: e.tableName,
|
|
1627
1627
|
type: "base",
|
|
1628
|
-
fields:
|
|
1628
|
+
fields: a.map((i) => ({
|
|
1629
1629
|
name: i.name,
|
|
1630
1630
|
type: i.type,
|
|
1631
1631
|
collectionId: i.type === "relation" ? i.collectionId : void 0,
|
|
@@ -1635,16 +1635,16 @@ function nn(t, e, n, r) {
|
|
|
1635
1635
|
],
|
|
1636
1636
|
e.tableName
|
|
1637
1637
|
) : void 0;
|
|
1638
|
-
return { fields:
|
|
1638
|
+
return { fields: a, auth: s };
|
|
1639
1639
|
}
|
|
1640
|
-
async function
|
|
1640
|
+
async function K(t, e, n) {
|
|
1641
1641
|
let r;
|
|
1642
1642
|
if (n.env === "runtime") {
|
|
1643
|
-
const { getCollections:
|
|
1644
|
-
r = await
|
|
1643
|
+
const { getCollections: a } = await import("./env.runtime-BTggk_Vb.js");
|
|
1644
|
+
r = await a();
|
|
1645
1645
|
} else {
|
|
1646
|
-
const { getPreviewCollections:
|
|
1647
|
-
r =
|
|
1646
|
+
const { getPreviewCollections: a } = await import("./env.preview-HlXZOEL4.js");
|
|
1647
|
+
r = a(n);
|
|
1648
1648
|
}
|
|
1649
1649
|
return nn(t, e, r, n);
|
|
1650
1650
|
}
|
|
@@ -1654,12 +1654,12 @@ class N {
|
|
|
1654
1654
|
this.expression = e;
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
|
-
function
|
|
1658
|
-
return t instanceof N ? t.expression : Array.isArray(t) ? `[${t.map((e) =>
|
|
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);
|
|
1659
1659
|
}
|
|
1660
|
-
function
|
|
1660
|
+
function et(t) {
|
|
1661
1661
|
return `{ ${Object.entries(t).map(
|
|
1662
|
-
([n, r]) => `${JSON.stringify(n)}: ${
|
|
1662
|
+
([n, r]) => `${JSON.stringify(n)}: ${nt(r)}`
|
|
1663
1663
|
).join(", ")} }`;
|
|
1664
1664
|
}
|
|
1665
1665
|
function an(t) {
|
|
@@ -1698,11 +1698,11 @@ function an(t) {
|
|
|
1698
1698
|
return;
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
1701
|
-
function
|
|
1701
|
+
function A(t, e) {
|
|
1702
1702
|
return t.replace("[id]", `\${${e}}`);
|
|
1703
1703
|
}
|
|
1704
1704
|
function At(t, e, n) {
|
|
1705
|
-
var r,
|
|
1705
|
+
var r, a, s;
|
|
1706
1706
|
switch (t.type) {
|
|
1707
1707
|
case "text":
|
|
1708
1708
|
case "editor":
|
|
@@ -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 = ((
|
|
1727
|
+
const i = ((a = (r = t.options) == null ? void 0 : r[0]) == null ? void 0 : a.value) ?? "default";
|
|
1728
1728
|
return t.maxSelect && t.maxSelect > 1 ? [i] : i;
|
|
1729
1729
|
}
|
|
1730
1730
|
case "relation": {
|
|
@@ -1740,22 +1740,22 @@ function At(t, e, n) {
|
|
|
1740
1740
|
return;
|
|
1741
1741
|
}
|
|
1742
1742
|
}
|
|
1743
|
-
function
|
|
1743
|
+
function xt(t, e, n) {
|
|
1744
1744
|
const r = {};
|
|
1745
|
-
for (const
|
|
1746
|
-
if (
|
|
1745
|
+
for (const a of t) {
|
|
1746
|
+
if (a.type === "file" || a.type === "autodate")
|
|
1747
1747
|
continue;
|
|
1748
|
-
if (n.authEnabled &&
|
|
1749
|
-
n.forForm || (r[
|
|
1748
|
+
if (n.authEnabled && a.type === "relation" && a.isCurrentUser) {
|
|
1749
|
+
n.forForm || (r[a.name] = new N("context.user.id"));
|
|
1750
1750
|
continue;
|
|
1751
1751
|
}
|
|
1752
|
-
const s = At(
|
|
1753
|
-
s !== void 0 && (r[
|
|
1752
|
+
const s = At(a, e, n);
|
|
1753
|
+
s !== void 0 && (r[a.name] = s);
|
|
1754
1754
|
}
|
|
1755
1755
|
return r;
|
|
1756
1756
|
}
|
|
1757
1757
|
function on(t, e, n) {
|
|
1758
|
-
var
|
|
1758
|
+
var a;
|
|
1759
1759
|
const r = {};
|
|
1760
1760
|
for (const s of t) {
|
|
1761
1761
|
if (s.system || s.name === "id")
|
|
@@ -1763,21 +1763,21 @@ function on(t, e, n) {
|
|
|
1763
1763
|
const i = an(s.type);
|
|
1764
1764
|
if (!i || i === "file" || i === "autodate" || i === "relation" && !s.collectionId)
|
|
1765
1765
|
continue;
|
|
1766
|
-
let
|
|
1766
|
+
let o;
|
|
1767
1767
|
if (i === "relation")
|
|
1768
|
-
|
|
1768
|
+
o = s.collectionId ? new N(
|
|
1769
1769
|
e[s.collectionId] ?? '"missing-relation-id"'
|
|
1770
1770
|
) : void 0;
|
|
1771
1771
|
else if (i === "select") {
|
|
1772
|
-
const c = ((
|
|
1773
|
-
|
|
1772
|
+
const c = ((a = s.values) == null ? void 0 : a[0]) ?? "default";
|
|
1773
|
+
o = (s.maxSelect ?? 1) > 1 ? [c] : c;
|
|
1774
1774
|
} else
|
|
1775
|
-
|
|
1775
|
+
o = At(
|
|
1776
1776
|
{ name: s.name, type: i },
|
|
1777
1777
|
e,
|
|
1778
1778
|
{ forForm: !1, authEnabled: n.features.auth }
|
|
1779
1779
|
);
|
|
1780
|
-
|
|
1780
|
+
o !== void 0 && (r[s.name] = o);
|
|
1781
1781
|
}
|
|
1782
1782
|
return r;
|
|
1783
1783
|
}
|
|
@@ -1789,19 +1789,19 @@ function sn(t) {
|
|
|
1789
1789
|
function ln(t, e) {
|
|
1790
1790
|
if (!t)
|
|
1791
1791
|
return [];
|
|
1792
|
-
const n = new Map(e.map((
|
|
1793
|
-
if (r.has(
|
|
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))
|
|
1794
1794
|
return;
|
|
1795
|
-
const c = n.get(
|
|
1795
|
+
const c = n.get(o);
|
|
1796
1796
|
if (c) {
|
|
1797
|
-
|
|
1797
|
+
a.add(o);
|
|
1798
1798
|
for (const m of c.fields)
|
|
1799
1799
|
m.type !== "relation" || !m.collectionId || i(m.collectionId);
|
|
1800
|
-
|
|
1800
|
+
a.delete(o), r.add(o), s.push(c);
|
|
1801
1801
|
}
|
|
1802
1802
|
};
|
|
1803
|
-
for (const
|
|
1804
|
-
|
|
1803
|
+
for (const o of t.fields)
|
|
1804
|
+
o.type !== "relation" || !o.collectionId || i(o.collectionId);
|
|
1805
1805
|
return s;
|
|
1806
1806
|
}
|
|
1807
1807
|
function cn(t, e) {
|
|
@@ -1835,25 +1835,25 @@ function mn(t, e) {
|
|
|
1835
1835
|
} : { name: n.name, type: n.type })
|
|
1836
1836
|
};
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const
|
|
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(
|
|
1840
1840
|
(l) => !(n.features.auth && l.name === "users")
|
|
1841
|
-
), i = {},
|
|
1841
|
+
), i = {}, o = [], c = /* @__PURE__ */ new Set();
|
|
1842
1842
|
for (const l of s) {
|
|
1843
|
-
const p = cn(
|
|
1844
|
-
|
|
1843
|
+
const p = cn(z(l.name, n).name, c);
|
|
1844
|
+
o.push({ varName: p, collection: l }), i[l.id] = `${p}.id`;
|
|
1845
1845
|
}
|
|
1846
|
-
const m =
|
|
1846
|
+
const m = o.length ? `${o.map((l) => `let ${l.varName}: { id: string };`).join(`
|
|
1847
1847
|
`)}
|
|
1848
1848
|
|
|
1849
|
-
` : "", g =
|
|
1849
|
+
` : "", g = o.map(({ varName: l, collection: p }) => {
|
|
1850
1850
|
const w = on(
|
|
1851
1851
|
p.fields,
|
|
1852
1852
|
i,
|
|
1853
1853
|
n
|
|
1854
1854
|
);
|
|
1855
|
-
return p.type === "auth" && sn(w), `${l} = await context.admin.collection("${p.name}").create(${
|
|
1856
|
-
}), f =
|
|
1855
|
+
return p.type === "auth" && sn(w), `${l} = await context.admin.collection("${p.name}").create(${et(w)});`;
|
|
1856
|
+
}), f = o.slice().reverse().map(
|
|
1857
1857
|
({ varName: l, collection: p }) => `await context.admin.collection("${p.name}").delete(${l}.id);`
|
|
1858
1858
|
), h = n.features.auth ? "context.agent" : "context.request", $ = n.features.auth ? `await context.agent.authenticateUser();
|
|
1859
1859
|
` : "";
|
|
@@ -1874,22 +1874,22 @@ function Nt(t, e, n, r) {
|
|
|
1874
1874
|
declarations: m,
|
|
1875
1875
|
setupSection: u,
|
|
1876
1876
|
requestAgent: h,
|
|
1877
|
-
modelDbData:
|
|
1878
|
-
|
|
1877
|
+
modelDbData: et(
|
|
1878
|
+
xt(e, i, {
|
|
1879
1879
|
forForm: !1,
|
|
1880
1880
|
authEnabled: n.features.auth
|
|
1881
1881
|
})
|
|
1882
1882
|
),
|
|
1883
|
-
modelFormData:
|
|
1884
|
-
|
|
1883
|
+
modelFormData: et(
|
|
1884
|
+
xt(e, i, {
|
|
1885
1885
|
forForm: !0,
|
|
1886
1886
|
authEnabled: n.features.auth
|
|
1887
1887
|
})
|
|
1888
1888
|
)
|
|
1889
1889
|
};
|
|
1890
1890
|
}
|
|
1891
|
-
function un(t, e, n, r,
|
|
1892
|
-
const { declarations: s, setupSection: i, requestAgent:
|
|
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
1893
|
return d`
|
|
1894
1894
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1895
1895
|
|
|
@@ -1898,24 +1898,24 @@ function un(t, e, n, r, o) {
|
|
|
1898
1898
|
|
|
1899
1899
|
describe("GET ${e.list}", () => {
|
|
1900
1900
|
it("should return a 200 status code", async (context) => {
|
|
1901
|
-
const response = await ${
|
|
1901
|
+
const response = await ${o}.get("${e.list}");
|
|
1902
1902
|
expect(response.status).toBe(200);
|
|
1903
1903
|
});
|
|
1904
1904
|
});
|
|
1905
1905
|
|
|
1906
1906
|
describe("GET ${e.new}", () => {
|
|
1907
1907
|
it("should return a 200 status code", async (context) => {
|
|
1908
|
-
const response = await ${
|
|
1908
|
+
const response = await ${o}.get("${e.new}");
|
|
1909
1909
|
expect(response.status).toBe(200);
|
|
1910
1910
|
});
|
|
1911
1911
|
});
|
|
1912
1912
|
|
|
1913
1913
|
describe("POST ${e.new}", () => {
|
|
1914
1914
|
it("should create a new ${t.displayName.toLowerCase()}", async (context) => {
|
|
1915
|
-
const response = await ${
|
|
1915
|
+
const response = await ${o}.post("${e.new}").type("form").send(${m});
|
|
1916
1916
|
expect(response.body.status).toBe(303);
|
|
1917
1917
|
|
|
1918
|
-
const response2 = await ${
|
|
1918
|
+
const response2 = await ${o}.get(response.body.location);
|
|
1919
1919
|
expect(response2.status).toBe(200);
|
|
1920
1920
|
});
|
|
1921
1921
|
});
|
|
@@ -1923,12 +1923,12 @@ function un(t, e, n, r, o) {
|
|
|
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 ${
|
|
1926
|
+
const response = await ${o}.get(\`${A(e.show, "id")}\`);
|
|
1927
1927
|
expect(response.status).toBe(200);
|
|
1928
1928
|
});
|
|
1929
1929
|
|
|
1930
1930
|
it("should return a 404 status code", async (context) => {
|
|
1931
|
-
const response = await ${
|
|
1931
|
+
const response = await ${o}.get("${e.show.replace("[id]", "non-existent")}");
|
|
1932
1932
|
expect(response.status).toBe(404);
|
|
1933
1933
|
});
|
|
1934
1934
|
});
|
|
@@ -1936,10 +1936,10 @@ function un(t, e, n, r, o) {
|
|
|
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 ${
|
|
1939
|
+
const response = await ${o}.post(\`${A(e.show, "id")}\`).type("form");
|
|
1940
1940
|
expect(response.body.status).toBe(303);
|
|
1941
1941
|
|
|
1942
|
-
const response2 = await ${
|
|
1942
|
+
const response2 = await ${o}.get(\`${A(e.show, "id")}\`);
|
|
1943
1943
|
expect(response2.status).toBe(404);
|
|
1944
1944
|
});
|
|
1945
1945
|
});
|
|
@@ -1947,7 +1947,7 @@ function un(t, e, n, r, o) {
|
|
|
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 ${
|
|
1950
|
+
const response = await ${o}.get(\`${A(e.edit, "id")}\`);
|
|
1951
1951
|
expect(response.status).toBe(200);
|
|
1952
1952
|
});
|
|
1953
1953
|
});
|
|
@@ -1955,19 +1955,19 @@ function un(t, e, n, r, o) {
|
|
|
1955
1955
|
describe("POST ${e.edit}", () => {
|
|
1956
1956
|
it("should update a ${t.displayName.toLowerCase()}", async (context) => {
|
|
1957
1957
|
const { id } = await context.admin.collection("${t.tableName}").create(${c});
|
|
1958
|
-
const response = await ${
|
|
1959
|
-
.post(\`${
|
|
1958
|
+
const response = await ${o}
|
|
1959
|
+
.post(\`${A(e.edit, "id")}\`)
|
|
1960
1960
|
.type("form")
|
|
1961
1961
|
.send(${m});
|
|
1962
1962
|
expect(response.body.status).toBe(303);
|
|
1963
|
-
expect(response.body.location).toBe(\`${
|
|
1963
|
+
expect(response.body.location).toBe(\`${A(e.show, "id")}\`);
|
|
1964
1964
|
});
|
|
1965
1965
|
});
|
|
1966
1966
|
});
|
|
1967
1967
|
`;
|
|
1968
1968
|
}
|
|
1969
|
-
function dn(t, e, n, r,
|
|
1970
|
-
const { declarations: s, setupSection: i, requestAgent:
|
|
1969
|
+
function dn(t, e, n, r, a) {
|
|
1970
|
+
const { declarations: s, setupSection: i, requestAgent: o, modelFormData: c } = jt(t, n, r, a);
|
|
1971
1971
|
return d`
|
|
1972
1972
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
1973
1973
|
|
|
@@ -1976,26 +1976,26 @@ function dn(t, e, n, r, o) {
|
|
|
1976
1976
|
|
|
1977
1977
|
describe("GET ${e}", () => {
|
|
1978
1978
|
it("should return a 200 status code", async (context) => {
|
|
1979
|
-
const response = await ${
|
|
1979
|
+
const response = await ${o}.get("${e}");
|
|
1980
1980
|
expect(response.status).toBe(200);
|
|
1981
1981
|
});
|
|
1982
1982
|
});
|
|
1983
1983
|
|
|
1984
1984
|
describe("POST ${e}", () => {
|
|
1985
1985
|
it("should submit the form successfully", async (context) => {
|
|
1986
|
-
const response = await ${
|
|
1986
|
+
const response = await ${o}.post("${e}").type("form").send(${c});
|
|
1987
1987
|
expect(response.body.status).toBe(200);
|
|
1988
1988
|
});
|
|
1989
1989
|
});
|
|
1990
1990
|
});
|
|
1991
1991
|
`;
|
|
1992
1992
|
}
|
|
1993
|
-
var
|
|
1993
|
+
var Ft = Object.freeze, pn = Object.defineProperty, fn = (t, e) => Ft(pn(t, "raw", { value: Ft(t.slice()) })), St;
|
|
1994
1994
|
function gn(t, e) {
|
|
1995
|
-
const n = t.replace(/^\/+|\/+$/g, ""), r = `${e}/${n}`,
|
|
1995
|
+
const n = t.replace(/^\/+|\/+$/g, ""), r = `${e}/${n}`, a = `/${n}`;
|
|
1996
1996
|
return {
|
|
1997
1997
|
pagePath: r,
|
|
1998
|
-
pageUrl:
|
|
1998
|
+
pageUrl: a
|
|
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
|
|
2009
|
+
function Nt(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
|
-
function
|
|
2016
|
-
const e = t.type === "select" ? `[${t.options.map((
|
|
2015
|
+
function Ct(t) {
|
|
2016
|
+
const e = t.type === "select" ? `[${t.options.map((a) => JSON.stringify(a.value)).join(", ")}]` : "";
|
|
2017
2017
|
let n;
|
|
2018
2018
|
switch (t.type) {
|
|
2019
2019
|
case "text":
|
|
@@ -2074,7 +2074,7 @@ function vn(t) {
|
|
|
2074
2074
|
if (n.type === "file" && n.maxSelect > 1) {
|
|
2075
2075
|
e.push({
|
|
2076
2076
|
name: n.name,
|
|
2077
|
-
schema:
|
|
2077
|
+
schema: Ct({ ...n, required: !1 })
|
|
2078
2078
|
}), e.push({
|
|
2079
2079
|
name: `${n.name}+`,
|
|
2080
2080
|
schema: "z.instanceof(File).array().optional()"
|
|
@@ -2084,7 +2084,7 @@ function vn(t) {
|
|
|
2084
2084
|
});
|
|
2085
2085
|
continue;
|
|
2086
2086
|
}
|
|
2087
|
-
e.push({ name: n.name, schema:
|
|
2087
|
+
e.push({ name: n.name, schema: Ct(n) });
|
|
2088
2088
|
}
|
|
2089
2089
|
return e;
|
|
2090
2090
|
}
|
|
@@ -2100,19 +2100,19 @@ function wn(t, e) {
|
|
|
2100
2100
|
`;
|
|
2101
2101
|
}
|
|
2102
2102
|
function yn(t, e) {
|
|
2103
|
-
const n =
|
|
2103
|
+
const n = L(e), r = [
|
|
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
|
-
...
|
|
2108
|
+
...at(n)
|
|
2109
2109
|
];
|
|
2110
2110
|
return [...new Set(r)];
|
|
2111
2111
|
}
|
|
2112
2112
|
function $n(t, e) {
|
|
2113
2113
|
const r = e.filter(
|
|
2114
|
-
(
|
|
2115
|
-
).map((
|
|
2114
|
+
(a) => a.type === "select"
|
|
2115
|
+
).map((a) => zt(a)).join(`
|
|
2116
2116
|
|
|
2117
2117
|
`);
|
|
2118
2118
|
return d`
|
|
@@ -2127,9 +2127,9 @@ function $n(t, e) {
|
|
|
2127
2127
|
}
|
|
2128
2128
|
function xn(t, e) {
|
|
2129
2129
|
const n = yn(t, e).join(`
|
|
2130
|
-
`), r = $n(t, e),
|
|
2131
|
-
`), s =
|
|
2132
|
-
return d(
|
|
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([`
|
|
2133
2133
|
<script lang="ts">
|
|
2134
2134
|
`, `
|
|
2135
2135
|
|
|
@@ -2152,10 +2152,10 @@ function xn(t, e) {
|
|
|
2152
2152
|
</form>
|
|
2153
2153
|
</div>
|
|
2154
2154
|
</section>
|
|
2155
|
-
`])), n, r, t.displayName, s,
|
|
2155
|
+
`])), n, r, t.displayName, s, a);
|
|
2156
2156
|
}
|
|
2157
2157
|
function Fn(t, e) {
|
|
2158
|
-
const n =
|
|
2158
|
+
const n = Nt(e), r = d`
|
|
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}";
|
|
@@ -2187,14 +2187,14 @@ function Fn(t, e) {
|
|
|
2187
2187
|
function V(t, e) {
|
|
2188
2188
|
return {
|
|
2189
2189
|
path: t,
|
|
2190
|
-
language:
|
|
2190
|
+
language: P(t),
|
|
2191
2191
|
content: e
|
|
2192
2192
|
};
|
|
2193
2193
|
}
|
|
2194
2194
|
async function Sn(t) {
|
|
2195
2195
|
const { modelPath: e, fields: n } = hn(t.argv);
|
|
2196
|
-
|
|
2197
|
-
const r =
|
|
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(
|
|
2198
2198
|
t
|
|
2199
2199
|
), m = [
|
|
2200
2200
|
V(`${i}/+page.svelte`, xn(r, s)),
|
|
@@ -2203,14 +2203,14 @@ async function Sn(t) {
|
|
|
2203
2203
|
`${i}/server.test.ts`,
|
|
2204
2204
|
dn(
|
|
2205
2205
|
r,
|
|
2206
|
-
|
|
2206
|
+
o,
|
|
2207
2207
|
s,
|
|
2208
2208
|
t,
|
|
2209
2209
|
c
|
|
2210
2210
|
)
|
|
2211
2211
|
),
|
|
2212
2212
|
V(`src/lib/schemas/${r.name}.ts`, wn(r, s))
|
|
2213
|
-
], g =
|
|
2213
|
+
], g = L(s);
|
|
2214
2214
|
return {
|
|
2215
2215
|
creates: m,
|
|
2216
2216
|
modifies: [],
|
|
@@ -2224,11 +2224,11 @@ const Cn = "generate-form", _n = "1.0.7", kn = "src/patterns/generate/form", Rn
|
|
|
2224
2224
|
async function Pn(t) {
|
|
2225
2225
|
const e = await Sn(t);
|
|
2226
2226
|
if (t.env !== "runtime")
|
|
2227
|
-
return
|
|
2227
|
+
return S(e);
|
|
2228
2228
|
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
2229
|
-
return n(await
|
|
2229
|
+
return n(await S(e), t);
|
|
2230
2230
|
}
|
|
2231
|
-
const
|
|
2231
|
+
const En = {
|
|
2232
2232
|
version: _n,
|
|
2233
2233
|
slug: Cn,
|
|
2234
2234
|
source: kn,
|
|
@@ -2249,7 +2249,7 @@ const zn = {
|
|
|
2249
2249
|
},
|
|
2250
2250
|
baseline: "velastack",
|
|
2251
2251
|
generate: Pn
|
|
2252
|
-
},
|
|
2252
|
+
}, In = ["text"], zn = {
|
|
2253
2253
|
string: "text",
|
|
2254
2254
|
boolean: "bool",
|
|
2255
2255
|
geopoint: "geoPoint",
|
|
@@ -2276,11 +2276,11 @@ const zn = {
|
|
|
2276
2276
|
geoPoint: "geoPoint",
|
|
2277
2277
|
relation: "relation"
|
|
2278
2278
|
};
|
|
2279
|
-
function
|
|
2279
|
+
function Mn(t) {
|
|
2280
2280
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t) ? t : `'${t}'`;
|
|
2281
2281
|
}
|
|
2282
2282
|
function Bn(t, e) {
|
|
2283
|
-
const n = t.type === "select" ? `[${(t.options ?? []).map((
|
|
2283
|
+
const n = t.type === "select" ? `[${(t.options ?? []).map((a) => JSON.stringify(a.value)).join(", ")}]` : "";
|
|
2284
2284
|
let r;
|
|
2285
2285
|
switch (t.type) {
|
|
2286
2286
|
case "text":
|
|
@@ -2338,114 +2338,114 @@ function Bn(t, e) {
|
|
|
2338
2338
|
default:
|
|
2339
2339
|
return t.type;
|
|
2340
2340
|
}
|
|
2341
|
-
return
|
|
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
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function it(t, e, n) {
|
|
2344
2344
|
const r = [];
|
|
2345
2345
|
n.includeModelFields && (r.push({ name: "id", type: "text", required: !1 }), r.push({ name: "collectionId", type: "text", required: !1 }));
|
|
2346
|
-
for (const
|
|
2347
|
-
if (
|
|
2348
|
-
r.push({ ...
|
|
2346
|
+
for (const o of e) {
|
|
2347
|
+
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
2349
|
continue;
|
|
2350
2350
|
}
|
|
2351
|
-
r.push(
|
|
2351
|
+
r.push(o);
|
|
2352
2352
|
}
|
|
2353
|
-
const
|
|
2353
|
+
const a = r.map((o) => `${Mn(o.name)}: ${Bn(o, n)}`).join(`,
|
|
2354
2354
|
`), s = n.includeModelFields ? `
|
|
2355
2355
|
import type { Schemas } from "pocketbase-svelte";` : "", i = n.includeModelFields ? ` satisfies Schemas["${t.tableName}"]` : "";
|
|
2356
2356
|
return d`
|
|
2357
2357
|
import { z } from "zod/v3";${s}
|
|
2358
2358
|
|
|
2359
2359
|
export const ${t.schemaName} = z.object({
|
|
2360
|
-
${
|
|
2360
|
+
${a}
|
|
2361
2361
|
})${i};
|
|
2362
2362
|
`;
|
|
2363
2363
|
}
|
|
2364
2364
|
function Dn(t) {
|
|
2365
|
-
const e =
|
|
2365
|
+
const e = zn[t];
|
|
2366
2366
|
if (!e)
|
|
2367
2367
|
throw new Error(`Unsupported collection field type "${t}" when generating from collection`);
|
|
2368
2368
|
return e;
|
|
2369
2369
|
}
|
|
2370
|
-
function
|
|
2371
|
-
const r = e.find((
|
|
2370
|
+
function lt(t, e, n) {
|
|
2371
|
+
const r = e.find((o) => o.name === t.tableName);
|
|
2372
2372
|
if (!r)
|
|
2373
2373
|
throw new Error(`Collection "${t.tableName}" not found`);
|
|
2374
|
-
const
|
|
2375
|
-
for (const
|
|
2376
|
-
if (
|
|
2374
|
+
const a = Tt(e), s = new Map(e.map((o) => [o.id, o])), i = [];
|
|
2375
|
+
for (const o of r.fields) {
|
|
2376
|
+
if (o.name === "id" || o.system)
|
|
2377
2377
|
continue;
|
|
2378
|
-
const c = Dn(
|
|
2378
|
+
const c = Dn(o.type), m = !!o.required, g = ot(o.name);
|
|
2379
2379
|
if (c === "relation") {
|
|
2380
|
-
const f =
|
|
2380
|
+
const f = o.collectionId ? s.get(o.collectionId) : void 0;
|
|
2381
2381
|
if (!f)
|
|
2382
2382
|
continue;
|
|
2383
|
-
const h =
|
|
2383
|
+
const h = z(f.name, n);
|
|
2384
2384
|
i.push({
|
|
2385
|
-
name:
|
|
2385
|
+
name: o.name,
|
|
2386
2386
|
title: g,
|
|
2387
2387
|
type: "relation",
|
|
2388
2388
|
required: m,
|
|
2389
2389
|
collectionId: f.id,
|
|
2390
|
-
maxSelect:
|
|
2391
|
-
displayField:
|
|
2390
|
+
maxSelect: o.maxSelect ?? 1,
|
|
2391
|
+
displayField: a[f.name] ?? "id",
|
|
2392
2392
|
relatedModel: h,
|
|
2393
|
-
singularRelationName:
|
|
2393
|
+
singularRelationName: j(
|
|
2394
2394
|
`${t.displayName} ${h.displayName}`
|
|
2395
2395
|
),
|
|
2396
|
-
pluralRelationName:
|
|
2396
|
+
pluralRelationName: j(
|
|
2397
2397
|
`${t.displayName} ${h.pluralDisplayName}`
|
|
2398
2398
|
),
|
|
2399
|
-
isCurrentUser: n.features.auth && f.name === "users" && /user|owner|author/i.test(
|
|
2399
|
+
isCurrentUser: n.features.auth && f.name === "users" && /user|owner|author/i.test(o.name)
|
|
2400
2400
|
});
|
|
2401
2401
|
continue;
|
|
2402
2402
|
}
|
|
2403
2403
|
if (c === "select") {
|
|
2404
2404
|
i.push({
|
|
2405
|
-
name:
|
|
2405
|
+
name: o.name,
|
|
2406
2406
|
title: g,
|
|
2407
2407
|
type: "select",
|
|
2408
2408
|
required: m,
|
|
2409
|
-
maxSelect:
|
|
2410
|
-
options: (
|
|
2409
|
+
maxSelect: o.maxSelect ?? 1,
|
|
2410
|
+
options: (o.values ?? []).map((f) => ({ label: f, value: f }))
|
|
2411
2411
|
});
|
|
2412
2412
|
continue;
|
|
2413
2413
|
}
|
|
2414
2414
|
if (c === "file") {
|
|
2415
2415
|
i.push({
|
|
2416
|
-
name:
|
|
2416
|
+
name: o.name,
|
|
2417
2417
|
title: g,
|
|
2418
2418
|
type: "file",
|
|
2419
2419
|
required: m,
|
|
2420
|
-
maxSelect:
|
|
2420
|
+
maxSelect: o.maxSelect ?? 1
|
|
2421
2421
|
});
|
|
2422
2422
|
continue;
|
|
2423
2423
|
}
|
|
2424
2424
|
if (c === "autodate") {
|
|
2425
2425
|
i.push({
|
|
2426
|
-
name:
|
|
2426
|
+
name: o.name,
|
|
2427
2427
|
title: g,
|
|
2428
2428
|
type: "autodate",
|
|
2429
2429
|
required: m,
|
|
2430
|
-
onCreate:
|
|
2431
|
-
onUpdate:
|
|
2430
|
+
onCreate: o.onCreate ?? o.name.includes("create"),
|
|
2431
|
+
onUpdate: o.onUpdate ?? o.name.includes("update")
|
|
2432
2432
|
});
|
|
2433
2433
|
continue;
|
|
2434
2434
|
}
|
|
2435
2435
|
i.push({
|
|
2436
|
-
name:
|
|
2436
|
+
name: o.name,
|
|
2437
2437
|
title: g,
|
|
2438
2438
|
type: c,
|
|
2439
2439
|
required: m
|
|
2440
2440
|
});
|
|
2441
2441
|
}
|
|
2442
|
-
return i.filter((
|
|
2442
|
+
return i.filter((o) => o.name !== "id");
|
|
2443
2443
|
}
|
|
2444
|
-
function
|
|
2444
|
+
function Ot(t) {
|
|
2445
2445
|
const e = t.filter((n) => n.type === "relation").map((n) => n.name);
|
|
2446
2446
|
return e.length > 0 ? e.join(",") : void 0;
|
|
2447
2447
|
}
|
|
2448
|
-
function
|
|
2448
|
+
function Lt(t) {
|
|
2449
2449
|
const e = /* @__PURE__ */ new Set(), n = [];
|
|
2450
2450
|
for (const r of t)
|
|
2451
2451
|
r.type === "relation" && (e.has(r.relatedModel.tableName) || (e.add(r.relatedModel.tableName), n.push(r.relatedModel)));
|
|
@@ -2497,58 +2497,58 @@ function An(t) {
|
|
|
2497
2497
|
);
|
|
2498
2498
|
return { modelPath: e, fields: n };
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function jn(t, e) {
|
|
2501
2501
|
return {
|
|
2502
2502
|
path: t,
|
|
2503
|
-
language:
|
|
2503
|
+
language: P(t),
|
|
2504
2504
|
content: e
|
|
2505
2505
|
};
|
|
2506
2506
|
}
|
|
2507
|
-
async function
|
|
2508
|
-
|
|
2509
|
-
const r =
|
|
2507
|
+
async function Nn(t, e, n) {
|
|
2508
|
+
Z(e);
|
|
2509
|
+
const r = z(e, t);
|
|
2510
2510
|
if (n.length > 0) {
|
|
2511
|
-
const i = await
|
|
2511
|
+
const i = await K(n, r, t);
|
|
2512
2512
|
return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
|
|
2513
2513
|
}
|
|
2514
|
-
const
|
|
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
2515
|
return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
|
|
2516
2516
|
}
|
|
2517
|
-
async function
|
|
2518
|
-
const { modelPath: e, fields: n } = An(t.argv), { model: r, fields:
|
|
2517
|
+
async function On(t) {
|
|
2518
|
+
const { modelPath: e, fields: n } = An(t.argv), { model: r, fields: a, auth: s, shouldCreateCollection: i } = await Nn(
|
|
2519
2519
|
t,
|
|
2520
2520
|
e,
|
|
2521
2521
|
n
|
|
2522
|
-
),
|
|
2522
|
+
), o = `src/lib/schemas/${r.name}.ts`, c = it(r, a, {
|
|
2523
2523
|
includeModelFields: !0,
|
|
2524
2524
|
forForm: !0
|
|
2525
2525
|
});
|
|
2526
2526
|
return {
|
|
2527
|
-
creates: [
|
|
2527
|
+
creates: [jn(o, c)],
|
|
2528
2528
|
modifies: [],
|
|
2529
2529
|
deletes: [],
|
|
2530
2530
|
components: [],
|
|
2531
2531
|
packages: [],
|
|
2532
|
-
collections: i ? [qt(r,
|
|
2532
|
+
collections: i ? [qt(r, a, s)] : []
|
|
2533
2533
|
};
|
|
2534
2534
|
}
|
|
2535
|
-
const
|
|
2535
|
+
const Ln = "generate-resource", qn = "1.0.7", Vn = "src/patterns/generate/resource", Un = "/generate/resource";
|
|
2536
2536
|
async function Hn(t) {
|
|
2537
|
-
const e = await
|
|
2537
|
+
const e = await On(t);
|
|
2538
2538
|
if (t.env !== "runtime")
|
|
2539
|
-
return
|
|
2540
|
-
const { createCollections: n } = await import("./collections-
|
|
2539
|
+
return S(e);
|
|
2540
|
+
const { createCollections: n } = await import("./collections-t61Ot2Ax.js"), r = await n(
|
|
2541
2541
|
e.collections,
|
|
2542
2542
|
t
|
|
2543
|
-
),
|
|
2543
|
+
), a = {
|
|
2544
2544
|
...e,
|
|
2545
2545
|
creates: [...e.creates, ...r]
|
|
2546
2546
|
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
2547
|
-
return s(await
|
|
2547
|
+
return s(await S(a), t);
|
|
2548
2548
|
}
|
|
2549
2549
|
const Gn = {
|
|
2550
2550
|
version: qn,
|
|
2551
|
-
slug:
|
|
2551
|
+
slug: Ln,
|
|
2552
2552
|
source: Vn,
|
|
2553
2553
|
docs: Un,
|
|
2554
2554
|
plan: "open",
|
|
@@ -2568,17 +2568,17 @@ const Gn = {
|
|
|
2568
2568
|
baseline: "velastack",
|
|
2569
2569
|
generate: Hn
|
|
2570
2570
|
};
|
|
2571
|
-
var
|
|
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
2572
|
function Jn(t) {
|
|
2573
2573
|
const [e, ...n] = t;
|
|
2574
2574
|
if (!e)
|
|
2575
2575
|
throw new Error("Invalid command arguments. Expected: <model> [fields...]");
|
|
2576
2576
|
return { modelPath: e, fields: n };
|
|
2577
2577
|
}
|
|
2578
|
-
function
|
|
2578
|
+
function _(t, e) {
|
|
2579
2579
|
return {
|
|
2580
2580
|
path: t,
|
|
2581
|
-
language:
|
|
2581
|
+
language: P(t),
|
|
2582
2582
|
content: e
|
|
2583
2583
|
};
|
|
2584
2584
|
}
|
|
@@ -2588,27 +2588,27 @@ function Vt(t) {
|
|
|
2588
2588
|
function Ut(t) {
|
|
2589
2589
|
return [...new Set(t.filter(Boolean))];
|
|
2590
2590
|
}
|
|
2591
|
-
function
|
|
2591
|
+
function ct(t) {
|
|
2592
2592
|
return t.filter(
|
|
2593
2593
|
(e) => e.type === "select"
|
|
2594
|
-
).map((e) =>
|
|
2594
|
+
).map((e) => zt(e)).join(`
|
|
2595
2595
|
|
|
2596
2596
|
`);
|
|
2597
2597
|
}
|
|
2598
2598
|
function Ht(t, e) {
|
|
2599
|
-
return
|
|
2599
|
+
return Lt(t).map(
|
|
2600
2600
|
(n) => `const ${n.pluralName} = await ${e}.collection("${n.tableName}").getFullList();`
|
|
2601
2601
|
).join(`
|
|
2602
2602
|
`);
|
|
2603
2603
|
}
|
|
2604
2604
|
function Gt(t) {
|
|
2605
|
-
return
|
|
2605
|
+
return Lt(t).map((e) => e.pluralName).join(", ");
|
|
2606
2606
|
}
|
|
2607
2607
|
function Zn(t) {
|
|
2608
2608
|
return t.features.auth ? "locals.pb" : "locals.admin";
|
|
2609
2609
|
}
|
|
2610
2610
|
function Wt(t, e, n = !1) {
|
|
2611
|
-
const r =
|
|
2611
|
+
const r = ct(e);
|
|
2612
2612
|
return d`
|
|
2613
2613
|
${r}
|
|
2614
2614
|
${n ? "let { data, params } = $props();" : "let { data } = $props();"}
|
|
@@ -2620,21 +2620,21 @@ function Wt(t, e, n = !1) {
|
|
|
2620
2620
|
const { form: formData } = form;
|
|
2621
2621
|
`;
|
|
2622
2622
|
}
|
|
2623
|
-
function
|
|
2624
|
-
const r = n.some((
|
|
2623
|
+
function Kn(t, e, n) {
|
|
2624
|
+
const r = n.some((o) => o.type === "select"), a = Ut([
|
|
2625
2625
|
'import { untrack } from "svelte";',
|
|
2626
2626
|
'import { superForm } from "sveltekit-superforms";',
|
|
2627
2627
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
2628
2628
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2629
|
-
...
|
|
2629
|
+
...at(L(n)),
|
|
2630
2630
|
'import { Button } from "$lib/components/ui/button";',
|
|
2631
2631
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
2632
2632
|
'import * as Form from "$lib/components/ui/form";',
|
|
2633
2633
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2634
2634
|
]).join(`
|
|
2635
|
-
`), s = n.map((
|
|
2635
|
+
`), s = n.map((o) => rt(o)).join(`
|
|
2636
2636
|
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2637
|
-
return d(
|
|
2637
|
+
return d(kt || (kt = X([`
|
|
2638
2638
|
<script lang="ts">
|
|
2639
2639
|
`, `
|
|
2640
2640
|
`, `
|
|
@@ -2661,23 +2661,23 @@ function Xn(t, e, n) {
|
|
|
2661
2661
|
</form>
|
|
2662
2662
|
</div>
|
|
2663
2663
|
</section>
|
|
2664
|
-
`])),
|
|
2664
|
+
`])), a, Wt(t, n), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2665
2665
|
}
|
|
2666
|
-
function
|
|
2667
|
-
const r = n.some((
|
|
2666
|
+
function Xn(t, e, n) {
|
|
2667
|
+
const r = n.some((o) => o.type === "select"), a = Ut([
|
|
2668
2668
|
'import { untrack } from "svelte";',
|
|
2669
2669
|
'import { superForm } from "sveltekit-superforms";',
|
|
2670
2670
|
'import { zodClient } from "sveltekit-superforms/adapters";',
|
|
2671
2671
|
`import { ${t.schemaName} } from "$lib/schemas/${t.name}";`,
|
|
2672
|
-
...
|
|
2672
|
+
...at(L(n)),
|
|
2673
2673
|
'import { Button } from "$lib/components/ui/button";',
|
|
2674
2674
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
2675
2675
|
'import * as Form from "$lib/components/ui/form";',
|
|
2676
2676
|
r ? 'import type { Models } from "pocketbase-svelte";' : ""
|
|
2677
2677
|
]).join(`
|
|
2678
|
-
`), s = n.map((
|
|
2678
|
+
`), s = n.map((o) => rt(o)).join(`
|
|
2679
2679
|
`), i = Vt(n) ? ' enctype="multipart/form-data"' : "";
|
|
2680
|
-
return d(
|
|
2680
|
+
return d(Rt || (Rt = X([`
|
|
2681
2681
|
<script lang="ts">
|
|
2682
2682
|
`, `
|
|
2683
2683
|
`, `
|
|
@@ -2731,23 +2731,23 @@ function Yn(t, e, n) {
|
|
|
2731
2731
|
</form>
|
|
2732
2732
|
</div>
|
|
2733
2733
|
</section>
|
|
2734
|
-
`])),
|
|
2734
|
+
`])), a, Wt(t, n, !0), t.displayName.toLowerCase(), e.list, i, s, e.list);
|
|
2735
2735
|
}
|
|
2736
|
-
function
|
|
2737
|
-
const r = n.some((
|
|
2736
|
+
function Yn(t, e, n) {
|
|
2737
|
+
const r = n.some((o) => o.type === "select"), a = r ? `${ct(n)}` : "", s = n.map((o) => {
|
|
2738
2738
|
let c = "{ getValue }", m = "{ value: getValue() }";
|
|
2739
|
-
return
|
|
2740
|
-
columnHelper.accessor("${
|
|
2741
|
-
header: ({ column }) => renderComponent(ColumnHeader, { column, title: "${
|
|
2742
|
-
cell: (${c}) => renderComponent(Cells.${
|
|
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`
|
|
2740
|
+
columnHelper.accessor("${o.name}", {
|
|
2741
|
+
header: ({ column }) => renderComponent(ColumnHeader, { column, title: "${o.title}" }),
|
|
2742
|
+
cell: (${c}) => renderComponent(Cells.${o.type.charAt(0).toUpperCase() + o.type.slice(1)}Cell, ${m})
|
|
2743
2743
|
})
|
|
2744
2744
|
`;
|
|
2745
2745
|
}).join(`,
|
|
2746
|
-
`), i = n.filter((
|
|
2747
|
-
(
|
|
2746
|
+
`), i = n.filter((o) => o.type === "select").map(
|
|
2747
|
+
(o) => `<FacetedFilter column={table.getColumn("${o.name}")!} title="${o.title}" options={Object.values(${o.name}Labels)} />`
|
|
2748
2748
|
).join(`
|
|
2749
2749
|
`);
|
|
2750
|
-
return d(
|
|
2750
|
+
return d(Pt || (Pt = X([`
|
|
2751
2751
|
<script lang="ts">
|
|
2752
2752
|
import {
|
|
2753
2753
|
type ColumnFiltersState,
|
|
@@ -3121,21 +3121,21 @@ function Kn(t, e, n) {
|
|
|
3121
3121
|
<Pagination {table} />
|
|
3122
3122
|
</div>
|
|
3123
3123
|
</section>
|
|
3124
|
-
`])), r ? 'import { FacetedFilter } from "$lib/components/ui/faceted-filter";' : "",
|
|
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());
|
|
3125
3125
|
}
|
|
3126
3126
|
function Qn(t, e, n) {
|
|
3127
|
-
const r =
|
|
3127
|
+
const r = Ot(e), a = r ? `{ expand: "${r}" }` : "";
|
|
3128
3128
|
return d`
|
|
3129
3129
|
export const load = async ({ locals }) => {
|
|
3130
|
-
const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${
|
|
3130
|
+
const ${t.pluralName} = await ${n}.collection("${t.tableName}").getFullList(${a});
|
|
3131
3131
|
return { ${t.pluralName} };
|
|
3132
3132
|
};
|
|
3133
3133
|
`;
|
|
3134
3134
|
}
|
|
3135
|
-
function tr(t, e, n, r,
|
|
3136
|
-
const s = Ht(n, r), i = Gt(n),
|
|
3135
|
+
function tr(t, e, n, r, a) {
|
|
3136
|
+
const s = Ht(n, r), i = Gt(n), o = i ? `, ${i}` : "", c = n.find(
|
|
3137
3137
|
(g) => g.type === "relation" && g.isCurrentUser
|
|
3138
|
-
), m =
|
|
3138
|
+
), m = a && c ? d`
|
|
3139
3139
|
{
|
|
3140
3140
|
...form.data,
|
|
3141
3141
|
${c.name}: locals.pb.authStore.record?.id
|
|
@@ -3150,7 +3150,7 @@ function tr(t, e, n, r, o) {
|
|
|
3150
3150
|
|
|
3151
3151
|
export const load = async ({ locals }) => {
|
|
3152
3152
|
${s}
|
|
3153
|
-
return { form: await superValidate(zod(${t.schemaName}))${
|
|
3153
|
+
return { form: await superValidate(zod(${t.schemaName}))${o} };
|
|
3154
3154
|
};
|
|
3155
3155
|
|
|
3156
3156
|
export const actions = {
|
|
@@ -3175,7 +3175,7 @@ function tr(t, e, n, r, o) {
|
|
|
3175
3175
|
`;
|
|
3176
3176
|
}
|
|
3177
3177
|
function er(t, e, n, r) {
|
|
3178
|
-
const
|
|
3178
|
+
const a = Ot(n), s = a ? `, { expand: "${a}" }` : "";
|
|
3179
3179
|
return d`
|
|
3180
3180
|
import { error, redirect } from "@sveltejs/kit";
|
|
3181
3181
|
|
|
@@ -3197,16 +3197,16 @@ function er(t, e, n, r) {
|
|
|
3197
3197
|
`;
|
|
3198
3198
|
}
|
|
3199
3199
|
function nr(t, e, n) {
|
|
3200
|
-
const r = n.some((m) => m.type === "select"),
|
|
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
3201
|
'import { Button } from "$lib/components/ui/button";',
|
|
3202
3202
|
'import ArrowLeftIcon from "@lucide/svelte/icons/arrow-left";',
|
|
3203
|
-
r ||
|
|
3204
|
-
|
|
3203
|
+
r || a ? 'import { Badge } from "$lib/components/ui/badge";' : "",
|
|
3204
|
+
a ? 'import CircleArrowRightIcon from "@lucide/svelte/icons/circle-arrow-right";' : "",
|
|
3205
3205
|
s ? 'import FileIcon from "@lucide/svelte/icons/file";' : ""
|
|
3206
3206
|
].filter(Boolean).join(`
|
|
3207
|
-
`),
|
|
3207
|
+
`), o = ct(n), c = n.map((m) => Ce(t, m)).join(`
|
|
3208
3208
|
`);
|
|
3209
|
-
return d(
|
|
3209
|
+
return d(Et || (Et = X([`
|
|
3210
3210
|
<script lang="ts">
|
|
3211
3211
|
`, `
|
|
3212
3212
|
`, `
|
|
@@ -3238,10 +3238,10 @@ function nr(t, e, n) {
|
|
|
3238
3238
|
</div>
|
|
3239
3239
|
</div>
|
|
3240
3240
|
</section>
|
|
3241
|
-
`])), i,
|
|
3241
|
+
`])), i, o, t.displayName, e.list, c, e.list, t.name);
|
|
3242
3242
|
}
|
|
3243
3243
|
function rr(t, e, n, r) {
|
|
3244
|
-
const
|
|
3244
|
+
const a = Ht(n, r), s = Gt(n), i = s ? `, ${s}` : "";
|
|
3245
3245
|
return d`
|
|
3246
3246
|
import { error, fail, redirect } from "@sveltejs/kit";
|
|
3247
3247
|
import { setPocketbaseErrors, setDefaultData } from "@velastack/pocketbase";
|
|
@@ -3256,7 +3256,7 @@ function rr(t, e, n, r) {
|
|
|
3256
3256
|
} catch {
|
|
3257
3257
|
throw error(404, "Not found");
|
|
3258
3258
|
}
|
|
3259
|
-
${
|
|
3259
|
+
${a}
|
|
3260
3260
|
return { form: await superValidate(${t.name}, zod(${t.schemaName}))${i} };
|
|
3261
3261
|
};
|
|
3262
3262
|
|
|
@@ -3283,81 +3283,81 @@ function rr(t, e, n, r) {
|
|
|
3283
3283
|
`;
|
|
3284
3284
|
}
|
|
3285
3285
|
async function ar(t, e, n) {
|
|
3286
|
-
|
|
3287
|
-
const r =
|
|
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(
|
|
3288
3288
|
t
|
|
3289
3289
|
);
|
|
3290
3290
|
if (n.length > 0) {
|
|
3291
|
-
const i = await
|
|
3291
|
+
const i = await K(n, r, t);
|
|
3292
3292
|
return {
|
|
3293
3293
|
model: r,
|
|
3294
3294
|
fields: i.fields,
|
|
3295
3295
|
auth: i.auth,
|
|
3296
3296
|
shouldCreateCollection: !0,
|
|
3297
|
-
collections:
|
|
3297
|
+
collections: a
|
|
3298
3298
|
};
|
|
3299
3299
|
}
|
|
3300
|
-
const s =
|
|
3300
|
+
const s = lt(r, a, t);
|
|
3301
3301
|
return {
|
|
3302
3302
|
model: r,
|
|
3303
3303
|
fields: s,
|
|
3304
3304
|
auth: void 0,
|
|
3305
3305
|
shouldCreateCollection: !1,
|
|
3306
|
-
collections:
|
|
3306
|
+
collections: a
|
|
3307
3307
|
};
|
|
3308
3308
|
}
|
|
3309
3309
|
async function or(t) {
|
|
3310
|
-
const { modelPath: e, fields: n } = Jn(t.argv), { model: r, fields:
|
|
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
3311
|
(u) => !(u.type === "relation" && u.isCurrentUser)
|
|
3312
3312
|
), h = [
|
|
3313
|
-
|
|
3313
|
+
_(
|
|
3314
3314
|
`src/lib/schemas/${r.name}.ts`,
|
|
3315
|
-
|
|
3315
|
+
it(r, a, {
|
|
3316
3316
|
includeModelFields: !0,
|
|
3317
3317
|
forForm: !0
|
|
3318
3318
|
})
|
|
3319
3319
|
),
|
|
3320
|
-
|
|
3320
|
+
_(
|
|
3321
3321
|
`${c.list}/+page.server.ts`,
|
|
3322
3322
|
Qn(r, f, g)
|
|
3323
3323
|
),
|
|
3324
|
-
|
|
3324
|
+
_(
|
|
3325
3325
|
`${c.list}/+page.svelte`,
|
|
3326
|
-
|
|
3326
|
+
Yn(r, m, f)
|
|
3327
3327
|
),
|
|
3328
|
-
|
|
3328
|
+
_(
|
|
3329
3329
|
`${c.new}/+page.server.ts`,
|
|
3330
3330
|
tr(r, m, f, g, t.features.auth)
|
|
3331
3331
|
),
|
|
3332
|
-
|
|
3333
|
-
|
|
3332
|
+
_(`${c.new}/+page.svelte`, Kn(r, m, f)),
|
|
3333
|
+
_(
|
|
3334
3334
|
`${c.show}/+page.server.ts`,
|
|
3335
3335
|
er(r, m, f, g)
|
|
3336
3336
|
),
|
|
3337
|
-
|
|
3337
|
+
_(
|
|
3338
3338
|
`${c.show}/+page.svelte`,
|
|
3339
3339
|
nr(r, m, f)
|
|
3340
3340
|
),
|
|
3341
|
-
|
|
3341
|
+
_(
|
|
3342
3342
|
`${c.edit}/+page.server.ts`,
|
|
3343
3343
|
rr(r, m, f, g)
|
|
3344
3344
|
),
|
|
3345
|
-
|
|
3345
|
+
_(
|
|
3346
3346
|
`${c.edit}/+page.svelte`,
|
|
3347
|
-
|
|
3347
|
+
Xn(r, m, f)
|
|
3348
3348
|
),
|
|
3349
|
-
|
|
3349
|
+
_(
|
|
3350
3350
|
`${c.list}/server.test.ts`,
|
|
3351
3351
|
un(
|
|
3352
3352
|
r,
|
|
3353
3353
|
m,
|
|
3354
|
-
|
|
3354
|
+
a,
|
|
3355
3355
|
t,
|
|
3356
|
-
|
|
3356
|
+
o
|
|
3357
3357
|
)
|
|
3358
3358
|
)
|
|
3359
3359
|
], $ = [
|
|
3360
|
-
...
|
|
3360
|
+
...L(f),
|
|
3361
3361
|
"button",
|
|
3362
3362
|
"table",
|
|
3363
3363
|
"data-table",
|
|
@@ -3380,22 +3380,22 @@ async function or(t) {
|
|
|
3380
3380
|
deletes: [],
|
|
3381
3381
|
components: [...new Set($)],
|
|
3382
3382
|
packages: ["@tanstack/table-core"],
|
|
3383
|
-
collections: i ? [qt(r,
|
|
3383
|
+
collections: i ? [qt(r, a, s)] : []
|
|
3384
3384
|
};
|
|
3385
3385
|
}
|
|
3386
3386
|
const sr = "generate-scaffold", ir = "1.0.7", lr = "src/patterns/generate/scaffold", cr = "/generate/scaffold";
|
|
3387
3387
|
async function mr(t) {
|
|
3388
3388
|
const e = await or(t);
|
|
3389
3389
|
if (t.env !== "runtime")
|
|
3390
|
-
return
|
|
3391
|
-
const { createCollections: n } = await import("./collections-
|
|
3390
|
+
return S(e);
|
|
3391
|
+
const { createCollections: n } = await import("./collections-t61Ot2Ax.js"), r = await n(
|
|
3392
3392
|
e.collections,
|
|
3393
3393
|
t
|
|
3394
|
-
),
|
|
3394
|
+
), a = {
|
|
3395
3395
|
...e,
|
|
3396
3396
|
creates: [...e.creates, ...r]
|
|
3397
3397
|
}, { writeResult: s } = await import("./write-result-CbUTMeAc.js");
|
|
3398
|
-
return s(await
|
|
3398
|
+
return s(await S(a), t);
|
|
3399
3399
|
}
|
|
3400
3400
|
const ur = {
|
|
3401
3401
|
version: ir,
|
|
@@ -3430,31 +3430,31 @@ function dr(t) {
|
|
|
3430
3430
|
function pr(t, e) {
|
|
3431
3431
|
return {
|
|
3432
3432
|
path: t,
|
|
3433
|
-
language:
|
|
3433
|
+
language: P(t),
|
|
3434
3434
|
content: e
|
|
3435
3435
|
};
|
|
3436
3436
|
}
|
|
3437
3437
|
async function fr(t, e, n) {
|
|
3438
|
-
|
|
3439
|
-
const r =
|
|
3438
|
+
Z(e);
|
|
3439
|
+
const r = z(e, t);
|
|
3440
3440
|
if (n.length > 0) {
|
|
3441
|
-
const i = await
|
|
3441
|
+
const i = await K(n, r, t);
|
|
3442
3442
|
return { model: r, fields: i.fields, includeModelFields: !1 };
|
|
3443
3443
|
}
|
|
3444
|
-
const
|
|
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
3445
|
return { model: r, fields: s, includeModelFields: !0 };
|
|
3446
3446
|
}
|
|
3447
3447
|
async function gr(t) {
|
|
3448
|
-
const { modelPath: e, fields: n } = dr(t.argv), { model: r, fields:
|
|
3448
|
+
const { modelPath: e, fields: n } = dr(t.argv), { model: r, fields: a, includeModelFields: s } = await fr(
|
|
3449
3449
|
t,
|
|
3450
3450
|
e,
|
|
3451
3451
|
n
|
|
3452
|
-
), i = `src/lib/schemas/${r.name}.ts`,
|
|
3452
|
+
), i = `src/lib/schemas/${r.name}.ts`, o = it(r, a, {
|
|
3453
3453
|
includeModelFields: s,
|
|
3454
3454
|
forForm: !0
|
|
3455
3455
|
});
|
|
3456
3456
|
return {
|
|
3457
|
-
creates: [pr(i,
|
|
3457
|
+
creates: [pr(i, o)],
|
|
3458
3458
|
modifies: [],
|
|
3459
3459
|
deletes: [],
|
|
3460
3460
|
components: [],
|
|
@@ -3466,9 +3466,9 @@ const hr = "generate-schema", br = "1.0.7", vr = "src/patterns/generate/schema",
|
|
|
3466
3466
|
async function yr(t) {
|
|
3467
3467
|
const e = await gr(t);
|
|
3468
3468
|
if (t.env !== "runtime")
|
|
3469
|
-
return
|
|
3469
|
+
return S(e);
|
|
3470
3470
|
const { writeResult: n } = await import("./write-result-CbUTMeAc.js");
|
|
3471
|
-
return n(await
|
|
3471
|
+
return n(await S(e), t);
|
|
3472
3472
|
}
|
|
3473
3473
|
const $r = {
|
|
3474
3474
|
version: br,
|
|
@@ -3746,24 +3746,24 @@ const oAuth2Schema = z.object({
|
|
|
3746
3746
|
});
|
|
3747
3747
|
|
|
3748
3748
|
export const loginSchema = z.discriminatedUnion('type', [otpSchema, passwordSchema, oAuth2Schema]);
|
|
3749
|
-
`,
|
|
3749
|
+
`, Er = `import { z } from 'zod/v3';
|
|
3750
3750
|
|
|
3751
3751
|
export const otpSchema = z.object({
|
|
3752
3752
|
otp: z.string()
|
|
3753
3753
|
});
|
|
3754
|
-
`,
|
|
3754
|
+
`, Ir = `import { z } from 'zod/v3';
|
|
3755
3755
|
|
|
3756
3756
|
export const profileSchema = z.object({
|
|
3757
3757
|
name: z.string().optional(),
|
|
3758
3758
|
avatar: z.union([z.instanceof(File), z.string()]).optional(),
|
|
3759
3759
|
emailVisibility: z.boolean().optional()
|
|
3760
3760
|
});
|
|
3761
|
-
`,
|
|
3761
|
+
`, zr = `import { z } from 'zod/v3';
|
|
3762
3762
|
|
|
3763
3763
|
export const resetSchema = z.object({
|
|
3764
3764
|
email: z.string().email()
|
|
3765
3765
|
});
|
|
3766
|
-
`,
|
|
3766
|
+
`, Mr = `import { z } from 'zod/v3';
|
|
3767
3767
|
|
|
3768
3768
|
export const signupSchema = z.object({
|
|
3769
3769
|
email: z.string().email(),
|
|
@@ -3843,14 +3843,14 @@ describe('dashboard', () => {
|
|
|
3843
3843
|
expect(response.status).toBe(200);
|
|
3844
3844
|
});
|
|
3845
3845
|
});
|
|
3846
|
-
`,
|
|
3846
|
+
`, jr = `export const load = async ({ parent }) => {
|
|
3847
3847
|
const { breadcrumbs } = await parent();
|
|
3848
3848
|
|
|
3849
3849
|
return {
|
|
3850
3850
|
breadcrumbs: [...breadcrumbs, { title: 'Settings', url: '/settings' }]
|
|
3851
3851
|
};
|
|
3852
3852
|
};
|
|
3853
|
-
`,
|
|
3853
|
+
`, Nr = `import { superValidate, fail, withFiles } from 'sveltekit-superforms';
|
|
3854
3854
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
3855
3855
|
import { setFlash } from 'sveltekit-flash-message/server';
|
|
3856
3856
|
import { profileSchema } from '$lib/schemas/profile';
|
|
@@ -3919,7 +3919,7 @@ export const actions = {
|
|
|
3919
3919
|
return {};
|
|
3920
3920
|
}
|
|
3921
3921
|
};
|
|
3922
|
-
`,
|
|
3922
|
+
`, Or = `<script lang="ts">
|
|
3923
3923
|
import { untrack } from 'svelte';
|
|
3924
3924
|
import { superForm } from 'sveltekit-superforms';
|
|
3925
3925
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
|
@@ -4197,7 +4197,7 @@ export const actions = {
|
|
|
4197
4197
|
</form>
|
|
4198
4198
|
</div>
|
|
4199
4199
|
</div>
|
|
4200
|
-
`,
|
|
4200
|
+
`, Lr = `import { fail, superValidate } from 'sveltekit-superforms';
|
|
4201
4201
|
import { zod } from 'sveltekit-superforms/adapters';
|
|
4202
4202
|
import { confirmEmailChangeSchema } from '$lib/schemas/confirmEmailChange';
|
|
4203
4203
|
import { redirect } from '@sveltejs/kit';
|
|
@@ -4520,7 +4520,7 @@ export const actions = {
|
|
|
4520
4520
|
redirect(303, redirectUrl);
|
|
4521
4521
|
}
|
|
4522
4522
|
};
|
|
4523
|
-
`,
|
|
4523
|
+
`, Kr = `<script lang="ts">
|
|
4524
4524
|
import { untrack } from 'svelte';
|
|
4525
4525
|
import { Button } from '$lib/components/ui/button';
|
|
4526
4526
|
import * as Card from '$lib/components/ui/card';
|
|
@@ -4703,7 +4703,7 @@ export const actions = {
|
|
|
4703
4703
|
</div>
|
|
4704
4704
|
</div>
|
|
4705
4705
|
</div>
|
|
4706
|
-
`,
|
|
4706
|
+
`, Xr = `import { describe, it, expect } from 'vitest';
|
|
4707
4707
|
import * as devalue from 'devalue';
|
|
4708
4708
|
import type { Match } from '@velastack/pocketbase';
|
|
4709
4709
|
import type { RouteId } from './$types';
|
|
@@ -4750,7 +4750,7 @@ describe('POST /login', () => {
|
|
|
4750
4750
|
expect(data.form.message.text).toBe('Failed to authenticate.');
|
|
4751
4751
|
});
|
|
4752
4752
|
});
|
|
4753
|
-
`,
|
|
4753
|
+
`, Yr = `import { redirect } from '@sveltejs/kit';
|
|
4754
4754
|
|
|
4755
4755
|
export const POST = ({ cookies, locals }) => {
|
|
4756
4756
|
locals.pb.authStore.clear();
|
|
@@ -5299,18 +5299,18 @@ describe('POST /signup', () => {
|
|
|
5299
5299
|
"./creates/src/lib/schemas/confirmEmailChange.ts": kr,
|
|
5300
5300
|
"./creates/src/lib/schemas/confirmReset.ts": Rr,
|
|
5301
5301
|
"./creates/src/lib/schemas/login.ts": Pr,
|
|
5302
|
-
"./creates/src/lib/schemas/otp.ts":
|
|
5303
|
-
"./creates/src/lib/schemas/profile.ts":
|
|
5304
|
-
"./creates/src/lib/schemas/reset.ts":
|
|
5305
|
-
"./creates/src/lib/schemas/signup.ts":
|
|
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
5306
|
"./creates/src/routes/(app)/+layout.server.ts": Br,
|
|
5307
5307
|
"./creates/src/routes/(app)/+layout.svelte": Dr,
|
|
5308
5308
|
"./creates/src/routes/(app)/dashboard/+page.svelte": Tr,
|
|
5309
5309
|
"./creates/src/routes/(app)/dashboard/server.test.ts": Ar,
|
|
5310
|
-
"./creates/src/routes/(app)/settings/+layout.server.ts":
|
|
5311
|
-
"./creates/src/routes/(app)/settings/+page.server.ts":
|
|
5312
|
-
"./creates/src/routes/(app)/settings/+page.svelte":
|
|
5313
|
-
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.server.ts":
|
|
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
5314
|
"./creates/src/routes/(public)/confirm-email-change/[token]/+page.svelte": qr,
|
|
5315
5315
|
"./creates/src/routes/(public)/confirm-email-change/[token]/server.test.ts": Vr,
|
|
5316
5316
|
"./creates/src/routes/(public)/confirm-reset/[token]/+page.server.ts": Ur,
|
|
@@ -5319,9 +5319,9 @@ describe('POST /signup', () => {
|
|
|
5319
5319
|
"./creates/src/routes/(public)/confirm-verification/[token]/+server.ts": Wr,
|
|
5320
5320
|
"./creates/src/routes/(public)/confirm-verification/[token]/server.test.ts": Jr,
|
|
5321
5321
|
"./creates/src/routes/(public)/login/+page.server.ts": Zr,
|
|
5322
|
-
"./creates/src/routes/(public)/login/+page.svelte":
|
|
5323
|
-
"./creates/src/routes/(public)/login/server.test.ts":
|
|
5324
|
-
"./creates/src/routes/(public)/logout/+server.ts":
|
|
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
5325
|
"./creates/src/routes/(public)/logout/server.test.ts": Qr,
|
|
5326
5326
|
"./creates/src/routes/(public)/otp/[token]/+page.server.ts": ta,
|
|
5327
5327
|
"./creates/src/routes/(public)/otp/[token]/+page.svelte": ea,
|
|
@@ -5334,14 +5334,14 @@ describe('POST /signup', () => {
|
|
|
5334
5334
|
"./creates/src/routes/(public)/signup/server.test.ts": la
|
|
5335
5335
|
}), ma = "./creates/";
|
|
5336
5336
|
async function ua(t) {
|
|
5337
|
-
const e = Object.entries(ca).map(([
|
|
5338
|
-
const i =
|
|
5337
|
+
const e = Object.entries(ca).map(([a, s]) => {
|
|
5338
|
+
const i = G(a, ma);
|
|
5339
5339
|
return {
|
|
5340
5340
|
path: i,
|
|
5341
|
-
language:
|
|
5341
|
+
language: P(i),
|
|
5342
5342
|
content: s
|
|
5343
5343
|
};
|
|
5344
|
-
}).sort((
|
|
5344
|
+
}).sort((a, s) => a.path.localeCompare(s.path)), n = [
|
|
5345
5345
|
"sidebar",
|
|
5346
5346
|
"breadcrumb",
|
|
5347
5347
|
"separator",
|
|
@@ -5562,10 +5562,10 @@ export const load = loadFlash(async ({ locals }) => {
|
|
|
5562
5562
|
}), ha = "./preview-modifies/";
|
|
5563
5563
|
async function ba(t) {
|
|
5564
5564
|
const e = Object.entries(ga).map(([n, r]) => {
|
|
5565
|
-
const
|
|
5565
|
+
const a = G(n, ha);
|
|
5566
5566
|
return {
|
|
5567
|
-
path:
|
|
5568
|
-
language:
|
|
5567
|
+
path: a,
|
|
5568
|
+
language: P(a),
|
|
5569
5569
|
content: r
|
|
5570
5570
|
};
|
|
5571
5571
|
}).sort((n, r) => n.path.localeCompare(r.path));
|
|
@@ -5583,11 +5583,11 @@ async function xa(t) {
|
|
|
5583
5583
|
const e = await ua(t);
|
|
5584
5584
|
if (t.env === "preview") {
|
|
5585
5585
|
const s = await ba();
|
|
5586
|
-
return
|
|
5586
|
+
return S(H([e, s]));
|
|
5587
5587
|
}
|
|
5588
|
-
const { generate: n } = await import("./generate.runtime-
|
|
5589
|
-
return
|
|
5590
|
-
await
|
|
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])),
|
|
5591
5591
|
t
|
|
5592
5592
|
);
|
|
5593
5593
|
}
|
|
@@ -5619,15 +5619,113 @@ const Fa = {
|
|
|
5619
5619
|
},
|
|
5620
5620
|
baseline: "velastack",
|
|
5621
5621
|
generate: xa
|
|
5622
|
-
},
|
|
5623
|
-
|
|
5622
|
+
}, Sa = `import { describe, expect, it } from "vitest";
|
|
5623
|
+
|
|
5624
|
+
describe("GET /api/health", () => {
|
|
5625
|
+
it("should return a 200 status code", async (context) => {
|
|
5626
|
+
const response = await context.request.get("/api/health");
|
|
5627
|
+
expect(response.status).toBe(200);
|
|
5628
|
+
});
|
|
5629
|
+
});
|
|
5630
|
+
`, Ca = /* @__PURE__ */ Object.assign({
|
|
5631
|
+
"./creates/src/routes/api/server.test.ts": Sa
|
|
5632
|
+
}), _a = "./creates/";
|
|
5633
|
+
async function ka(t) {
|
|
5634
|
+
return {
|
|
5635
|
+
creates: Object.entries(Ca).map(([n, r]) => {
|
|
5636
|
+
const a = G(n, _a);
|
|
5637
|
+
return {
|
|
5638
|
+
path: a,
|
|
5639
|
+
language: P(a),
|
|
5640
|
+
content: r
|
|
5641
|
+
};
|
|
5642
|
+
}).sort((n, r) => n.path.localeCompare(r.path)),
|
|
5643
|
+
modifies: [],
|
|
5644
|
+
deletes: [],
|
|
5645
|
+
components: [],
|
|
5646
|
+
packages: [],
|
|
5647
|
+
collections: []
|
|
5648
|
+
};
|
|
5649
|
+
}
|
|
5650
|
+
const Ra = `import {
|
|
5651
|
+
POCKETBASE_URL,
|
|
5652
|
+
POCKETBASE_SUPERUSER_EMAIL,
|
|
5653
|
+
POCKETBASE_SUPERUSER_PASSWORD,
|
|
5654
|
+
} from "$env/static/private";
|
|
5655
|
+
import { handlePocketbase } from "@velastack/pocketbase";
|
|
5656
|
+
|
|
5657
|
+
export const handle = handlePocketbase({
|
|
5658
|
+
pocketbaseUrl: POCKETBASE_URL,
|
|
5659
|
+
superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
|
|
5660
|
+
superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,
|
|
5661
|
+
// [!code highlight:1]
|
|
5662
|
+
api: { enabled: true },
|
|
5663
|
+
});
|
|
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);
|
|
5670
|
+
return {
|
|
5671
|
+
path: a,
|
|
5672
|
+
language: P(a),
|
|
5673
|
+
content: r
|
|
5674
|
+
};
|
|
5675
|
+
}).sort((n, r) => n.path.localeCompare(r.path));
|
|
5676
|
+
return {
|
|
5677
|
+
creates: [],
|
|
5678
|
+
modifies: e,
|
|
5679
|
+
deletes: [],
|
|
5680
|
+
components: [],
|
|
5681
|
+
packages: [],
|
|
5682
|
+
collections: []
|
|
5683
|
+
};
|
|
5684
|
+
}
|
|
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();
|
|
5688
|
+
if (t.env === "preview") {
|
|
5689
|
+
const s = await Ia();
|
|
5690
|
+
return S(H([e, s]));
|
|
5691
|
+
}
|
|
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])),
|
|
5695
|
+
t
|
|
5696
|
+
);
|
|
5697
|
+
}
|
|
5698
|
+
const Aa = {
|
|
5699
|
+
version: Ma,
|
|
5700
|
+
slug: za,
|
|
5701
|
+
source: Ba,
|
|
5702
|
+
docs: Da,
|
|
5703
|
+
plan: "open",
|
|
5704
|
+
title: "Enable API",
|
|
5705
|
+
summary: "Enables the PocketBase API.",
|
|
5706
|
+
requires: {
|
|
5707
|
+
auth: !1,
|
|
5708
|
+
payments: !1
|
|
5709
|
+
},
|
|
5710
|
+
category: "api",
|
|
5711
|
+
tags: ["sveltekit", "api", "rest", "backend", "pocketbase", "velastack"],
|
|
5712
|
+
command: {
|
|
5713
|
+
raw: "vela enable api",
|
|
5714
|
+
base: "vela enable api",
|
|
5715
|
+
argv: []
|
|
5716
|
+
},
|
|
5717
|
+
baseline: "velastack",
|
|
5718
|
+
generate: Ta
|
|
5719
|
+
}, Va = ne.version, Jt = [
|
|
5720
|
+
En,
|
|
5624
5721
|
$r,
|
|
5625
5722
|
Gn,
|
|
5626
5723
|
ur,
|
|
5627
|
-
Fa
|
|
5628
|
-
|
|
5724
|
+
Fa,
|
|
5725
|
+
Aa
|
|
5726
|
+
], Ua = Object.fromEntries(
|
|
5629
5727
|
Jt.map((t) => [t.slug, t])
|
|
5630
|
-
),
|
|
5728
|
+
), Ha = Jt.reduce(
|
|
5631
5729
|
(t, e) => {
|
|
5632
5730
|
const n = e.category;
|
|
5633
5731
|
return t[n] ?? (t[n] = []), t[n].push(e), t;
|
|
@@ -5635,13 +5733,13 @@ const Fa = {
|
|
|
5635
5733
|
{}
|
|
5636
5734
|
);
|
|
5637
5735
|
export {
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5736
|
+
La as D,
|
|
5737
|
+
qa as M,
|
|
5738
|
+
Ua as a,
|
|
5739
|
+
Ha as b,
|
|
5642
5740
|
d,
|
|
5643
|
-
|
|
5741
|
+
P as l,
|
|
5644
5742
|
Jt as p,
|
|
5645
|
-
|
|
5743
|
+
Va as v
|
|
5646
5744
|
};
|
|
5647
|
-
//# sourceMappingURL=index-
|
|
5745
|
+
//# sourceMappingURL=index-Dav9F9Qf.js.map
|