@oxyhq/core 3.8.0 → 3.8.2
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/HttpService.js +18 -4
- package/dist/cjs/mixins/OxyServices.applications.js +69 -6
- package/dist/cjs/mixins/OxyServices.assets.js +16 -3
- package/dist/cjs/mixins/OxyServices.features.js +47 -10
- package/dist/cjs/mixins/OxyServices.managedAccounts.js +29 -3
- package/dist/cjs/mixins/OxyServices.privacy.js +34 -8
- package/dist/cjs/mixins/OxyServices.topics.js +5 -1
- package/dist/cjs/mixins/OxyServices.user.js +23 -3
- package/dist/cjs/mixins/OxyServices.workspaces.js +38 -3
- package/dist/cjs/utils/cache.js +9 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/HttpService.js +18 -4
- package/dist/esm/mixins/OxyServices.applications.js +69 -6
- package/dist/esm/mixins/OxyServices.assets.js +16 -3
- package/dist/esm/mixins/OxyServices.features.js +47 -10
- package/dist/esm/mixins/OxyServices.managedAccounts.js +29 -3
- package/dist/esm/mixins/OxyServices.privacy.js +34 -8
- package/dist/esm/mixins/OxyServices.topics.js +5 -1
- package/dist/esm/mixins/OxyServices.user.js +23 -3
- package/dist/esm/mixins/OxyServices.workspaces.js +38 -3
- package/dist/esm/utils/cache.js +9 -2
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/HttpService.d.ts +9 -0
- package/dist/types/mixins/OxyServices.applications.d.ts +26 -0
- package/dist/types/mixins/OxyServices.features.d.ts +27 -6
- package/dist/types/mixins/OxyServices.managedAccounts.d.ts +16 -1
- package/dist/types/mixins/OxyServices.privacy.d.ts +22 -4
- package/dist/types/mixins/OxyServices.user.d.ts +28 -1
- package/dist/types/mixins/OxyServices.workspaces.d.ts +12 -0
- package/dist/types/models/interfaces.d.ts +12 -0
- package/dist/types/utils/cache.d.ts +4 -1
- package/package.json +1 -4
- package/src/HttpService.ts +28 -4
- package/src/__tests__/httpServiceCache.test.ts +68 -0
- package/src/mixins/OxyServices.applications.ts +71 -6
- package/src/mixins/OxyServices.assets.ts +16 -3
- package/src/mixins/OxyServices.features.ts +47 -10
- package/src/mixins/OxyServices.managedAccounts.ts +29 -3
- package/src/mixins/OxyServices.privacy.ts +34 -8
- package/src/mixins/OxyServices.topics.ts +5 -1
- package/src/mixins/OxyServices.user.ts +39 -3
- package/src/mixins/OxyServices.workspaces.ts +39 -3
- package/src/mixins/__tests__/privacyCacheInvalidation.test.ts +147 -0
- package/src/models/interfaces.ts +13 -1
- package/src/utils/cache.ts +9 -2
|
@@ -23,6 +23,9 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
23
23
|
async createWorkspace(data) {
|
|
24
24
|
try {
|
|
25
25
|
const res = await this.makeRequest('POST', '/workspaces', data, { cache: false });
|
|
26
|
+
// Bust the cached workspace list so the new workspace appears on the
|
|
27
|
+
// next `getWorkspaces()` read within the TTL window.
|
|
28
|
+
this.clearCacheEntry('GET:/workspaces');
|
|
26
29
|
return res.workspace;
|
|
27
30
|
}
|
|
28
31
|
catch (error) {
|
|
@@ -50,6 +53,9 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
50
53
|
async updateWorkspace(workspaceId, data) {
|
|
51
54
|
try {
|
|
52
55
|
const res = await this.makeRequest('PATCH', `/workspaces/${encodeURIComponent(workspaceId)}`, data, { cache: false });
|
|
56
|
+
// Bust the cached detail and list — both surface workspace fields.
|
|
57
|
+
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
58
|
+
this.clearCacheEntry('GET:/workspaces');
|
|
53
59
|
return res.workspace;
|
|
54
60
|
}
|
|
55
61
|
catch (error) {
|
|
@@ -62,7 +68,12 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
62
68
|
*/
|
|
63
69
|
async deleteWorkspace(workspaceId) {
|
|
64
70
|
try {
|
|
65
|
-
|
|
71
|
+
const result = await this.makeRequest('DELETE', `/workspaces/${encodeURIComponent(workspaceId)}`, undefined, { cache: false });
|
|
72
|
+
// Bust every cached representation of the deleted workspace.
|
|
73
|
+
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
74
|
+
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}/members`);
|
|
75
|
+
this.clearCacheEntry('GET:/workspaces');
|
|
76
|
+
return result;
|
|
66
77
|
}
|
|
67
78
|
catch (error) {
|
|
68
79
|
throw this.handleError(error);
|
|
@@ -91,6 +102,7 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
91
102
|
async inviteWorkspaceMember(workspaceId, data) {
|
|
92
103
|
try {
|
|
93
104
|
const res = await this.makeRequest('POST', `/workspaces/${encodeURIComponent(workspaceId)}/members`, data, { cache: false });
|
|
105
|
+
this._invalidateWorkspaceMembership(workspaceId);
|
|
94
106
|
return res.member;
|
|
95
107
|
}
|
|
96
108
|
catch (error) {
|
|
@@ -106,6 +118,7 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
106
118
|
async updateWorkspaceMember(workspaceId, memberId, data) {
|
|
107
119
|
try {
|
|
108
120
|
const res = await this.makeRequest('PATCH', `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(memberId)}`, data, { cache: false });
|
|
121
|
+
this._invalidateWorkspaceMembership(workspaceId);
|
|
109
122
|
return res.member;
|
|
110
123
|
}
|
|
111
124
|
catch (error) {
|
|
@@ -119,7 +132,9 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
119
132
|
*/
|
|
120
133
|
async removeWorkspaceMember(workspaceId, memberId) {
|
|
121
134
|
try {
|
|
122
|
-
|
|
135
|
+
const result = await this.makeRequest('DELETE', `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(memberId)}`, undefined, { cache: false });
|
|
136
|
+
this._invalidateWorkspaceMembership(workspaceId);
|
|
137
|
+
return result;
|
|
123
138
|
}
|
|
124
139
|
catch (error) {
|
|
125
140
|
throw this.handleError(error);
|
|
@@ -133,11 +148,31 @@ export function OxyServicesWorkspacesMixin(Base) {
|
|
|
133
148
|
*/
|
|
134
149
|
async transferWorkspaceOwnership(workspaceId, data) {
|
|
135
150
|
try {
|
|
136
|
-
|
|
151
|
+
const result = await this.makeRequest('POST', `/workspaces/${encodeURIComponent(workspaceId)}/transfer-ownership`, data, { cache: false });
|
|
152
|
+
// Ownership change alters roles in the member list AND the detail, and
|
|
153
|
+
// can change which workspaces the caller "owns" in the list view.
|
|
154
|
+
this._invalidateWorkspaceMembership(workspaceId);
|
|
155
|
+
this.clearCacheEntry('GET:/workspaces');
|
|
156
|
+
return result;
|
|
137
157
|
}
|
|
138
158
|
catch (error) {
|
|
139
159
|
throw this.handleError(error);
|
|
140
160
|
}
|
|
141
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Bust the cached member list and detail for a workspace after a membership
|
|
164
|
+
* mutation. The member list (`getWorkspaceMembers`) and the detail
|
|
165
|
+
* (`getWorkspace`, which can embed member counts) both go stale when the
|
|
166
|
+
* member set or a member's role changes.
|
|
167
|
+
*
|
|
168
|
+
* Internal helper (leading underscore); not part of the supported public
|
|
169
|
+
* surface. Public rather than `private` because mixins compose into an
|
|
170
|
+
* exported anonymous class, where TypeScript cannot represent a private
|
|
171
|
+
* member in the emitted declaration file (TS4094).
|
|
172
|
+
*/
|
|
173
|
+
_invalidateWorkspaceMembership(workspaceId) {
|
|
174
|
+
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}/members`);
|
|
175
|
+
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
176
|
+
}
|
|
142
177
|
};
|
|
143
178
|
}
|
package/dist/esm/utils/cache.js
CHANGED
|
@@ -65,11 +65,18 @@ export class TTLCache {
|
|
|
65
65
|
* Set a value in cache
|
|
66
66
|
* @param key Cache key
|
|
67
67
|
* @param data Data to cache
|
|
68
|
-
* @param ttl Optional TTL override (uses default if not provided)
|
|
68
|
+
* @param ttl Optional TTL override (uses default if not provided). An
|
|
69
|
+
* explicit `0` or negative value is honored as "already expired" — the
|
|
70
|
+
* entry is stored with `expiresAt <= now`, so the next `get`/`has` treats
|
|
71
|
+
* it as a miss — rather than silently falling back to the default TTL.
|
|
69
72
|
*/
|
|
70
73
|
set(key, data, ttl) {
|
|
71
74
|
const now = Date.now();
|
|
72
|
-
|
|
75
|
+
// Distinguish "no override provided" (undefined → use default) from an
|
|
76
|
+
// explicit `0`/negative (do not cache). `ttl || this.defaultTTL` collapsed
|
|
77
|
+
// both into the default, making `cacheTTL:0` impossible to honor.
|
|
78
|
+
const effectiveTTL = ttl === undefined ? this.defaultTTL : ttl;
|
|
79
|
+
const expiresAt = now + effectiveTTL;
|
|
73
80
|
this.cache.set(key, { data, timestamp: now, expiresAt });
|
|
74
81
|
}
|
|
75
82
|
/**
|