@typespec/http-client-js 0.4.0-dev.2 → 0.4.0-dev.3

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 (107) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/src/components/client-operation.d.ts +4 -1
  3. package/dist/src/components/client-operation.d.ts.map +1 -1
  4. package/dist/src/components/client-operation.js +64 -32
  5. package/dist/src/components/client-operation.js.map +1 -1
  6. package/dist/src/components/client.d.ts.map +1 -1
  7. package/dist/src/components/client.js +2 -1
  8. package/dist/src/components/client.js.map +1 -1
  9. package/dist/src/components/http-request-options.d.ts +4 -4
  10. package/dist/src/components/http-request-options.d.ts.map +1 -1
  11. package/dist/src/components/http-request-options.js +10 -11
  12. package/dist/src/components/http-request-options.js.map +1 -1
  13. package/dist/src/components/http-request.d.ts +3 -3
  14. package/dist/src/components/http-request.d.ts.map +1 -1
  15. package/dist/src/components/http-request.js +35 -31
  16. package/dist/src/components/http-request.js.map +1 -1
  17. package/dist/src/components/http-response.d.ts +3 -3
  18. package/dist/src/components/http-response.d.ts.map +1 -1
  19. package/dist/src/components/http-response.js +11 -6
  20. package/dist/src/components/http-response.js.map +1 -1
  21. package/dist/src/components/operation-handlers/index.d.ts +3 -0
  22. package/dist/src/components/operation-handlers/index.d.ts.map +1 -0
  23. package/dist/src/components/operation-handlers/index.js +3 -0
  24. package/dist/src/components/operation-handlers/index.js.map +1 -0
  25. package/dist/src/components/operation-handlers/operation-pipeline.d.ts +15 -0
  26. package/dist/src/components/operation-handlers/operation-pipeline.d.ts.map +1 -0
  27. package/dist/src/components/operation-handlers/operation-pipeline.js +28 -0
  28. package/dist/src/components/operation-handlers/operation-pipeline.js.map +1 -0
  29. package/dist/src/components/operation-handlers/paging/page-item.d.ts +3 -0
  30. package/dist/src/components/operation-handlers/paging/page-item.d.ts.map +1 -0
  31. package/dist/src/components/operation-handlers/paging/page-item.js +17 -0
  32. package/dist/src/components/operation-handlers/paging/page-item.js.map +1 -0
  33. package/dist/src/components/operation-handlers/paging/page-response.d.ts +10 -0
  34. package/dist/src/components/operation-handlers/paging/page-response.d.ts.map +1 -0
  35. package/dist/src/components/operation-handlers/paging/page-response.js +50 -0
  36. package/dist/src/components/operation-handlers/paging/page-response.js.map +1 -0
  37. package/dist/src/components/operation-handlers/paging/page-settings.d.ts +11 -0
  38. package/dist/src/components/operation-handlers/paging/page-settings.d.ts.map +1 -0
  39. package/dist/src/components/operation-handlers/paging/page-settings.js +52 -0
  40. package/dist/src/components/operation-handlers/paging/page-settings.js.map +1 -0
  41. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.d.ts +3 -0
  42. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.d.ts.map +1 -0
  43. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.js +170 -0
  44. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.js.map +1 -0
  45. package/dist/src/components/operation-handlers/paging/request-send.d.ts +12 -0
  46. package/dist/src/components/operation-handlers/paging/request-send.d.ts.map +1 -0
  47. package/dist/src/components/operation-handlers/paging/request-send.js +78 -0
  48. package/dist/src/components/operation-handlers/paging/request-send.js.map +1 -0
  49. package/dist/src/components/operation-handlers/paging/response-deserialize.d.ts +11 -0
  50. package/dist/src/components/operation-handlers/paging/response-deserialize.d.ts.map +1 -0
  51. package/dist/src/components/operation-handlers/paging/response-deserialize.js +51 -0
  52. package/dist/src/components/operation-handlers/paging/response-deserialize.js.map +1 -0
  53. package/dist/src/components/operation-handlers/paging/util.d.ts +17 -0
  54. package/dist/src/components/operation-handlers/paging/util.d.ts.map +1 -0
  55. package/dist/src/components/operation-handlers/paging/util.js +46 -0
  56. package/dist/src/components/operation-handlers/paging/util.js.map +1 -0
  57. package/dist/src/components/operation-handlers/types.d.ts +16 -0
  58. package/dist/src/components/operation-handlers/types.d.ts.map +1 -0
  59. package/dist/src/components/operation-handlers/types.js +1 -0
  60. package/dist/src/components/operation-handlers/types.js.map +1 -0
  61. package/dist/src/components/operation-options.d.ts +2 -0
  62. package/dist/src/components/operation-options.d.ts.map +1 -1
  63. package/dist/src/components/operation-options.js +2 -1
  64. package/dist/src/components/operation-options.js.map +1 -1
  65. package/dist/src/components/output.d.ts.map +1 -1
  66. package/dist/src/components/output.js +4 -0
  67. package/dist/src/components/output.js.map +1 -1
  68. package/dist/src/components/static-helpers/paging-helper.d.ts +5 -0
  69. package/dist/src/components/static-helpers/paging-helper.d.ts.map +1 -0
  70. package/dist/src/components/static-helpers/paging-helper.js +197 -0
  71. package/dist/src/components/static-helpers/paging-helper.js.map +1 -0
  72. package/dist/src/components/transforms/operation-transform-expression.d.ts +2 -2
  73. package/dist/src/components/transforms/operation-transform-expression.d.ts.map +1 -1
  74. package/dist/src/components/transforms/operation-transform-expression.js +1 -1
  75. package/dist/src/components/transforms/operation-transform-expression.js.map +1 -1
  76. package/dist/src/emitter.d.ts.map +1 -1
  77. package/dist/src/emitter.js +2 -1
  78. package/dist/src/emitter.js.map +1 -1
  79. package/dist/src/lib.d.ts +17 -2
  80. package/dist/src/lib.d.ts.map +1 -1
  81. package/dist/src/lib.js +6 -0
  82. package/dist/src/lib.js.map +1 -1
  83. package/dist/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +2 -2
  85. package/src/components/client-operation.tsx +37 -13
  86. package/src/components/client.tsx +2 -1
  87. package/src/components/http-request-options.tsx +11 -12
  88. package/src/components/http-request.tsx +22 -21
  89. package/src/components/http-response.tsx +8 -9
  90. package/src/components/operation-handlers/index.tsx +2 -0
  91. package/src/components/operation-handlers/operation-pipeline.tsx +33 -0
  92. package/src/components/operation-handlers/paging/page-item.tsx +13 -0
  93. package/src/components/operation-handlers/paging/page-response.tsx +55 -0
  94. package/src/components/operation-handlers/paging/page-settings.tsx +53 -0
  95. package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +192 -0
  96. package/src/components/operation-handlers/paging/request-send.tsx +70 -0
  97. package/src/components/operation-handlers/paging/response-deserialize.tsx +54 -0
  98. package/src/components/operation-handlers/paging/util.ts +70 -0
  99. package/src/components/operation-handlers/types.tsx +18 -0
  100. package/src/components/operation-options.tsx +6 -3
  101. package/src/components/output.tsx +2 -1
  102. package/src/components/static-helpers/paging-helper.tsx +195 -0
  103. package/src/components/transforms/operation-transform-expression.tsx +3 -3
  104. package/src/emitter.tsx +2 -0
  105. package/src/lib.ts +6 -0
  106. package/test/e2e/http/payload/pageable/main.test.ts +78 -22
  107. package/test/scenarios/http-operations/paging.md +244 -0
@@ -0,0 +1,28 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import { ClientOperation as DefaultOperationComponent } from "../client-operation.js";
4
+ /**
5
+ * Component that manages the operation handler pipeline.
6
+ * It will try each handler in order until it finds one that can handle the operation.
7
+ * If no handler is found, it will use the default ClientOperation component.
8
+ */
9
+ export function OperationPipeline({
10
+ httpOperation,
11
+ pipeline,
12
+ internal
13
+ }) {
14
+ for (const handler of pipeline.handlers) {
15
+ if (handler.canHandle(httpOperation)) {
16
+ return handler.handle(httpOperation);
17
+ }
18
+ }
19
+
20
+ // Default to standard client operation if no handler matched
21
+ const defaultOperationRefkey = ay.refkey(httpOperation.operation);
22
+ return _$createComponent(DefaultOperationComponent, {
23
+ httpOperation: httpOperation,
24
+ internal: internal,
25
+ refkey: defaultOperationRefkey
26
+ });
27
+ }
28
+ //# sourceMappingURL=operation-pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-pipeline.js","names":["ay","ClientOperation","DefaultOperationComponent","OperationPipeline","httpOperation","pipeline","internal","handler","handlers","canHandle","handle","defaultOperationRefkey","refkey","operation","_$createComponent"],"sources":["../../../../src/components/operation-handlers/operation-pipeline.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AAEpC,SAASC,eAAe,IAAIC,yBAAyB;AASrD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAC;EAAEC,aAAa;EAAEC,QAAQ;EAAEC;AAAiC,CAAC,EAAE;EAC/F,KAAK,MAAMC,OAAO,IAAIF,QAAQ,CAACG,QAAQ,EAAE;IACvC,IAAID,OAAO,CAACE,SAAS,CAACL,aAAa,CAAC,EAAE;MACpC,OAAOG,OAAO,CAACG,MAAM,CAACN,aAAa,CAAC;IACtC;EACF;;EAEA;EACA,MAAMO,sBAAsB,GAAGX,EAAE,CAACY,MAAM,CAACR,aAAa,CAACS,SAAS,CAAC;EACjE,OAAAC,iBAAA,CACGZ,yBAAyB;IACxBE,aAAa,EAAEA,aAAa;IAC5BE,QAAQ,EAAEA,QAAQ;IAClBM,MAAM,EAAED;EAAsB;AAGpC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { PagingOperation } from "@typespec/compiler";
2
+ export declare function getPageItemTypeName(pagingOperation: PagingOperation): import("@alloy-js/core").Children;
3
+ //# sourceMappingURL=page-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-item.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/page-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,eAAe,qCAQnE"}
@@ -0,0 +1,17 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { $ } from "@typespec/compiler/experimental/typekit";
3
+ import { TypeExpression } from "@typespec/emitter-framework/typescript";
4
+ export function getPageItemTypeName(pagingOperation) {
5
+ const type = pagingOperation.output.pageItems.property.type;
6
+ // only accept array type
7
+ if (type.kind === "Model" && $.array.is(type)) {
8
+ return _$createComponent(TypeExpression, {
9
+ get type() {
10
+ return $.array.getElementType(type);
11
+ }
12
+ });
13
+ }
14
+ // not supported and throw exceptions
15
+ throw new Error("Not supported");
16
+ }
17
+ //# sourceMappingURL=page-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-item.js","names":["$","TypeExpression","getPageItemTypeName","pagingOperation","type","output","pageItems","property","kind","array","is","_$createComponent","getElementType","Error"],"sources":["../../../../../src/components/operation-handlers/paging/page-item.tsx"],"sourcesContent":[null],"mappings":";AACA,SAASA,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,cAAc,QAAQ,wCAAwC;AAEvE,OAAO,SAASC,mBAAmBA,CAACC,eAAgC,EAAE;EACpE,MAAMC,IAAI,GAAGD,eAAe,CAACE,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACH,IAAI;EAC3D;EACA,IAAIA,IAAI,CAACI,IAAI,KAAK,OAAO,IAAIR,CAAC,CAACS,KAAK,CAACC,EAAE,CAACN,IAAI,CAAC,EAAE;IAC7C,OAAAO,iBAAA,CAAQV,cAAc;MAAA,IAACG,IAAIA,CAAA;QAAA,OAAEJ,CAAC,CAACS,KAAK,CAACG,cAAc,CAACR,IAAI,CAAC;MAAA;IAAA;EAC3D;EACA;EACA,MAAM,IAAIS,KAAK,CAAC,eAAe,CAAC;AAClC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import { PagingOperation } from "@typespec/compiler";
3
+ import { HttpOperation } from "@typespec/http";
4
+ export interface PageResponseProps {
5
+ operation: HttpOperation;
6
+ pagingOperation: PagingOperation;
7
+ }
8
+ export declare function getPageResponseTypeRefkey(operation: HttpOperation): ay.Refkey;
9
+ export declare function PageResponseDeclaration(props: PageResponseProps): ay.Children;
10
+ //# sourceMappingURL=page-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-response.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/page-response.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,aAAa,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,aAAa,aAEjE;AACD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,eAyC/D"}
@@ -0,0 +1,50 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import * as ef from "@typespec/emitter-framework/typescript";
5
+ export function getPageResponseTypeRefkey(operation) {
6
+ return ay.refkey(operation, "page-response");
7
+ }
8
+ export function PageResponseDeclaration(props) {
9
+ const namePolicy = ts.useTSNamePolicy();
10
+ const interfaceName = namePolicy.getName(props.operation.operation.name + "PageResponse", "interface");
11
+ const definedResponses = props.pagingOperation.output;
12
+ // Only accept these respose items
13
+ const acceptedColumns = ["continuationToken", "pageItems", "nextLink", "prevLink", "firstLink", "lastLink"];
14
+ const responseProperties = [];
15
+ for (const key in definedResponses) {
16
+ const property = definedResponses[key];
17
+ if (acceptedColumns.includes(key) && !!property) {
18
+ responseProperties.push(property);
19
+ }
20
+ }
21
+ return _$createComponent(ts.InterfaceDeclaration, {
22
+ "export": true,
23
+ name: interfaceName,
24
+ get refkey() {
25
+ return getPageResponseTypeRefkey(props.operation);
26
+ },
27
+ get children() {
28
+ return _$createComponent(ay.For, {
29
+ each: responseProperties,
30
+ line: true,
31
+ children: parameter => _$createComponent(ts.InterfaceMember, {
32
+ get name() {
33
+ return parameter.property.name;
34
+ },
35
+ get optional() {
36
+ return parameter.property.optional;
37
+ },
38
+ get type() {
39
+ return _$createComponent(ef.TypeExpression, {
40
+ get type() {
41
+ return parameter.property.type;
42
+ }
43
+ });
44
+ }
45
+ })
46
+ });
47
+ }
48
+ });
49
+ }
50
+ //# sourceMappingURL=page-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-response.js","names":["ay","ts","ef","getPageResponseTypeRefkey","operation","refkey","PageResponseDeclaration","props","namePolicy","useTSNamePolicy","interfaceName","getName","name","definedResponses","pagingOperation","output","acceptedColumns","responseProperties","key","property","includes","push","_$createComponent","InterfaceDeclaration","children","For","each","line","parameter","InterfaceMember","optional","type","TypeExpression"],"sources":["../../../../../src/components/operation-handlers/paging/page-response.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,OAAO,KAAKC,EAAE,MAAM,wCAAwC;AAO5D,OAAO,SAASC,yBAAyBA,CAACC,SAAwB,EAAE;EAClE,OAAOJ,EAAE,CAACK,MAAM,CAACD,SAAS,EAAE,eAAe,CAAC;AAC9C;AACA,OAAO,SAASE,uBAAuBA,CAACC,KAAwB,EAAE;EAChE,MAAMC,UAAU,GAAGP,EAAE,CAACQ,eAAe,CAAC,CAAC;EACvC,MAAMC,aAAa,GAAGF,UAAU,CAACG,OAAO,CACtCJ,KAAK,CAACH,SAAS,CAACA,SAAS,CAACQ,IAAI,GAAG,cAAc,EAC/C,WACF,CAAC;EACD,MAAMC,gBAAgB,GAAGN,KAAK,CAACO,eAAe,CAACC,MAAM;EACrD;EACA,MAAMC,eAAe,GAAG,CACtB,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,CACX;EACD,MAAMC,kBAAoC,GAAG,EAAE;EAC/C,KAAK,MAAMC,GAAG,IAAIL,gBAAgB,EAAE;IAClC,MAAMM,QAAQ,GAAGN,gBAAgB,CAACK,GAAG,CAAkC;IACvE,IAAIF,eAAe,CAACI,QAAQ,CAACF,GAAG,CAAC,IAAI,CAAC,CAACC,QAAQ,EAAE;MAC/CF,kBAAkB,CAACI,IAAI,CAACF,QAAQ,CAAC;IACnC;EACF;EAEA,OAAAG,iBAAA,CACGrB,EAAE,CAACsB,oBAAoB;IAAA;IAEtBX,IAAI,EAAEF,aAAa;IAAA,IACnBL,MAAMA,CAAA;MAAA,OAAEF,yBAAyB,CAACI,KAAK,CAACH,SAAS,CAAC;IAAA;IAAA,IAAAoB,SAAA;MAAA,OAAAF,iBAAA,CAEjDtB,EAAE,CAACyB,GAAG;QAACC,IAAI,EAAET,kBAAkB;QAAEU,IAAI;QAAAH,QAAA,EAClCI,SAAS,IAAAN,iBAAA,CACRrB,EAAE,CAAC4B,eAAe;UAAA,IACjBjB,IAAIA,CAAA;YAAA,OAAEgB,SAAS,CAACT,QAAQ,CAACP,IAAI;UAAA;UAAA,IAC7BkB,QAAQA,CAAA;YAAA,OAAEF,SAAS,CAACT,QAAQ,CAACW,QAAQ;UAAA;UAAA,IACrCC,IAAIA,CAAA;YAAA,OAAAT,iBAAA,CAAGpB,EAAE,CAAC8B,cAAc;cAAA,IAACD,IAAIA,CAAA;gBAAA,OAAEH,SAAS,CAACT,QAAQ,CAACY,IAAI;cAAA;YAAA;UAAA;QAAA;MAEzD;IAAA;EAAA;AAIT","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import { PagingOperation, PagingProperty } from "@typespec/compiler";
3
+ import { HttpOperation } from "@typespec/http";
4
+ export interface PageSettingsProps {
5
+ operation: HttpOperation;
6
+ pagingOperation: PagingOperation;
7
+ }
8
+ export declare function getPageSettingsTypeRefkey(operation: HttpOperation): ay.Refkey;
9
+ export declare function getPageSettingProperties(pagingOperation: PagingOperation): PagingProperty[];
10
+ export declare function PageSettingsDeclaration(props: PageSettingsProps): ay.Children;
11
+ //# sourceMappingURL=page-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/page-settings.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,aAAa,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,aAAa,aAEjE;AAED,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,eAAe,oBAYxE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,eAwB/D"}
@@ -0,0 +1,52 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import * as ef from "@typespec/emitter-framework/typescript";
5
+ export function getPageSettingsTypeRefkey(operation) {
6
+ return ay.refkey(operation, "page-settings");
7
+ }
8
+ export function getPageSettingProperties(pagingOperation) {
9
+ const definedSettings = pagingOperation.input;
10
+ // Only accept these page settings
11
+ const acceptedSettings = ["continuationToken", "offset", "pageSize", "pageIndex"];
12
+ const settingProperties = [];
13
+ for (const key in definedSettings) {
14
+ const property = definedSettings[key];
15
+ if (acceptedSettings.includes(key) && !!property) {
16
+ settingProperties.push(property);
17
+ }
18
+ }
19
+ return settingProperties;
20
+ }
21
+ export function PageSettingsDeclaration(props) {
22
+ const namePolicy = ts.useTSNamePolicy();
23
+ const interfaceName = namePolicy.getName(props.operation.operation.name + "PageSettings", "interface");
24
+ const settingProperties = getPageSettingProperties(props.pagingOperation);
25
+ return _$createComponent(ts.InterfaceDeclaration, {
26
+ "export": true,
27
+ name: interfaceName,
28
+ get refkey() {
29
+ return getPageSettingsTypeRefkey(props.operation);
30
+ },
31
+ get children() {
32
+ return _$createComponent(ay.For, {
33
+ each: settingProperties,
34
+ line: true,
35
+ children: parameter => _$createComponent(ts.InterfaceMember, {
36
+ get name() {
37
+ return parameter.property.name;
38
+ },
39
+ optional: true,
40
+ get type() {
41
+ return _$createComponent(ef.TypeExpression, {
42
+ get type() {
43
+ return parameter.property.type;
44
+ }
45
+ });
46
+ }
47
+ })
48
+ });
49
+ }
50
+ });
51
+ }
52
+ //# sourceMappingURL=page-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-settings.js","names":["ay","ts","ef","getPageSettingsTypeRefkey","operation","refkey","getPageSettingProperties","pagingOperation","definedSettings","input","acceptedSettings","settingProperties","key","property","includes","push","PageSettingsDeclaration","props","namePolicy","useTSNamePolicy","interfaceName","getName","name","_$createComponent","InterfaceDeclaration","children","For","each","line","parameter","InterfaceMember","optional","type","TypeExpression"],"sources":["../../../../../src/components/operation-handlers/paging/page-settings.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,OAAO,KAAKC,EAAE,MAAM,wCAAwC;AAO5D,OAAO,SAASC,yBAAyBA,CAACC,SAAwB,EAAE;EAClE,OAAOJ,EAAE,CAACK,MAAM,CAACD,SAAS,EAAE,eAAe,CAAC;AAC9C;AAEA,OAAO,SAASE,wBAAwBA,CAACC,eAAgC,EAAE;EACzE,MAAMC,eAAe,GAAGD,eAAe,CAACE,KAAK;EAC7C;EACA,MAAMC,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC;EACjF,MAAMC,iBAAmC,GAAG,EAAE;EAC9C,KAAK,MAAMC,GAAG,IAAIJ,eAAe,EAAE;IACjC,MAAMK,QAAQ,GAAGL,eAAe,CAACI,GAAG,CAAiC;IACrE,IAAIF,gBAAgB,CAACI,QAAQ,CAACF,GAAG,CAAC,IAAI,CAAC,CAACC,QAAQ,EAAE;MAChDF,iBAAiB,CAACI,IAAI,CAACF,QAAQ,CAAC;IAClC;EACF;EACA,OAAOF,iBAAiB;AAC1B;AAEA,OAAO,SAASK,uBAAuBA,CAACC,KAAwB,EAAE;EAChE,MAAMC,UAAU,GAAGjB,EAAE,CAACkB,eAAe,CAAC,CAAC;EACvC,MAAMC,aAAa,GAAGF,UAAU,CAACG,OAAO,CACtCJ,KAAK,CAACb,SAAS,CAACA,SAAS,CAACkB,IAAI,GAAG,cAAc,EAC/C,WACF,CAAC;EACD,MAAMX,iBAAiB,GAAGL,wBAAwB,CAACW,KAAK,CAACV,eAAe,CAAC;EACzE,OAAAgB,iBAAA,CACGtB,EAAE,CAACuB,oBAAoB;IAAA;IAEtBF,IAAI,EAAEF,aAAa;IAAA,IACnBf,MAAMA,CAAA;MAAA,OAAEF,yBAAyB,CAACc,KAAK,CAACb,SAAS,CAAC;IAAA;IAAA,IAAAqB,SAAA;MAAA,OAAAF,iBAAA,CAEjDvB,EAAE,CAAC0B,GAAG;QAACC,IAAI,EAAEhB,iBAAiB;QAAEiB,IAAI;QAAAH,QAAA,EACjCI,SAAS,IAAAN,iBAAA,CACRtB,EAAE,CAAC6B,eAAe;UAAA,IACjBR,IAAIA,CAAA;YAAA,OAAEO,SAAS,CAAChB,QAAQ,CAACS,IAAI;UAAA;UAC7BS,QAAQ;UAAA,IACRC,IAAIA,CAAA;YAAA,OAAAT,iBAAA,CAAGrB,EAAE,CAAC+B,cAAc;cAAA,IAACD,IAAIA,CAAA;gBAAA,OAAEH,SAAS,CAAChB,QAAQ,CAACmB,IAAI;cAAA;YAAA;UAAA;QAAA;MAEzD;IAAA;EAAA;AAIT","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { OperationHandler } from "../types.js";
2
+ export declare const PaginatedOperationHandler: OperationHandler;
3
+ //# sourceMappingURL=paginated-operation-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginated-operation-handler.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/paginated-operation-handler.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,yBAAyB,EAAE,gBA2DvC,CAAC"}
@@ -0,0 +1,170 @@
1
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { $ } from "@typespec/compiler/experimental/typekit";
6
+ import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
7
+ import * as cl from "@typespec/http-client";
8
+ import { reportDiagnostic } from "../../../lib.js";
9
+ import { getClientcontextDeclarationRef } from "../../client-context/client-context-declaration.js";
10
+ import { OperationOptionsDeclaration } from "../../operation-options.js";
11
+ import { getOperationParameters } from "../../operation-parameters.js";
12
+ import { getBuildPagedAsyncIteratorRefkey, getPagedAsyncIterableIteratorRefkey } from "../../static-helpers/paging-helper.js";
13
+ import { getPageItemTypeName } from "../paging/page-item.js";
14
+ import { getPageResponseTypeRefkey, PageResponseDeclaration } from "../paging/page-response.js";
15
+ import { getPageSettingProperties, getPageSettingsTypeRefkey, PageSettingsDeclaration } from "../paging/page-settings.js";
16
+ import { HttpRequestSend } from "../paging/request-send.js";
17
+ import { getHttpRequestDeserializeRefkey, HttpResponseDeserialize } from "../paging/response-deserialize.js";
18
+ import { extractPagingDetail } from "../paging/util.js";
19
+ export const PaginatedOperationHandler = {
20
+ canHandle(httpOperation) {
21
+ const pagingMetadata = $.operation.getPagingMetadata(httpOperation.operation);
22
+ return pagingMetadata !== undefined;
23
+ },
24
+ handle(httpOperation) {
25
+ const clientLibrary = cl.useClientLibrary();
26
+ const client = clientLibrary.getClientForOperation(httpOperation);
27
+ if (!client) {
28
+ reportDiagnostic($.program, {
29
+ code: "client-not-found",
30
+ target: httpOperation.operation
31
+ });
32
+ return;
33
+ }
34
+ const pagingOperation = $.operation.getPagingMetadata(httpOperation.operation);
35
+ const responseRefkey = ay.refkey(httpOperation, "http-response");
36
+ const operationRefkey = ay.refkey(httpOperation.operation);
37
+ const returnType = ay.code`${getPagedAsyncIterableIteratorRefkey()}<${getPageItemTypeName(pagingOperation)},${getPageResponseTypeRefkey(httpOperation)},${getPageSettingsTypeRefkey(httpOperation)}>`;
38
+ const clientContextInterfaceRef = getClientcontextDeclarationRef(client);
39
+ const signatureParams = [{
40
+ name: "client",
41
+ type: clientContextInterfaceRef,
42
+ refkey: ay.refkey(client, "client")
43
+ }, ...getOperationParameters(httpOperation)];
44
+ const pagingDetail = extractPagingDetail(httpOperation, pagingOperation);
45
+ // Exclude from operation options and include them into PageSettings
46
+ const excludes = getPageSettingProperties(pagingOperation).map(p => p.property);
47
+ return _$createComponent(ay.List, {
48
+ get children() {
49
+ return [_$createComponent(OperationOptionsDeclaration, {
50
+ operation: httpOperation,
51
+ excludes: excludes
52
+ }), _$createComponent(PageSettingsDeclaration, {
53
+ operation: httpOperation,
54
+ pagingOperation: pagingOperation
55
+ }), _$createComponent(PageResponseDeclaration, {
56
+ operation: httpOperation,
57
+ pagingOperation: pagingOperation
58
+ }), _$createComponent(HttpRequestSend, {
59
+ httpOperation: httpOperation,
60
+ responseRefkey: responseRefkey
61
+ }), _$createComponent(HttpResponseDeserialize, {
62
+ httpOperation: httpOperation,
63
+ responseRefkey: responseRefkey
64
+ }), _$createComponent(FunctionDeclaration, {
65
+ "export": true,
66
+ get name() {
67
+ return httpOperation.operation.name;
68
+ },
69
+ returnType: returnType,
70
+ refkey: operationRefkey,
71
+ parametersMode: "replace",
72
+ parameters: signatureParams,
73
+ get children() {
74
+ return _$createComponent(ay.List, {
75
+ get children() {
76
+ return [_$createComponent(GetElements, {
77
+ httpOperation: httpOperation,
78
+ pageDetail: pagingDetail
79
+ }), _$createComponent(GetPagedResponse, {
80
+ httpOperation: httpOperation,
81
+ pageDetail: pagingDetail,
82
+ operationParams: signatureParams
83
+ }), [_$memo(() => ay.code`
84
+ return ${getBuildPagedAsyncIteratorRefkey}<${getPageItemTypeName(pagingOperation)}, ${getPageResponseTypeRefkey(httpOperation)}, ${getPageSettingsTypeRefkey(httpOperation)}>({${getElementsRefkey(httpOperation)}, ${getPagedResponseFunctionRefkey(httpOperation)}});`)]];
85
+ }
86
+ });
87
+ }
88
+ })];
89
+ }
90
+ });
91
+ }
92
+ };
93
+ function getPagedResponseFunctionRefkey(httpOperation) {
94
+ return ay.refkey(httpOperation, "get-paged-response");
95
+ }
96
+ function GetPagedResponse(props) {
97
+ const pagingDetail = props.pageDetail;
98
+ const httpOperation = props.httpOperation;
99
+ const params = [{
100
+ name: "nextToken",
101
+ type: "string",
102
+ optional: true,
103
+ refkey: ay.refkey()
104
+ }, {
105
+ name: "settings",
106
+ type: getPageSettingsTypeRefkey(httpOperation),
107
+ optional: true,
108
+ refkey: ay.refkey()
109
+ }];
110
+ // TODO: template can't resolve the ref key so fallback to useTSNamePolicy
111
+ const namePolicy = ts.useTSNamePolicy();
112
+ const functionName = namePolicy.getName(httpOperation.operation.name + "Send", "function");
113
+ const sendParamStr = props.operationParams.map(param => param.name).slice(0, -1).join(", ");
114
+ return _$createComponent(FunctionDeclaration, {
115
+ name: "getPagedResponse",
116
+ async: true,
117
+ get refkey() {
118
+ return getPagedResponseFunctionRefkey(httpOperation);
119
+ },
120
+ parameters: params,
121
+ get children() {
122
+ return ay.code`
123
+ ${props.pageDetail.pattern === "nextLink" ? `
124
+ let response: PathUncheckedResponse;
125
+ if (nextToken) {
126
+ response = await client.pathUnchecked(nextToken).get();
127
+ } else {
128
+ const combinedOptions = { ...options, ...settings };
129
+ response = await ${functionName}(${sendParamStr}, combinedOptions);
130
+ } ` : `
131
+ const combinedOptions = {...options, ...settings};
132
+ ${pagingDetail.input?.nextToken ? `
133
+ if (nextToken) {
134
+ combinedOptions.${pagingDetail.input?.nextToken} = nextToken;
135
+ }` : ``}
136
+ const response = await ${functionName}(${sendParamStr}, combinedOptions);
137
+ `}
138
+ return {
139
+ pagedResponse: await ${getHttpRequestDeserializeRefkey(httpOperation)}(response, options),
140
+ nextToken: ${pagingDetail.output.nextToken ? `response.${pagingDetail.output.nextToken.position}["${pagingDetail.output.nextToken.name}"]` : `undefined`},
141
+ };
142
+ `;
143
+ }
144
+ });
145
+ }
146
+ function getElementsRefkey(httpOperation) {
147
+ return ay.refkey(httpOperation, "get-elements");
148
+ }
149
+ function GetElements(props) {
150
+ const pagingDetail = props.pageDetail;
151
+ const httpOperation = props.httpOperation;
152
+ const params = [{
153
+ name: "response",
154
+ type: getPageResponseTypeRefkey(httpOperation),
155
+ refkey: ay.refkey()
156
+ }];
157
+ return _$createComponent(FunctionDeclaration, {
158
+ name: "getElements",
159
+ get refkey() {
160
+ return getElementsRefkey(httpOperation);
161
+ },
162
+ parameters: params,
163
+ get children() {
164
+ return ay.code`
165
+ return response.${pagingDetail.output.items};
166
+ `;
167
+ }
168
+ });
169
+ }
170
+ //# sourceMappingURL=paginated-operation-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginated-operation-handler.js","names":["ay","ts","$","FunctionDeclaration","cl","reportDiagnostic","getClientcontextDeclarationRef","OperationOptionsDeclaration","getOperationParameters","getBuildPagedAsyncIteratorRefkey","getPagedAsyncIterableIteratorRefkey","getPageItemTypeName","getPageResponseTypeRefkey","PageResponseDeclaration","getPageSettingProperties","getPageSettingsTypeRefkey","PageSettingsDeclaration","HttpRequestSend","getHttpRequestDeserializeRefkey","HttpResponseDeserialize","extractPagingDetail","PaginatedOperationHandler","canHandle","httpOperation","pagingMetadata","operation","getPagingMetadata","undefined","handle","clientLibrary","useClientLibrary","client","getClientForOperation","program","code","target","pagingOperation","responseRefkey","refkey","operationRefkey","returnType","clientContextInterfaceRef","signatureParams","name","type","pagingDetail","excludes","map","p","property","_$createComponent","List","children","parametersMode","parameters","GetElements","pageDetail","GetPagedResponse","operationParams","_$memo","getElementsRefkey","getPagedResponseFunctionRefkey","props","params","optional","namePolicy","useTSNamePolicy","functionName","getName","sendParamStr","param","slice","join","async","pattern","input","nextToken","output","position","items"],"sources":["../../../../../src/components/operation-handlers/paging/paginated-operation-handler.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AAEpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1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ACO;IAAA;EAAA;AAGP;AAMA,SAASiB,iBAAiBA,CAACrC,aAA4B,EAAE;EACvD,OAAOvB,EAAE,CAACsC,MAAM,CAACf,aAAa,EAAE,cAAc,CAAC;AACjD;AACA,SAASgC,WAAWA,CAACO,KAAuB,EAAE;EAC5C,MAAMjB,YAAY,GAAGiB,KAAK,CAACN,UAAU;EACrC,MAAMjC,aAAa,GAAGuC,KAAK,CAACvC,aAAa;EACzC,MAAMwC,MAAM,GAAG,CACb;IACEpB,IAAI,EAAE,UAAU;IAChBC,IAAI,EAAEhC,yBAAyB,CAACW,aAAa,CAAC;IAC9Ce,MAAM,EAAEtC,EAAE,CAACsC,MAAM,CAAC;EACpB,CAAC,CACF;EACD,OAAAY,iBAAA,CACG/C,mBAAmB;IAClBwC,IAAI;IAAA,IACJL,MAAMA,CAAA;MAAA,OAAEsB,iBAAiB,CAACrC,aAAa,CAAC;IAAA;IACxC+B,UAAU,EAAES,MAAM;IAAA,IAAAX,SAAA;MAAA,OAEjBpD,EAAE,CAACkC,IAAI;AACd,wBAAwBW,YAAY,CAACgC,MAAM,CAACE,KAAK;AACjD,OAAO;IAAA;EAAA;AAGP","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import { Refkey } from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import { HttpOperation } from "@typespec/http";
5
+ export interface HttpRequestSendProps {
6
+ httpOperation: HttpOperation;
7
+ responseRefkey?: Refkey;
8
+ }
9
+ export declare function getHttpRequestSendRefkey(httpOperation: HttpOperation): ay.Refkey;
10
+ export declare function getHttpRequestSendParams(httpOperation: HttpOperation): ts.ParameterDescriptor[];
11
+ export declare function HttpRequestSend(props: HttpRequestSendProps): ay.Children;
12
+ //# sourceMappingURL=request-send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-send.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/request-send.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAQ,MAAM,EAA+B,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU/C,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,aAAa,aAEpE;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,aAAa,4BAiBpE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA0B1D"}
@@ -0,0 +1,78 @@
1
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import { List, StatementList, code, refkey } from "@alloy-js/core";
5
+ import * as ts from "@alloy-js/typescript";
6
+ import { Reference } from "@alloy-js/typescript";
7
+ import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
8
+ import * as cl from "@typespec/http-client";
9
+ import { getClientcontextDeclarationRef } from "../../client-context/client-context-declaration.js";
10
+ import { HttpRequestOptions } from "../../http-request-options.js";
11
+ import { HttpRequest } from "../../http-request.js";
12
+ import { getOperationOptionsParameterRefkey, getOperationParameters } from "../../operation-parameters.js";
13
+ export function getHttpRequestSendRefkey(httpOperation) {
14
+ return refkey(httpOperation, "http-request-send");
15
+ }
16
+ export function getHttpRequestSendParams(httpOperation) {
17
+ const clientLibrary = cl.useClientLibrary();
18
+ const client = clientLibrary.getClientForOperation(httpOperation);
19
+ const clientContextInterfaceRef = getClientcontextDeclarationRef(client);
20
+ const signatureParams = [{
21
+ name: "client",
22
+ type: clientContextInterfaceRef,
23
+ refkey: ay.refkey(client, "client")
24
+ }, ...getOperationParameters(httpOperation)];
25
+ const parameters = [...signatureParams];
26
+ // re-correct the `options` parameter to Record<string, any> to accept both paging and non-paging options
27
+ parameters[parameters.length - 1] = {
28
+ name: "options",
29
+ type: "Record<string, any>",
30
+ refkey: getOperationOptionsParameterRefkey(httpOperation),
31
+ optional: true
32
+ };
33
+ return parameters;
34
+ }
35
+ export function HttpRequestSend(props) {
36
+ const httpOperation = props.httpOperation;
37
+ const operationUrlRefkey = refkey();
38
+ const requestOptionsRefkey = refkey();
39
+ const verb = props.httpOperation.verb;
40
+ const namePolicy = ts.useTSNamePolicy();
41
+ const functionName = namePolicy.getName(httpOperation.operation.name + "Send", "function");
42
+ const parameters = getHttpRequestSendParams(httpOperation);
43
+ return _$createComponent(FunctionDeclaration, {
44
+ name: functionName,
45
+ async: true,
46
+ get refkey() {
47
+ return getHttpRequestSendRefkey(httpOperation);
48
+ },
49
+ parametersMode: "replace",
50
+ parameters: parameters,
51
+ get children() {
52
+ return _$createComponent(List, {
53
+ get children() {
54
+ return _$createComponent(StatementList, {
55
+ get children() {
56
+ return [_$createComponent(HttpRequest.Url, {
57
+ get httpOperation() {
58
+ return props.httpOperation;
59
+ },
60
+ refkey: operationUrlRefkey
61
+ }), _$createComponent(HttpRequestOptions, {
62
+ get httpOperation() {
63
+ return props.httpOperation;
64
+ },
65
+ refkey: requestOptionsRefkey
66
+ }), _$memo(() => code`return await client.pathUnchecked(${_$createComponent(Reference, {
67
+ refkey: operationUrlRefkey
68
+ })}).${verb}(${_$createComponent(Reference, {
69
+ refkey: requestOptionsRefkey
70
+ })});`)];
71
+ }
72
+ });
73
+ }
74
+ });
75
+ }
76
+ });
77
+ }
78
+ //# sourceMappingURL=request-send.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-send.js","names":["ay","List","StatementList","code","refkey","ts","Reference","FunctionDeclaration","cl","getClientcontextDeclarationRef","HttpRequestOptions","HttpRequest","getOperationOptionsParameterRefkey","getOperationParameters","getHttpRequestSendRefkey","httpOperation","getHttpRequestSendParams","clientLibrary","useClientLibrary","client","getClientForOperation","clientContextInterfaceRef","signatureParams","name","type","parameters","length","optional","HttpRequestSend","props","operationUrlRefkey","requestOptionsRefkey","verb","namePolicy","useTSNamePolicy","functionName","getName","operation","_$createComponent","async","parametersMode","children","Url","_$memo"],"sources":["../../../../../src/components/operation-handlers/paging/request-send.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,SAASC,IAAI,EAAUC,aAAa,EAAEC,IAAI,EAAEC,MAAM,QAAQ,gBAAgB;AAC1E,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,mBAAmB,QAAQ,wCAAwC;AAE5E,OAAO,KAAKC,EAAE,MAAM,uBAAuB;AAC3C,SAASC,8BAA8B;AACvC,SAASC,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SACEC,kCAAkC,EAClCC,sBAAsB;AAQxB,OAAO,SAASC,wBAAwBA,CAACC,aAA4B,EAAE;EACrE,OAAOX,MAAM,CAACW,aAAa,EAAE,mBAAmB,CAAC;AACnD;AAEA,OAAO,SAASC,wBAAwBA,CAACD,aAA4B,EAAE;EACrE,MAAME,aAAa,GAAGT,EAAE,CAACU,gBAAgB,CAAC,CAAC;EAC3C,MAAMC,MAAM,GAAGF,aAAa,CAACG,qBAAqB,CAACL,aAAa,CAAC;EACjE,MAAMM,yBAAyB,GAAGZ,8BAA8B,CAACU,MAAO,CAAC;EACzE,MAAMG,eAAyC,GAAG,CAChD;IAAEC,IAAI,EAAE,QAAQ;IAAEC,IAAI,EAAEH,yBAAyB;IAAEjB,MAAM,EAAEJ,EAAE,CAACI,MAAM,CAACe,MAAM,EAAE,QAAQ;EAAE,CAAC,EACxF,GAAGN,sBAAsB,CAACE,aAAa,CAAC,CACzC;EACD,MAAMU,UAAoC,GAAG,CAAC,GAAGH,eAAe,CAAC;EACjE;EACAG,UAAU,CAACA,UAAU,CAACC,MAAM,GAAG,CAAC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E2B;cAAoB,IAAAY,MAAA,OACnFxC,IAAI,qCAAAmC,iBAAA,CAAuChC,SAAS;gBAACF,MAAM,EAAE0B;cAAkB,OAAUE,IAAI,IAAAM,iBAAA,CAAMhC,SAAS;gBAACF,MAAM,EAAE2B;cAAoB,MAAS;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAK7J","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { Children, Refkey } from "@alloy-js/core";
2
+ import { HttpOperation } from "@typespec/http";
3
+ import { HttpResponseProps } from "../../http-response.jsx";
4
+ export declare function getHttpRequestDeserializeRefkey(httpOperation: HttpOperation): Refkey;
5
+ export interface HttpResponseDeserializeProps {
6
+ httpOperation: HttpOperation;
7
+ responseRefkey: Refkey;
8
+ children?: Children;
9
+ }
10
+ export declare function HttpResponseDeserialize(props: HttpResponseProps): Children;
11
+ //# sourceMappingURL=response-deserialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-deserialize.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/response-deserialize.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,EAAU,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAK3E,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,aAAa,UAE3E;AAED,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,YAiC/D"}
@@ -0,0 +1,51 @@
1
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
+ import { code, List, refkey } from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
6
+ import { httpRuntimeTemplateLib } from "../../external-packages/ts-http-runtime.js";
7
+ import { HttpResponses } from "../../http-response.js";
8
+ import { getOperationOptionsTypeRefkey } from "../../operation-options.js";
9
+ import { getOperationOptionsParameterRefkey } from "../../operation-parameters.js";
10
+ import { getCreateRestErrorRefkey } from "../../static-helpers/rest-error.js";
11
+ export function getHttpRequestDeserializeRefkey(httpOperation) {
12
+ return refkey(httpOperation, "http-request-deserialize");
13
+ }
14
+ export function HttpResponseDeserialize(props) {
15
+ const httpOperation = props.httpOperation;
16
+ const namePolicy = ts.useTSNamePolicy();
17
+ const functionName = namePolicy.getName(httpOperation.operation.name + "Deserialize", "function");
18
+ const params = [{
19
+ name: "response",
20
+ type: httpRuntimeTemplateLib.PathUncheckedResponse
21
+ }, {
22
+ name: "options",
23
+ refkey: getOperationOptionsParameterRefkey(httpOperation),
24
+ type: getOperationOptionsTypeRefkey(httpOperation),
25
+ optional: true
26
+ }];
27
+ return _$createComponent(FunctionDeclaration, {
28
+ name: functionName,
29
+ get refkey() {
30
+ return getHttpRequestDeserializeRefkey(httpOperation);
31
+ },
32
+ parametersMode: "replace",
33
+ parameters: params,
34
+ get children() {
35
+ return [code`
36
+ if (typeof options?.operationOptions?.onResponse === "function") {
37
+ options?.operationOptions?.onResponse(response);
38
+ }`, _$createComponent(List, {
39
+ hardline: true,
40
+ get children() {
41
+ return [_$createComponent(HttpResponses, {
42
+ get httpOperation() {
43
+ return props.httpOperation;
44
+ }
45
+ }), _$memo(() => code`throw ${getCreateRestErrorRefkey()}(response);`)];
46
+ }
47
+ })];
48
+ }
49
+ });
50
+ }
51
+ //# sourceMappingURL=response-deserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-deserialize.js","names":["code","List","refkey","ts","FunctionDeclaration","httpRuntimeTemplateLib","HttpResponses","getOperationOptionsTypeRefkey","getOperationOptionsParameterRefkey","getCreateRestErrorRefkey","getHttpRequestDeserializeRefkey","httpOperation","HttpResponseDeserialize","props","namePolicy","useTSNamePolicy","functionName","getName","operation","name","params","type","PathUncheckedResponse","optional","_$createComponent","parametersMode","parameters","children","hardline","_$memo"],"sources":["../../../../../src/components/operation-handlers/paging/response-deserialize.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAAmBA,IAAI,EAAEC,IAAI,EAAUC,MAAM,QAAQ,gBAAgB;AACrE,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,mBAAmB,QAAQ,wCAAwC;AAE5E,SAASC,sBAAsB,QAAQ,4CAA4C;AACnF,SAA4BC,aAAa;AACzC,SAASC,6BAA6B;AACtC,SAASC,kCAAkC;AAC3C,SAASC,wBAAwB;AAEjC,OAAO,SAASC,+BAA+BA,CAACC,aAA4B,EAAE;EAC5E,OAAOT,MAAM,CAACS,aAAa,EAAE,0BAA0B,CAAC;AAC1D;AAQA,OAAO,SAASC,uBAAuBA,CAACC,KAAwB,EAAE;EAChE,MAAMF,aAAa,GAAGE,KAAK,CAACF,aAAa;EACzC,MAAMG,UAAU,GAAGX,EAAE,CAACY,eAAe,CAAC,CAAC;EACvC,MAAMC,YAAY,GAAGF,UAAU,CAACG,OAAO,CAACN,aAAa,CAACO,SAAS,CAACC,IAAI,GAAG,aAAa,EAAE,UAAU,CAAC;EACjG,MAAMC,MAAM,GAAG,CACb;IACED,IAAI,EAAE,UAAU;IAChBE,IAAI,EAAEhB,sBAAsB,CAACiB;EAC/B,CAAC,EACD;IACEH,IAAI,EAAE,SAAS;IACfjB,MAAM,EAAEM,kCAAkC,CAACG,aAAa,CAAC;IACzDU,IAAI,EAAEd,6BAA6B,CAACI,aAAa,CAAC;IAClDY,QAAQ,EAAE;EACZ,CAAC,CACF;EACD,OAAAC,iBAAA,CACGpB,mBAAmB;IAClBe,IAAI,EAAEH,YAAY;IAAA,IAClBd,MAAMA,CAAA;MAAA,OAAEQ,+BAA+B,CAACC,aAAa,CAAC;IAAA;IACtDc,cAAc;IACdC,UAAU,EAAEN,MAAM;IAAA,IAAAO,SAAA;MAAA,QAEjB3B,IAAI;AACX;AACA;AACA,QAAQ,EAAAwB,iBAAA,CACDvB,IAAI;QAAC2B,QAAQ;QAAA,IAAAD,SAAA;UAAA,QAAAH,iBAAA,CACXlB,aAAa;YAAA,IAACK,aAAaA,CAAA;cAAA,OAAEE,KAAK,CAACF,aAAa;YAAA;UAAA,IAAAkB,MAAA,OAChD7B,IAAI,SAASS,wBAAwB,CAAC,CAAC,aAAa;QAAA;MAAA;IAAA;EAAA;AAI7D","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import { PagingOperation } from "@typespec/compiler";
2
+ import { HttpOperation } from "@typespec/http";
3
+ export interface PagingDetail {
4
+ pattern: "nextLink" | "continuationToken";
5
+ input?: {
6
+ nextToken: string;
7
+ };
8
+ output: {
9
+ items: string;
10
+ nextToken?: {
11
+ name: string;
12
+ position: "headers" | "body";
13
+ };
14
+ };
15
+ }
16
+ export declare function extractPagingDetail(httpOperation: HttpOperation, pagingOperation: PagingOperation): PagingDetail;
17
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/components/operation-handlers/paging/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,YAAY;IAE3B,OAAO,EAAE,UAAU,GAAG,mBAAmB,CAAC;IAC1C,KAAK,CAAC,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE;YACV,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC;SAC9B,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe,GAC/B,YAAY,CA4Bd"}