@vtecx/vtecxnext 3.0.3 → 3.0.4

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.
@@ -113,6 +113,10 @@ export interface OAuthUserInfo {
113
113
  nickname?: string;
114
114
  state?: string | string[];
115
115
  }
116
+ export interface IndexInfo {
117
+ uri?: string;
118
+ fields?: string[];
119
+ }
116
120
  /**
117
121
  * vtecxnext.
118
122
  * Executes various operations for the vte.cx service.
@@ -1061,6 +1065,30 @@ export declare class VtecxNext {
1061
1065
  * @return property value
1062
1066
  */
1063
1067
  property: (name: string) => Promise<string | null>;
1068
+ /**
1069
+ * update index.
1070
+ * for service admin function
1071
+ * @param indexInfos update index information
1072
+ */
1073
+ updateIndex: (indexInfos: IndexInfo[]) => Promise<void>;
1074
+ /**
1075
+ * delete index.
1076
+ * for service admin function
1077
+ * @param indexInfos delete index information
1078
+ */
1079
+ deleteIndex: (indexInfos: IndexInfo[]) => Promise<void>;
1080
+ /**
1081
+ * convert index informations to argument entry
1082
+ * @param indexInfos index informations
1083
+ * @returns feed
1084
+ */
1085
+ private convertIndexInfoToEntries;
1086
+ /**
1087
+ * convert index fields to comma-separated string
1088
+ * @param fields index fields
1089
+ * @returns comma-separated string
1090
+ */
1091
+ private convertIndexFields;
1064
1092
  /**
1065
1093
  * vte.cxへリクエスト
1066
1094
  * @param method メソッド
package/dist/vtecxnext.js CHANGED
@@ -3886,6 +3886,98 @@ class VtecxNext {
3886
3886
  const data = await getJson(response);
3887
3887
  return data.feed.title;
3888
3888
  };
3889
+ /**
3890
+ * update index.
3891
+ * for service admin function
3892
+ * @param indexInfos update index information
3893
+ */
3894
+ updateIndex = async (indexInfos) => {
3895
+ //console.log('[vtecxnext updateIndex] start.')
3896
+ const feed = this.convertIndexInfoToEntries(indexInfos);
3897
+ // vte.cxへリクエスト
3898
+ const method = 'PUT';
3899
+ const url = `${SERVLETPATH_DATA}/?_updateindex`;
3900
+ let response;
3901
+ try {
3902
+ response = await this.requestVtecx(method, url, JSON.stringify(feed));
3903
+ }
3904
+ catch (e) {
3905
+ throw newFetchError(e, true);
3906
+ }
3907
+ //console.log(`[vtecxnext updateIndex] response=${response}`)
3908
+ // vte.cxからのset-cookieを転記
3909
+ this.setCookie(response);
3910
+ // レスポンスのエラーチェック
3911
+ await checkVtecxResponse(response);
3912
+ // 戻り値
3913
+ return await getJson(response);
3914
+ };
3915
+ /**
3916
+ * delete index.
3917
+ * for service admin function
3918
+ * @param indexInfos delete index information
3919
+ */
3920
+ deleteIndex = async (indexInfos) => {
3921
+ //console.log('[vtecxnext deleteIndex] start.')
3922
+ const feed = this.convertIndexInfoToEntries(indexInfos);
3923
+ // vte.cxへリクエスト
3924
+ const method = 'PUT';
3925
+ const url = `${SERVLETPATH_DATA}/?_deleteindex`;
3926
+ let response;
3927
+ try {
3928
+ response = await this.requestVtecx(method, url, JSON.stringify(feed));
3929
+ }
3930
+ catch (e) {
3931
+ throw newFetchError(e, true);
3932
+ }
3933
+ //console.log(`[vtecxnext deleteIndex] response=${response}`)
3934
+ // vte.cxからのset-cookieを転記
3935
+ this.setCookie(response);
3936
+ // レスポンスのエラーチェック
3937
+ await checkVtecxResponse(response);
3938
+ // 戻り値
3939
+ return await getJson(response);
3940
+ };
3941
+ /**
3942
+ * convert index informations to argument entry
3943
+ * @param indexInfos index informations
3944
+ * @returns feed
3945
+ */
3946
+ convertIndexInfoToEntries = (indexInfos) => {
3947
+ const retFeed = [];
3948
+ for (const indexInfo of indexInfos) {
3949
+ const title = this.convertIndexFields(indexInfo.fields);
3950
+ const retEntry = {
3951
+ link: [
3952
+ {
3953
+ ___rel: 'self',
3954
+ ___href: indexInfo.uri
3955
+ }
3956
+ ],
3957
+ title: title
3958
+ };
3959
+ retFeed.push(retEntry);
3960
+ }
3961
+ return retFeed;
3962
+ };
3963
+ /**
3964
+ * convert index fields to comma-separated string
3965
+ * @param fields index fields
3966
+ * @returns comma-separated string
3967
+ */
3968
+ convertIndexFields = (fields) => {
3969
+ if (fields && fields.length) {
3970
+ let title = '';
3971
+ for (const field of fields) {
3972
+ if (title) {
3973
+ title += ',';
3974
+ }
3975
+ title += fields;
3976
+ }
3977
+ return title;
3978
+ }
3979
+ return undefined;
3980
+ };
3889
3981
  //----------------------
3890
3982
  /**
3891
3983
  * vte.cxへリクエスト
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [