@pegma/support-desk-contracts 0.1.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/index.d.ts +120 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pegma contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @pegma/support-desk-contracts
|
|
2
|
+
|
|
3
|
+
Provider-neutral ticket, requester, message, and event contracts shared by
|
|
4
|
+
Support Desk packages and host applications.
|
|
5
|
+
|
|
6
|
+
`Ticket` carries optional host-configured `category` and dual timestamps:
|
|
7
|
+
staff-facing `updatedAt` and customer-visible `customerUpdatedAt`. Category is
|
|
8
|
+
an opaque allowlisted label and never establishes identity, permission,
|
|
9
|
+
priority, or assignment.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { IsoTimestamp, PrincipalId } from "@pegma/spine";
|
|
2
|
+
/**
|
|
3
|
+
* Identity and time are ecosystem-wide, not Support Desk's to define.
|
|
4
|
+
*
|
|
5
|
+
* A principal resolved by `@pegma/authorization-core` has to be the same value
|
|
6
|
+
* Support Desk stores on a ticket, authorizes a reply against, and writes into
|
|
7
|
+
* an audit event. Declaring the type locally would make that agreement a
|
|
8
|
+
* coincidence rather than something the compiler checks, so both come from
|
|
9
|
+
* `@pegma/spine` and are re-exported here for convenience.
|
|
10
|
+
*/
|
|
11
|
+
export type { IsoTimestamp, PrincipalId };
|
|
12
|
+
export type TicketId = string;
|
|
13
|
+
export type MessageId = string;
|
|
14
|
+
export type TicketChannel = "web" | "email" | "api";
|
|
15
|
+
export type TicketPriority = "low" | "normal" | "high" | "urgent";
|
|
16
|
+
export type TicketStatus = "open" | "waiting_on_support" | "waiting_on_customer" | "resolved" | "closed";
|
|
17
|
+
/**
|
|
18
|
+
* Describes how a requester was associated with an account.
|
|
19
|
+
*
|
|
20
|
+
* `matched_email` is useful for routing and context, but is explicitly not an
|
|
21
|
+
* authenticated identity.
|
|
22
|
+
*/
|
|
23
|
+
export type RequesterAssociation = "authenticated" | "matched_email" | "unverified";
|
|
24
|
+
export interface TicketRequester {
|
|
25
|
+
readonly association: RequesterAssociation;
|
|
26
|
+
readonly principalId?: PrincipalId;
|
|
27
|
+
readonly email?: string;
|
|
28
|
+
readonly displayName?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Current ticket state stored with optimistic-concurrency revision. */
|
|
31
|
+
export interface Ticket {
|
|
32
|
+
readonly id: TicketId;
|
|
33
|
+
readonly number: number;
|
|
34
|
+
readonly revision: number;
|
|
35
|
+
readonly subject: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional host-configured opaque label (for example `bug` or `feedback`).
|
|
38
|
+
* Never establishes identity, permission, priority, or assignment.
|
|
39
|
+
*/
|
|
40
|
+
readonly category?: string;
|
|
41
|
+
readonly channel: TicketChannel;
|
|
42
|
+
readonly status: TicketStatus;
|
|
43
|
+
readonly priority: TicketPriority;
|
|
44
|
+
readonly requester: TicketRequester;
|
|
45
|
+
readonly assignedTo?: PrincipalId;
|
|
46
|
+
readonly createdAt: IsoTimestamp;
|
|
47
|
+
/** Staff-facing update time; advances on every accepted ticket change. */
|
|
48
|
+
readonly updatedAt: IsoTimestamp;
|
|
49
|
+
/**
|
|
50
|
+
* Customer-visible update time. Advances for customer-visible messages and
|
|
51
|
+
* lifecycle changes; notes, assignment, and priority leave it unchanged.
|
|
52
|
+
*/
|
|
53
|
+
readonly customerUpdatedAt: IsoTimestamp;
|
|
54
|
+
readonly resolvedAt?: IsoTimestamp;
|
|
55
|
+
readonly closedAt?: IsoTimestamp;
|
|
56
|
+
}
|
|
57
|
+
export type MessageAuthorKind = "customer" | "staff" | "system";
|
|
58
|
+
export type MessageVisibility = "customer" | "internal";
|
|
59
|
+
export type MessageFormat = "plain_text" | "markdown";
|
|
60
|
+
/**
|
|
61
|
+
* One canonical message in a ticket conversation.
|
|
62
|
+
*
|
|
63
|
+
* Mail adapters should convert and sanitize provider content before producing
|
|
64
|
+
* this contract. Raw MIME payloads and unsafe HTML do not belong here.
|
|
65
|
+
*/
|
|
66
|
+
export interface TicketMessage {
|
|
67
|
+
readonly id: MessageId;
|
|
68
|
+
readonly ticketId: TicketId;
|
|
69
|
+
readonly authorKind: MessageAuthorKind;
|
|
70
|
+
readonly authorPrincipalId?: PrincipalId;
|
|
71
|
+
readonly channel: TicketChannel;
|
|
72
|
+
readonly visibility: MessageVisibility;
|
|
73
|
+
readonly format: MessageFormat;
|
|
74
|
+
readonly body: string;
|
|
75
|
+
readonly createdAt: IsoTimestamp;
|
|
76
|
+
readonly externalMessageId?: string;
|
|
77
|
+
readonly inReplyToExternalMessageId?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface CreateTicketInput {
|
|
80
|
+
readonly id: TicketId;
|
|
81
|
+
readonly number: number;
|
|
82
|
+
readonly subject: string;
|
|
83
|
+
readonly channel: TicketChannel;
|
|
84
|
+
readonly priority?: TicketPriority;
|
|
85
|
+
/** Optional host-validated opaque category; preserved for the ticket life. */
|
|
86
|
+
readonly category?: string;
|
|
87
|
+
readonly requester: TicketRequester;
|
|
88
|
+
readonly createdAt: IsoTimestamp;
|
|
89
|
+
}
|
|
90
|
+
interface TicketEventBase {
|
|
91
|
+
readonly occurredAt: IsoTimestamp;
|
|
92
|
+
}
|
|
93
|
+
export type TicketEvent = (TicketEventBase & {
|
|
94
|
+
readonly type: "customer_replied";
|
|
95
|
+
readonly actorId?: PrincipalId;
|
|
96
|
+
}) | (TicketEventBase & {
|
|
97
|
+
readonly type: "support_replied";
|
|
98
|
+
readonly actorId: PrincipalId;
|
|
99
|
+
}) | (TicketEventBase & {
|
|
100
|
+
readonly type: "note_added";
|
|
101
|
+
readonly actorId: PrincipalId;
|
|
102
|
+
}) | (TicketEventBase & {
|
|
103
|
+
readonly type: "resolved";
|
|
104
|
+
readonly actorId: PrincipalId;
|
|
105
|
+
}) | (TicketEventBase & {
|
|
106
|
+
readonly type: "closed";
|
|
107
|
+
readonly actorId: PrincipalId;
|
|
108
|
+
}) | (TicketEventBase & {
|
|
109
|
+
readonly type: "reopened";
|
|
110
|
+
readonly actorId: PrincipalId;
|
|
111
|
+
}) | (TicketEventBase & {
|
|
112
|
+
readonly type: "assigned";
|
|
113
|
+
readonly actorId: PrincipalId;
|
|
114
|
+
readonly assigneeId: PrincipalId | null;
|
|
115
|
+
}) | (TicketEventBase & {
|
|
116
|
+
readonly type: "priority_changed";
|
|
117
|
+
readonly actorId: PrincipalId;
|
|
118
|
+
readonly priority: TicketPriority;
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;;;GAQG;AACH,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAClE,MAAM,MAAM,YAAY,GACtB,MAAM,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAC9B,eAAe,GAAG,eAAe,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wEAAwE;AACxE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;I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AAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B,CAAC,GACF,CAAC,eAAe,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;CACzC,CAAC,GACF,CAAC,eAAe,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC,CAAC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pegma/support-desk-contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Provider-neutral ticket and message contracts for Support Desk.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*.d.ts",
|
|
13
|
+
"dist/**/*.d.ts.map",
|
|
14
|
+
"dist/**/*.js",
|
|
15
|
+
"dist/**/*.js.map"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/pegma-dev/support-desk.git",
|
|
29
|
+
"directory": "packages/contracts"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
34
|
+
"prepack": "npm run build"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@pegma/spine": "0.1.1"
|
|
38
|
+
}
|
|
39
|
+
}
|