@konomi-app/kintone-utilities 1.10.1 → 1.11.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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export type { kintoneAPI } from './api-types';
2
2
  export * from './character-width-conversion';
3
3
  export * from './event-listener';
4
4
  export * from './plugin';
5
+ export * from './rest-api';
6
+ export * from './types/kintone.config';
5
7
  export * from './utilities';
6
8
  export * from './utility-types';
7
- export * from './types/kintone.config';
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from './character-width-conversion';
2
2
  export * from './event-listener';
3
3
  export * from './plugin';
4
+ export * from './rest-api';
5
+ export * from './types/kintone.config';
4
6
  export * from './utilities';
5
7
  export * from './utility-types';
6
- export * from './types/kintone.config';
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const getAllRecordsWithId: <T extends {
2
+ $id: unknown;
3
+ } & Record<string, any>>(props: {
4
+ app: number | string;
5
+ fields?: string[] | undefined;
6
+ onStep?: ((current: T[]) => void) | undefined;
7
+ condition?: string | undefined;
8
+ }) => Promise<T[]>;
@@ -0,0 +1,26 @@
1
+ const CHUNK_SIZE = 500;
2
+ export const getAllRecordsWithId = async (props) => {
3
+ const { fields: initFields, condition: initCondition = '' } = props;
4
+ const fields = initFields?.length ? [...new Set([...initFields, '$id'])] : undefined;
5
+ // order byは使用できないため、conditionに含まれている場合は除外する
6
+ const condition = initCondition.replace(/order by.*/g, '');
7
+ return getRecursive({ ...props, fields, condition });
8
+ };
9
+ const getRecursive = async (props) => {
10
+ const { app, fields, condition, id } = props;
11
+ const newCondition = id ? `${condition ? `${condition} and ` : ''} $id < ${id}` : condition;
12
+ const query = `${newCondition} order by $id desc limit ${CHUNK_SIZE}`;
13
+ const { records } = await kintone.api(kintone.api.url('/k/v1/records', true), 'GET', {
14
+ app,
15
+ fields,
16
+ query,
17
+ });
18
+ const stored = [...(props.stored ?? []), ...records];
19
+ if (props.onStep) {
20
+ props.onStep(stored);
21
+ }
22
+ const lastRecord = stored[stored.length - 1];
23
+ const lastId = lastRecord.$id.value;
24
+ return records.length === CHUNK_SIZE ? getRecursive({ ...props, id: lastId, stored }) : stored;
25
+ };
26
+ //# sourceMappingURL=rest-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-api.js","sourceRoot":"","sources":["../src/rest-api.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAoD,KAK3F,EAAgB,EAAE;IACjB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IAEpE,MAAM,MAAM,GAAG,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAErF,4CAA4C;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,EAA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@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/kintone-utilities",
3
- "version": "1.10.1",
3
+ "version": "1.11.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",
@@ -13,10 +13,10 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@emotion/css": "^11.10.6",
16
- "@kintone/rest-api-client": "^3.3.5"
16
+ "@kintone/rest-api-client": "^3.3.6"
17
17
  },
18
18
  "devDependencies": {
19
- "@kintone/dts-gen": "^6.1.22",
19
+ "@kintone/dts-gen": "^6.1.23",
20
20
  "typescript": "^5.0.2"
21
21
  },
22
22
  "prettier": {