@azure/arm-resourcegraph 5.0.0-beta.1 → 5.0.0-beta.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 (103) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +12 -1
  3. package/dist/index.js +113 -16
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js +1 -1
  6. package/dist/index.min.js.map +1 -1
  7. package/dist-esm/samples-dev/operationsListSample.d.ts +2 -0
  8. package/dist-esm/samples-dev/operationsListSample.d.ts.map +1 -0
  9. package/dist-esm/samples-dev/{operationsList.js → operationsListSample.js} +3 -3
  10. package/dist-esm/samples-dev/operationsListSample.js.map +1 -0
  11. package/dist-esm/samples-dev/resourcesHistorySample.d.ts +2 -0
  12. package/dist-esm/samples-dev/resourcesHistorySample.d.ts.map +1 -0
  13. package/dist-esm/samples-dev/{resourceHistoryManagementGroupScopeQuery.js → resourcesHistorySample.js} +28 -3
  14. package/dist-esm/samples-dev/resourcesHistorySample.js.map +1 -0
  15. package/dist-esm/samples-dev/resourcesSample.d.ts +2 -0
  16. package/dist-esm/samples-dev/resourcesSample.d.ts.map +1 -0
  17. package/dist-esm/samples-dev/resourcesSample.js +245 -0
  18. package/dist-esm/samples-dev/resourcesSample.js.map +1 -0
  19. package/dist-esm/src/index.d.ts +1 -0
  20. package/dist-esm/src/index.d.ts.map +1 -1
  21. package/dist-esm/src/index.js +1 -0
  22. package/dist-esm/src/index.js.map +1 -1
  23. package/dist-esm/src/models/index.d.ts +4 -4
  24. package/dist-esm/src/models/index.d.ts.map +1 -1
  25. package/dist-esm/src/operations/operations.d.ts.map +1 -1
  26. package/dist-esm/src/operations/operations.js +8 -4
  27. package/dist-esm/src/operations/operations.js.map +1 -1
  28. package/dist-esm/src/pagingHelper.d.ts +13 -0
  29. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  30. package/dist-esm/src/pagingHelper.js +32 -0
  31. package/dist-esm/src/pagingHelper.js.map +1 -0
  32. package/dist-esm/src/resourceGraphClient.d.ts +2 -0
  33. package/dist-esm/src/resourceGraphClient.d.ts.map +1 -1
  34. package/dist-esm/src/resourceGraphClient.js +54 -5
  35. package/dist-esm/src/resourceGraphClient.js.map +1 -1
  36. package/dist-esm/test/sampleTest.js +11 -13
  37. package/dist-esm/test/sampleTest.js.map +1 -1
  38. package/package.json +41 -22
  39. package/review/arm-resourcegraph.api.md +10 -7
  40. package/rollup.config.js +6 -72
  41. package/src/index.ts +1 -0
  42. package/src/models/index.ts +5 -4
  43. package/src/operations/operations.ts +10 -5
  44. package/src/pagingHelper.ts +39 -0
  45. package/src/resourceGraphClient.ts +70 -5
  46. package/tsconfig.json +18 -5
  47. package/types/arm-resourcegraph.d.ts +15 -4
  48. package/types/tsdoc-metadata.json +1 -1
  49. package/LICENSE.txt +0 -21
  50. package/dist-esm/samples-dev/accessAPropertiesField.d.ts +0 -2
  51. package/dist-esm/samples-dev/accessAPropertiesField.d.ts.map +0 -1
  52. package/dist-esm/samples-dev/accessAPropertiesField.js +0 -32
  53. package/dist-esm/samples-dev/accessAPropertiesField.js.map +0 -1
  54. package/dist-esm/samples-dev/basicManagementGroupQuery.d.ts +0 -2
  55. package/dist-esm/samples-dev/basicManagementGroupQuery.d.ts.map +0 -1
  56. package/dist-esm/samples-dev/basicManagementGroupQuery.js +0 -32
  57. package/dist-esm/samples-dev/basicManagementGroupQuery.js.map +0 -1
  58. package/dist-esm/samples-dev/basicQuery.d.ts +0 -2
  59. package/dist-esm/samples-dev/basicQuery.d.ts.map +0 -1
  60. package/dist-esm/samples-dev/basicQuery.js +0 -32
  61. package/dist-esm/samples-dev/basicQuery.js.map +0 -1
  62. package/dist-esm/samples-dev/basicTenantQuery.d.ts +0 -2
  63. package/dist-esm/samples-dev/basicTenantQuery.d.ts.map +0 -1
  64. package/dist-esm/samples-dev/basicTenantQuery.js +0 -31
  65. package/dist-esm/samples-dev/basicTenantQuery.js.map +0 -1
  66. package/dist-esm/samples-dev/complexQuery.d.ts +0 -2
  67. package/dist-esm/samples-dev/complexQuery.d.ts.map +0 -1
  68. package/dist-esm/samples-dev/complexQuery.js +0 -32
  69. package/dist-esm/samples-dev/complexQuery.js.map +0 -1
  70. package/dist-esm/samples-dev/filterResources.d.ts +0 -2
  71. package/dist-esm/samples-dev/filterResources.d.ts.map +0 -1
  72. package/dist-esm/samples-dev/filterResources.js +0 -32
  73. package/dist-esm/samples-dev/filterResources.js.map +0 -1
  74. package/dist-esm/samples-dev/firstPageQuery.d.ts +0 -2
  75. package/dist-esm/samples-dev/firstPageQuery.d.ts.map +0 -1
  76. package/dist-esm/samples-dev/firstPageQuery.js +0 -33
  77. package/dist-esm/samples-dev/firstPageQuery.js.map +0 -1
  78. package/dist-esm/samples-dev/nextPageQuery.d.ts +0 -2
  79. package/dist-esm/samples-dev/nextPageQuery.d.ts.map +0 -1
  80. package/dist-esm/samples-dev/nextPageQuery.js +0 -35
  81. package/dist-esm/samples-dev/nextPageQuery.js.map +0 -1
  82. package/dist-esm/samples-dev/operationsList.d.ts +0 -2
  83. package/dist-esm/samples-dev/operationsList.d.ts.map +0 -1
  84. package/dist-esm/samples-dev/operationsList.js.map +0 -1
  85. package/dist-esm/samples-dev/queryWithAFacetRequest.d.ts +0 -2
  86. package/dist-esm/samples-dev/queryWithAFacetRequest.d.ts.map +0 -1
  87. package/dist-esm/samples-dev/queryWithAFacetRequest.js +0 -51
  88. package/dist-esm/samples-dev/queryWithAFacetRequest.js.map +0 -1
  89. package/dist-esm/samples-dev/randomPageQuery.d.ts +0 -2
  90. package/dist-esm/samples-dev/randomPageQuery.d.ts.map +0 -1
  91. package/dist-esm/samples-dev/randomPageQuery.js +0 -33
  92. package/dist-esm/samples-dev/randomPageQuery.js.map +0 -1
  93. package/dist-esm/samples-dev/resourceHistoryManagementGroupScopeQuery.d.ts +0 -2
  94. package/dist-esm/samples-dev/resourceHistoryManagementGroupScopeQuery.d.ts.map +0 -1
  95. package/dist-esm/samples-dev/resourceHistoryManagementGroupScopeQuery.js.map +0 -1
  96. package/dist-esm/samples-dev/resourceHistoryQuery.d.ts +0 -2
  97. package/dist-esm/samples-dev/resourceHistoryQuery.d.ts.map +0 -1
  98. package/dist-esm/samples-dev/resourceHistoryQuery.js +0 -38
  99. package/dist-esm/samples-dev/resourceHistoryQuery.js.map +0 -1
  100. package/dist-esm/samples-dev/summarizeResourcesByLocation.d.ts +0 -2
  101. package/dist-esm/samples-dev/summarizeResourcesByLocation.d.ts.map +0 -1
  102. package/dist-esm/samples-dev/summarizeResourcesByLocation.js +0 -32
  103. package/dist-esm/samples-dev/summarizeResourcesByLocation.js.map +0 -1
@@ -5,7 +5,9 @@
5
5
  * Code generated by Microsoft (R) AutoRest Code Generator.
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
+ import { __awaiter } from "tslib";
8
9
  import * as coreClient from "@azure/core-client";
10
+ import * as coreRestPipeline from "@azure/core-rest-pipeline";
9
11
  import { OperationsImpl } from "./operations";
10
12
  import * as Parameters from "./models/parameters";
11
13
  import * as Mappers from "./models/mappers";
@@ -16,6 +18,7 @@ export class ResourceGraphClient extends coreClient.ServiceClient {
16
18
  * @param options The parameter options
17
19
  */
18
20
  constructor(credentials, options) {
21
+ var _a, _b, _c;
19
22
  if (credentials === undefined) {
20
23
  throw new Error("'credentials' cannot be null");
21
24
  }
@@ -27,21 +30,67 @@ export class ResourceGraphClient extends coreClient.ServiceClient {
27
30
  requestContentType: "application/json; charset=utf-8",
28
31
  credential: credentials
29
32
  };
30
- const packageDetails = `azsdk-js-arm-resourcegraph/5.0.0-beta.1`;
33
+ const packageDetails = `azsdk-js-arm-resourcegraph/5.0.0-beta.3`;
31
34
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
32
35
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
33
36
  : `${packageDetails}`;
34
- if (!options.credentialScopes) {
35
- options.credentialScopes = ["https://management.azure.com/.default"];
36
- }
37
37
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
38
38
  userAgentPrefix
39
- }, baseUri: options.endpoint || "https://management.azure.com" });
39
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
40
40
  super(optionsWithDefaults);
41
+ let bearerTokenAuthenticationPolicyFound = false;
42
+ if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
43
+ const pipelinePolicies = options.pipeline.getOrderedPolicies();
44
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
45
+ coreRestPipeline.bearerTokenAuthenticationPolicyName);
46
+ }
47
+ if (!options ||
48
+ !options.pipeline ||
49
+ options.pipeline.getOrderedPolicies().length == 0 ||
50
+ !bearerTokenAuthenticationPolicyFound) {
51
+ this.pipeline.removePolicy({
52
+ name: coreRestPipeline.bearerTokenAuthenticationPolicyName
53
+ });
54
+ this.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
55
+ credential: credentials,
56
+ scopes: (_c = optionsWithDefaults.credentialScopes) !== null && _c !== void 0 ? _c : `${optionsWithDefaults.endpoint}/.default`,
57
+ challengeCallbacks: {
58
+ authorizeRequestOnChallenge: coreClient.authorizeRequestOnClaimChallenge
59
+ }
60
+ }));
61
+ }
41
62
  // Assigning values to Constant parameters
42
63
  this.$host = options.$host || "https://management.azure.com";
43
64
  this.apiVersion = options.apiVersion || "2021-06-01-preview";
44
65
  this.operations = new OperationsImpl(this);
66
+ this.addCustomApiVersionPolicy(options.apiVersion);
67
+ }
68
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
69
+ addCustomApiVersionPolicy(apiVersion) {
70
+ if (!apiVersion) {
71
+ return;
72
+ }
73
+ const apiVersionPolicy = {
74
+ name: "CustomApiVersionPolicy",
75
+ sendRequest(request, next) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const param = request.url.split("?");
78
+ if (param.length > 1) {
79
+ const newParams = param[1].split("&").map((item) => {
80
+ if (item.indexOf("api-version") > -1) {
81
+ return "api-version=" + apiVersion;
82
+ }
83
+ else {
84
+ return item;
85
+ }
86
+ });
87
+ request.url = param[0] + "?" + newParams.join("&");
88
+ }
89
+ return next(request);
90
+ });
91
+ }
92
+ };
93
+ this.pipeline.addPolicy(apiVersionPolicy);
45
94
  }
46
95
  /**
47
96
  * Queries the resources managed by Azure Resource Manager for scopes specified in the request.
@@ -1 +1 @@
1
- {"version":3,"file":"resourceGraphClient.js","sourceRoot":"","sources":["../../src/resourceGraphClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAW5C,MAAM,OAAO,mBAAoB,SAAQ,UAAU,CAAC,aAAa;IAI/D;;;;OAIG;IACH,YACE,WAAqC,EACrC,OAA2C;QAE3C,IAAI,WAAW,KAAK,SAAS,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAsC;YAClD,kBAAkB,EAAE,iCAAiC;YACrD,UAAU,EAAE,WAAW;SACxB,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,E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AC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC;AACF,MAAM,6BAA6B,GAA6B;IAC9D,IAAI,EAAE,qDAAqD;IAC3D,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;aAC/D;SACF;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;KACF;IACD,WAAW,EAAE,UAAU,CAAC,OAAO;IAC/B,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;IACjC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC"}
@@ -6,24 +6,22 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
  import { __awaiter } from "tslib";
9
- import { record } from "@azure-tools/test-recorder";
10
- const recorderEnvSetup = {
11
- replaceableVariables: {
12
- AZURE_CLIENT_ID: "azure_client_id",
13
- AZURE_CLIENT_SECRET: "azure_client_secret",
14
- AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
15
- SUBSCRIPTION_ID: "azure_subscription_id"
16
- },
17
- customizationsOnRecordings: [
18
- (recording) => recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
19
- ],
20
- queryParametersToSkip: []
9
+ import { Recorder } from "@azure-tools/test-recorder";
10
+ const replaceableVariables = {
11
+ AZURE_CLIENT_ID: "azure_client_id",
12
+ AZURE_CLIENT_SECRET: "azure_client_secret",
13
+ AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
14
+ SUBSCRIPTION_ID: "azure_subscription_id"
15
+ };
16
+ const recorderOptions = {
17
+ envSetupForPlayback: replaceableVariables
21
18
  };
22
19
  describe("My test", () => {
23
20
  let recorder;
24
21
  beforeEach(function () {
25
22
  return __awaiter(this, void 0, void 0, function* () {
26
- recorder = record(this, recorderEnvSetup);
23
+ recorder = new Recorder(this.currentTest);
24
+ yield recorder.start(recorderOptions);
27
25
  });
28
26
  });
29
27
  afterEach(function () {
@@ -1 +1 @@
1
- {"version":3,"file":"sampleTest.js","sourceRoot":"","sources":["../../test/sampleTest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EAEL,MAAM,EAGP,MAAM,4BAA4B,CAAC;AAGpC,MAAM,gBAAgB,GAA6B;IACjD,oBAAoB,EAAE;QACpB,eAAe,EAAE,iBAAiB;QAClC,mBAAmB,EAAE,qBAAqB;QAC1C,eAAe,EAAE,sCAAsC;QACvD,eAAe,EAAE,uBAAuB;KACzC;IACD,0BAA0B,EAAE;QAC1B,CAAC,SAAc,EAAO,EAAE,CACtB,SAAS,CAAC,OAAO,CACf,yBAAyB,EACzB,+BAA+B,CAChC;KACJ;IACD,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,QAAkB,CAAC;IAEvB,UAAU,CAAC;;YACT,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAC5C,CAAC;KAAA,CAAC,CAAC;IAEH,SAAS,CAAC;;YACR,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC;KAAA,CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,EAAE;;YAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC;KAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"sampleTest.js","sourceRoot":"","sources":["../../test/sampleTest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EACL,QAAQ,EAGT,MAAM,4BAA4B,CAAC;AAIpC,MAAM,oBAAoB,GAA2B;IACnD,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,sCAAsC;IACvD,eAAe,EAAE,uBAAuB;CACzC,CAAC;AAEF,MAAM,eAAe,GAAyB;IAC5C,mBAAmB,EAAE,oBAAoB;CAC1C,CAAC;AAEF,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,QAAkB,CAAC;IAEvB,UAAU,CAAC;;YACT,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1C,MAAM,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;KAAA,CAAC,CAAC;IAEH,SAAS,CAAC;;YACR,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC;KAAA,CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,EAAE;;YAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC;KAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -3,43 +3,58 @@
3
3
  "sdk-type": "mgmt",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "A generated SDK for ResourceGraphClient.",
6
- "version": "5.0.0-beta.1",
7
- "engines": { "node": ">=12.0.0" },
6
+ "version": "5.0.0-beta.3",
7
+ "engines": {
8
+ "node": ">=14.0.0"
9
+ },
8
10
  "dependencies": {
9
11
  "@azure/core-paging": "^1.2.0",
10
- "@azure/core-client": "^1.0.0",
12
+ "@azure/core-client": "^1.6.1",
11
13
  "@azure/core-auth": "^1.3.0",
12
- "@azure/core-rest-pipeline": "^1.1.0",
14
+ "@azure/core-rest-pipeline": "^1.8.0",
13
15
  "tslib": "^2.2.0"
14
16
  },
15
- "keywords": ["node", "azure", "typescript", "browser", "isomorphic"],
17
+ "keywords": [
18
+ "node",
19
+ "azure",
20
+ "typescript",
21
+ "browser",
22
+ "isomorphic"
23
+ ],
16
24
  "license": "MIT",
17
25
  "main": "./dist/index.js",
18
26
  "module": "./dist-esm/src/index.js",
19
27
  "types": "./types/arm-resourcegraph.d.ts",
20
28
  "devDependencies": {
21
- "@microsoft/api-extractor": "^7.18.11",
22
- "@rollup/plugin-commonjs": "11.0.2",
23
- "@rollup/plugin-json": "^4.0.0",
24
- "@rollup/plugin-multi-entry": "^3.0.0",
25
- "@rollup/plugin-node-resolve": "^8.0.0",
29
+ "@microsoft/api-extractor": "^7.31.1",
30
+ "@rollup/plugin-commonjs": "^21.0.1",
31
+ "@rollup/plugin-json": "^4.1.0",
32
+ "@rollup/plugin-multi-entry": "^4.1.0",
33
+ "@rollup/plugin-node-resolve": "^13.1.3",
26
34
  "mkdirp": "^1.0.4",
27
- "rollup": "^1.16.3",
28
- "rollup-plugin-sourcemaps": "^0.4.2",
29
- "typescript": "~4.2.0",
35
+ "rollup": "^2.66.1",
36
+ "rollup-plugin-sourcemaps": "^0.6.3",
37
+ "typescript": "~4.8.0",
30
38
  "uglify-js": "^3.4.9",
31
39
  "rimraf": "^3.0.0",
32
40
  "@azure/identity": "^2.0.1",
33
- "@azure-tools/test-recorder": "^1.0.0",
41
+ "@azure-tools/test-recorder": "^2.0.0",
42
+ "@azure-tools/test-credential": "^1.0.0",
34
43
  "mocha": "^7.1.1",
35
- "cross-env": "^7.0.2"
44
+ "@types/chai": "^4.2.8",
45
+ "chai": "^4.2.0",
46
+ "cross-env": "^7.0.2",
47
+ "@types/node": "^14.0.0",
48
+ "@azure/dev-tool": "^1.0.0"
36
49
  },
37
50
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resourcegraph/arm-resourcegraph",
38
51
  "repository": {
39
52
  "type": "git",
40
53
  "url": "https://github.com/Azure/azure-sdk-for-js.git"
41
54
  },
42
- "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" },
55
+ "bugs": {
56
+ "url": "https://github.com/Azure/azure-sdk-for-js/issues"
57
+ },
43
58
  "files": [
44
59
  "dist/**/*.js",
45
60
  "dist/**/*.js.map",
@@ -81,21 +96,25 @@
81
96
  "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node",
82
97
  "unit-test:browser": "echo skipped",
83
98
  "integration-test": "npm run integration-test:node && npm run integration-test:browser",
84
- "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js",
85
- "integration-test:browser": "echo skipped",
86
- "docs": "echo skipped"
99
+ "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'",
100
+ "integration-test:browser": "echo skipped"
87
101
  },
88
102
  "sideEffects": false,
89
103
  "//metadata": {
90
104
  "constantPaths": [
91
- { "path": "src/ResourceGraphClient.ts", "prefix": "packageDetails" }
105
+ {
106
+ "path": "src/resourceGraphClient.ts",
107
+ "prefix": "packageDetails"
108
+ }
92
109
  ]
93
110
  },
94
111
  "autoPublish": true,
95
112
  "//sampleConfiguration": {
96
113
  "productName": "",
97
- "productSlugs": ["azure"],
114
+ "productSlugs": [
115
+ "azure"
116
+ ],
98
117
  "disableDocsMs": true,
99
118
  "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-resourcegraph?view=azure-node-preview"
100
119
  }
101
- }
120
+ }
@@ -52,10 +52,10 @@ export interface Facet {
52
52
  }
53
53
 
54
54
  // @public
55
- export type FacetError = Facet & {
56
- resultType: "FacetError";
55
+ export interface FacetError extends Facet {
57
56
  errors: ErrorDetails[];
58
- };
57
+ resultType: "FacetError";
58
+ }
59
59
 
60
60
  // @public
61
61
  export interface FacetRequest {
@@ -72,12 +72,12 @@ export interface FacetRequestOptions {
72
72
  }
73
73
 
74
74
  // @public
75
- export type FacetResult = Facet & {
76
- resultType: "FacetResult";
77
- totalRecords: number;
75
+ export interface FacetResult extends Facet {
78
76
  count: number;
79
77
  data: Record<string, unknown>;
80
- };
78
+ resultType: "FacetResult";
79
+ totalRecords: number;
80
+ }
81
81
 
82
82
  // @public
83
83
  export type FacetSortOrder = "asc" | "desc";
@@ -85,6 +85,9 @@ export type FacetSortOrder = "asc" | "desc";
85
85
  // @public (undocumented)
86
86
  export type FacetUnion = Facet | FacetResult | FacetError;
87
87
 
88
+ // @public
89
+ export function getContinuationToken(page: unknown): string | undefined;
90
+
88
91
  // @public
89
92
  export interface Operation {
90
93
  display?: OperationDisplay;
package/rollup.config.js CHANGED
@@ -14,62 +14,14 @@ import json from "@rollup/plugin-json";
14
14
 
15
15
  import nodeBuiltins from "builtin-modules";
16
16
 
17
- /**
18
- * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
19
- *
20
- * NOTE: this manual configuration is only needed because OpenTelemetry uses an
21
- * __exportStar downleveled helper function to declare its exports which confuses
22
- * rollup's automatic discovery mechanism.
23
- *
24
- * @returns an object reference that can be `...`'d into your cjs() configuration.
25
- */
26
- export function openTelemetryCommonJs() {
27
- const namedExports = {};
28
-
29
- for (const key of [
30
- "@opentelemetry/api",
31
- "@azure/core-tracing/node_modules/@opentelemetry/api"
32
- ]) {
33
- namedExports[key] = [
34
- "SpanKind",
35
- "TraceFlags",
36
- "getSpan",
37
- "setSpan",
38
- "SpanStatusCode",
39
- "getSpanContext",
40
- "setSpanContext"
41
- ];
42
- }
43
-
44
- const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"];
45
-
46
- for (const version of releasedOpenTelemetryVersions) {
47
- namedExports[
48
- // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path.
49
- `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js`
50
- ] = [
51
- "SpanKind",
52
- "TraceFlags",
53
- "getSpan",
54
- "setSpan",
55
- "StatusCode",
56
- "CanonicalCode",
57
- "getSpanContext",
58
- "setSpanContext"
59
- ];
60
- }
61
-
62
- return namedExports;
63
- }
64
-
65
17
  // #region Warning Handler
66
18
 
67
19
  /**
68
- * A function that can determine whether a rollupwarning should be ignored. If
20
+ * A function that can determine whether a rollup warning should be ignored. If
69
21
  * the function returns `true`, then the warning will not be displayed.
70
22
  */
71
23
 
72
- function ignoreNiseSinonEvalWarnings(warning) {
24
+ function ignoreNiseSinonEval(warning) {
73
25
  return (
74
26
  warning.code === "EVAL" &&
75
27
  warning.id &&
@@ -78,17 +30,14 @@ function ignoreNiseSinonEvalWarnings(warning) {
78
30
  );
79
31
  }
80
32
 
81
- function ignoreChaiCircularDependencyWarnings(warning) {
33
+ function ignoreChaiCircularDependency(warning) {
82
34
  return (
83
35
  warning.code === "CIRCULAR_DEPENDENCY" &&
84
36
  warning.importer && warning.importer.includes("node_modules/chai") === true
85
37
  );
86
38
  }
87
39
 
88
- const warningInhibitors = [
89
- ignoreChaiCircularDependencyWarnings,
90
- ignoreNiseSinonEvalWarnings
91
- ];
40
+ const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval];
92
41
 
93
42
  /**
94
43
  * Construct a warning handler for the shared rollup configuration
@@ -122,22 +71,7 @@ function makeBrowserTestConfig() {
122
71
  nodeResolve({
123
72
  mainFields: ["module", "browser"]
124
73
  }),
125
- cjs({
126
- namedExports: {
127
- // Chai's strange internal architecture makes it impossible to statically
128
- // analyze its exports.
129
- chai: [
130
- "version",
131
- "use",
132
- "util",
133
- "config",
134
- "expect",
135
- "should",
136
- "assert"
137
- ],
138
- ...openTelemetryCommonJs()
139
- }
140
- }),
74
+ cjs(),
141
75
  json(),
142
76
  sourcemaps()
143
77
  //viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
@@ -173,7 +107,7 @@ export function makeConfig(pkg, options) {
173
107
  ],
174
108
  output: { file: "dist/index.js", format: "cjs", sourcemap: true },
175
109
  preserveSymlinks: false,
176
- plugins: [sourcemaps(), nodeResolve(), cjs()]
110
+ plugins: [sourcemaps(), nodeResolve()]
177
111
  };
178
112
 
179
113
  const config = [baseConfig];
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  /// <reference lib="esnext.asynciterable" />
10
+ export { getContinuationToken } from "./pagingHelper";
10
11
  export * from "./models";
11
12
  export { ResourceGraphClient } from "./resourceGraphClient";
12
13
  export * from "./operationsInterfaces";
@@ -189,7 +189,7 @@ export interface Column {
189
189
  }
190
190
 
191
191
  /** Successfully executed facet containing additional statistics on the response of a query. */
192
- export type FacetResult = Facet & {
192
+ export interface FacetResult extends Facet {
193
193
  /** Polymorphic discriminator, which specifies the different types this object can be */
194
194
  resultType: "FacetResult";
195
195
  /** Number of total records in the facet results. */
@@ -198,15 +198,16 @@ export type FacetResult = Facet & {
198
198
  count: number;
199
199
  /** A JObject array or Table containing the desired facets. Only present if the facet is valid. */
200
200
  data: Record<string, unknown>;
201
- };
201
+ }
202
202
 
203
203
  /** A facet whose execution resulted in an error. */
204
- export type FacetError = Facet & {
204
+ export interface FacetError extends Facet {
205
205
  /** Polymorphic discriminator, which specifies the different types this object can be */
206
206
  resultType: "FacetError";
207
207
  /** An array containing detected facet errors with details. */
208
208
  errors: ErrorDetails[];
209
- };
209
+ }
210
+
210
211
  /** Defines values for ResultFormat. */
211
212
  export type ResultFormat = "table" | "objectArray";
212
213
  /** Defines values for AuthorizationScopeFilter. */
@@ -6,7 +6,7 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
10
  import { Operations } from "../operationsInterfaces";
11
11
  import * as coreClient from "@azure/core-client";
12
12
  import * as Mappers from "../models/mappers";
@@ -46,16 +46,21 @@ export class OperationsImpl implements Operations {
46
46
  [Symbol.asyncIterator]() {
47
47
  return this;
48
48
  },
49
- byPage: () => {
50
- return this.listPagingPage(options);
49
+ byPage: (settings?: PageSettings) => {
50
+ if (settings?.maxPageSize) {
51
+ throw new Error("maxPageSize is not supported by this operation.");
52
+ }
53
+ return this.listPagingPage(options, settings);
51
54
  }
52
55
  };
53
56
  }
54
57
 
55
58
  private async *listPagingPage(
56
- options?: OperationsListOptionalParams
59
+ options?: OperationsListOptionalParams,
60
+ _settings?: PageSettings
57
61
  ): AsyncIterableIterator<Operation[]> {
58
- let result = await this._list(options);
62
+ let result: OperationsListResponse;
63
+ result = await this._list(options);
59
64
  yield result.value || [];
60
65
  }
61
66
 
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Code generated by Microsoft (R) AutoRest Code Generator.
6
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ */
8
+
9
+ export interface PageInfo {
10
+ continuationToken?: string;
11
+ }
12
+
13
+ const pageMap = new WeakMap<object, PageInfo>();
14
+
15
+ /**
16
+ * Given the last `.value` produced by the `byPage` iterator,
17
+ * returns a continuation token that can be used to begin paging from
18
+ * that point later.
19
+ * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator.
20
+ * @returns The continuation token that can be passed into byPage() during future calls.
21
+ */
22
+ export function getContinuationToken(page: unknown): string | undefined {
23
+ if (typeof page !== "object" || page === null) {
24
+ return undefined;
25
+ }
26
+ return pageMap.get(page)?.continuationToken;
27
+ }
28
+
29
+ export function setContinuationToken(
30
+ page: unknown,
31
+ continuationToken: string | undefined
32
+ ): void {
33
+ if (typeof page !== "object" || page === null || !continuationToken) {
34
+ return;
35
+ }
36
+ const pageInfo = pageMap.get(page) ?? {};
37
+ pageInfo.continuationToken = continuationToken;
38
+ pageMap.set(page, pageInfo);
39
+ }
@@ -7,6 +7,12 @@
7
7
  */
8
8
 
9
9
  import * as coreClient from "@azure/core-client";
10
+ import * as coreRestPipeline from "@azure/core-rest-pipeline";
11
+ import {
12
+ PipelineRequest,
13
+ PipelineResponse,
14
+ SendRequest
15
+ } from "@azure/core-rest-pipeline";
10
16
  import * as coreAuth from "@azure/core-auth";
11
17
  import { OperationsImpl } from "./operations";
12
18
  import { Operations } from "./operationsInterfaces";
@@ -48,29 +54,88 @@ export class ResourceGraphClient extends coreClient.ServiceClient {
48
54
  credential: credentials
49
55
  };
50
56
 
51
- const packageDetails = `azsdk-js-arm-resourcegraph/5.0.0-beta.1`;
57
+ const packageDetails = `azsdk-js-arm-resourcegraph/5.0.0-beta.3`;
52
58
  const userAgentPrefix =
53
59
  options.userAgentOptions && options.userAgentOptions.userAgentPrefix
54
60
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
55
61
  : `${packageDetails}`;
56
62
 
57
- if (!options.credentialScopes) {
58
- options.credentialScopes = ["https://management.azure.com/.default"];
59
- }
60
63
  const optionsWithDefaults = {
61
64
  ...defaults,
62
65
  ...options,
63
66
  userAgentOptions: {
64
67
  userAgentPrefix
65
68
  },
66
- baseUri: options.endpoint || "https://management.azure.com"
69
+ endpoint:
70
+ options.endpoint ?? options.baseUri ?? "https://management.azure.com"
67
71
  };
68
72
  super(optionsWithDefaults);
69
73
 
74
+ let bearerTokenAuthenticationPolicyFound: boolean = false;
75
+ if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
76
+ const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
77
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
78
+ (pipelinePolicy) =>
79
+ pipelinePolicy.name ===
80
+ coreRestPipeline.bearerTokenAuthenticationPolicyName
81
+ );
82
+ }
83
+ if (
84
+ !options ||
85
+ !options.pipeline ||
86
+ options.pipeline.getOrderedPolicies().length == 0 ||
87
+ !bearerTokenAuthenticationPolicyFound
88
+ ) {
89
+ this.pipeline.removePolicy({
90
+ name: coreRestPipeline.bearerTokenAuthenticationPolicyName
91
+ });
92
+ this.pipeline.addPolicy(
93
+ coreRestPipeline.bearerTokenAuthenticationPolicy({
94
+ credential: credentials,
95
+ scopes:
96
+ optionsWithDefaults.credentialScopes ??
97
+ `${optionsWithDefaults.endpoint}/.default`,
98
+ challengeCallbacks: {
99
+ authorizeRequestOnChallenge:
100
+ coreClient.authorizeRequestOnClaimChallenge
101
+ }
102
+ })
103
+ );
104
+ }
105
+
70
106
  // Assigning values to Constant parameters
71
107
  this.$host = options.$host || "https://management.azure.com";
72
108
  this.apiVersion = options.apiVersion || "2021-06-01-preview";
73
109
  this.operations = new OperationsImpl(this);
110
+ this.addCustomApiVersionPolicy(options.apiVersion);
111
+ }
112
+
113
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
114
+ private addCustomApiVersionPolicy(apiVersion?: string) {
115
+ if (!apiVersion) {
116
+ return;
117
+ }
118
+ const apiVersionPolicy = {
119
+ name: "CustomApiVersionPolicy",
120
+ async sendRequest(
121
+ request: PipelineRequest,
122
+ next: SendRequest
123
+ ): Promise<PipelineResponse> {
124
+ const param = request.url.split("?");
125
+ if (param.length > 1) {
126
+ const newParams = param[1].split("&").map((item) => {
127
+ if (item.indexOf("api-version") > -1) {
128
+ return "api-version=" + apiVersion;
129
+ } else {
130
+ return item;
131
+ }
132
+ });
133
+ request.url = param[0] + "?" + newParams.join("&");
134
+ }
135
+ return next(request);
136
+ }
137
+ };
138
+ this.pipeline.addPolicy(apiVersionPolicy);
74
139
  }
75
140
 
76
141
  /**