@velastack/patterns 0.0.23 → 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/README.md +9 -16
- 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 +250 -231
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- 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
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./dedent-BFNYR8cb.js";
|
|
2
|
-
import { n as t, r as n, t as r } from "./pocketbase-CPRrN7Qs.js";
|
|
3
|
-
import { i, n as a, r as o } from "./ts-morph-helpers-BiOU9sUx.js";
|
|
4
|
-
import s from "node:fs";
|
|
5
|
-
import c from "node:path";
|
|
6
|
-
import { Project as l, SyntaxKind as u } from "ts-morph";
|
|
7
|
-
//#region src/patterns/enable/auth/modifies/+layout.server.ts
|
|
8
|
-
function d(t) {
|
|
9
|
-
if (!s.existsSync(t)) {
|
|
10
|
-
let n = e`
|
|
11
|
-
export const load = async ({ locals }) => {
|
|
12
|
-
return { user: locals.pb.authStore.record };
|
|
13
|
-
};
|
|
14
|
-
`;
|
|
15
|
-
s.writeFileSync(t, n);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
let n = new l().addSourceFileAtPath(t), r = (e) => {
|
|
19
|
-
e.getProperty("user") || e.addPropertyAssignment({
|
|
20
|
-
name: "user",
|
|
21
|
-
initializer: "locals.pb.authStore.record"
|
|
22
|
-
});
|
|
23
|
-
}, i, a, o = n.getVariableDeclaration("load");
|
|
24
|
-
if (o && o.getFirstAncestorByKind(u.VariableStatement)?.hasExportKeyword()) {
|
|
25
|
-
let e = o.getInitializerIfKind(u.ArrowFunction);
|
|
26
|
-
if (e) i = e;
|
|
27
|
-
else {
|
|
28
|
-
let e = o.getInitializer();
|
|
29
|
-
if (e) {
|
|
30
|
-
let t = e.getFirstDescendantByKind(u.ArrowFunction);
|
|
31
|
-
if (t) i = t;
|
|
32
|
-
else {
|
|
33
|
-
let t = e.getFirstDescendantByKind(u.FunctionExpression);
|
|
34
|
-
t && (a = t);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (!i) {
|
|
40
|
-
let e = n.getFunction("load");
|
|
41
|
-
e && e.isExported() && (a = e);
|
|
42
|
-
}
|
|
43
|
-
if (!i && !a) {
|
|
44
|
-
n.addFunction({
|
|
45
|
-
isExported: !0,
|
|
46
|
-
isAsync: !0,
|
|
47
|
-
name: "load",
|
|
48
|
-
parameters: [{ name: "{ locals }" }],
|
|
49
|
-
statements: "return { user: locals.pb.authStore.record };"
|
|
50
|
-
}), n.formatText(), n.saveSync();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
let c = i ?? a, d = c.getParameters();
|
|
54
|
-
if (d.length === 0) c.insertParameter(0, { name: "{ locals }" });
|
|
55
|
-
else {
|
|
56
|
-
let e = d[0], t = e.getStructure(), n = e.getNameNode();
|
|
57
|
-
if (n.getKind() === u.ObjectBindingPattern) {
|
|
58
|
-
let r = n;
|
|
59
|
-
if (!r.getElements().some((e) => e.getName() === "locals")) {
|
|
60
|
-
let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = n.length > 0 ? ", " + n.join(", ") : "";
|
|
61
|
-
e.set({
|
|
62
|
-
name: `{ locals${i} }`,
|
|
63
|
-
type: t.type,
|
|
64
|
-
initializer: t.initializer
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
let n = e.getName();
|
|
69
|
-
n !== "locals" && e.set({
|
|
70
|
-
name: `{ locals, ...${n} }`,
|
|
71
|
-
type: t.type,
|
|
72
|
-
initializer: t.initializer
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (i) {
|
|
77
|
-
let e = i.getBody();
|
|
78
|
-
if (e.getKind() === u.Block) e.getDescendantsOfKind(u.ReturnStatement).forEach((e) => {
|
|
79
|
-
let t = e.getExpression();
|
|
80
|
-
if (t) {
|
|
81
|
-
if (t.getKind() === u.ObjectLiteralExpression) r(t);
|
|
82
|
-
else if (t.getKind() === u.ParenthesizedExpression) {
|
|
83
|
-
let e = t.getExpression();
|
|
84
|
-
e.getKind() === u.ObjectLiteralExpression && r(e);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
else {
|
|
89
|
-
let t = e;
|
|
90
|
-
if (t.getKind() === u.ParenthesizedExpression) {
|
|
91
|
-
let e = t.getExpression();
|
|
92
|
-
e.getKind() === u.ObjectLiteralExpression && r(e);
|
|
93
|
-
} else t.getKind() === u.ObjectLiteralExpression && r(t);
|
|
94
|
-
}
|
|
95
|
-
} else if (a) {
|
|
96
|
-
let e = a.getBody();
|
|
97
|
-
e && e.getDescendantsOfKind(u.ReturnStatement).forEach((e) => {
|
|
98
|
-
let t = e.getExpression();
|
|
99
|
-
if (t) {
|
|
100
|
-
if (t.getKind() === u.ObjectLiteralExpression) r(t);
|
|
101
|
-
else if (t.getKind() === u.ParenthesizedExpression) {
|
|
102
|
-
let e = t.getExpression();
|
|
103
|
-
e.getKind() === u.ObjectLiteralExpression && r(e);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
n.formatText(), n.saveSync();
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/patterns/enable/auth/modifies/root-layout.svelte.ts
|
|
112
|
-
var f = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <Avatar.Root>\n {#if data.user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n alt={data.user?.email}\n />\n {/if}\n <Avatar.Fallback>\n {data.user?.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ";
|
|
113
|
-
function p(e) {
|
|
114
|
-
if (!s.existsSync(e)) return !1;
|
|
115
|
-
let t = i.fromPath(e);
|
|
116
|
-
return !t.hasElement("Navbar.List") || t.hasElement("AuthMenu.Root") ? !1 : (t.modifyScript((e) => {
|
|
117
|
-
let { source: t } = o(e, (e) => {
|
|
118
|
-
a(e, [{
|
|
119
|
-
namespaceImport: "AuthMenu",
|
|
120
|
-
moduleSpecifier: "$lib/components/ui/auth-menu"
|
|
121
|
-
}, {
|
|
122
|
-
namespaceImport: "Avatar",
|
|
123
|
-
moduleSpecifier: "$lib/components/ui/avatar"
|
|
124
|
-
}]);
|
|
125
|
-
});
|
|
126
|
-
return t;
|
|
127
|
-
}), t.insertBeforeClosingTag("Navbar.List", f), t.writeTo(e), t.hasChanged());
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/patterns/enable/auth/modifies/hooks.server.ts
|
|
131
|
-
function m(e) {
|
|
132
|
-
let t = new l().addSourceFileAtPath(e), n = t.getDescendantsOfKind(u.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
133
|
-
if (!n) {
|
|
134
|
-
t.saveSync();
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
let r = n.getArguments();
|
|
138
|
-
if (r.length === 0) {
|
|
139
|
-
n.addArgument("{ auth: { protectedRoutes: ['/(app)'] } }"), t.formatText(), t.saveSync();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
let i = r[0];
|
|
143
|
-
if (i.getKind() !== u.ObjectLiteralExpression) {
|
|
144
|
-
n.insertArgument(0, "{ auth: { protectedRoutes: ['/(app)'] } }"), t.formatText(), t.saveSync();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
let a = i.asKindOrThrow(u.ObjectLiteralExpression), o = a.getProperty("auth");
|
|
148
|
-
if (!o) {
|
|
149
|
-
a.addPropertyAssignment({
|
|
150
|
-
name: "auth",
|
|
151
|
-
initializer: "{ protectedRoutes: ['/(app)'] }"
|
|
152
|
-
}), t.formatText(), t.saveSync();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (o.getKind() === u.PropertyAssignment) {
|
|
156
|
-
let e = o.getInitializer();
|
|
157
|
-
if (e && e.getKind() === u.ObjectLiteralExpression) {
|
|
158
|
-
let t = e, n = t.getProperty("protectedRoutes");
|
|
159
|
-
if (!n) t.addPropertyAssignment({
|
|
160
|
-
name: "protectedRoutes",
|
|
161
|
-
initializer: "['/(app)']"
|
|
162
|
-
});
|
|
163
|
-
else if (n.getKind() === u.PropertyAssignment) {
|
|
164
|
-
let e = n.getInitializer();
|
|
165
|
-
if (e && e.getKind() === u.ArrayLiteralExpression) {
|
|
166
|
-
let t = e;
|
|
167
|
-
t.getElements().some((e) => e.getText().replace(/['"`]/g, "") === "/(app)") || t.addElement("'/(app)'");
|
|
168
|
-
} else n.setInitializer("['/(app)']");
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
t.formatText(), t.saveSync();
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/patterns/enable/auth/generate.runtime.ts
|
|
176
|
-
async function h(e) {
|
|
177
|
-
let { input: i } = e, a = [];
|
|
178
|
-
await n(e.root, async (n) => {
|
|
179
|
-
await n.settings.update({ meta: {
|
|
180
|
-
senderName: i.senderName,
|
|
181
|
-
senderAddress: i.senderAddress
|
|
182
|
-
} }), await t();
|
|
183
|
-
let o = await n.collections.getOne("users");
|
|
184
|
-
if (!o) throw Error("Users collection not found");
|
|
185
|
-
let c = o.verificationTemplate.body.replace("{APP_URL}/_/#/auth/confirm-verification/{TOKEN}", "{APP_URL}/confirm-verification/{TOKEN}"), l = o.resetPasswordTemplate.body.replace("{APP_URL}/_/#/auth/confirm-reset/{TOKEN}", "{APP_URL}/confirm-reset/{TOKEN}"), u = o.confirmEmailChangeTemplate.body.replace("{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}", "{APP_URL}/confirm-email-change/{TOKEN}");
|
|
186
|
-
await n.collections.update("users", {
|
|
187
|
-
listRule: "@request.auth.id = id",
|
|
188
|
-
viewRule: "@request.auth.id = id",
|
|
189
|
-
createRule: "@request.auth.id = id",
|
|
190
|
-
updateRule: "@request.auth.id = id",
|
|
191
|
-
deleteRule: "@request.auth.id = id",
|
|
192
|
-
verificationTemplate: { body: c },
|
|
193
|
-
resetPasswordTemplate: { body: l },
|
|
194
|
-
confirmEmailChangeTemplate: { body: u }
|
|
195
|
-
}), await t();
|
|
196
|
-
let d = r("users", "updated", e);
|
|
197
|
-
d && a.push({
|
|
198
|
-
path: d,
|
|
199
|
-
language: "ts",
|
|
200
|
-
content: s.readFileSync(d, "utf8")
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
let o = [], l = c.join(e.root, "src", "routes", "+layout.server.ts");
|
|
204
|
-
await d(l), o.push({
|
|
205
|
-
path: l,
|
|
206
|
-
language: "ts",
|
|
207
|
-
content: s.readFileSync(l, "utf8")
|
|
208
|
-
});
|
|
209
|
-
let u = c.join(e.root, "src", "routes", "(public)", "root-layout.svelte");
|
|
210
|
-
s.existsSync(u) || (u = c.join(e.root, "src", "routes", "root-layout.svelte")), s.existsSync(u) || (u = c.join(e.root, "src", "routes", "(public)", "+layout.svelte")), s.existsSync(u) || (u = c.join(e.root, "src", "routes", "+layout.svelte")), s.existsSync(u) && (p(u), o.push({
|
|
211
|
-
path: u,
|
|
212
|
-
language: "svelte",
|
|
213
|
-
content: s.readFileSync(u, "utf8")
|
|
214
|
-
}));
|
|
215
|
-
let f = c.join(e.root, "src", "hooks.server.ts");
|
|
216
|
-
return s.existsSync(f) && (m(f), o.push({
|
|
217
|
-
path: f,
|
|
218
|
-
language: "ts",
|
|
219
|
-
content: s.readFileSync(f, "utf8")
|
|
220
|
-
})), {
|
|
221
|
-
creates: [],
|
|
222
|
-
modifies: o,
|
|
223
|
-
deletes: [],
|
|
224
|
-
components: [],
|
|
225
|
-
packages: [],
|
|
226
|
-
collections: []
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
//#endregion
|
|
230
|
-
export { h as generate };
|
|
231
|
-
|
|
232
|
-
//# sourceMappingURL=generate.runtime-DXkJgkP4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-DXkJgkP4.js","names":[],"sources":["../../src/patterns/enable/auth/modifies/+layout.server.ts","../../src/patterns/enable/auth/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth/modifies/hooks.server.ts","../../src/patterns/enable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyLayoutServer(layoutPath: string) {\n if (!fs.existsSync(layoutPath)) {\n // write file directly\n\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return;\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\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 no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\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 hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\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 addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\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 addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t{data.user?.email?.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</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nexport function modifyRootLayoutSvelte(layoutPath: string): boolean {\n if (!fs.existsSync(layoutPath)) return false;\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) return false;\n if (file.hasElement(\"AuthMenu.Root\")) return false;\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"$lib/components/ui/auth-menu\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"$lib/components/ui/avatar\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return file.hasChanged();\n}\n","import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n // Create an options object if missing\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n // Replace non-object first arg with an object including auth\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n // Replace non-array with desired value\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n // Modify files\n let modifies: File[] = [];\n\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n\n await modifyLayoutServer(layoutServerFile);\n modifies.push({\n path: layoutServerFile,\n language: \"ts\",\n content: fs.readFileSync(layoutServerFile, \"utf8\"),\n });\n\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n let layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\");\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"+layout.svelte\",\n );\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n }\n\n if (fs.existsSync(layoutFile)) {\n modifyRootLayoutSvelte(layoutFile);\n modifies.push({\n path: layoutFile,\n language: \"svelte\",\n content: fs.readFileSync(layoutFile, \"utf8\"),\n });\n }\n\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n\n if (fs.existsSync(hooksServerFile)) {\n modifyHooksServer(hooksServerFile);\n modifies.push({\n path: hooksServerFile,\n language: \"ts\",\n content: fs.readFileSync(hooksServerFile, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies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,SAAS,EAAG,aAAa,GAAiB,OAAO;EAClD,CAAC,GAGG;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EAChB"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import e from "node:fs";
|
|
2
|
-
import t from "node:path";
|
|
3
|
-
import { Project as n, SyntaxKind as r } from "ts-morph";
|
|
4
|
-
//#region src/patterns/enable/api/modifies/hooks.server.ts
|
|
5
|
-
function i(e) {
|
|
6
|
-
let t = new n().addSourceFileAtPath(e), i = t.getDescendantsOfKind(r.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
7
|
-
if (!i) {
|
|
8
|
-
t.saveSync();
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
let a = i.getArguments();
|
|
12
|
-
if (a.length === 0) {
|
|
13
|
-
i.addArgument("{ api: { enabled: true } }"), t.formatText(), t.saveSync();
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
let o = a[0];
|
|
17
|
-
if (o.getKind() !== r.ObjectLiteralExpression) {
|
|
18
|
-
i.insertArgument(0, "{ api: { enabled: true } }"), t.formatText(), t.saveSync();
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
let s = o.asKindOrThrow(r.ObjectLiteralExpression), c = s.getProperty("api");
|
|
22
|
-
if (!c) {
|
|
23
|
-
s.addPropertyAssignment({
|
|
24
|
-
name: "api",
|
|
25
|
-
initializer: "{ enabled: true }"
|
|
26
|
-
}), t.formatText(), t.saveSync();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (c.getKind() === r.PropertyAssignment) {
|
|
30
|
-
let e = c.getInitializer();
|
|
31
|
-
if (e && e.getKind() === r.ObjectLiteralExpression) {
|
|
32
|
-
let t = e;
|
|
33
|
-
t.getProperty("enabled") || t.addPropertyAssignment({
|
|
34
|
-
name: "enabled",
|
|
35
|
-
initializer: "true"
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
t.formatText(), t.saveSync();
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/patterns/enable/api/generate.runtime.ts
|
|
43
|
-
async function a(n) {
|
|
44
|
-
let r = [], a = t.join(n.root, "src", "hooks.server.ts");
|
|
45
|
-
return e.existsSync(a) && (i(a), r.push({
|
|
46
|
-
path: a,
|
|
47
|
-
language: "ts",
|
|
48
|
-
content: e.readFileSync(a, "utf8")
|
|
49
|
-
})), {
|
|
50
|
-
creates: [],
|
|
51
|
-
modifies: r,
|
|
52
|
-
deletes: [],
|
|
53
|
-
components: [],
|
|
54
|
-
packages: [],
|
|
55
|
-
collections: []
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { a as generate };
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=generate.runtime-egq8I3EA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-egq8I3EA.js","names":[],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const modifies: File[] = [];\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n if (fs.existsSync(hooksServerPath)) {\n modifyHooksServer(hooksServerPath);\n modifies.push({\n path: hooksServerPath,\n language: \"ts\",\n content: fs.readFileSync(hooksServerPath, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;AAEA,SAAgB,EAAkB,GAAyB;CAEzD,IAAM,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AAEpE,KAAI,CAAC,GAAU;AACb,IAAW,UAAU;AACrB;;CAGF,IAAM,IAAO,EAAS,cAAc;AACpC,KAAI,EAAK,WAAW,GAAG;AAGrB,EAFA,EAAS,YAAY,6BAA6B,EAClD,EAAW,YAAY,EACvB,EAAW,UAAU;AACrB;;CAGF,IAAM,IAAW,EAAK;AACtB,KAAI,EAAS,SAAS,KAAK,EAAW,yBAAyB;AAG7D,EAFA,EAAS,eAAe,GAAG,6BAA6B,EACxD,EAAW,YAAY,EACvB,EAAW,UAAU;AACrB;;CAGF,IAAM,IAAa,EAAS,cAAc,EAAW,wBAAwB,EACvE,IAAU,EAAW,YAAY,MAAM;AAE7C,KAAI,CAAC,GAAS;AAMZ,EALA,EAAW,sBAAsB;GAC/B,MAAM;GACN,aAAa;GACd,CAAC,EACF,EAAW,YAAY,EACvB,EAAW,UAAU;AACrB;;AAGF,KAAI,EAAQ,SAAS,KAAK,EAAW,oBAAoB;EACvD,IAAM,IACJ,EACA,gBAAgB;AAClB,MAAI,KAAW,EAAQ,SAAS,KAAK,EAAW,yBAAyB;GACvE,IAAM,IAAS;AAEf,GADoB,EAAO,YAAY,UAAU,IAE/C,EAAO,sBAAsB;IAAE,MAAM;IAAW,aAAa;IAAQ,CAAC;;;AAM5E,CADA,EAAW,YAAY,EACvB,EAAW,UAAU;;;;ACrDvB,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAmB,EAAE,EAErB,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAUzE,QATI,EAAG,WAAW,EAAgB,KAChC,EAAkB,EAAgB,EAClC,EAAS,KAAK;EACZ,MAAM;EACN,UAAU;EACV,SAAS,EAAG,aAAa,GAAiB,OAAO;EAClD,CAAC,GAGG;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EAChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-uPCB71Ki.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\";\n\nexport function modifyAppLayoutSvelte(layoutPath: string): boolean {\n if (!fs.existsSync(layoutPath)) {\n return false;\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (\n !file.hasElement(\"AppSidebar\") ||\n file.hasAttribute(\"AppSidebar\", \"teams\")\n ) {\n return false;\n }\n\n file.appendToAttributes(\n \"AppSidebar\",\n \" team={data.team} teams={data.teams ?? []}\",\n );\n file.writeTo(layoutPath);\n return 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\";\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\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): boolean {\n if (!fs.existsSync(appSidebarPath)) return false;\n\n const file = SvelteFile.fromPath(appSidebarPath);\n if (file.hasElement(\"TeamSwitcher\")) return false;\n if (!file.hasElement(\"Sidebar.Header\")) return false;\n\n file.modifyScript(updateAppSidebarScript);\n file.replaceElement(\"Sidebar.Header\", NEW_HEADER);\n file.writeTo(appSidebarPath);\n return file.hasChanged();\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyLayoutServer(layoutServerPath: string) {\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;\n }\n\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;\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}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\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): boolean {\n if (!fs.existsSync(navUserPath)) return false;\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Teams\",\n \"/teams\",\n \"UsersIcon\",\n \"@lucide/svelte/icons/users\",\n );\n\n if (wasAdded) {\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n }\n\n return wasAdded;\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 { 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 });\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\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n if (fs.existsSync(layoutServerPath)) {\n modifyLayoutServer(layoutServerPath);\n modifies.push({\n path: layoutServerPath,\n language: \"ts\",\n content: fs.readFileSync(layoutServerPath, \"utf8\"),\n });\n }\n\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n if (fs.existsSync(appLayoutPath) && modifyAppLayoutSvelte(appLayoutPath)) {\n modifies.push({\n path: appLayoutPath,\n language: \"svelte\",\n content: fs.readFileSync(appLayoutPath, \"utf8\"),\n });\n }\n\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n if (fs.existsSync(appSidebarPath) && modifyAppSidebar(appSidebarPath)) {\n modifies.push({\n path: appSidebarPath,\n language: \"svelte\",\n content: fs.readFileSync(appSidebarPath, \"utf8\"),\n });\n }\n\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n if (modifyNavUser(navUserPath)) {\n modifies.push({\n path: navUserPath,\n language: \"svelte\",\n content: fs.readFileSync(navUserPath, \"utf8\"),\n });\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,EAAsB,GAA6B;AACjE,KAAI,CAAC,EAAG,WAAW,EAAW,CAC5B,QAAO;CAGT,IAAM,IAAO,EAAW,SAAS,EAAW;AAa5C,QAXE,CAAC,EAAK,WAAW,aAAa,IAC9B,EAAK,aAAa,cAAc,QAAQ,GAEjC,MAGT,EAAK,mBACH,cACA,6CACD,EACD,EAAK,QAAQ,EAAW,EACjB,EAAK,YAAY;;;;ACb1B,IAAM,IAAa;AAgCnB,SAAS,EAAuB,GAAwB;CACtD,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;AACzD,IAAc,GAAI;GAChB;IACE,eAAe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