@symbo.ls/sdk 2.32.5 → 2.32.7

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.
@@ -22,8 +22,10 @@ __export(AuthService_exports, {
22
22
  module.exports = __toCommonJS(AuthService_exports);
23
23
  var import_BaseService = require("./BaseService.js");
24
24
  var import_permission = require("../utils/permission.js");
25
+ const PLUGIN_SESSION_STORAGE_KEY = "plugin_auth_session";
25
26
  class AuthService extends import_BaseService.BaseService {
26
27
  constructor(config) {
28
+ var _a, _b;
27
29
  super(config);
28
30
  this._userRoles = /* @__PURE__ */ new Set(["guest", "editor", "admin", "owner"]);
29
31
  this._projectTiers = /* @__PURE__ */ new Set([
@@ -35,17 +37,28 @@ class AuthService extends import_BaseService.BaseService {
35
37
  ]);
36
38
  this._projectRoleCache = /* @__PURE__ */ new Map();
37
39
  this._roleCacheExpiry = 5 * 60 * 1e3;
40
+ this._pluginSession = null;
41
+ this._resolvePluginSession(
42
+ (config == null ? void 0 : config.session) || (config == null ? void 0 : config.pluginSession) || ((_a = config == null ? void 0 : config.options) == null ? void 0 : _a.pluginSession) || ((_b = config == null ? void 0 : config.context) == null ? void 0 : _b.pluginSession) || null
43
+ );
38
44
  }
39
45
  // Use BaseService.init/_request/_requireReady implementations
40
46
  // ==================== AUTH METHODS ====================
41
- async register(userData) {
47
+ async register(userData, options = {}) {
42
48
  try {
49
+ const { payload, session } = this._preparePluginPayload(
50
+ { ...userData || {} },
51
+ options.session
52
+ );
43
53
  const response = await this._request("/auth/register", {
44
54
  method: "POST",
45
- body: JSON.stringify(userData),
55
+ body: JSON.stringify(payload),
46
56
  methodName: "register"
47
57
  });
48
58
  if (response.success) {
59
+ if (session) {
60
+ this._clearPluginSession(session);
61
+ }
49
62
  return response.data;
50
63
  }
51
64
  throw new Error(response.message);
@@ -53,12 +66,19 @@ class AuthService extends import_BaseService.BaseService {
53
66
  throw new Error(`Registration failed: ${error.message}`, { cause: error });
54
67
  }
55
68
  }
56
- async login(email, password) {
69
+ async login(email, password, options = {}) {
57
70
  var _a;
58
71
  try {
72
+ const { payload, session } = this._preparePluginPayload(
73
+ {
74
+ email,
75
+ password
76
+ },
77
+ options.session
78
+ );
59
79
  const response = await this._request("/auth/login", {
60
80
  method: "POST",
61
- body: JSON.stringify({ email, password }),
81
+ body: JSON.stringify(payload),
62
82
  methodName: "login"
63
83
  });
64
84
  if (response.success && response.data && response.data.tokens) {
@@ -74,6 +94,9 @@ class AuthService extends import_BaseService.BaseService {
74
94
  }
75
95
  }
76
96
  if (response.success) {
97
+ if (session) {
98
+ this._clearPluginSession(session);
99
+ }
77
100
  return response.data;
78
101
  }
79
102
  throw new Error(response.message);
@@ -113,10 +136,10 @@ class AuthService extends import_BaseService.BaseService {
113
136
  throw new Error(`Token refresh failed: ${error.message}`, { cause: error });
114
137
  }
115
138
  }
116
- async googleAuth(idToken, inviteToken = null) {
139
+ async googleAuth(idToken, inviteToken = null, options = {}) {
117
140
  var _a;
118
141
  try {
119
- const payload = { idToken };
142
+ const { payload, session } = this._preparePluginPayload({ idToken }, options.session);
120
143
  if (inviteToken) {
121
144
  payload.inviteToken = inviteToken;
122
145
  }
@@ -138,6 +161,9 @@ class AuthService extends import_BaseService.BaseService {
138
161
  }
139
162
  }
140
163
  if (response.success) {
164
+ if (session) {
165
+ this._clearPluginSession(session);
166
+ }
141
167
  return response.data;
142
168
  }
143
169
  throw new Error(response.message);
@@ -145,10 +171,10 @@ class AuthService extends import_BaseService.BaseService {
145
171
  throw new Error(`Google auth failed: ${error.message}`, { cause: error });
146
172
  }
147
173
  }
148
- async githubAuth(code, inviteToken = null) {
174
+ async githubAuth(code, inviteToken = null, options = {}) {
149
175
  var _a;
150
176
  try {
151
- const payload = { code };
177
+ const { payload, session } = this._preparePluginPayload({ code }, options.session);
152
178
  if (inviteToken) {
153
179
  payload.inviteToken = inviteToken;
154
180
  }
@@ -170,6 +196,9 @@ class AuthService extends import_BaseService.BaseService {
170
196
  }
171
197
  }
172
198
  if (response.success) {
199
+ if (session) {
200
+ this._clearPluginSession(session);
201
+ }
173
202
  return response.data;
174
203
  }
175
204
  throw new Error(response.message);
@@ -177,10 +206,13 @@ class AuthService extends import_BaseService.BaseService {
177
206
  throw new Error(`GitHub auth failed: ${error.message}`, { cause: error });
178
207
  }
179
208
  }
180
- async googleAuthCallback(code, redirectUri, inviteToken = null) {
209
+ async googleAuthCallback(code, redirectUri, inviteToken = null, options = {}) {
181
210
  var _a;
182
211
  try {
183
- const body = { code, redirectUri };
212
+ const { payload: body, session } = this._preparePluginPayload(
213
+ { code, redirectUri },
214
+ options.session
215
+ );
184
216
  if (inviteToken) {
185
217
  body.inviteToken = inviteToken;
186
218
  }
@@ -202,6 +234,9 @@ class AuthService extends import_BaseService.BaseService {
202
234
  }
203
235
  }
204
236
  if (response.success) {
237
+ if (session) {
238
+ this._clearPluginSession(session);
239
+ }
205
240
  return response.data;
206
241
  }
207
242
  throw new Error(response.message);
@@ -685,17 +720,17 @@ class AuthService extends import_BaseService.BaseService {
685
720
  /**
686
721
  * Helper method to register with validation
687
722
  */
688
- async registerWithValidation(userData) {
723
+ async registerWithValidation(userData, options = {}) {
689
724
  const validation = this.validateRegistrationData(userData);
690
725
  if (!validation.isValid) {
691
726
  throw new Error(`Validation failed: ${validation.errors.join(", ")}`);
692
727
  }
693
- return await this.register(userData);
728
+ return await this.register(userData, options);
694
729
  }
695
730
  /**
696
731
  * Helper method to login with validation
697
732
  */
698
- async loginWithValidation(email, password) {
733
+ async loginWithValidation(email, password, options = {}) {
699
734
  if (!email || typeof email !== "string") {
700
735
  throw new Error("Email is required and must be a string");
701
736
  }
@@ -705,7 +740,7 @@ class AuthService extends import_BaseService.BaseService {
705
740
  if (!this._isValidEmail(email)) {
706
741
  throw new Error("Email must be a valid email address");
707
742
  }
708
- return await this.login(email, password);
743
+ return await this.login(email, password, options);
709
744
  }
710
745
  /**
711
746
  * Private helper to validate email format
@@ -813,4 +848,81 @@ class AuthService extends import_BaseService.BaseService {
813
848
  this._projectRoleCache.clear();
814
849
  this._setReady(false);
815
850
  }
851
+ _preparePluginPayload(payload, sessionOverride = null) {
852
+ const target = payload && typeof payload === "object" ? { ...payload } : {};
853
+ const session = this._resolvePluginSession(sessionOverride);
854
+ if (session && !Object.hasOwn(target, "session")) {
855
+ target.session = session;
856
+ return { payload: target, session };
857
+ }
858
+ return { payload: target, session: null };
859
+ }
860
+ _resolvePluginSession(sessionOverride = null) {
861
+ var _a, _b;
862
+ if (sessionOverride) {
863
+ return this._cachePluginSession(sessionOverride);
864
+ }
865
+ if (this._pluginSession) {
866
+ return this._pluginSession;
867
+ }
868
+ const optionSession = (_a = this._options) == null ? void 0 : _a.pluginSession;
869
+ if (optionSession) {
870
+ return this._cachePluginSession(optionSession);
871
+ }
872
+ const contextSession = (_b = this._context) == null ? void 0 : _b.pluginSession;
873
+ if (contextSession) {
874
+ return this._cachePluginSession(contextSession);
875
+ }
876
+ if (typeof window !== "undefined") {
877
+ try {
878
+ const sessionFromUrl = new URL(window.location.href).searchParams.get("session");
879
+ if (sessionFromUrl) {
880
+ return this._cachePluginSession(sessionFromUrl);
881
+ }
882
+ } catch {
883
+ }
884
+ try {
885
+ if (window.localStorage) {
886
+ const stored = window.localStorage.getItem(PLUGIN_SESSION_STORAGE_KEY);
887
+ if (stored) {
888
+ this._pluginSession = stored;
889
+ return stored;
890
+ }
891
+ }
892
+ } catch {
893
+ }
894
+ }
895
+ return null;
896
+ }
897
+ _cachePluginSession(session) {
898
+ if (!session) {
899
+ return null;
900
+ }
901
+ this._pluginSession = session;
902
+ if (typeof window !== "undefined") {
903
+ try {
904
+ if (window.localStorage) {
905
+ window.localStorage.setItem(PLUGIN_SESSION_STORAGE_KEY, session);
906
+ }
907
+ } catch {
908
+ }
909
+ }
910
+ return session;
911
+ }
912
+ setPluginSession(session) {
913
+ this._cachePluginSession(session);
914
+ }
915
+ _clearPluginSession(session = null) {
916
+ if (!session || this._pluginSession === session) {
917
+ this._pluginSession = null;
918
+ }
919
+ if (typeof window !== "undefined") {
920
+ try {
921
+ if (window.localStorage) {
922
+ window.localStorage.removeItem(PLUGIN_SESSION_STORAGE_KEY);
923
+ }
924
+ } catch {
925
+ }
926
+ }
927
+ }
816
928
  }
@@ -24,14 +24,17 @@ var import_BaseService = require("./BaseService.js");
24
24
  class FileService extends import_BaseService.BaseService {
25
25
  // ==================== FILE METHODS ====================
26
26
  async uploadFile(file, options = {}) {
27
+ var _a;
27
28
  this._requireReady("uploadFile");
28
29
  if (!file) {
29
30
  throw new Error("File is required for upload");
30
31
  }
31
32
  const formData = new FormData();
32
33
  formData.append("file", file);
33
- if (options.projectId) {
34
- formData.append("projectId", options.projectId);
34
+ const hasProjectIdOption = Object.hasOwn(options, "projectId");
35
+ const projectId = hasProjectIdOption ? options.projectId : (_a = this._context.project) == null ? void 0 : _a.id;
36
+ if (projectId != null && projectId !== "") {
37
+ formData.append("projectId", projectId);
35
38
  }
36
39
  if (options.tags) {
37
40
  formData.append("tags", JSON.stringify(options.tags));
@@ -53,12 +56,7 @@ class FileService extends import_BaseService.BaseService {
53
56
  if (!response.success) {
54
57
  throw new Error(response.message);
55
58
  }
56
- return {
57
- id: response.data.id,
58
- src: `${this._apiUrl}/core/files/public/${response.data.id}/download`,
59
- success: true,
60
- message: response.message
61
- };
59
+ return response.data;
62
60
  } catch (error) {
63
61
  throw new Error(`File upload failed: ${error.message}`, { cause: error });
64
62
  }
@@ -39,11 +39,12 @@ function preprocessChanges(root, tuples = [], options = {}) {
39
39
  const expandTuple = (t) => {
40
40
  const [action, path, value] = t || [];
41
41
  const isSchemaPath = Array.isArray(path) && path[0] === "schema";
42
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
42
43
  if (action === "delete") {
43
44
  return [t];
44
45
  }
45
46
  const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject(value);
46
- if (!canConsiderExpansion) {
47
+ if (!canConsiderExpansion || isFilesPath || value && value.type === "files") {
47
48
  return [t];
48
49
  }
49
50
  const prev = getByPathSafe(root, path) || {};
@@ -109,7 +110,8 @@ function preprocessChanges(root, tuples = [], options = {}) {
109
110
  continue;
110
111
  }
111
112
  const [action, path, value] = t;
112
- if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject(value)) {
113
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
114
+ if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject(value) || isFilesPath || value && value.type === "files") {
113
115
  continue;
114
116
  }
115
117
  const keys = Object.keys(value).filter((k) => k !== "__order");
package/dist/esm/index.js CHANGED
@@ -14924,8 +14924,10 @@ var PROJECT_ROLE_PERMISSIONS = {
14924
14924
  };
14925
14925
 
14926
14926
  // src/services/AuthService.js
14927
+ var PLUGIN_SESSION_STORAGE_KEY = "plugin_auth_session";
14927
14928
  var AuthService = class extends BaseService {
14928
14929
  constructor(config) {
14930
+ var _a, _b;
14929
14931
  super(config);
14930
14932
  this._userRoles = /* @__PURE__ */ new Set(["guest", "editor", "admin", "owner"]);
14931
14933
  this._projectTiers = /* @__PURE__ */ new Set([
@@ -14937,17 +14939,28 @@ var AuthService = class extends BaseService {
14937
14939
  ]);
14938
14940
  this._projectRoleCache = /* @__PURE__ */ new Map();
14939
14941
  this._roleCacheExpiry = 5 * 60 * 1e3;
14942
+ this._pluginSession = null;
14943
+ this._resolvePluginSession(
14944
+ (config == null ? void 0 : config.session) || (config == null ? void 0 : config.pluginSession) || ((_a = config == null ? void 0 : config.options) == null ? void 0 : _a.pluginSession) || ((_b = config == null ? void 0 : config.context) == null ? void 0 : _b.pluginSession) || null
14945
+ );
14940
14946
  }
14941
14947
  // Use BaseService.init/_request/_requireReady implementations
14942
14948
  // ==================== AUTH METHODS ====================
14943
- async register(userData) {
14949
+ async register(userData, options = {}) {
14944
14950
  try {
14951
+ const { payload, session } = this._preparePluginPayload(
14952
+ { ...userData || {} },
14953
+ options.session
14954
+ );
14945
14955
  const response = await this._request("/auth/register", {
14946
14956
  method: "POST",
14947
- body: JSON.stringify(userData),
14957
+ body: JSON.stringify(payload),
14948
14958
  methodName: "register"
14949
14959
  });
14950
14960
  if (response.success) {
14961
+ if (session) {
14962
+ this._clearPluginSession(session);
14963
+ }
14951
14964
  return response.data;
14952
14965
  }
14953
14966
  throw new Error(response.message);
@@ -14955,12 +14968,19 @@ var AuthService = class extends BaseService {
14955
14968
  throw new Error(`Registration failed: ${error.message}`, { cause: error });
14956
14969
  }
14957
14970
  }
14958
- async login(email, password) {
14971
+ async login(email, password, options = {}) {
14959
14972
  var _a;
14960
14973
  try {
14974
+ const { payload, session } = this._preparePluginPayload(
14975
+ {
14976
+ email,
14977
+ password
14978
+ },
14979
+ options.session
14980
+ );
14961
14981
  const response = await this._request("/auth/login", {
14962
14982
  method: "POST",
14963
- body: JSON.stringify({ email, password }),
14983
+ body: JSON.stringify(payload),
14964
14984
  methodName: "login"
14965
14985
  });
14966
14986
  if (response.success && response.data && response.data.tokens) {
@@ -14976,6 +14996,9 @@ var AuthService = class extends BaseService {
14976
14996
  }
14977
14997
  }
14978
14998
  if (response.success) {
14999
+ if (session) {
15000
+ this._clearPluginSession(session);
15001
+ }
14979
15002
  return response.data;
14980
15003
  }
14981
15004
  throw new Error(response.message);
@@ -15015,10 +15038,10 @@ var AuthService = class extends BaseService {
15015
15038
  throw new Error(`Token refresh failed: ${error.message}`, { cause: error });
15016
15039
  }
15017
15040
  }
15018
- async googleAuth(idToken, inviteToken = null) {
15041
+ async googleAuth(idToken, inviteToken = null, options = {}) {
15019
15042
  var _a;
15020
15043
  try {
15021
- const payload = { idToken };
15044
+ const { payload, session } = this._preparePluginPayload({ idToken }, options.session);
15022
15045
  if (inviteToken) {
15023
15046
  payload.inviteToken = inviteToken;
15024
15047
  }
@@ -15040,6 +15063,9 @@ var AuthService = class extends BaseService {
15040
15063
  }
15041
15064
  }
15042
15065
  if (response.success) {
15066
+ if (session) {
15067
+ this._clearPluginSession(session);
15068
+ }
15043
15069
  return response.data;
15044
15070
  }
15045
15071
  throw new Error(response.message);
@@ -15047,10 +15073,10 @@ var AuthService = class extends BaseService {
15047
15073
  throw new Error(`Google auth failed: ${error.message}`, { cause: error });
15048
15074
  }
15049
15075
  }
15050
- async githubAuth(code, inviteToken = null) {
15076
+ async githubAuth(code, inviteToken = null, options = {}) {
15051
15077
  var _a;
15052
15078
  try {
15053
- const payload = { code };
15079
+ const { payload, session } = this._preparePluginPayload({ code }, options.session);
15054
15080
  if (inviteToken) {
15055
15081
  payload.inviteToken = inviteToken;
15056
15082
  }
@@ -15072,6 +15098,9 @@ var AuthService = class extends BaseService {
15072
15098
  }
15073
15099
  }
15074
15100
  if (response.success) {
15101
+ if (session) {
15102
+ this._clearPluginSession(session);
15103
+ }
15075
15104
  return response.data;
15076
15105
  }
15077
15106
  throw new Error(response.message);
@@ -15079,10 +15108,13 @@ var AuthService = class extends BaseService {
15079
15108
  throw new Error(`GitHub auth failed: ${error.message}`, { cause: error });
15080
15109
  }
15081
15110
  }
15082
- async googleAuthCallback(code, redirectUri, inviteToken = null) {
15111
+ async googleAuthCallback(code, redirectUri, inviteToken = null, options = {}) {
15083
15112
  var _a;
15084
15113
  try {
15085
- const body = { code, redirectUri };
15114
+ const { payload: body, session } = this._preparePluginPayload(
15115
+ { code, redirectUri },
15116
+ options.session
15117
+ );
15086
15118
  if (inviteToken) {
15087
15119
  body.inviteToken = inviteToken;
15088
15120
  }
@@ -15104,6 +15136,9 @@ var AuthService = class extends BaseService {
15104
15136
  }
15105
15137
  }
15106
15138
  if (response.success) {
15139
+ if (session) {
15140
+ this._clearPluginSession(session);
15141
+ }
15107
15142
  return response.data;
15108
15143
  }
15109
15144
  throw new Error(response.message);
@@ -15587,17 +15622,17 @@ var AuthService = class extends BaseService {
15587
15622
  /**
15588
15623
  * Helper method to register with validation
15589
15624
  */
15590
- async registerWithValidation(userData) {
15625
+ async registerWithValidation(userData, options = {}) {
15591
15626
  const validation = this.validateRegistrationData(userData);
15592
15627
  if (!validation.isValid) {
15593
15628
  throw new Error(`Validation failed: ${validation.errors.join(", ")}`);
15594
15629
  }
15595
- return await this.register(userData);
15630
+ return await this.register(userData, options);
15596
15631
  }
15597
15632
  /**
15598
15633
  * Helper method to login with validation
15599
15634
  */
15600
- async loginWithValidation(email, password) {
15635
+ async loginWithValidation(email, password, options = {}) {
15601
15636
  if (!email || typeof email !== "string") {
15602
15637
  throw new Error("Email is required and must be a string");
15603
15638
  }
@@ -15607,7 +15642,7 @@ var AuthService = class extends BaseService {
15607
15642
  if (!this._isValidEmail(email)) {
15608
15643
  throw new Error("Email must be a valid email address");
15609
15644
  }
15610
- return await this.login(email, password);
15645
+ return await this.login(email, password, options);
15611
15646
  }
15612
15647
  /**
15613
15648
  * Private helper to validate email format
@@ -15715,6 +15750,83 @@ var AuthService = class extends BaseService {
15715
15750
  this._projectRoleCache.clear();
15716
15751
  this._setReady(false);
15717
15752
  }
15753
+ _preparePluginPayload(payload, sessionOverride = null) {
15754
+ const target = payload && typeof payload === "object" ? { ...payload } : {};
15755
+ const session = this._resolvePluginSession(sessionOverride);
15756
+ if (session && !Object.hasOwn(target, "session")) {
15757
+ target.session = session;
15758
+ return { payload: target, session };
15759
+ }
15760
+ return { payload: target, session: null };
15761
+ }
15762
+ _resolvePluginSession(sessionOverride = null) {
15763
+ var _a, _b;
15764
+ if (sessionOverride) {
15765
+ return this._cachePluginSession(sessionOverride);
15766
+ }
15767
+ if (this._pluginSession) {
15768
+ return this._pluginSession;
15769
+ }
15770
+ const optionSession = (_a = this._options) == null ? void 0 : _a.pluginSession;
15771
+ if (optionSession) {
15772
+ return this._cachePluginSession(optionSession);
15773
+ }
15774
+ const contextSession = (_b = this._context) == null ? void 0 : _b.pluginSession;
15775
+ if (contextSession) {
15776
+ return this._cachePluginSession(contextSession);
15777
+ }
15778
+ if (typeof window !== "undefined") {
15779
+ try {
15780
+ const sessionFromUrl = new URL(window.location.href).searchParams.get("session");
15781
+ if (sessionFromUrl) {
15782
+ return this._cachePluginSession(sessionFromUrl);
15783
+ }
15784
+ } catch {
15785
+ }
15786
+ try {
15787
+ if (window.localStorage) {
15788
+ const stored = window.localStorage.getItem(PLUGIN_SESSION_STORAGE_KEY);
15789
+ if (stored) {
15790
+ this._pluginSession = stored;
15791
+ return stored;
15792
+ }
15793
+ }
15794
+ } catch {
15795
+ }
15796
+ }
15797
+ return null;
15798
+ }
15799
+ _cachePluginSession(session) {
15800
+ if (!session) {
15801
+ return null;
15802
+ }
15803
+ this._pluginSession = session;
15804
+ if (typeof window !== "undefined") {
15805
+ try {
15806
+ if (window.localStorage) {
15807
+ window.localStorage.setItem(PLUGIN_SESSION_STORAGE_KEY, session);
15808
+ }
15809
+ } catch {
15810
+ }
15811
+ }
15812
+ return session;
15813
+ }
15814
+ setPluginSession(session) {
15815
+ this._cachePluginSession(session);
15816
+ }
15817
+ _clearPluginSession(session = null) {
15818
+ if (!session || this._pluginSession === session) {
15819
+ this._pluginSession = null;
15820
+ }
15821
+ if (typeof window !== "undefined") {
15822
+ try {
15823
+ if (window.localStorage) {
15824
+ window.localStorage.removeItem(PLUGIN_SESSION_STORAGE_KEY);
15825
+ }
15826
+ } catch {
15827
+ }
15828
+ }
15829
+ }
15718
15830
  };
15719
15831
 
15720
15832
  // src/services/CoreService.js
@@ -28583,11 +28695,12 @@ function preprocessChanges(root, tuples = [], options = {}) {
28583
28695
  const expandTuple = (t) => {
28584
28696
  const [action, path, value2] = t || [];
28585
28697
  const isSchemaPath = Array.isArray(path) && path[0] === "schema";
28698
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
28586
28699
  if (action === "delete") {
28587
28700
  return [t];
28588
28701
  }
28589
28702
  const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject2(value2);
28590
- if (!canConsiderExpansion) {
28703
+ if (!canConsiderExpansion || isFilesPath || value2 && value2.type === "files") {
28591
28704
  return [t];
28592
28705
  }
28593
28706
  const prev = getByPathSafe(root, path) || {};
@@ -28653,7 +28766,8 @@ function preprocessChanges(root, tuples = [], options = {}) {
28653
28766
  continue;
28654
28767
  }
28655
28768
  const [action, path, value2] = t;
28656
- if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value2)) {
28769
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
28770
+ if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value2) || isFilesPath || value2 && value2.type === "files") {
28657
28771
  continue;
28658
28772
  }
28659
28773
  const keys2 = Object.keys(value2).filter((k) => k !== "__order");
@@ -30687,14 +30801,17 @@ var SubscriptionService = class extends BaseService {
30687
30801
  var FileService = class extends BaseService {
30688
30802
  // ==================== FILE METHODS ====================
30689
30803
  async uploadFile(file, options = {}) {
30804
+ var _a;
30690
30805
  this._requireReady("uploadFile");
30691
30806
  if (!file) {
30692
30807
  throw new Error("File is required for upload");
30693
30808
  }
30694
30809
  const formData = new FormData();
30695
30810
  formData.append("file", file);
30696
- if (options.projectId) {
30697
- formData.append("projectId", options.projectId);
30811
+ const hasProjectIdOption = Object.hasOwn(options, "projectId");
30812
+ const projectId = hasProjectIdOption ? options.projectId : (_a = this._context.project) == null ? void 0 : _a.id;
30813
+ if (projectId != null && projectId !== "") {
30814
+ formData.append("projectId", projectId);
30698
30815
  }
30699
30816
  if (options.tags) {
30700
30817
  formData.append("tags", JSON.stringify(options.tags));
@@ -30716,12 +30833,7 @@ var FileService = class extends BaseService {
30716
30833
  if (!response.success) {
30717
30834
  throw new Error(response.message);
30718
30835
  }
30719
- return {
30720
- id: response.data.id,
30721
- src: `${this._apiUrl}/core/files/public/${response.data.id}/download`,
30722
- success: true,
30723
- message: response.message
30724
- };
30836
+ return response.data;
30725
30837
  } catch (error) {
30726
30838
  throw new Error(`File upload failed: ${error.message}`, { cause: error });
30727
30839
  }