@velastack/patterns 0.0.24 → 0.0.25
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-Bzyt18yv.js → collections-DdGJC7Ip.js} +5 -3
- package/dist/chunks/collections-DdGJC7Ip.js.map +1 -0
- package/dist/chunks/{generate.runtime-uPCB71Ki.js → generate.runtime-B0EfMNMf.js} +212 -134
- package/dist/chunks/generate.runtime-B0EfMNMf.js.map +1 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js +289 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js.map +1 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js +81 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js.map +1 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js +430 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js.map +1 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js +207 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js.map +1 -0
- package/dist/chunks/modify-file-Dxow9QKT.js +22 -0
- package/dist/chunks/modify-file-Dxow9QKT.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js → ts-morph-helpers-DmD7iwna.js} +1 -1
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js.map → ts-morph-helpers-DmD7iwna.js.map} +1 -1
- package/dist/chunks/{write-result-CSxmq40z.js → write-result-DhQIE6kA.js} +4 -4
- package/dist/chunks/{write-result-CSxmq40z.js.map → write-result-DhQIE6kA.js.map} +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +245 -227
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/collections-Bzyt18yv.js.map +0 -1
- package/dist/chunks/generate.runtime-BEuc5hDN.js +0 -225
- package/dist/chunks/generate.runtime-BEuc5hDN.js.map +0 -1
- package/dist/chunks/generate.runtime-CHmm4bBZ.js +0 -154
- package/dist/chunks/generate.runtime-CHmm4bBZ.js.map +0 -1
- package/dist/chunks/generate.runtime-DXkJgkP4.js +0 -232
- package/dist/chunks/generate.runtime-DXkJgkP4.js.map +0 -1
- package/dist/chunks/generate.runtime-egq8I3EA.js +0 -61
- package/dist/chunks/generate.runtime-egq8I3EA.js.map +0 -1
- package/dist/chunks/generate.runtime-uPCB71Ki.js.map +0 -1
|
@@ -20,7 +20,8 @@ async function s(n, a, s) {
|
|
|
20
20
|
t && c.push({
|
|
21
21
|
path: t,
|
|
22
22
|
language: e(t),
|
|
23
|
-
content: i(t, "utf8")
|
|
23
|
+
content: i(t, "utf8"),
|
|
24
|
+
status: "success"
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -41,7 +42,8 @@ async function c(o, s) {
|
|
|
41
42
|
o && c.push({
|
|
42
43
|
path: o,
|
|
43
44
|
language: e(o),
|
|
44
|
-
content: i(o, "utf8")
|
|
45
|
+
content: i(o, "utf8"),
|
|
46
|
+
status: "success"
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
}), c;
|
|
@@ -49,4 +51,4 @@ async function c(o, s) {
|
|
|
49
51
|
//#endregion
|
|
50
52
|
export { s as applyCollectionRulePatches, c as createCollections };
|
|
51
53
|
|
|
52
|
-
//# sourceMappingURL=collections-
|
|
54
|
+
//# sourceMappingURL=collections-DdGJC7Ip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-DdGJC7Ip.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type {\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;AAqBA,SAAS,EACP,GACS;AACT,KAAI,EAAM,UAAU,MAAM,MAAM,SAAS,wBACvC,QAAO;CAGT,IAAM,IAAU,EAAM,SAAS,aAAa,IAAI;AAChD,QACE,EAAQ,SAAS,iBAAiB,IAAI,EAAQ,SAAS,iBAAiB;;AAI5E,SAAS,EACP,GACyB;CACzB,IAAM,IAAmC,EAAE;AAM3C,QALI,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aACxD;;AAOT,eAAsB,EACpB,GAMA,GACA,GACiB;CACjB,IAAM,IAAqB,EAAE;AAE7B,MAAK,IAAM,KAAS,GAAS;EAC3B,IAAM,IAAU,EAAM,eAAe,QAAQ,MAAM,KAAK,EAClD,IAAM,MAAM,EAAG,YAAY,iBAAiB,SAAS,EAAQ,GAAG;AAItE,MAHA,MAAM,EAAG,YAAY,OAAO,EAAI,IAAI,EAAqB,EAAM,CAAC,EAChE,MAAM,GAAgB,EAElB,GAAS;GACX,IAAM,IAAgB,EACpB,EAAM,gBACN,WACA,EACD;AACD,GAAI,KACF,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC5C,QAAQ;IACT,CAAC;;;AAKR,QAAO;;AAGT,eAAsB,EACpB,GACA,GACiB;AACjB,KAAI,EAAY,WAAW,EACzB,QAAO,EAAE;CAGX,IAAM,IAAqB,EAAE;AAsC7B,QApCA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;AAC/C,OAAK,IAAM,KAAc,GAAa;AACpC,OAAI;AACF,UAAM,EAAG,YAAY,OAAO,EAAW;YAChC,GAAO;AAUd,UARE,EACE,EACD,GAES,MACR,eAAe,EAAW,KAAK,0FAChC,GAEG;;AAER,SAAM,GAAgB;GAEtB,IAAM,IAAgB,EACpB,EAAW,MACX,WACA,EACD;AACI,QAIL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC5C,QAAQ;IACT,CAAC;;GAEJ,EAEK"}
|
|
@@ -2,23 +2,69 @@ import { t as e } from "./dedent-BFNYR8cb.js";
|
|
|
2
2
|
import { n as t } from "./util-k-qPjL06.js";
|
|
3
3
|
import { t as n } from "./pocketbase-CSl9ydRr.js";
|
|
4
4
|
import { n as r, r as i, t as a } from "./pocketbase-CPRrN7Qs.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import d from "
|
|
8
|
-
import f from "node:
|
|
9
|
-
import
|
|
5
|
+
import { t as o } from "./modify-file-Dxow9QKT.js";
|
|
6
|
+
import { i as s, n as c, r as l, t as u } from "./ts-morph-helpers-DmD7iwna.js";
|
|
7
|
+
import { applyCollectionRulePatches as d } from "./collections-DdGJC7Ip.js";
|
|
8
|
+
import f from "node:fs";
|
|
9
|
+
import p from "node:path";
|
|
10
|
+
import { Project as m, SyntaxKind as h } from "ts-morph";
|
|
10
11
|
//#region src/patterns/enable/teams/modifies/modify-app-layout.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var g = [
|
|
13
|
+
"Pass team props to <AppSidebar> in your app layout:",
|
|
14
|
+
"",
|
|
15
|
+
"<AppSidebar team={data.team} teams={data.teams ?? []} />"
|
|
16
|
+
].join("\n"), _ = [
|
|
17
|
+
"Create an app layout that renders <AppSidebar> with team props:",
|
|
18
|
+
"",
|
|
19
|
+
"<AppSidebar team={data.team} teams={data.teams ?? []} />"
|
|
20
|
+
].join("\n");
|
|
21
|
+
function v(e) {
|
|
22
|
+
if (!f.existsSync(e)) return {
|
|
23
|
+
status: "not-found",
|
|
24
|
+
message: _
|
|
25
|
+
};
|
|
26
|
+
let t = s.fromPath(e);
|
|
27
|
+
return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "teams") ? {
|
|
28
|
+
status: "success",
|
|
29
|
+
changed: !1
|
|
30
|
+
} : (t.appendToAttributes("AppSidebar", " team={data.team} teams={data.teams ?? []}"), t.writeTo(e), {
|
|
31
|
+
status: "success",
|
|
32
|
+
changed: t.hasChanged()
|
|
33
|
+
}) : {
|
|
34
|
+
status: "failed",
|
|
35
|
+
message: g
|
|
36
|
+
};
|
|
15
37
|
}
|
|
16
38
|
//#endregion
|
|
17
39
|
//#region src/patterns/enable/teams/modifies/modify-app-sidebar.ts
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
var y = "<Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>", b = [
|
|
41
|
+
"import TeamSwitcher from '$lib/components/team-switcher.svelte';",
|
|
42
|
+
"import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';",
|
|
43
|
+
"import * as Avatar from '$lib/components/ui/avatar';"
|
|
44
|
+
].join("\n"), x = [
|
|
45
|
+
"Replace the <Sidebar.Header> in your app sidebar with the team switcher.",
|
|
46
|
+
"",
|
|
47
|
+
"Imports to add to the <script> tag:",
|
|
48
|
+
"",
|
|
49
|
+
b,
|
|
50
|
+
"",
|
|
51
|
+
"Props to destructure in $props(): team, teams = []",
|
|
52
|
+
"",
|
|
53
|
+
"Markup to use as the header:",
|
|
54
|
+
y
|
|
55
|
+
].join("\n"), S = [
|
|
56
|
+
"Create an app sidebar with a <Sidebar.Header> containing the team switcher.",
|
|
57
|
+
"",
|
|
58
|
+
"Imports:",
|
|
59
|
+
"",
|
|
60
|
+
b,
|
|
61
|
+
"",
|
|
62
|
+
"Header markup:",
|
|
63
|
+
y
|
|
64
|
+
].join("\n");
|
|
65
|
+
function C(e) {
|
|
66
|
+
let { source: t } = l(e, (e) => {
|
|
67
|
+
c(e, [
|
|
22
68
|
{
|
|
23
69
|
defaultImport: "TeamSwitcher",
|
|
24
70
|
moduleSpecifier: "$lib/components/team-switcher.svelte"
|
|
@@ -36,15 +82,15 @@ function _(e) {
|
|
|
36
82
|
let e = t.getInitializer();
|
|
37
83
|
if (!e || e.getText() !== "$props()") continue;
|
|
38
84
|
let n = t.getNameNode();
|
|
39
|
-
if (n.getKind() !==
|
|
40
|
-
let r = n.asKindOrThrow(
|
|
85
|
+
if (n.getKind() !== h.ObjectBindingPattern) continue;
|
|
86
|
+
let r = n.asKindOrThrow(h.ObjectBindingPattern), i = r.getElements();
|
|
41
87
|
if (i.some((e) => e.getName() === "team")) continue;
|
|
42
88
|
let a = t.getTypeNode();
|
|
43
|
-
if (a?.getKind() ===
|
|
44
|
-
let e = a.asKindOrThrow(
|
|
89
|
+
if (a?.getKind() === h.IntersectionType) {
|
|
90
|
+
let e = a.asKindOrThrow(h.IntersectionType);
|
|
45
91
|
for (let t of e.getTypeNodes()) {
|
|
46
|
-
if (t.getKind() !==
|
|
47
|
-
let e = t.asKindOrThrow(
|
|
92
|
+
if (t.getKind() !== h.TypeLiteral) continue;
|
|
93
|
+
let e = t.asKindOrThrow(h.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
|
|
48
94
|
if (n.some((e) => /^team\b/.test(e))) break;
|
|
49
95
|
n.push("team?: string | undefined", "teams?: { id: string; name: string }[]"), e.replaceWithText(`{ ${n.join("; ")}; }`);
|
|
50
96
|
break;
|
|
@@ -57,15 +103,27 @@ function _(e) {
|
|
|
57
103
|
});
|
|
58
104
|
return t;
|
|
59
105
|
}
|
|
60
|
-
function
|
|
61
|
-
if (!
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
function w(e) {
|
|
107
|
+
if (!f.existsSync(e)) return {
|
|
108
|
+
status: "not-found",
|
|
109
|
+
message: S
|
|
110
|
+
};
|
|
111
|
+
let t = s.fromPath(e);
|
|
112
|
+
return t.hasElement("TeamSwitcher") ? {
|
|
113
|
+
status: "success",
|
|
114
|
+
changed: !1
|
|
115
|
+
} : t.hasElement("Sidebar.Header") ? (t.modifyScript(C), t.replaceElement("Sidebar.Header", y), t.writeTo(e), {
|
|
116
|
+
status: "success",
|
|
117
|
+
changed: t.hasChanged()
|
|
118
|
+
}) : {
|
|
119
|
+
status: "failed",
|
|
120
|
+
message: x
|
|
121
|
+
};
|
|
64
122
|
}
|
|
65
123
|
//#endregion
|
|
66
124
|
//#region src/patterns/enable/teams/modifies/+layout.server.ts
|
|
67
|
-
function
|
|
68
|
-
if (!
|
|
125
|
+
function T(t) {
|
|
126
|
+
if (!f.existsSync(t)) {
|
|
69
127
|
let n = e`
|
|
70
128
|
export const load = async ({ locals, depends }) => {
|
|
71
129
|
const user = locals.pb.authStore.record!;
|
|
@@ -77,57 +135,59 @@ function y(t) {
|
|
|
77
135
|
return { user, team, teams, breadcrumbs };
|
|
78
136
|
};
|
|
79
137
|
`;
|
|
80
|
-
|
|
81
|
-
|
|
138
|
+
return f.writeFileSync(t, n), {
|
|
139
|
+
status: "success",
|
|
140
|
+
changed: !0
|
|
141
|
+
};
|
|
82
142
|
}
|
|
83
|
-
let n = new
|
|
143
|
+
let n = f.readFileSync(t, "utf8"), r = new m().addSourceFileAtPath(t), i = (e, t, n) => {
|
|
84
144
|
e.getProperty(t) || (t === n ? e.addShorthandPropertyAssignment({ name: t }) : e.addPropertyAssignment({
|
|
85
145
|
name: t,
|
|
86
146
|
initializer: n
|
|
87
147
|
}));
|
|
88
|
-
},
|
|
89
|
-
if (
|
|
90
|
-
let e =
|
|
91
|
-
if (e)
|
|
148
|
+
}, a, o, s = r.getVariableDeclaration("load");
|
|
149
|
+
if (s && s.getFirstAncestorByKind(h.VariableStatement)?.hasExportKeyword()) {
|
|
150
|
+
let e = s.getInitializerIfKind(h.ArrowFunction);
|
|
151
|
+
if (e) a = e;
|
|
92
152
|
else {
|
|
93
|
-
let e =
|
|
153
|
+
let e = s.getInitializer();
|
|
94
154
|
if (e) {
|
|
95
|
-
let t = e.getFirstDescendantByKind(
|
|
96
|
-
if (t)
|
|
155
|
+
let t = e.getFirstDescendantByKind(h.ArrowFunction);
|
|
156
|
+
if (t) a = t;
|
|
97
157
|
else {
|
|
98
|
-
let t = e.getFirstDescendantByKind(
|
|
99
|
-
t && (
|
|
158
|
+
let t = e.getFirstDescendantByKind(h.FunctionExpression);
|
|
159
|
+
t && (o = t);
|
|
100
160
|
}
|
|
101
161
|
}
|
|
102
162
|
}
|
|
103
163
|
}
|
|
104
|
-
if (!
|
|
105
|
-
let e =
|
|
106
|
-
e && e.isExported() && (
|
|
107
|
-
}
|
|
108
|
-
if (!i && !a) {
|
|
109
|
-
n.addFunction({
|
|
110
|
-
isExported: !0,
|
|
111
|
-
isAsync: !0,
|
|
112
|
-
name: "load",
|
|
113
|
-
parameters: [{ name: "{ locals, depends }" }],
|
|
114
|
-
statements: [
|
|
115
|
-
"const user = locals.pb.authStore.record!;",
|
|
116
|
-
"const team = locals.team;",
|
|
117
|
-
"const teams = await locals.pb.collection(\"teams\").getFullList();",
|
|
118
|
-
"depends(\"app:team\");",
|
|
119
|
-
"",
|
|
120
|
-
"const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];",
|
|
121
|
-
"return { user, team, teams, breadcrumbs };"
|
|
122
|
-
]
|
|
123
|
-
}), n.formatText(), n.saveSync();
|
|
124
|
-
return;
|
|
164
|
+
if (!a) {
|
|
165
|
+
let e = r.getFunction("load");
|
|
166
|
+
e && e.isExported() && (o = e);
|
|
125
167
|
}
|
|
126
|
-
|
|
127
|
-
|
|
168
|
+
if (!a && !o) return r.addFunction({
|
|
169
|
+
isExported: !0,
|
|
170
|
+
isAsync: !0,
|
|
171
|
+
name: "load",
|
|
172
|
+
parameters: [{ name: "{ locals, depends }" }],
|
|
173
|
+
statements: [
|
|
174
|
+
"const user = locals.pb.authStore.record!;",
|
|
175
|
+
"const team = locals.team;",
|
|
176
|
+
"const teams = await locals.pb.collection(\"teams\").getFullList();",
|
|
177
|
+
"depends(\"app:team\");",
|
|
178
|
+
"",
|
|
179
|
+
"const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];",
|
|
180
|
+
"return { user, team, teams, breadcrumbs };"
|
|
181
|
+
]
|
|
182
|
+
}), r.formatText(), r.saveSync(), {
|
|
183
|
+
status: "success",
|
|
184
|
+
changed: !0
|
|
185
|
+
};
|
|
186
|
+
let c = a ?? o, l = c.getParameters();
|
|
187
|
+
if (l.length === 0) c.insertParameter(0, { name: "{ locals, depends }" });
|
|
128
188
|
else {
|
|
129
|
-
let e =
|
|
130
|
-
if (n.getKind() ===
|
|
189
|
+
let e = l[0], t = e.getStructure(), n = e.getNameNode();
|
|
190
|
+
if (n.getKind() === h.ObjectBindingPattern) {
|
|
131
191
|
let r = n, i = r.getElements().some((e) => e.getName() === "depends"), a = r.getElements().some((e) => e.getName() === "locals");
|
|
132
192
|
if (!i) {
|
|
133
193
|
let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = n.length > 0 ? ", " + n.join(", ") : "";
|
|
@@ -154,97 +214,129 @@ function y(t) {
|
|
|
154
214
|
});
|
|
155
215
|
}
|
|
156
216
|
}
|
|
157
|
-
|
|
158
|
-
let
|
|
159
|
-
if (
|
|
160
|
-
let e =
|
|
217
|
+
a && !a.isAsync() ? a.setIsAsync(!0) : o && !o.isAsync() && o.setIsAsync(!0);
|
|
218
|
+
let u = c.getBody();
|
|
219
|
+
if (u && u.getKind() === h.Block) {
|
|
220
|
+
let e = u, t = e.getStatements(), n = t.some((e) => e.getKind() === h.VariableStatement && e.getDescendantsOfKind(h.Identifier).some((e) => e.getText() === "team")), r = t.some((e) => e.getKind() === h.VariableStatement && e.getDescendantsOfKind(h.Identifier).some((e) => e.getText() === "teams")), i = t.some((e) => e.getKind() === h.ExpressionStatement && e.getDescendantsOfKind(h.CallExpression).some((e) => {
|
|
161
221
|
if (e.getExpression().getText() !== "depends") return !1;
|
|
162
222
|
let t = e.getArguments(), n = t[0]?.getText() ?? "";
|
|
163
223
|
return t.length === 1 && (n === "'app:team'" || n === "\"app:team\"");
|
|
164
224
|
}));
|
|
165
225
|
n || e.insertStatements(1, "const team = locals.team;"), r || e.insertStatements(2, "const teams = await locals.pb.collection(\"teams\").getFullList();"), i || e.insertStatements(3, "depends(\"app:team\");");
|
|
166
226
|
}
|
|
167
|
-
if (
|
|
168
|
-
let e =
|
|
169
|
-
if (e.getKind() ===
|
|
227
|
+
if (a) {
|
|
228
|
+
let e = a.getBody();
|
|
229
|
+
if (e.getKind() === h.Block) e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
|
|
170
230
|
let t = e.getExpression();
|
|
171
231
|
if (t) {
|
|
172
|
-
if (t.getKind() ===
|
|
232
|
+
if (t.getKind() === h.ObjectLiteralExpression) {
|
|
173
233
|
let e = t;
|
|
174
|
-
|
|
175
|
-
} else if (t.getKind() ===
|
|
234
|
+
i(e, "team", "team"), i(e, "teams", "teams");
|
|
235
|
+
} else if (t.getKind() === h.ParenthesizedExpression) {
|
|
176
236
|
let e = t.getExpression();
|
|
177
|
-
if (e.getKind() ===
|
|
237
|
+
if (e.getKind() === h.ObjectLiteralExpression) {
|
|
178
238
|
let t = e;
|
|
179
|
-
|
|
239
|
+
i(t, "team", "team"), i(t, "teams", "teams");
|
|
180
240
|
}
|
|
181
241
|
}
|
|
182
242
|
}
|
|
183
243
|
});
|
|
184
244
|
else {
|
|
185
245
|
let t = e;
|
|
186
|
-
if (t.getKind() ===
|
|
246
|
+
if (t.getKind() === h.ParenthesizedExpression) {
|
|
187
247
|
let e = t.getExpression();
|
|
188
|
-
if (e.getKind() ===
|
|
248
|
+
if (e.getKind() === h.ObjectLiteralExpression) {
|
|
189
249
|
let t = e;
|
|
190
|
-
|
|
250
|
+
i(t, "team", "team"), i(t, "teams", "teams");
|
|
191
251
|
}
|
|
192
|
-
} else if (t.getKind() ===
|
|
252
|
+
} else if (t.getKind() === h.ObjectLiteralExpression) {
|
|
193
253
|
let e = t;
|
|
194
|
-
|
|
254
|
+
i(e, "team", "team"), i(e, "teams", "teams");
|
|
195
255
|
}
|
|
196
256
|
}
|
|
197
|
-
} else if (
|
|
198
|
-
let e =
|
|
199
|
-
e && e.getDescendantsOfKind(
|
|
257
|
+
} else if (o) {
|
|
258
|
+
let e = o.getBody();
|
|
259
|
+
e && e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
|
|
200
260
|
let t = e.getExpression();
|
|
201
261
|
if (t) {
|
|
202
|
-
if (t.getKind() ===
|
|
262
|
+
if (t.getKind() === h.ObjectLiteralExpression) {
|
|
203
263
|
let e = t;
|
|
204
|
-
|
|
205
|
-
} else if (t.getKind() ===
|
|
264
|
+
i(e, "team", "team"), i(e, "teams", "teams");
|
|
265
|
+
} else if (t.getKind() === h.ParenthesizedExpression) {
|
|
206
266
|
let e = t.getExpression();
|
|
207
|
-
if (e.getKind() ===
|
|
267
|
+
if (e.getKind() === h.ObjectLiteralExpression) {
|
|
208
268
|
let t = e;
|
|
209
|
-
|
|
269
|
+
i(t, "team", "team"), i(t, "teams", "teams");
|
|
210
270
|
}
|
|
211
271
|
}
|
|
212
272
|
}
|
|
213
273
|
});
|
|
214
274
|
}
|
|
215
|
-
|
|
275
|
+
return r.formatText(), r.saveSync(), {
|
|
276
|
+
status: "success",
|
|
277
|
+
changed: r.getFullText() !== n
|
|
278
|
+
};
|
|
216
279
|
}
|
|
217
280
|
//#endregion
|
|
218
281
|
//#region src/patterns/enable/teams/modifies/modify-nav-user.ts
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
282
|
+
var E = [
|
|
283
|
+
"import UsersIcon from '@lucide/svelte/icons/users';",
|
|
284
|
+
"",
|
|
285
|
+
"// Add to your navUser array:",
|
|
286
|
+
"{ title: 'Teams', url: '/teams', icon: UsersIcon }"
|
|
287
|
+
].join("\n"), D = [
|
|
288
|
+
"Add a Teams nav item to nav-user.svelte:",
|
|
289
|
+
"",
|
|
290
|
+
E
|
|
291
|
+
].join("\n"), O = [
|
|
292
|
+
"Create nav-user.svelte with a Teams entry:",
|
|
293
|
+
"",
|
|
294
|
+
E
|
|
295
|
+
].join("\n");
|
|
296
|
+
function k(e, t, n, r, i) {
|
|
297
|
+
let a = new s(e), o = !1, c = (e) => {
|
|
298
|
+
o || e((e) => {
|
|
299
|
+
let a = u(e, t, n, r, i);
|
|
300
|
+
return a.wasAdded && (o = !0), a.source;
|
|
224
301
|
});
|
|
225
302
|
};
|
|
226
|
-
return c((e) => a.modifyModuleScript(e)),
|
|
303
|
+
return c((e) => a.modifyModuleScript(e)), o || c((e) => a.modifyScript(e)), {
|
|
227
304
|
newNavUserSnippet: a.toString(),
|
|
228
|
-
wasAdded:
|
|
305
|
+
wasAdded: o
|
|
229
306
|
};
|
|
230
307
|
}
|
|
231
|
-
function
|
|
232
|
-
if (!
|
|
233
|
-
|
|
234
|
-
|
|
308
|
+
function A(e) {
|
|
309
|
+
if (!f.existsSync(e)) return {
|
|
310
|
+
status: "not-found",
|
|
311
|
+
message: O
|
|
312
|
+
};
|
|
313
|
+
let t = f.readFileSync(e, "utf8");
|
|
314
|
+
if (t.includes("/teams")) return {
|
|
315
|
+
status: "success",
|
|
316
|
+
changed: !1
|
|
317
|
+
};
|
|
318
|
+
let { newNavUserSnippet: n, wasAdded: r } = k(t, "Teams", "/teams", "UsersIcon", "@lucide/svelte/icons/users");
|
|
319
|
+
return r ? (f.writeFileSync(e, n, "utf8"), {
|
|
320
|
+
status: "success",
|
|
321
|
+
changed: !0
|
|
322
|
+
}) : {
|
|
323
|
+
status: "failed",
|
|
324
|
+
message: D
|
|
325
|
+
};
|
|
235
326
|
}
|
|
236
327
|
//#endregion
|
|
237
328
|
//#region src/patterns/enable/teams/generate.runtime.ts
|
|
238
|
-
async function
|
|
329
|
+
async function j(e, n, i) {
|
|
239
330
|
await r();
|
|
240
331
|
let o = a(n, "created", i);
|
|
241
332
|
o && e.push({
|
|
242
333
|
path: o,
|
|
243
334
|
language: t(o),
|
|
244
|
-
content:
|
|
335
|
+
content: f.readFileSync(o, "utf8"),
|
|
336
|
+
status: "success"
|
|
245
337
|
});
|
|
246
338
|
}
|
|
247
|
-
async function
|
|
339
|
+
async function M(e) {
|
|
248
340
|
let t = [];
|
|
249
341
|
await i(e.root, async (r) => {
|
|
250
342
|
let i = await r.collections.getOne("users"), a = await r.collections.create({
|
|
@@ -289,7 +381,7 @@ async function C(e) {
|
|
|
289
381
|
}
|
|
290
382
|
]
|
|
291
383
|
});
|
|
292
|
-
await
|
|
384
|
+
await j(t, "teams", e);
|
|
293
385
|
let o = await r.collections.create({
|
|
294
386
|
name: "team_memberships",
|
|
295
387
|
type: "base",
|
|
@@ -347,7 +439,7 @@ async function C(e) {
|
|
|
347
439
|
}
|
|
348
440
|
]
|
|
349
441
|
});
|
|
350
|
-
await
|
|
442
|
+
await j(t, "team_memberships", e), await r.collections.create({
|
|
351
443
|
name: "team_users",
|
|
352
444
|
type: "view",
|
|
353
445
|
fields: [
|
|
@@ -402,7 +494,7 @@ async function C(e) {
|
|
|
402
494
|
}
|
|
403
495
|
],
|
|
404
496
|
viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;"
|
|
405
|
-
}), await
|
|
497
|
+
}), await j(t, "team_users", e), await r.collections.create({
|
|
406
498
|
name: "team_invites",
|
|
407
499
|
type: "base",
|
|
408
500
|
fields: [
|
|
@@ -443,7 +535,7 @@ async function C(e) {
|
|
|
443
535
|
type: "autodate"
|
|
444
536
|
}
|
|
445
537
|
]
|
|
446
|
-
}), await
|
|
538
|
+
}), await j(t, "team_invites", e), await r.collections.create({
|
|
447
539
|
name: "team_invite_links",
|
|
448
540
|
type: "base",
|
|
449
541
|
fields: [
|
|
@@ -480,34 +572,20 @@ async function C(e) {
|
|
|
480
572
|
}
|
|
481
573
|
],
|
|
482
574
|
indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"]
|
|
483
|
-
}), await
|
|
484
|
-
let s = await
|
|
575
|
+
}), await j(t, "team_invite_links", e);
|
|
576
|
+
let s = await d(r, n, e);
|
|
485
577
|
t.push(...s);
|
|
486
578
|
});
|
|
487
|
-
let r = [], a =
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
content: d.readFileSync(o, "utf8")
|
|
498
|
-
});
|
|
499
|
-
let s = f.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
500
|
-
d.existsSync(s) && v(s) && r.push({
|
|
501
|
-
path: s,
|
|
502
|
-
language: "svelte",
|
|
503
|
-
content: d.readFileSync(s, "utf8")
|
|
504
|
-
});
|
|
505
|
-
let c = f.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
506
|
-
return x(c) && r.push({
|
|
507
|
-
path: c,
|
|
508
|
-
language: "svelte",
|
|
509
|
-
content: d.readFileSync(c, "utf8")
|
|
510
|
-
}), {
|
|
579
|
+
let r = [], a = (e) => {
|
|
580
|
+
e && r.push(e);
|
|
581
|
+
}, s = p.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
582
|
+
a(o(s, T(s)));
|
|
583
|
+
let c = p.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
584
|
+
a(o(c, v(c)));
|
|
585
|
+
let l = p.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
586
|
+
a(o(l, w(l)));
|
|
587
|
+
let u = p.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
588
|
+
return a(o(u, A(u))), {
|
|
511
589
|
creates: t,
|
|
512
590
|
modifies: r,
|
|
513
591
|
deletes: [],
|
|
@@ -517,6 +595,6 @@ async function C(e) {
|
|
|
517
595
|
};
|
|
518
596
|
}
|
|
519
597
|
//#endregion
|
|
520
|
-
export {
|
|
598
|
+
export { M as generate };
|
|
521
599
|
|
|
522
|
-
//# sourceMappingURL=generate.runtime-
|
|
600
|
+
//# sourceMappingURL=generate.runtime-B0EfMNMf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-B0EfMNMf.js","names":[],"sources":["../../src/patterns/enable/teams/modifies/modify-app-layout.ts","../../src/patterns/enable/teams/modifies/modify-app-sidebar.ts","../../src/patterns/enable/teams/modifies/+layout.server.ts","../../src/patterns/enable/teams/modifies/modify-nav-user.ts","../../src/patterns/enable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass team props to <AppSidebar> in your app layout:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app layout that renders <AppSidebar> with team props:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"teams\")) {\n return { status: \"success\", changed: false };\n }\n\n file.appendToAttributes(\n \"AppSidebar\",\n \" team={data.team} teams={data.teams ?? []}\",\n );\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NEW_HEADER = `<Sidebar.Header>\n\t\t<Sidebar.Menu>\n\t\t\t<TeamSwitcher {teams}>\n\t\t\t\t{#snippet children()}\n\t\t\t\t\t{@const activeTeam = teams.find((t) => t.id === team)}\n\t\t\t\t\t{#if activeTeam}\n\t\t\t\t\t\t<Avatar.Root class=\"size-8 rounded-lg\">\n\t\t\t\t\t\t\t<Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<img src=\"/favicon.svg\" alt=\"logo\" class=\"size-6\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">{meta.appName}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t\t<ChevronsUpDownIcon class=\"ml-auto\" />\n\t\t\t\t{/snippet}\n\t\t\t</TeamSwitcher>\n\t\t</Sidebar.Menu>\n\t</Sidebar.Header>`;\n\nconst IMPORT_SNIPPET = [\n \"import TeamSwitcher from '$lib/components/team-switcher.svelte';\",\n \"import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\",\n \"import * as Avatar from '$lib/components/ui/avatar';\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Replace the <Sidebar.Header> in your app sidebar with the team switcher.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Props to destructure in $props(): team, teams = []\",\n \"\",\n \"Markup to use as the header:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app sidebar with a <Sidebar.Header> containing the team switcher.\",\n \"\",\n \"Imports:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Header markup:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nfunction updateAppSidebarScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"TeamSwitcher\",\n moduleSpecifier: \"$lib/components/team-switcher.svelte\",\n },\n {\n defaultImport: \"ChevronsUpDownIcon\",\n moduleSpecifier: \"@lucide/svelte/icons/chevrons-up-down\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"$lib/components/ui/avatar\",\n },\n ]);\n\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n\n if (elements.some((e) => e.getName() === \"team\")) continue;\n\n // Type changes first — name change can shift positions and invalidate type node refs.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^team\\b/.test(t))) break;\n propTexts.push(\n \"team?: string | undefined\",\n \"teams?: { id: string; name: string }[]\",\n );\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Rebuild binding pattern: insert team, teams = [] before first rest/initializer element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elements.length;\n elementTexts.splice(insertIdx, 0, \"team\", \"teams = []\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n }\n sf.formatText();\n });\n return out;\n}\n\nexport function modifyAppSidebar(appSidebarPath: string): ModifyOutcome {\n if (!fs.existsSync(appSidebarPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(appSidebarPath);\n if (file.hasElement(\"TeamSwitcher\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Sidebar.Header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript(updateAppSidebarScript);\n file.replaceElement(\"Sidebar.Header\", NEW_HEADER);\n file.writeTo(appSidebarPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n return { user, team, teams, breadcrumbs };\n };\n `;\n\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n const hasProperty = !!obj.getProperty(name);\n if (!hasProperty) {\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n }\n };\n\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n \"const user = locals.pb.authStore.record!;\",\n \"const team = locals.team;\",\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n 'depends(\"app:team\");',\n \"\",\n 'const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];',\n \"return { user, team, teams, breadcrumbs };\",\n ],\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasDepends = obp\n .getElements()\n .some((el) => el.getName() === \"depends\");\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n\n if (!hasDepends) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n\n if (hasLocals) {\n first.set({\n name: `{ depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) {\n loadArrow.setIsAsync(true);\n } else if (loadFn && !loadFn.isAsync()) {\n loadFn.setIsAsync(true);\n }\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const hasTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id: import(\"ts-morph\").Identifier) => id.getText() === \"team\"),\n );\n\n const hasTeams = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id: import(\"ts-morph\").Identifier) => id.getText() === \"teams\",\n ),\n );\n\n const hasDependsTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((ce: import(\"ts-morph\").CallExpression) => {\n const expr = ce.getExpression();\n if (expr.getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:team'\" || argText === '\"app:team\"')\n );\n }),\n );\n\n if (!hasTeam) {\n blockBody.insertStatements(1, \"const team = locals.team;\");\n }\n\n if (!hasTeams) {\n blockBody.insertStatements(\n 2,\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n );\n }\n\n if (!hasDependsTeam) {\n blockBody.insertStatements(3, 'depends(\"app:team\");');\n }\n }\n\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n });\n } else {\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = bodyExpr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) {\n const returns = fnBody.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","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 TEAMS_NAV_SNIPPET = [\n \"import UsersIcon from '@lucide/svelte/icons/users';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Teams', url: '/teams', icon: UsersIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Teams nav item to nav-user.svelte:\",\n \"\",\n TEAMS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Teams entry:\",\n \"\",\n TEAMS_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(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Teams\",\n \"/teams\",\n \"UsersIcon\",\n \"@lucide/svelte/icons/users\",\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 path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { languageFromPath } from \"../../../core/util\";\nimport { applyCollectionRulePatches } from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { TEAM_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n) {\n // Wait so the next schema op lands in a different PocketBase timestamp second.\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) {\n return;\n }\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nexport async function generate(options: Options) {\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n\n const teamsCollection = await pb.collections.create({\n name: \"teams\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"name\",\n type: \"text\",\n required: true,\n },\n {\n name: \"owner\",\n type: \"relation\",\n cascadeDelete: false,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n });\n await pushMigrationCreates(creates, \"teams\", options);\n\n const teamMembershipsCollection = await pb.collections.create({\n name: \"team_memberships\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"user\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\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(creates, \"team_memberships\", options);\n\n await pb.collections.create({\n name: \"team_users\",\n type: \"view\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"email\",\n exceptDomains: null,\n onlyDomains: null,\n required: true,\n type: \"email\",\n },\n {\n name: \"name\",\n max: 255,\n required: false,\n type: \"text\",\n },\n {\n name: \"membership_id\",\n cascadeDelete: false,\n collectionId: teamMembershipsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: false,\n type: \"relation\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\n },\n ],\n viewQuery:\n \"select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;\",\n });\n await pushMigrationCreates(creates, \"team_users\", options);\n\n await pb.collections.create({\n name: \"team_invites\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"team\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"email\",\n type: \"email\",\n required: 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(creates, \"team_invites\", options);\n\n await pb.collections.create({\n name: \"team_invite_links\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\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 indexes: [\n \"CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)\",\n ],\n });\n await pushMigrationCreates(creates, \"team_invite_links\", options);\n\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n TEAM_RULE_PATCHES,\n options,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerPath, modifyLayoutServer(layoutServerPath)),\n );\n\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayoutSvelte(appLayoutPath)),\n );\n\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\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 return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AAIA,IAAM,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EAAsB,GAAmC;AACvE,KAAI,CAAC,EAAG,WAAW,EAAW,CAC5B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;C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