create-ones-app 0.0.7 → 0.0.9
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/LICENSE +201 -0
- package/dist/index.cjs +7087 -22
- package/dist/index.js +7091 -26
- package/dist/types/actions/create/index.d.ts +3 -0
- package/dist/types/actions/create/index.d.ts.map +1 -0
- package/dist/types/actions/create/normalize.d.ts +6 -0
- package/dist/types/actions/create/normalize.d.ts.map +1 -0
- package/dist/types/actions/index.d.ts +5 -0
- package/dist/types/actions/index.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/command/create/index.d.ts +9 -0
- package/dist/types/command/create/index.d.ts.map +1 -0
- package/dist/types/command/index.d.ts +5 -0
- package/dist/types/command/index.d.ts.map +1 -0
- package/dist/types/common/command/index.d.ts +6 -0
- package/dist/types/common/command/index.d.ts.map +1 -0
- package/dist/types/common/command/types.d.ts +10 -0
- package/dist/types/common/command/types.d.ts.map +1 -0
- package/dist/types/common/command/utils.d.ts +8 -0
- package/dist/types/common/command/utils.d.ts.map +1 -0
- package/dist/types/common/context/index.d.ts +6 -0
- package/dist/types/common/context/index.d.ts.map +1 -0
- package/dist/types/common/context/types.d.ts +6 -0
- package/dist/types/common/context/types.d.ts.map +1 -0
- package/dist/types/common/context/utils.d.ts +4 -0
- package/dist/types/common/context/utils.d.ts.map +1 -0
- package/dist/types/common/error/enums.d.ts +7 -0
- package/dist/types/common/error/enums.d.ts.map +1 -0
- package/dist/types/common/error/index.d.ts +7 -0
- package/dist/types/common/error/index.d.ts.map +1 -0
- package/dist/types/common/error/types.d.ts +2 -0
- package/dist/types/common/error/types.d.ts.map +1 -0
- package/dist/types/common/error/utils.d.ts +2 -0
- package/dist/types/common/error/utils.d.ts.map +1 -0
- package/dist/types/common/locales/en/index.d.ts +10 -0
- package/dist/types/common/locales/en/index.d.ts.map +1 -0
- package/dist/types/common/locales/index.d.ts +6 -0
- package/dist/types/common/locales/index.d.ts.map +1 -0
- package/dist/types/common/locales/types.d.ts +4 -0
- package/dist/types/common/locales/types.d.ts.map +1 -0
- package/dist/types/common/locales/utils.d.ts +6 -0
- package/dist/types/common/locales/utils.d.ts.map +1 -0
- package/dist/types/common/package/consts.d.ts +6 -0
- package/dist/types/common/package/consts.d.ts.map +1 -0
- package/dist/types/common/package/index.d.ts +8 -0
- package/dist/types/common/package/index.d.ts.map +1 -0
- package/dist/types/common/package/schema.d.ts +345 -0
- package/dist/types/common/package/schema.d.ts.map +1 -0
- package/dist/types/common/package/types.d.ts.map +1 -0
- package/dist/types/common/package/utils.d.ts +5 -0
- package/dist/types/common/package/utils.d.ts.map +1 -0
- package/dist/types/common/public/consts.d.ts +5 -0
- package/dist/types/common/public/consts.d.ts.map +1 -0
- package/dist/types/common/public/index.d.ts +6 -0
- package/dist/types/common/public/index.d.ts.map +1 -0
- package/dist/types/common/public/utils.d.ts +2 -0
- package/dist/types/common/public/utils.d.ts.map +1 -0
- package/dist/types/common/template/index.d.ts +5 -0
- package/dist/types/common/template/index.d.ts.map +1 -0
- package/dist/types/common/template/utils.d.ts +4 -0
- package/dist/types/common/template/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +26 -5
- package/public/.onesrc.json +9 -0
- package/public/app_opkx_schema.json +566 -0
- package/public/logos/logo-bulb.svg +20 -0
- package/public/logos/logo-check.svg +18 -0
- package/public/logos/logo-claude.svg +19 -0
- package/public/logos/logo-claw.svg +23 -0
- package/public/logos/logo-gear.svg +18 -0
- package/public/logos/logo-gemini.svg +19 -0
- package/public/logos/logo-haiper.svg +19 -0
- package/public/logos/logo-lightning.svg +19 -0
- package/public/logos/logo-manus.svg +21 -0
- package/public/logos/logo-new-api.svg +21 -0
- package/public/logos/logo-puzzle.svg +19 -0
- package/public/logos/logo-trae.svg +19 -0
- package/public/logos/logo-user.svg +20 -0
- package/public/opkx.json +21 -0
- package/template/example/.template.json +1 -1
- package/template/example/AGENTS.md +92 -103
- package/template/example/LICENSE +201 -0
- package/template/example/README.md +1 -84
- package/template/example/_eslint.config.mjs_ +39 -0
- package/template/example/_gitignore +23 -0
- package/template/example/_husky_pre-commit +1 -0
- package/template/example/_prettierignore +11 -0
- package/template/example/_prettierrc +6 -0
- package/template/example/_tsconfig.json +8 -0
- package/template/example/backend/app.controller.ts +85 -0
- package/template/example/backend/app.module.ts +34 -0
- package/template/example/backend/app.service.ts +46 -0
- package/template/example/backend/dto/issue-created-event.dto.ts +29 -0
- package/template/example/backend/dto/recent-work-item.dto.ts +11 -0
- package/template/example/backend/main.ts +10 -0
- package/template/example/backend/proxy.ts +46 -0
- package/template/example/backend/services/recent-work-items.service.ts +84 -0
- package/template/example/backend/utils.ts +41 -0
- package/template/example/nest-cli.json +8 -0
- package/template/example/opkx.json +106 -0
- package/template/example/package-lock.json +12699 -0
- package/template/example/package.json +84 -0
- package/template/example/postcss.config.js +10 -0
- package/template/example/public/assets/loading.png +0 -0
- package/template/example/public/favicon.ico +0 -0
- package/template/example/public/i18n/en.json +17 -0
- package/template/example/public/i18n/zh.json +17 -0
- package/template/example/public/normalize.css@8.0.1/normalize.css +349 -0
- package/template/example/tsconfig.backend.json +34 -0
- package/template/example/tsconfig.build.json +3 -0
- package/template/example/tsconfig.vite.json +34 -0
- package/template/example/tsconfig.web.json +39 -0
- package/template/example/vite.config.ts +286 -0
- package/template/example/web/pages/recent-work-items/index.css +131 -0
- package/template/example/web/pages/recent-work-items/index.tsx +265 -0
- package/template/example/web/template/index.html +65 -0
- package/dist/types/action.d.ts +0 -2
- package/dist/types/action.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils.d.ts +0 -7
- package/dist/types/utils.d.ts.map +0 -1
- package/template/example/netlify/functions/app_manifest.js +0 -90
- package/template/example/netlify/functions/app_setting_pages.js +0 -48
- package/template/example/netlify/functions/events.js +0 -35
- package/template/example/netlify/functions/install.js +0 -35
- package/template/example/netlify/functions/metadata.js +0 -37
- package/template/example/netlify.toml +0 -44
- package/template/example/public/index.html +0 -20
- package/template/example/public/logo.svg +0 -4
- package/template/example/public/script.js +0 -56
- package/template/example/public/style.css +0 -66
- package/template/example/types/app_manifest.d.ts +0 -115
- package/template/example/types/app_setting_pages.d.ts +0 -14
- /package/dist/types/{types.d.ts → common/package/types.d.ts} +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
# README
|
|
2
|
-
|
|
3
|
-
这是 ONES 应用代码目录
|
|
4
|
-
|
|
5
|
-
下一步,你可以部署 ONES 应用
|
|
6
|
-
|
|
7
|
-
在部署之前你需要:
|
|
8
|
-
|
|
9
|
-
## 1. 检查 netlify cli 是否已安装
|
|
10
|
-
|
|
11
|
-
检查命令:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
netlify -v
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
如果提示缺少命令,你可以用以下命令安装:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm i -g netlify-cli
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
如果提示 `Error: EACCES: permission denied` 错误时
|
|
24
|
-
|
|
25
|
-
你需要申请 `sudo` 权限,用以下命令重试:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
sudo npm i -g netlify-cli
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
如果提示其他错误时
|
|
32
|
-
|
|
33
|
-
请检查网络和代理配置,然后重试
|
|
34
|
-
|
|
35
|
-
## 2. 检查 netlify cli 是否已登录
|
|
36
|
-
|
|
37
|
-
检查命令:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
netlify status
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
如果你未登录
|
|
44
|
-
|
|
45
|
-
可以根据 `netlify --help` 的提示进行注册或者登录
|
|
46
|
-
|
|
47
|
-
## 3. 部署 ONES 应用
|
|
48
|
-
|
|
49
|
-
部署命令:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
netlify deploy --create-site --prod
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
如果部署失败时
|
|
56
|
-
|
|
57
|
-
请检查网络和代理配置,然后重试
|
|
58
|
-
|
|
59
|
-
## 4. 获取应用信息
|
|
60
|
-
|
|
61
|
-
在上一步,`netlify` 会在命令行输出应用的部署地址
|
|
62
|
-
|
|
63
|
-
应用的部署地址会紧跟在 Deployed to production URL 的声明后面
|
|
64
|
-
|
|
65
|
-
- 应用的部署地址: `${url}`
|
|
66
|
-
- 应用的安装地址:`${url}/api/app_manifest`
|
|
67
|
-
|
|
68
|
-
应用的安装地址,其实是根据应用的部署地址拼接的
|
|
69
|
-
|
|
70
|
-
拼接的路径,默认为 `/api/app_manifest`
|
|
71
|
-
|
|
72
|
-
对应 `netlify/functions/app_manifest.js` 这个文件
|
|
73
|
-
|
|
74
|
-
如果移动过这个文件,请替换为实际的文件名
|
|
75
|
-
|
|
76
|
-
当你拿到应用的安装地址时,可以去 ONES 的应用中心进行安装
|
|
77
|
-
|
|
78
|
-
## 5. 迭代和开发
|
|
79
|
-
|
|
80
|
-
当你需要二次开发时,请浏览开发者文档
|
|
81
|
-
|
|
82
|
-
开发者文档地址如下:
|
|
83
|
-
|
|
84
|
-
[https://p8205-k3s-9-submodule-opendocs2.k3s-dev.myones.net/]
|
|
1
|
+
# README
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import eslint from '@eslint/js';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{
|
|
9
|
+
ignores: ['eslint.config.mjs', 'postcss.config.js', 'node_modules/', 'dist/', 'build/', 'coverage/', '*.min.js'],
|
|
10
|
+
},
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
13
|
+
eslintPluginPrettierRecommended,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.node,
|
|
18
|
+
...globals.jest,
|
|
19
|
+
},
|
|
20
|
+
sourceType: 'commonjs',
|
|
21
|
+
parserOptions: {
|
|
22
|
+
projectService: true,
|
|
23
|
+
tsconfigRootDir: import.meta.dirname,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
rules: {
|
|
29
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
30
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
31
|
+
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
32
|
+
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
|
33
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
34
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
35
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
36
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Controller, Get, Post, HttpCode, Body, Query, Headers } from '@nestjs/common'
|
|
2
|
+
import { AppService, type InstallCallbackPayload } from './app.service'
|
|
3
|
+
import type { IssueCreatedEvent } from './dto/issue-created-event.dto'
|
|
4
|
+
import type { RecentLimit } from './dto/recent-work-item.dto'
|
|
5
|
+
import { RecentWorkItemsService } from './services/recent-work-items.service'
|
|
6
|
+
import { createWebPageURL } from './utils'
|
|
7
|
+
|
|
8
|
+
@Controller()
|
|
9
|
+
export class AppController {
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly appService: AppService,
|
|
12
|
+
private readonly recentWorkItemsService: RecentWorkItemsService,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
@Get('/health_check')
|
|
16
|
+
healthCheck() {
|
|
17
|
+
return this.appService.healthCheck()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Post('/install_cb')
|
|
21
|
+
@HttpCode(200)
|
|
22
|
+
installCallback(@Body() body: InstallCallbackPayload) {
|
|
23
|
+
return this.appService.installCallback(body)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Post('/app_setting_entries')
|
|
27
|
+
@HttpCode(200)
|
|
28
|
+
getCustomEntries() {
|
|
29
|
+
return this.buildCustomEntries()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private buildCustomEntries() {
|
|
33
|
+
return {
|
|
34
|
+
entries: [
|
|
35
|
+
{
|
|
36
|
+
title: 'Recent Work Items',
|
|
37
|
+
page_url: createWebPageURL('recent-work-items.html'),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Post('/events/webhook')
|
|
44
|
+
@HttpCode(200)
|
|
45
|
+
async handleEventWebhook(
|
|
46
|
+
@Body() body: unknown,
|
|
47
|
+
@Headers('x-ones-event-type') eventType?: string,
|
|
48
|
+
) {
|
|
49
|
+
if (eventType === 'ones:events:health') {
|
|
50
|
+
return { ok: true, message: 'health check passed' }
|
|
51
|
+
}
|
|
52
|
+
return this.handleEvents(body)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Get('/api/recent-work-items')
|
|
56
|
+
@HttpCode(200)
|
|
57
|
+
async getRecentWorkItems(@Query() query: Record<string, string>) {
|
|
58
|
+
const limit = Number(query.limit) as RecentLimit
|
|
59
|
+
if (![5, 10, 30].includes(limit)) {
|
|
60
|
+
return { ok: false, error: 'limit must be 5, 10, or 30' }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const items = await this.recentWorkItemsService.getRecent({ limit })
|
|
64
|
+
return { ok: true, items }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private async handleEvents(event: unknown) {
|
|
68
|
+
if (!this.isIssueCreatedEvent(event)) {
|
|
69
|
+
return { ok: false, error: 'invalid event payload' }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await this.recentWorkItemsService.handleIssueCreated(event)
|
|
73
|
+
return { ok: true, handled: true }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private isIssueCreatedEvent(event: unknown): event is IssueCreatedEvent {
|
|
77
|
+
const candidate = event as Partial<IssueCreatedEvent> | null | undefined
|
|
78
|
+
return (
|
|
79
|
+
!!candidate &&
|
|
80
|
+
candidate.eventType === 'ones:project:issue:created' &&
|
|
81
|
+
typeof candidate.eventData?.issueID === 'string' &&
|
|
82
|
+
typeof candidate.eventData?.basicInfoChanges?.createTime?.toTime === 'number'
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common'
|
|
2
|
+
import { ServeStaticModule } from '@nestjs/serve-static'
|
|
3
|
+
import { AppController } from './app.controller'
|
|
4
|
+
import { AppService } from './app.service'
|
|
5
|
+
import { RecentWorkItemsService } from './services/recent-work-items.service'
|
|
6
|
+
import { WebProxyMiddleware } from './proxy'
|
|
7
|
+
import { getPublicPath, createPublicURL, getWebPath, createWebURL, isProd } from './utils'
|
|
8
|
+
import type { MiddlewareConsumer } from '@nestjs/common'
|
|
9
|
+
|
|
10
|
+
const imports = [
|
|
11
|
+
ServeStaticModule.forRoot({
|
|
12
|
+
rootPath: getPublicPath(),
|
|
13
|
+
serveRoot: createPublicURL(''),
|
|
14
|
+
}),
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
if (isProd()) {
|
|
18
|
+
imports.push(
|
|
19
|
+
ServeStaticModule.forRoot({
|
|
20
|
+
rootPath: getWebPath(),
|
|
21
|
+
serveRoot: createWebURL(''),
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
@Module({
|
|
26
|
+
imports,
|
|
27
|
+
controllers: [AppController],
|
|
28
|
+
providers: [AppService, RecentWorkItemsService],
|
|
29
|
+
})
|
|
30
|
+
export class AppModule {
|
|
31
|
+
configure(consumer: MiddlewareConsumer) {
|
|
32
|
+
consumer.apply(WebProxyMiddleware).forRoutes('*')
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Injectable, OnApplicationShutdown } from '@nestjs/common'
|
|
2
|
+
import { storage } from '@ones-open/node-sdk'
|
|
3
|
+
|
|
4
|
+
export type InstallCallbackPayload = {
|
|
5
|
+
installation_id: string
|
|
6
|
+
shared_secret: string
|
|
7
|
+
ones_base_url: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type InstallationSecretEntity = {
|
|
11
|
+
installation_id: string
|
|
12
|
+
shared_secret: string
|
|
13
|
+
ones_base_url: string
|
|
14
|
+
updated_at: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const installationSecretEntity = storage.entity<InstallationSecretEntity>('installation_secret')
|
|
18
|
+
|
|
19
|
+
@Injectable()
|
|
20
|
+
export class AppService implements OnApplicationShutdown {
|
|
21
|
+
healthCheck() {
|
|
22
|
+
return { ok: true }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async installCallback(payload: InstallCallbackPayload) {
|
|
26
|
+
const installationId = payload.installation_id.trim()
|
|
27
|
+
const row: InstallationSecretEntity = {
|
|
28
|
+
installation_id: installationId,
|
|
29
|
+
shared_secret: payload.shared_secret.trim(),
|
|
30
|
+
ones_base_url: payload.ones_base_url.trim(),
|
|
31
|
+
updated_at: Date.now(),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await installationSecretEntity.set(installationId, row)
|
|
36
|
+
return { ok: true }
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('install-callback: failed to save shared_secret', error)
|
|
39
|
+
return { ok: false, error: 'failed to save install callback data' }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onApplicationShutdown(signal?: string) {
|
|
44
|
+
console.log('shutdown signal:', signal)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface IssueCreatedEvent {
|
|
2
|
+
eventID: string
|
|
3
|
+
eventType: 'ones:project:issue:created'
|
|
4
|
+
timestamp: number
|
|
5
|
+
subscriberID: string
|
|
6
|
+
eventData: {
|
|
7
|
+
organizationID?: string
|
|
8
|
+
teamID?: string
|
|
9
|
+
triggerUserID?: string
|
|
10
|
+
issueID: string
|
|
11
|
+
statusID: string
|
|
12
|
+
scopeID: string
|
|
13
|
+
basicInfoChanges: {
|
|
14
|
+
creator: { fromID: string; toID: string }
|
|
15
|
+
assignee: { fromID: string; toID: string }
|
|
16
|
+
createTime: { fromTime: number; toTime: number }
|
|
17
|
+
}
|
|
18
|
+
properties?: Record<
|
|
19
|
+
string,
|
|
20
|
+
{
|
|
21
|
+
issueID: string
|
|
22
|
+
fieldID: string
|
|
23
|
+
propertyType: number
|
|
24
|
+
oldValue?: { stringValue?: string }
|
|
25
|
+
newValue?: { stringValue?: string }
|
|
26
|
+
}
|
|
27
|
+
>
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestFactory } from '@nestjs/core'
|
|
2
|
+
import { AppModule } from './app.module'
|
|
3
|
+
import { getHostedPort } from './utils'
|
|
4
|
+
|
|
5
|
+
async function bootstrap() {
|
|
6
|
+
const app = await NestFactory.create(AppModule)
|
|
7
|
+
app.enableShutdownHooks()
|
|
8
|
+
await app.listen(getHostedPort())
|
|
9
|
+
}
|
|
10
|
+
bootstrap().catch(console.error)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Readable } from 'stream'
|
|
2
|
+
import { isProd, getWebDevPort } from './utils'
|
|
3
|
+
import type { NextFunction, Request, Response } from 'express'
|
|
4
|
+
|
|
5
|
+
export function WebProxyMiddleware(req: Request, res: Response, next: NextFunction) {
|
|
6
|
+
if (isProd()) {
|
|
7
|
+
return next()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { originalUrl, method } = req
|
|
11
|
+
if (originalUrl.startsWith('/web/pages') && method === 'GET') {
|
|
12
|
+
const url = originalUrl.replace('/web/pages', `http://localhost:${getWebDevPort()}`)
|
|
13
|
+
const headers: Record<string, string> = {}
|
|
14
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
15
|
+
if (key === 'host' || key === 'connection') {
|
|
16
|
+
continue
|
|
17
|
+
}
|
|
18
|
+
if (value !== undefined) {
|
|
19
|
+
headers[key] = Array.isArray(value) ? value.join(', ') : String(value)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
fetch(url, {
|
|
23
|
+
method: 'GET',
|
|
24
|
+
headers,
|
|
25
|
+
})
|
|
26
|
+
.then((response) => {
|
|
27
|
+
res.status(response.status)
|
|
28
|
+
response.headers.forEach((value, key) => {
|
|
29
|
+
res.setHeader(key, value)
|
|
30
|
+
})
|
|
31
|
+
if (response.body == null) {
|
|
32
|
+
res.end()
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
const nodeReadable = Readable.fromWeb(response.body as any)
|
|
36
|
+
nodeReadable.pipe(res)
|
|
37
|
+
nodeReadable.on('error', (err) => next(err))
|
|
38
|
+
})
|
|
39
|
+
.catch((error) => {
|
|
40
|
+
next(error)
|
|
41
|
+
})
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return next()
|
|
46
|
+
}
|