@blocklet/js-sdk 1.16.52-beta-20251002-030549-0f91dab2 → 1.16.52-beta-20251005-235515-42ad5caf

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.d.mts CHANGED
@@ -40,6 +40,10 @@ interface SpaceGateway {
40
40
  url: string;
41
41
  endpoint: string;
42
42
  }
43
+ declare enum OrgQueryType {
44
+ OWNED = "owned",
45
+ JOINED = "joined"
46
+ }
43
47
  declare class AuthService {
44
48
  private api;
45
49
  private token;
@@ -101,6 +105,29 @@ declare class AuthService {
101
105
  destroyMyself(): Promise<{
102
106
  did: string;
103
107
  }>;
108
+ /**
109
+ * org 相关
110
+ */
111
+ getOrgs({ search, type, page, pageSize, }: {
112
+ search?: string;
113
+ page: number;
114
+ pageSize: number;
115
+ type?: OrgQueryType | '';
116
+ }): Promise<any>;
117
+ getOrg(orgId: string): Promise<any>;
118
+ createOrg(org: any): Promise<any>;
119
+ getRole(name: string): Promise<any>;
120
+ addResourceToOrg({ orgId, resourceId, type, metadata, }: {
121
+ orgId: string;
122
+ resourceId: string;
123
+ type?: string;
124
+ metadata?: any;
125
+ }): Promise<any>;
126
+ migrateResourceToOrg({ form, to, resourceId }: {
127
+ form: string;
128
+ to: string;
129
+ resourceId: string;
130
+ }): Promise<any>;
104
131
  }
105
132
 
106
133
  type RequestParams = {
@@ -323,4 +350,4 @@ declare function createFetch(options?: RequestInit, requestParams?: RequestParam
323
350
  }) => Promise<Response>;
324
351
  declare const getBlockletSDK: () => BlockletSDK;
325
352
 
326
- export { AuthService, BlockletSDK, BlockletService, ComponentService, FederatedService, type NotificationConfig, type PrivacyConfig, type SpaceGateway, TokenService, type UserPublicInfo, type UserSession, type UserSessionList, type UserSessionQuery, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
353
+ export { AuthService, BlockletSDK, BlockletService, ComponentService, FederatedService, type NotificationConfig, OrgQueryType, type PrivacyConfig, type SpaceGateway, TokenService, type UserPublicInfo, type UserSession, type UserSessionList, type UserSessionQuery, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
package/dist/index.d.ts CHANGED
@@ -40,6 +40,10 @@ interface SpaceGateway {
40
40
  url: string;
41
41
  endpoint: string;
42
42
  }
43
+ declare enum OrgQueryType {
44
+ OWNED = "owned",
45
+ JOINED = "joined"
46
+ }
43
47
  declare class AuthService {
44
48
  private api;
45
49
  private token;
@@ -101,6 +105,29 @@ declare class AuthService {
101
105
  destroyMyself(): Promise<{
102
106
  did: string;
103
107
  }>;
108
+ /**
109
+ * org 相关
110
+ */
111
+ getOrgs({ search, type, page, pageSize, }: {
112
+ search?: string;
113
+ page: number;
114
+ pageSize: number;
115
+ type?: OrgQueryType | '';
116
+ }): Promise<any>;
117
+ getOrg(orgId: string): Promise<any>;
118
+ createOrg(org: any): Promise<any>;
119
+ getRole(name: string): Promise<any>;
120
+ addResourceToOrg({ orgId, resourceId, type, metadata, }: {
121
+ orgId: string;
122
+ resourceId: string;
123
+ type?: string;
124
+ metadata?: any;
125
+ }): Promise<any>;
126
+ migrateResourceToOrg({ form, to, resourceId }: {
127
+ form: string;
128
+ to: string;
129
+ resourceId: string;
130
+ }): Promise<any>;
104
131
  }
105
132
 
106
133
  type RequestParams = {
@@ -323,4 +350,4 @@ declare function createFetch(options?: RequestInit, requestParams?: RequestParam
323
350
  }) => Promise<Response>;
324
351
  declare const getBlockletSDK: () => BlockletSDK;
325
352
 
326
- export { AuthService, BlockletSDK, BlockletService, ComponentService, FederatedService, type NotificationConfig, type PrivacyConfig, type SpaceGateway, TokenService, type UserPublicInfo, type UserSession, type UserSessionList, type UserSessionQuery, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
353
+ export { AuthService, BlockletSDK, BlockletService, ComponentService, FederatedService, type NotificationConfig, OrgQueryType, type PrivacyConfig, type SpaceGateway, TokenService, type UserPublicInfo, type UserSession, type UserSessionList, type UserSessionQuery, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
package/dist/index.mjs CHANGED
@@ -117,6 +117,45 @@ class AuthService {
117
117
  const { data } = await this.api.delete("/api/user");
118
118
  return data;
119
119
  }
120
+ /**
121
+ * org 相关
122
+ */
123
+ async getOrgs({
124
+ search = "",
125
+ type = "",
126
+ page = 1,
127
+ pageSize = 20
128
+ }) {
129
+ const { data } = await this.api.get("/api/user/orgs", { params: { search, page, pageSize, type } });
130
+ return data;
131
+ }
132
+ // 根据 orgId 查询一个 org 的信息
133
+ async getOrg(orgId) {
134
+ const { data } = await this.api.get(`/api/user/orgs/${orgId}`);
135
+ return data;
136
+ }
137
+ async createOrg(org) {
138
+ const { data } = await this.api.post("/api/user/orgs", { org });
139
+ return data;
140
+ }
141
+ // 查询一个role 的信息用于获取是否属于一个 org
142
+ async getRole(name) {
143
+ const { data } = await this.api.get("/api/user/role", { params: { name } });
144
+ return data;
145
+ }
146
+ async addResourceToOrg({
147
+ orgId,
148
+ resourceId,
149
+ type,
150
+ metadata
151
+ }) {
152
+ const { data } = await this.api.post(`/api/user/orgs/${orgId}/resources`, { resourceId, type, metadata });
153
+ return data;
154
+ }
155
+ async migrateResourceToOrg({ form, to, resourceId }) {
156
+ const { data } = await this.api.put(`/api/user/orgs/${form}/resources`, { to, resourceId });
157
+ return data;
158
+ }
120
159
  }
121
160
 
122
161
  class TokenService {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/js-sdk",
3
- "version": "1.16.52-beta-20251002-030549-0f91dab2",
3
+ "version": "1.16.52-beta-20251005-235515-42ad5caf",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -38,9 +38,9 @@
38
38
  "watch": "nodemon -w src -e ts -x 'npm run build'"
39
39
  },
40
40
  "dependencies": {
41
- "@abtnode/constant": "1.16.52-beta-20251002-030549-0f91dab2",
41
+ "@abtnode/constant": "1.16.52-beta-20251005-235515-42ad5caf",
42
42
  "@arcblock/did": "1.25.6",
43
- "@blocklet/meta": "1.16.52-beta-20251002-030549-0f91dab2",
43
+ "@blocklet/meta": "1.16.52-beta-20251005-235515-42ad5caf",
44
44
  "@ocap/wallet": "1.25.6",
45
45
  "axios": "^1.7.9",
46
46
  "is-url": "^1.2.4",
@@ -65,5 +65,5 @@
65
65
  "unbuild": "^2.0.0",
66
66
  "vitest": "^3.2.4"
67
67
  },
68
- "gitHead": "57e57e5edc99bfbb7e4591d682f1057ec05655a8"
68
+ "gitHead": "7b295929a123edac2cb292c43f2edda0d3e3e6b8"
69
69
  }