@appconda/nextjs 1.0.79 → 1.0.81

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.
@@ -25,7 +25,9 @@ export const authenticatedActionClient = actionClient.use(async ({ next }) => {
25
25
  if (!session?.user) {
26
26
  throw new AuthenticationError("Not authenticated");
27
27
  }
28
+ //@ts-ignore
28
29
  const userId = session.user.id;
30
+ //@ts-ignore
29
31
  const user = await getUser(userId);
30
32
  if (!user) {
31
33
  throw new AuthorizationError("User not found");
@@ -2,7 +2,7 @@ import CredentialsProvider from "next-auth/providers/credentials";
2
2
  import { cookies } from "next/headers";
3
3
  import { getAppcondaClient } from "../getAppcondaClient";
4
4
  import { Account } from "../modules/account/service";
5
- import { env } from "../lib/env";
5
+ import { getEnv } from "../lib/env";
6
6
  import { getSDKForCurrentUser } from "../getSDKForCurrentUser";
7
7
  import { Query } from "../query";
8
8
  export async function signIn({ userName, password }) {
@@ -169,7 +169,7 @@ export const authOptions = {
169
169
  },
170
170
  }),
171
171
  // Conditionally add enterprise SSO providers
172
- ...(env.ENTERPRISE_LICENSE_KEY ? [] : []),
172
+ ...(getEnv().ENTERPRISE_LICENSE_KEY ? [] : []),
173
173
  ],
174
174
  callbacks: {
175
175
  async jwt({ token }) {
@@ -183,16 +183,18 @@ export const authOptions = {
183
183
  } */
184
184
  return {
185
185
  ...token,
186
+ //@ts-ignore
186
187
  profile: { id: user.$id, ...user },
187
188
  };
188
189
  },
189
190
  async session({ session, token }) {
190
- // @ts-expect-error
191
+ //@ts-ignore
191
192
  session.user.id = token?.id;
192
- // @ts-expect-error
193
+ //@ts-ignore
193
194
  session.user = token.profile;
194
195
  return session;
195
196
  },
197
+ //@ts-ignore
196
198
  async signIn({ user, account }) {
197
199
  /* if (account?.provider === "credentials" || account?.provider === "token") {
198
200
  // check if user's email is verified or not
@@ -1,5 +1,5 @@
1
1
  import { Client } from "./client";
2
- import { env } from "./lib/env";
2
+ import { getEnv } from "./lib/env";
3
3
  function getPortAndHostname(urlString) {
4
4
  try {
5
5
  const url = new URL(urlString);
@@ -16,8 +16,8 @@ function getPortAndHostname(urlString) {
16
16
  }
17
17
  export async function getAppcondaClient() {
18
18
  let url;
19
- if (env.APPCONDA_ENDPOINT) {
20
- url = env.APPCONDA_ENDPOINT;
19
+ if (getEnv().APPCONDA_ENDPOINT) {
20
+ url = getEnv().APPCONDA_ENDPOINT;
21
21
  }
22
22
  else if (typeof window !== 'undefined') {
23
23
  const hostInfo = getPortAndHostname(window.location.href);
@@ -29,7 +29,7 @@ export async function getAppcondaClient() {
29
29
  }
30
30
  }
31
31
  else {
32
- url = env.APPCONDA_ENDPOINT || 'http://appconda/v1';
32
+ url = getEnv().APPCONDA_ENDPOINT || 'http://appconda/v1';
33
33
  }
34
34
  /* if (ApplicationConfig.Port == null) {
35
35
  url = `${ApplicationConfig.Protocol}://${ApplicationConfig.Domain}:${ApplicationConfig.Port}/v1`
@@ -1,10 +1,10 @@
1
1
  import { getAppcondaClient } from "./getAppcondaClient";
2
- import { env } from "./lib/env";
2
+ import { getEnv } from "./lib/env";
3
3
  import { WaitlistService } from "./modules";
4
4
  import { Configuration } from "./services/configuration";
5
5
  export async function getSDKForService() {
6
6
  const adminClient = await getAppcondaClient();
7
- adminClient.addHeader('x-service-token', env._SERVICE_TOKEN ?? '');
7
+ adminClient.addHeader('x-service-token', getEnv()._SERVICE_TOKEN ?? '');
8
8
  /*
9
9
  const accounts = new Account(adminClient);
10
10
  const databases = new Databases(adminClient);
package/dist/lib/env.d.ts CHANGED
@@ -1,6 +1 @@
1
- export declare const env: Readonly<{
2
- APPCONDA_ENDPOINT: string;
3
- APPCONDA_CLIENT_ENDPOINT: string;
4
- _SERVICE_TOKEN: string;
5
- ENTERPRISE_LICENSE_KEY: string;
6
- }>;
1
+ export declare const getEnv: () => any;
package/dist/lib/env.js CHANGED
@@ -1,120 +1,128 @@
1
1
  import { createEnv } from "@t3-oss/env-nextjs";
2
2
  import { z } from "zod";
3
- export const env = createEnv({
4
- /*
5
- * Serverside Environment variables, not available on the client.
6
- * Will throw if you access these variables on the client.
7
- */
8
- server: {
9
- APPCONDA_ENDPOINT: z.string(),
10
- APPCONDA_CLIENT_ENDPOINT: z.string(),
11
- _SERVICE_TOKEN: z.string(),
12
- ENTERPRISE_LICENSE_KEY: z.string(),
13
- /* AI_AZURE_LLM_API_KEY: z.string().optional(),
14
- AI_AZURE_EMBEDDINGS_DEPLOYMENT_ID: z.string().optional(),
15
- AI_AZURE_LLM_DEPLOYMENT_ID: z.string().optional(),
16
- AI_AZURE_EMBEDDINGS_RESSOURCE_NAME: z.string().optional(),
17
- AI_AZURE_LLM_RESSOURCE_NAME: z.string().optional(),
18
- AIRTABLE_CLIENT_ID: z.string().optional(),
19
- AZUREAD_CLIENT_ID: z.string().optional(),
20
- AZUREAD_CLIENT_SECRET: z.string().optional(),
21
- AZUREAD_TENANT_ID: z.string().optional(),
22
- CRON_SECRET: z.string().min(10),
23
- CUSTOMER_IO_API_KEY: z.string().optional(),
24
- CUSTOMER_IO_SITE_ID: z.string().optional(),
25
- DATABASE_URL: z.string().url(),
26
- DEBUG: z.enum(["1", "0"]).optional(),
27
- DEFAULT_ORGANIZATION_ID: z.string().optional(),
28
- DEFAULT_ORGANIZATION_ROLE: z.enum(["owner", "manager", "member", "billing"]).optional(),
29
- E2E_TESTING: z.enum(["1", "0"]).optional(),
30
- EMAIL_AUTH_DISABLED: z.enum(["1", "0"]).optional(),
31
- EMAIL_VERIFICATION_DISABLED: z.enum(["1", "0"]).optional(),
32
- ENCRYPTION_KEY: z.string().length(64).or(z.string().length(32)),
33
- ENTERPRISE_LICENSE_KEY: z.string().optional(),
34
- FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)).optional(),
35
- GITHUB_ID: z.string().optional(),
36
- GITHUB_SECRET: z.string().optional(),
37
- GOOGLE_CLIENT_ID: z.string().optional(),
38
- GOOGLE_CLIENT_SECRET: z.string().optional(),
39
- GOOGLE_SHEETS_CLIENT_ID: z.string().optional(),
40
- GOOGLE_SHEETS_CLIENT_SECRET: z.string().optional(),
41
- GOOGLE_SHEETS_REDIRECT_URL: z.string().optional(),
42
- HTTP_PROXY: z.string().url().optional(),
43
- HTTPS_PROXY: z.string().url().optional(),
44
- IMPRINT_URL: z
45
- .string()
46
- .url()
47
- .optional()
48
- .or(z.string().refine((str) => str === "")),
49
- IMPRINT_ADDRESS: z.string().optional(),
50
- INVITE_DISABLED: z.enum(["1", "0"]).optional(),
51
- INTERCOM_SECRET_KEY: z.string().optional(),
52
- IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
53
- MAIL_FROM: z.string().email().optional(),
54
- NEXTAUTH_SECRET: z.string().min(1),
55
- NOTION_OAUTH_CLIENT_ID: z.string().optional(),
56
- NOTION_OAUTH_CLIENT_SECRET: z.string().optional(),
57
- OIDC_CLIENT_ID: z.string().optional(),
58
- OIDC_CLIENT_SECRET: z.string().optional(),
59
- OIDC_DISPLAY_NAME: z.string().optional(),
60
- OIDC_ISSUER: z.string().optional(),
61
- OIDC_SIGNING_ALGORITHM: z.string().optional(),
62
- OPENTELEMETRY_LISTENER_URL: z.string().optional(),
63
- REDIS_URL: z.string().optional(),
64
- REDIS_HTTP_URL: z.string().optional(),
65
- PASSWORD_RESET_DISABLED: z.enum(["1", "0"]).optional(),
66
- PRIVACY_URL: z
67
- .string()
68
- .url()
69
- .optional()
70
- .or(z.string().refine((str) => str === "")),
71
- RATE_LIMITING_DISABLED: z.enum(["1", "0"]).optional(),
72
- S3_ACCESS_KEY: z.string().optional(),
73
- S3_BUCKET_NAME: z.string().optional(),
74
- S3_REGION: z.string().optional(),
75
- S3_SECRET_KEY: z.string().optional(),
76
- S3_ENDPOINT_URL: z.string().optional(),
77
- S3_FORCE_PATH_STYLE: z.enum(["1", "0"]).optional(),
78
- SHORT_URL_BASE: z.string().url().optional().or(z.string().length(0)),
79
- SIGNUP_DISABLED: z.enum(["1", "0"]).optional(),
80
- SLACK_CLIENT_ID: z.string().optional(),
81
- SLACK_CLIENT_SECRET: z.string().optional(),
82
- SMTP_HOST: z.string().min(1).optional(),
83
- SMTP_PORT: z.string().min(1).optional(),
84
- SMTP_SECURE_ENABLED: z.enum(["1", "0"]).optional(),
85
- SMTP_USER: z.string().min(1).optional(),
86
- SMTP_PASSWORD: z.string().min(1).optional(),
87
- SMTP_AUTHENTICATED: z.enum(["1", "0"]).optional(),
88
- SMTP_REJECT_UNAUTHORIZED_TLS: z.enum(["1", "0"]).optional(),
89
- STRIPE_SECRET_KEY: z.string().optional(),
90
- STRIPE_WEBHOOK_SECRET: z.string().optional(),
91
- TELEMETRY_DISABLED: z.enum(["1", "0"]).optional(),
92
- TERMS_URL: z
93
- .string()
94
- .url()
95
- .optional()
96
- .or(z.string().refine((str) => str === "")),
97
- TURNSTILE_SECRET_KEY: z.string().optional(),
98
- UPLOADS_DIR: z.string().min(1).optional(),
99
- VERCEL_URL: z.string().optional(),
100
- _ADMIN_DOMAIN: z.string().optional(),
101
- ADMIN_URL: z.string().url().optional(),
102
- UNSPLASH_ACCESS_KEY: z.string().optional(),
103
- LANGFUSE_SECRET_KEY: z.string().optional(),
104
- LANGFUSE_PUBLIC_KEY: z.string().optional(),
105
- LANGFUSE_BASEURL: z.string().optional(), */
106
- },
107
- /*
108
- * Due to how Next.js bundles environment variables on Edge and Client,
109
- * we need to manually destructure them to make sure all are included in bundle.
110
- *
111
- * 💡 You'll get type errors if not all variables from `server` & `client` are included here.
112
- */
113
- runtimeEnv: {
114
- APPCONDA_ENDPOINT: process.env.APPCONDA_ENDPOINT,
115
- APPCONDA_CLIENT_ENDPOINT: process.env.APPCONDA_CLIENT_ENDPOINT,
116
- _SERVICE_TOKEN: process.env._SERVICE_TOKEN,
117
- ENTERPRISE_LICENSE_KEY: process.env.ENTERPRISE_LICENSE_KEY,
118
- },
119
- });
120
- console.log(env);
3
+ export const getEnv = (() => {
4
+ let env = null;
5
+ return () => {
6
+ if (env == null) {
7
+ env = createEnv({
8
+ /*
9
+ * Serverside Environment variables, not available on the client.
10
+ * Will throw if you access these variables on the client.
11
+ */
12
+ server: {
13
+ APPCONDA_ENDPOINT: z.string(),
14
+ APPCONDA_CLIENT_ENDPOINT: z.string(),
15
+ _SERVICE_TOKEN: z.string(),
16
+ ENTERPRISE_LICENSE_KEY: z.string(),
17
+ /* AI_AZURE_LLM_API_KEY: z.string().optional(),
18
+ AI_AZURE_EMBEDDINGS_DEPLOYMENT_ID: z.string().optional(),
19
+ AI_AZURE_LLM_DEPLOYMENT_ID: z.string().optional(),
20
+ AI_AZURE_EMBEDDINGS_RESSOURCE_NAME: z.string().optional(),
21
+ AI_AZURE_LLM_RESSOURCE_NAME: z.string().optional(),
22
+ AIRTABLE_CLIENT_ID: z.string().optional(),
23
+ AZUREAD_CLIENT_ID: z.string().optional(),
24
+ AZUREAD_CLIENT_SECRET: z.string().optional(),
25
+ AZUREAD_TENANT_ID: z.string().optional(),
26
+ CRON_SECRET: z.string().min(10),
27
+ CUSTOMER_IO_API_KEY: z.string().optional(),
28
+ CUSTOMER_IO_SITE_ID: z.string().optional(),
29
+ DATABASE_URL: z.string().url(),
30
+ DEBUG: z.enum(["1", "0"]).optional(),
31
+ DEFAULT_ORGANIZATION_ID: z.string().optional(),
32
+ DEFAULT_ORGANIZATION_ROLE: z.enum(["owner", "manager", "member", "billing"]).optional(),
33
+ E2E_TESTING: z.enum(["1", "0"]).optional(),
34
+ EMAIL_AUTH_DISABLED: z.enum(["1", "0"]).optional(),
35
+ EMAIL_VERIFICATION_DISABLED: z.enum(["1", "0"]).optional(),
36
+ ENCRYPTION_KEY: z.string().length(64).or(z.string().length(32)),
37
+ ENTERPRISE_LICENSE_KEY: z.string().optional(),
38
+ FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)).optional(),
39
+ GITHUB_ID: z.string().optional(),
40
+ GITHUB_SECRET: z.string().optional(),
41
+ GOOGLE_CLIENT_ID: z.string().optional(),
42
+ GOOGLE_CLIENT_SECRET: z.string().optional(),
43
+ GOOGLE_SHEETS_CLIENT_ID: z.string().optional(),
44
+ GOOGLE_SHEETS_CLIENT_SECRET: z.string().optional(),
45
+ GOOGLE_SHEETS_REDIRECT_URL: z.string().optional(),
46
+ HTTP_PROXY: z.string().url().optional(),
47
+ HTTPS_PROXY: z.string().url().optional(),
48
+ IMPRINT_URL: z
49
+ .string()
50
+ .url()
51
+ .optional()
52
+ .or(z.string().refine((str) => str === "")),
53
+ IMPRINT_ADDRESS: z.string().optional(),
54
+ INVITE_DISABLED: z.enum(["1", "0"]).optional(),
55
+ INTERCOM_SECRET_KEY: z.string().optional(),
56
+ IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
57
+ MAIL_FROM: z.string().email().optional(),
58
+ NEXTAUTH_SECRET: z.string().min(1),
59
+ NOTION_OAUTH_CLIENT_ID: z.string().optional(),
60
+ NOTION_OAUTH_CLIENT_SECRET: z.string().optional(),
61
+ OIDC_CLIENT_ID: z.string().optional(),
62
+ OIDC_CLIENT_SECRET: z.string().optional(),
63
+ OIDC_DISPLAY_NAME: z.string().optional(),
64
+ OIDC_ISSUER: z.string().optional(),
65
+ OIDC_SIGNING_ALGORITHM: z.string().optional(),
66
+ OPENTELEMETRY_LISTENER_URL: z.string().optional(),
67
+ REDIS_URL: z.string().optional(),
68
+ REDIS_HTTP_URL: z.string().optional(),
69
+ PASSWORD_RESET_DISABLED: z.enum(["1", "0"]).optional(),
70
+ PRIVACY_URL: z
71
+ .string()
72
+ .url()
73
+ .optional()
74
+ .or(z.string().refine((str) => str === "")),
75
+ RATE_LIMITING_DISABLED: z.enum(["1", "0"]).optional(),
76
+ S3_ACCESS_KEY: z.string().optional(),
77
+ S3_BUCKET_NAME: z.string().optional(),
78
+ S3_REGION: z.string().optional(),
79
+ S3_SECRET_KEY: z.string().optional(),
80
+ S3_ENDPOINT_URL: z.string().optional(),
81
+ S3_FORCE_PATH_STYLE: z.enum(["1", "0"]).optional(),
82
+ SHORT_URL_BASE: z.string().url().optional().or(z.string().length(0)),
83
+ SIGNUP_DISABLED: z.enum(["1", "0"]).optional(),
84
+ SLACK_CLIENT_ID: z.string().optional(),
85
+ SLACK_CLIENT_SECRET: z.string().optional(),
86
+ SMTP_HOST: z.string().min(1).optional(),
87
+ SMTP_PORT: z.string().min(1).optional(),
88
+ SMTP_SECURE_ENABLED: z.enum(["1", "0"]).optional(),
89
+ SMTP_USER: z.string().min(1).optional(),
90
+ SMTP_PASSWORD: z.string().min(1).optional(),
91
+ SMTP_AUTHENTICATED: z.enum(["1", "0"]).optional(),
92
+ SMTP_REJECT_UNAUTHORIZED_TLS: z.enum(["1", "0"]).optional(),
93
+ STRIPE_SECRET_KEY: z.string().optional(),
94
+ STRIPE_WEBHOOK_SECRET: z.string().optional(),
95
+ TELEMETRY_DISABLED: z.enum(["1", "0"]).optional(),
96
+ TERMS_URL: z
97
+ .string()
98
+ .url()
99
+ .optional()
100
+ .or(z.string().refine((str) => str === "")),
101
+ TURNSTILE_SECRET_KEY: z.string().optional(),
102
+ UPLOADS_DIR: z.string().min(1).optional(),
103
+ VERCEL_URL: z.string().optional(),
104
+ _ADMIN_DOMAIN: z.string().optional(),
105
+ ADMIN_URL: z.string().url().optional(),
106
+ UNSPLASH_ACCESS_KEY: z.string().optional(),
107
+ LANGFUSE_SECRET_KEY: z.string().optional(),
108
+ LANGFUSE_PUBLIC_KEY: z.string().optional(),
109
+ LANGFUSE_BASEURL: z.string().optional(), */
110
+ },
111
+ /*
112
+ * Due to how Next.js bundles environment variables on Edge and Client,
113
+ * we need to manually destructure them to make sure all are included in bundle.
114
+ *
115
+ * 💡 You'll get type errors if not all variables from `server` & `client` are included here.
116
+ */
117
+ runtimeEnv: {
118
+ APPCONDA_ENDPOINT: typeof window !== 'undefined' ? process.env.APPCONDA_ENDPOINT : "",
119
+ APPCONDA_CLIENT_ENDPOINT: typeof window !== 'undefined' ? process.env.APPCONDA_CLIENT_ENDPOINT : "",
120
+ _SERVICE_TOKEN: typeof window !== 'undefined' ? process.env._SERVICE_TOKEN : "",
121
+ ENTERPRISE_LICENSE_KEY: typeof window !== 'undefined' ? process.env.ENTERPRISE_LICENSE_KEY : "",
122
+ },
123
+ });
124
+ console.log(env);
125
+ }
126
+ return env;
127
+ };
128
+ })();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appconda/nextjs",
3
3
  "homepage": "https://appconda.io/support",
4
4
  "description": "Appconda is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "1.0.79",
5
+ "version": "1.0.81",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -32,8 +32,10 @@ export const authenticatedActionClient = actionClient.use(async ({ next }) => {
32
32
  throw new AuthenticationError("Not authenticated");
33
33
  }
34
34
 
35
+ //@ts-ignore
35
36
  const userId = session.user.id;
36
37
 
38
+ //@ts-ignore
37
39
  const user = await getUser(userId);
38
40
  if (!user) {
39
41
  throw new AuthorizationError("User not found");
@@ -3,14 +3,12 @@ import CredentialsProvider from "next-auth/providers/credentials";
3
3
  import { cookies } from "next/headers";
4
4
  import { getAppcondaClient } from "../getAppcondaClient";
5
5
  import { Account } from "../modules/account/service";
6
- import { env } from "../lib/env";
6
+ import { getEnv } from "../lib/env";
7
7
  import { getSDKForCurrentUser } from "../getSDKForCurrentUser";
8
8
  import { Query } from "../query";
9
9
 
10
10
 
11
11
  export async function signIn({ userName, password }: { userName: string, password: string }) {
12
-
13
-
14
12
  const adminClient = await getAppcondaClient();
15
13
 
16
14
  const account = new Account(adminClient);
@@ -186,7 +184,7 @@ export const authOptions: NextAuthOptions = {
186
184
  },
187
185
  }),
188
186
  // Conditionally add enterprise SSO providers
189
- ...(env.ENTERPRISE_LICENSE_KEY ? [] : []),
187
+ ...(getEnv().ENTERPRISE_LICENSE_KEY ? [] : []),
190
188
  ],
191
189
  callbacks: {
192
190
  async jwt({ token }) {
@@ -204,17 +202,19 @@ export const authOptions: NextAuthOptions = {
204
202
 
205
203
  return {
206
204
  ...token,
205
+ //@ts-ignore
207
206
  profile: { id: user.$id, ...user },
208
207
  };
209
208
  },
210
209
  async session({ session, token }) {
211
- // @ts-expect-error
210
+ //@ts-ignore
212
211
  session.user.id = token?.id;
213
- // @ts-expect-error
212
+ //@ts-ignore
214
213
  session.user = token.profile;
215
214
 
216
215
  return session;
217
216
  },
217
+ //@ts-ignore
218
218
  async signIn({ user, account }: { user: any; account: Account | null }) {
219
219
  /* if (account?.provider === "credentials" || account?.provider === "token") {
220
220
  // check if user's email is verified or not
@@ -1,5 +1,5 @@
1
1
  import { Client } from "./client";
2
- import { env } from "./lib/env";
2
+ import { getEnv } from "./lib/env";
3
3
 
4
4
  function getPortAndHostname(urlString: string): { hostname: string; port: string; protocol: string } {
5
5
  try {
@@ -18,8 +18,8 @@ function getPortAndHostname(urlString: string): { hostname: string; port: string
18
18
  export async function getAppcondaClient() {
19
19
 
20
20
  let url;
21
- if (env.APPCONDA_ENDPOINT) {
22
- url = env.APPCONDA_ENDPOINT;
21
+ if (getEnv().APPCONDA_ENDPOINT) {
22
+ url = getEnv().APPCONDA_ENDPOINT;
23
23
  } else if (typeof window !== 'undefined') {
24
24
  const hostInfo = getPortAndHostname(window.location.href);
25
25
  if (hostInfo.port) {
@@ -28,7 +28,7 @@ export async function getAppcondaClient() {
28
28
  url = `${hostInfo.protocol}//${hostInfo.hostname}/v1`
29
29
  }
30
30
  } else {
31
- url = env.APPCONDA_ENDPOINT || 'http://appconda/v1'
31
+ url = getEnv().APPCONDA_ENDPOINT || 'http://appconda/v1'
32
32
  }
33
33
 
34
34
  /* if (ApplicationConfig.Port == null) {
@@ -1,12 +1,12 @@
1
1
  import { getAppcondaClient } from "./getAppcondaClient";
2
- import { env } from "./lib/env";
2
+ import { getEnv } from "./lib/env";
3
3
  import { WaitlistService } from "./modules";
4
4
  import { Configuration } from "./services/configuration";
5
5
 
6
6
  export async function getSDKForService() {
7
7
  const adminClient = await getAppcondaClient();
8
8
 
9
- adminClient.addHeader('x-service-token', env._SERVICE_TOKEN ?? '');
9
+ adminClient.addHeader('x-service-token', getEnv()._SERVICE_TOKEN ?? '');
10
10
  /*
11
11
  const accounts = new Account(adminClient);
12
12
  const databases = new Databases(adminClient);
package/src/lib/env.ts CHANGED
@@ -1,124 +1,137 @@
1
1
  import { createEnv } from "@t3-oss/env-nextjs";
2
2
  import { z } from "zod";
3
3
 
4
- export const env = createEnv({
5
- /*
6
- * Serverside Environment variables, not available on the client.
7
- * Will throw if you access these variables on the client.
8
- */
9
- server: {
10
- APPCONDA_ENDPOINT: z.string(),
11
- APPCONDA_CLIENT_ENDPOINT: z.string(),
12
- _SERVICE_TOKEN: z.string(),
13
- ENTERPRISE_LICENSE_KEY: z.string(),
14
- /* AI_AZURE_LLM_API_KEY: z.string().optional(),
15
- AI_AZURE_EMBEDDINGS_DEPLOYMENT_ID: z.string().optional(),
16
- AI_AZURE_LLM_DEPLOYMENT_ID: z.string().optional(),
17
- AI_AZURE_EMBEDDINGS_RESSOURCE_NAME: z.string().optional(),
18
- AI_AZURE_LLM_RESSOURCE_NAME: z.string().optional(),
19
- AIRTABLE_CLIENT_ID: z.string().optional(),
20
- AZUREAD_CLIENT_ID: z.string().optional(),
21
- AZUREAD_CLIENT_SECRET: z.string().optional(),
22
- AZUREAD_TENANT_ID: z.string().optional(),
23
- CRON_SECRET: z.string().min(10),
24
- CUSTOMER_IO_API_KEY: z.string().optional(),
25
- CUSTOMER_IO_SITE_ID: z.string().optional(),
26
- DATABASE_URL: z.string().url(),
27
- DEBUG: z.enum(["1", "0"]).optional(),
28
- DEFAULT_ORGANIZATION_ID: z.string().optional(),
29
- DEFAULT_ORGANIZATION_ROLE: z.enum(["owner", "manager", "member", "billing"]).optional(),
30
- E2E_TESTING: z.enum(["1", "0"]).optional(),
31
- EMAIL_AUTH_DISABLED: z.enum(["1", "0"]).optional(),
32
- EMAIL_VERIFICATION_DISABLED: z.enum(["1", "0"]).optional(),
33
- ENCRYPTION_KEY: z.string().length(64).or(z.string().length(32)),
34
- ENTERPRISE_LICENSE_KEY: z.string().optional(),
35
- FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)).optional(),
36
- GITHUB_ID: z.string().optional(),
37
- GITHUB_SECRET: z.string().optional(),
38
- GOOGLE_CLIENT_ID: z.string().optional(),
39
- GOOGLE_CLIENT_SECRET: z.string().optional(),
40
- GOOGLE_SHEETS_CLIENT_ID: z.string().optional(),
41
- GOOGLE_SHEETS_CLIENT_SECRET: z.string().optional(),
42
- GOOGLE_SHEETS_REDIRECT_URL: z.string().optional(),
43
- HTTP_PROXY: z.string().url().optional(),
44
- HTTPS_PROXY: z.string().url().optional(),
45
- IMPRINT_URL: z
46
- .string()
47
- .url()
48
- .optional()
49
- .or(z.string().refine((str) => str === "")),
50
- IMPRINT_ADDRESS: z.string().optional(),
51
- INVITE_DISABLED: z.enum(["1", "0"]).optional(),
52
- INTERCOM_SECRET_KEY: z.string().optional(),
53
- IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
54
- MAIL_FROM: z.string().email().optional(),
55
- NEXTAUTH_SECRET: z.string().min(1),
56
- NOTION_OAUTH_CLIENT_ID: z.string().optional(),
57
- NOTION_OAUTH_CLIENT_SECRET: z.string().optional(),
58
- OIDC_CLIENT_ID: z.string().optional(),
59
- OIDC_CLIENT_SECRET: z.string().optional(),
60
- OIDC_DISPLAY_NAME: z.string().optional(),
61
- OIDC_ISSUER: z.string().optional(),
62
- OIDC_SIGNING_ALGORITHM: z.string().optional(),
63
- OPENTELEMETRY_LISTENER_URL: z.string().optional(),
64
- REDIS_URL: z.string().optional(),
65
- REDIS_HTTP_URL: z.string().optional(),
66
- PASSWORD_RESET_DISABLED: z.enum(["1", "0"]).optional(),
67
- PRIVACY_URL: z
68
- .string()
69
- .url()
70
- .optional()
71
- .or(z.string().refine((str) => str === "")),
72
- RATE_LIMITING_DISABLED: z.enum(["1", "0"]).optional(),
73
- S3_ACCESS_KEY: z.string().optional(),
74
- S3_BUCKET_NAME: z.string().optional(),
75
- S3_REGION: z.string().optional(),
76
- S3_SECRET_KEY: z.string().optional(),
77
- S3_ENDPOINT_URL: z.string().optional(),
78
- S3_FORCE_PATH_STYLE: z.enum(["1", "0"]).optional(),
79
- SHORT_URL_BASE: z.string().url().optional().or(z.string().length(0)),
80
- SIGNUP_DISABLED: z.enum(["1", "0"]).optional(),
81
- SLACK_CLIENT_ID: z.string().optional(),
82
- SLACK_CLIENT_SECRET: z.string().optional(),
83
- SMTP_HOST: z.string().min(1).optional(),
84
- SMTP_PORT: z.string().min(1).optional(),
85
- SMTP_SECURE_ENABLED: z.enum(["1", "0"]).optional(),
86
- SMTP_USER: z.string().min(1).optional(),
87
- SMTP_PASSWORD: z.string().min(1).optional(),
88
- SMTP_AUTHENTICATED: z.enum(["1", "0"]).optional(),
89
- SMTP_REJECT_UNAUTHORIZED_TLS: z.enum(["1", "0"]).optional(),
90
- STRIPE_SECRET_KEY: z.string().optional(),
91
- STRIPE_WEBHOOK_SECRET: z.string().optional(),
92
- TELEMETRY_DISABLED: z.enum(["1", "0"]).optional(),
93
- TERMS_URL: z
94
- .string()
95
- .url()
96
- .optional()
97
- .or(z.string().refine((str) => str === "")),
98
- TURNSTILE_SECRET_KEY: z.string().optional(),
99
- UPLOADS_DIR: z.string().min(1).optional(),
100
- VERCEL_URL: z.string().optional(),
101
- _ADMIN_DOMAIN: z.string().optional(),
102
- ADMIN_URL: z.string().url().optional(),
103
- UNSPLASH_ACCESS_KEY: z.string().optional(),
104
- LANGFUSE_SECRET_KEY: z.string().optional(),
105
- LANGFUSE_PUBLIC_KEY: z.string().optional(),
106
- LANGFUSE_BASEURL: z.string().optional(), */
107
- },
108
4
 
109
- /*
110
- * Due to how Next.js bundles environment variables on Edge and Client,
111
- * we need to manually destructure them to make sure all are included in bundle.
112
- *
113
- * 💡 You'll get type errors if not all variables from `server` & `client` are included here.
114
- */
115
- runtimeEnv: {
116
- APPCONDA_ENDPOINT: process.env.APPCONDA_ENDPOINT,
117
- APPCONDA_CLIENT_ENDPOINT: process.env.APPCONDA_CLIENT_ENDPOINT,
118
- _SERVICE_TOKEN: process.env._SERVICE_TOKEN,
119
- ENTERPRISE_LICENSE_KEY: process.env.ENTERPRISE_LICENSE_KEY,
120
- },
121
- });
5
+ export const getEnv = (() => {
6
+ let env = null;
7
+ return () => {
8
+ if (env == null) {
9
+ env = createEnv({
10
+ /*
11
+ * Serverside Environment variables, not available on the client.
12
+ * Will throw if you access these variables on the client.
13
+ */
14
+ server: {
15
+ APPCONDA_ENDPOINT: z.string(),
16
+ APPCONDA_CLIENT_ENDPOINT: z.string(),
17
+ _SERVICE_TOKEN: z.string(),
18
+ ENTERPRISE_LICENSE_KEY: z.string(),
19
+ /* AI_AZURE_LLM_API_KEY: z.string().optional(),
20
+ AI_AZURE_EMBEDDINGS_DEPLOYMENT_ID: z.string().optional(),
21
+ AI_AZURE_LLM_DEPLOYMENT_ID: z.string().optional(),
22
+ AI_AZURE_EMBEDDINGS_RESSOURCE_NAME: z.string().optional(),
23
+ AI_AZURE_LLM_RESSOURCE_NAME: z.string().optional(),
24
+ AIRTABLE_CLIENT_ID: z.string().optional(),
25
+ AZUREAD_CLIENT_ID: z.string().optional(),
26
+ AZUREAD_CLIENT_SECRET: z.string().optional(),
27
+ AZUREAD_TENANT_ID: z.string().optional(),
28
+ CRON_SECRET: z.string().min(10),
29
+ CUSTOMER_IO_API_KEY: z.string().optional(),
30
+ CUSTOMER_IO_SITE_ID: z.string().optional(),
31
+ DATABASE_URL: z.string().url(),
32
+ DEBUG: z.enum(["1", "0"]).optional(),
33
+ DEFAULT_ORGANIZATION_ID: z.string().optional(),
34
+ DEFAULT_ORGANIZATION_ROLE: z.enum(["owner", "manager", "member", "billing"]).optional(),
35
+ E2E_TESTING: z.enum(["1", "0"]).optional(),
36
+ EMAIL_AUTH_DISABLED: z.enum(["1", "0"]).optional(),
37
+ EMAIL_VERIFICATION_DISABLED: z.enum(["1", "0"]).optional(),
38
+ ENCRYPTION_KEY: z.string().length(64).or(z.string().length(32)),
39
+ ENTERPRISE_LICENSE_KEY: z.string().optional(),
40
+ FORMBRICKS_ENCRYPTION_KEY: z.string().length(24).or(z.string().length(0)).optional(),
41
+ GITHUB_ID: z.string().optional(),
42
+ GITHUB_SECRET: z.string().optional(),
43
+ GOOGLE_CLIENT_ID: z.string().optional(),
44
+ GOOGLE_CLIENT_SECRET: z.string().optional(),
45
+ GOOGLE_SHEETS_CLIENT_ID: z.string().optional(),
46
+ GOOGLE_SHEETS_CLIENT_SECRET: z.string().optional(),
47
+ GOOGLE_SHEETS_REDIRECT_URL: z.string().optional(),
48
+ HTTP_PROXY: z.string().url().optional(),
49
+ HTTPS_PROXY: z.string().url().optional(),
50
+ IMPRINT_URL: z
51
+ .string()
52
+ .url()
53
+ .optional()
54
+ .or(z.string().refine((str) => str === "")),
55
+ IMPRINT_ADDRESS: z.string().optional(),
56
+ INVITE_DISABLED: z.enum(["1", "0"]).optional(),
57
+ INTERCOM_SECRET_KEY: z.string().optional(),
58
+ IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
59
+ MAIL_FROM: z.string().email().optional(),
60
+ NEXTAUTH_SECRET: z.string().min(1),
61
+ NOTION_OAUTH_CLIENT_ID: z.string().optional(),
62
+ NOTION_OAUTH_CLIENT_SECRET: z.string().optional(),
63
+ OIDC_CLIENT_ID: z.string().optional(),
64
+ OIDC_CLIENT_SECRET: z.string().optional(),
65
+ OIDC_DISPLAY_NAME: z.string().optional(),
66
+ OIDC_ISSUER: z.string().optional(),
67
+ OIDC_SIGNING_ALGORITHM: z.string().optional(),
68
+ OPENTELEMETRY_LISTENER_URL: z.string().optional(),
69
+ REDIS_URL: z.string().optional(),
70
+ REDIS_HTTP_URL: z.string().optional(),
71
+ PASSWORD_RESET_DISABLED: z.enum(["1", "0"]).optional(),
72
+ PRIVACY_URL: z
73
+ .string()
74
+ .url()
75
+ .optional()
76
+ .or(z.string().refine((str) => str === "")),
77
+ RATE_LIMITING_DISABLED: z.enum(["1", "0"]).optional(),
78
+ S3_ACCESS_KEY: z.string().optional(),
79
+ S3_BUCKET_NAME: z.string().optional(),
80
+ S3_REGION: z.string().optional(),
81
+ S3_SECRET_KEY: z.string().optional(),
82
+ S3_ENDPOINT_URL: z.string().optional(),
83
+ S3_FORCE_PATH_STYLE: z.enum(["1", "0"]).optional(),
84
+ SHORT_URL_BASE: z.string().url().optional().or(z.string().length(0)),
85
+ SIGNUP_DISABLED: z.enum(["1", "0"]).optional(),
86
+ SLACK_CLIENT_ID: z.string().optional(),
87
+ SLACK_CLIENT_SECRET: z.string().optional(),
88
+ SMTP_HOST: z.string().min(1).optional(),
89
+ SMTP_PORT: z.string().min(1).optional(),
90
+ SMTP_SECURE_ENABLED: z.enum(["1", "0"]).optional(),
91
+ SMTP_USER: z.string().min(1).optional(),
92
+ SMTP_PASSWORD: z.string().min(1).optional(),
93
+ SMTP_AUTHENTICATED: z.enum(["1", "0"]).optional(),
94
+ SMTP_REJECT_UNAUTHORIZED_TLS: z.enum(["1", "0"]).optional(),
95
+ STRIPE_SECRET_KEY: z.string().optional(),
96
+ STRIPE_WEBHOOK_SECRET: z.string().optional(),
97
+ TELEMETRY_DISABLED: z.enum(["1", "0"]).optional(),
98
+ TERMS_URL: z
99
+ .string()
100
+ .url()
101
+ .optional()
102
+ .or(z.string().refine((str) => str === "")),
103
+ TURNSTILE_SECRET_KEY: z.string().optional(),
104
+ UPLOADS_DIR: z.string().min(1).optional(),
105
+ VERCEL_URL: z.string().optional(),
106
+ _ADMIN_DOMAIN: z.string().optional(),
107
+ ADMIN_URL: z.string().url().optional(),
108
+ UNSPLASH_ACCESS_KEY: z.string().optional(),
109
+ LANGFUSE_SECRET_KEY: z.string().optional(),
110
+ LANGFUSE_PUBLIC_KEY: z.string().optional(),
111
+ LANGFUSE_BASEURL: z.string().optional(), */
112
+ },
113
+
114
+ /*
115
+ * Due to how Next.js bundles environment variables on Edge and Client,
116
+ * we need to manually destructure them to make sure all are included in bundle.
117
+ *
118
+ * 💡 You'll get type errors if not all variables from `server` & `client` are included here.
119
+ */
120
+ runtimeEnv: {
121
+ APPCONDA_ENDPOINT: typeof window !== 'undefined' ? process.env.APPCONDA_ENDPOINT : "",
122
+ APPCONDA_CLIENT_ENDPOINT: typeof window !== 'undefined' ? process.env.APPCONDA_CLIENT_ENDPOINT : "",
123
+ _SERVICE_TOKEN: typeof window !== 'undefined' ? process.env._SERVICE_TOKEN : "",
124
+ ENTERPRISE_LICENSE_KEY: typeof window !== 'undefined' ? process.env.ENTERPRISE_LICENSE_KEY : "",
125
+ },
126
+ });
127
+ console.log(env);
128
+ }
129
+
130
+ return env;
131
+
132
+ };
133
+ })();
134
+
135
+
122
136
 
123
137
 
124
- console.log(env);