@azure-rest/synapse-access-control 1.0.0-alpha.20241219.1 → 1.0.0-alpha.20241223.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/accessControlRestClient.d.ts +12 -1
- package/dist/browser/accessControlRestClient.d.ts.map +1 -1
- package/dist/browser/accessControlRestClient.js +30 -8
- package/dist/browser/accessControlRestClient.js.map +1 -1
- package/dist/browser/clientDefinitions.d.ts +9 -9
- package/dist/browser/clientDefinitions.js.map +1 -1
- package/dist/browser/isUnexpected.d.ts +9 -9
- package/dist/browser/isUnexpected.js +35 -28
- package/dist/browser/isUnexpected.js.map +1 -1
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/logger.js +5 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/models.d.ts +4 -0
- package/dist/browser/models.d.ts.map +1 -1
- package/dist/browser/models.js.map +1 -1
- package/dist/browser/outputModels.d.ts +16 -7
- package/dist/browser/outputModels.d.ts.map +1 -1
- package/dist/browser/outputModels.js.map +1 -1
- package/dist/browser/paginateHelper.d.ts +27 -2
- package/dist/browser/paginateHelper.d.ts.map +1 -1
- package/dist/browser/paginateHelper.js +98 -1
- package/dist/browser/paginateHelper.js.map +1 -1
- package/dist/browser/parameters.d.ts +1 -1
- package/dist/browser/parameters.d.ts.map +1 -1
- package/dist/browser/parameters.js.map +1 -1
- package/dist/browser/responses.d.ts +8 -10
- package/dist/browser/responses.d.ts.map +1 -1
- package/dist/browser/responses.js.map +1 -1
- package/dist/commonjs/accessControlRestClient.d.ts +12 -1
- package/dist/commonjs/accessControlRestClient.d.ts.map +1 -1
- package/dist/commonjs/accessControlRestClient.js +30 -8
- package/dist/commonjs/accessControlRestClient.js.map +1 -1
- package/dist/commonjs/clientDefinitions.d.ts +9 -9
- package/dist/commonjs/clientDefinitions.js.map +1 -1
- package/dist/commonjs/isUnexpected.d.ts +9 -9
- package/dist/commonjs/isUnexpected.js +35 -28
- package/dist/commonjs/isUnexpected.js.map +1 -1
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models.d.ts +4 -0
- package/dist/commonjs/models.d.ts.map +1 -1
- package/dist/commonjs/models.js.map +1 -1
- package/dist/commonjs/outputModels.d.ts +16 -7
- package/dist/commonjs/outputModels.d.ts.map +1 -1
- package/dist/commonjs/outputModels.js.map +1 -1
- package/dist/commonjs/paginateHelper.d.ts +27 -2
- package/dist/commonjs/paginateHelper.d.ts.map +1 -1
- package/dist/commonjs/paginateHelper.js +99 -2
- package/dist/commonjs/paginateHelper.js.map +1 -1
- package/dist/commonjs/parameters.d.ts +1 -1
- package/dist/commonjs/parameters.d.ts.map +1 -1
- package/dist/commonjs/parameters.js.map +1 -1
- package/dist/commonjs/responses.d.ts +8 -10
- package/dist/commonjs/responses.d.ts.map +1 -1
- package/dist/commonjs/responses.js.map +1 -1
- package/dist/esm/accessControlRestClient.d.ts +12 -1
- package/dist/esm/accessControlRestClient.d.ts.map +1 -1
- package/dist/esm/accessControlRestClient.js +30 -8
- package/dist/esm/accessControlRestClient.js.map +1 -1
- package/dist/esm/clientDefinitions.d.ts +9 -9
- package/dist/esm/clientDefinitions.js.map +1 -1
- package/dist/esm/isUnexpected.d.ts +9 -9
- package/dist/esm/isUnexpected.js +35 -28
- package/dist/esm/isUnexpected.js.map +1 -1
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models.d.ts +4 -0
- package/dist/esm/models.d.ts.map +1 -1
- package/dist/esm/models.js.map +1 -1
- package/dist/esm/outputModels.d.ts +16 -7
- package/dist/esm/outputModels.d.ts.map +1 -1
- package/dist/esm/outputModels.js.map +1 -1
- package/dist/esm/paginateHelper.d.ts +27 -2
- package/dist/esm/paginateHelper.d.ts.map +1 -1
- package/dist/esm/paginateHelper.js +98 -1
- package/dist/esm/paginateHelper.js.map +1 -1
- package/dist/esm/parameters.d.ts +1 -1
- package/dist/esm/parameters.d.ts.map +1 -1
- package/dist/esm/parameters.js.map +1 -1
- package/dist/esm/responses.d.ts +8 -10
- package/dist/esm/responses.d.ts.map +1 -1
- package/dist/esm/responses.js.map +1 -1
- package/dist/react-native/accessControlRestClient.d.ts +12 -1
- package/dist/react-native/accessControlRestClient.d.ts.map +1 -1
- package/dist/react-native/accessControlRestClient.js +30 -8
- package/dist/react-native/accessControlRestClient.js.map +1 -1
- package/dist/react-native/clientDefinitions.d.ts +9 -9
- package/dist/react-native/clientDefinitions.js.map +1 -1
- package/dist/react-native/isUnexpected.d.ts +9 -9
- package/dist/react-native/isUnexpected.js +35 -28
- package/dist/react-native/isUnexpected.js.map +1 -1
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models.d.ts +4 -0
- package/dist/react-native/models.d.ts.map +1 -1
- package/dist/react-native/models.js.map +1 -1
- package/dist/react-native/outputModels.d.ts +16 -7
- package/dist/react-native/outputModels.d.ts.map +1 -1
- package/dist/react-native/outputModels.js.map +1 -1
- package/dist/react-native/paginateHelper.d.ts +27 -2
- package/dist/react-native/paginateHelper.d.ts.map +1 -1
- package/dist/react-native/paginateHelper.js +98 -1
- package/dist/react-native/paginateHelper.js.map +1 -1
- package/dist/react-native/parameters.d.ts +1 -1
- package/dist/react-native/parameters.d.ts.map +1 -1
- package/dist/react-native/parameters.js.map +1 -1
- package/dist/react-native/responses.d.ts +8 -10
- package/dist/react-native/responses.d.ts.map +1 -1
- package/dist/react-native/responses.js.map +1 -1
- package/package.json +2 -2
|
@@ -19,52 +19,59 @@ function isUnexpected(response) {
|
|
|
19
19
|
const method = response.request.method;
|
|
20
20
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
21
21
|
if (!pathDetails) {
|
|
22
|
-
pathDetails =
|
|
22
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
23
23
|
}
|
|
24
24
|
return !pathDetails.includes(response.status);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function getParametrizedPathSuccess(method, path) {
|
|
27
|
+
var _a, _b, _c, _d;
|
|
27
28
|
const pathParts = path.split("/");
|
|
29
|
+
// Traverse list to match the longest candidate
|
|
30
|
+
// matchedLen: the length of candidate path
|
|
31
|
+
// matchedValue: the matched status code array
|
|
32
|
+
let matchedLen = -1, matchedValue = [];
|
|
28
33
|
// Iterate the responseMap to find a match
|
|
29
34
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
30
35
|
// Extracting the path from the map key which is in format
|
|
31
36
|
// GET /path/foo
|
|
37
|
+
if (!key.startsWith(method)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
32
40
|
const candidatePath = getPathFromMapKey(key);
|
|
33
41
|
// Get each part of the url path
|
|
34
42
|
const candidateParts = candidatePath.split("/");
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
// If the candidate part is not a template and
|
|
48
|
-
// the parts don't match mark the candidate as not found
|
|
49
|
-
// to move on with the next candidate path.
|
|
50
|
-
if (candidateParts[i] !== pathParts[i]) {
|
|
43
|
+
// track if we have found a match to return the values found.
|
|
44
|
+
let found = true;
|
|
45
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
46
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
47
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
48
|
+
// If the current part of the candidate is a "template" part
|
|
49
|
+
// Try to use the suffix of pattern to match the path
|
|
50
|
+
// {guid} ==> $
|
|
51
|
+
// {guid}:export ==> :export$
|
|
52
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
53
|
+
if (!isMatched) {
|
|
51
54
|
found = false;
|
|
52
55
|
break;
|
|
53
56
|
}
|
|
57
|
+
continue;
|
|
54
58
|
}
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
// the path
|
|
58
|
-
if (
|
|
59
|
-
|
|
59
|
+
// If the candidate part is not a template and
|
|
60
|
+
// the parts don't match mark the candidate as not found
|
|
61
|
+
// to move on with the next candidate path.
|
|
62
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
63
|
+
found = false;
|
|
64
|
+
break;
|
|
60
65
|
}
|
|
61
66
|
}
|
|
67
|
+
// We finished evaluating the current candidate parts
|
|
68
|
+
// Update the matched value if and only if we found the longer pattern
|
|
69
|
+
if (found && candidatePath.length > matchedLen) {
|
|
70
|
+
matchedLen = candidatePath.length;
|
|
71
|
+
matchedValue = value;
|
|
72
|
+
}
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
function hasParametrizedPath(path) {
|
|
67
|
-
return path.includes("/{");
|
|
74
|
+
return matchedValue;
|
|
68
75
|
}
|
|
69
76
|
function getPathFromMapKey(mapKey) {
|
|
70
77
|
const pathStart = mapKey.indexOf("/");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwElC,oCAoCC;AAtFD,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EA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MIT License.\n\nimport type {\n RoleAssignmentsCheckPrincipalAccess200Response,\n RoleAssignmentsCheckPrincipalAccessdefaultResponse,\n RoleAssignmentsListRoleAssignments200Response,\n RoleAssignmentsListRoleAssignmentsdefaultResponse,\n RoleAssignmentsCreateRoleAssignment200Response,\n RoleAssignmentsCreateRoleAssignmentdefaultResponse,\n RoleAssignmentsGetRoleAssignmentById200Response,\n RoleAssignmentsGetRoleAssignmentByIddefaultResponse,\n RoleAssignmentsDeleteRoleAssignmentById200Response,\n RoleAssignmentsDeleteRoleAssignmentById204Response,\n RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse,\n RoleDefinitionsListRoleDefinitions200Response,\n RoleDefinitionsListRoleDefinitionsdefaultResponse,\n RoleDefinitionsGetRoleDefinitionById200Response,\n RoleDefinitionsGetRoleDefinitionByIddefaultResponse,\n RoleDefinitionsListScopes200Response,\n RoleDefinitionsListScopesdefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /checkAccessSynapseRbac\": [\"200\"],\n \"GET /roleAssignments\": [\"200\"],\n \"PUT /roleAssignments/{roleAssignmentId}\": [\"200\"],\n \"GET /roleAssignments/{roleAssignmentId}\": [\"200\"],\n \"DELETE /roleAssignments/{roleAssignmentId}\": [\"200\", \"204\"],\n \"GET /roleDefinitions\": [\"200\"],\n \"GET /roleDefinitions/{roleDefinitionId}\": [\"200\"],\n \"GET /rbacScopes\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | RoleAssignmentsCheckPrincipalAccess200Response\n | RoleAssignmentsCheckPrincipalAccessdefaultResponse,\n): response is RoleAssignmentsCheckPrincipalAccessdefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsListRoleAssignments200Response\n | RoleAssignmentsListRoleAssignmentsdefaultResponse,\n): response is RoleAssignmentsListRoleAssignmentsdefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsCreateRoleAssignment200Response\n | RoleAssignmentsCreateRoleAssignmentdefaultResponse,\n): response is RoleAssignmentsCreateRoleAssignmentdefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsGetRoleAssignmentById200Response\n | RoleAssignmentsGetRoleAssignmentByIddefaultResponse,\n): response is RoleAssignmentsGetRoleAssignmentByIddefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsDeleteRoleAssignmentById200Response\n | RoleAssignmentsDeleteRoleAssignmentById204Response\n | RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse,\n): response is RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse;\nexport function isUnexpected(\n response:\n | RoleDefinitionsListRoleDefinitions200Response\n | RoleDefinitionsListRoleDefinitionsdefaultResponse,\n): response is RoleDefinitionsListRoleDefinitionsdefaultResponse;\nexport function isUnexpected(\n response:\n | RoleDefinitionsGetRoleDefinitionById200Response\n | RoleDefinitionsGetRoleDefinitionByIddefaultResponse,\n): response is RoleDefinitionsGetRoleDefinitionByIddefaultResponse;\nexport function isUnexpected(\n response: RoleDefinitionsListScopes200Response | RoleDefinitionsListScopesdefaultResponse,\n): response is RoleDefinitionsListScopesdefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsCheckPrincipalAccess200Response\n | RoleAssignmentsCheckPrincipalAccessdefaultResponse\n | RoleAssignmentsListRoleAssignments200Response\n | RoleAssignmentsListRoleAssignmentsdefaultResponse\n | RoleAssignmentsCreateRoleAssignment200Response\n | RoleAssignmentsCreateRoleAssignmentdefaultResponse\n | RoleAssignmentsGetRoleAssignmentById200Response\n | RoleAssignmentsGetRoleAssignmentByIddefaultResponse\n | RoleAssignmentsDeleteRoleAssignmentById200Response\n | RoleAssignmentsDeleteRoleAssignmentById204Response\n | RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse\n | RoleDefinitionsListRoleDefinitions200Response\n | RoleDefinitionsListRoleDefinitionsdefaultResponse\n | RoleDefinitionsGetRoleDefinitionById200Response\n | RoleDefinitionsGetRoleDefinitionByIddefaultResponse\n | RoleDefinitionsListScopes200Response\n | RoleDefinitionsListScopesdefaultResponse,\n): response is\n | RoleAssignmentsCheckPrincipalAccessdefaultResponse\n | RoleAssignmentsListRoleAssignmentsdefaultResponse\n | RoleAssignmentsCreateRoleAssignmentdefaultResponse\n | RoleAssignmentsGetRoleAssignmentByIddefaultResponse\n | RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse\n | RoleDefinitionsListRoleDefinitionsdefaultResponse\n | RoleDefinitionsGetRoleDefinitionByIddefaultResponse\n | RoleDefinitionsListScopesdefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (candidateParts.length === pathParts.length && hasParametrizedPath(key)) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (candidateParts[i].startsWith(\"{\") && candidateParts[i].endsWith(\"}\")) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwElC,oCAoCC;AAtFD,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;IACvC,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,yCAAyC,EAAE,CAAC,KAAK,CAAC;IAClD,yCAAyC,EAAE,CAAC,KAAK,CAAC;IAClD,4CAA4C,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC5D,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,yCAAyC,EAAE,CAAC,KAAK,CAAC;IAClD,iBAAiB,EAAE,CAAC,KAAK,CAAC;CAC3B,CAAC;AAyCF,SAAgB,YAAY,CAC1B,QAiB4C;IAU5C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IACvC,IAAI,WAAW,GAAG,WAAW,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,0BAA0B,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,0BAA0B,CAAC,MAAc,EAAE,IAAY;;IAC9D,M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AAG,IAAI,MAAM,CAAC,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAC1E,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CACnB,CAAC;gBAEF,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;gBACR,CAAC;gBACD,SAAS;YACX,CAAC;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n RoleAssignmentsCheckPrincipalAccess200Response,\n RoleAssignmentsCheckPrincipalAccessDefaultResponse,\n RoleAssignmentsListRoleAssignments200Response,\n RoleAssignmentsListRoleAssignmentsDefaultResponse,\n RoleAssignmentsCreateRoleAssignment200Response,\n RoleAssignmentsCreateRoleAssignmentDefaultResponse,\n RoleAssignmentsGetRoleAssignmentById200Response,\n RoleAssignmentsGetRoleAssignmentByIdDefaultResponse,\n RoleAssignmentsDeleteRoleAssignmentById200Response,\n RoleAssignmentsDeleteRoleAssignmentById204Response,\n RoleAssignmentsDeleteRoleAssignmentByIdDefaultResponse,\n RoleDefinitionsListRoleDefinitions200Response,\n RoleDefinitionsListRoleDefinitionsDefaultResponse,\n RoleDefinitionsGetRoleDefinitionById200Response,\n RoleDefinitionsGetRoleDefinitionByIdDefaultResponse,\n RoleDefinitionsListScopes200Response,\n RoleDefinitionsListScopesDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /checkAccessSynapseRbac\": [\"200\"],\n \"GET /roleAssignments\": [\"200\"],\n \"PUT /roleAssignments/{roleAssignmentId}\": [\"200\"],\n \"GET /roleAssignments/{roleAssignmentId}\": [\"200\"],\n \"DELETE /roleAssignments/{roleAssignmentId}\": [\"200\", \"204\"],\n \"GET /roleDefinitions\": [\"200\"],\n \"GET /roleDefinitions/{roleDefinitionId}\": [\"200\"],\n \"GET /rbacScopes\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | RoleAssignmentsCheckPrincipalAccess200Response\n | RoleAssignmentsCheckPrincipalAccessDefaultResponse,\n): response is RoleAssignmentsCheckPrincipalAccessDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsListRoleAssignments200Response\n | RoleAssignmentsListRoleAssignmentsDefaultResponse,\n): response is RoleAssignmentsListRoleAssignmentsDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsCreateRoleAssignment200Response\n | RoleAssignmentsCreateRoleAssignmentDefaultResponse,\n): response is RoleAssignmentsCreateRoleAssignmentDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsGetRoleAssignmentById200Response\n | RoleAssignmentsGetRoleAssignmentByIdDefaultResponse,\n): response is RoleAssignmentsGetRoleAssignmentByIdDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsDeleteRoleAssignmentById200Response\n | RoleAssignmentsDeleteRoleAssignmentById204Response\n | RoleAssignmentsDeleteRoleAssignmentByIdDefaultResponse,\n): response is RoleAssignmentsDeleteRoleAssignmentByIdDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleDefinitionsListRoleDefinitions200Response\n | RoleDefinitionsListRoleDefinitionsDefaultResponse,\n): response is RoleDefinitionsListRoleDefinitionsDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleDefinitionsGetRoleDefinitionById200Response\n | RoleDefinitionsGetRoleDefinitionByIdDefaultResponse,\n): response is RoleDefinitionsGetRoleDefinitionByIdDefaultResponse;\nexport function isUnexpected(\n response: RoleDefinitionsListScopes200Response | RoleDefinitionsListScopesDefaultResponse,\n): response is RoleDefinitionsListScopesDefaultResponse;\nexport function isUnexpected(\n response:\n | RoleAssignmentsCheckPrincipalAccess200Response\n | RoleAssignmentsCheckPrincipalAccessDefaultResponse\n | RoleAssignmentsListRoleAssignments200Response\n | RoleAssignmentsListRoleAssignmentsDefaultResponse\n | RoleAssignmentsCreateRoleAssignment200Response\n | RoleAssignmentsCreateRoleAssignmentDefaultResponse\n | RoleAssignmentsGetRoleAssignmentById200Response\n | RoleAssignmentsGetRoleAssignmentByIdDefaultResponse\n | RoleAssignmentsDeleteRoleAssignmentById200Response\n | RoleAssignmentsDeleteRoleAssignmentById204Response\n | RoleAssignmentsDeleteRoleAssignmentByIdDefaultResponse\n | RoleDefinitionsListRoleDefinitions200Response\n | RoleDefinitionsListRoleDefinitionsDefaultResponse\n | RoleDefinitionsGetRoleDefinitionById200Response\n | RoleDefinitionsGetRoleDefinitionByIdDefaultResponse\n | RoleDefinitionsListScopes200Response\n | RoleDefinitionsListScopesDefaultResponse,\n): response is\n | RoleAssignmentsCheckPrincipalAccessDefaultResponse\n | RoleAssignmentsListRoleAssignmentsDefaultResponse\n | RoleAssignmentsCreateRoleAssignmentDefaultResponse\n | RoleAssignmentsGetRoleAssignmentByIdDefaultResponse\n | RoleAssignmentsDeleteRoleAssignmentByIdDefaultResponse\n | RoleDefinitionsListRoleDefinitionsDefaultResponse\n | RoleDefinitionsGetRoleDefinitionByIdDefaultResponse\n | RoleDefinitionsListScopesDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,qCAA+C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.logger = void 0;
|
|
6
|
+
const logger_1 = require("@azure/logger");
|
|
7
|
+
exports.logger = (0, logger_1.createClientLogger)("synapse-access-control");
|
|
8
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,0CAAmD;AACtC,QAAA,MAAM,GAAG,IAAA,2BAAkB,EAAC,wBAAwB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"synapse-access-control\");\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Check access request details */
|
|
1
2
|
export interface CheckPrincipalAccessRequest {
|
|
2
3
|
/** Subject details */
|
|
3
4
|
subject: SubjectInfo;
|
|
@@ -6,6 +7,7 @@ export interface CheckPrincipalAccessRequest {
|
|
|
6
7
|
/** Scope at which the check access is done. */
|
|
7
8
|
scope: string;
|
|
8
9
|
}
|
|
10
|
+
/** Subject details */
|
|
9
11
|
export interface SubjectInfo {
|
|
10
12
|
/**
|
|
11
13
|
* Principal Id
|
|
@@ -16,12 +18,14 @@ export interface SubjectInfo {
|
|
|
16
18
|
/** List of group Ids that the principalId is part of. */
|
|
17
19
|
groupIds?: Array<string>;
|
|
18
20
|
}
|
|
21
|
+
/** Action Info */
|
|
19
22
|
export interface RequiredAction {
|
|
20
23
|
/** Action Id. */
|
|
21
24
|
id: string;
|
|
22
25
|
/** Is a data action or not. */
|
|
23
26
|
isDataAction: boolean;
|
|
24
27
|
}
|
|
28
|
+
/** Role Assignment request details */
|
|
25
29
|
export interface RoleAssignmentRequest {
|
|
26
30
|
/**
|
|
27
31
|
* Role ID of the Synapse Built-In Role
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,2BAA2B;IAC1C,sBAAsB;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,uBAAuB;IACvB,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA,mCAAmC;AACnC,MAAM,WAAW,2BAA2B;IAC1C,sBAAsB;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,uBAAuB;IACvB,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sBAAsB;AACtB,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,kBAAkB;AAClB,MAAM,WAAW,cAAc;IAC7B,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport interface CheckPrincipalAccessRequest {\n /** Subject details */\n subject: SubjectInfo;\n /** List of actions. */\n actions: Array<RequiredAction>;\n /** Scope at which the check access is done. */\n scope: string;\n}\n\nexport interface SubjectInfo {\n /**\n * Principal Id\n *\n * Value may contain a UUID\n */\n principalId: string;\n /** List of group Ids that the principalId is part of. */\n groupIds?: Array<string>;\n}\n\nexport interface RequiredAction {\n /** Action Id. */\n id: string;\n /** Is a data action or not. */\n isDataAction: boolean;\n}\n\nexport interface RoleAssignmentRequest {\n /**\n * Role ID of the Synapse Built-In Role\n *\n * Value may contain a UUID\n */\n roleId: string;\n /**\n * Object ID of the AAD principal or security-group\n *\n * Value may contain a UUID\n */\n principalId: string;\n /** Scope at which the role assignment is created */\n scope: string;\n /** Type of the principal Id: User, Group or ServicePrincipal */\n principalType?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/** Check access request details */\nexport interface CheckPrincipalAccessRequest {\n /** Subject details */\n subject: SubjectInfo;\n /** List of actions. */\n actions: Array<RequiredAction>;\n /** Scope at which the check access is done. */\n scope: string;\n}\n\n/** Subject details */\nexport interface SubjectInfo {\n /**\n * Principal Id\n *\n * Value may contain a UUID\n */\n principalId: string;\n /** List of group Ids that the principalId is part of. */\n groupIds?: Array<string>;\n}\n\n/** Action Info */\nexport interface RequiredAction {\n /** Action Id. */\n id: string;\n /** Is a data action or not. */\n isDataAction: boolean;\n}\n\n/** Role Assignment request details */\nexport interface RoleAssignmentRequest {\n /**\n * Role ID of the Synapse Built-In Role\n *\n * Value may contain a UUID\n */\n roleId: string;\n /**\n * Object ID of the AAD principal or security-group\n *\n * Value may contain a UUID\n */\n principalId: string;\n /** Scope at which the role assignment is created */\n scope: string;\n /** Type of the principal Id: User, Group or ServicePrincipal */\n principalType?: string;\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/** Check access response details */
|
|
1
2
|
export interface CheckPrincipalAccessResponseOutput {
|
|
2
3
|
/** To check if the current user, group, or service principal has permission to read artifacts in the specified workspace. */
|
|
3
4
|
AccessDecisions?: Array<CheckAccessDecisionOutput>;
|
|
4
5
|
}
|
|
6
|
+
/** Check access response details */
|
|
5
7
|
export interface CheckAccessDecisionOutput {
|
|
6
8
|
/** Access Decision. */
|
|
7
9
|
accessDecision?: string;
|
|
@@ -10,6 +12,7 @@ export interface CheckAccessDecisionOutput {
|
|
|
10
12
|
/** Role Assignment response details */
|
|
11
13
|
roleAssignment?: RoleAssignmentDetailsOutput;
|
|
12
14
|
}
|
|
15
|
+
/** Role Assignment response details */
|
|
13
16
|
export interface RoleAssignmentDetailsOutput {
|
|
14
17
|
/** Role Assignment ID */
|
|
15
18
|
id?: string;
|
|
@@ -30,34 +33,39 @@ export interface RoleAssignmentDetailsOutput {
|
|
|
30
33
|
/** Type of the principal Id: User, Group or ServicePrincipal */
|
|
31
34
|
principalType?: string;
|
|
32
35
|
}
|
|
36
|
+
/** Contains details when the response code indicates an error. */
|
|
33
37
|
export interface ErrorContractOutput {
|
|
34
38
|
/** The error details. */
|
|
35
39
|
error?: ErrorResponseOutput;
|
|
36
40
|
}
|
|
41
|
+
/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */
|
|
37
42
|
export interface ErrorResponseOutput {
|
|
38
43
|
/** The error code. */
|
|
39
|
-
code?: string;
|
|
44
|
+
readonly code?: string;
|
|
40
45
|
/** The error message. */
|
|
41
|
-
message?: string;
|
|
46
|
+
readonly message?: string;
|
|
42
47
|
/** The error target. */
|
|
43
|
-
target?: string;
|
|
48
|
+
readonly target?: string;
|
|
44
49
|
/** The error details. */
|
|
45
|
-
details?: Array<ErrorResponseOutput>;
|
|
50
|
+
readonly details?: Array<ErrorResponseOutput>;
|
|
46
51
|
/** The error additional info. */
|
|
47
|
-
additionalInfo?: Array<ErrorAdditionalInfoOutput>;
|
|
52
|
+
readonly additionalInfo?: Array<ErrorAdditionalInfoOutput>;
|
|
48
53
|
}
|
|
54
|
+
/** The resource management error additional info. */
|
|
49
55
|
export interface ErrorAdditionalInfoOutput {
|
|
50
56
|
/** The additional info type. */
|
|
51
|
-
type?: string;
|
|
57
|
+
readonly type?: string;
|
|
52
58
|
/** The additional info. */
|
|
53
|
-
info?: Record<string, unknown>;
|
|
59
|
+
readonly info?: Record<string, unknown>;
|
|
54
60
|
}
|
|
61
|
+
/** Role Assignment response details */
|
|
55
62
|
export interface RoleAssignmentDetailsListOutput {
|
|
56
63
|
/** Number of role assignments */
|
|
57
64
|
count?: number;
|
|
58
65
|
/** A list of role assignments */
|
|
59
66
|
value?: Array<RoleAssignmentDetailsOutput>;
|
|
60
67
|
}
|
|
68
|
+
/** Synapse role definition details */
|
|
61
69
|
export interface SynapseRoleDefinitionOutput {
|
|
62
70
|
/**
|
|
63
71
|
* Role Definition ID
|
|
@@ -78,6 +86,7 @@ export interface SynapseRoleDefinitionOutput {
|
|
|
78
86
|
/** Availability of the Synapse role */
|
|
79
87
|
availabilityStatus?: string;
|
|
80
88
|
}
|
|
89
|
+
/** Synapse role definition details */
|
|
81
90
|
export interface SynapseRbacPermissionOutput {
|
|
82
91
|
/** List of actions */
|
|
83
92
|
actions?: Array<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outputModels.d.ts","sourceRoot":"","sources":["../../src/outputModels.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kCAAkC;IACjD,6HAA6H;IAC7H,eAAe,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,yBAAyB;IACxC,uBAAuB;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,cAAc,CAAC,EAAE,2BAA2B,CAAC;CAC9C;AAED,MAAM,WAAW,2BAA2B;IAC1C,yBAAyB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,yBAAyB;IACzB,KAAK,CAAC,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"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sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport interface CheckPrincipalAccessResponseOutput {\n /** To check if the current user, group, or service principal has permission to read artifacts in the specified workspace. */\n AccessDecisions?: Array<CheckAccessDecisionOutput>;\n}\n\nexport interface CheckAccessDecisionOutput {\n /** Access Decision. */\n accessDecision?: string;\n /** Action Id. */\n actionId?: string;\n /** Role Assignment response details */\n roleAssignment?: RoleAssignmentDetailsOutput;\n}\n\nexport interface RoleAssignmentDetailsOutput {\n /** Role Assignment ID */\n id?: string;\n /**\n * Role ID of the Synapse Built-In Role\n *\n * Value may contain a UUID\n */\n roleDefinitionId?: string;\n /**\n * Object ID of the AAD principal or security-group\n *\n * Value may contain a UUID\n */\n principalId?: string;\n /** Scope at the role assignment is created */\n scope?: string;\n /** Type of the principal Id: User, Group or ServicePrincipal */\n principalType?: string;\n}\n\nexport interface ErrorContractOutput {\n /** The error details. */\n error?: ErrorResponseOutput;\n}\n\nexport interface ErrorResponseOutput {\n /** The error code. */\n code?: string;\n /** The error message. */\n message?: string;\n /** The error target. */\n target?: string;\n /** The error details. */\n details?: Array<ErrorResponseOutput>;\n /** The error additional info. */\n additionalInfo?: Array<ErrorAdditionalInfoOutput>;\n}\n\nexport interface ErrorAdditionalInfoOutput {\n /** The additional info type. */\n type?: string;\n /** The additional info. */\n info?: Record<string, unknown>;\n}\n\nexport interface RoleAssignmentDetailsListOutput {\n /** Number of role assignments */\n count?: number;\n /** A list of role assignments */\n value?: Array<RoleAssignmentDetailsOutput>;\n}\n\nexport interface SynapseRoleDefinitionOutput {\n /**\n * Role Definition ID\n *\n * Value may contain a UUID\n */\n id?: string;\n /** Name of the Synapse role */\n name?: string;\n /** Is a built-in role or not */\n isBuiltIn?: boolean;\n /** Description for the Synapse role */\n description?: string;\n /** Permissions for the Synapse role */\n permissions?: Array<SynapseRbacPermissionOutput>;\n /** Allowed scopes for the Synapse role */\n scopes?: Array<string>;\n /** Availability of the Synapse role */\n availabilityStatus?: string;\n}\n\nexport interface SynapseRbacPermissionOutput {\n /** List of actions */\n actions?: Array<string>;\n /** List of Not actions */\n notActions?: Array<string>;\n /** List of data actions */\n dataActions?: Array<string>;\n /** List of Not data actions */\n notDataActions?: Array<string>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../src/outputModels.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/** Check access response details */\nexport interface CheckPrincipalAccessResponseOutput {\n /** To check if the current user, group, or service principal has permission to read artifacts in the specified workspace. */\n AccessDecisions?: Array<CheckAccessDecisionOutput>;\n}\n\n/** Check access response details */\nexport interface CheckAccessDecisionOutput {\n /** Access Decision. */\n accessDecision?: string;\n /** Action Id. */\n actionId?: string;\n /** Role Assignment response details */\n roleAssignment?: RoleAssignmentDetailsOutput;\n}\n\n/** Role Assignment response details */\nexport interface RoleAssignmentDetailsOutput {\n /** Role Assignment ID */\n id?: string;\n /**\n * Role ID of the Synapse Built-In Role\n *\n * Value may contain a UUID\n */\n roleDefinitionId?: string;\n /**\n * Object ID of the AAD principal or security-group\n *\n * Value may contain a UUID\n */\n principalId?: string;\n /** Scope at the role assignment is created */\n scope?: string;\n /** Type of the principal Id: User, Group or ServicePrincipal */\n principalType?: string;\n}\n\n/** Contains details when the response code indicates an error. */\nexport interface ErrorContractOutput {\n /** The error details. */\n error?: ErrorResponseOutput;\n}\n\n/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */\nexport interface ErrorResponseOutput {\n /** The error code. */\n readonly code?: string;\n /** The error message. */\n readonly message?: string;\n /** The error target. */\n readonly target?: string;\n /** The error details. */\n readonly details?: Array<ErrorResponseOutput>;\n /** The error additional info. */\n readonly additionalInfo?: Array<ErrorAdditionalInfoOutput>;\n}\n\n/** The resource management error additional info. */\nexport interface ErrorAdditionalInfoOutput {\n /** The additional info type. */\n readonly type?: string;\n /** The additional info. */\n readonly info?: Record<string, unknown>;\n}\n\n/** Role Assignment response details */\nexport interface RoleAssignmentDetailsListOutput {\n /** Number of role assignments */\n count?: number;\n /** A list of role assignments */\n value?: Array<RoleAssignmentDetailsOutput>;\n}\n\n/** Synapse role definition details */\nexport interface SynapseRoleDefinitionOutput {\n /**\n * Role Definition ID\n *\n * Value may contain a UUID\n */\n id?: string;\n /** Name of the Synapse role */\n name?: string;\n /** Is a built-in role or not */\n isBuiltIn?: boolean;\n /** Description for the Synapse role */\n description?: string;\n /** Permissions for the Synapse role */\n permissions?: Array<SynapseRbacPermissionOutput>;\n /** Allowed scopes for the Synapse role */\n scopes?: Array<string>;\n /** Availability of the Synapse role */\n availabilityStatus?: string;\n}\n\n/** Synapse role definition details */\nexport interface SynapseRbacPermissionOutput {\n /** List of actions */\n actions?: Array<string>;\n /** List of Not actions */\n notActions?: Array<string>;\n /** List of data actions */\n dataActions?: Array<string>;\n /** List of Not data actions */\n notDataActions?: Array<string>;\n}\n"]}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import type { PagedAsyncIterableIterator } from "@azure/core-paging";
|
|
2
1
|
import type { Client, PathUncheckedResponse } from "@azure-rest/core-client";
|
|
2
|
+
/**
|
|
3
|
+
* An interface that tracks the settings for paged iteration
|
|
4
|
+
*/
|
|
5
|
+
export interface PageSettings {
|
|
6
|
+
/**
|
|
7
|
+
* The token that keeps track of where to continue the iterator
|
|
8
|
+
*/
|
|
9
|
+
continuationToken?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An interface that allows async iterable iteration both to completion and by page.
|
|
13
|
+
*/
|
|
14
|
+
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
15
|
+
/**
|
|
16
|
+
* The next method, part of the iteration protocol
|
|
17
|
+
*/
|
|
18
|
+
next(): Promise<IteratorResult<TElement>>;
|
|
19
|
+
/**
|
|
20
|
+
* The connection to the async iterator, part of the iteration protocol
|
|
21
|
+
*/
|
|
22
|
+
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
|
23
|
+
/**
|
|
24
|
+
* Return an AsyncIterableIterator that works a page at a time
|
|
25
|
+
*/
|
|
26
|
+
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
|
|
27
|
+
}
|
|
3
28
|
/**
|
|
4
29
|
* Helper type to extract the type of an array
|
|
5
30
|
*/
|
|
@@ -7,7 +32,7 @@ export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
|
|
|
7
32
|
/**
|
|
8
33
|
* The type of a custom function that defines how to get a page and a link to the next one if any.
|
|
9
34
|
*/
|
|
10
|
-
export type GetPage<TPage> = (pageLink: string
|
|
35
|
+
export type GetPage<TPage> = (pageLink: string) => Promise<{
|
|
11
36
|
page: TPage;
|
|
12
37
|
nextPageLink?: string;
|
|
13
38
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginateHelper.d.ts","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"paginateHelper.d.ts","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAuF7E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrF;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpE;AAyBD;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACzD,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,SAAS;IACtC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;CACtD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,IAAI,OAAO,SAAS;IACpD,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAA;KAAE,CAAC;CAC/B,GACG,YAAY,CAAC,KAAK,CAAC,GACnB,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,qBAAqB,EAC9D,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,SAAS,EAC1B,OAAO,GAAE,aAAa,CAAC,SAAS,CAAM,GACrC,0BAA0B,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CA0BvD"}
|
|
@@ -3,8 +3,105 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.paginate = paginate;
|
|
6
|
-
const
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
7
|
const core_client_1 = require("@azure-rest/core-client");
|
|
8
|
+
/**
|
|
9
|
+
* returns an async iterator that iterates over results. It also has a `byPage`
|
|
10
|
+
* method that returns pages of items at once.
|
|
11
|
+
*
|
|
12
|
+
* @param pagedResult - an object that specifies how to get pages.
|
|
13
|
+
* @returns a paged async iterator that iterates over results.
|
|
14
|
+
*/
|
|
15
|
+
function getPagedAsyncIterator(pagedResult) {
|
|
16
|
+
var _a;
|
|
17
|
+
const iter = getItemAsyncIterator(pagedResult);
|
|
18
|
+
return {
|
|
19
|
+
next() {
|
|
20
|
+
return iter.next();
|
|
21
|
+
},
|
|
22
|
+
[Symbol.asyncIterator]() {
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
|
|
26
|
+
const { continuationToken } = settings !== null && settings !== void 0 ? settings : {};
|
|
27
|
+
return getPageAsyncIterator(pagedResult, {
|
|
28
|
+
pageLink: continuationToken,
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getItemAsyncIterator(pagedResult) {
|
|
34
|
+
return tslib_1.__asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
|
|
35
|
+
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
36
|
+
const pages = getPageAsyncIterator(pagedResult);
|
|
37
|
+
const firstVal = yield tslib_1.__await(pages.next());
|
|
38
|
+
// if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
|
|
39
|
+
if (!Array.isArray(firstVal.value)) {
|
|
40
|
+
// can extract elements from this page
|
|
41
|
+
const { toElements } = pagedResult;
|
|
42
|
+
if (toElements) {
|
|
43
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(firstVal.value))));
|
|
44
|
+
try {
|
|
45
|
+
for (var _g = true, pages_1 = tslib_1.__asyncValues(pages), pages_1_1; pages_1_1 = yield tslib_1.__await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
|
|
46
|
+
_c = pages_1_1.value;
|
|
47
|
+
_g = false;
|
|
48
|
+
const page = _c;
|
|
49
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(page))));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
if (!_g && !_a && (_b = pages_1.return)) yield tslib_1.__await(_b.call(pages_1));
|
|
56
|
+
}
|
|
57
|
+
finally { if (e_1) throw e_1.error; }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
yield yield tslib_1.__await(firstVal.value);
|
|
62
|
+
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
|
|
63
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(pages)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(firstVal.value)));
|
|
68
|
+
try {
|
|
69
|
+
for (var _h = true, pages_2 = tslib_1.__asyncValues(pages), pages_2_1; pages_2_1 = yield tslib_1.__await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
|
|
70
|
+
_f = pages_2_1.value;
|
|
71
|
+
_h = false;
|
|
72
|
+
const page = _f;
|
|
73
|
+
// pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
|
|
74
|
+
// it must be the case that `TPage = TElement[]`
|
|
75
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
79
|
+
finally {
|
|
80
|
+
try {
|
|
81
|
+
if (!_h && !_d && (_e = pages_2.return)) yield tslib_1.__await(_e.call(pages_2));
|
|
82
|
+
}
|
|
83
|
+
finally { if (e_2) throw e_2.error; }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function getPageAsyncIterator(pagedResult_1) {
|
|
89
|
+
return tslib_1.__asyncGenerator(this, arguments, function* getPageAsyncIterator_1(pagedResult, options = {}) {
|
|
90
|
+
const { pageLink } = options;
|
|
91
|
+
let response = yield tslib_1.__await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink));
|
|
92
|
+
if (!response) {
|
|
93
|
+
return yield tslib_1.__await(void 0);
|
|
94
|
+
}
|
|
95
|
+
yield yield tslib_1.__await(response.page);
|
|
96
|
+
while (response.nextPageLink) {
|
|
97
|
+
response = yield tslib_1.__await(pagedResult.getPage(response.nextPageLink));
|
|
98
|
+
if (!response) {
|
|
99
|
+
return yield tslib_1.__await(void 0);
|
|
100
|
+
}
|
|
101
|
+
yield yield tslib_1.__await(response.page);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
8
105
|
/**
|
|
9
106
|
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
10
107
|
* @param client - Client to use for sending the next page requests
|
|
@@ -33,7 +130,7 @@ function paginate(client, initialResponse, options = {}) {
|
|
|
33
130
|
};
|
|
34
131
|
},
|
|
35
132
|
};
|
|
36
|
-
return
|
|
133
|
+
return getPagedAsyncIterator(pagedResult);
|
|
37
134
|
}
|
|
38
135
|
/**
|
|
39
136
|
* Gets for the value of nextLink in the body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqDlC,4BA8BC;AAhFD,oDAA2D;AAE3D,yDAA0D;AAyC1D;;;;;;GAMG;AACH,SAAgB,QAAQ,CACtB,MAAc,EACd,eAA0B,EAC1B,UA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,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAc,IAAa,EAAE,QAAgB;IAC/D,MAAM,KAAK,GAAI,IAAgC,CAAC,QAAQ,CAAQ,CAAC;IAEjE,qEAAqE;IACrE,qEAAqE;IACrE,iDAAiD;IACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,kFAAkF,QAAQ,EAAE,CAC7F,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,QAA+B;IACzD,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,IAAA,6BAAe,EACnB,gDAAgD,QAAQ,CAAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { getPagedAsyncIterator } from \"@azure/core-paging\";\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number,\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA2LlC,4BA8BC;;AAtND,yDAA0D;AAE1D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAM5B,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,mCAClB,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC;YAC7C,OAAO,oBAAoB,CAAC,WAAW,EAAE;gBACvC,QAAQ,EAAE,iBAAiD;aAC5D,CAA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C,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,IAAA,6BAAe,EACnB,gDAAgD,QAAQ,CAAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nfunction getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string,\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n (((settings?: PageSettings) => {\n const { continuationToken } = settings ?? {};\n return getPageAsyncIterator(pagedResult, {\n pageLink: continuationToken as unknown as TLink | undefined,\n });\n }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator<TPage>),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n // can extract elements from this page\n const { toElements } = pagedResult;\n if (toElements) {\n yield* toElements(firstVal.value) as TElement[];\n for await (const page of pages) {\n yield* toElements(page) as TElement[];\n }\n } else {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n }\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n options: {\n pageLink?: TLink;\n } = {},\n): AsyncIterableIterator<TPage> {\n const { pageLink } = options;\n let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n }\n}\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n}\n\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<TElement>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\ninterface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (pageLink: TLink) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>;\n /**\n * a function to implement the `byPage` method on the paged async iterator.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n\n /**\n * A function to extract elements from a page.\n */\n toElements?: (page: TPage) => unknown[];\n}\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (pageLink: string) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n"]}
|
|
@@ -26,7 +26,7 @@ export interface RoleAssignmentsListRoleAssignmentsQueryParam {
|
|
|
26
26
|
queryParameters?: RoleAssignmentsListRoleAssignmentsQueryParamProperties;
|
|
27
27
|
}
|
|
28
28
|
export interface RoleAssignmentsListRoleAssignmentsHeaderParam {
|
|
29
|
-
headers
|
|
29
|
+
headers?: RawHttpHeadersInput & RoleAssignmentsListRoleAssignmentsHeaders;
|
|
30
30
|
}
|
|
31
31
|
export type RoleAssignmentsListRoleAssignmentsParameters = RoleAssignmentsListRoleAssignmentsQueryParam & RoleAssignmentsListRoleAssignmentsHeaderParam & RequestParameters;
|
|
32
32
|
export interface RoleAssignmentsCreateRoleAssignmentBodyParam {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEtF,MAAM,WAAW,4CAA4C;IAC3D,uDAAuD;IACvD,IAAI,EAAE,2BAA2B,CAAC;CACnC;AAED,MAAM,WAAW,kDAAkD;IACjE,2BAA2B;IAC3B,WAAW,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAAC;CAChD;AAED,MAAM,MAAM,6CAA6C,GACvD,kDAAkD,GAChD,4CAA4C,GAC5C,iBAAiB,CAAC;AAEtB,MAAM,WAAW,yCAAyC;IACxD,0BAA0B;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,sDAAsD;IACrE,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4CAA4C;IAC3D,eAAe,CAAC,EAAE,sDAAsD,CAAC;CAC1E;AAED,MAAM,WAAW,6CAA6C;IAC5D,OAAO,EAAE,mBAAmB,GAAG,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KA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C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iDAAiD;IAChE,eAAe,CAAC,EAAE,2DAA2D,CAAC;CAC/E;AAED,MAAM,MAAM,iDAAiD,GAC3D,iDAAiD,GAAG,iBAAiB,CAAC;AAExE,MAAM,WAAW,sDAAsD;IACrE,yCAAyC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4CAA4C;IAC3D,eAAe,CAAC,EAAE,sDAAsD,CAAC;CAC1E;AAED,MAAM,MAAM,4CAA4C,GACtD,4CAA4C,GAAG,iBAAiB,CAAC;AACnE,MAAM,MAAM,8CAA8C,GAAG,iBAAiB,CAAC;AAC/E,MAAM,MAAM,mCAAmC,GAAG,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { RequestParameters } from \"@azure-rest/core-client\";\nimport type { CheckPrincipalAccessRequest, RoleAssignmentRequest } from \"./models.js\";\n\nexport interface RoleAssignmentsCheckPrincipalAccessBodyParam {\n /** Details of scope, list of actions and principal. */\n body: CheckPrincipalAccessRequest;\n}\n\nexport interface RoleAssignmentsCheckPrincipalAccessMediaTypesParam {\n /** Request content type */\n contentType?: \"application/json\" | \"text/json\";\n}\n\nexport type RoleAssignmentsCheckPrincipalAccessParameters =\n RoleAssignmentsCheckPrincipalAccessMediaTypesParam &\n RoleAssignmentsCheckPrincipalAccessBodyParam &\n RequestParameters;\n\nexport interface RoleAssignmentsListRoleAssignmentsHeaders {\n /** Continuation token. */\n \"x-ms-continuation\"?: string;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsQueryParamProperties {\n /** Synapse Built-In Role Id. */\n roleId?: string;\n /** Object ID of the AAD principal or security-group. */\n principalId?: string;\n /** Scope of the Synapse Built-in Role. */\n scope?: string;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsQueryParam {\n queryParameters?: RoleAssignmentsListRoleAssignmentsQueryParamProperties;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsHeaderParam {\n headers
|
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { RequestParameters } from \"@azure-rest/core-client\";\nimport type { CheckPrincipalAccessRequest, RoleAssignmentRequest } from \"./models.js\";\n\nexport interface RoleAssignmentsCheckPrincipalAccessBodyParam {\n /** Details of scope, list of actions and principal. */\n body: CheckPrincipalAccessRequest;\n}\n\nexport interface RoleAssignmentsCheckPrincipalAccessMediaTypesParam {\n /** Request content type */\n contentType?: \"application/json\" | \"text/json\";\n}\n\nexport type RoleAssignmentsCheckPrincipalAccessParameters =\n RoleAssignmentsCheckPrincipalAccessMediaTypesParam &\n RoleAssignmentsCheckPrincipalAccessBodyParam &\n RequestParameters;\n\nexport interface RoleAssignmentsListRoleAssignmentsHeaders {\n /** Continuation token. */\n \"x-ms-continuation\"?: string;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsQueryParamProperties {\n /** Synapse Built-In Role Id. */\n roleId?: string;\n /** Object ID of the AAD principal or security-group. */\n principalId?: string;\n /** Scope of the Synapse Built-in Role. */\n scope?: string;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsQueryParam {\n queryParameters?: RoleAssignmentsListRoleAssignmentsQueryParamProperties;\n}\n\nexport interface RoleAssignmentsListRoleAssignmentsHeaderParam {\n headers?: RawHttpHeadersInput & RoleAssignmentsListRoleAssignmentsHeaders;\n}\n\nexport type RoleAssignmentsListRoleAssignmentsParameters =\n RoleAssignmentsListRoleAssignmentsQueryParam &\n RoleAssignmentsListRoleAssignmentsHeaderParam &\n RequestParameters;\n\nexport interface RoleAssignmentsCreateRoleAssignmentBodyParam {\n /** Details of role id, scope and object id. */\n body: RoleAssignmentRequest;\n}\n\nexport interface RoleAssignmentsCreateRoleAssignmentMediaTypesParam {\n /** Request content type */\n contentType?: \"application/json\" | \"text/json\";\n}\n\nexport type RoleAssignmentsCreateRoleAssignmentParameters =\n RoleAssignmentsCreateRoleAssignmentMediaTypesParam &\n RoleAssignmentsCreateRoleAssignmentBodyParam &\n RequestParameters;\nexport type RoleAssignmentsGetRoleAssignmentByIdParameters = RequestParameters;\n\nexport interface RoleAssignmentsDeleteRoleAssignmentByIdQueryParamProperties {\n /** Scope of the Synapse Built-in Role. */\n scope?: string;\n}\n\nexport interface RoleAssignmentsDeleteRoleAssignmentByIdQueryParam {\n queryParameters?: RoleAssignmentsDeleteRoleAssignmentByIdQueryParamProperties;\n}\n\nexport type RoleAssignmentsDeleteRoleAssignmentByIdParameters =\n RoleAssignmentsDeleteRoleAssignmentByIdQueryParam & RequestParameters;\n\nexport interface RoleDefinitionsListRoleDefinitionsQueryParamProperties {\n /** Is a Synapse Built-In Role or not. */\n isBuiltIn?: boolean;\n /** Scope of the Synapse Built-in Role. */\n scope?: string;\n}\n\nexport interface RoleDefinitionsListRoleDefinitionsQueryParam {\n queryParameters?: RoleDefinitionsListRoleDefinitionsQueryParamProperties;\n}\n\nexport type RoleDefinitionsListRoleDefinitionsParameters =\n RoleDefinitionsListRoleDefinitionsQueryParam & RequestParameters;\nexport type RoleDefinitionsGetRoleDefinitionByIdParameters = RequestParameters;\nexport type RoleDefinitionsListScopesParameters = RequestParameters;\n"]}
|