@kernhq/module-tracker 0.1.0 → 0.1.2
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/package.json +9 -5
- package/src/client/format.ts +1 -1
- package/src/client/group.ts +1 -1
- package/src/client/kql.ts +13 -5
- package/src/client/types.ts +1 -1
- package/src/contract/events.ts +94 -0
- package/src/contract/index.ts +5 -0
- package/src/contract/models.ts +1422 -0
- package/src/contract/notifications.ts +47 -0
- package/src/contract/permissions.ts +197 -0
- package/src/contract/router.ts +857 -0
- package/src/kql/ast.ts +136 -0
- package/src/kql/dates.ts +62 -0
- package/src/kql/fields.ts +150 -0
- package/src/kql/index.ts +15 -0
- package/src/kql/kql.test.ts +371 -0
- package/src/kql/lexer.ts +172 -0
- package/src/kql/parser.ts +300 -0
- package/src/kql/suggest.ts +102 -0
- package/src/kql/validate.ts +89 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kernhq/module-tracker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Kern tracker module: projects, work item types, custom fields, workflows, issues, KQL, cycles, views, reports, intake, time tracking (server + client skeleton)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -16,20 +16,24 @@
|
|
|
16
16
|
"dist",
|
|
17
17
|
"migrations",
|
|
18
18
|
"src/client",
|
|
19
|
-
"
|
|
19
|
+
"src/contract",
|
|
20
|
+
"src/kql"
|
|
20
21
|
],
|
|
21
22
|
"exports": {
|
|
22
23
|
"./contract": {
|
|
23
24
|
"types": "./dist/contract/index.d.ts",
|
|
24
|
-
"import": "./dist/contract/index.js"
|
|
25
|
+
"import": "./dist/contract/index.js",
|
|
26
|
+
"default": "./dist/contract/index.js"
|
|
25
27
|
},
|
|
26
28
|
"./kql": {
|
|
27
29
|
"types": "./dist/kql/index.d.ts",
|
|
28
|
-
"import": "./dist/kql/index.js"
|
|
30
|
+
"import": "./dist/kql/index.js",
|
|
31
|
+
"default": "./dist/kql/index.js"
|
|
29
32
|
},
|
|
30
33
|
"./server": {
|
|
31
34
|
"types": "./dist/server/index.d.ts",
|
|
32
|
-
"import": "./dist/server/index.js"
|
|
35
|
+
"import": "./dist/server/index.js",
|
|
36
|
+
"default": "./dist/server/index.js"
|
|
33
37
|
},
|
|
34
38
|
"./client": {
|
|
35
39
|
"types": "./src/client/index.ts",
|
package/src/client/format.ts
CHANGED
package/src/client/group.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StatusCategory } from '@kernhq/workflow'
|
|
2
|
-
import type { GroupBy, Issue, Priority } from '../contract/
|
|
2
|
+
import type { GroupBy, Issue, Priority } from '../contract/index.js'
|
|
3
3
|
import { PRIORITY_GROUP_ORDER, STATUS_CATEGORY_ORDER } from './format.js'
|
|
4
4
|
import { byRank } from './rank.js'
|
|
5
5
|
|
package/src/client/kql.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { KqlError, KqlSuggestion } from '../contract/
|
|
2
|
-
import type { KqlExpr, KqlOp, KqlOrder, KqlQuery, KqlValue, Span } from '../kql/
|
|
3
|
-
import { printQuery } from '../kql/ast.js'
|
|
1
|
+
import type { KqlError, KqlSuggestion } from '../contract/index.js'
|
|
2
|
+
import type { KqlExpr, KqlOp, KqlOrder, KqlQuery, KqlValue, Span } from '../kql/index.js'
|
|
4
3
|
import {
|
|
5
4
|
customKqlField,
|
|
6
5
|
findField,
|
|
7
6
|
KQL_FUNCTIONS,
|
|
8
7
|
type KqlField,
|
|
9
8
|
operatorsFor,
|
|
9
|
+
printQuery,
|
|
10
10
|
SYSTEM_FIELDS,
|
|
11
|
-
} from '../kql/
|
|
11
|
+
} from '../kql/index.js'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A KQL reader for the query box.
|
|
@@ -487,6 +487,14 @@ function suggest(tokens: Token[], fields: readonly KqlField[], cursor: number):
|
|
|
487
487
|
.map((k) => ({ kind: 'keyword' as const, label: k, insertText: `${k} ` }))
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
-
export type {
|
|
490
|
+
export type {
|
|
491
|
+
KqlComparison,
|
|
492
|
+
KqlExpr,
|
|
493
|
+
KqlOp,
|
|
494
|
+
KqlOrder,
|
|
495
|
+
KqlQuery,
|
|
496
|
+
KqlValue,
|
|
497
|
+
Span,
|
|
498
|
+
} from '../kql/index.js'
|
|
491
499
|
export type { KqlField }
|
|
492
500
|
export { customKqlField, operatorsFor, SYSTEM_FIELDS }
|
package/src/client/types.ts
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { defineEvent, Id, UserId, WorkspaceId } from '@kernhq/contracts'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { IssueKey, Priority, StatusCategory } from './models.js'
|
|
4
|
+
|
|
5
|
+
const issueRef = z.object({
|
|
6
|
+
workspaceId: WorkspaceId,
|
|
7
|
+
projectId: Id,
|
|
8
|
+
issueId: Id,
|
|
9
|
+
key: IssueKey,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
/** Events published by the tracker module (also available as automation triggers). */
|
|
13
|
+
export const trackerEvents = {
|
|
14
|
+
issueCreated: defineEvent(
|
|
15
|
+
'tracker.issue.created',
|
|
16
|
+
issueRef.extend({
|
|
17
|
+
typeId: Id,
|
|
18
|
+
title: z.string(),
|
|
19
|
+
statusId: z.string(),
|
|
20
|
+
priority: Priority,
|
|
21
|
+
assigneeIds: z.array(UserId),
|
|
22
|
+
triage: z.boolean(),
|
|
23
|
+
source: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
issueUpdated: defineEvent(
|
|
27
|
+
'tracker.issue.updated',
|
|
28
|
+
issueRef.extend({
|
|
29
|
+
changes: z.array(z.object({ field: z.string(), from: z.unknown(), to: z.unknown() })),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
issueStatusChanged: defineEvent(
|
|
33
|
+
'tracker.issue.status_changed',
|
|
34
|
+
issueRef.extend({
|
|
35
|
+
fromStatusId: z.string().nullable(),
|
|
36
|
+
toStatusId: z.string(),
|
|
37
|
+
fromCategory: StatusCategory.nullable(),
|
|
38
|
+
toCategory: StatusCategory,
|
|
39
|
+
transitionId: z.string().nullable(),
|
|
40
|
+
resolution: z.string().nullable(),
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
issueAssigned: defineEvent(
|
|
44
|
+
'tracker.issue.assigned',
|
|
45
|
+
issueRef.extend({ assigneeIds: z.array(UserId), added: z.array(UserId), removed: z.array(UserId) }),
|
|
46
|
+
),
|
|
47
|
+
issueCommented: defineEvent(
|
|
48
|
+
'tracker.issue.commented',
|
|
49
|
+
issueRef.extend({ commentId: Id, parentId: Id.nullable(), authorId: UserId.nullable() }),
|
|
50
|
+
),
|
|
51
|
+
issueDeleted: defineEvent('tracker.issue.deleted', issueRef),
|
|
52
|
+
issueArchived: defineEvent('tracker.issue.archived', issueRef.extend({ archived: z.boolean() })),
|
|
53
|
+
issueDue: defineEvent(
|
|
54
|
+
'tracker.issue.due',
|
|
55
|
+
issueRef.extend({ dueDate: z.string(), assigneeIds: z.array(UserId) }),
|
|
56
|
+
),
|
|
57
|
+
|
|
58
|
+
cycleStarted: defineEvent(
|
|
59
|
+
'tracker.cycle.started',
|
|
60
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, cycleId: Id, number: z.number().int() }),
|
|
61
|
+
),
|
|
62
|
+
cycleCompleted: defineEvent(
|
|
63
|
+
'tracker.cycle.completed',
|
|
64
|
+
z.object({
|
|
65
|
+
workspaceId: WorkspaceId,
|
|
66
|
+
projectId: Id,
|
|
67
|
+
cycleId: Id,
|
|
68
|
+
number: z.number().int(),
|
|
69
|
+
carriedOver: z.number().int(),
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
|
|
73
|
+
projectCreated: defineEvent(
|
|
74
|
+
'tracker.project.created',
|
|
75
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, key: z.string(), name: z.string() }),
|
|
76
|
+
),
|
|
77
|
+
projectUpdated: defineEvent(
|
|
78
|
+
'tracker.project.updated',
|
|
79
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, changes: z.array(z.string()) }),
|
|
80
|
+
),
|
|
81
|
+
projectArchived: defineEvent(
|
|
82
|
+
'tracker.project.archived',
|
|
83
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, archived: z.boolean() }),
|
|
84
|
+
),
|
|
85
|
+
projectDeleted: defineEvent(
|
|
86
|
+
'tracker.project.deleted',
|
|
87
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, key: z.string() }),
|
|
88
|
+
),
|
|
89
|
+
|
|
90
|
+
versionReleased: defineEvent(
|
|
91
|
+
'tracker.version.released',
|
|
92
|
+
z.object({ workspaceId: WorkspaceId, projectId: Id, versionId: Id, name: z.string() }),
|
|
93
|
+
),
|
|
94
|
+
}
|