@vtecx/vtecxnext 2.2.11 → 2.2.13

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.
@@ -618,6 +618,13 @@ export declare class VtecxNext {
618
618
  * @return feed
619
619
  */
620
620
  leaveGroup: (group: string) => Promise<boolean>;
621
+ /**
622
+ * leave group by admin
623
+ * @param uids uid list
624
+ * @param group group
625
+ * @return feed
626
+ */
627
+ leaveGroupByAdmin: (uids: string[], group: string) => Promise<any>;
621
628
  /**
622
629
  * Get entries that have entries in a group, but are not in the group.
623
630
  * (for entries with no signature or with an incorrect signature, if the user group requires a signature)
@@ -628,9 +635,9 @@ export declare class VtecxNext {
628
635
  /**
629
636
  * Get groups
630
637
  * @param uri group key
631
- * @return feed (entry array)
638
+ * @return group array
632
639
  */
633
- getGroups: () => Promise<any>;
640
+ getGroups: () => Promise<string[] | null>;
634
641
  /**
635
642
  * whether you are in the group
636
643
  * @param uri group key
package/dist/vtecxnext.js CHANGED
@@ -2358,7 +2358,7 @@ class VtecxNext {
2358
2358
  // 入力チェック
2359
2359
  checkUri(group);
2360
2360
  // vte.cxへリクエスト
2361
- const method = 'DELETE';
2361
+ const method = 'PUT';
2362
2362
  const url = `${SERVLETPATH_PROVIDER}${group}?_leavegroup`;
2363
2363
  let response;
2364
2364
  try {
@@ -2375,6 +2375,41 @@ class VtecxNext {
2375
2375
  // 戻り値
2376
2376
  return true;
2377
2377
  };
2378
+ /**
2379
+ * leave group by admin
2380
+ * @param uids uid list
2381
+ * @param group group
2382
+ * @return feed
2383
+ */
2384
+ leaveGroupByAdmin = async (uids, group) => {
2385
+ //console.log(`[vtecxnext leaveGroupByAdmin] start. group=${group} uids=${uids}`)
2386
+ // 入力チェック
2387
+ checkUri(group, 'group key');
2388
+ checkNotNull(uids, 'uid');
2389
+ // vte.cxへリクエスト
2390
+ const method = 'PUT';
2391
+ const url = `${SERVLETPATH_PROVIDER}${group}?_leavegroupByAdmin`;
2392
+ const feed = [];
2393
+ for (const uid of uids) {
2394
+ const entry = { 'link': [{ '___rel': 'self', '___href': `/_user/${uid}` }] };
2395
+ feed.push(entry);
2396
+ }
2397
+ const value = JSON.stringify(feed);
2398
+ let response;
2399
+ try {
2400
+ response = await this.requestVtecx(method, url, value);
2401
+ }
2402
+ catch (e) {
2403
+ throw newFetchError(e, true);
2404
+ }
2405
+ //console.log(`[vtecxnext leaveGroupByAdmin] response. status=${response.status}`)
2406
+ // vte.cxからのset-cookieを転記
2407
+ this.setCookie(response);
2408
+ // レスポンスのエラーチェック
2409
+ await checkVtecxResponse(response);
2410
+ // 戻り値
2411
+ return await getJson(response);
2412
+ };
2378
2413
  /**
2379
2414
  * Get entries that have entries in a group, but are not in the group.
2380
2415
  * (for entries with no signature or with an incorrect signature, if the user group requires a signature)
@@ -2406,7 +2441,7 @@ class VtecxNext {
2406
2441
  /**
2407
2442
  * Get groups
2408
2443
  * @param uri group key
2409
- * @return feed (entry array)
2444
+ * @return group array
2410
2445
  */
2411
2446
  getGroups = async () => {
2412
2447
  //console.log('[vtecxnext getGroups] start.')
@@ -2426,7 +2461,18 @@ class VtecxNext {
2426
2461
  // レスポンスのエラーチェック
2427
2462
  await checkVtecxResponse(response);
2428
2463
  // 戻り値
2429
- return await getJson(response);
2464
+ const feed = await getJson(response);
2465
+ //console.log(`[vtecxnext getGroups] feed=${JSON.stringify(feed)}`)
2466
+ if (feed && Array.isArray(feed) && feed.length > 0) {
2467
+ const groups = [];
2468
+ for (const entry of feed) {
2469
+ if (entry.link && entry.link.length > 0) {
2470
+ groups.push(entry.link[0].___href);
2471
+ }
2472
+ }
2473
+ return groups;
2474
+ }
2475
+ return null;
2430
2476
  };
2431
2477
  /**
2432
2478
  * whether you are in the group
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "2.2.11",
3
+ "version": "2.2.13",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [