@velastack/patterns 0.0.26 → 0.0.27

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.
Files changed (33) hide show
  1. package/dist/chunks/{collections-DdGJC7Ip.js → collections-CwH8DO-2.js} +2 -2
  2. package/dist/chunks/{collections-DdGJC7Ip.js.map → collections-CwH8DO-2.js.map} +1 -1
  3. package/dist/chunks/{env.preview-Cpr4Im0G.js → env.preview-kw0hC6y8.js} +1 -1
  4. package/dist/chunks/{env.preview-Cpr4Im0G.js.map → env.preview-kw0hC6y8.js.map} +1 -1
  5. package/dist/chunks/{env.runtime-iw-bWvXM.js → env.runtime-CJS54CZX.js} +1 -1
  6. package/dist/chunks/{env.runtime-iw-bWvXM.js.map → env.runtime-CJS54CZX.js.map} +1 -1
  7. package/dist/chunks/{generate.runtime-Bt6kbkWX.js → generate.runtime-B3WXGKZY.js} +4 -4
  8. package/dist/chunks/{generate.runtime-Bt6kbkWX.js.map → generate.runtime-B3WXGKZY.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-B0EfMNMf.js → generate.runtime-BS_l-k-A.js} +6 -6
  10. package/dist/chunks/{generate.runtime-B0EfMNMf.js.map → generate.runtime-BS_l-k-A.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-BtGvtuWm.js → generate.runtime-Bhqdiykw.js} +2 -2
  12. package/dist/chunks/{generate.runtime-BtGvtuWm.js.map → generate.runtime-Bhqdiykw.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-DiJDMdAq.js → generate.runtime-CzKWz6BN.js} +4 -4
  14. package/dist/chunks/{generate.runtime-DiJDMdAq.js.map → generate.runtime-CzKWz6BN.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-CcKMIm9M.js → generate.runtime-DVRoiEhh.js} +2 -2
  16. package/dist/chunks/{generate.runtime-CcKMIm9M.js.map → generate.runtime-DVRoiEhh.js.map} +1 -1
  17. package/dist/chunks/generate.runtime-V7jzalbO.js +602 -0
  18. package/dist/chunks/generate.runtime-V7jzalbO.js.map +1 -0
  19. package/dist/chunks/{modify-file-Dxow9QKT.js → modify-file-Drki52pc.js} +1 -1
  20. package/dist/chunks/{modify-file-Dxow9QKT.js.map → modify-file-Drki52pc.js.map} +1 -1
  21. package/dist/chunks/{pocketbase-CSl9ydRr.js → pocketbase-CDu4GzZD.js} +1 -1
  22. package/dist/chunks/{pocketbase-CSl9ydRr.js.map → pocketbase-CDu4GzZD.js.map} +1 -1
  23. package/dist/chunks/{pocketbase-CPRrN7Qs.js → pocketbase-CmKcAXDf.js} +1 -1
  24. package/dist/chunks/{pocketbase-CPRrN7Qs.js.map → pocketbase-CmKcAXDf.js.map} +1 -1
  25. package/dist/chunks/taggedTemplateLiteral-BLWebVbJ.js +6 -0
  26. package/dist/chunks/{ts-morph-helpers-DmD7iwna.js → ts-morph-helpers-BMxk6lHK.js} +1 -1
  27. package/dist/chunks/{ts-morph-helpers-DmD7iwna.js.map → ts-morph-helpers-BMxk6lHK.js.map} +1 -1
  28. package/dist/chunks/{write-result-DhQIE6kA.js → write-result-C3SCX65t.js} +1 -1
  29. package/dist/chunks/{write-result-DhQIE6kA.js.map → write-result-C3SCX65t.js.map} +1 -1
  30. package/dist/index.d.ts +197 -17
  31. package/dist/index.js +1651 -560
  32. package/dist/index.js.map +1 -1
  33. package/package.json +6 -1
@@ -0,0 +1,602 @@
1
+ import { t as e } from "./dedent-BFNYR8cb.js";
2
+ import { n as t } from "./util-k-qPjL06.js";
3
+ import { t as n } from "./taggedTemplateLiteral-BLWebVbJ.js";
4
+ import { n as r, r as i, t as a } from "./pocketbase-CmKcAXDf.js";
5
+ import { t as o } from "./modify-file-Drki52pc.js";
6
+ import { i as s, t as c } from "./ts-morph-helpers-BMxk6lHK.js";
7
+ import l from "node:fs";
8
+ import u from "node:path";
9
+ import { Project as d, QuoteKind as f, SyntaxKind as p } from "ts-morph";
10
+ import { randomBytes as m } from "node:crypto";
11
+ import h from "stripe";
12
+ //#region src/patterns/enable/payments/modifies/modify-nav-user.ts
13
+ var g = [
14
+ "import CreditCardIcon from '@lucide/svelte/icons/credit-card';",
15
+ "",
16
+ "// Add to your navUser array:",
17
+ "{ title: 'Billing', url: '/billing', icon: CreditCardIcon }"
18
+ ].join("\n"), _ = [
19
+ "Add a Billing nav item to nav-user.svelte:",
20
+ "",
21
+ g
22
+ ].join("\n"), v = [
23
+ "Create nav-user.svelte with a Billing entry:",
24
+ "",
25
+ g
26
+ ].join("\n");
27
+ function y(e, t, n, r, i) {
28
+ let a = new s(e), o = !1, l = (e) => {
29
+ o || e((e) => {
30
+ let a = c(e, t, n, r, i);
31
+ return a.wasAdded && (o = !0), a.source;
32
+ });
33
+ };
34
+ return l((e) => a.modifyModuleScript(e)), o || l((e) => a.modifyScript(e)), {
35
+ newNavUserSnippet: a.toString(),
36
+ wasAdded: o
37
+ };
38
+ }
39
+ function b(e) {
40
+ if (!l.existsSync(e)) return {
41
+ status: "not-found",
42
+ message: v
43
+ };
44
+ let t = l.readFileSync(e, "utf8");
45
+ if (t.includes("/billing")) return {
46
+ status: "success",
47
+ changed: !1
48
+ };
49
+ let { newNavUserSnippet: n, wasAdded: r } = y(t, "Billing", "/billing", "CreditCardIcon", "@lucide/svelte/icons/credit-card");
50
+ return r ? (l.writeFileSync(e, n, "utf8"), {
51
+ status: "success",
52
+ changed: !0
53
+ }) : {
54
+ status: "failed",
55
+ message: _
56
+ };
57
+ }
58
+ //#endregion
59
+ //#region src/patterns/enable/payments/modifies/modify-user-signup.ts
60
+ var x = e`
61
+ const linkStripeCustomer = async (email: string, user: { id: string }, locals: App.Locals) => {
62
+ const matchingCustomer = await stripe.customers.list({
63
+ email: email,
64
+ limit: 1,
65
+ expand: ['data.invoice_settings']
66
+ });
67
+
68
+ let customer;
69
+ let isExistingCustomer = false;
70
+
71
+ if (matchingCustomer.data.length > 0) {
72
+ isExistingCustomer = true;
73
+ customer = matchingCustomer.data[0];
74
+ } else {
75
+ customer = await stripe.customers.create({
76
+ email: email
77
+ });
78
+ }
79
+
80
+ await locals.admin.collection('stripe_customers').create({
81
+ id: customer.id,
82
+ user: user.id
83
+ });
84
+
85
+ if (!isExistingCustomer) {
86
+ return;
87
+ }
88
+
89
+ const paymentMethods = await stripe.customers.listPaymentMethods(customer.id, {
90
+ type: 'card',
91
+ allow_redisplay: 'always'
92
+ });
93
+
94
+ for (const paymentMethod of paymentMethods.data) {
95
+ if (paymentMethod.allow_redisplay === 'unspecified') {
96
+ continue;
97
+ }
98
+
99
+ await locals.admin.collection('stripe_payment_methods').create({
100
+ id: paymentMethod.id,
101
+ customer: customer.id,
102
+ brand: paymentMethod.card?.brand,
103
+ last4: paymentMethod.card?.last4,
104
+ exp_month: paymentMethod.card?.exp_month,
105
+ exp_year: paymentMethod.card?.exp_year
106
+ });
107
+ }
108
+
109
+ const defaultPaymentMethod = customer.invoice_settings?.default_payment_method;
110
+
111
+ if (defaultPaymentMethod) {
112
+ try {
113
+ await locals.admin.collection('stripe_customers').update(customer.id, {
114
+ default_payment_method: defaultPaymentMethod
115
+ });
116
+ } catch {}
117
+ }
118
+ };
119
+ `, S = ["Could not locate the requestVerification call in signup +page.server.ts.", "Add a linkStripeCustomer helper and call it before requestVerification()."].join("\n"), C = ["Create src/routes/(public)/signup/+page.server.ts before enabling payments."].join("\n");
120
+ function w(t) {
121
+ if (!l.existsSync(t)) return {
122
+ status: "not-found",
123
+ message: C
124
+ };
125
+ let n = l.readFileSync(t, "utf8"), r = new d({ manipulationSettings: { quoteKind: f.Single } }).addSourceFileAtPath(t);
126
+ if (r.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "$lib/stripe")) return {
127
+ status: "success",
128
+ changed: !1
129
+ };
130
+ r.addImportDeclaration({
131
+ defaultImport: "stripe",
132
+ moduleSpecifier: "$lib/stripe"
133
+ });
134
+ let i = r.getDescendantsOfKind(p.CallExpression).find((e) => {
135
+ let t = e.getExpression();
136
+ return t.getKind() === p.PropertyAccessExpression && t.getText().includes("requestVerification");
137
+ });
138
+ if (!i) return {
139
+ status: "failed",
140
+ message: S
141
+ };
142
+ let a = i.getFirstAncestorByKind(p.ExpressionStatement);
143
+ if (!a) return {
144
+ status: "failed",
145
+ message: S
146
+ };
147
+ r.addStatements(x);
148
+ let o = e`
149
+ await linkStripeCustomer(form.data.email, user, locals);
150
+ `;
151
+ return a.replaceWithText(o + "\n\n" + a.getText()), r.formatText(), r.saveSync(), {
152
+ status: "success",
153
+ changed: r.getFullText() !== n
154
+ };
155
+ }
156
+ //#endregion
157
+ //#region src/patterns/enable/payments/modifies/modify-env.ts
158
+ function T(e, t) {
159
+ return (!e.length || e.endsWith("\n") ? e : e + "\n") + t + "\n";
160
+ }
161
+ function E(e, t) {
162
+ let n = e;
163
+ for (let e of t) {
164
+ if (e.type === "comment") {
165
+ let t = `# ${e.key}`;
166
+ n.includes(t) || (n = T(n, t));
167
+ continue;
168
+ }
169
+ n.includes(`${e.key}=`) || (n = T(n, `${e.key}=${e.value ?? ""}`));
170
+ }
171
+ return n;
172
+ }
173
+ function D(e, t) {
174
+ let n = l.existsSync(e) ? l.readFileSync(e, "utf8") : "", r = E(n, t);
175
+ return r === n ? {
176
+ status: "success",
177
+ changed: !1
178
+ } : (l.writeFileSync(e, r, "utf8"), {
179
+ status: "success",
180
+ changed: !0
181
+ });
182
+ }
183
+ //#endregion
184
+ //#region src/patterns/enable/payments/runtime/stripe.ts
185
+ async function O(e) {
186
+ let t = new h(e), n = await t.products.search({
187
+ query: "name:\"Test Product\" AND metadata[\"test\"]:\"true\"",
188
+ limit: 1
189
+ });
190
+ if (n.data.length > 0) {
191
+ let e = n.data[0], r = await t.prices.list({
192
+ product: e.id,
193
+ active: !0,
194
+ limit: 1
195
+ });
196
+ if (r.data.length > 0) return {
197
+ product: e,
198
+ price: r.data[0],
199
+ existing: !0
200
+ };
201
+ }
202
+ let r = await t.products.create({
203
+ name: "Test Product",
204
+ metadata: { test: "true" }
205
+ });
206
+ return {
207
+ product: r,
208
+ price: await t.prices.create({
209
+ product: r.id,
210
+ unit_amount: 1e3,
211
+ currency: "usd"
212
+ }),
213
+ existing: !1
214
+ };
215
+ }
216
+ //#endregion
217
+ //#region src/patterns/enable/payments/generate.runtime.ts
218
+ var k;
219
+ async function A(e, n, i, o) {
220
+ await r();
221
+ let s = a(n, i, o);
222
+ s && e.push({
223
+ path: s,
224
+ language: t(s),
225
+ content: l.readFileSync(s, "utf8"),
226
+ status: "success"
227
+ });
228
+ }
229
+ function j(t) {
230
+ return e(k ||= n(["\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), t);
231
+ }
232
+ async function M(e) {
233
+ let { stripeSecretKey: t, stripePublishableKey: n, stripeWebhookSecret: r } = e.input, a = e.features.auth, s = [], c = [], l = (e) => {
234
+ e && c.push(e);
235
+ }, d = m(16).toString("hex"), f = [
236
+ {
237
+ type: "comment",
238
+ key: "Stripe credentials"
239
+ },
240
+ {
241
+ type: "var",
242
+ key: "STRIPE_SECRET_KEY",
243
+ value: t
244
+ },
245
+ {
246
+ type: "var",
247
+ key: "PUBLIC_STRIPE_PUBLISHABLE_KEY",
248
+ value: n
249
+ },
250
+ {
251
+ type: "var",
252
+ key: "STRIPE_WEBHOOK_SECRET",
253
+ value: r
254
+ },
255
+ {
256
+ type: "var",
257
+ key: "INTERNAL_JOB_SECRET",
258
+ value: d
259
+ }
260
+ ], p = u.join(e.root, ".env");
261
+ l(o(p, D(p, f))), await i(e.root, async (t) => {
262
+ if (await t.collections.create({
263
+ name: "stripe_products",
264
+ type: "base",
265
+ fields: [
266
+ {
267
+ name: "id",
268
+ pattern: "^[a-zA-Z0-9_]+$",
269
+ primaryKey: !0,
270
+ required: !0,
271
+ system: !0,
272
+ type: "text"
273
+ },
274
+ {
275
+ name: "name",
276
+ required: !1,
277
+ type: "text"
278
+ },
279
+ {
280
+ name: "active",
281
+ required: !1,
282
+ type: "text"
283
+ },
284
+ {
285
+ name: "default_price",
286
+ required: !1,
287
+ type: "text"
288
+ },
289
+ {
290
+ name: "created",
291
+ onCreate: !0,
292
+ onUpdate: !1,
293
+ type: "autodate"
294
+ },
295
+ {
296
+ name: "updated",
297
+ onCreate: !0,
298
+ onUpdate: !0,
299
+ type: "autodate"
300
+ }
301
+ ]
302
+ }), await A(s, "stripe_products", "created", e), await t.collections.create({
303
+ name: "stripe_prices",
304
+ type: "base",
305
+ fields: [
306
+ {
307
+ name: "id",
308
+ pattern: "^[a-zA-Z0-9_]+$",
309
+ primaryKey: !0,
310
+ required: !0,
311
+ system: !0,
312
+ type: "text"
313
+ },
314
+ {
315
+ name: "billing_scheme",
316
+ required: !1,
317
+ type: "text"
318
+ },
319
+ {
320
+ name: "currency",
321
+ required: !1,
322
+ type: "text"
323
+ },
324
+ {
325
+ name: "product",
326
+ required: !1,
327
+ type: "text"
328
+ },
329
+ {
330
+ name: "recurring",
331
+ required: !1,
332
+ type: "text"
333
+ },
334
+ {
335
+ name: "type",
336
+ required: !1,
337
+ type: "text"
338
+ },
339
+ {
340
+ name: "unit_amount",
341
+ required: !1,
342
+ type: "number"
343
+ },
344
+ {
345
+ name: "active",
346
+ required: !1,
347
+ type: "bool"
348
+ },
349
+ {
350
+ name: "created",
351
+ onCreate: !0,
352
+ onUpdate: !1,
353
+ type: "autodate"
354
+ },
355
+ {
356
+ name: "updated",
357
+ onCreate: !0,
358
+ onUpdate: !0,
359
+ type: "autodate"
360
+ }
361
+ ]
362
+ }), await A(s, "stripe_prices", "created", e), a) {
363
+ let n = await t.collections.create({
364
+ name: "stripe_customers",
365
+ type: "base",
366
+ fields: [
367
+ {
368
+ name: "id",
369
+ pattern: "^[a-zA-Z0-9_]+$",
370
+ primaryKey: !0,
371
+ required: !0,
372
+ system: !0,
373
+ type: "text"
374
+ },
375
+ {
376
+ collectionId: "_pb_users_auth_",
377
+ maxSelect: 1,
378
+ minSelect: 0,
379
+ name: "user",
380
+ required: !0,
381
+ type: "relation"
382
+ },
383
+ {
384
+ name: "created",
385
+ onCreate: !0,
386
+ onUpdate: !1,
387
+ type: "autodate"
388
+ },
389
+ {
390
+ name: "updated",
391
+ onCreate: !0,
392
+ onUpdate: !0,
393
+ type: "autodate"
394
+ }
395
+ ]
396
+ });
397
+ await A(s, "stripe_customers", "created", e);
398
+ let r = await t.collections.create({
399
+ name: "stripe_payment_methods",
400
+ type: "base",
401
+ fields: [
402
+ {
403
+ name: "id",
404
+ pattern: "^[a-zA-Z0-9_]+$",
405
+ primaryKey: !0,
406
+ required: !0,
407
+ system: !0,
408
+ type: "text"
409
+ },
410
+ {
411
+ name: "brand",
412
+ required: !0,
413
+ type: "text"
414
+ },
415
+ {
416
+ name: "last4",
417
+ required: !0,
418
+ type: "text"
419
+ },
420
+ {
421
+ name: "exp_month",
422
+ required: !0,
423
+ type: "number"
424
+ },
425
+ {
426
+ name: "exp_year",
427
+ required: !0,
428
+ type: "number"
429
+ },
430
+ {
431
+ collectionId: n.id,
432
+ maxSelect: 1,
433
+ minSelect: 0,
434
+ name: "customer",
435
+ required: !0,
436
+ type: "relation",
437
+ cascadeDelete: !0
438
+ },
439
+ {
440
+ name: "created",
441
+ onCreate: !0,
442
+ onUpdate: !1,
443
+ type: "autodate"
444
+ },
445
+ {
446
+ name: "updated",
447
+ onCreate: !0,
448
+ onUpdate: !0,
449
+ type: "autodate"
450
+ }
451
+ ]
452
+ });
453
+ await A(s, "stripe_payment_methods", "created", e), await t.collections.update("stripe_customers", { fields: [
454
+ {
455
+ name: "id",
456
+ pattern: "^[a-zA-Z0-9_]+$",
457
+ primaryKey: !0,
458
+ required: !0,
459
+ system: !0,
460
+ type: "text"
461
+ },
462
+ {
463
+ collectionId: "_pb_users_auth_",
464
+ maxSelect: 1,
465
+ minSelect: 0,
466
+ name: "user",
467
+ required: !0,
468
+ type: "relation"
469
+ },
470
+ {
471
+ collectionId: r.id,
472
+ maxSelect: 1,
473
+ minSelect: 0,
474
+ name: "default_payment_method",
475
+ required: !1,
476
+ type: "relation"
477
+ },
478
+ {
479
+ name: "created",
480
+ onCreate: !0,
481
+ onUpdate: !1,
482
+ type: "autodate"
483
+ },
484
+ {
485
+ name: "updated",
486
+ onCreate: !0,
487
+ onUpdate: !0,
488
+ type: "autodate"
489
+ }
490
+ ] }), await A(s, "stripe_customers", "updated", e), await t.collections.create({
491
+ name: "transactions",
492
+ type: "base",
493
+ fields: [
494
+ {
495
+ autogeneratePattern: "[a-z0-9]{15}",
496
+ max: 15,
497
+ min: 15,
498
+ name: "id",
499
+ pattern: "^[a-z0-9]+$",
500
+ primaryKey: !0,
501
+ required: !0,
502
+ system: !0,
503
+ type: "text"
504
+ },
505
+ {
506
+ name: "stripe_payment_intent",
507
+ required: !0,
508
+ type: "text"
509
+ },
510
+ {
511
+ name: "amount",
512
+ required: !0,
513
+ type: "number"
514
+ },
515
+ {
516
+ name: "currency",
517
+ required: !0,
518
+ type: "text"
519
+ },
520
+ {
521
+ name: "last4",
522
+ required: !0,
523
+ type: "text"
524
+ },
525
+ {
526
+ name: "brand",
527
+ required: !0,
528
+ type: "text"
529
+ },
530
+ {
531
+ name: "created",
532
+ required: !0,
533
+ type: "date"
534
+ },
535
+ {
536
+ name: "stripe_charge",
537
+ required: !0,
538
+ type: "text"
539
+ },
540
+ {
541
+ name: "stripe_customer",
542
+ required: !0,
543
+ type: "text"
544
+ },
545
+ {
546
+ collectionId: "_pb_users_auth_",
547
+ maxSelect: 1,
548
+ minSelect: 0,
549
+ name: "user",
550
+ required: !0,
551
+ type: "relation"
552
+ },
553
+ {
554
+ name: "receipt_url",
555
+ required: !0,
556
+ type: "url"
557
+ }
558
+ ]
559
+ }), await A(s, "transactions", "created", e);
560
+ }
561
+ });
562
+ let { product: h, price: g } = await O(t);
563
+ if (await i(e.root, async (e) => {
564
+ await e.collection("stripe_products").create({
565
+ id: h.id,
566
+ name: h.name,
567
+ active: h.active,
568
+ default_price: h.default_price
569
+ }), await e.collection("stripe_prices").create({
570
+ id: g.id,
571
+ billing_scheme: g.billing_scheme,
572
+ currency: g.currency,
573
+ product: g.product,
574
+ recurring: g.recurring,
575
+ type: g.type,
576
+ unit_amount: g.unit_amount,
577
+ active: g.active
578
+ });
579
+ }), s.push({
580
+ path: "src/routes/(public)/payment/+page.svelte",
581
+ language: "svelte",
582
+ content: j(g.id),
583
+ status: "success"
584
+ }), a) {
585
+ let t = u.join(e.root, "src", "lib", "components", "nav-user.svelte");
586
+ l(o(t, b(t)));
587
+ let n = u.join(e.root, "src", "routes", "(public)", "signup", "+page.server.ts");
588
+ l(o(n, w(n)));
589
+ }
590
+ return {
591
+ creates: s,
592
+ modifies: c,
593
+ deletes: [],
594
+ components: [],
595
+ packages: [],
596
+ collections: []
597
+ };
598
+ }
599
+ //#endregion
600
+ export { M as generate };
601
+
602
+ //# sourceMappingURL=generate.runtime-V7jzalbO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-V7jzalbO.js","names":[],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts","../../src/patterns/enable/payments/modifies/modify-user-signup.ts","../../src/patterns/enable/payments/modifies/modify-env.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LINK_STRIPE_CUSTOMER_SNIPPET = dedent`\n const linkStripeCustomer = async (email: string, user: { id: string }, locals: App.Locals) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: ['data.invoice_settings']\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email\n });\n }\n\n await locals.admin.collection('stripe_customers').create({\n id: customer.id,\n user: user.id\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(customer.id, {\n type: 'card',\n allow_redisplay: 'always'\n });\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === 'unspecified') {\n continue;\n }\n\n await locals.admin.collection('stripe_payment_methods').create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year\n });\n }\n\n const defaultPaymentMethod = customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection('stripe_customers').update(customer.id, {\n default_payment_method: defaultPaymentMethod\n });\n } catch {}\n }\n };\n`;\n\nconst FAILURE_HINT = [\n \"Could not locate the requestVerification call in signup +page.server.ts.\",\n \"Add a linkStripeCustomer helper and call it before requestVerification().\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(public)/signup/+page.server.ts before enabling payments.\",\n].join(\"\\n\");\n\nexport function modifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n const hasStripeImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"$lib/stripe\");\n\n if (hasStripeImport) {\n return { status: \"success\", changed: false };\n }\n\n sourceFile.addImportDeclaration({\n defaultImport: \"stripe\",\n moduleSpecifier: \"$lib/stripe\",\n });\n\n const requestVerificationCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => {\n const expr = ce.getExpression();\n return (\n expr.getKind() === SyntaxKind.PropertyAccessExpression &&\n expr.getText().includes(\"requestVerification\")\n );\n });\n\n if (!requestVerificationCall) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const statement = requestVerificationCall.getFirstAncestorByKind(\n SyntaxKind.ExpressionStatement,\n );\n\n if (!statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n sourceFile.addStatements(LINK_STRIPE_CUSTOMER_SNIPPET);\n\n const stripeCall = dedent`\n await linkStripeCustomer(form.data.email, user, locals);\n `;\n\n statement.replaceWithText(stripeCall + \"\\n\\n\" + statement.getText());\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport interface EnvEdit {\n type: \"comment\" | \"var\";\n /** For \"comment\": the text after `# `. For \"var\": the KEY. */\n key: string;\n /** Only for \"var\" entries. */\n value?: string;\n}\n\nfunction appendEnvContent(existing: string, content: string): string {\n const withNewLine =\n !existing.length || existing.endsWith(\"\\n\") ? existing : existing + \"\\n\";\n return withNewLine + content + \"\\n\";\n}\n\nexport function applyEnvEdits(source: string, edits: EnvEdit[]): string {\n let next = source;\n for (const edit of edits) {\n if (edit.type === \"comment\") {\n const commented = `# ${edit.key}`;\n if (!next.includes(commented)) {\n next = appendEnvContent(next, commented);\n }\n continue;\n }\n if (!next.includes(`${edit.key}=`)) {\n next = appendEnvContent(next, `${edit.key}=${edit.value ?? \"\"}`);\n }\n }\n return next;\n}\n\nexport function modifyEnv(envPath: string, edits: EnvEdit[]): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = applyEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import Stripe from \"stripe\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { modifyEnv, type EnvEdit } from \"./modifies/modify-env\";\nimport { createTestProductAndPrice } from \"./runtime/stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n) {\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\nexport async function generate(options: Options) {\n const { stripeSecretKey, stripePublishableKey, stripeWebhookSecret } =\n options.input as {\n stripeSecretKey: string;\n stripePublishableKey: string;\n stripeWebhookSecret: string;\n };\n\n const isAppMode = options.features.auth;\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const internalJobSecret = randomBytes(16).toString(\"hex\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\", value: stripeSecretKey },\n {\n type: \"var\",\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n value: stripePublishableKey,\n },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\", value: stripeWebhookSecret },\n { type: \"var\", key: \"INTERNAL_JOB_SECRET\", value: internalJobSecret },\n ];\n\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnv(envPath, envEdits)));\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collections.create({\n name: \"stripe_products\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_products\", \"created\", options);\n\n await pb.collections.create({\n name: \"stripe_prices\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"text\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_prices\", \"created\", options);\n\n if (isAppMode) {\n const stripeCustomersCollection = await pb.collections.create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n );\n\n const stripePaymentMethodsCollection = await pb.collections.create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n );\n\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n await pb.collections.create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(creates, \"transactions\", \"created\", options);\n }\n });\n\n const { product, price } = await createTestProductAndPrice(stripeSecretKey);\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n });\n\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, modifyUserSignup(userSignupPath)),\n );\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAKA,IAAM,IAAsB;CAC1B;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EACd,GACA,GACA,GACA,GACA,GACkD;CAClD,IAAM,IAAO,IAAI,EAAW,EAAe,EACvC,IAAW,IAET,KAAU,MAAgD;AAC1D,OACJ,GAAK,MAAW;GACd,IAAM,IAAS,EACb,GACA,GACA,GACA,GACA,EACD;AAED,UADI,EAAO,aAAU,IAAW,KACzB,EAAO;IACd;;AAMJ,QAHA,GAAQ,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACtC,KAAU,GAAQ,MAAO,EAAK,aAAa,EAAG,CAAC,EAE7C;EAAE,mBAAmB,EAAK,UAAU;EAAE;EAAU;;AAGzD,SAAgB,EAAc,GAAoC;AAChE,KAAI,CAAC,EAAG,WAAW,EAAY,CAC7B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAiB,EAAG,aAAa,GAAa,OAAO;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eAAe,EAAQ;GACxB,CAAC,EAEF,MAAM,EAAG,WAAW,gBAAgB,CAAC,OAAO;GAC1C,IAAI,EAAM;GACV,gBAAgB,EAAM;GACtB,UAAU,EAAM;GAChB,SAAS,EAAM;GACf,WAAW,EAAM;GACjB,MAAM,EAAM;GACZ,aAAa,EAAM;GACnB,QAAQ,EAAM;GACf,CAAC;GACF,EAEF,EAAQ,KAAK;EACX,MAAM;EACN,UAAU;EACV,SAAS,EAAmB,EAAM,GAAG;EACrC,QAAQ;EACT,CAAC,EAEE,GAAW;EACb,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AACD,IAAW,EAAoB,GAAa,EAAc,EAAY,CAAC,CAAC;EAExE,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,YACA,UACA,kBACD;AACD,IACE,EAAoB,GAAgB,EAAiB,EAAe,CAAC,CACtE;;AAGH,QAAO;EACL;EACA;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EAChB"}
@@ -19,4 +19,4 @@ function n(n, r) {
19
19
  //#endregion
20
20
  export { n as t };
21
21
 
22
- //# sourceMappingURL=modify-file-Dxow9QKT.js.map
22
+ //# sourceMappingURL=modify-file-Drki52pc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modify-file-Dxow9QKT.js","names":[],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n"],"mappings":";;;AAIA,SAAgB,EACd,GACA,GACa;CACb,IAAM,IAAW,EAAiB,EAAS;AAiB3C,QAfI,EAAQ,WAAW,YAChB,EAAQ,UACN;EACL,MAAM;EACN;EACA,SAAS,EAAG,aAAa,GAAU,OAAO;EAC1C,QAAQ;EACT,GAN4B,OAcxB;EACL,MAAM;EACN;EACA,SAPA,EAAQ,WAAW,YAAY,EAAG,WAAW,EAAS,GAClD,EAAG,aAAa,GAAU,OAAO,GACjC;EAMJ,QAAQ,EAAQ;EAChB,SAAS,EAAQ;EAClB"}
1
+ {"version":3,"file":"modify-file-Drki52pc.js","names":[],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n"],"mappings":";;;AAIA,SAAgB,EACd,GACA,GACa;CACb,IAAM,IAAW,EAAiB,EAAS;AAiB3C,QAfI,EAAQ,WAAW,YAChB,EAAQ,UACN;EACL,MAAM;EACN;EACA,SAAS,EAAG,aAAa,GAAU,OAAO;EAC1C,QAAQ;EACT,GAN4B,OAcxB;EACL,MAAM;EACN;EACA,SAPA,EAAQ,WAAW,YAAY,EAAG,WAAW,EAAS,GAClD,EAAG,aAAa,GAAU,OAAO,GACjC;EAMJ,QAAQ,EAAQ;EAChB,SAAS,EAAQ;EAClB"}
@@ -44,4 +44,4 @@ var e = [
44
44
  //#endregion
45
45
  export { e as t };
46
46
 
47
- //# sourceMappingURL=pocketbase-CSl9ydRr.js.map
47
+ //# sourceMappingURL=pocketbase-CDu4GzZD.js.map