@konomi-app/kintone-utilities 2.15.1 → 3.0.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.
@@ -1,4 +1,5 @@
1
1
  import type { kintoneAPI } from './types/api';
2
+ import { KintoneEventMap } from './types/api/js';
2
3
  type ErrorHandler = (error: any, props: {
3
4
  event: kintoneAPI.Event;
4
5
  }) => void;
@@ -26,7 +27,7 @@ export declare class KintoneEventListener {
26
27
  * @param events
27
28
  * @param callback
28
29
  */
29
- add: <T = import("./types/api/record").Record>(events: kintoneAPI.js.EventType[], callback: (event: kintoneAPI.js.Event<T>, options: CallbackOption) => kintoneAPI.js.Event<T> | Promise<kintoneAPI.js.Event<T>>) => void;
30
+ add: <K extends keyof KintoneEventMap<T>, T extends import("./types/api/record").Record = import("./types/api/record").Record>(events: K[], callback: (event: KintoneEventMap<T>[K], options: CallbackOption) => KintoneEventMap<T>[K] | Promise<KintoneEventMap<T>[K]>) => void;
30
31
  /**
31
32
  * Changeイベントを登録します
32
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"event-listener.js","sourceRoot":"","sources":["../src/event-listener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAanE,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAW,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnD,SAAS,CAAU;IACnB,mBAAmB,CAAe;IAClC,aAAa,CAAgB;IACtC,YAAY,CAAU;IACtB,UAAU,CAAS;IAEnB;;OAEG;IACH,YAAmB,KAAwB;QACzC,MAAM,EACJ,YAAY,GAAG,GAAG,EAAE,CAAC,IAAI,EACzB,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,EAAE,GACf,GAAG,KAAK,IAAI,EAAE,CAAC;QAEhB,MAAM,YAAY,GA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B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAChC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,2CAA2C;IACnC,YAAY,CAAC,KAAwB;QAC3C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -1,4 +1,75 @@
1
- type AppRecordIndexShow<T> = {
1
+ import { kintoneAPI } from '.';
2
+ interface CommonEvent<T = kintoneAPI.RecordData> {
3
+ appId: number;
4
+ recordId: number;
5
+ record: T;
6
+ error: string;
7
+ url: string;
8
+ type: keyof KintoneEventMap<T>;
9
+ changes?: {
10
+ field: {
11
+ type: string;
12
+ value: string;
13
+ };
14
+ row: any;
15
+ };
16
+ records?: T[];
17
+ /**
18
+ * 現在表示している一覧のID
19
+ * app.record.index.show イベントでのみ取得できます
20
+ */
21
+ viewId: number;
22
+ /**
23
+ * 現在表示している一覧の種類
24
+ * app.record.index.show イベントでのみ取得できます
25
+ */
26
+ viewType?: 'list' | 'calendar' | 'custom';
27
+ /**
28
+ * 現在表示している一覧の名前
29
+ * app.record.index.show イベントでのみ取得できます
30
+ */
31
+ viewName?: string;
32
+ /**
33
+ * 一覧のレコードのオフセット
34
+ * app.record.index.show イベントでのみ取得でき、viewTypeがCalendar以外の場合に取得できます
35
+ */
36
+ offset?: number | null;
37
+ /**
38
+ * 一覧のレコードの表示件数
39
+ * app.record.index.show イベントでのみ取得でき、viewTypeがCalendar以外の場合に取得できます
40
+ */
41
+ size?: number | null;
42
+ /**
43
+ * プロセス - 実行されたアクション
44
+ * app.record.detail.process.proceed イベントで取得できます
45
+ */
46
+ action?: {
47
+ value: string;
48
+ };
49
+ /**
50
+ * プロセス - 現在のステータス
51
+ * app.record.detail.process.proceed イベントで取得できます
52
+ */
53
+ status?: {
54
+ value: string;
55
+ };
56
+ /**
57
+ * プロセス - 次のステータス
58
+ * app.record.detail.process.proceed イベントで取得できます
59
+ */
60
+ nextStatus?: {
61
+ value: string;
62
+ };
63
+ }
64
+ type CommonRecordEvent<T> = {
65
+ appId: number;
66
+ recordId: number;
67
+ record: T;
68
+ };
69
+ type PortalEvent = {
70
+ type: 'portal.show' | 'mobile.portal.show';
71
+ };
72
+ type AppRecordIndexShowEvent<T> = {
2
73
  type: 'app.record.index.show' | 'mobile.app.record.index.show';
3
74
  appId: string;
4
75
  viewId: number;
@@ -9,29 +80,76 @@ type AppRecordIndexShow<T> = {
9
80
  offset: number | null;
10
81
  size: number | null;
11
82
  };
12
- type AppRecordIndexEditShow<T> = {
83
+ type AppRecordIndexEditShowEvent<T> = CommonRecordEvent<T> & {
13
84
  type: 'app.record.index.edit.show';
14
- appId: string;
15
- recordId: string;
16
- record: T;
17
85
  };
18
- type AppRecordIndexEditSubmit<T> = {
86
+ type AppRecordIndexEditSubmitEvent<T> = CommonRecordEvent<T> & {
19
87
  type: 'app.record.index.edit.submit';
20
- appId: string;
21
- recordId: string;
22
- record: T;
23
88
  };
24
- type AppRecordIndexEditSubmitSuccess<T> = {
89
+ type AppRecordIndexEditSubmitSuccessEvent<T> = CommonRecordEvent<T> & {
25
90
  type: 'app.record.index.edit.submit.success';
26
- appId: string;
27
- recordId: string;
28
- record: T;
29
91
  };
30
- type AppRecordIndexDeleteSubmit<T> = {
92
+ type AppRecordIndexDeleteSubmitEvent<T> = CommonRecordEvent<T> & {
31
93
  type: 'app.record.index.delete.submit';
32
- appId: string;
33
- recordId: string;
94
+ };
95
+ type AppRecordDetailShowEvent<T> = CommonRecordEvent<T> & {
96
+ type: 'app.record.detail.show' | 'mobile.app.record.detail.show';
97
+ };
98
+ type AppRecordDetailDeleteSubmitEvent<T> = CommonRecordEvent<T> & {
99
+ type: 'app.record.detail.delete.submit' | 'mobile.app.record.detail.delete.submit';
100
+ };
101
+ type AppRecordDetailProcessProceedEvent<T> = {
102
+ type: 'app.record.detail.process.proceed' | 'mobile.app.record.detail.process.proceed';
34
103
  record: T;
104
+ action: {
105
+ value: string;
106
+ };
107
+ nextStatus: {
108
+ value: string;
109
+ };
110
+ status: {
111
+ value: string;
112
+ };
113
+ };
114
+ type AppRecordCreateShowEvent<T> = Omit<CommonRecordEvent<T>, 'recordId'> & {
115
+ type: 'app.record.create.show' | 'mobile.app.record.create.show';
116
+ reuse: boolean;
117
+ };
118
+ type AppRecordCreateSubmitEvent<T> = Omit<CommonRecordEvent<T>, 'recordId'> & {
119
+ type: 'app.record.create.submit' | 'mobile.app.record.create.submit';
120
+ };
121
+ type AppRecordCreateSubmitSuccessEvent<T> = CommonEvent<T> & {
122
+ type: 'app.record.create.submit.success' | 'mobile.app.record.create.submit.success';
35
123
  };
36
- export type Event<T> = AppRecordIndexShow<T> | AppRecordIndexEditShow<T> | AppRecordIndexEditSubmit<T> | AppRecordIndexEditSubmitSuccess<T> | AppRecordIndexDeleteSubmit<T>;
124
+ export interface KintoneEventMap<T> {
125
+ 'portal.show': PortalEvent;
126
+ 'app.record.index.show': AppRecordIndexShowEvent<T>;
127
+ 'app.record.index.edit.show': AppRecordIndexEditShowEvent<T>;
128
+ 'app.record.index.edit.submit': AppRecordIndexEditSubmitEvent<T>;
129
+ 'app.record.index.edit.submit.success': AppRecordIndexEditSubmitSuccessEvent<T>;
130
+ 'app.record.index.delete.submit': AppRecordIndexDeleteSubmitEvent<T>;
131
+ 'app.record.detail.show': AppRecordDetailShowEvent<T>;
132
+ 'app.record.detail.delete.submit': AppRecordDetailDeleteSubmitEvent<T>;
133
+ 'app.record.detail.process.proceed': AppRecordDetailProcessProceedEvent<T>;
134
+ 'app.record.create.show': AppRecordCreateShowEvent<T>;
135
+ 'app.record.create.submit': AppRecordCreateSubmitEvent<T>;
136
+ 'app.record.create.submit.success': AppRecordCreateSubmitSuccessEvent<T>;
137
+ 'app.record.edit.show': CommonEvent<T>;
138
+ 'app.record.edit.change': CommonEvent<T>;
139
+ 'app.record.edit.submit': CommonEvent<T>;
140
+ 'app.record.edit.submit.success': CommonEvent<T>;
141
+ 'app.record.print.show': CommonEvent<T>;
142
+ 'mobile.app.record.index.show': CommonEvent<T>;
143
+ 'mobile.app.record.detail.show': CommonEvent<T>;
144
+ 'mobile.app.record.detail.delete.submit': CommonEvent<T>;
145
+ 'mobile.app.record.detail.process.proceed': CommonEvent<T>;
146
+ 'mobile.app.record.create.show': CommonEvent<T>;
147
+ 'mobile.app.record.create.change': CommonEvent<T>;
148
+ 'mobile.app.record.create.submit': CommonEvent<T>;
149
+ 'mobile.app.record.create.submit.success': CommonEvent<T>;
150
+ 'mobile.app.record.edit.show': CommonEvent<T>;
151
+ 'mobile.app.record.edit.change': CommonEvent<T>;
152
+ 'mobile.app.record.edit.submit': CommonEvent<T>;
153
+ 'mobile.app.record.edit.submit.success': CommonEvent<T>;
154
+ }
37
155
  export {};
@@ -1,6 +1,9 @@
1
1
  type Locales = {
2
+ /** 日本語 */
2
3
  ja: string;
4
+ /** 英語 */
3
5
  en: string;
6
+ /** 簡体字中国語 */
4
7
  zh: string;
5
8
  };
6
9
  type Resources = {
@@ -21,7 +24,17 @@ export type PluginManifest = {
21
24
  type: 'APP';
22
25
  manifest_version: 1;
23
26
  version: number | string;
27
+ /**
28
+ * プラグインの名前
29
+ *
30
+ * インストール時、プラグイン一覧画面で表示されます
31
+ */
24
32
  name: Locales;
33
+ /**
34
+ * プラグインの説明
35
+ *
36
+ * インストール時、プラグイン一覧画面で表示されます
37
+ */
25
38
  description?: Locales;
26
39
  icon: string;
27
40
  homepage_url?: Partial<Locales>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/kintone-utilities",
3
- "version": "2.15.1",
3
+ "version": "3.0.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",
@@ -8,8 +8,8 @@
8
8
  "license": "MIT",
9
9
  "scripts": {
10
10
  "build": "rmdir dist /s /q && tsc",
11
- "prepare": "yarn run build",
12
- "play": "cd playground && yarn run dev"
11
+ "prepare": "npm run build",
12
+ "play": "cd playground && npm run dev"
13
13
  },
14
14
  "dependencies": {
15
15
  "@emotion/css": "^11.11.2",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@kintone/dts-gen": "^7.0.4",
20
- "typescript": "^5.1.6"
20
+ "typescript": "^5.2.2"
21
21
  },
22
22
  "prettier": {
23
23
  "printWidth": 100,