@typespec/compiler 0.62.0-dev.11 → 0.62.0-dev.13

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.
Files changed (103) hide show
  1. package/dist/generated-defs/TypeSpec.Prototypes.d.ts +6 -0
  2. package/dist/generated-defs/TypeSpec.Prototypes.d.ts.map +1 -0
  3. package/dist/generated-defs/TypeSpec.Prototypes.js +2 -0
  4. package/dist/generated-defs/TypeSpec.Prototypes.js.map +1 -0
  5. package/dist/generated-defs/TypeSpec.Prototypes.ts-test.d.ts +2 -0
  6. package/dist/generated-defs/TypeSpec.Prototypes.ts-test.d.ts.map +1 -0
  7. package/dist/generated-defs/TypeSpec.Prototypes.ts-test.js +5 -0
  8. package/dist/generated-defs/TypeSpec.Prototypes.ts-test.js.map +1 -0
  9. package/dist/generated-defs/TypeSpec.d.ts +148 -8
  10. package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
  11. package/dist/manifest.js +2 -2
  12. package/dist/src/core/binder.d.ts +8 -0
  13. package/dist/src/core/binder.d.ts.map +1 -1
  14. package/dist/src/core/binder.js +107 -43
  15. package/dist/src/core/binder.js.map +1 -1
  16. package/dist/src/core/checker.d.ts +3 -7
  17. package/dist/src/core/checker.d.ts.map +1 -1
  18. package/dist/src/core/checker.js +319 -814
  19. package/dist/src/core/checker.js.map +1 -1
  20. package/dist/src/core/diagnostics.js +2 -2
  21. package/dist/src/core/diagnostics.js.map +1 -1
  22. package/dist/src/core/helpers/operation-utils.d.ts.map +1 -1
  23. package/dist/src/core/helpers/operation-utils.js +4 -1
  24. package/dist/src/core/helpers/operation-utils.js.map +1 -1
  25. package/dist/src/core/helpers/syntax-utils.d.ts +2 -0
  26. package/dist/src/core/helpers/syntax-utils.d.ts.map +1 -1
  27. package/dist/src/core/helpers/syntax-utils.js +11 -0
  28. package/dist/src/core/helpers/syntax-utils.js.map +1 -1
  29. package/dist/src/core/inspector/node.d.ts +2 -0
  30. package/dist/src/core/inspector/node.d.ts.map +1 -0
  31. package/dist/src/core/inspector/node.js +35 -0
  32. package/dist/src/core/inspector/node.js.map +1 -0
  33. package/dist/src/core/inspector/symbol.d.ts +3 -0
  34. package/dist/src/core/inspector/symbol.d.ts.map +1 -0
  35. package/dist/src/core/inspector/symbol.js +84 -0
  36. package/dist/src/core/inspector/symbol.js.map +1 -0
  37. package/dist/src/core/messages.d.ts +99 -43
  38. package/dist/src/core/messages.d.ts.map +1 -1
  39. package/dist/src/core/messages.js +29 -13
  40. package/dist/src/core/messages.js.map +1 -1
  41. package/dist/src/core/name-resolver.d.ts +107 -0
  42. package/dist/src/core/name-resolver.d.ts.map +1 -0
  43. package/dist/src/core/name-resolver.js +989 -0
  44. package/dist/src/core/name-resolver.js.map +1 -0
  45. package/dist/src/core/program.d.ts.map +1 -1
  46. package/dist/src/core/program.js +11 -5
  47. package/dist/src/core/program.js.map +1 -1
  48. package/dist/src/core/semantic-walker.d.ts.map +1 -1
  49. package/dist/src/core/semantic-walker.js +3 -1
  50. package/dist/src/core/semantic-walker.js.map +1 -1
  51. package/dist/src/core/type-utils.js +2 -2
  52. package/dist/src/core/type-utils.js.map +1 -1
  53. package/dist/src/core/types.d.ts +140 -34
  54. package/dist/src/core/types.d.ts.map +1 -1
  55. package/dist/src/core/types.js +9 -0
  56. package/dist/src/core/types.js.map +1 -1
  57. package/dist/src/index.d.ts +5 -5
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/index.js +13 -4
  60. package/dist/src/index.js.map +1 -1
  61. package/dist/src/lib/decorators.d.ts +2 -13
  62. package/dist/src/lib/decorators.d.ts.map +1 -1
  63. package/dist/src/lib/decorators.js +1 -33
  64. package/dist/src/lib/decorators.js.map +1 -1
  65. package/dist/src/lib/intrinsic/decorators.d.ts +5 -0
  66. package/dist/src/lib/intrinsic/decorators.d.ts.map +1 -0
  67. package/dist/src/lib/intrinsic/decorators.js +25 -0
  68. package/dist/src/lib/intrinsic/decorators.js.map +1 -0
  69. package/dist/src/lib/intrinsic/tsp-index.d.ts +9 -0
  70. package/dist/src/lib/intrinsic/tsp-index.d.ts.map +1 -0
  71. package/dist/src/lib/intrinsic/tsp-index.js +11 -0
  72. package/dist/src/lib/intrinsic/tsp-index.js.map +1 -0
  73. package/dist/src/lib/paging.d.ts +112 -0
  74. package/dist/src/lib/paging.d.ts.map +1 -0
  75. package/dist/src/lib/paging.js +260 -0
  76. package/dist/src/lib/paging.js.map +1 -0
  77. package/dist/src/lib/tsp-index.d.ts.map +1 -1
  78. package/dist/src/lib/tsp-index.js +12 -2
  79. package/dist/src/lib/tsp-index.js.map +1 -1
  80. package/dist/src/server/completion.d.ts.map +1 -1
  81. package/dist/src/server/completion.js +7 -6
  82. package/dist/src/server/completion.js.map +1 -1
  83. package/dist/src/server/type-details.js +3 -2
  84. package/dist/src/server/type-details.js.map +1 -1
  85. package/dist/src/server/type-signature.js +2 -1
  86. package/dist/src/server/type-signature.js.map +1 -1
  87. package/dist/src/testing/test-host.js +1 -1
  88. package/dist/src/testing/test-host.js.map +1 -1
  89. package/dist/src/testing/test-utils.d.ts +6 -0
  90. package/dist/src/testing/test-utils.d.ts.map +1 -1
  91. package/dist/src/testing/test-utils.js +19 -1
  92. package/dist/src/testing/test-utils.js.map +1 -1
  93. package/dist/src/utils/misc.d.ts +6 -5
  94. package/dist/src/utils/misc.d.ts.map +1 -1
  95. package/dist/src/utils/misc.js.map +1 -1
  96. package/lib/intrinsics.tsp +2 -1
  97. package/lib/prototypes.tsp +18 -0
  98. package/lib/std/decorators.tsp +151 -7
  99. package/package.json +3 -4
  100. package/dist/src/lib/intrinsic-decorators.d.ts +0 -6
  101. package/dist/src/lib/intrinsic-decorators.d.ts.map +0 -1
  102. package/dist/src/lib/intrinsic-decorators.js +0 -17
  103. package/dist/src/lib/intrinsic-decorators.js.map +0 -1
@@ -277,13 +277,6 @@ extern dec maxValueExclusive(target: numeric | ModelProperty, value: valueof num
277
277
  */
278
278
  extern dec secret(target: string | ModelProperty);
279
279
 
280
- /**
281
- * Mark this operation as a `list` operation for resource types.
282
- * @deprecated Use the `listsResource` decorator in `@typespec/rest` instead.
283
- * @param listedType Optional type of the items in the list.
284
- */
285
- extern dec list(target: Operation, listedType?: Model);
286
-
287
280
  /**
288
281
  * Attaches a tag to an operation, interface, or namespace. Multiple `@tag` decorators can be specified to attach multiple tags to a TypeSpec element.
289
282
  * @param tag Tag value
@@ -689,6 +682,157 @@ extern dec withoutOmittedProperties(target: Model, omit: string | Union);
689
682
  */
690
683
  extern dec withPickedProperties(target: Model, pick: string | Union);
691
684
 
685
+ //---------------------------------------------------------------------------
686
+ // Paging
687
+ //---------------------------------------------------------------------------
688
+
689
+ /**
690
+ * Mark this operation as a `list` operation that returns a paginated list of items.
691
+ */
692
+ extern dec list(target: Operation);
693
+
694
+ /**
695
+ * Pagination property defining the number of items to skip.
696
+ * @example
697
+ * ```tsp
698
+ * model Page<T> {
699
+ * @pageItems items: T[];
700
+ * }
701
+ * @list op listPets(@offset skip: int32, @pageSize pageSize: int8): Page<Pet>;
702
+ * ```
703
+ */
704
+ extern dec offset(target: ModelProperty);
705
+
706
+ /**
707
+ * Pagination property defining the page index.
708
+ *
709
+ * @example
710
+ * ```tsp
711
+ * model Page<T> {
712
+ * @pageItems items: T[];
713
+ * }
714
+ * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
715
+ * ```
716
+ */
717
+ extern dec pageIndex(target: ModelProperty);
718
+
719
+ /**
720
+ * Specify the pagination parameter that controls the maximum number of items to include in a page.
721
+ *
722
+ * @example
723
+ * ```tsp
724
+ * model Page<T> {
725
+ * @pageItems items: T[];
726
+ * }
727
+ * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
728
+ * ```
729
+ */
730
+ extern dec pageSize(target: ModelProperty);
731
+
732
+ /**
733
+ * Specify the the property that contains the array of page items.
734
+ *
735
+ * @example
736
+ * ```tsp
737
+ * model Page<T> {
738
+ * @pageItems items: T[];
739
+ * }
740
+ * @list op listPets(@pageIndex page: int32, @pageSize pageSize: int8): Page<Pet>;
741
+ * ```
742
+ */
743
+ extern dec pageItems(target: ModelProperty);
744
+
745
+ /**
746
+ * Pagination property defining the token to get to the next page.
747
+ * It MUST be specified both on the request parameter and the response.
748
+ *
749
+ * @example
750
+ * ```tsp
751
+ * model Page<T> {
752
+ * @pageItems items: T[];
753
+ * @continuationToken continuationToken: string;
754
+ * }
755
+ * @list op listPets(@continuationToken continuationToken: string): Page<Pet>;
756
+ * ```
757
+ */
758
+ extern dec continuationToken(target: ModelProperty);
759
+
760
+ /**
761
+ * Pagination property defining a link to the next page.
762
+ *
763
+ * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
764
+ *
765
+ * @example
766
+ * ```tsp
767
+ * model Page<T> {
768
+ * @pageItems items: T[];
769
+ * @nextLink next: url;
770
+ * @prevLink prev: url;
771
+ * @firstLink first: url;
772
+ * @lastLink last: url;
773
+ * }
774
+ * @list op listPets(): Page<Pet>;
775
+ * ```
776
+ */
777
+ extern dec nextLink(target: ModelProperty);
778
+
779
+ /**
780
+ * Pagination property defining a link to the previous page.
781
+ *
782
+ * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
783
+ *
784
+ * @example
785
+ * ```tsp
786
+ * model Page<T> {
787
+ * @pageItems items: T[];
788
+ * @nextLink next: url;
789
+ * @prevLink prev: url;
790
+ * @firstLink first: url;
791
+ * @lastLink last: url;
792
+ * }
793
+ * @list op listPets(): Page<Pet>;
794
+ * ```
795
+ */
796
+ extern dec prevLink(target: ModelProperty);
797
+
798
+ /**
799
+ * Pagination property defining a link to the first page.
800
+ *
801
+ * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
802
+ *
803
+ * @example
804
+ * ```tsp
805
+ * model Page<T> {
806
+ * @pageItems items: T[];
807
+ * @nextLink next: url;
808
+ * @prevLink prev: url;
809
+ * @firstLink first: url;
810
+ * @lastLink last: url;
811
+ * }
812
+ * @list op listPets(): Page<Pet>;
813
+ * ```
814
+ */
815
+ extern dec firstLink(target: ModelProperty);
816
+
817
+ /**
818
+ * Pagination property defining a link to the last page.
819
+ *
820
+ * It is expected that navigating to the link will return the same set of responses as the operation that returned the current page.
821
+ *
822
+ * @example
823
+ * ```tsp
824
+ * model Page<T> {
825
+ * @pageItems items: T[];
826
+ * @nextLink next: url;
827
+ * @prevLink prev: url;
828
+ * @firstLink first: url;
829
+ * @lastLink last: url;
830
+ * }
831
+ * @list op listPets(): Page<Pet>;
832
+ * ```
833
+ */
834
+ extern dec lastLink(target: ModelProperty);
835
+
692
836
  //---------------------------------------------------------------------------
693
837
  // Debugging
694
838
  //---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/compiler",
3
- "version": "0.62.0-dev.11",
3
+ "version": "0.62.0-dev.13",
4
4
  "description": "TypeSpec Compiler Preview",
5
5
  "author": "Microsoft Corporation",
6
6
  "license": "MIT",
@@ -96,7 +96,6 @@
96
96
  "rimraf": "~6.0.1",
97
97
  "source-map-support": "~0.5.21",
98
98
  "tmlanguage-generator": "~0.5.9 || >=0.6.0-dev <0.6.0",
99
- "ts-node": "~10.9.2",
100
99
  "typescript": "~5.6.3",
101
100
  "vitest": "^2.1.2",
102
101
  "vscode-oniguruma": "~2.0.1",
@@ -105,13 +104,13 @@
105
104
  "peerDependencies": {},
106
105
  "scripts": {
107
106
  "clean": "rimraf ./dist ./temp",
108
- "build:init-templates-index": "node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm ./.scripts/build-init-templates.ts",
107
+ "build:init-templates-index": "tsx ./.scripts/build-init-templates.ts",
109
108
  "build": "npm run gen-manifest && npm run build:init-templates-index && npm run compile && npm run generate-tmlanguage",
110
109
  "compile": "tsc -p .",
111
110
  "watch": "tsc -p . --watch",
112
111
  "watch-tmlanguage": "node scripts/watch-tmlanguage.js",
113
112
  "generate-tmlanguage": "node scripts/generate-tmlanguage.js",
114
- "gen-extern-signature": "node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm ./.scripts/gen-extern-signature.ts",
113
+ "gen-extern-signature": "tsx ./.scripts/gen-extern-signature.ts",
115
114
  "dogfood": "node scripts/dogfood.js",
116
115
  "test": "vitest run",
117
116
  "test:ui": "vitest --ui",
@@ -1,6 +0,0 @@
1
- import type { Program } from "../core/program.js";
2
- import type { DecoratorContext, ModelIndexer, Scalar, Type } from "../core/types.js";
3
- export declare const namespace = "TypeSpec";
4
- export declare const $indexer: (context: DecoratorContext, target: Type, key: Scalar, value: Type) => void;
5
- export declare function getIndexer(program: Program, target: Type): ModelIndexer | undefined;
6
- //# sourceMappingURL=intrinsic-decorators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intrinsic-decorators.d.ts","sourceRoot":"","sources":["../../../src/lib/intrinsic-decorators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAErF,eAAO,MAAM,SAAS,aAAa,CAAC;AAGpC,eAAO,MAAM,QAAQ,YAAa,gBAAgB,UAAU,IAAI,OAAO,MAAM,SAAS,IAAI,SAGzF,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,YAAY,GAAG,SAAS,CAEnF"}
@@ -1,17 +0,0 @@
1
- import { setDocData } from "../core/intrinsic-type-state.js";
2
- export const namespace = "TypeSpec";
3
- const indexTypeKey = Symbol.for(`TypeSpec.index`);
4
- export const $indexer = (context, target, key, value) => {
5
- const indexer = { key, value };
6
- context.program.stateMap(indexTypeKey).set(target, indexer);
7
- };
8
- export function getIndexer(program, target) {
9
- return program.stateMap(indexTypeKey).get(target);
10
- }
11
- /**
12
- * @internal to be used to set the `@doc` from doc comment.
13
- */
14
- export const $docFromComment = (context, target, key, text) => {
15
- setDocData(context.program, target, key, { value: text, source: "comment" });
16
- };
17
- //# sourceMappingURL=intrinsic-decorators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intrinsic-decorators.js","sourceRoot":"","sources":["../../../src/lib/intrinsic-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAIxE,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAEpC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAyB,EAAE,MAAY,EAAE,GAAW,EAAE,KAAW,EAAE,EAAE;IAC5F,MAAM,OAAO,GAAiB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC7C,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,OAAgB,EAAE,MAAY;IACvD,OAAO,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAyB,EACzB,MAAY,EACZ,GAAc,EACd,IAAY,EACZ,EAAE;IACF,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC"}