@typespec/compiler 0.66.0-dev.26 → 0.66.0-dev.28
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/dist/generated-defs/TypeSpec.d.ts +7 -3
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +9 -7
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/messages.d.ts +2 -2
- package/dist/src/lib/decorators.d.ts +1 -1
- package/dist/src/lib/service.d.ts +1 -1
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/lib/service.js +4 -40
- package/dist/src/lib/service.js.map +1 -1
- package/lib/std/decorators.tsp +3 -3
- package/package.json +1 -1
- package/templates/__snapshots__/rest/main.tsp +1 -3
- package/templates/rest/main.tsp +1 -3
|
@@ -1036,7 +1036,7 @@ declare const diagnostics: {
|
|
|
1036
1036
|
};
|
|
1037
1037
|
};
|
|
1038
1038
|
export type CompilerDiagnostics = TypeOfDiagnostics<typeof diagnostics>;
|
|
1039
|
-
export declare const createDiagnostic: <C extends "
|
|
1039
|
+
export declare const createDiagnostic: <C extends "digit-expected" | "hex-digit-expected" | "binary-digit-expected" | "unterminated" | "creating-file" | "invalid-escape-sequence" | "no-new-line-start-triple-quote" | "no-new-line-end-triple-quote" | "triple-quote-indent" | "invalid-character" | "file-not-found" | "file-load" | "init-template-invalid-json" | "init-template-download-failed" | "multiple-blockless-namespace" | "blockless-namespace-first" | "import-first" | "token-expected" | "unknown-directive" | "augment-decorator-target" | "duplicate-decorator" | "decorator-conflict" | "reserved-identifier" | "invalid-directive-location" | "invalid-decorator-location" | "invalid-projection" | "default-required" | "invalid-template-argument-name" | "invalid-template-default" | "required-parameter-first" | "rest-parameter-last" | "rest-parameter-required" | "doc-invalid-identifier" | "using-invalid-ref" | "invalid-type-ref" | "invalid-template-args" | "intersect-non-model" | "intersect-invalid-index" | "incompatible-indexer" | "no-array-properties" | "intersect-duplicate-property" | "invalid-decorator" | "invalid-ref" | "duplicate-property" | "override-property-mismatch" | "extend-scalar" | "extend-model" | "is-model" | "is-operation" | "spread-model" | "unsupported-default" | "spread-object" | "expect-value" | "non-callable" | "named-init-required" | "invalid-primitive-init" | "ambiguous-scalar-type" | "unassignable" | "property-unassignable" | "property-required" | "value-in-type" | "no-prop" | "missing-index" | "missing-property" | "unexpected-property" | "extends-interface" | "extends-interface-duplicate" | "interface-duplicate" | "union-duplicate" | "enum-member-duplicate" | "constructor-duplicate" | "spread-enum" | "decorator-fail" | "rest-parameter-array" | "decorator-extern" | "function-extern" | "missing-implementation" | "overload-same-parent" | "shadow" | "invalid-deprecation-argument" | "duplicate-deprecation" | "config-invalid-argument" | "config-circular-variable" | "config-path-absolute" | "config-invalid-name" | "path-unix-style" | "config-path-not-found" | "dynamic-import" | "invalid-import" | "invalid-main" | "import-not-found" | "library-invalid" | "incompatible-library" | "compiler-version-mismatch" | "duplicate-symbol" | "decorator-decl-target" | "mixed-string-template" | "non-literal-string-template" | "ambiguous-symbol" | "duplicate-using" | "on-validate-fail" | "invalid-emitter" | "js-error" | "missing-import" | "invalid-rule-ref" | "unknown-rule" | "unknown-rule-set" | "rule-enabled-disabled" | "format-failed" | "invalid-pattern-regex" | "decorator-wrong-target" | "invalid-argument" | "invalid-argument-count" | "known-values-invalid-enum" | "invalid-value" | "deprecated" | "no-optional-key" | "invalid-discriminated-union" | "invalid-discriminated-union-variant" | "missing-discriminator-property" | "invalid-discriminator-value" | "invalid-encode" | "invalid-mime-type" | "no-mime-type-suffix" | "encoded-name-conflict" | "incompatible-paging-props" | "invalid-paging-prop" | "duplicate-paging-prop" | "missing-paging-items" | "service-decorator-duplicate" | "list-type-not-model" | "invalid-range" | "add-response" | "add-parameter" | "add-model-property" | "add-model-property-fail" | "add-response-type" | "circular-base-type" | "circular-constraint" | "circular-op-signature" | "circular-alias-type" | "circular-const" | "circular-prop" | "conflict-marker" | "visibility-sealed" | "visibility-mixed-legacy" | "visibility-legacy" | "default-visibility-not-member" | "operation-visibility-constraint-empty" | "no-compatible-vs-installed" | "vs-extension-windows-only" | "vscode-in-path", M extends keyof {
|
|
1040
1040
|
"digit-expected": {
|
|
1041
1041
|
readonly default: "Digit expected.";
|
|
1042
1042
|
};
|
|
@@ -2098,7 +2098,7 @@ export declare const createDiagnostic: <C extends "triple-quote-indent" | "digit
|
|
|
2098
2098
|
readonly default: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.";
|
|
2099
2099
|
readonly osx: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.\nSee instruction for Mac OS here https://code.visualstudio.com/docs/setup/mac";
|
|
2100
2100
|
};
|
|
2101
|
-
}, C, M>) => import("./types.js").Diagnostic, reportDiagnostic: <C extends "
|
|
2101
|
+
}, C, M>) => import("./types.js").Diagnostic, reportDiagnostic: <C extends "digit-expected" | "hex-digit-expected" | "binary-digit-expected" | "unterminated" | "creating-file" | "invalid-escape-sequence" | "no-new-line-start-triple-quote" | "no-new-line-end-triple-quote" | "triple-quote-indent" | "invalid-character" | "file-not-found" | "file-load" | "init-template-invalid-json" | "init-template-download-failed" | "multiple-blockless-namespace" | "blockless-namespace-first" | "import-first" | "token-expected" | "unknown-directive" | "augment-decorator-target" | "duplicate-decorator" | "decorator-conflict" | "reserved-identifier" | "invalid-directive-location" | "invalid-decorator-location" | "invalid-projection" | "default-required" | "invalid-template-argument-name" | "invalid-template-default" | "required-parameter-first" | "rest-parameter-last" | "rest-parameter-required" | "doc-invalid-identifier" | "using-invalid-ref" | "invalid-type-ref" | "invalid-template-args" | "intersect-non-model" | "intersect-invalid-index" | "incompatible-indexer" | "no-array-properties" | "intersect-duplicate-property" | "invalid-decorator" | "invalid-ref" | "duplicate-property" | "override-property-mismatch" | "extend-scalar" | "extend-model" | "is-model" | "is-operation" | "spread-model" | "unsupported-default" | "spread-object" | "expect-value" | "non-callable" | "named-init-required" | "invalid-primitive-init" | "ambiguous-scalar-type" | "unassignable" | "property-unassignable" | "property-required" | "value-in-type" | "no-prop" | "missing-index" | "missing-property" | "unexpected-property" | "extends-interface" | "extends-interface-duplicate" | "interface-duplicate" | "union-duplicate" | "enum-member-duplicate" | "constructor-duplicate" | "spread-enum" | "decorator-fail" | "rest-parameter-array" | "decorator-extern" | "function-extern" | "missing-implementation" | "overload-same-parent" | "shadow" | "invalid-deprecation-argument" | "duplicate-deprecation" | "config-invalid-argument" | "config-circular-variable" | "config-path-absolute" | "config-invalid-name" | "path-unix-style" | "config-path-not-found" | "dynamic-import" | "invalid-import" | "invalid-main" | "import-not-found" | "library-invalid" | "incompatible-library" | "compiler-version-mismatch" | "duplicate-symbol" | "decorator-decl-target" | "mixed-string-template" | "non-literal-string-template" | "ambiguous-symbol" | "duplicate-using" | "on-validate-fail" | "invalid-emitter" | "js-error" | "missing-import" | "invalid-rule-ref" | "unknown-rule" | "unknown-rule-set" | "rule-enabled-disabled" | "format-failed" | "invalid-pattern-regex" | "decorator-wrong-target" | "invalid-argument" | "invalid-argument-count" | "known-values-invalid-enum" | "invalid-value" | "deprecated" | "no-optional-key" | "invalid-discriminated-union" | "invalid-discriminated-union-variant" | "missing-discriminator-property" | "invalid-discriminator-value" | "invalid-encode" | "invalid-mime-type" | "no-mime-type-suffix" | "encoded-name-conflict" | "incompatible-paging-props" | "invalid-paging-prop" | "duplicate-paging-prop" | "missing-paging-items" | "service-decorator-duplicate" | "list-type-not-model" | "invalid-range" | "add-response" | "add-parameter" | "add-model-property" | "add-model-property-fail" | "add-response-type" | "circular-base-type" | "circular-constraint" | "circular-op-signature" | "circular-alias-type" | "circular-const" | "circular-prop" | "conflict-marker" | "visibility-sealed" | "visibility-mixed-legacy" | "visibility-legacy" | "default-visibility-not-member" | "operation-visibility-constraint-empty" | "no-compatible-vs-installed" | "vs-extension-windows-only" | "vscode-in-path", M extends keyof {
|
|
2102
2102
|
"digit-expected": {
|
|
2103
2103
|
readonly default: "Digit expected.";
|
|
2104
2104
|
};
|
|
@@ -149,7 +149,7 @@ export interface EncodeData {
|
|
|
149
149
|
encoding?: DateTimeKnownEncoding | DurationKnownEncoding | BytesKnownEncoding | string;
|
|
150
150
|
type: Scalar;
|
|
151
151
|
}
|
|
152
|
-
declare const getEncode: (program: Program, type:
|
|
152
|
+
declare const getEncode: (program: Program, type: ModelProperty | Scalar) => EncodeData | undefined;
|
|
153
153
|
export declare const $encode: EncodeDecorator;
|
|
154
154
|
export { getEncode };
|
|
155
155
|
export declare const $withOptionalProperties: WithOptionalPropertiesDecorator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServiceDecorator } from "../../generated-defs/TypeSpec.js";
|
|
1
|
+
import type { ServiceDecorator } from "../../generated-defs/TypeSpec.js";
|
|
2
2
|
import type { Program } from "../core/program.js";
|
|
3
3
|
import { Namespace } from "../core/types.js";
|
|
4
4
|
export interface ServiceDetails {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/lib/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/lib/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,kCAAkC,CAAC;AAGzF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAoB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI/D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6NAA6N;IAC7N,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,OAAQ,SAAQ,cAAc;IAC7C,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,QAAA,MAAO,UAAU,4DAEhB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAExD;AAED,OAAO;AACL;;;;;GAKG;AACH,UAAU,GACX,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,cAAmB,GAC3B,IAAI,CAIN;AAED,eAAO,MAAM,QAAQ,EAAE,gBAgBtB,CAAC"}
|
package/dist/src/lib/service.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { validateDecoratorUniqueOnNode } from "../core/decorator-utils.js";
|
|
2
|
-
import {
|
|
3
|
-
import { reportDiagnostic } from "../core/messages.js";
|
|
2
|
+
import { reportDeprecated } from "../core/index.js";
|
|
4
3
|
import { Realm } from "../experimental/realm.js";
|
|
5
4
|
import { useStateMap } from "../utils/index.js";
|
|
6
5
|
const [getService, setService, getServiceMap] = useStateMap(Symbol.for("@typespec/compiler.services"));
|
|
@@ -42,44 +41,9 @@ export function addService(program, namespace, details = {}) {
|
|
|
42
41
|
}
|
|
43
42
|
export const $service = (context, target, options) => {
|
|
44
43
|
validateDecoratorUniqueOnNode(context, target, $service);
|
|
45
|
-
if (options
|
|
46
|
-
|
|
47
|
-
code: "invalid-argument",
|
|
48
|
-
format: { value: options.kind, expected: "Model" },
|
|
49
|
-
target: context.getArgumentTarget(0),
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
44
|
+
if (options?.version) {
|
|
45
|
+
reportDeprecated(context.program, "version: property is deprecated in @service. If wanting to describe a service versioning you can use the `@typespec/versioning` library. If wanting to describe the project version you can use the package.json version.", context.getArgumentTarget(0));
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
const title = options?.properties.get("title")?.type;
|
|
55
|
-
const versionProp = options?.properties.get("version");
|
|
56
|
-
if (title) {
|
|
57
|
-
if (title.kind === "String") {
|
|
58
|
-
serviceDetails.title = title.value;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
reportDiagnostic(context.program, {
|
|
62
|
-
code: "unassignable",
|
|
63
|
-
format: { sourceType: getTypeName(title), targetType: "String" },
|
|
64
|
-
target: context.getArgumentTarget(0),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (versionProp) {
|
|
69
|
-
const version = versionProp.type;
|
|
70
|
-
reportDeprecated(context.program, "version: property is deprecated in @service. If wanting to describe a service versioning you can use the `@typespec/versioning` library. If wanting to describe the project version you can use the package.json version.", versionProp);
|
|
71
|
-
if (version.kind === "String") {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
73
|
-
serviceDetails.version = version.value;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
reportDiagnostic(context.program, {
|
|
77
|
-
code: "unassignable",
|
|
78
|
-
format: { sourceType: getTypeName(version), targetType: "String" },
|
|
79
|
-
target: context.getArgumentTarget(0),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
addService(context.program, target, serviceDetails);
|
|
47
|
+
addService(context.program, target, options);
|
|
84
48
|
};
|
|
85
49
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/lib/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/lib/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,WAAW,EA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C,iBAAiB,CAAC,CAAC,CAAE,CAC9B,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
package/lib/std/decorators.tsp
CHANGED
|
@@ -102,17 +102,17 @@ model ServiceOptions {
|
|
|
102
102
|
*
|
|
103
103
|
* @example Setting service title
|
|
104
104
|
* ```typespec
|
|
105
|
-
* @service({title: "Pet store"})
|
|
105
|
+
* @service(#{title: "Pet store"})
|
|
106
106
|
* namespace PetStore;
|
|
107
107
|
* ```
|
|
108
108
|
*
|
|
109
109
|
* @example Setting service version
|
|
110
110
|
* ```typespec
|
|
111
|
-
* @service({version: "1.0"})
|
|
111
|
+
* @service(#{version: "1.0"})
|
|
112
112
|
* namespace PetStore;
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
|
-
extern dec service(target: Namespace, options?: ServiceOptions);
|
|
115
|
+
extern dec service(target: Namespace, options?: valueof ServiceOptions);
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* Specify that this model is an error type. Operations return error types when the operation has failed.
|
package/package.json
CHANGED