@konomi-app/kintone-utilities 1.22.2 → 1.24.0

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.
@@ -0,0 +1,4 @@
1
+ import { kintoneAPI } from '../types/api';
2
+ export declare const api: <T = any>(path: string, method: kintoneAPI.rest.Method, body: any) => Promise<T>;
3
+ export declare const checkBrowser: () => void;
4
+ export declare const sliceIntoChunks: <T>(array: T[], size: number) => T[][];
@@ -0,0 +1,20 @@
1
+ export const api = (path, method, body) => {
2
+ checkBrowser();
3
+ return kintone.api(kintone.api.url(path, true), method, body);
4
+ };
5
+ export const checkBrowser = () => {
6
+ if (typeof window === 'undefined') {
7
+ throw new Error('この関数はブラウザでのみ使用できます');
8
+ }
9
+ if (typeof kintone === 'undefined') {
10
+ throw new Error('kintoneオブジェクトが見つかりません');
11
+ }
12
+ };
13
+ export const sliceIntoChunks = (array, size) => {
14
+ const result = [];
15
+ for (let i = 0, j = array.length; i < j; i += size) {
16
+ result.push(array.slice(i, i + size));
17
+ }
18
+ return result;
19
+ };
20
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/rest-api/common.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,IAAY,EACZ,MAA8B,EAC9B,IAAS,EACG,EAAE;IACd,YAAY,EAAE,CAAC;IACf,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAe,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;IACD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC1C;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,KAAU,EAAE,IAAY,EAAS,EAAE;IACpE,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE;QAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;KACvC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { kintoneAPI } from '../types/api';
2
+ export declare const getCybozuUsers: (props?: kintoneAPI.cybozu.GetUsersRequest) => Promise<kintoneAPI.cybozu.GetUsersResponse>;
3
+ export declare const getUsedCybozuServices: (props: kintoneAPI.cybozu.GetUsedServicesRequest) => Promise<kintoneAPI.cybozu.GetUsedServicesResponse>;
4
+ export declare const updateUsedCybozuServices: (props: kintoneAPI.cybozu.UpdateUsedServicesRequest) => Promise<kintoneAPI.cybozu.UpdateUsedServicesResponse>;
@@ -0,0 +1,15 @@
1
+ import { api } from './common';
2
+ const API_ENDPOINT_ROOT = '/v1';
3
+ const API_ENDPOINT_USERS = `${API_ENDPOINT_ROOT}/users.json`;
4
+ const API_ENDPOINT_SERVICES = `${API_ENDPOINT_ROOT}/users/services.json`;
5
+ const API_ENDPOINT_GROUPS = `${API_ENDPOINT_ROOT}/groups.json`;
6
+ export const getCybozuUsers = (props = {}) => {
7
+ return api(API_ENDPOINT_USERS, 'GET', props);
8
+ };
9
+ export const getUsedCybozuServices = (props) => {
10
+ return api(API_ENDPOINT_SERVICES, 'GET', props);
11
+ };
12
+ export const updateUsedCybozuServices = (props) => {
13
+ return api(API_ENDPOINT_SERVICES, 'PUT', props);
14
+ };
15
+ //# sourceMappingURL=cybozu-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cybozu-user.js","sourceRoot":"","sources":["../../src/rest-api/cybozu-user.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,kBAAkB,GAAG,GAAG,iBAAiB,aAAa,CAAC;AAC7D,MAAM,qBAAqB,GAAG,GAAG,iBAAiB,sBAAsB,CAAC;AACzE,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAA2C,EAAE,EAAE,EAAE;IAC9E,OAAO,GAAG,CAAqC,kBAAkB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACnF,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA+C,EAAE,EAAE;IACvF,OAAO,GAAG,CAA4C,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC7F,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAkD,EAAE,EAAE;IAC7F,OAAO,GAAG,CAA+C,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAChG,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './record';
2
+ export * from './space';
@@ -0,0 +1,3 @@
1
+ export * from './record';
2
+ export * from './space';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rest-api/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,126 @@
1
+ import { kintoneAPI } from '../types/api';
2
+ type App = number | string;
3
+ export declare const backdoor: (props: {
4
+ apiToken: string;
5
+ method: kintoneAPI.rest.Method;
6
+ path: string;
7
+ body?: any;
8
+ }) => Promise<any>;
9
+ export declare const getRecord: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordGetRequest) => Promise<T>;
10
+ export declare const backdoorGetRecord: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordGetRequest & {
11
+ apiToken: string;
12
+ }) => Promise<T>;
13
+ export declare const updateRecord: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordPutRequest<T>) => Promise<kintoneAPI.rest.RecordPutResponse>;
14
+ export declare const addRecord: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordPostRequest<T>) => Promise<kintoneAPI.rest.RecordPostResponse>;
15
+ export declare const updateRecords: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordsPutRequest<T>) => Promise<kintoneAPI.rest.RecordsPutResponse>;
16
+ export declare const addRecords: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordsPostRequest<T>) => Promise<kintoneAPI.rest.RecordsPostResponse>;
17
+ /**
18
+ * 対象アプリの指定されたクエリに一致するレコードを全件取得します
19
+ *
20
+ * クエリを解析し、order byが含まれている場合はカーソルAPIを使ってレコードを取得します
21
+ *
22
+ * order byが含まれていない場合は、レコードIDを使ってレコードを取得します
23
+ *
24
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onStep: 段階的にレコードを取得する過程で実行される関数
25
+ * @returns 取得したレコードの配列
26
+ */
27
+ export declare const getAllRecords: <T extends Record<string, any> = import("@kintone/rest-api-client/lib/client/types").Record>(props: kintoneAPI.rest.RecordsGetRequest & {
28
+ onStep?: OnStep<T> | undefined;
29
+ }) => Promise<T[]>;
30
+ type WithId<T> = T & {
31
+ $id: kintoneAPI.field.ID;
32
+ };
33
+ type OnStep<T> = (records: T[]) => void;
34
+ /**
35
+ * 対象アプリの指定されたクエリに一致するレコードを、レコードIDをもとに全件取得します
36
+ *
37
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onStep: 段階的にレコードを取得する過程で実行される関数
38
+ * @returns 取得したレコードの配列
39
+ */
40
+ export declare const getAllRecordsWithId: <T extends Record<string, any>>(props: {
41
+ app: App;
42
+ fields?: string[] | undefined;
43
+ onStep?: OnStep<T> | undefined;
44
+ condition?: string | undefined;
45
+ }) => Promise<WithId<T>[]>;
46
+ type OnTotalGet = (total: number) => void;
47
+ /**
48
+ * 対象アプリの指定されたクエリに一致するレコードを、カーソルAPIを使って全件取得します
49
+ *
50
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onTotalGet: 取得するレコードの総数を取得した際に実行される関数, onStep: 段階的にレコードを取得する過程で実行される関数
51
+ * @returns 取得したレコードの配列
52
+ */
53
+ export declare const getAllRecordsWithCursor: <T extends kintoneAPI.rest.Frame>(props: {
54
+ app: App;
55
+ fields?: string[] | undefined;
56
+ query?: string | undefined;
57
+ onTotalGet?: OnTotalGet | undefined;
58
+ onStep?: OnStep<T> | undefined;
59
+ }) => Promise<T[]>;
60
+ /**
61
+ * kintoneへファイルをアップロードします
62
+ *
63
+ * @param props
64
+ * @returns
65
+ */
66
+ export declare const uploadFile: (props: {
67
+ file: {
68
+ name: string;
69
+ data: Blob;
70
+ };
71
+ }) => Promise<{
72
+ fileKey: string;
73
+ }>;
74
+ export declare const downloadFile: (props: {
75
+ fileKey: string;
76
+ }) => Promise<Blob>;
77
+ export declare const getApp: (props: {
78
+ id: App;
79
+ }) => Promise<kintoneAPI.App>;
80
+ export declare const getAllApps: (offset?: number, _apps?: kintoneAPI.App[]) => Promise<kintoneAPI.App[]>;
81
+ export declare const getFormFields: (props: {
82
+ app: App;
83
+ preview?: boolean;
84
+ }) => Promise<{
85
+ properties: kintoneAPI.FieldProperties;
86
+ revision: string;
87
+ }>;
88
+ export declare const getFormLayout: (props: {
89
+ app: App;
90
+ preview?: boolean;
91
+ }) => Promise<{
92
+ layout: kintoneAPI.Layout;
93
+ revision: string;
94
+ }>;
95
+ export declare const getViews: (props: {
96
+ app: App;
97
+ lang?: 'ja' | 'en' | 'zh' | 'user' | 'default';
98
+ preview?: boolean;
99
+ }) => Promise<{
100
+ views: Record<string, kintoneAPI.view.Response>;
101
+ revision: string;
102
+ }>;
103
+ export declare const updateViews: (props: {
104
+ app: App;
105
+ views: Record<string, kintoneAPI.view.Parameter>;
106
+ }) => Promise<any>;
107
+ export declare const bulkRequest: <T extends kintoneAPI.rest.Frame = import("@kintone/rest-api-client/lib/client/types").Record>(props: {
108
+ requests: ({
109
+ type: 'updateRecord';
110
+ props: kintoneAPI.rest.RecordPutRequest<T>;
111
+ } | {
112
+ type: 'addRecord';
113
+ props: kintoneAPI.rest.RecordPostRequest<T>;
114
+ } | {
115
+ type: 'updateRecords';
116
+ props: kintoneAPI.rest.RecordsPutRequest<T>;
117
+ } | {
118
+ type: 'addRecords';
119
+ props: kintoneAPI.rest.RecordsPostRequest<T>;
120
+ } | {
121
+ type: 'deleteRecords';
122
+ props: kintoneAPI.rest.RecordsDeleteRequest;
123
+ })[];
124
+ debug?: boolean | undefined;
125
+ }) => Promise<kintoneAPI.rest.BulkResponse>;
126
+ export {};
@@ -0,0 +1,267 @@
1
+ import { api, checkBrowser, sliceIntoChunks } from './common';
2
+ const API_ENDPOINT_ROOT = '/k/v1';
3
+ const API_ENDPOINT_RECORD = `${API_ENDPOINT_ROOT}/record.json`;
4
+ const API_ENDPOINT_RECORDS = `${API_ENDPOINT_ROOT}/records.json`;
5
+ const API_ENDPOINT_CURSOR = `${API_ENDPOINT_ROOT}/records/cursor.json`;
6
+ const API_ENDPOINT_BULK = `${API_ENDPOINT_ROOT}/bulkRequest.json`;
7
+ const API_LIMIT_GET = 500;
8
+ const API_LIMIT_PUT = 100;
9
+ const API_LIMIT_POST = 100;
10
+ const API_LIMIT_DELETE = 100;
11
+ const API_LIMIT_APP = 100;
12
+ const API_LIMIT_BULK_REQUEST = 20;
13
+ export const backdoor = async (props) => {
14
+ checkBrowser();
15
+ const { apiToken, method, path, body } = props;
16
+ const header = {
17
+ 'X-Cybozu-API-Token': apiToken,
18
+ };
19
+ if (method !== 'GET') {
20
+ header['Content-Type'] = 'application/json';
21
+ }
22
+ const uri = kintone.api.url(path, true);
23
+ const response = await kintone.proxy(uri, method, header, body);
24
+ if (response[1] !== 200) {
25
+ throw new Error(`Backdoor API Error: ${response[1]} ${response[0]}`);
26
+ }
27
+ return JSON.parse(response[0]);
28
+ };
29
+ export const getRecord = async (props) => {
30
+ const { app, id } = props;
31
+ const { record } = await api(API_ENDPOINT_RECORD, 'GET', {
32
+ app,
33
+ id,
34
+ });
35
+ return record;
36
+ };
37
+ export const backdoorGetRecord = async (props) => {
38
+ const { app, id, apiToken } = props;
39
+ const { record } = await backdoor({
40
+ apiToken,
41
+ method: 'GET',
42
+ path: API_ENDPOINT_RECORD,
43
+ body: { app, id },
44
+ });
45
+ return record;
46
+ };
47
+ export const updateRecord = async (props) => {
48
+ return api(API_ENDPOINT_RECORD, 'PUT', props);
49
+ };
50
+ export const addRecord = async (props) => {
51
+ return api(API_ENDPOINT_RECORD, 'POST', props);
52
+ };
53
+ export const updateRecords = async (props) => {
54
+ const responses = (await bulkRequest({
55
+ requests: [{ type: 'updateRecords', props }],
56
+ }));
57
+ return responses.reduce((acc, response) => {
58
+ return { records: [...acc.records, ...response.records] };
59
+ }, { records: [] });
60
+ };
61
+ export const addRecords = async (props) => {
62
+ const responses = (await bulkRequest({
63
+ requests: [{ type: 'addRecords', props }],
64
+ }));
65
+ return responses.reduce((acc, response) => {
66
+ return {
67
+ ids: [...acc.ids, ...response.ids],
68
+ revision: [...acc.revision, ...response.revision],
69
+ };
70
+ }, { ids: [], revision: [] });
71
+ };
72
+ /**
73
+ * 対象アプリの指定されたクエリに一致するレコードを全件取得します
74
+ *
75
+ * クエリを解析し、order byが含まれている場合はカーソルAPIを使ってレコードを取得します
76
+ *
77
+ * order byが含まれていない場合は、レコードIDを使ってレコードを取得します
78
+ *
79
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onStep: 段階的にレコードを取得する過程で実行される関数
80
+ * @returns 取得したレコードの配列
81
+ */
82
+ export const getAllRecords = async (props) => {
83
+ if (props.query && props.query.includes('order by')) {
84
+ return getAllRecordsWithCursor(props);
85
+ }
86
+ return getAllRecordsWithId({ ...props, condition: props.query });
87
+ };
88
+ /**
89
+ * 対象アプリの指定されたクエリに一致するレコードを、レコードIDをもとに全件取得します
90
+ *
91
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onStep: 段階的にレコードを取得する過程で実行される関数
92
+ * @returns 取得したレコードの配列
93
+ */
94
+ export const getAllRecordsWithId = async (props) => {
95
+ const { fields: initFields, condition: initCondition = '' } = props;
96
+ const fields = initFields?.length ? [...new Set([...initFields, '$id'])] : undefined;
97
+ // order byは使用できないため、conditionに含まれている場合は除外する
98
+ const condition = initCondition.replace(/order by.*/g, '');
99
+ return getRecursive({ ...props, fields, condition });
100
+ };
101
+ const getRecursive = async (props) => {
102
+ const { app, fields, condition, id } = props;
103
+ const newCondition = id ? `${condition ? `${condition} and ` : ''} $id < ${id}` : condition;
104
+ const query = `${newCondition} order by $id desc limit ${API_LIMIT_GET}`;
105
+ const { records } = await api(API_ENDPOINT_RECORDS, 'GET', { app, fields, query });
106
+ if (!records.length) {
107
+ return props.stored ?? [];
108
+ }
109
+ const stored = [...(props.stored ?? []), ...records];
110
+ if (props.onStep) {
111
+ props.onStep(stored);
112
+ }
113
+ const lastRecord = stored[stored.length - 1];
114
+ const lastId = lastRecord.$id.value;
115
+ return records.length === API_LIMIT_GET ? getRecursive({ ...props, id: lastId, stored }) : stored;
116
+ };
117
+ /**
118
+ * 対象アプリの指定されたクエリに一致するレコードを、カーソルAPIを使って全件取得します
119
+ *
120
+ * @param props app: 対象アプリのID, query: 取得するレコードのクエリ, fields: 取得するフィールドコードの配列, onTotalGet: 取得するレコードの総数を取得した際に実行される関数, onStep: 段階的にレコードを取得する過程で実行される関数
121
+ * @returns 取得したレコードの配列
122
+ */
123
+ export const getAllRecordsWithCursor = async (props) => {
124
+ const { app, fields = [], query = '', onTotalGet = null, onStep = null } = props;
125
+ const param = { app, fields, size: API_LIMIT_GET, query };
126
+ const cursor = await api(API_ENDPOINT_CURSOR, 'POST', param);
127
+ if (onTotalGet) {
128
+ onTotalGet(Number(cursor.totalCount));
129
+ }
130
+ return getRecordsByCursorId({ id: cursor.id, onStep });
131
+ };
132
+ const getRecordsByCursorId = async (props) => {
133
+ const { id, onStep, loadedData = [] } = props;
134
+ const response = await api(API_ENDPOINT_CURSOR, 'GET', {
135
+ id,
136
+ });
137
+ const newRecords = [...loadedData, ...response.records];
138
+ if (onStep) {
139
+ onStep(newRecords);
140
+ }
141
+ return response.next ? getRecordsByCursorId({ id, onStep, loadedData: newRecords }) : newRecords;
142
+ };
143
+ /**
144
+ * kintoneへファイルをアップロードします
145
+ *
146
+ * @param props
147
+ * @returns
148
+ */
149
+ export const uploadFile = async (props) => {
150
+ const { file } = props;
151
+ const formData = new FormData();
152
+ formData.append('__REQUEST_TOKEN__', kintone.getRequestToken());
153
+ formData.append('file', file.data, file.name);
154
+ const headers = { 'X-Requested-With': 'XMLHttpRequest' };
155
+ const response = await fetch('/k/v1/file.json', {
156
+ method: 'POST',
157
+ headers,
158
+ body: formData,
159
+ });
160
+ return response.json();
161
+ };
162
+ export const downloadFile = async (props) => {
163
+ const { fileKey } = props;
164
+ const headers = { 'X-Requested-With': 'XMLHttpRequest' };
165
+ const response = await fetch(`/k/v1/file.json?fileKey=${fileKey}`, {
166
+ method: 'GET',
167
+ headers,
168
+ });
169
+ return response.blob();
170
+ };
171
+ export const getApp = async (props) => {
172
+ return api(`${API_ENDPOINT_ROOT}/app`, 'GET', props);
173
+ };
174
+ const getApps = async (props) => {
175
+ return api(`${API_ENDPOINT_ROOT}/apps`, 'GET', props);
176
+ };
177
+ export const getAllApps = async (offset = 0, _apps = []) => {
178
+ const { apps } = await getApps({ limit: API_LIMIT_APP, offset });
179
+ const allApps = [..._apps, ...apps];
180
+ return apps.length === API_LIMIT_APP ? getAllApps(offset + API_LIMIT_APP, allApps) : allApps;
181
+ };
182
+ export const getFormFields = async (props) => {
183
+ const { app, preview = false } = props;
184
+ return api(`${API_ENDPOINT_ROOT}/${preview ? 'preview/' : ''}app/form/fields`, 'GET', { app });
185
+ };
186
+ export const getFormLayout = async (props) => {
187
+ const { app, preview = false } = props;
188
+ return api(`${API_ENDPOINT_ROOT}/${preview ? 'preview/' : ''}app/form/layout`, 'GET', { app });
189
+ };
190
+ export const getViews = async (props) => {
191
+ const { app, preview = false, lang = 'default' } = props;
192
+ return api(`${API_ENDPOINT_ROOT}/${preview ? 'preview/' : ''}app/views`, 'GET', { app, lang });
193
+ };
194
+ export const updateViews = async (props) => {
195
+ return api(`${API_ENDPOINT_ROOT}/preview/app/views`, 'PUT', props);
196
+ };
197
+ export const bulkRequest = async (props) => {
198
+ const { requests, debug = false } = props;
199
+ let reshapedRequests = [];
200
+ for (const request of requests) {
201
+ if (request.type === 'updateRecord') {
202
+ reshapedRequests.push({
203
+ method: 'PUT',
204
+ api: API_ENDPOINT_RECORD,
205
+ payloads: request.props,
206
+ });
207
+ }
208
+ else if (request.type === 'addRecord') {
209
+ reshapedRequests.push({
210
+ method: 'POST',
211
+ api: API_ENDPOINT_RECORD,
212
+ payloads: request.props,
213
+ });
214
+ }
215
+ else if (request.type === 'updateRecords') {
216
+ const { records, ...rest } = request.props;
217
+ const recordChunks = sliceIntoChunks(request.props.records, API_LIMIT_PUT);
218
+ for (const records of recordChunks) {
219
+ reshapedRequests.push({
220
+ method: 'PUT',
221
+ api: API_ENDPOINT_RECORDS,
222
+ payloads: {
223
+ ...rest,
224
+ records,
225
+ },
226
+ });
227
+ }
228
+ }
229
+ else if (request.type === 'addRecords') {
230
+ const recordChunks = sliceIntoChunks(request.props.records, API_LIMIT_POST);
231
+ for (const records of recordChunks) {
232
+ reshapedRequests.push({
233
+ method: 'POST',
234
+ api: API_ENDPOINT_RECORDS,
235
+ payloads: {
236
+ app: request.props.app,
237
+ records,
238
+ },
239
+ });
240
+ }
241
+ }
242
+ else if (request.type === 'deleteRecords') {
243
+ const idChunks = sliceIntoChunks(request.props.ids, API_LIMIT_DELETE);
244
+ for (const ids of idChunks) {
245
+ reshapedRequests.push({
246
+ method: 'DELETE',
247
+ api: API_ENDPOINT_RECORDS,
248
+ payloads: {
249
+ app: request.props.app,
250
+ ids,
251
+ },
252
+ });
253
+ }
254
+ }
255
+ }
256
+ const responses = [];
257
+ const requestChunks = sliceIntoChunks(reshapedRequests, API_LIMIT_BULK_REQUEST);
258
+ for (const requests of requestChunks) {
259
+ const response = await api(API_ENDPOINT_BULK, 'POST', requests);
260
+ if (debug) {
261
+ console.log(`bulk request ${requests.length}/${reshapedRequests.length}`);
262
+ }
263
+ responses.push(response);
264
+ }
265
+ return responses;
266
+ };
267
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/rest-api/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,cAAc,CAAC;AAC/D,MAAM,oBAAoB,GAAG,GAAG,iBAAiB,eAAe,CAAC;AACjE,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,sBAAsB,CAAC;AACvE,MAAM,iBAAiB,GAAG,GAAG,iBAAiB,mBAAmB,CAAC;AAClE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,a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AM,QAAQ,IAAI,aAAa,EAAE;QACpC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAA+B,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC9F,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,gBAAgB,QAAQ,CAAC,MAAM,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;SAC3E;QACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { kintoneAPI } from '../types/api';
2
+ export declare const getSpace: (props: kintoneAPI.rest.space.GetSpaceRequest) => Promise<kintoneAPI.rest.space.GetSpaceResponse>;
3
+ export declare const createSpace: (props: kintoneAPI.rest.space.CreateSpaceRequest) => Promise<kintoneAPI.rest.space.CreateSpaceResponse>;
4
+ export declare const deleteSpace: (props: kintoneAPI.rest.space.DeleteSpaceRequest) => Promise<kintoneAPI.rest.space.DeleteSpaceResponse>;
5
+ export declare const updateThread: (props: kintoneAPI.rest.space.UpdateThreadRequest) => Promise<kintoneAPI.rest.space.UpdateThreadResponse>;
@@ -0,0 +1,23 @@
1
+ import { api, checkBrowser } from './common';
2
+ const API_ENDPOINT_ROOT = '/k/v1';
3
+ const API_ENDPOINT_SPACE = `${API_ENDPOINT_ROOT}/space.json`;
4
+ const API_ENDPOINT_THREAD = `${API_ENDPOINT_ROOT}/space/thread.json`;
5
+ const API_ENDPOINT_MEMBERS = `${API_ENDPOINT_ROOT}/space/members.json`;
6
+ const API_ENDPOINT_TEMPLATE = `${API_ENDPOINT_ROOT}/template/space.json`;
7
+ export const getSpace = (props) => {
8
+ checkBrowser();
9
+ return api(API_ENDPOINT_SPACE, 'GET', props);
10
+ };
11
+ export const createSpace = (props) => {
12
+ checkBrowser();
13
+ return api(API_ENDPOINT_TEMPLATE, 'POST', props);
14
+ };
15
+ export const deleteSpace = (props) => {
16
+ checkBrowser();
17
+ return api(API_ENDPOINT_SPACE, 'DELETE', props);
18
+ };
19
+ export const updateThread = (props) => {
20
+ checkBrowser();
21
+ return api(API_ENDPOINT_THREAD, 'PUT', props);
22
+ };
23
+ //# sourceMappingURL=space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space.js","sourceRoot":"","sources":["../../src/rest-api/space.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC,MAAM,kBAAkB,GAAG,GAAG,iBAAiB,aAAa,CAAC;AAC7D,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,oBAAoB,CAAC;AACrE,MAAM,oBAAoB,GAAG,GAAG,iBAAiB,qBAAqB,CAAC;AACvE,MAAM,qBAAqB,GAAG,GAAG,iBAAiB,sBAAsB,CAAC;AAEzE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAA4C,EAAE,EAAE;IACvE,YAAY,EAAE,CAAC;IACf,OAAO,GAAG,CAAyC,kBAAkB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACvF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA+C,EAAE,EAAE;IAC7E,YAAY,EAAE,CAAC;IACf,OAAO,GAAG,CAA4C,qBAAqB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC9F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA+C,EAAE,EAAE;IAC7E,YAAY,EAAE,CAAC;IACf,OAAO,GAAG,CAA4C,kBAAkB,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAgD,EAAE,EAAE;IAC/E,YAAY,EAAE,CAAC;IACf,OAAO,GAAG,CAA6C,mBAAmB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5F,CAAC,CAAC"}
@@ -197,8 +197,13 @@ export declare namespace kintoneAPI {
197
197
  type AppID = string | number;
198
198
  type RecordID = string | number;
199
199
  type Revision = string | number;
200
+ type IDToRequest = string | number;
200
201
  type Frame = Record<string, any>;
201
202
  type Method = 'GET' | 'PUT' | 'POST' | 'DELETE';
203
+ type People = {
204
+ code: string;
205
+ name: string;
206
+ };
202
207
  type TypeOmmited<T extends Record<string, any>> = {
203
208
  [P in keyof T]: Omit<T[P], 'type'>;
204
209
  };
@@ -299,6 +304,166 @@ export declare namespace kintoneAPI {
299
304
  api: string;
300
305
  payloads: RecordPostRequest<T> | RecordsPostRequest<T> | RecordPutRequest<T> | RecordsPutRequest<T> | RecordsDeleteRequest;
301
306
  }[];
302
- type BulkResponse = (kintoneAPI.rest.RecordPutResponse | kintoneAPI.rest.RecordPostResponse | kintoneAPI.rest.RecordsPostResponse | kintoneAPI.rest.RecordsPutResponse | kintoneAPI.rest.RecordsDeleteResponse)[];
307
+ type BulkResponse = (kintoneAPI.rest.RecordsPutResponse | kintoneAPI.rest.RecordPostResponse | kintoneAPI.rest.RecordsPostResponse | kintoneAPI.rest.RecordsPutResponse | kintoneAPI.rest.RecordsDeleteResponse)[];
308
+ namespace space {
309
+ type SpaceIdToRequest = string | number;
310
+ type GetSpaceRequest = {
311
+ id: string | number;
312
+ };
313
+ type GetSpaceResponse = {
314
+ /** スペースID */
315
+ id: string;
316
+ /** スペース名 */
317
+ name: string;
318
+ /**
319
+ * スペースが作成されたときに初期作成されたスレッドのスレッド ID
320
+ *
321
+ * 1 つのスレッドのみ使用するスペースの場合はこのスレッドのみ存在します。
322
+ */
323
+ defaultThread: string;
324
+ /** 公開/非公開の区分 */
325
+ isPrivate: boolean;
326
+ creator: People;
327
+ modifier: People;
328
+ memberCount: string;
329
+ coverType: string;
330
+ /** スペースのカバー画像のキー文字列 */
331
+ coverKey: string;
332
+ /** スペースのカバー画像の URL */
333
+ coverUrl: string;
334
+ body: string;
335
+ useMultiThread: boolean;
336
+ isGuest: boolean;
337
+ attachedApps: {
338
+ threadId: string;
339
+ appId: string;
340
+ code: string;
341
+ name: string;
342
+ description: string;
343
+ createdAt: string;
344
+ creator: People;
345
+ modifiedAt: string;
346
+ modifier: People;
347
+ fixedMember: boolean;
348
+ showAnnouncement: boolean;
349
+ showThreadList: boolean;
350
+ showAppList: boolean;
351
+ showMemberList: boolean;
352
+ showRelatedLinkList: boolean;
353
+ }[];
354
+ };
355
+ type CreateSpaceRequest = {
356
+ id: SpaceIdToRequest;
357
+ name: string;
358
+ members: {
359
+ entity: {
360
+ type: 'USER' | 'GROUP' | 'ORGANIZATION';
361
+ code: string;
362
+ };
363
+ isAdmin: boolean;
364
+ includeSubs?: boolean;
365
+ }[];
366
+ isPrivate?: boolean;
367
+ isGuest?: boolean;
368
+ fixedMember?: boolean;
369
+ };
370
+ type CreateSpaceResponse = {
371
+ id: string;
372
+ };
373
+ type DeleteSpaceRequest = {
374
+ id: SpaceIdToRequest;
375
+ };
376
+ type DeleteSpaceResponse = {};
377
+ type UpdateThreadRequest = {
378
+ /** 更新するスレッドのスレッドID */
379
+ id: IDToRequest;
380
+ /**
381
+ * スレッド名
382
+ *
383
+ * 1文字から128文字まで指定可能。省略した場合は、スレッド名は更新されません。
384
+ *
385
+ * シングルスレッドスペースのスレッドはスレッド名が存在しないため更新できません。
386
+ */
387
+ name?: string;
388
+ /**
389
+ * スレッドの本文
390
+ *
391
+ * 65535文字まで指定可能。省略した場合は、本文は更新されません。
392
+ *
393
+ * 許可されていない属性やタグは自動的に削除されます。
394
+ *
395
+ * アプリ貼り付け、ファイル添付、絵文字は HTML で指定します。
396
+ *
397
+ * 宛先を HTML 内で指定しても、その宛先には通知されません。
398
+ */
399
+ body?: string;
400
+ };
401
+ type UpdateThreadResponse = {};
402
+ type GetSpaceMembersRequest = {
403
+ id: IDToRequest;
404
+ };
405
+ }
406
+ }
407
+ namespace cybozu {
408
+ type CustomItemValue = {
409
+ code: string;
410
+ value: string;
411
+ };
412
+ type CybozuUser = {
413
+ id: number;
414
+ code: string;
415
+ ctime: string;
416
+ mtime: string;
417
+ valid: boolean;
418
+ name: string;
419
+ surName: string;
420
+ givenName: string;
421
+ surNameReading: string;
422
+ givenNameReading: string;
423
+ localName: string;
424
+ localNameLocale: string;
425
+ timezone: string;
426
+ locale: string;
427
+ description: string;
428
+ phone: string;
429
+ mobilePhone: string;
430
+ extensionNumber: string;
431
+ email: string;
432
+ callto: string;
433
+ url: string;
434
+ employeeNumber: string;
435
+ birthDate: string;
436
+ joinDate: string;
437
+ primaryOrganization: number;
438
+ sortOrder: number;
439
+ customItemValues: CustomItemValue[];
440
+ };
441
+ type GetUsersRequest = {
442
+ ids?: string[];
443
+ codes?: string[];
444
+ size?: number;
445
+ offset?: number;
446
+ };
447
+ type GetUsersResponse = {
448
+ users: CybozuUser[];
449
+ };
450
+ type GetUsedServicesRequest = {
451
+ code: string[];
452
+ size?: number;
453
+ offset?: number;
454
+ };
455
+ type GetUsedServicesResponse = {
456
+ users: {
457
+ code: string;
458
+ services: string[];
459
+ };
460
+ };
461
+ type UpdateUsedServicesRequest = {
462
+ users: {
463
+ code: string;
464
+ services: string[];
465
+ };
466
+ };
467
+ type UpdateUsedServicesResponse = {};
303
468
  }
304
469
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/kintone-utilities",
3
- "version": "1.22.2",
3
+ "version": "1.24.0",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/local-bias/kintone-utilities.git",