@foldspace-fe/casdoor-next-auth-kit 0.1.23 → 0.1.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.
Files changed (35) hide show
  1. package/dist/auth-role-C35sP1i6.d.ts +40 -0
  2. package/dist/callback-Da3JC_EN.d.ts +18 -0
  3. package/dist/casdoor/index.d.ts +3 -8
  4. package/dist/casdoor/index.js +6 -4
  5. package/dist/{chunk-GLK4IW22.js → chunk-CSQFNYTS.js} +25 -11
  6. package/dist/chunk-CSQFNYTS.js.map +1 -0
  7. package/dist/{chunk-MWXY4JSL.js → chunk-IPJT66SK.js} +19 -11
  8. package/dist/{chunk-MWXY4JSL.js.map → chunk-IPJT66SK.js.map} +1 -1
  9. package/dist/chunk-JCQ5P7QZ.js +74 -0
  10. package/dist/chunk-JCQ5P7QZ.js.map +1 -0
  11. package/dist/chunk-YHPSOLXM.js +904 -0
  12. package/dist/chunk-YHPSOLXM.js.map +1 -0
  13. package/dist/cli-templates-IhA9gjyF.d.ts +31 -0
  14. package/dist/cli-templates.d.ts +2 -0
  15. package/dist/cli-templates.js +7 -0
  16. package/dist/cli-templates.js.map +1 -0
  17. package/dist/cli.js +52 -557
  18. package/dist/cli.js.map +1 -1
  19. package/dist/index.d.ts +8 -14
  20. package/dist/index.js +56 -6
  21. package/dist/next/index.d.ts +3 -3
  22. package/dist/next/index.js +7 -5
  23. package/dist/{options-D2YQdRWu.d.ts → options-CpWDszxZ.d.ts} +5 -2
  24. package/dist/react/index.d.ts +5 -4
  25. package/dist/react/index.js +4 -18
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/skills/casdoor-next-auth-kit/SKILL.md +1 -0
  28. package/dist/{types-BJv6j3NZ.d.ts → types-COXcI8tx.d.ts} +3 -1
  29. package/package.json +1 -1
  30. package/dist/callback-rEWxVGyL.d.ts +0 -12
  31. package/dist/chunk-GLK4IW22.js.map +0 -1
  32. package/dist/chunk-SZVWLQQT.js +0 -332
  33. package/dist/chunk-SZVWLQQT.js.map +0 -1
  34. package/dist/chunk-T2M5MVPE.js +0 -20
  35. package/dist/chunk-T2M5MVPE.js.map +0 -1
@@ -1,332 +0,0 @@
1
- // src/core/env.ts
2
- var AUTH_KIT_ENV_FILES = [".env", ".env.local", ".env.production", ".env.example"];
3
- var AUTH_KIT_ENV_VARIABLES = [
4
- {
5
- key: "APP_URL",
6
- description: "\u7AD9\u70B9\u5BF9\u5916\u516C\u5F00\u5730\u5740",
7
- example: "https://your-domain.com",
8
- local: "http://localhost:5177",
9
- production: "https://your-domain.com"
10
- },
11
- {
12
- key: "NEXTAUTH_URL",
13
- description: "NextAuth \u56DE\u8C03\u5730\u5740",
14
- example: "http://localhost:5177",
15
- local: "http://localhost:5177",
16
- production: "https://your-domain.com"
17
- },
18
- {
19
- key: "NEXTAUTH_SECRET",
20
- description: "NextAuth JWT secret",
21
- example: "replace-with-a-random-secret",
22
- local: "replace-with-a-random-secret",
23
- production: "replace-with-a-random-secret"
24
- },
25
- {
26
- key: "GLOBAL_ADMIN_EMAILS",
27
- description: "\u5168\u5C40\u7BA1\u7406\u5458\u90AE\u7BB1\uFF0C\u9017\u53F7\u5206\u9694",
28
- example: "admin@example.com",
29
- local: "admin@example.com",
30
- production: "admin@example.com"
31
- },
32
- {
33
- key: "AUTH_DEBUG",
34
- description: "\u662F\u5426\u5F00\u542F\u8BA4\u8BC1\u8C03\u8BD5\u65E5\u5FD7",
35
- example: "false",
36
- local: "false",
37
- production: "false"
38
- },
39
- {
40
- key: "NEXT_PUBLIC_CASDOOR_SERVER_URL",
41
- description: "Casdoor \u670D\u52A1\u5730\u5740",
42
- example: "https://auth.example.com",
43
- local: "https://auth.example.com",
44
- production: "https://auth.example.com"
45
- },
46
- {
47
- key: "NEXT_PUBLIC_CASDOOR_CLIENT_ID",
48
- description: "Casdoor client id",
49
- example: "your-casdoor-client-id",
50
- local: "your-casdoor-client-id",
51
- production: "your-casdoor-client-id"
52
- },
53
- {
54
- key: "NEXT_PUBLIC_CASDOOR_APP_NAME",
55
- description: "Casdoor app name",
56
- example: "your-app-name",
57
- local: "your-app-name",
58
- production: "your-app-name"
59
- },
60
- {
61
- key: "NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME",
62
- description: "Casdoor organization name",
63
- example: "your-org-name",
64
- local: "your-org-name",
65
- production: "your-org-name"
66
- },
67
- {
68
- key: "NEXT_PUBLIC_CASDOOR_REDIRECT_PATH",
69
- description: "Casdoor OAuth \u56DE\u8C03\u8DEF\u5F84",
70
- example: "/callback",
71
- local: "/callback",
72
- production: "/callback"
73
- },
74
- {
75
- key: "NEXT_PUBLIC_CASDOOR_SIGNIN_PATH",
76
- description: "Casdoor authorize \u8DEF\u5F84",
77
- example: "/login/oauth/authorize",
78
- local: "/login/oauth/authorize",
79
- production: "/login/oauth/authorize"
80
- },
81
- {
82
- key: "NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH",
83
- description: "\u6CE8\u9500\u540E\u8DF3\u8F6C\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u9996\u9875",
84
- example: "/",
85
- local: "/",
86
- production: "/"
87
- },
88
- {
89
- key: "NEXT_PUBLIC_BILLING_PURCHASABLE_IDS",
90
- description: "Billing \u53EF\u8D2D\u4E70\u9879\u767D\u540D\u5355\uFF0C\u9017\u53F7\u5206\u9694",
91
- example: "membership-monthly,credits-50",
92
- local: "membership-monthly,credits-50",
93
- production: "membership-monthly,credits-50"
94
- },
95
- {
96
- key: "NEXT_PUBLIC_CASDOOR_STATIC_ORIGIN",
97
- description: "Casdoor \u9759\u6001\u8D44\u6E90 origin",
98
- example: "https://casdoor-static.foldspace.cn",
99
- local: "https://casdoor-static.foldspace.cn",
100
- production: "https://casdoor-static.foldspace.cn"
101
- },
102
- {
103
- key: "CASDOOR_CLIENT_SECRET",
104
- description: "Casdoor client secret",
105
- example: "your-casdoor-client-secret",
106
- local: "your-casdoor-client-secret",
107
- production: "your-casdoor-client-secret"
108
- },
109
- {
110
- key: "BILLING_PAYMENT_SUCCESS_DEBUG",
111
- description: "\u662F\u5426\u6253\u5370 payment-success \u8C03\u8BD5\u65E5\u5FD7",
112
- example: "false",
113
- local: "false",
114
- production: "false"
115
- }
116
- ];
117
- function stringifyEnvValue(value) {
118
- if (value === "") {
119
- return '""';
120
- }
121
- if (/^[A-Za-z0-9_./:-]+$/.test(value)) {
122
- return value;
123
- }
124
- return JSON.stringify(value);
125
- }
126
- function stripQuotes(value) {
127
- const trimmed = value.trim();
128
- if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
129
- return trimmed.slice(1, -1);
130
- }
131
- return trimmed;
132
- }
133
- function parseEnvKeys(content) {
134
- const keys = /* @__PURE__ */ new Set();
135
- for (const line of content.split(/\r?\n/)) {
136
- const trimmed = line.trim();
137
- if (!trimmed || trimmed.startsWith("#")) {
138
- continue;
139
- }
140
- const separatorIndex = trimmed.indexOf("=");
141
- if (separatorIndex === -1) {
142
- continue;
143
- }
144
- const key = trimmed.slice(0, separatorIndex).trim();
145
- if (key) {
146
- keys.add(key);
147
- }
148
- }
149
- return keys;
150
- }
151
- function readManagedEnvValue(content, key) {
152
- for (const line of content.split(/\r?\n/)) {
153
- const trimmed = line.trim();
154
- if (!trimmed || trimmed.startsWith("#")) {
155
- continue;
156
- }
157
- const separatorIndex = trimmed.indexOf("=");
158
- if (separatorIndex === -1) {
159
- continue;
160
- }
161
- const currentKey = trimmed.slice(0, separatorIndex).trim();
162
- if (currentKey !== key) {
163
- continue;
164
- }
165
- const rawValue = trimmed.slice(separatorIndex + 1).trim();
166
- return stripQuotes(rawValue);
167
- }
168
- return null;
169
- }
170
- function getManagedEnvValue(definition, file) {
171
- if (file === ".env.example") {
172
- return definition.example;
173
- }
174
- if (file === ".env.production") {
175
- return definition.production ?? definition.example;
176
- }
177
- if (file === ".env.local") {
178
- return definition.local ?? definition.example;
179
- }
180
- return definition.base ?? definition.local ?? definition.production ?? definition.example;
181
- }
182
- function buildManagedEnvTemplate(file, existingContent = "") {
183
- const existingKeys = parseEnvKeys(existingContent);
184
- const lines = existingContent.trimEnd() ? existingContent.trimEnd().split(/\r?\n/) : [];
185
- const missing = AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key));
186
- if (missing.length === 0 && existingContent) {
187
- return existingContent;
188
- }
189
- if (lines.length > 0) {
190
- lines.push("");
191
- }
192
- lines.push(`# Casdoor Next Auth Kit managed values for ${file}`);
193
- for (const definition of missing) {
194
- const value = getManagedEnvValue(definition, file);
195
- lines.push(`# ${definition.description}`);
196
- lines.push(`${definition.key}=${stringifyEnvValue(value)}`);
197
- lines.push("");
198
- }
199
- while (lines.length > 0 && lines[lines.length - 1] === "") {
200
- lines.pop();
201
- }
202
- return `${lines.join("\n")}
203
- `;
204
- }
205
- function getMissingManagedEnvKeys(content) {
206
- const existingKeys = parseEnvKeys(content);
207
- return AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key)).map(
208
- (definition) => definition.key
209
- );
210
- }
211
- function sanitizeExistingEnvContent(content) {
212
- return stripQuotes(content);
213
- }
214
-
215
- // src/prisma/schema-template.ts
216
- var AUTH_PRISMA_SCHEMA_MODELS = [
217
- {
218
- name: "AuthUser",
219
- description: "Shared authentication user record",
220
- fields: [
221
- { name: "id", type: "String", attributes: ["@id", "@default(cuid())"] },
222
- { name: "email", type: "String?", attributes: ["@unique"] },
223
- { name: "name", type: "String?" },
224
- { name: "image", type: "String?" },
225
- { name: "isAdmin", type: "Boolean", attributes: ["@default(false)"] },
226
- { name: "tokenBalance", type: "Int", attributes: ["@default(0)"] },
227
- { name: "isVip", type: "Boolean", attributes: ["@default(false)"] },
228
- { name: "createdAt", type: "DateTime", attributes: ["@default(now())"] },
229
- { name: "updatedAt", type: "DateTime", attributes: ["@updatedAt"] }
230
- ],
231
- blockAttributes: ["@@index([email])"]
232
- },
233
- {
234
- name: "AuthMembership",
235
- description: "Subscription membership snapshot",
236
- fields: [
237
- { name: "id", type: "String", attributes: ["@id", "@default(cuid())"] },
238
- { name: "userId", type: "String", attributes: ["@unique"] },
239
- { name: "plan", type: "String" },
240
- { name: "status", type: "String" },
241
- { name: "startsAt", type: "DateTime?" },
242
- { name: "endsAt", type: "DateTime?" },
243
- { name: "createdAt", type: "DateTime", attributes: ["@default(now())"] },
244
- { name: "updatedAt", type: "DateTime", attributes: ["@updatedAt"] }
245
- ],
246
- blockAttributes: ["@@index([userId])"]
247
- },
248
- {
249
- name: "AuthOrder",
250
- description: "Commerce order record",
251
- fields: [
252
- { name: "id", type: "String", attributes: ["@id", "@default(cuid())"] },
253
- { name: "userId", type: "String" },
254
- { name: "kind", type: "String" },
255
- { name: "status", type: "String" },
256
- { name: "amount", type: "Int" },
257
- { name: "currency", type: "String", attributes: ['@default("CNY")'] },
258
- { name: "payload", type: "Json?" },
259
- { name: "createdAt", type: "DateTime", attributes: ["@default(now())"] },
260
- { name: "updatedAt", type: "DateTime", attributes: ["@updatedAt"] }
261
- ],
262
- blockAttributes: ["@@index([userId])"]
263
- },
264
- {
265
- name: "AuthSubscription",
266
- description: "Commerce subscription record",
267
- fields: [
268
- { name: "id", type: "String", attributes: ["@id", "@default(cuid())"] },
269
- { name: "userId", type: "String" },
270
- { name: "productId", type: "String" },
271
- { name: "status", type: "String" },
272
- { name: "interval", type: "String" },
273
- { name: "startsAt", type: "DateTime?" },
274
- { name: "endsAt", type: "DateTime?" },
275
- { name: "createdAt", type: "DateTime", attributes: ["@default(now())"] },
276
- { name: "updatedAt", type: "DateTime", attributes: ["@updatedAt"] }
277
- ],
278
- blockAttributes: ["@@index([userId])", "@@index([productId])"]
279
- },
280
- {
281
- name: "AuthInvoice",
282
- description: "Commerce invoice record",
283
- fields: [
284
- { name: "id", type: "String", attributes: ["@id", "@default(cuid())"] },
285
- { name: "userId", type: "String" },
286
- { name: "orderId", type: "String?" },
287
- { name: "invoiceNo", type: "String", attributes: ["@unique"] },
288
- { name: "status", type: "String" },
289
- { name: "amount", type: "Int" },
290
- { name: "createdAt", type: "DateTime", attributes: ["@default(now())"] },
291
- { name: "updatedAt", type: "DateTime", attributes: ["@updatedAt"] }
292
- ],
293
- blockAttributes: ["@@index([userId])", "@@index([orderId])"]
294
- }
295
- ];
296
- function renderField(field) {
297
- const attributes = field.attributes?.length ? ` ${field.attributes.join(" ")}` : "";
298
- return ` ${field.name} ${field.type}${attributes}`;
299
- }
300
- function renderModel(model) {
301
- const lines = [
302
- `/// ${model.description}`,
303
- `model ${model.name} {`,
304
- ...model.fields.map(renderField)
305
- ];
306
- if (model.blockAttributes?.length) {
307
- lines.push(...model.blockAttributes.map((attribute) => ` ${attribute}`));
308
- }
309
- lines.push("}");
310
- return lines.join("\n");
311
- }
312
- function buildAuthPrismaSchemaTemplate(models = AUTH_PRISMA_SCHEMA_MODELS) {
313
- return [
314
- "// generated by @foldspace-fe/casdoor-next-auth-kit",
315
- "// merge these models into the host Prisma schema if you want a dedicated auth module",
316
- "",
317
- ...models.map(renderModel)
318
- ].join("\n\n");
319
- }
320
-
321
- export {
322
- AUTH_KIT_ENV_FILES,
323
- AUTH_KIT_ENV_VARIABLES,
324
- readManagedEnvValue,
325
- getManagedEnvValue,
326
- buildManagedEnvTemplate,
327
- getMissingManagedEnvKeys,
328
- sanitizeExistingEnvContent,
329
- AUTH_PRISMA_SCHEMA_MODELS,
330
- buildAuthPrismaSchemaTemplate
331
- };
332
- //# sourceMappingURL=chunk-SZVWLQQT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/env.ts","../src/prisma/schema-template.ts"],"sourcesContent":["import type { ManagedEnvFile, ManagedEnvVariableDefinition } from '../types';\n\nexport const AUTH_KIT_ENV_FILES: ManagedEnvFile[] = ['.env', '.env.local', '.env.production', '.env.example'];\n\nexport const AUTH_KIT_ENV_VARIABLES: ManagedEnvVariableDefinition[] = [\n {\n key: 'APP_URL',\n description: '站点对外公开地址',\n example: 'https://your-domain.com',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_URL',\n description: 'NextAuth 回调地址',\n example: 'http://localhost:5177',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_SECRET',\n description: 'NextAuth JWT secret',\n example: 'replace-with-a-random-secret',\n local: 'replace-with-a-random-secret',\n production: 'replace-with-a-random-secret',\n },\n {\n key: 'GLOBAL_ADMIN_EMAILS',\n description: '全局管理员邮箱,逗号分隔',\n example: 'admin@example.com',\n local: 'admin@example.com',\n production: 'admin@example.com',\n },\n {\n key: 'AUTH_DEBUG',\n description: '是否开启认证调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SERVER_URL',\n description: 'Casdoor 服务地址',\n example: 'https://auth.example.com',\n local: 'https://auth.example.com',\n production: 'https://auth.example.com',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_CLIENT_ID',\n description: 'Casdoor client id',\n example: 'your-casdoor-client-id',\n local: 'your-casdoor-client-id',\n production: 'your-casdoor-client-id',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_APP_NAME',\n description: 'Casdoor app name',\n example: 'your-app-name',\n local: 'your-app-name',\n production: 'your-app-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME',\n description: 'Casdoor organization name',\n example: 'your-org-name',\n local: 'your-org-name',\n production: 'your-org-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_REDIRECT_PATH',\n description: 'Casdoor OAuth 回调路径',\n example: '/callback',\n local: '/callback',\n production: '/callback',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SIGNIN_PATH',\n description: 'Casdoor authorize 路径',\n example: '/login/oauth/authorize',\n local: '/login/oauth/authorize',\n production: '/login/oauth/authorize',\n },\n {\n key: 'NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH',\n description: '注销后跳转路径,默认首页',\n example: '/',\n local: '/',\n production: '/',\n },\n {\n key: 'NEXT_PUBLIC_BILLING_PURCHASABLE_IDS',\n description: 'Billing 可购买项白名单,逗号分隔',\n example: 'membership-monthly,credits-50',\n local: 'membership-monthly,credits-50',\n production: 'membership-monthly,credits-50',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_STATIC_ORIGIN',\n description: 'Casdoor 静态资源 origin',\n example: 'https://casdoor-static.foldspace.cn',\n local: 'https://casdoor-static.foldspace.cn',\n production: 'https://casdoor-static.foldspace.cn',\n },\n {\n key: 'CASDOOR_CLIENT_SECRET',\n description: 'Casdoor client secret',\n example: 'your-casdoor-client-secret',\n local: 'your-casdoor-client-secret',\n production: 'your-casdoor-client-secret',\n },\n {\n key: 'BILLING_PAYMENT_SUCCESS_DEBUG',\n description: '是否打印 payment-success 调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n];\n\nfunction stringifyEnvValue(value: string): string {\n if (value === '') {\n return '\"\"';\n }\n\n if (/^[A-Za-z0-9_./:-]+$/.test(value)) {\n return value;\n }\n\n return JSON.stringify(value);\n}\n\nfunction stripQuotes(value: string): string {\n const trimmed = value.trim();\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n\n return trimmed;\n}\n\nfunction parseEnvKeys(content: string): Set<string> {\n const keys = new Set<string>();\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const key = trimmed.slice(0, separatorIndex).trim();\n if (key) {\n keys.add(key);\n }\n }\n return keys;\n}\n\nexport function readManagedEnvValue(content: string, key: string): string | null {\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const currentKey = trimmed.slice(0, separatorIndex).trim();\n if (currentKey !== key) {\n continue;\n }\n\n const rawValue = trimmed.slice(separatorIndex + 1).trim();\n return stripQuotes(rawValue);\n }\n\n return null;\n}\n\nexport function getManagedEnvValue(definition: ManagedEnvVariableDefinition, file: ManagedEnvFile): string {\n if (file === '.env.example') {\n return definition.example;\n }\n if (file === '.env.production') {\n return definition.production ?? definition.example;\n }\n if (file === '.env.local') {\n return definition.local ?? definition.example;\n }\n return definition.base ?? definition.local ?? definition.production ?? definition.example;\n}\n\nexport function buildManagedEnvTemplate(file: ManagedEnvFile, existingContent = ''): string {\n const existingKeys = parseEnvKeys(existingContent);\n const lines: string[] = existingContent.trimEnd() ? existingContent.trimEnd().split(/\\r?\\n/) : [];\n const missing = AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key));\n\n if (missing.length === 0 && existingContent) {\n return existingContent;\n }\n\n if (lines.length > 0) {\n lines.push('');\n }\n\n lines.push(`# Casdoor Next Auth Kit managed values for ${file}`);\n for (const definition of missing) {\n const value = getManagedEnvValue(definition, file);\n lines.push(`# ${definition.description}`);\n lines.push(`${definition.key}=${stringifyEnvValue(value)}`);\n lines.push('');\n }\n\n while (lines.length > 0 && lines[lines.length - 1] === '') {\n lines.pop();\n }\n\n return `${lines.join('\\n')}\\n`;\n}\n\nexport function getMissingManagedEnvKeys(content: string): string[] {\n const existingKeys = parseEnvKeys(content);\n return AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key)).map(\n (definition) => definition.key,\n );\n}\n\nexport function sanitizeExistingEnvContent(content: string): string {\n return stripQuotes(content);\n}\n","import type { PrismaSchemaFieldDefinition, PrismaSchemaModelDefinition } from '../types';\n\nexport const AUTH_PRISMA_SCHEMA_MODELS: PrismaSchemaModelDefinition[] = [\n {\n name: 'AuthUser',\n description: 'Shared authentication user record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'email', type: 'String?', attributes: ['@unique'] },\n { name: 'name', type: 'String?' },\n { name: 'image', type: 'String?' },\n { name: 'isAdmin', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'tokenBalance', type: 'Int', attributes: ['@default(0)'] },\n { name: 'isVip', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([email])'],\n },\n {\n name: 'AuthMembership',\n description: 'Subscription membership snapshot',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String', attributes: ['@unique'] },\n { name: 'plan', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthOrder',\n description: 'Commerce order record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'kind', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'currency', type: 'String', attributes: ['@default(\"CNY\")'] },\n { name: 'payload', type: 'Json?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthSubscription',\n description: 'Commerce subscription record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'productId', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'interval', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([productId])'],\n },\n {\n name: 'AuthInvoice',\n description: 'Commerce invoice record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'orderId', type: 'String?' },\n { name: 'invoiceNo', type: 'String', attributes: ['@unique'] },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([orderId])'],\n },\n];\n\nfunction renderField(field: PrismaSchemaFieldDefinition): string {\n const attributes = field.attributes?.length ? ` ${field.attributes.join(' ')}` : '';\n return ` ${field.name} ${field.type}${attributes}`;\n}\n\nfunction renderModel(model: PrismaSchemaModelDefinition): string {\n const lines = [\n `/// ${model.description}`,\n `model ${model.name} {`,\n ...model.fields.map(renderField),\n ];\n\n if (model.blockAttributes?.length) {\n lines.push(...model.blockAttributes.map((attribute) => ` ${attribute}`));\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\nexport function buildAuthPrismaSchemaTemplate(models: PrismaSchemaModelDefinition[] = AUTH_PRISMA_SCHEMA_MODELS): string {\n return [\n '// generated by @foldspace-fe/casdoor-next-auth-kit',\n '// merge these models into the host Prisma schema if you want a dedicated auth module',\n '',\n ...models.map(renderModel),\n ].join('\\n\\n');\n}\n"],"mappings":";AAEO,IAAM,qBAAuC,CAAC,QAAQ,cAAc,mBAAmB,cAAc;AAErG,IAAM,yBAAyD;AAAA,EACpE;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS;AAAA,IACT,O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QAAM,QAAQ;AAAA,IACZ,OAAO,MAAM,WAAW;AAAA,IACxB,SAAS,MAAM,IAAI;AAAA,IACnB,GAAG,MAAM,OAAO,IAAI,WAAW;AAAA,EACjC;AAEA,MAAI,MAAM,iBAAiB,QAAQ;AACjC,UAAM,KAAK,GAAG,MAAM,gBAAgB,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;AAAA,EAC1E;AAEA,QAAM,KAAK,GAAG;AACd,SAAO,MAAM,KAAK,IAAI;AACxB;AAEO,SAAS,8BAA8B,SAAwC,2BAAmC;AACvH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,OAAO,IAAI,WAAW;AAAA,EAC3B,EAAE,KAAK,MAAM;AACf;","names":[]}
@@ -1,20 +0,0 @@
1
- // src/core/redirect.ts
2
- function buildAuthJumpHref(kind, redirect, basePath = "/auth") {
3
- const normalizedBasePath = basePath ? basePath.startsWith("/") ? basePath : "/" + basePath : "";
4
- const targetPath = (normalizedBasePath + "/" + kind).replace(/\/+/g, "/");
5
- const url = new URL(targetPath, "http://localhost");
6
- if (redirect) {
7
- url.searchParams.set("redirect", redirect);
8
- }
9
- return url.pathname + url.search;
10
- }
11
- function resolvePostLoginRedirect(user, fallback = "/") {
12
- if (user.isAdmin) return "/admin";
13
- return fallback;
14
- }
15
-
16
- export {
17
- buildAuthJumpHref,
18
- resolvePostLoginRedirect
19
- };
20
- //# sourceMappingURL=chunk-T2M5MVPE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/redirect.ts"],"sourcesContent":["import type { AuthUser } from '../types';\n\nexport function buildAuthJumpHref(kind: 'login' | 'signup', redirect?: string, basePath = '/auth'): string {\n const normalizedBasePath = basePath ? (basePath.startsWith('/') ? basePath : '/' + basePath) : '';\n const targetPath = (normalizedBasePath + '/' + kind).replace(/\\/+/g, '/');\n const url = new URL(targetPath, 'http://localhost');\n\n if (redirect) {\n url.searchParams.set('redirect', redirect);\n }\n\n return url.pathname + url.search;\n}\n\nexport function resolvePostLoginRedirect(user: AuthUser, fallback = '/'): string {\n if (user.isAdmin) return '/admin';\n return fallback;\n}\n"],"mappings":";AAEO,SAAS,kBAAkB,MAA0B,UAAmB,WAAW,SAAiB;AACzG,QAAM,qBAAqB,WAAY,SAAS,WAAW,GAAG,IAAI,WAAW,MAAM,WAAY;AAC/F,QAAM,cAAc,qBAAqB,MAAM,MAAM,QAAQ,QAAQ,GAAG;AACxE,QAAM,MAAM,IAAI,IAAI,YAAY,kBAAkB;AAElD,MAAI,UAAU;AACZ,QAAI,aAAa,IAAI,YAAY,QAAQ;AAAA,EAC3C;AAEA,SAAO,IAAI,WAAW,IAAI;AAC5B;AAEO,SAAS,yBAAyB,MAAgB,WAAW,KAAa;AAC/E,MAAI,KAAK,QAAS,QAAO;AACzB,SAAO;AACT;","names":[]}