@symbo.ls/sdk 2.32.4 → 2.32.6

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.
@@ -841,8 +841,10 @@ var PROJECT_ROLE_PERMISSIONS = {
841
841
  };
842
842
 
843
843
  // src/services/AuthService.js
844
+ var PLUGIN_SESSION_STORAGE_KEY = "plugin_auth_session";
844
845
  var AuthService = class extends BaseService {
845
846
  constructor(config) {
847
+ var _a, _b;
846
848
  super(config);
847
849
  this._userRoles = /* @__PURE__ */ new Set(["guest", "editor", "admin", "owner"]);
848
850
  this._projectTiers = /* @__PURE__ */ new Set([
@@ -854,17 +856,28 @@ var AuthService = class extends BaseService {
854
856
  ]);
855
857
  this._projectRoleCache = /* @__PURE__ */ new Map();
856
858
  this._roleCacheExpiry = 5 * 60 * 1e3;
859
+ this._pluginSession = null;
860
+ this._resolvePluginSession(
861
+ (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
862
+ );
857
863
  }
858
864
  // Use BaseService.init/_request/_requireReady implementations
859
865
  // ==================== AUTH METHODS ====================
860
- async register(userData) {
866
+ async register(userData, options = {}) {
861
867
  try {
868
+ const { payload, session } = this._preparePluginPayload(
869
+ { ...userData || {} },
870
+ options.session
871
+ );
862
872
  const response = await this._request("/auth/register", {
863
873
  method: "POST",
864
- body: JSON.stringify(userData),
874
+ body: JSON.stringify(payload),
865
875
  methodName: "register"
866
876
  });
867
877
  if (response.success) {
878
+ if (session) {
879
+ this._clearPluginSession(session);
880
+ }
868
881
  return response.data;
869
882
  }
870
883
  throw new Error(response.message);
@@ -872,12 +885,19 @@ var AuthService = class extends BaseService {
872
885
  throw new Error(`Registration failed: ${error.message}`, { cause: error });
873
886
  }
874
887
  }
875
- async login(email, password) {
888
+ async login(email, password, options = {}) {
876
889
  var _a;
877
890
  try {
891
+ const { payload, session } = this._preparePluginPayload(
892
+ {
893
+ email,
894
+ password
895
+ },
896
+ options.session
897
+ );
878
898
  const response = await this._request("/auth/login", {
879
899
  method: "POST",
880
- body: JSON.stringify({ email, password }),
900
+ body: JSON.stringify(payload),
881
901
  methodName: "login"
882
902
  });
883
903
  if (response.success && response.data && response.data.tokens) {
@@ -893,6 +913,9 @@ var AuthService = class extends BaseService {
893
913
  }
894
914
  }
895
915
  if (response.success) {
916
+ if (session) {
917
+ this._clearPluginSession(session);
918
+ }
896
919
  return response.data;
897
920
  }
898
921
  throw new Error(response.message);
@@ -932,10 +955,10 @@ var AuthService = class extends BaseService {
932
955
  throw new Error(`Token refresh failed: ${error.message}`, { cause: error });
933
956
  }
934
957
  }
935
- async googleAuth(idToken, inviteToken = null) {
958
+ async googleAuth(idToken, inviteToken = null, options = {}) {
936
959
  var _a;
937
960
  try {
938
- const payload = { idToken };
961
+ const { payload, session } = this._preparePluginPayload({ idToken }, options.session);
939
962
  if (inviteToken) {
940
963
  payload.inviteToken = inviteToken;
941
964
  }
@@ -957,6 +980,9 @@ var AuthService = class extends BaseService {
957
980
  }
958
981
  }
959
982
  if (response.success) {
983
+ if (session) {
984
+ this._clearPluginSession(session);
985
+ }
960
986
  return response.data;
961
987
  }
962
988
  throw new Error(response.message);
@@ -964,10 +990,10 @@ var AuthService = class extends BaseService {
964
990
  throw new Error(`Google auth failed: ${error.message}`, { cause: error });
965
991
  }
966
992
  }
967
- async githubAuth(code, inviteToken = null) {
993
+ async githubAuth(code, inviteToken = null, options = {}) {
968
994
  var _a;
969
995
  try {
970
- const payload = { code };
996
+ const { payload, session } = this._preparePluginPayload({ code }, options.session);
971
997
  if (inviteToken) {
972
998
  payload.inviteToken = inviteToken;
973
999
  }
@@ -989,6 +1015,9 @@ var AuthService = class extends BaseService {
989
1015
  }
990
1016
  }
991
1017
  if (response.success) {
1018
+ if (session) {
1019
+ this._clearPluginSession(session);
1020
+ }
992
1021
  return response.data;
993
1022
  }
994
1023
  throw new Error(response.message);
@@ -996,10 +1025,13 @@ var AuthService = class extends BaseService {
996
1025
  throw new Error(`GitHub auth failed: ${error.message}`, { cause: error });
997
1026
  }
998
1027
  }
999
- async googleAuthCallback(code, redirectUri, inviteToken = null) {
1028
+ async googleAuthCallback(code, redirectUri, inviteToken = null, options = {}) {
1000
1029
  var _a;
1001
1030
  try {
1002
- const body = { code, redirectUri };
1031
+ const { payload: body, session } = this._preparePluginPayload(
1032
+ { code, redirectUri },
1033
+ options.session
1034
+ );
1003
1035
  if (inviteToken) {
1004
1036
  body.inviteToken = inviteToken;
1005
1037
  }
@@ -1021,6 +1053,9 @@ var AuthService = class extends BaseService {
1021
1053
  }
1022
1054
  }
1023
1055
  if (response.success) {
1056
+ if (session) {
1057
+ this._clearPluginSession(session);
1058
+ }
1024
1059
  return response.data;
1025
1060
  }
1026
1061
  throw new Error(response.message);
@@ -1504,17 +1539,17 @@ var AuthService = class extends BaseService {
1504
1539
  /**
1505
1540
  * Helper method to register with validation
1506
1541
  */
1507
- async registerWithValidation(userData) {
1542
+ async registerWithValidation(userData, options = {}) {
1508
1543
  const validation = this.validateRegistrationData(userData);
1509
1544
  if (!validation.isValid) {
1510
1545
  throw new Error(`Validation failed: ${validation.errors.join(", ")}`);
1511
1546
  }
1512
- return await this.register(userData);
1547
+ return await this.register(userData, options);
1513
1548
  }
1514
1549
  /**
1515
1550
  * Helper method to login with validation
1516
1551
  */
1517
- async loginWithValidation(email, password) {
1552
+ async loginWithValidation(email, password, options = {}) {
1518
1553
  if (!email || typeof email !== "string") {
1519
1554
  throw new Error("Email is required and must be a string");
1520
1555
  }
@@ -1524,7 +1559,7 @@ var AuthService = class extends BaseService {
1524
1559
  if (!this._isValidEmail(email)) {
1525
1560
  throw new Error("Email must be a valid email address");
1526
1561
  }
1527
- return await this.login(email, password);
1562
+ return await this.login(email, password, options);
1528
1563
  }
1529
1564
  /**
1530
1565
  * Private helper to validate email format
@@ -1632,6 +1667,83 @@ var AuthService = class extends BaseService {
1632
1667
  this._projectRoleCache.clear();
1633
1668
  this._setReady(false);
1634
1669
  }
1670
+ _preparePluginPayload(payload, sessionOverride = null) {
1671
+ const target = payload && typeof payload === "object" ? { ...payload } : {};
1672
+ const session = this._resolvePluginSession(sessionOverride);
1673
+ if (session && !Object.hasOwn(target, "session")) {
1674
+ target.session = session;
1675
+ return { payload: target, session };
1676
+ }
1677
+ return { payload: target, session: null };
1678
+ }
1679
+ _resolvePluginSession(sessionOverride = null) {
1680
+ var _a, _b;
1681
+ if (sessionOverride) {
1682
+ return this._cachePluginSession(sessionOverride);
1683
+ }
1684
+ if (this._pluginSession) {
1685
+ return this._pluginSession;
1686
+ }
1687
+ const optionSession = (_a = this._options) == null ? void 0 : _a.pluginSession;
1688
+ if (optionSession) {
1689
+ return this._cachePluginSession(optionSession);
1690
+ }
1691
+ const contextSession = (_b = this._context) == null ? void 0 : _b.pluginSession;
1692
+ if (contextSession) {
1693
+ return this._cachePluginSession(contextSession);
1694
+ }
1695
+ if (typeof window !== "undefined") {
1696
+ try {
1697
+ const sessionFromUrl = new URL(window.location.href).searchParams.get("session");
1698
+ if (sessionFromUrl) {
1699
+ return this._cachePluginSession(sessionFromUrl);
1700
+ }
1701
+ } catch {
1702
+ }
1703
+ try {
1704
+ if (window.localStorage) {
1705
+ const stored = window.localStorage.getItem(PLUGIN_SESSION_STORAGE_KEY);
1706
+ if (stored) {
1707
+ this._pluginSession = stored;
1708
+ return stored;
1709
+ }
1710
+ }
1711
+ } catch {
1712
+ }
1713
+ }
1714
+ return null;
1715
+ }
1716
+ _cachePluginSession(session) {
1717
+ if (!session) {
1718
+ return null;
1719
+ }
1720
+ this._pluginSession = session;
1721
+ if (typeof window !== "undefined") {
1722
+ try {
1723
+ if (window.localStorage) {
1724
+ window.localStorage.setItem(PLUGIN_SESSION_STORAGE_KEY, session);
1725
+ }
1726
+ } catch {
1727
+ }
1728
+ }
1729
+ return session;
1730
+ }
1731
+ setPluginSession(session) {
1732
+ this._cachePluginSession(session);
1733
+ }
1734
+ _clearPluginSession(session = null) {
1735
+ if (!session || this._pluginSession === session) {
1736
+ this._pluginSession = null;
1737
+ }
1738
+ if (typeof window !== "undefined") {
1739
+ try {
1740
+ if (window.localStorage) {
1741
+ window.localStorage.removeItem(PLUGIN_SESSION_STORAGE_KEY);
1742
+ }
1743
+ } catch {
1744
+ }
1745
+ }
1746
+ }
1635
1747
  };
1636
1748
  export {
1637
1749
  AuthService
@@ -24868,11 +24868,12 @@ function preprocessChanges(root, tuples = [], options = {}) {
24868
24868
  const expandTuple = (t) => {
24869
24869
  const [action, path, value2] = t || [];
24870
24870
  const isSchemaPath = Array.isArray(path) && path[0] === "schema";
24871
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
24871
24872
  if (action === "delete") {
24872
24873
  return [t];
24873
24874
  }
24874
24875
  const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject2(value2);
24875
- if (!canConsiderExpansion) {
24876
+ if (!canConsiderExpansion || isFilesPath || value2 && value2.type === "files") {
24876
24877
  return [t];
24877
24878
  }
24878
24879
  const prev = getByPathSafe(root, path) || {};
@@ -24938,7 +24939,8 @@ function preprocessChanges(root, tuples = [], options = {}) {
24938
24939
  continue;
24939
24940
  }
24940
24941
  const [action, path, value2] = t;
24941
- if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value2)) {
24942
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
24943
+ if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value2) || isFilesPath || value2 && value2.type === "files") {
24942
24944
  continue;
24943
24945
  }
24944
24946
  const keys2 = Object.keys(value2).filter((k) => k !== "__order");
@@ -708,14 +708,17 @@ var BaseService = class {
708
708
  var FileService = class extends BaseService {
709
709
  // ==================== FILE METHODS ====================
710
710
  async uploadFile(file, options = {}) {
711
+ var _a;
711
712
  this._requireReady("uploadFile");
712
713
  if (!file) {
713
714
  throw new Error("File is required for upload");
714
715
  }
715
716
  const formData = new FormData();
716
717
  formData.append("file", file);
717
- if (options.projectId) {
718
- formData.append("projectId", options.projectId);
718
+ const hasProjectIdOption = Object.hasOwn(options, "projectId");
719
+ const projectId = hasProjectIdOption ? options.projectId : (_a = this._context.project) == null ? void 0 : _a.id;
720
+ if (projectId != null && projectId !== "") {
721
+ formData.append("projectId", projectId);
719
722
  }
720
723
  if (options.tags) {
721
724
  formData.append("tags", JSON.stringify(options.tags));
@@ -737,12 +740,7 @@ var FileService = class extends BaseService {
737
740
  if (!response.success) {
738
741
  throw new Error(response.message);
739
742
  }
740
- return {
741
- id: response.data.id,
742
- src: `${this._apiUrl}/core/files/public/${response.data.id}/download`,
743
- success: true,
744
- message: response.message
745
- };
743
+ return response.data;
746
744
  } catch (error) {
747
745
  throw new Error(`File upload failed: ${error.message}`, { cause: error });
748
746
  }
@@ -1050,11 +1050,12 @@ function preprocessChanges(root, tuples = [], options = {}) {
1050
1050
  const expandTuple = (t) => {
1051
1051
  const [action, path, value] = t || [];
1052
1052
  const isSchemaPath = Array.isArray(path) && path[0] === "schema";
1053
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
1053
1054
  if (action === "delete") {
1054
1055
  return [t];
1055
1056
  }
1056
1057
  const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject2(value);
1057
- if (!canConsiderExpansion) {
1058
+ if (!canConsiderExpansion || isFilesPath || value && value.type === "files") {
1058
1059
  return [t];
1059
1060
  }
1060
1061
  const prev = getByPathSafe(root, path) || {};
@@ -1120,7 +1121,8 @@ function preprocessChanges(root, tuples = [], options = {}) {
1120
1121
  continue;
1121
1122
  }
1122
1123
  const [action, path, value] = t;
1123
- if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value)) {
1124
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
1125
+ if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value) || isFilesPath || value && value.type === "files") {
1124
1126
  continue;
1125
1127
  }
1126
1128
  const keys = Object.keys(value).filter((k) => k !== "__order");
@@ -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
  }
@@ -344,11 +344,12 @@ function preprocessChanges(root, tuples = [], options = {}) {
344
344
  const expandTuple = (t) => {
345
345
  const [action, path, value] = t || [];
346
346
  const isSchemaPath = Array.isArray(path) && path[0] === "schema";
347
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
347
348
  if (action === "delete") {
348
349
  return [t];
349
350
  }
350
351
  const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject2(value);
351
- if (!canConsiderExpansion) {
352
+ if (!canConsiderExpansion || isFilesPath || value && value.type === "files") {
352
353
  return [t];
353
354
  }
354
355
  const prev = getByPathSafe(root, path) || {};
@@ -414,7 +415,8 @@ function preprocessChanges(root, tuples = [], options = {}) {
414
415
  continue;
415
416
  }
416
417
  const [action, path, value] = t;
417
- if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value)) {
418
+ const isFilesPath = Array.isArray(path) && path[0] === "files";
419
+ if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value) || isFilesPath || value && value.type === "files") {
418
420
  continue;
419
421
  }
420
422
  const keys = Object.keys(value).filter((k) => k !== "__order");