@konomi-app/kintone-utilities 1.15.0 → 1.16.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.
- package/dist/rest-api.d.ts +10 -0
- package/dist/rest-api.js +23 -11
- package/dist/rest-api.js.map +1 -1
- package/package.json +1 -1
package/dist/rest-api.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare const uploadFile: (props: {
|
|
|
32
32
|
}) => Promise<{
|
|
33
33
|
fileKey: string;
|
|
34
34
|
}>;
|
|
35
|
+
export declare const getApp: (props: {
|
|
36
|
+
id: App;
|
|
37
|
+
}) => Promise<kintoneAPI.App>;
|
|
35
38
|
export declare const getFormFields: (props: {
|
|
36
39
|
app: App;
|
|
37
40
|
preview?: boolean;
|
|
@@ -39,4 +42,11 @@ export declare const getFormFields: (props: {
|
|
|
39
42
|
properties: kintoneAPI.FieldProperties;
|
|
40
43
|
revision: string;
|
|
41
44
|
}>;
|
|
45
|
+
export declare const getFormLayout: (props: {
|
|
46
|
+
app: App;
|
|
47
|
+
preview?: boolean;
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
properties: kintoneAPI.Layout;
|
|
50
|
+
revision: string;
|
|
51
|
+
}>;
|
|
42
52
|
export {};
|
package/dist/rest-api.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
const API_ENDPOINT_ROOT = '/k/v1';
|
|
2
|
-
const
|
|
2
|
+
const API_ENDPOINT_RECORD = `${API_ENDPOINT_ROOT}/record`;
|
|
3
|
+
const API_ENDPOINT_RECORDS = `${API_ENDPOINT_ROOT}/records`;
|
|
4
|
+
const API_ENDPOINT_CURSOR = `${API_ENDPOINT_RECORDS}/cursor`;
|
|
3
5
|
const API_LIMIT = {
|
|
4
6
|
GET: 500,
|
|
5
7
|
};
|
|
8
|
+
const api = (path, method, body) => {
|
|
9
|
+
return kintone.api(kintone.api.url(path, true), method, body);
|
|
10
|
+
};
|
|
6
11
|
export const getAllRecords = async (props) => {
|
|
7
12
|
if (props.query && props.query.includes('order by')) {
|
|
8
13
|
return getAllRecordsWithCursor(props);
|
|
@@ -21,7 +26,7 @@ const getRecursive = async (props) => {
|
|
|
21
26
|
const { app, fields, condition, id } = props;
|
|
22
27
|
const newCondition = id ? `${condition ? `${condition} and ` : ''} $id < ${id}` : condition;
|
|
23
28
|
const query = `${newCondition} order by $id desc limit ${API_LIMIT.GET}`;
|
|
24
|
-
const { records } = await
|
|
29
|
+
const { records } = await api(API_ENDPOINT_RECORDS, 'GET', {
|
|
25
30
|
app,
|
|
26
31
|
fields,
|
|
27
32
|
query,
|
|
@@ -41,7 +46,7 @@ export const getAllRecordsWithCursor = async (props) => {
|
|
|
41
46
|
checkBrowser();
|
|
42
47
|
const { app, fields = [], query = '', onTotalGet = null, onStep = null } = props;
|
|
43
48
|
const param = { app, fields, size: API_LIMIT.GET, query };
|
|
44
|
-
const cursor = await
|
|
49
|
+
const cursor = await api(API_ENDPOINT_CURSOR, 'POST', param);
|
|
45
50
|
if (onTotalGet) {
|
|
46
51
|
onTotalGet(cursor.totalCount);
|
|
47
52
|
}
|
|
@@ -49,9 +54,7 @@ export const getAllRecordsWithCursor = async (props) => {
|
|
|
49
54
|
};
|
|
50
55
|
const getRecordsByCursorId = async (props) => {
|
|
51
56
|
const { id, onStep, loadedData = [] } = props;
|
|
52
|
-
const response = await
|
|
53
|
-
id,
|
|
54
|
-
});
|
|
57
|
+
const response = await api(API_ENDPOINT_CURSOR, 'GET', { id });
|
|
55
58
|
const newRecords = [...loadedData, ...response.records];
|
|
56
59
|
if (onStep) {
|
|
57
60
|
onStep(newRecords);
|
|
@@ -72,14 +75,23 @@ export const uploadFile = async (props) => {
|
|
|
72
75
|
});
|
|
73
76
|
return response.json();
|
|
74
77
|
};
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
78
|
+
export const getApp = async (props) => {
|
|
79
|
+
checkBrowser();
|
|
80
|
+
return api(`${API_ENDPOINT_ROOT}/app`, 'GET', props);
|
|
79
81
|
};
|
|
80
82
|
export const getFormFields = async (props) => {
|
|
81
83
|
checkBrowser();
|
|
82
84
|
const { app, preview = false } = props;
|
|
83
|
-
return
|
|
85
|
+
return api(`${API_ENDPOINT_ROOT}/${preview ? 'preview/' : ''}app/form/fields`, 'GET', { app });
|
|
86
|
+
};
|
|
87
|
+
export const getFormLayout = async (props) => {
|
|
88
|
+
checkBrowser();
|
|
89
|
+
const { app, preview = false } = props;
|
|
90
|
+
return api(`${API_ENDPOINT_ROOT}/${preview ? 'preview/' : ''}app/form/layout`, 'GET', { app });
|
|
91
|
+
};
|
|
92
|
+
const checkBrowser = () => {
|
|
93
|
+
if (typeof window === 'undefined') {
|
|
94
|
+
throw new Error('この関数はブラウザでのみ使用できます');
|
|
95
|
+
}
|
|
84
96
|
};
|
|
85
97
|
//# sourceMappingURL=rest-api.js.map
|
package/dist/rest-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.js","sourceRoot":"","sources":["../src/rest-api.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"rest-api.js","sourceRoot":"","sources":["../src/rest-api.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,mBAAmB,GAAG,GAAG,iBAAiB,SAAS,CAAC;AAC1D,MAAM,oBAAoB,GAAG,GAAG,iBAAiB,UAAU,CAAC;AAC5D,MAAM,mBAAmB,GAAG,GAAG,oBAAoB,SAAS,CAAC;AAC7D,MAAM,SAAS,GAAG;IAChB,GAAG,EAAE,GAAG;CACT,CAAC;AAEF,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,MAAyC,EAAE,IAAS,EAAE,EAAE;IACjF,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CA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