create-ones-app 0.0.7 → 0.0.8
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,84 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common'
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { storage } from '@ones-open/node-sdk'
|
|
4
|
+
import { IssueCreatedEvent } from '../dto/issue-created-event.dto'
|
|
5
|
+
import { GetRecentWorkItemsQuery, RecentWorkItem } from '../dto/recent-work-item.dto'
|
|
6
|
+
|
|
7
|
+
type RecentWorkItemEntity = {
|
|
8
|
+
work_item_id: string
|
|
9
|
+
title: string
|
|
10
|
+
created_at: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type RecentWorkItemIndexes = {
|
|
14
|
+
recent_by_created_at: null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ENTITY_KEY_PATTERN = /^[_a-z0-9]{1,64}$/
|
|
18
|
+
const ENTITY_KEY_MAX_LENGTH = 64
|
|
19
|
+
const ENTITY_KEY_PREFIX = 'issue_'
|
|
20
|
+
const ENTITY_KEY_HASH_LENGTH = ENTITY_KEY_MAX_LENGTH - ENTITY_KEY_PREFIX.length
|
|
21
|
+
|
|
22
|
+
const recentWorkItemEntity = storage.entity<RecentWorkItemEntity, RecentWorkItemIndexes>(
|
|
23
|
+
'recent_work_item',
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@Injectable()
|
|
27
|
+
export class RecentWorkItemsService {
|
|
28
|
+
async handleIssueCreated(event: IssueCreatedEvent): Promise<void> {
|
|
29
|
+
const issueId = event.eventData.issueID
|
|
30
|
+
const key = this.toEntityKey(issueId)
|
|
31
|
+
const createdAt = event.eventData.basicInfoChanges.createTime.toTime
|
|
32
|
+
const title = this.extractTitle(event) || `Issue ${issueId}`
|
|
33
|
+
console.log(`recent-work-items: issue created
|
|
34
|
+
id: ${issueId}, title: ${title}, entity key: ${key}`)
|
|
35
|
+
const item: RecentWorkItemEntity = {
|
|
36
|
+
work_item_id: issueId,
|
|
37
|
+
title,
|
|
38
|
+
created_at: createdAt,
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
await recentWorkItemEntity.set(key, item)
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('recent-work-items: error setting entity', error)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getRecent(query: GetRecentWorkItemsQuery): Promise<RecentWorkItem[]> {
|
|
48
|
+
const baseQuery = recentWorkItemEntity.query().sort(storage.entity.Sort.DESC).limit(query.limit)
|
|
49
|
+
const result = await baseQuery.index('recent_by_created_at').getMany()
|
|
50
|
+
return result.data.map((row) => this.toRecentWorkItem(row.value))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private extractTitle(event: IssueCreatedEvent): string | undefined {
|
|
54
|
+
const properties = event.eventData.properties
|
|
55
|
+
if (!properties) return undefined
|
|
56
|
+
|
|
57
|
+
for (const key of Object.keys(properties)) {
|
|
58
|
+
const prop = properties[key]
|
|
59
|
+
if (prop.propertyType === 1 && prop.newValue?.stringValue) {
|
|
60
|
+
return prop.newValue.stringValue
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private toEntityKey(issueId: string): string {
|
|
68
|
+
const normalized = issueId.toLowerCase()
|
|
69
|
+
if (ENTITY_KEY_PATTERN.test(normalized)) {
|
|
70
|
+
return normalized
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const hash = createHash('sha256').update(issueId).digest('hex').slice(0, ENTITY_KEY_HASH_LENGTH)
|
|
74
|
+
return `${ENTITY_KEY_PREFIX}${hash}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private toRecentWorkItem(row: RecentWorkItemEntity): RecentWorkItem {
|
|
78
|
+
return {
|
|
79
|
+
workItemId: row.work_item_id,
|
|
80
|
+
title: row.title,
|
|
81
|
+
createdAt: row.created_at,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
|
|
3
|
+
export const isDev = () => {
|
|
4
|
+
return process.env.NODE_ENV === 'development'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const isProd = () => {
|
|
8
|
+
return !isDev()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getHostedPort = () => {
|
|
12
|
+
return Number(process.env.ONES_HOSTED_PORT) || 8201
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getWebDevPort = () => {
|
|
16
|
+
return Number(process.env.ONES_DEV_WEB_SERVER_PORT) || 8202
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const getRootPath = () => {
|
|
20
|
+
return __dirname
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const getPublicPath = () => {
|
|
24
|
+
return join(getRootPath(), '..', 'public')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const createPublicURL = (path: string) => {
|
|
28
|
+
return `/public/${path}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getWebPath = () => {
|
|
32
|
+
return join(getRootPath(), '..', 'web')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createWebURL = (path: string) => {
|
|
36
|
+
return `/web/${path}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const createWebPageURL = (path: string) => {
|
|
40
|
+
return `/web/pages/${path}`
|
|
41
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"id": "",
|
|
4
|
+
"name": "",
|
|
5
|
+
"version": "v0.0.1",
|
|
6
|
+
"desc": "",
|
|
7
|
+
"logo": "/public/logo.svg",
|
|
8
|
+
"auth": {
|
|
9
|
+
"type": "jwt"
|
|
10
|
+
},
|
|
11
|
+
"lifecycle_callback": {
|
|
12
|
+
"install": "/install_cb"
|
|
13
|
+
},
|
|
14
|
+
"events": {
|
|
15
|
+
"url": "/events/webhook",
|
|
16
|
+
"types": [
|
|
17
|
+
{
|
|
18
|
+
"eventType": "ones:project:issue:created"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"oauth": {
|
|
23
|
+
"scope": [
|
|
24
|
+
"read:account:teams"
|
|
25
|
+
],
|
|
26
|
+
"type": [
|
|
27
|
+
"user"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"extensions": {
|
|
31
|
+
"appSettingPages": [
|
|
32
|
+
{
|
|
33
|
+
"key": "entries",
|
|
34
|
+
"funcs": {
|
|
35
|
+
"customEntries": "/app_setting_entries"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"ones": {
|
|
42
|
+
"storage": {
|
|
43
|
+
"entities": [
|
|
44
|
+
{
|
|
45
|
+
"name": "recent_work_item",
|
|
46
|
+
"attributes": {
|
|
47
|
+
"work_item_id": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"length": 64,
|
|
50
|
+
"required": true
|
|
51
|
+
},
|
|
52
|
+
"title": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"length": 256,
|
|
55
|
+
"required": true
|
|
56
|
+
},
|
|
57
|
+
"created_at": {
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"required": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"indexes": [
|
|
63
|
+
{
|
|
64
|
+
"name": "recent_by_created_at",
|
|
65
|
+
"range_attribute": "created_at"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "installation_secret",
|
|
71
|
+
"attributes": {
|
|
72
|
+
"installation_id": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"length": 128,
|
|
75
|
+
"required": true
|
|
76
|
+
},
|
|
77
|
+
"shared_secret": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"length": 512,
|
|
80
|
+
"required": true
|
|
81
|
+
},
|
|
82
|
+
"ones_base_url": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"length": 256,
|
|
85
|
+
"required": true
|
|
86
|
+
},
|
|
87
|
+
"updated_at": {
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"required": true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"runtime": {
|
|
97
|
+
"type": "ones-node-22",
|
|
98
|
+
"healthcheck": {
|
|
99
|
+
"path": "/health_check"
|
|
100
|
+
},
|
|
101
|
+
"command": [
|
|
102
|
+
"node",
|
|
103
|
+
"dist/backend/index.js"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|