@atlaskit/teams-client 4.0.0
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/CHANGELOG.md +1061 -0
- package/LICENSE.md +11 -0
- package/README.md +9 -0
- package/client/package.json +15 -0
- package/dist/cjs/common/types.js +8 -0
- package/dist/cjs/common/utils/ari.js +31 -0
- package/dist/cjs/common/utils/error/index.js +182 -0
- package/dist/cjs/common/utils/filter-null.js +9 -0
- package/dist/cjs/common/utils/http.js +119 -0
- package/dist/cjs/common/utils/index.js +37 -0
- package/dist/cjs/common/utils/permissions/constants.js +68 -0
- package/dist/cjs/common/utils/permissions/has-permission.js +42 -0
- package/dist/cjs/common/utils/permissions/index.js +31 -0
- package/dist/cjs/common/utils/permissions/types.js +11 -0
- package/dist/cjs/common/utils/sort-teams.js +52 -0
- package/dist/cjs/common/utils/status-code-handlers-provider.js +30 -0
- package/dist/cjs/common/utils/team.js +19 -0
- package/dist/cjs/common/utils/ufo/constants.js +22 -0
- package/dist/cjs/common/utils/ufo/index.js +69 -0
- package/dist/cjs/common/utils/ufo/utils.js +26 -0
- package/dist/cjs/index.js +166 -0
- package/dist/cjs/mocks/endpoints.js +267 -0
- package/dist/cjs/mocks/generate-data.js +115 -0
- package/dist/cjs/mocks/index.js +61 -0
- package/dist/cjs/mocks/invitations.js +21 -0
- package/dist/cjs/mocks/responses.js +480 -0
- package/dist/cjs/mocks/team-link.js +26 -0
- package/dist/cjs/mocks/team.js +150 -0
- package/dist/cjs/mocks/user.js +102 -0
- package/dist/cjs/mocks/with-faker.js +16 -0
- package/dist/cjs/services/agg-client/index.js +137 -0
- package/dist/cjs/services/agg-client/mocks/index.js +71 -0
- package/dist/cjs/services/agg-client/types.js +10 -0
- package/dist/cjs/services/agg-client/utils/queries/team-membership-query.js +8 -0
- package/dist/cjs/services/agg-client/utils/queries/user-query.js +12 -0
- package/dist/cjs/services/agg-client/utils/user-type.js +18 -0
- package/dist/cjs/services/base-client/index.js +94 -0
- package/dist/cjs/services/collaborationgraph-client/index.js +58 -0
- package/dist/cjs/services/constants.js +13 -0
- package/dist/cjs/services/directory-client/index.js +241 -0
- package/dist/cjs/services/graphql-client/index.js +12 -0
- package/dist/cjs/services/graphql-client/main.js +69 -0
- package/dist/cjs/services/graphql-client/types.js +5 -0
- package/dist/cjs/services/graphql-client/utils/index.js +157 -0
- package/dist/cjs/services/hooks/use-teams-client-setup.js +44 -0
- package/dist/cjs/services/identity-client/index.js +171 -0
- package/dist/cjs/services/identity-client/utils.js +183 -0
- package/dist/cjs/services/index.js +18 -0
- package/dist/cjs/services/invitations-client/index.js +168 -0
- package/dist/cjs/services/invitations-client/types.js +1 -0
- package/dist/cjs/services/invitations-client/utils/index.js +115 -0
- package/dist/cjs/services/invitations-client/utils/types.js +5 -0
- package/dist/cjs/services/legion-client/index.js +1160 -0
- package/dist/cjs/services/legion-client/types.js +5 -0
- package/dist/cjs/services/main.js +1941 -0
- package/dist/cjs/services/mutability-client/index.js +97 -0
- package/dist/cjs/services/mutability-client/types.js +1 -0
- package/dist/cjs/services/object-resolver-client/index.js +60 -0
- package/dist/cjs/services/object-resolver-client/types.js +17 -0
- package/dist/cjs/services/object-resolver-client/utils.js +67 -0
- package/dist/cjs/services/perms-client/index.js +48 -0
- package/dist/cjs/services/public-api-client/generated/data-contracts.js +1 -0
- package/dist/cjs/services/public-api-client/index.js +264 -0
- package/dist/cjs/services/rest-client/index.js +381 -0
- package/dist/cjs/services/rest-client/utils/cookie.js +23 -0
- package/dist/cjs/services/rest-client/utils/parse-error-message.js +62 -0
- package/dist/cjs/services/rest-client/utils/parse-response.js +20 -0
- package/dist/cjs/services/rest-client/utils/strip-uuid.js +10 -0
- package/dist/cjs/services/sentry/constants.js +15 -0
- package/dist/cjs/services/sentry/index.js +67 -0
- package/dist/cjs/services/sentry/main.js +196 -0
- package/dist/cjs/services/sentry/types.js +5 -0
- package/dist/cjs/services/sentry/utils/get-sentry-config.js +45 -0
- package/dist/cjs/services/sentry/utils/initialise-sentry.js +55 -0
- package/dist/cjs/services/sentry/utils/sentry-client.js +121 -0
- package/dist/cjs/services/sentry/utils/use-teams-sentry-client-setup.js +40 -0
- package/dist/cjs/services/teams-in-slack-client/index.js +103 -0
- package/dist/cjs/services/types.js +1 -0
- package/dist/cjs/services/use-query-light/index.js +25 -0
- package/dist/cjs/services/use-query-light/main.js +232 -0
- package/dist/cjs/services/use-query-light/types.js +52 -0
- package/dist/cjs/services/user-info-provider/index.js +18 -0
- package/dist/cjs/services/user-info-provider/main.js +72 -0
- package/dist/cjs/services/user-preferences-client/index.js +98 -0
- package/dist/cjs/types/config.js +1 -0
- package/dist/cjs/types/index.js +19 -0
- package/dist/cjs/types/links.js +22 -0
- package/dist/cjs/types/media.js +1 -0
- package/dist/cjs/types/membership.js +24 -0
- package/dist/cjs/types/slack.js +1 -0
- package/dist/cjs/types/team.js +5 -0
- package/dist/cjs/types/user.js +10 -0
- package/dist/es2019/common/types.js +2 -0
- package/dist/es2019/common/utils/ari.js +21 -0
- package/dist/es2019/common/utils/error/index.js +142 -0
- package/dist/es2019/common/utils/filter-null.js +3 -0
- package/dist/es2019/common/utils/http.js +82 -0
- package/dist/es2019/common/utils/index.js +2 -0
- package/dist/es2019/common/utils/permissions/constants.js +59 -0
- package/dist/es2019/common/utils/permissions/has-permission.js +33 -0
- package/dist/es2019/common/utils/permissions/index.js +2 -0
- package/dist/es2019/common/utils/permissions/types.js +5 -0
- package/dist/es2019/common/utils/sort-teams.js +45 -0
- package/dist/es2019/common/utils/status-code-handlers-provider.js +25 -0
- package/dist/es2019/common/utils/team.js +6 -0
- package/dist/es2019/common/utils/ufo/constants.js +12 -0
- package/dist/es2019/common/utils/ufo/index.js +43 -0
- package/dist/es2019/common/utils/ufo/utils.js +18 -0
- package/dist/es2019/index.js +19 -0
- package/dist/es2019/mocks/endpoints.js +250 -0
- package/dist/es2019/mocks/generate-data.js +96 -0
- package/dist/es2019/mocks/index.js +2 -0
- package/dist/es2019/mocks/invitations.js +11 -0
- package/dist/es2019/mocks/responses.js +478 -0
- package/dist/es2019/mocks/team-link.js +14 -0
- package/dist/es2019/mocks/team.js +127 -0
- package/dist/es2019/mocks/user.js +79 -0
- package/dist/es2019/mocks/with-faker.js +8 -0
- package/dist/es2019/services/agg-client/index.js +70 -0
- package/dist/es2019/services/agg-client/mocks/index.js +64 -0
- package/dist/es2019/services/agg-client/types.js +4 -0
- package/dist/es2019/services/agg-client/utils/queries/team-membership-query.js +36 -0
- package/dist/es2019/services/agg-client/utils/queries/user-query.js +39 -0
- package/dist/es2019/services/agg-client/utils/user-type.js +13 -0
- package/dist/es2019/services/base-client/index.js +66 -0
- package/dist/es2019/services/collaborationgraph-client/index.js +37 -0
- package/dist/es2019/services/constants.js +7 -0
- package/dist/es2019/services/directory-client/index.js +155 -0
- package/dist/es2019/services/graphql-client/index.js +1 -0
- package/dist/es2019/services/graphql-client/main.js +23 -0
- package/dist/es2019/services/graphql-client/types.js +1 -0
- package/dist/es2019/services/graphql-client/utils/index.js +76 -0
- package/dist/es2019/services/hooks/use-teams-client-setup.js +40 -0
- package/dist/es2019/services/identity-client/index.js +53 -0
- package/dist/es2019/services/identity-client/utils.js +167 -0
- package/dist/es2019/services/index.js +1 -0
- package/dist/es2019/services/invitations-client/index.js +65 -0
- package/dist/es2019/services/invitations-client/types.js +0 -0
- package/dist/es2019/services/invitations-client/utils/index.js +101 -0
- package/dist/es2019/services/invitations-client/utils/types.js +1 -0
- package/dist/es2019/services/legion-client/index.js +484 -0
- package/dist/es2019/services/legion-client/types.js +1 -0
- package/dist/es2019/services/main.js +541 -0
- package/dist/es2019/services/mutability-client/index.js +49 -0
- package/dist/es2019/services/mutability-client/types.js +0 -0
- package/dist/es2019/services/object-resolver-client/index.js +21 -0
- package/dist/es2019/services/object-resolver-client/types.js +12 -0
- package/dist/es2019/services/object-resolver-client/utils.js +53 -0
- package/dist/es2019/services/perms-client/index.js +25 -0
- package/dist/es2019/services/public-api-client/generated/data-contracts.js +0 -0
- package/dist/es2019/services/public-api-client/index.js +120 -0
- package/dist/es2019/services/rest-client/index.js +177 -0
- package/dist/es2019/services/rest-client/utils/cookie.js +13 -0
- package/dist/es2019/services/rest-client/utils/parse-error-message.js +20 -0
- package/dist/es2019/services/rest-client/utils/parse-response.js +14 -0
- package/dist/es2019/services/rest-client/utils/strip-uuid.js +4 -0
- package/dist/es2019/services/sentry/constants.js +10 -0
- package/dist/es2019/services/sentry/index.js +2 -0
- package/dist/es2019/services/sentry/main.js +107 -0
- package/dist/es2019/services/sentry/types.js +1 -0
- package/dist/es2019/services/sentry/utils/get-sentry-config.js +37 -0
- package/dist/es2019/services/sentry/utils/initialise-sentry.js +23 -0
- package/dist/es2019/services/sentry/utils/sentry-client.js +57 -0
- package/dist/es2019/services/sentry/utils/use-teams-sentry-client-setup.js +14 -0
- package/dist/es2019/services/teams-in-slack-client/index.js +32 -0
- package/dist/es2019/services/types.js +0 -0
- package/dist/es2019/services/use-query-light/index.js +2 -0
- package/dist/es2019/services/use-query-light/main.js +162 -0
- package/dist/es2019/services/use-query-light/types.js +27 -0
- package/dist/es2019/services/user-info-provider/index.js +1 -0
- package/dist/es2019/services/user-info-provider/main.js +44 -0
- package/dist/es2019/services/user-preferences-client/index.js +19 -0
- package/dist/es2019/types/config.js +0 -0
- package/dist/es2019/types/index.js +2 -0
- package/dist/es2019/types/links.js +16 -0
- package/dist/es2019/types/media.js +0 -0
- package/dist/es2019/types/membership.js +16 -0
- package/dist/es2019/types/slack.js +0 -0
- package/dist/es2019/types/team.js +1 -0
- package/dist/es2019/types/user.js +4 -0
- package/dist/esm/common/types.js +2 -0
- package/dist/esm/common/utils/ari.js +25 -0
- package/dist/esm/common/utils/error/index.js +176 -0
- package/dist/esm/common/utils/filter-null.js +3 -0
- package/dist/esm/common/utils/http.js +109 -0
- package/dist/esm/common/utils/index.js +2 -0
- package/dist/esm/common/utils/permissions/constants.js +61 -0
- package/dist/esm/common/utils/permissions/has-permission.js +34 -0
- package/dist/esm/common/utils/permissions/index.js +2 -0
- package/dist/esm/common/utils/permissions/types.js +5 -0
- package/dist/esm/common/utils/sort-teams.js +46 -0
- package/dist/esm/common/utils/status-code-handlers-provider.js +23 -0
- package/dist/esm/common/utils/team.js +12 -0
- package/dist/esm/common/utils/ufo/constants.js +15 -0
- package/dist/esm/common/utils/ufo/index.js +62 -0
- package/dist/esm/common/utils/ufo/utils.js +20 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/mocks/endpoints.js +261 -0
- package/dist/esm/mocks/generate-data.js +106 -0
- package/dist/esm/mocks/index.js +2 -0
- package/dist/esm/mocks/invitations.js +14 -0
- package/dist/esm/mocks/responses.js +473 -0
- package/dist/esm/mocks/team-link.js +19 -0
- package/dist/esm/mocks/team.js +143 -0
- package/dist/esm/mocks/user.js +95 -0
- package/dist/esm/mocks/with-faker.js +10 -0
- package/dist/esm/services/agg-client/index.js +130 -0
- package/dist/esm/services/agg-client/mocks/index.js +64 -0
- package/dist/esm/services/agg-client/types.js +4 -0
- package/dist/esm/services/agg-client/utils/queries/team-membership-query.js +2 -0
- package/dist/esm/services/agg-client/utils/queries/user-query.js +5 -0
- package/dist/esm/services/agg-client/utils/user-type.js +12 -0
- package/dist/esm/services/base-client/index.js +87 -0
- package/dist/esm/services/collaborationgraph-client/index.js +51 -0
- package/dist/esm/services/constants.js +7 -0
- package/dist/esm/services/directory-client/index.js +234 -0
- package/dist/esm/services/graphql-client/index.js +1 -0
- package/dist/esm/services/graphql-client/main.js +62 -0
- package/dist/esm/services/graphql-client/types.js +1 -0
- package/dist/esm/services/graphql-client/utils/index.js +149 -0
- package/dist/esm/services/hooks/use-teams-client-setup.js +39 -0
- package/dist/esm/services/identity-client/index.js +164 -0
- package/dist/esm/services/identity-client/utils.js +174 -0
- package/dist/esm/services/index.js +1 -0
- package/dist/esm/services/invitations-client/index.js +163 -0
- package/dist/esm/services/invitations-client/types.js +0 -0
- package/dist/esm/services/invitations-client/utils/index.js +108 -0
- package/dist/esm/services/invitations-client/utils/types.js +1 -0
- package/dist/esm/services/legion-client/index.js +1154 -0
- package/dist/esm/services/legion-client/types.js +1 -0
- package/dist/esm/services/main.js +1936 -0
- package/dist/esm/services/mutability-client/index.js +90 -0
- package/dist/esm/services/mutability-client/types.js +0 -0
- package/dist/esm/services/object-resolver-client/index.js +53 -0
- package/dist/esm/services/object-resolver-client/types.js +12 -0
- package/dist/esm/services/object-resolver-client/utils.js +61 -0
- package/dist/esm/services/perms-client/index.js +42 -0
- package/dist/esm/services/public-api-client/generated/data-contracts.js +0 -0
- package/dist/esm/services/public-api-client/index.js +260 -0
- package/dist/esm/services/rest-client/index.js +373 -0
- package/dist/esm/services/rest-client/utils/cookie.js +14 -0
- package/dist/esm/services/rest-client/utils/parse-error-message.js +55 -0
- package/dist/esm/services/rest-client/utils/parse-response.js +14 -0
- package/dist/esm/services/rest-client/utils/strip-uuid.js +4 -0
- package/dist/esm/services/sentry/constants.js +10 -0
- package/dist/esm/services/sentry/index.js +2 -0
- package/dist/esm/services/sentry/main.js +186 -0
- package/dist/esm/services/sentry/types.js +1 -0
- package/dist/esm/services/sentry/utils/get-sentry-config.js +38 -0
- package/dist/esm/services/sentry/utils/initialise-sentry.js +48 -0
- package/dist/esm/services/sentry/utils/sentry-client.js +108 -0
- package/dist/esm/services/sentry/utils/use-teams-sentry-client-setup.js +33 -0
- package/dist/esm/services/teams-in-slack-client/index.js +96 -0
- package/dist/esm/services/types.js +0 -0
- package/dist/esm/services/use-query-light/index.js +2 -0
- package/dist/esm/services/use-query-light/main.js +225 -0
- package/dist/esm/services/use-query-light/types.js +45 -0
- package/dist/esm/services/user-info-provider/index.js +1 -0
- package/dist/esm/services/user-info-provider/main.js +66 -0
- package/dist/esm/services/user-preferences-client/index.js +91 -0
- package/dist/esm/types/config.js +0 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/links.js +16 -0
- package/dist/esm/types/media.js +0 -0
- package/dist/esm/types/membership.js +17 -0
- package/dist/esm/types/slack.js +0 -0
- package/dist/esm/types/team.js +1 -0
- package/dist/esm/types/user.js +4 -0
- package/dist/types/common/types.d.ts +4 -0
- package/dist/types/common/utils/ari.d.ts +7 -0
- package/dist/types/common/utils/error/index.d.ts +91 -0
- package/dist/types/common/utils/filter-null.d.ts +1 -0
- package/dist/types/common/utils/http.d.ts +31 -0
- package/dist/types/common/utils/index.d.ts +2 -0
- package/dist/types/common/utils/permissions/constants.d.ts +23 -0
- package/dist/types/common/utils/permissions/has-permission.d.ts +31 -0
- package/dist/types/common/utils/permissions/index.d.ts +3 -0
- package/dist/types/common/utils/permissions/types.d.ts +7 -0
- package/dist/types/common/utils/sort-teams.d.ts +2 -0
- package/dist/types/common/utils/status-code-handlers-provider.d.ts +17 -0
- package/dist/types/common/utils/team.d.ts +5 -0
- package/dist/types/common/utils/ufo/constants.d.ts +5 -0
- package/dist/types/common/utils/ufo/index.d.ts +6 -0
- package/dist/types/common/utils/ufo/utils.d.ts +11 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/mocks/endpoints.d.ts +22 -0
- package/dist/types/mocks/generate-data.d.ts +16 -0
- package/dist/types/mocks/index.d.ts +2 -0
- package/dist/types/mocks/invitations.d.ts +11 -0
- package/dist/types/mocks/responses.d.ts +75 -0
- package/dist/types/mocks/team-link.d.ts +7 -0
- package/dist/types/mocks/team.d.ts +14 -0
- package/dist/types/mocks/user.d.ts +15 -0
- package/dist/types/mocks/with-faker.d.ts +11 -0
- package/dist/types/services/agg-client/index.d.ts +12 -0
- package/dist/types/services/agg-client/mocks/index.d.ts +49 -0
- package/dist/types/services/agg-client/types.d.ts +13 -0
- package/dist/types/services/agg-client/utils/queries/team-membership-query.d.ts +33 -0
- package/dist/types/services/agg-client/utils/queries/user-query.d.ts +31 -0
- package/dist/types/services/agg-client/utils/user-type.d.ts +7 -0
- package/dist/types/services/base-client/index.d.ts +37 -0
- package/dist/types/services/collaborationgraph-client/index.d.ts +37 -0
- package/dist/types/services/constants.d.ts +2 -0
- package/dist/types/services/directory-client/index.d.ts +53 -0
- package/dist/types/services/graphql-client/index.d.ts +1 -0
- package/dist/types/services/graphql-client/main.d.ts +8 -0
- package/dist/types/services/graphql-client/types.d.ts +19 -0
- package/dist/types/services/graphql-client/utils/index.d.ts +3 -0
- package/dist/types/services/hooks/use-teams-client-setup.d.ts +12 -0
- package/dist/types/services/identity-client/index.d.ts +33 -0
- package/dist/types/services/identity-client/utils.d.ts +81 -0
- package/dist/types/services/index.d.ts +1 -0
- package/dist/types/services/invitations-client/index.d.ts +11 -0
- package/dist/types/services/invitations-client/types.d.ts +67 -0
- package/dist/types/services/invitations-client/utils/index.d.ts +7 -0
- package/dist/types/services/invitations-client/utils/types.d.ts +7 -0
- package/dist/types/services/legion-client/index.d.ts +133 -0
- package/dist/types/services/legion-client/types.d.ts +107 -0
- package/dist/types/services/main.d.ts +316 -0
- package/dist/types/services/mutability-client/index.d.ts +8 -0
- package/dist/types/services/mutability-client/types.d.ts +5 -0
- package/dist/types/services/object-resolver-client/index.d.ts +8 -0
- package/dist/types/services/object-resolver-client/types.d.ts +38 -0
- package/dist/types/services/object-resolver-client/utils.d.ts +18 -0
- package/dist/types/services/perms-client/index.d.ts +16 -0
- package/dist/types/services/public-api-client/generated/data-contracts.d.ts +112 -0
- package/dist/types/services/public-api-client/index.d.ts +41 -0
- package/dist/types/services/rest-client/index.d.ts +40 -0
- package/dist/types/services/rest-client/utils/cookie.d.ts +5 -0
- package/dist/types/services/rest-client/utils/parse-error-message.d.ts +1 -0
- package/dist/types/services/rest-client/utils/parse-response.d.ts +1 -0
- package/dist/types/services/rest-client/utils/strip-uuid.d.ts +1 -0
- package/dist/types/services/sentry/constants.d.ts +5 -0
- package/dist/types/services/sentry/index.d.ts +3 -0
- package/dist/types/services/sentry/main.d.ts +36 -0
- package/dist/types/services/sentry/types.d.ts +36 -0
- package/dist/types/services/sentry/utils/get-sentry-config.d.ts +2 -0
- package/dist/types/services/sentry/utils/initialise-sentry.d.ts +2 -0
- package/dist/types/services/sentry/utils/sentry-client.d.ts +9 -0
- package/dist/types/services/sentry/utils/use-teams-sentry-client-setup.d.ts +2 -0
- package/dist/types/services/teams-in-slack-client/index.d.ts +27 -0
- package/dist/types/services/types.d.ts +10 -0
- package/dist/types/services/use-query-light/index.d.ts +3 -0
- package/dist/types/services/use-query-light/main.d.ts +4 -0
- package/dist/types/services/use-query-light/types.d.ts +57 -0
- package/dist/types/services/user-info-provider/index.d.ts +1 -0
- package/dist/types/services/user-info-provider/main.d.ts +14 -0
- package/dist/types/services/user-preferences-client/index.d.ts +9 -0
- package/dist/types/types/config.d.ts +7 -0
- package/dist/types/types/index.d.ts +10 -0
- package/dist/types/types/links.d.ts +31 -0
- package/dist/types/types/media.d.ts +6 -0
- package/dist/types/types/membership.d.ts +35 -0
- package/dist/types/types/slack.d.ts +7 -0
- package/dist/types/types/team.d.ts +117 -0
- package/dist/types/types/user.d.ts +41 -0
- package/dist/types-ts4.5/common/types.d.ts +4 -0
- package/dist/types-ts4.5/common/utils/ari.d.ts +7 -0
- package/dist/types-ts4.5/common/utils/error/index.d.ts +91 -0
- package/dist/types-ts4.5/common/utils/filter-null.d.ts +1 -0
- package/dist/types-ts4.5/common/utils/http.d.ts +31 -0
- package/dist/types-ts4.5/common/utils/index.d.ts +2 -0
- package/dist/types-ts4.5/common/utils/permissions/constants.d.ts +23 -0
- package/dist/types-ts4.5/common/utils/permissions/has-permission.d.ts +31 -0
- package/dist/types-ts4.5/common/utils/permissions/index.d.ts +3 -0
- package/dist/types-ts4.5/common/utils/permissions/types.d.ts +26 -0
- package/dist/types-ts4.5/common/utils/sort-teams.d.ts +2 -0
- package/dist/types-ts4.5/common/utils/status-code-handlers-provider.d.ts +17 -0
- package/dist/types-ts4.5/common/utils/team.d.ts +5 -0
- package/dist/types-ts4.5/common/utils/ufo/constants.d.ts +64 -0
- package/dist/types-ts4.5/common/utils/ufo/index.d.ts +6 -0
- package/dist/types-ts4.5/common/utils/ufo/utils.d.ts +11 -0
- package/dist/types-ts4.5/index.d.ts +15 -0
- package/dist/types-ts4.5/mocks/endpoints.d.ts +22 -0
- package/dist/types-ts4.5/mocks/generate-data.d.ts +16 -0
- package/dist/types-ts4.5/mocks/index.d.ts +2 -0
- package/dist/types-ts4.5/mocks/invitations.d.ts +11 -0
- package/dist/types-ts4.5/mocks/responses.d.ts +75 -0
- package/dist/types-ts4.5/mocks/team-link.d.ts +7 -0
- package/dist/types-ts4.5/mocks/team.d.ts +14 -0
- package/dist/types-ts4.5/mocks/user.d.ts +15 -0
- package/dist/types-ts4.5/mocks/with-faker.d.ts +11 -0
- package/dist/types-ts4.5/services/agg-client/index.d.ts +12 -0
- package/dist/types-ts4.5/services/agg-client/mocks/index.d.ts +49 -0
- package/dist/types-ts4.5/services/agg-client/types.d.ts +13 -0
- package/dist/types-ts4.5/services/agg-client/utils/queries/team-membership-query.d.ts +33 -0
- package/dist/types-ts4.5/services/agg-client/utils/queries/user-query.d.ts +31 -0
- package/dist/types-ts4.5/services/agg-client/utils/user-type.d.ts +7 -0
- package/dist/types-ts4.5/services/base-client/index.d.ts +37 -0
- package/dist/types-ts4.5/services/collaborationgraph-client/index.d.ts +37 -0
- package/dist/types-ts4.5/services/constants.d.ts +2 -0
- package/dist/types-ts4.5/services/directory-client/index.d.ts +53 -0
- package/dist/types-ts4.5/services/graphql-client/index.d.ts +1 -0
- package/dist/types-ts4.5/services/graphql-client/main.d.ts +8 -0
- package/dist/types-ts4.5/services/graphql-client/types.d.ts +19 -0
- package/dist/types-ts4.5/services/graphql-client/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/services/hooks/use-teams-client-setup.d.ts +12 -0
- package/dist/types-ts4.5/services/identity-client/index.d.ts +33 -0
- package/dist/types-ts4.5/services/identity-client/utils.d.ts +81 -0
- package/dist/types-ts4.5/services/index.d.ts +1 -0
- package/dist/types-ts4.5/services/invitations-client/index.d.ts +11 -0
- package/dist/types-ts4.5/services/invitations-client/types.d.ts +67 -0
- package/dist/types-ts4.5/services/invitations-client/utils/index.d.ts +7 -0
- package/dist/types-ts4.5/services/invitations-client/utils/types.d.ts +7 -0
- package/dist/types-ts4.5/services/legion-client/index.d.ts +133 -0
- package/dist/types-ts4.5/services/legion-client/types.d.ts +107 -0
- package/dist/types-ts4.5/services/main.d.ts +316 -0
- package/dist/types-ts4.5/services/mutability-client/index.d.ts +8 -0
- package/dist/types-ts4.5/services/mutability-client/types.d.ts +5 -0
- package/dist/types-ts4.5/services/object-resolver-client/index.d.ts +8 -0
- package/dist/types-ts4.5/services/object-resolver-client/types.d.ts +38 -0
- package/dist/types-ts4.5/services/object-resolver-client/utils.d.ts +18 -0
- package/dist/types-ts4.5/services/perms-client/index.d.ts +16 -0
- package/dist/types-ts4.5/services/public-api-client/generated/data-contracts.d.ts +112 -0
- package/dist/types-ts4.5/services/public-api-client/index.d.ts +41 -0
- package/dist/types-ts4.5/services/rest-client/index.d.ts +40 -0
- package/dist/types-ts4.5/services/rest-client/utils/cookie.d.ts +5 -0
- package/dist/types-ts4.5/services/rest-client/utils/parse-error-message.d.ts +1 -0
- package/dist/types-ts4.5/services/rest-client/utils/parse-response.d.ts +1 -0
- package/dist/types-ts4.5/services/rest-client/utils/strip-uuid.d.ts +1 -0
- package/dist/types-ts4.5/services/sentry/constants.d.ts +5 -0
- package/dist/types-ts4.5/services/sentry/index.d.ts +3 -0
- package/dist/types-ts4.5/services/sentry/main.d.ts +36 -0
- package/dist/types-ts4.5/services/sentry/types.d.ts +36 -0
- package/dist/types-ts4.5/services/sentry/utils/get-sentry-config.d.ts +2 -0
- package/dist/types-ts4.5/services/sentry/utils/initialise-sentry.d.ts +2 -0
- package/dist/types-ts4.5/services/sentry/utils/sentry-client.d.ts +9 -0
- package/dist/types-ts4.5/services/sentry/utils/use-teams-sentry-client-setup.d.ts +2 -0
- package/dist/types-ts4.5/services/teams-in-slack-client/index.d.ts +27 -0
- package/dist/types-ts4.5/services/types.d.ts +10 -0
- package/dist/types-ts4.5/services/use-query-light/index.d.ts +3 -0
- package/dist/types-ts4.5/services/use-query-light/main.d.ts +7 -0
- package/dist/types-ts4.5/services/use-query-light/types.d.ts +57 -0
- package/dist/types-ts4.5/services/user-info-provider/index.d.ts +1 -0
- package/dist/types-ts4.5/services/user-info-provider/main.d.ts +14 -0
- package/dist/types-ts4.5/services/user-preferences-client/index.d.ts +9 -0
- package/dist/types-ts4.5/types/config.d.ts +7 -0
- package/dist/types-ts4.5/types/index.d.ts +10 -0
- package/dist/types-ts4.5/types/links.d.ts +31 -0
- package/dist/types-ts4.5/types/media.d.ts +6 -0
- package/dist/types-ts4.5/types/membership.d.ts +35 -0
- package/dist/types-ts4.5/types/slack.d.ts +7 -0
- package/dist/types-ts4.5/types/team.d.ts +117 -0
- package/dist/types-ts4.5/types/user.d.ts +51 -0
- package/mocks/package.json +15 -0
- package/package.json +111 -0
- package/permissions/package.json +15 -0
- package/public/package.json +15 -0
- package/report.api.md +1210 -0
- package/scripts/generate-docs.ts +31 -0
- package/scripts/utils.ts +269 -0
- package/sentry/package.json +15 -0
- package/types/package.json +15 -0
- package/ufo/package.json +15 -0
- package/use-query-light/package.json +15 -0
- package/user-info-provider/package.json +15 -0
- package/utils/package.json +15 -0
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { HttpError, SLOIgnoreHttpError } from '../../common/utils/error';
|
|
2
|
+
import { DEFAULT_CONFIG } from '../constants';
|
|
3
|
+
import { RestClient } from '../rest-client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated migrate to generated types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated migrate to generated types
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated migrate to generated types
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const V1_URL = '/teams/v1';
|
|
18
|
+
const SENTRY_IGNORED_ERROR_MESSAGES_CREATE = ['TEAM_NOT_FOUND'];
|
|
19
|
+
export class PublicApiClient extends RestClient {
|
|
20
|
+
constructor(serviceUrlRoot) {
|
|
21
|
+
super({
|
|
22
|
+
serviceUrl: serviceUrlRoot
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async addUsersToTeam(teamId, members) {
|
|
26
|
+
if (!members || members.length === 0) {
|
|
27
|
+
const missingMembersError = new Error('Missing members to add');
|
|
28
|
+
this.logException(missingMembersError, 'addUsersToTeam');
|
|
29
|
+
throw missingMembersError;
|
|
30
|
+
}
|
|
31
|
+
const membersWithIds = members.filter(member => !!member.accountId);
|
|
32
|
+
if (membersWithIds.length !== members.length) {
|
|
33
|
+
this.logException(new Error('Missing accountIds for some members'), 'addUsersToTeam');
|
|
34
|
+
}
|
|
35
|
+
if (membersWithIds.length === 0) {
|
|
36
|
+
const missingMembersError = new Error('Missing accountIds for all members');
|
|
37
|
+
this.logException(missingMembersError, 'addUsersToTeam');
|
|
38
|
+
throw missingMembersError;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const orgId = this.getOrgId();
|
|
42
|
+
const url = `${V1_URL}/org/${orgId}/teams/${teamId}/members/add`;
|
|
43
|
+
const response = await this.postResource(url, {
|
|
44
|
+
members: membersWithIds
|
|
45
|
+
});
|
|
46
|
+
return response;
|
|
47
|
+
} catch (e) {
|
|
48
|
+
this.logException(e, 'addUsersToTeam');
|
|
49
|
+
if (e instanceof HttpError && SENTRY_IGNORED_ERROR_MESSAGES_CREATE.includes(e.message)) {
|
|
50
|
+
throw new SLOIgnoreHttpError(e);
|
|
51
|
+
}
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async removeTeamMemberships(teamId, members) {
|
|
56
|
+
if (!members || members.length === 0) {
|
|
57
|
+
const missingMembersError = new Error('Missing members to remove');
|
|
58
|
+
this.logException(missingMembersError, 'removeTeamMemberships');
|
|
59
|
+
throw missingMembersError;
|
|
60
|
+
}
|
|
61
|
+
const membersWithIds = members.filter(member => !!member.accountId);
|
|
62
|
+
if (membersWithIds.length !== members.length) {
|
|
63
|
+
this.logException(new Error('Missing accountIds for some members'), 'addUsersToTeam');
|
|
64
|
+
}
|
|
65
|
+
if (membersWithIds.length === 0) {
|
|
66
|
+
const missingMembersError = new Error('Missing accountIds for all members');
|
|
67
|
+
this.logException(missingMembersError, 'removeTeamMemberships');
|
|
68
|
+
throw missingMembersError;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const orgId = this.getOrgId();
|
|
72
|
+
const url = `${V1_URL}/org/${orgId}/teams/${teamId}/members/remove`;
|
|
73
|
+
const response = await this.postResource(url, {
|
|
74
|
+
members: membersWithIds
|
|
75
|
+
});
|
|
76
|
+
return response;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
this.logException(e, 'removeTeamMemberships');
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async getTeamDetails(teamId) {
|
|
83
|
+
try {
|
|
84
|
+
const orgId = this.getOrgId();
|
|
85
|
+
const url = `${V1_URL}/org/${orgId}/teams/${teamId}`;
|
|
86
|
+
const response = await this.getResource(url);
|
|
87
|
+
return response;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
this.logException(e, 'getTeamDetails');
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async getTeamMembers(teamId, first = 50, after) {
|
|
94
|
+
try {
|
|
95
|
+
const orgId = this.getOrgId();
|
|
96
|
+
const url = `${V1_URL}/org/${orgId}/teams/${teamId}/members`;
|
|
97
|
+
const response = await this.postResource(url, {
|
|
98
|
+
after,
|
|
99
|
+
first
|
|
100
|
+
});
|
|
101
|
+
return response;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
this.logException(e, 'getTeamMembers');
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async restoreTeam(teamId) {
|
|
108
|
+
try {
|
|
109
|
+
const orgId = this.getOrgId();
|
|
110
|
+
const url = `${V1_URL}/org/${orgId}/teams/${teamId}/restore`;
|
|
111
|
+
return this.postResource(url);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
this.logException(e, 'restoreTeam');
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
120
|
+
export default new PublicApiClient(DEFAULT_CONFIG.publicApiRoot);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import once from 'lodash/once';
|
|
3
|
+
import { HttpError, SLOIgnoreError } from '../../common/utils/error';
|
|
4
|
+
import { fetchWithExponentialBackoff } from '../../common/utils/http';
|
|
5
|
+
import { handleResponse } from '../../common/utils/status-code-handlers-provider';
|
|
6
|
+
import { BaseClient } from '../base-client';
|
|
7
|
+
import { clearCookie, getCookieAsInteger, REDIRECT_COUNT, setCookie } from './utils/cookie';
|
|
8
|
+
import { parseErrorMessage } from './utils/parse-error-message';
|
|
9
|
+
import { parseResponse } from './utils/parse-response';
|
|
10
|
+
import { stripUUIDFromPath } from './utils/strip-uuid';
|
|
11
|
+
const defaultFetchOptions = {
|
|
12
|
+
credentials: 'include',
|
|
13
|
+
headers: {
|
|
14
|
+
Accept: 'application/json'
|
|
15
|
+
},
|
|
16
|
+
mode: 'cors'
|
|
17
|
+
};
|
|
18
|
+
let incrementRedirectCount;
|
|
19
|
+
let clearRedirectCount;
|
|
20
|
+
resetRedirectCountOnceFlag();
|
|
21
|
+
|
|
22
|
+
// Used by test to reset the once-ness of the functions above
|
|
23
|
+
export function resetRedirectCountOnceFlag() {
|
|
24
|
+
incrementRedirectCount = once(() => setCookie(REDIRECT_COUNT, getCookieAsInteger(REDIRECT_COUNT) + 1));
|
|
25
|
+
clearRedirectCount = once(() => clearCookie(REDIRECT_COUNT));
|
|
26
|
+
}
|
|
27
|
+
export class RestClient extends BaseClient {
|
|
28
|
+
constructor({
|
|
29
|
+
serviceUrl = '',
|
|
30
|
+
config = {
|
|
31
|
+
logException: () => {}
|
|
32
|
+
}
|
|
33
|
+
}) {
|
|
34
|
+
super(config);
|
|
35
|
+
/**
|
|
36
|
+
* This function is necessary for if `statusCodeHandler` prescribes a login
|
|
37
|
+
* redirect upon a 401 response.
|
|
38
|
+
* While the default redirect behaviour may be overriden, this function has
|
|
39
|
+
* been kept separate to ensure it cannot be overriden, lest a host
|
|
40
|
+
* application supply embeddable-directory with a custom handler that suffers
|
|
41
|
+
* the infinite redirect bug.
|
|
42
|
+
*/
|
|
43
|
+
_defineProperty(this, "preventInfiniteRedirectLoop", response => {
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const responseStatusCode = response.status;
|
|
46
|
+
if (responseStatusCode === 401) {
|
|
47
|
+
incrementRedirectCount();
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
clearRedirectCount();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.serviceUrl = serviceUrl;
|
|
54
|
+
}
|
|
55
|
+
setServiceUrl(serviceUrl) {
|
|
56
|
+
this.serviceUrl = serviceUrl;
|
|
57
|
+
}
|
|
58
|
+
async getResource(path, fetchOptions = {}) {
|
|
59
|
+
return this.makeRequest(path, fetchOptions);
|
|
60
|
+
}
|
|
61
|
+
async getResourceCached(path, fetchOptions = {}, cacheOptions) {
|
|
62
|
+
const cacheKey = path;
|
|
63
|
+
const cacheRecord = this.getCachedValue(cacheKey);
|
|
64
|
+
if (cacheRecord) {
|
|
65
|
+
return cacheRecord;
|
|
66
|
+
}
|
|
67
|
+
const response = await this.getResource(path, fetchOptions);
|
|
68
|
+
this.cacheValue(cacheKey, response, cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.expiration);
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
71
|
+
async postResource(path, data, fetchOptions = {}) {
|
|
72
|
+
return this.postResourceRaw(path, JSON.stringify(data), fetchOptions);
|
|
73
|
+
}
|
|
74
|
+
async postResourceRaw(path, data, fetchOptions = {}) {
|
|
75
|
+
fetchOptions = {
|
|
76
|
+
method: 'post',
|
|
77
|
+
headers: {},
|
|
78
|
+
...fetchOptions
|
|
79
|
+
};
|
|
80
|
+
if (data) {
|
|
81
|
+
fetchOptions = {
|
|
82
|
+
body: data,
|
|
83
|
+
...fetchOptions,
|
|
84
|
+
headers: {
|
|
85
|
+
'Content-Type': 'application/json',
|
|
86
|
+
...fetchOptions.headers
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return this.makeRequest(path, fetchOptions);
|
|
91
|
+
}
|
|
92
|
+
async patchResource(path, data) {
|
|
93
|
+
let fetchOptions = {
|
|
94
|
+
/**
|
|
95
|
+
* PATCH must be uppercase as per fetch spec only
|
|
96
|
+
* DELETE, GET, HEAD, OPTIONS, POST, and PUT methods
|
|
97
|
+
* are normalised to uppercase.
|
|
98
|
+
*
|
|
99
|
+
* https://github.com/github/fetch/issues/37
|
|
100
|
+
* https://fetch.spec.whatwg.org/#methods
|
|
101
|
+
*/
|
|
102
|
+
method: 'PATCH'
|
|
103
|
+
};
|
|
104
|
+
if (data) {
|
|
105
|
+
fetchOptions = {
|
|
106
|
+
...fetchOptions,
|
|
107
|
+
body: JSON.stringify(data),
|
|
108
|
+
headers: {
|
|
109
|
+
'Content-Type': 'application/json'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return this.makeRequest(path, fetchOptions);
|
|
114
|
+
}
|
|
115
|
+
async putResource(path, data, additionalFetchOptions = {}) {
|
|
116
|
+
const fetchOptions = {
|
|
117
|
+
method: 'put'
|
|
118
|
+
};
|
|
119
|
+
if (data) {
|
|
120
|
+
Object.assign(fetchOptions, {
|
|
121
|
+
body: JSON.stringify(data),
|
|
122
|
+
headers: {
|
|
123
|
+
'Content-Type': 'application/json'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return this.makeRequest(path, {
|
|
128
|
+
...fetchOptions,
|
|
129
|
+
...additionalFetchOptions
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async deleteResource(path, options = {}) {
|
|
133
|
+
const fetchOptions = {
|
|
134
|
+
...options,
|
|
135
|
+
method: 'delete'
|
|
136
|
+
};
|
|
137
|
+
return this.makeRequest(path, fetchOptions);
|
|
138
|
+
}
|
|
139
|
+
async makeRequest(path, additionalFetchOptions = {
|
|
140
|
+
shouldLogError: e => e.status !== 429
|
|
141
|
+
}) {
|
|
142
|
+
const url = this.serviceUrl + path;
|
|
143
|
+
const options = {
|
|
144
|
+
...defaultFetchOptions,
|
|
145
|
+
...additionalFetchOptions
|
|
146
|
+
};
|
|
147
|
+
const response = await fetchWithExponentialBackoff(url, options);
|
|
148
|
+
this.preventInfiniteRedirectLoop(response);
|
|
149
|
+
handleResponse(response);
|
|
150
|
+
const responseStatusCode = response.status;
|
|
151
|
+
const traceId = response.headers.get('atl-traceid');
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
if (responseStatusCode === 401) {
|
|
154
|
+
throw new SLOIgnoreError({
|
|
155
|
+
message: 'Unauthorized Request - incrementing redirect count'
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
const message = await parseErrorMessage(response);
|
|
159
|
+
const httpError = new HttpError({
|
|
160
|
+
message,
|
|
161
|
+
status: responseStatusCode,
|
|
162
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : undefined,
|
|
163
|
+
path
|
|
164
|
+
});
|
|
165
|
+
if (options.shouldLogError && options.shouldLogError(httpError)) {
|
|
166
|
+
this.logException(httpError, stripUUIDFromPath(path), {
|
|
167
|
+
method: options.method || 'GET',
|
|
168
|
+
url,
|
|
169
|
+
status: responseStatusCode
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
throw httpError;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return additionalFetchOptions.ignoreResponse ? null : parseResponse(response);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const REDIRECT_COUNT = 'redirectCount';
|
|
2
|
+
export const IDENTITY_CSRF_TOKEN = 'avatar.csrf.token';
|
|
3
|
+
export function setCookie(key, value) {
|
|
4
|
+
document.cookie = `${key}=${value};path=/;max-age=30`;
|
|
5
|
+
}
|
|
6
|
+
export function getCookieAsInteger(key, defaultValue = 0) {
|
|
7
|
+
const regex = new RegExp(`${key}=(\\d+)`);
|
|
8
|
+
const result = document.cookie.match(regex);
|
|
9
|
+
return result ? parseInt(result[1], 10) : defaultValue;
|
|
10
|
+
}
|
|
11
|
+
export function clearCookie(key) {
|
|
12
|
+
document.cookie = `${key}=doesntmatter;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export async function parseErrorMessage(response) {
|
|
2
|
+
let json;
|
|
3
|
+
const text = await response.text();
|
|
4
|
+
try {
|
|
5
|
+
json = JSON.parse(text);
|
|
6
|
+
} catch (err) {
|
|
7
|
+
return text;
|
|
8
|
+
}
|
|
9
|
+
delete json.timestamp; // to dedupe sentry, scrub non-unique 'timestamp' field from the error body
|
|
10
|
+
|
|
11
|
+
if (json.error) {
|
|
12
|
+
return `${json.status || 'UNKNOWN_STATUS'} ${json.error || 'MISSING_ERROR_MESSAGE'}`;
|
|
13
|
+
} else if (json.status) {
|
|
14
|
+
return `${json.status} MISSING_ERROR_MESSAGE`;
|
|
15
|
+
} else if (json.errors) {
|
|
16
|
+
const errs = json.errors.map(error => typeof error === 'string' ? error : error.code || error.message || 'MISSING_ERROR_MESSAGE');
|
|
17
|
+
return errs.join('\n - ');
|
|
18
|
+
}
|
|
19
|
+
return JSON.stringify(json);
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function parseResponse(response) {
|
|
2
|
+
const responseStatusCode = response.status;
|
|
3
|
+
if (responseStatusCode === 204 || responseStatusCode === 202) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const contentType = response.headers.get('content-type');
|
|
7
|
+
if (!contentType || contentType.includes('text/html') || contentType.includes('text/plain')) {
|
|
8
|
+
return response.text();
|
|
9
|
+
}
|
|
10
|
+
if (contentType.includes('application/json')) {
|
|
11
|
+
return response.json();
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isFedRamp } from '@atlaskit/atlassian-context';
|
|
2
|
+
|
|
3
|
+
// https://sentry.io/settings/atlassian-2y/projects/people-and-teams-directory/keys/
|
|
4
|
+
export const SENTRY_PUBLIC_KEY = '1dc056d49dfe4df8961dc1b810e4620d';
|
|
5
|
+
export const SENTRY_PROJECT_ID = '5988845';
|
|
6
|
+
export const SENTRY_FEDRAMP_PUBLIC_KEY = '067abcc494be9a87b3cdf9416f2b97d5';
|
|
7
|
+
export const SENTRY_FEDRAMP_PROJECT_ID = '47';
|
|
8
|
+
const SENTRY_COMMERCIAL_DSN = `https://${SENTRY_PUBLIC_KEY}@o55978.ingest.sentry.io/${SENTRY_PROJECT_ID}`;
|
|
9
|
+
const SENTRY_FEDRAMP_DSN = `https://${SENTRY_FEDRAMP_PUBLIC_KEY}@sentry.atlassian-us-gov-mod.com/${SENTRY_FEDRAMP_PROJECT_ID}`;
|
|
10
|
+
export const SENTRY_DSN = isFedRamp() ? SENTRY_FEDRAMP_DSN : SENTRY_COMMERCIAL_DSN;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { addBreadcrumb, logException, logErrorMessage, logInfoMessage, createErrorHandler, logExceptionWithPackageContext, logErrorMessageWithPackageContext, logInfoMessageWithPackageContext, createErrorHandlerWithPackageContext } from './main';
|
|
2
|
+
export { useTeamsSentryClientSetup } from './utils/use-teams-sentry-client-setup';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// See Sentry accepted options in here https://docs.sentry.io/error-reporting/configuration/?platform=javascript
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
+
|
|
5
|
+
import { getSentryClient } from './utils/sentry-client';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
|
|
9
|
+
function decorateScope(scope, context) {
|
|
10
|
+
const {
|
|
11
|
+
tags,
|
|
12
|
+
...otherContext
|
|
13
|
+
} = context;
|
|
14
|
+
if (tags) {
|
|
15
|
+
scope.setTags(tags);
|
|
16
|
+
}
|
|
17
|
+
if (Object.keys(otherContext).length) {
|
|
18
|
+
scope.setExtras(otherContext);
|
|
19
|
+
}
|
|
20
|
+
return scope;
|
|
21
|
+
}
|
|
22
|
+
export async function logException(ex, name, context = {}) {
|
|
23
|
+
try {
|
|
24
|
+
const sentryClient = await getSentryClient();
|
|
25
|
+
if (!sentryClient || typeof sentryClient.captureException !== 'function') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
sentryClient.withScope(scope => {
|
|
29
|
+
var _context$packageName, _context$packageVersi;
|
|
30
|
+
decorateScope(scope, context);
|
|
31
|
+
scope.setTag('name', name);
|
|
32
|
+
scope.setTag('packageName', (_context$packageName = context.packageName) !== null && _context$packageName !== void 0 ? _context$packageName : 'unknown');
|
|
33
|
+
scope.setTag('packageVersion', (_context$packageVersi = context.packageVersion) !== null && _context$packageVersi !== void 0 ? _context$packageVersi : 'unknown');
|
|
34
|
+
sentryClient.captureException(ex, scope);
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
// silence sentry exceptions
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function logMessage(severity, message, context = {}) {
|
|
41
|
+
const sentryClient = await getSentryClient();
|
|
42
|
+
if (!sentryClient || typeof sentryClient.captureException !== 'function') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
sentryClient.withScope(scope => {
|
|
46
|
+
var _context$packageName2, _context$packageVersi2;
|
|
47
|
+
decorateScope(scope, context);
|
|
48
|
+
// The Severity enum is being replaced by SeverityLevel type in v7 anyway
|
|
49
|
+
scope.setLevel(severity);
|
|
50
|
+
scope.setTag('packageName', (_context$packageName2 = context.packageName) !== null && _context$packageName2 !== void 0 ? _context$packageName2 : 'unknown');
|
|
51
|
+
scope.setTag('packageVersion', (_context$packageVersi2 = context.packageVersion) !== null && _context$packageVersi2 !== void 0 ? _context$packageVersi2 : 'unknown');
|
|
52
|
+
sentryClient.captureMessage(message, scope);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function logErrorMessage(message, context = {}) {
|
|
56
|
+
logMessage('error', message, context).catch(() => {});
|
|
57
|
+
}
|
|
58
|
+
export function logInfoMessage(message, context = {}) {
|
|
59
|
+
logMessage('info', message, context).catch(() => {});
|
|
60
|
+
}
|
|
61
|
+
export const createErrorHandler = details => {
|
|
62
|
+
return (error, message, tags = {}) => {
|
|
63
|
+
logException(error, message, {
|
|
64
|
+
tags: {
|
|
65
|
+
...details,
|
|
66
|
+
...tags
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export const logExceptionWithPackageContext = packageContext => (...args) => {
|
|
72
|
+
// Intentionally not awaiting the promise here as we don't need the result
|
|
73
|
+
logException(args[0], args[1], {
|
|
74
|
+
...args[2],
|
|
75
|
+
packageName: packageContext.packageName,
|
|
76
|
+
packageVersion: packageContext.packageVersion
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export const logErrorMessageWithPackageContext = packageContext => (...args) => {
|
|
80
|
+
// Intentionally not awaiting the promise here as we don't need the result
|
|
81
|
+
logErrorMessage(args[0], {
|
|
82
|
+
...args[1],
|
|
83
|
+
packageName: packageContext.packageName,
|
|
84
|
+
packageVersion: packageContext.packageVersion
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
export const logInfoMessageWithPackageContext = packageContext => (...args) => {
|
|
88
|
+
// Intentionally not awaiting the promise here as we don't need the result
|
|
89
|
+
logInfoMessage(args[0], {
|
|
90
|
+
...args[1],
|
|
91
|
+
packageName: packageContext.packageName,
|
|
92
|
+
packageVersion: packageContext.packageVersion
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
export const createErrorHandlerWithPackageContext = packageContext => (...args) => createErrorHandler({
|
|
96
|
+
...args[0],
|
|
97
|
+
packageName: packageContext.packageName,
|
|
98
|
+
packageVersion: packageContext.packageVersion
|
|
99
|
+
});
|
|
100
|
+
export async function addBreadcrumb(crumb) {
|
|
101
|
+
const sentryClient = await getSentryClient();
|
|
102
|
+
sentryClient.withScope(scope => {
|
|
103
|
+
scope.addBreadcrumb(typeof crumb === 'string' ? {
|
|
104
|
+
message: crumb
|
|
105
|
+
} : crumb);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SENTRY_DSN } from '../constants';
|
|
2
|
+
const DEFAULT_SENTRY_CONFIG = {
|
|
3
|
+
whitelistUrls: [/atl-paas.net/,
|
|
4
|
+
// test local host
|
|
5
|
+
/localhost/],
|
|
6
|
+
ignoreErrors: [/^SentryIgnore:/,
|
|
7
|
+
// Network related errors
|
|
8
|
+
'The operation was aborted', 'Software caused connection abort', 'GraphQL error: Failed to fetch', 'TypeError: Failed to fetch', 'TypeError: NetworkError when attempting to fetch resource.', 'AbortError: The user aborted a request.', /^network error/i, /^network failure/i, /^NetworkError/i, /^Unexpected token ..*/],
|
|
9
|
+
ignoreUrls: [
|
|
10
|
+
// Chrome extensions
|
|
11
|
+
/extensions\//i, /^chrome:\/\//i],
|
|
12
|
+
dsn: SENTRY_DSN,
|
|
13
|
+
attachStacktrace: true
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// return value is an Sentry configuration object:
|
|
17
|
+
// https://docs.sentry.io/learn/configuration/?platform=javascript
|
|
18
|
+
export function getSentryConfig(options) {
|
|
19
|
+
var _window$__buildInfo;
|
|
20
|
+
const {
|
|
21
|
+
env,
|
|
22
|
+
version,
|
|
23
|
+
noGlobals: _,
|
|
24
|
+
...otherOptions
|
|
25
|
+
} = options;
|
|
26
|
+
return {
|
|
27
|
+
...otherOptions,
|
|
28
|
+
...DEFAULT_SENTRY_CONFIG,
|
|
29
|
+
// Standalone __VERSION__ is set from `bin/set-release-version.sh`
|
|
30
|
+
// when building to deploy to production
|
|
31
|
+
release: `${"@atlaskit/teams-client"}@${"4.0.0"}` ||
|
|
32
|
+
// @ts-ignore Jira - window.BUILD_KEY
|
|
33
|
+
window.BUILD_KEY || ( // @ts-ignore Confluence - window.__buildInfo
|
|
34
|
+
(_window$__buildInfo = window.__buildInfo) === null || _window$__buildInfo === void 0 ? void 0 : _window$__buildInfo.FRONTEND_VERSION) || '---',
|
|
35
|
+
environment: env || 'prod'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getSentryConfig } from './get-sentry-config';
|
|
2
|
+
import { sentryClient, setSentryClient } from './sentry-client';
|
|
3
|
+
const DISABLED_INTEGRATIONS = ['onerror', 'onunhandledrejection',
|
|
4
|
+
// In Jira this integration is being initialised twice, resulting in no events being sent to Sentry
|
|
5
|
+
'Dedupe'];
|
|
6
|
+
export async function initialiseSentry(client, options) {
|
|
7
|
+
if (sentryClient) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (!client) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setSentryClient(client);
|
|
14
|
+
const sentryConfig = getSentryConfig(options);
|
|
15
|
+
sentryClient.init({
|
|
16
|
+
...sentryConfig,
|
|
17
|
+
integrations: function (integrations) {
|
|
18
|
+
return integrations.filter(function (integration) {
|
|
19
|
+
return DISABLED_INTEGRATIONS.indexOf(integration.name) === -1;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SENTRY_DSN } from '../constants';
|
|
2
|
+
import { initialiseSentry } from './initialise-sentry';
|
|
3
|
+
export let sentryClient;
|
|
4
|
+
export const setSentryClient = client => {
|
|
5
|
+
sentryClient = client;
|
|
6
|
+
};
|
|
7
|
+
export const getSentryClient = async () => {
|
|
8
|
+
if (!sentryClient) {
|
|
9
|
+
await setupSentryClient({});
|
|
10
|
+
}
|
|
11
|
+
return sentryClient;
|
|
12
|
+
};
|
|
13
|
+
export async function setupSentryClient({
|
|
14
|
+
appName,
|
|
15
|
+
env
|
|
16
|
+
}) {
|
|
17
|
+
var _window$__buildInfo;
|
|
18
|
+
const sentryClient = await requireSentryLib();
|
|
19
|
+
if (!sentryClient) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// initialiseSentry sets the sentry client
|
|
24
|
+
initialiseSentry(sentryClient, {
|
|
25
|
+
initialScope: {
|
|
26
|
+
tags: {
|
|
27
|
+
renderMode: appName || 'unknown',
|
|
28
|
+
productBuild:
|
|
29
|
+
// @ts-ignore Jira - window.BUILD_KEY, confluence - window.__buildInfo
|
|
30
|
+
window.BUILD_KEY || ((_window$__buildInfo = window.__buildInfo) === null || _window$__buildInfo === void 0 ? void 0 : _window$__buildInfo.FRONTEND_VERSION) || 'unknown',
|
|
31
|
+
product: getProduct()
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
env,
|
|
35
|
+
noGlobals: true,
|
|
36
|
+
dsn: SENTRY_DSN,
|
|
37
|
+
attachStacktrace: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function requireSentryLib() {
|
|
41
|
+
// saving ~40K
|
|
42
|
+
try {
|
|
43
|
+
return import( /* webpackChunkName: "teams-client_sentry" */'@sentry/browser');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn('Ignoring rejected promise when loading sentry resource.', error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function getProduct() {
|
|
50
|
+
const path = window.location.pathname;
|
|
51
|
+
if (path.includes('/jira/people')) {
|
|
52
|
+
return 'jira';
|
|
53
|
+
} else if (path.includes('/wiki/people')) {
|
|
54
|
+
return 'confluence';
|
|
55
|
+
}
|
|
56
|
+
return 'unknown';
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { sentryClient, setupSentryClient } from './sentry-client';
|
|
3
|
+
export const useTeamsSentryClientSetup = (isSentryEnabled, config) => {
|
|
4
|
+
const [sentryInitialised, setSentryInitialised] = useState(false);
|
|
5
|
+
const setupSentry = useCallback(async () => {
|
|
6
|
+
if (!sentryInitialised && isSentryEnabled && !sentryClient) {
|
|
7
|
+
await setupSentryClient(config);
|
|
8
|
+
}
|
|
9
|
+
}, [config, isSentryEnabled, sentryInitialised]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setupSentry().then(() => setSentryInitialised(true));
|
|
12
|
+
}, [setupSentry]);
|
|
13
|
+
return sentryClient;
|
|
14
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG } from '../constants';
|
|
2
|
+
import { RestClient } from '../rest-client';
|
|
3
|
+
const defaultConfig = {
|
|
4
|
+
serviceUrl: `${DEFAULT_CONFIG.stargateRoot}/teamsslack/api/team`
|
|
5
|
+
};
|
|
6
|
+
export class TeamsInSlackClient extends RestClient {
|
|
7
|
+
constructor(config = {}) {
|
|
8
|
+
super({
|
|
9
|
+
...defaultConfig,
|
|
10
|
+
...config
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async getTeamInSlack(teamId, teamName) {
|
|
14
|
+
return this.getResource(`/${teamId}?teamName=${encodeURIComponent(teamName)}`).then(response => ({
|
|
15
|
+
id: teamId,
|
|
16
|
+
...response
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
async disconnectTeamInSlack(teamId) {
|
|
20
|
+
return this.deleteResource(`/${teamId}`).then(response => ({
|
|
21
|
+
id: teamId,
|
|
22
|
+
...response
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
async updateTeamInSlack(teamId, channelId, usergroupHandle) {
|
|
26
|
+
return this.postResource(`/${teamId}?channel=${channelId}&groupName=${usergroupHandle}`).then(response => ({
|
|
27
|
+
id: teamId,
|
|
28
|
+
...response
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default new TeamsInSlackClient();
|
|
File without changes
|