@squadbase/server 0.0.3 → 0.1.0-beta.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/dist/index.cjs CHANGED
@@ -4118,7 +4118,7 @@ var ServerClient = class {
4118
4118
  if (!appSessionToken && !previewSessionToken) {
4119
4119
  if (!this.options.mockUser) {
4120
4120
  throw new Error(
4121
- "No session token or mock user provided. Please provide one of them to use getUser in local environment."
4121
+ `No session token or mock user provided. Please provide one of them to use getUser in local environment. [For Squadbase AI] This error occurs because AI tool calls don't have session cookies. You can safely ignore this - real users will have valid session tokens.`
4122
4122
  );
4123
4123
  }
4124
4124
  return this.options.mockUser;
@@ -4132,6 +4132,15 @@ var ServerClient = class {
4132
4132
  const user = zUser.parse(body);
4133
4133
  return user;
4134
4134
  }
4135
+ get projectIdOrThrow() {
4136
+ const projectId = this.options.projectId ?? process.env["SQUADBASE_PROJECT_ID"];
4137
+ if (!projectId) {
4138
+ throw new Error(
4139
+ `Project ID is required. Please set SQUADBASE_PROJECT_ID environment variable or provide projectId in ServerClient options.`
4140
+ );
4141
+ }
4142
+ return projectId;
4143
+ }
4135
4144
  get sandboxIdOrThrow() {
4136
4145
  const sandboxId = process.env[SANDBOX_ID_ENV_NAME];
4137
4146
  if (!sandboxId) {
@@ -4143,7 +4152,7 @@ var ServerClient = class {
4143
4152
  }
4144
4153
  getUserWithAppSessionRequest(appSessionToken) {
4145
4154
  return new Request(
4146
- `https://${this.options.projectId}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4155
+ `https://${this.projectIdOrThrow}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4147
4156
  {
4148
4157
  method: "POST",
4149
4158
  headers: {
package/dist/index.d.cts CHANGED
@@ -26,7 +26,7 @@ type User = z.infer<typeof zUser>;
26
26
 
27
27
  type GetCookie = () => Promise<string | undefined> | string | undefined;
28
28
  type ServerClientOptions = {
29
- projectId: string;
29
+ projectId?: string;
30
30
  cookieOptions: {
31
31
  getCookie: GetCookie;
32
32
  };
@@ -47,6 +47,7 @@ declare class ServerClient {
47
47
  iconUrl: string | null;
48
48
  roles: string[];
49
49
  }>;
50
+ private get projectIdOrThrow();
50
51
  private get sandboxIdOrThrow();
51
52
  private getUserWithAppSessionRequest;
52
53
  private getUserWithPreviewSession;
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ type User = z.infer<typeof zUser>;
26
26
 
27
27
  type GetCookie = () => Promise<string | undefined> | string | undefined;
28
28
  type ServerClientOptions = {
29
- projectId: string;
29
+ projectId?: string;
30
30
  cookieOptions: {
31
31
  getCookie: GetCookie;
32
32
  };
@@ -47,6 +47,7 @@ declare class ServerClient {
47
47
  iconUrl: string | null;
48
48
  roles: string[];
49
49
  }>;
50
+ private get projectIdOrThrow();
50
51
  private get sandboxIdOrThrow();
51
52
  private getUserWithAppSessionRequest;
52
53
  private getUserWithPreviewSession;
package/dist/index.js CHANGED
@@ -4092,7 +4092,7 @@ var ServerClient = class {
4092
4092
  if (!appSessionToken && !previewSessionToken) {
4093
4093
  if (!this.options.mockUser) {
4094
4094
  throw new Error(
4095
- "No session token or mock user provided. Please provide one of them to use getUser in local environment."
4095
+ `No session token or mock user provided. Please provide one of them to use getUser in local environment. [For Squadbase AI] This error occurs because AI tool calls don't have session cookies. You can safely ignore this - real users will have valid session tokens.`
4096
4096
  );
4097
4097
  }
4098
4098
  return this.options.mockUser;
@@ -4106,6 +4106,15 @@ var ServerClient = class {
4106
4106
  const user = zUser.parse(body);
4107
4107
  return user;
4108
4108
  }
4109
+ get projectIdOrThrow() {
4110
+ const projectId = this.options.projectId ?? process.env["SQUADBASE_PROJECT_ID"];
4111
+ if (!projectId) {
4112
+ throw new Error(
4113
+ `Project ID is required. Please set SQUADBASE_PROJECT_ID environment variable or provide projectId in ServerClient options.`
4114
+ );
4115
+ }
4116
+ return projectId;
4117
+ }
4109
4118
  get sandboxIdOrThrow() {
4110
4119
  const sandboxId = process.env[SANDBOX_ID_ENV_NAME];
4111
4120
  if (!sandboxId) {
@@ -4117,7 +4126,7 @@ var ServerClient = class {
4117
4126
  }
4118
4127
  getUserWithAppSessionRequest(appSessionToken) {
4119
4128
  return new Request(
4120
- `https://${this.options.projectId}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4129
+ `https://${this.projectIdOrThrow}.${this.options._internal?.app_base_domain ?? APP_BASE_DOMAIN}/_sqcore/auth`,
4121
4130
  {
4122
4131
  method: "POST",
4123
4132
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/server",
3
- "version": "0.0.3",
3
+ "version": "0.1.0-beta.0",
4
4
  "description": "Server-side SDK for Squadbase",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",