next-workflow-builder 0.3.0
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 +165 -0
- package/dist/chunk-3MSAF2TH.js +438 -0
- package/dist/chunk-5YYA34YV.js +96 -0
- package/dist/chunk-7MUXUHEL.js +66 -0
- package/dist/chunk-BNYDOC3I.js +169 -0
- package/dist/chunk-D44JFQYX.js +546 -0
- package/dist/chunk-DJ7ANVJ3.js +51 -0
- package/dist/chunk-O3I2INCD.js +71 -0
- package/dist/chunk-OQHML4II.js +36 -0
- package/dist/chunk-P3DTV3QS.js +105 -0
- package/dist/chunk-XJ67EFQA.js +1162 -0
- package/dist/chunk-Z3BJJYHM.js +246 -0
- package/dist/client/index.d.ts +32 -0
- package/dist/client/index.js +13700 -0
- package/dist/condition-SFT7Y5YJ.js +29 -0
- package/dist/database-query-GRWP3S3M.js +99 -0
- package/dist/http-request-2HVCXQHK.js +76 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +66 -0
- package/dist/plugins/index.d.ts +113 -0
- package/dist/plugins/index.js +52 -0
- package/dist/server/api/index.d.ts +8 -0
- package/dist/server/api/index.js +2672 -0
- package/dist/server/index.d.ts +2911 -0
- package/dist/server/index.js +60 -0
- package/dist/style-prefixed.css +5167 -0
- package/dist/styles.css +5167 -0
- package/dist/types-BACZx2Ft.d.ts +139 -0
- package/package.json +112 -0
- package/src/scripts/nwb.ts +54 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
accounts,
|
|
3
|
+
db,
|
|
4
|
+
integrations,
|
|
5
|
+
sessions,
|
|
6
|
+
users,
|
|
7
|
+
verifications,
|
|
8
|
+
workflowExecutionLogs,
|
|
9
|
+
workflowExecutions,
|
|
10
|
+
workflowExecutionsRelations,
|
|
11
|
+
workflows
|
|
12
|
+
} from "./chunk-3MSAF2TH.js";
|
|
13
|
+
|
|
14
|
+
// src/server/auth/index.ts
|
|
15
|
+
import { betterAuth } from "better-auth";
|
|
16
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
17
|
+
import { anonymous } from "better-auth/plugins";
|
|
18
|
+
import { eq } from "drizzle-orm";
|
|
19
|
+
|
|
20
|
+
// src/server/auth/config-store.ts
|
|
21
|
+
function getAuthConfig() {
|
|
22
|
+
const authOptions = process.env.__NWB_AUTH_OPTIONS ? JSON.parse(process.env.__NWB_AUTH_OPTIONS) : void 0;
|
|
23
|
+
return {
|
|
24
|
+
hasRealProviders: Object.keys(authOptions?.socialProviders ?? {})?.length > 0,
|
|
25
|
+
authOptions
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/server/auth/index.ts
|
|
30
|
+
var schema = {
|
|
31
|
+
user: users,
|
|
32
|
+
session: sessions,
|
|
33
|
+
account: accounts,
|
|
34
|
+
verification: verifications,
|
|
35
|
+
workflows,
|
|
36
|
+
workflowExecutions,
|
|
37
|
+
workflowExecutionLogs,
|
|
38
|
+
workflowExecutionsRelations
|
|
39
|
+
};
|
|
40
|
+
function getBaseURL() {
|
|
41
|
+
if (process.env.BETTER_AUTH_URL) {
|
|
42
|
+
return process.env.BETTER_AUTH_URL;
|
|
43
|
+
}
|
|
44
|
+
if (process.env.NEXT_PUBLIC_APP_URL) {
|
|
45
|
+
return process.env.NEXT_PUBLIC_APP_URL;
|
|
46
|
+
}
|
|
47
|
+
if (process.env.VERCEL_URL) {
|
|
48
|
+
return `https://${process.env.VERCEL_URL}`;
|
|
49
|
+
}
|
|
50
|
+
return "http://localhost:3000";
|
|
51
|
+
}
|
|
52
|
+
function buildAuth() {
|
|
53
|
+
const config = getAuthConfig();
|
|
54
|
+
const plugins = [
|
|
55
|
+
// Anonymous sessions: enabled only when NO real providers configured (zero-config default)
|
|
56
|
+
...!config.hasRealProviders ? [
|
|
57
|
+
anonymous({
|
|
58
|
+
async onLinkAccount(data) {
|
|
59
|
+
const fromUserId = data.anonymousUser.user.id;
|
|
60
|
+
const toUserId = data.newUser.user.id;
|
|
61
|
+
console.log(
|
|
62
|
+
`[Anonymous Migration] Migrating from user ${fromUserId} to ${toUserId}`
|
|
63
|
+
);
|
|
64
|
+
try {
|
|
65
|
+
await db.update(workflows).set({ userId: toUserId }).where(eq(workflows.userId, fromUserId));
|
|
66
|
+
await db.update(workflowExecutions).set({ userId: toUserId }).where(eq(workflowExecutions.userId, fromUserId));
|
|
67
|
+
await db.update(integrations).set({ userId: toUserId }).where(eq(integrations.userId, fromUserId));
|
|
68
|
+
console.log(
|
|
69
|
+
`[Anonymous Migration] Successfully migrated data from ${fromUserId} to ${toUserId}`
|
|
70
|
+
);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(
|
|
73
|
+
"[Anonymous Migration] Error migrating user data:",
|
|
74
|
+
error
|
|
75
|
+
);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
] : []
|
|
81
|
+
];
|
|
82
|
+
return betterAuth({
|
|
83
|
+
baseURL: getBaseURL(),
|
|
84
|
+
// always use internal baseURL
|
|
85
|
+
database: drizzleAdapter(db, {
|
|
86
|
+
// always use internal db
|
|
87
|
+
provider: "pg",
|
|
88
|
+
schema
|
|
89
|
+
}),
|
|
90
|
+
...config.authOptions,
|
|
91
|
+
// user overrides (base layer)
|
|
92
|
+
plugins: [
|
|
93
|
+
...plugins,
|
|
94
|
+
// built-in plugins
|
|
95
|
+
...config.authOptions?.plugins ?? []
|
|
96
|
+
// user's additional plugins
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
var auth = buildAuth();
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
getAuthConfig,
|
|
104
|
+
auth
|
|
105
|
+
};
|