• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript azure-devops-extension-api.getClient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中azure-devops-extension-api.getClient函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getClient函数的具体用法?TypeScript getClient怎么用?TypeScript getClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getClient函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getIterations

    async getIterations(
        projectId: string,
        iterations: [string, string][]
    ): Promise<IIteration[]> {
        const client = getClient(WorkRestClient);

        const result = await Promise.all(
            iterations.map(([teamId, iterationId]) =>
                client
                    .getTeamIteration(
                        {
                            project: "",
                            projectId,
                            team: "",
                            teamId
                        },
                        iterationId
                    )
                    .then(
                        x =>
                            ({
                                id: x.id,
                                name: x.name
                            } as IIteration)
                    )
                    .catch(() => null)
            )
        );

        return result.filter(x => x !== null) as IIteration[];
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:31,代码来源:sprints.ts


示例2: getAllTeams

 public async getAllTeams(projectId: string): Promise<ITeam[]> {
     const client = getClient(CoreRestClient);
     const teams = await client.getTeams(projectId);
     return teams.map(({ id, name }) => ({
         id,
         name
     }));
 }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:8,代码来源:teams.ts


示例3: getWorkItemTypes

    async getWorkItemTypes(projectId: string): Promise<IWorkItemType[]> {
        // Get type fields
        const workClient = getClient(WorkRestClient);
        const processConfig = await workClient.getProcessConfiguration(
            projectId
        );
        const effortField = processConfig.typeFields["Effort"]!;

        const client = getClient(WorkItemTrackingRestClient);
        const workItemTypes = await client.getWorkItemTypes(projectId);

        // Merge with config
        const sessionService = Services.getService<ISessionService>(
            SessionServiceId
        );
        const configuration = await sessionService.getSettingsValue<{
            [name: string]: IWorkItemType;
        }>(projectId, FieldConfiguration);

        return workItemTypes.map(wi => {
            let estimationFieldRefName: string | undefined;

            if (
                wi.fields.some(
                    f =>
                        f.referenceName.toLocaleLowerCase() ===
                        effortField.referenceName.toLocaleLowerCase()
                )
            ) {
                // Work item type has effort field, use this
                estimationFieldRefName = effortField.referenceName;
            }

            // Check for overrides from configuration
            if (configuration && configuration[wi.name]) {
                estimationFieldRefName =
                    configuration[wi.name].estimationFieldRefName;
            }

            return {
                name: wi.name,
                estimationFieldRefName
            };
        });
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:45,代码来源:workItems.ts


示例4: runQuery

    async runQuery(projectId: string, queryId: string): Promise<number[]> {
        const client = getClient(WorkItemTrackingRestClient);
        const result = await client.queryById(queryId, projectId);

        if (result.workItems) {
            return result.workItems.map(x => x.id);
        } else if (result.workItemRelations) {
            return result.workItemRelations.map(x => x.target.id);
        }

        return [];
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:12,代码来源:queries.ts


示例5: getFields

    async getFields(projectId: string): Promise<IField[]> {
        const client = getClient(WorkItemTrackingRestClient);
        const fields = await client.getFields(projectId);

        const mappedFields: IField[] = fields.map(f => ({
            name: f.name,
            referenceName: f.referenceName
        }));
        mappedFields.sort((a, b) => a.name.localeCompare(b.name));

        return mappedFields;
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:12,代码来源:workItems.ts


示例6: getQueries

    async getQueries(projectId: string, queryIds: string[]): Promise<IQuery[]> {
        const client = getClient(WorkItemTrackingRestClient);
        const queries = await client.getQueriesBatch(
            {
                ids: queryIds,
                errorPolicy: QueryErrorPolicy.Omit,
                $expand: QueryExpand.Minimal
            },
            projectId
        );

        return queries.map(q => ({
            id: q.id,
            name: q.name
        }));
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:16,代码来源:queries.ts


示例7: saveEstimate

    async saveEstimate(
        workItemId: number,
        estimationFieldRefName: string,
        estimate?: string | number | undefined
    ): Promise<void> {
        const client = getClient(WorkItemTrackingRestClient);

        await client.updateWorkItem(
            [
                {
                    op: "add",
                    path: `/fields/${estimationFieldRefName}`,
                    value: estimate
                }
            ],
            workItemId
        );
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:18,代码来源:workItems.ts


示例8: getIterationsForTeam

    public async getIterationsForTeam(teamId: string): Promise<IIteration[]> {
        const projectService: IProjectPageService = await DevOps.getService<
            IProjectPageService
        >("ms.vss-tfs-web.tfs-page-data-service");
        const project = await projectService.getProject();
        if (!project) {
            throw new Error("Project is required");
        }

        const client = getClient(WorkRestClient);
        const teamIterations = await client.getTeamIterations({
            projectId: project.id,
            teamId
        } as TeamContext);

        return teamIterations.map(({ id, name }) => ({
            id,
            name
        }));
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:20,代码来源:teams.ts


示例9: getWorkItems

    async getWorkItems(
        projectId: string,
        teamId: string,
        iterationId: string
    ): Promise<number[]> {
        const teamContext = {
            project: "",
            projectId,
            team: "",
            teamId
        };

        // Get ownership for team
        const client = getClient(WorkRestClient);
        const iterationWorkItems = await client.getIterationWorkItems(
            teamContext,
            iterationId
        );

        return iterationWorkItems.workItemRelations.map(x => x.target.id);
    }
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:21,代码来源:sprints.ts


示例10: getWorkItems

    async getWorkItems(workItemIds: number[]): Promise<IWorkItem[]> {
        if (!workItemIds || workItemIds.length === 0) {
            return [];
        }

        // Get all work items
        const workItemTrackingClient = getClient(WorkItemTrackingRestClient);
        const workItems = await workItemTrackingClient.getWorkItemsBatch({
            ids: workItemIds,
            fields: [
                "System.Id",
                "System.Title",
                "System.WorkItemType",
                "System.TeamProject"
            ],
            $expand: 0 /* None */,
            errorPolicy: 2 /* Omit */
        } as WorkItemBatchGetRequest);

        const mappedWorkItems: IWorkItem[] = workItems.map(wi => {
            return {
                project: wi.fields["System.TeamProject"],
                id: wi.id,
                title: wi.fields["System.Title"],
                workItemType: wi.fields["System.WorkItemType"],
                description: ""
            };
        });

        // The rest of the method is getting the work item type definitions for the work items and then identifying which HTML fields
        // to use for the description. If most of the work items are in a single project this should be fast, if not it could be
        // really really slow, but this should not be the mainline scenario.

        // Aggregate all projects
        const projectById = new Map<
            string,
            { workItemTypes: Map<string, IWorkItemTypeInfo> }
        >();
        for (const workItem of mappedWorkItems) {
            if (projectById.has(workItem.project)) {
                const projectEntry = projectById.get(workItem.project)!;
                // We can just override here
                projectEntry.workItemTypes.set(workItem.workItemType, {});
            } else {
                projectById.set(workItem.project, {
                    workItemTypes: new Map<string, IWorkItemTypeInfo>([
                        [workItem.workItemType, {}]
                    ])
                });
            }
        }

        const coreClient = getClient(CoreRestClient);
        const processClient = getClient(WorkItemTrackingProcessRestClient);

        await Promise.all(
            Array.from(projectById.entries()).map(
                async ([projectName, projectInfo]) => {
                    // Get id for project
                    // Unfortunately, the project properties API only accepts projectId and not name, so make this roundtrip here.
                    const project = await coreClient.getProject(projectName);

                    // Get work item types and their configuration
                    const currentProjectWorkItemTypes = await this.getWorkItemTypes(
                        project.id
                    );

                    const witEstimationFieldRefNameMapping: {
                        [workItemTypeName: string]: string | undefined;
                    } = {};
                    currentProjectWorkItemTypes.forEach(workItemType => {
                        witEstimationFieldRefNameMapping[workItemType.name] =
                            workItemType.estimationFieldRefName;
                    });

                    // Get process type id
                    const properties = await coreClient.getProjectProperties(
                        project.id,
                        ["System.ProcessTemplateType"]
                    );
                    const processTypeId = properties[0].value;

                    const workItemTypes = await processClient.getProcessWorkItemTypes(
                        processTypeId
                    );

                    // Map of friendly work item name (e.g. Bug) to reference name inherited customization
                    const witNameToRefNameMapping: {
                        [name: string]: string;
                    } = {};
                    workItemTypes.forEach(x => {
                        witNameToRefNameMapping[x.name] = x.referenceName;
                    });

                    // Get work item type definitions
                    await Promise.all(
                        Array.from(projectInfo.workItemTypes.keys()).map(
                            async workItemTypeName => {
                                const workItemType = await processClient.getProcessWorkItemType(
                                    processTypeId,
//.........这里部分代码省略.........
开发者ID:cschleiden,项目名称:vsts-estimate,代码行数:101,代码来源:workItems.ts



注:本文中的azure-devops-extension-api.getClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap