forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.ts
54 lines (51 loc) · 1.78 KB
/
lib.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler";
const libDefinition = {
name: "@typespec/rest",
diagnostics: {
"not-key-type": {
severity: "error",
messages: {
default: "Cannot copy keys from a non-key type (KeysOf<T> or ParentKeysOf<T>)",
},
},
"resource-missing-key": {
severity: "error",
messages: {
default: paramMessage`Type '${"modelName"}' is used as a resource and therefore must have a key. Use @key to designate a property as the key.`,
},
},
"resource-missing-error": {
severity: "error",
messages: {
default: paramMessage`Type '${"modelName"}' is used as an error and therefore must have the @error decorator applied.`,
},
},
"duplicate-key": {
severity: "error",
messages: {
default: paramMessage`More than one key found on model type ${"resourceName"}`,
},
},
"duplicate-parent-key": {
severity: "error",
messages: {
default: paramMessage`Resource type '${"resourceName"}' has a key property named '${"keyName"}' which conflicts with the key name of a parent or child resource.`,
},
},
"invalid-action-name": {
severity: "error",
messages: {
default: "Action name cannot be empty string.",
},
},
"shared-route-unspecified-action-name": {
severity: "error",
messages: {
default: paramMessage`An operation marked as '@sharedRoute' must have an explicit collection action name passed to '${"decoratorName"}'.`,
},
},
},
} as const;
const restLib = createTypeSpecLibrary(libDefinition);
const { reportDiagnostic, createDiagnostic, createStateSymbol } = restLib;
export { createDiagnostic, createStateSymbol, reportDiagnostic, restLib };