メインコンテンツまでスキップ
バージョン: 0.14.0 (最新)

🛣️ Organization ルート

Organization ルートは Express ミドルウェアではなく SDK コンポーザーです。対応する 機能 または organizationService をマウントしてください。各詳細にはスキーマ、バリデーター、パイプライン、レスポンス契約へのリンクがあります。

一覧

ルートメソッド/プロトコルパススキーマバリデーター成功ステータス
createOrganizationRoutePOST / HTTP/organizationscreateOrganizationSchemaisAuthenticated(), checkIdentityType(['admin'])200
getOrganizationRouteGET / HTTP/organizations/:organizationIdgetOrganizationSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin', 'member'], ['params', 'requestParams', 'organizationId'] ) )200
findOrganizationsRouteGET / HTTP/organizationsfindOrganizationsSchemaisAuthenticated(), checkIdentityType(['admin'])200
updateOrganizationRoutePATCH / HTTP/organizations/:organizationIdupdateOrganizationSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )200
updateOrganizationAsAdminRoutePATCH / HTTP/admin/organizations/:organizationId/updateOrganizationAsAdminSchemaisAuthenticated(), checkIdentityType(['admin'])200
deleteOrganizationRouteDELETE / HTTP/organizations/:organizationIddeleteOrganizationSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )204
getOrganizationMemberRoleRouteGET / HTTP/organizations/:organizationId/members/:identityId/rolegetOrganizationMemberRoleSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ) )200
checkOrganizationMemberExistenceRouteGET / HTTP/organizations/:organizationId/members/check-existencecheckOrganizationMemberExistenceSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ) )200
findOrganizationMembersRouteGET / HTTP/organizations/:organizationId/membersfindOrganizationMembersSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ) )200
upsertOrganizationMembersRoutePATCH / HTTP/organizations/:organizationId/membersupsertOrganizationMembersSchemaisAuthenticated(), some( checkIdentityType(['admin']), all( hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ), hasOrgRoleAssignmentPermission( ['params', 'requestParams', 'organizationId'], ['params', 'requestBody'] ) ) ), hasOrgOwnerRemainingAfterMembersUpsert( ['params', 'requestParams', 'organizationId'], ['params', 'requestBody'] )204
deleteOrganizationMemberRouteDELETE / HTTP/organizations/:organizationId/members/:identityIddeleteOrganizationMemberSchemaisAuthenticated(), some( checkIdentityType(['admin']), all( hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ), hasOrgRoleSameOrAbove( ['params', 'requestParams', 'organizationId'], ['params', 'requestParams', 'identityId'] ) ) ), hasOrgOwnerRemainingAfterMemberRemoval( ['params', 'requestParams', 'organizationId'], ['params', 'requestParams', 'identityId'] )204
findOrganizationsForMemberRouteGET / HTTP/organizations/members/:identityIdfindOrganizationsForMemberSchemaisAuthenticated(), some( checkIdentityType(['admin']), isSelf(['params', 'requestParams', 'identityId']) )200
findOrganizationDescendantsRouteGET / HTTP/organizations/:organizationId/descendantsfindOrganizationDescendantsSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ) )200
getLogoUploadUrlRouteGET / HTTP/organizations/:organizationId/logo-upload-urlgetSignedImageUploadUrlSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )200
getCertificateUploadUrlRouteGET / HTTP/organizations/:organizationId/certificate-upload-urlgetCertificateUploadUrlSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )200
createChangeRequestRoutePOST / HTTP/organizations/:organizationId/change-requestscreateChangeRequestSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )204
findChangeRequestsForOrganizationRouteGET / HTTP/organizations/:organizationId/change-requestsfindChangeRequestsForOrganizationSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )200
getOrganizationFollowersRouteGET / HTTP/organizations/:organizationId/followersgetOrganizationFollowersSchemaisAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId']) )200

詳細

createOrganizationRoute

実装

エンドポイント: POST /organizations

親/祖先およびロゴ正規化を伴って、POST /organizations で新しい Organization を作成します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedcheckIdentityType.

リクエスト: createOrganizationSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdcalculateChildAncestorsnoopcreateOrganizationnormalizeLogoOfOwnernormalizeOrganizationTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const createOrganizationRoute = withRoute({
handler: compose(
ifElse(
match(Boolean, ['params', 'requestBody', 'parentId']),
compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestBody', 'parentId'],
],
'parentOrganization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
calculateChildAncestors,
[['context', 'data', 'parentOrganization']],
'ancestors'
)
)
)
),
applyPayloadArgs(noop, [[]])
),
withLogging(
flatMapAsync(
applyPayloadArgs(
createOrganization,
[
['context', 'db', 'organizations'],
['params', 'requestBody', 'ownerId'],
['params', 'requestBody', 'organization'],
['params', 'requestBody', 'parentId'],
['context', 'data', 'ancestors'],
],
'organizationId'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['context', 'data', 'organizationId'],
],
'rawOrganization'
)
)
),
// TODO: once we remove terminators, these 'normalizeX' functions should be replaced by a single normalizer
flatMapAsync(
applyPayloadArgs(
normalizeLogoOfOwner,
[
['context', 'fileStorageDriver'],
['context', 'data', 'rawOrganization'],
],
'organization'
)
),
// TODO: replace terminator (because we are using old terminator, the function directly before it has to append "organization" to context.data)
lift(withLogging(normalizeOrganizationTerminator))
),
method: 'POST',
path: '/organizations',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

getOrganizationRoute

実装

エンドポイント: GET /organizations/:organizationId

ロゴ正規化とアクセス制御を伴って、GET /organizations/:organizationId で指定した Organization を取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: getOrganizationSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdnormalizeCertificateImagenormalizeLogoOfOwnernormalizeOrganizationTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const getOrganizationRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'rawOrganization'
)
),

// TODO: once we remove terminators, these 'normalizeX' functions should be replaced by a single normalizer
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImage,
[
['context', 'fileStorageDriver'],
['context', 'data', 'rawOrganization'],
],
'organizationWithCertificateImage'
)
),

flatMapAsync(
applyPayloadArgs(
normalizeLogoOfOwner,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organizationWithCertificateImage'],
],
'organization'
)
),
// TODO: replace terminator (because we are using old terminator, the function directly before it has to append "organization" to context.data)
lift(withLogging(normalizeOrganizationTerminator))
),
method: 'GET',
path: '/organizations/:organizationId',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(
['owner', 'admin', 'member'],
['params', 'requestParams', 'organizationId']
)
),
],
});

findOrganizationsRoute

実装

エンドポイント: GET /organizations

管理者ユーザー向けに証明書とロゴを正規化し、GET /organizations でページネーション済み Organization リストを取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedcheckIdentityType.

リクエスト: findOrganizationsSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: findOrganizationsnormalizeCertificateImagesnormalizeLogosOfOwnersapplySpecnormalizeOrganizationsListTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const findOrganizationsRoute = withRoute({
handler: compose(
withPagination(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['params', 'requestQuery'],
],
'paginatedOrganizations'
)
)
),
// TODO: once we remove terminators, these 'normalizeX' functions should be replaced by a single normalizer
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImages,
[
['context', 'fileStorageDriver'],
['context', 'data', 'paginatedOrganizations', 'data'],
],
'organizationsWithCertificateImages'
)
),
flatMapAsync(
applyPayloadArgs(
normalizeLogosOfOwners,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organizationsWithCertificateImages'],
],
'normalizedOrganizations'
)
),
flatMapAsync(
applyPayloadArgs(
applySpec({
data: nthArg(0),
metadata: nthArg(1),
}),
[
['context', 'data', 'normalizedOrganizations'],
['context', 'data', 'paginatedOrganizations', 'metadata'],
],
'organizations'
)
),
// TODO: replace terminator (because we are using old terminator, the function directly before it has to append "organizations" to context.data)
lift(withLogging(normalizeOrganizationsListTerminator))
),
method: 'GET',
path: '/organizations',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

updateOrganizationRoute

実装

エンドポイント: PATCH /organizations/:organizationId

ロゴ正規化とアクセス制御を伴って、PATCH /organizations/:organizationId で既存の Organization を更新します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: updateOrganizationSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: updateOrganizationgetOrganizationByIdnormalizeCertificateImagenormalizeLogoOfOwnernormalizeOrganizationTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const updateOrganizationRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
updateOrganization,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
['params', 'requestBody'],
],
'hasUpdatedOrganization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'rawOrganization'
)
)
),

// TODO: once we remove terminators, these 'normalizeX' functions should be replaced by a single normalizer
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImage,
[
['context', 'fileStorageDriver'],
['context', 'data', 'rawOrganization'],
],
'organizationWithCertificateImage'
)
),
flatMapAsync(
applyPayloadArgs(
normalizeLogoOfOwner,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organizationWithCertificateImage'],
],
'organization'
)
),
// TODO: replace terminator (because we are using old terminator, the function directly before it has to append "organization" to context.data)
lift(withLogging(normalizeOrganizationTerminator))
),
method: 'PATCH',
path: '/organizations/:organizationId',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

updateOrganizationAsAdminRoute

実装

エンドポイント: PATCH /admin/organizations/:organizationId/

PATCH /admin/organizations/:organizationId/ で管理者として Organization を更新します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedcheckIdentityType.

リクエスト: updateOrganizationAsAdminSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: validateAuditStatusupdateOrganizationgetOrganizationByIdnormalizeCertificateImagenormalizeLogoOfOwnernormalizeOrganizationTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const updateOrganizationAsAdminRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
validateAuditStatus,
[['params', 'requestBody', 'auditStatus']],
'isValidAuditStatus'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
updateOrganization,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
['params', 'requestBody'],
],
'hasUpdatedOrganization'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'rawOrganization'
)
)
),

// TODO: once we remove terminators, these 'normalizeX' functions should be replaced by a single normalizer
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImage,
[
['context', 'fileStorageDriver'],
['context', 'data', 'rawOrganization'],
],
'organizationWithCertificateImage'
)
),

flatMapAsync(
applyPayloadArgs(
normalizeLogoOfOwner,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organizationWithCertificateImage'],
],
'organization'
)
),
// TODO: replace terminator (because we are using old terminator, the function directly before it has to append "organization" to context.data)
lift(withLogging(normalizeOrganizationTerminator))
),
method: 'PATCH',
path: '/admin/organizations/:organizationId/',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

deleteOrganizationRoute

実装

エンドポイント: DELETE /organizations/:organizationId

DELETE /organizations/:organizationId で Organization とそのロゴを削除します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: deleteOrganizationSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIddeleteLogoOfOwnerdeleteOrganizationdeleteOrganizationTerminator.

成功: 204; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const deleteOrganizationRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),

flatMapAsync(
applyPayloadArgs(
deleteLogoOfOwner,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organization'],
],
'logoOfOwnerDeleted'
)
),

// TODO: there is currently no way to delete certificates

flatMapAsync(
withLogging(
applyPayloadArgs(
deleteOrganization,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'hasDeletedOrganization'
)
)
),
// TODO: replace terminator
lift(withLogging(deleteOrganizationTerminator))
),
method: 'DELETE',
path: '/organizations/:organizationId',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

getOrganizationMemberRoleRoute

実装

エンドポイント: GET /organizations/:organizationId/members/:identityId/role

GET /organizations/:organizationId/members/:identityId/role で、Organization 内の指定メンバーのロールを取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: getOrganizationMemberRoleSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdbuildOrganizationsForMemberByIdsQueryfindOrganizationscalculateMemberRole.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const getOrganizationMemberRoleRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildOrganizationsForMemberByIdsQuery,
[
['params', 'requestParams', 'identityId'],
['context', 'data', 'organization', 'ancestors'],
],
'ancestorOrganizationsQuery'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'ancestorOrganizationsQuery'],
],
'ancestorOrganizations'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
calculateMemberRole,
[
['context', 'data', 'organization'],
['context', 'data', 'ancestorOrganizations'],
['params', 'requestParams', 'identityId'],
],
'memberRole'
)
)
),
lift(
orThrow(
[
[OrganizationMemberNotFoundError, 404],
[OrganizationMemberRoleNotFoundError, 404],
[OrganizationDbError, 500],
],
[['context', 'data', 'memberRole'], 200]
)
)
),
method: 'GET',
path: '/organizations/:organizationId/members/:identityId/role',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
)
),
],
});

checkOrganizationMemberExistenceRoute

実装

エンドポイント: GET /organizations/:organizationId/members/check-existence

GET /organizations/:organizationId/members/check-existence で、指定したアイデンティティが Organization のメンバーとして存在するか確認します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: checkOrganizationMemberExistenceSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdcheckOrganizationMemberExistencenormalizeOrganizationMemberExistenceTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const checkOrganizationMemberExistenceRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
checkOrganizationMemberExistence,
[
['context', 'data', 'organization', 'members'],
['params', 'requestQuery', 'identityId'],
],
'isMemberOfOrganization'
)
)
),
// TODO: replace terminator
lift(withLogging(normalizeOrganizationMemberExistenceTerminator))
),
method: 'GET',
path: '/organizations/:organizationId/members/check-existence',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
)
),
],
});

findOrganizationMembersRoute

実装

エンドポイント: GET /organizations/:organizationId/members

GET /organizations/:organizationId/members で、Organization 内のすべてのメンバーを取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: findOrganizationMembersSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: findOrganizationMembersnormalizeOrganizationMembersListTerminator.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const findOrganizationMembersRoute = withRoute({
handler: compose(
withPaginatedProperty(
withLogging(
applyPayloadArgs(
findOrganizationMembers,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organizationMembers'
)
),
['members']
),
// TODO: replace terminator
lift(withLogging(normalizeOrganizationMembersListTerminator))
),
method: 'GET',
path: '/organizations/:organizationId/members',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
)
),
],
});

upsertOrganizationMembersRoute

実装

エンドポイント: PATCH /organizations/:organizationId/members

PATCH /organizations/:organizationId/members で、Organization 内のメンバーをアップサートします。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypeallhasOrgRolehasOrgRoleAssignmentPermissionhasOrgOwnerRemainingAfterMembersUpsert.

リクエスト: upsertOrganizationMembersSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdupsertOrganizationMembersupsertOrganizationMembersTerminator.

成功: 204; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const upsertOrganizationMembersRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
upsertOrganizationMembers,
[
['context', 'db', 'organizations'],
['context', 'data', 'organization', 'members'],
['params', 'requestParams', 'organizationId'],
['params', 'requestBody'],
],
'hasUpsertedOrganizationMembers'
)
)
),
// TODO: replace terminator
lift(withLogging(upsertOrganizationMembersTerminator))
),
method: 'PATCH',
path: '/organizations/:organizationId/members',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
all(
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
),
hasOrgRoleAssignmentPermission(
['params', 'requestParams', 'organizationId'],
['params', 'requestBody']
)
)
),
hasOrgOwnerRemainingAfterMembersUpsert(
['params', 'requestParams', 'organizationId'],
['params', 'requestBody']
),
],
});

deleteOrganizationMemberRoute

実装

エンドポイント: DELETE /organizations/:organizationId/members/:identityId

DELETE /organizations/:organizationId/members/:identityId で、Organization からメンバーを削除します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypeallhasOrgRolehasOrgRoleSameOrAbovehasOrgOwnerRemainingAfterMemberRemoval.

リクエスト: deleteOrganizationMemberSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: deleteOrganizationMemberdeleteOrganizationMemberTerminator.

成功: 204; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const deleteOrganizationMemberRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
deleteOrganizationMember,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
['params', 'requestParams', 'identityId'],
],
'hasDeletedOrganizationMember'
)
),
// TODO: replace terminator
lift(withLogging(deleteOrganizationMemberTerminator))
),
method: 'DELETE',
path: '/organizations/:organizationId/members/:identityId',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
all(
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
),
hasOrgRoleSameOrAbove(
['params', 'requestParams', 'organizationId'],
['params', 'requestParams', 'identityId']
)
)
),
hasOrgOwnerRemainingAfterMemberRemoval(
['params', 'requestParams', 'organizationId'],
['params', 'requestParams', 'identityId']
),
],
});

findOrganizationsForMemberRoute

実装

エンドポイント: GET /organizations/members/:identityId

GET /organizations/members/:identityId で、直接および継承ロールを含む指定メンバーのすべての Organization を取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypeisSelf.

リクエスト: findOrganizationsForMemberSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: buildOrganizationsForMemberByRoleQueryfindOrganizationsnormalizeCertificateImagesnormalizeLogosOfOwnersbuildOrganizationsWithDescendantsQueryextractAncestorsbuildOrganizationsForMemberByIdsQuerycalculateMemberRoleForOrganizationsnormalizeOrganizationsForMember.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const findOrganizationsForMemberRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
buildOrganizationsForMemberByRoleQuery,
[
['params', 'requestParams', 'identityId'],
['params', 'requestQuery', 'roles'],
],
'organizationsForMemberQuery'
)
),
flatMapAsync(
ifElse(
match(equals('true'), ['params', 'requestQuery', 'includeInherited']),
compose(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'organizationsForMemberQuery'],
],
'organizationsForMember'
)
),
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImages,
[
['context', 'fileStorageDriver'],
['context', 'data', 'organizationsForMember'],
],
'organizationsForMemberWithCertificateImages'
)
),
flatMapAsync(
applyPayloadArgs(
normalizeLogosOfOwners,
[
['context', 'fileStorageDriver'],
[
'context',
'data',
'organizationsForMemberWithCertificateImages',
],
],
'organizationsForMemberWithCertificateImagesAndLogos'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildOrganizationsWithDescendantsQuery,
[
[
'context',
'data',
'organizationsForMemberWithCertificateImagesAndLogos',
],
],
'organizationsWithDescendantsQuery'
)
)
),
flatMapAsync(
// TODO: comment out withPagination for now due to the issue with the database patching
// withPagination(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'organizationsWithDescendantsQuery'],
],
'organizationsWithDescendants'
)
)
// )
),
flatMapAsync(
withLogging(
applyPayloadArgs(
extractAncestors,
[['context', 'data', 'organizationsWithDescendants']],
'concatenatedAncestors'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildOrganizationsForMemberByIdsQuery,
[
['params', 'requestParams', 'identityId'],
['context', 'data', 'concatenatedAncestors'],
],
'ancestorOrganizationsQuery'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'ancestorOrganizationsQuery'],
],
'ancestorOrganizations'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
calculateMemberRoleForOrganizations,
[
['context', 'data', 'organizationsWithDescendants'],
['context', 'data', 'ancestorOrganizations'],
['params', 'requestParams', 'identityId'],
],
'organizationWithMemberRoles'
)
)
)
),
compose(
withPagination(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'organizationsForMemberQuery'],
],
'paginatedOrganizationsForMember'
)
)
),
flatMapAsync(
applyPayloadArgs(
normalizeCertificateImages,
[
['context', 'fileStorageDriver'],
['context', 'data', 'paginatedOrganizationsForMember', 'data'],
],
'organizationsForMemberWithCertificateImages'
)
),
flatMapAsync(
applyPayloadArgs(
normalizeLogosOfOwners,
[
['context', 'fileStorageDriver'],
[
'context',
'data',
'organizationsForMemberWithCertificateImages',
],
],
'organizationsForMemberWithCertificateImagesAndLogos'
)
),
flatMapAsync(
withLogging(applyPayloadArgs(() => [], [], 'ancestorOrganizations'))
),
flatMapAsync(
withLogging(
applyPayloadArgs(
calculateMemberRoleForOrganizations,
[
[
'context',
'data',
'organizationsForMemberWithCertificateImagesAndLogos',
],
['context', 'data', 'ancestorOrganizations'],
['params', 'requestParams', 'identityId'],
],
'organizationWithMemberRoles'
)
)
)
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
normalizeOrganizationsForMember,
[['context', 'data', 'organizationWithMemberRoles']],
'normalizedOrganizationsForMember'
)
)
),
lift(
orThrow(
[
[OrganizationMemberNotFoundError, 404],
[OrganizationMemberRoleNotFoundError, 404],
[OrganizationDbError, 500],
],
[['context', 'data', 'normalizedOrganizationsForMember'], 200]
)
)
),
method: 'GET',
path: '/organizations/members/:identityId',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
isSelf(['params', 'requestParams', 'identityId'])
),
],
});

findOrganizationDescendantsRoute

実装

エンドポイント: GET /organizations/:organizationId/descendants

ページネーションと正規化を備えた Organization 子孫取得ルートです。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: findOrganizationDescendantsSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdbuildDescendantsQueryfindOrganizationsnormalizeOrganizationsapplySpec.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const findOrganizationDescendantsRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildDescendantsQuery,
[
['context', 'data', 'organization'],
['params', 'requestQuery', 'depth'],
],
'descendantsQuery'
)
)
),
flatMapAsync(
withPagination(
withLogging(
applyPayloadArgs(
findOrganizations,
[
['context', 'db', 'organizations'],
['context', 'data', 'descendantsQuery'],
],
'paginatedOrganizationDescendants'
)
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
normalizeOrganizations,
[['context', 'data', 'paginatedOrganizationDescendants', 'data']],
'normalizedOrganizations'
)
)
),
flatMapAsync(
applyPayloadArgs(
applySpec({ data: nthArg(0), metadata: { pagination: nthArg(1) } }),
[
['context', 'data', 'normalizedOrganizations'],
['context', 'data', 'paginatedOrganizationDescendants', 'metadata'],
],
'normalizedOrganizationsWithPagination'
)
),
lift(
orThrow(
[
[OrganizationInvalidQueryError, 400],
[OrganizationDbError, 500],
],
[['context', 'data', 'normalizedOrganizationsWithPagination'], 200]
)
)
),
method: 'GET',
path: '/organizations/:organizationId/descendants',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(
['owner', 'admin'],
['params', 'requestParams', 'organizationId']
)
),
],
});

getLogoUploadUrlRoute

実装

エンドポイント: GET /organizations/:organizationId/logo-upload-url

GET /organizations/:organizationId/logo-upload-url で、Organization ロゴ用の署名付きアップロード URL を生成します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: getSignedImageUploadUrlSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: generateFileUploadUrl.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const getLogoUploadUrlRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(generateFileUploadUrl, [
['context', 'fileStorageDriver'],
['params', 'requestQuery', 'contentType'],
['params', 'requestQuery', 'contentLength'],
])
),
lift(orThrow([[FileStorageServiceError, 500]], [['context', 'data'], 200]))
),
method: 'GET',
path: '/organizations/:organizationId/logo-upload-url',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

getCertificateUploadUrlRoute

実装

エンドポイント: GET /organizations/:organizationId/certificate-upload-url

GET /organizations/:organizationId/certificate-upload-url で、Organization 証明書用の署名付きアップロード URL を生成します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: getCertificateUploadUrlSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: generateFileUploadUrl.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const getCertificateUploadUrlRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(generateFileUploadUrl, [
['context', 'fileStorageDriver'],
['params', 'requestQuery', 'contentType'],
['params', 'requestQuery', 'contentLength'],
])
),
lift(orThrow([[FileStorageServiceError, 500]], [['context', 'data'], 200]))
),
method: 'GET',
path: '/organizations/:organizationId/certificate-upload-url',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

createChangeRequestRoute

実装

エンドポイント: POST /organizations/:organizationId/change-requests

POST /organizations/:organizationId/change-requests で Organization の変更リクエストを作成します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: createChangeRequestSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdvalidateOrganizationNamenoopextractTokenFromAuthorizationHeadercheckTokencreateChangeRequestbuildUpdateOrganizationAfterNewChangeRequestPayloadupdateOrganizationnormalizeEmptyBody.

成功: 204; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const createChangeRequestRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'rawOrganization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
validateOrganizationName,
[
['context', 'db', 'organizations'],
['context', 'data', 'rawOrganization'],
['params', 'requestParams', 'organizationId'],
['params', 'requestBody', 'name'],
],
'isValidOrganizationName'
)
)
),
flatMapAsync(
withLogging(
whenCookieAuth(
withLogging(
applyPayloadArgs(
noop,
[['context', 'request', 'cookies', 'accessToken']],
'accessToken'
)
),
withLogging(
applyPayloadArgs(
extractTokenFromAuthorizationHeader,
[['context', 'request', 'headers', 'authorization']],
'accessToken'
)
)
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
checkToken,
[
['context', 'db', 'onetimetokens'],
['context', 'configuration', 'authSecrets'],
['context', 'request'],
['context', 'data', 'accessToken'],
],
'checkTokenResult'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
createChangeRequest,
[
['context', 'db', 'organizationChangeRequests'],
['params', 'requestParams', 'organizationId'],
['context', 'data', 'checkTokenResult', 'tokenInfo', 'identityId'],
['params', 'requestBody'],
],
'changeRequestId'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildUpdateOrganizationAfterNewChangeRequestPayload,
[],
'organizationFieldsToUpdate'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
updateOrganization,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
['context', 'data', 'organizationFieldsToUpdate'],
],
'hasUpdatedOrganization'
)
)
),
flatMapAsync(
withLogging(applyPayloadArgs(normalizeEmptyBody, [], 'normalizedBody'))
),
lift(
withLogging(
orThrow(
[
[OrganizationBadRequestError, 400],
[OrganizationDbError, 500],
[AuthenticationBadRequestError, 400],
[AuthenticationUnauthorizedError, 401],
[AuthenticationInvalidTokenError, 400],
[AuthenticationUnexpectedDBError, 500],
[FileStorageServiceError, 500],
[OrganizationChangeRequestDbError, 500],
],
[['context', 'data', 'normalizedBody'], 204]
)
)
)
),
method: 'POST',
path: '/organizations/:organizationId/change-requests',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

findChangeRequestsForOrganizationRoute

実装

エンドポイント: GET /organizations/:organizationId/change-requests

GET /organizations/:organizationId/change-requests で、指定した Organization の変更リクエストを取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: findChangeRequestsForOrganizationSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: findChangeRequestsnormalizeChangeRequestsapplySpec.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const findChangeRequestsForOrganizationRoute = withRoute({
handler: compose(
withLogging(
withPagination(
applyPayloadArgs(
findChangeRequests,
[
['context', 'db', 'organizationChangeRequests'],
['params', 'requestParams', 'organizationId'],
],
'changeRequests'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
normalizeChangeRequests,
[
['context', 'fileStorageDriver'],
['context', 'data', 'changeRequests', 'data'],
],
'normalizedChangeRequests'
)
)
),
flatMapAsync(
applyPayloadArgs(
applySpec({ data: nthArg(0), metadata: { pagination: nthArg(1) } }),
[
['context', 'data', 'normalizedChangeRequests'],
['context', 'data', 'changeRequests', 'metadata'],
],
'normalizedBody'
)
),

lift(
withLogging(
orThrow(
[
[OrganizationChangeRequestDbError, 500],
[OrganizationChangeRequestError, 500],
],
[['context', 'data', 'normalizedBody'], 200]
)
)
)
),
method: 'GET',
path: '/organizations/:organizationId/change-requests',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});

getOrganizationFollowersRoute

実装

エンドポイント: GET /organizations/:organizationId/followers

GET /organizations/:organizationId/followers で Organization のフォロワーを取得します。

アクセス: ソースは次のバリデーターチェーンを順に実行します: isAuthenticatedsomecheckIdentityTypehasOrgRole.

リクエスト: getOrganizationFollowersSchema はパス、クエリ、ヘッダー、JSON 本文の契約を定義します。

パイプライン: getOrganizationByIdbuildOrganizationFollowersByFollowOrganizationIdQuerybuildWithoutMongoIdFindOptionsfindProfilesnormalizeFollowersapplySpec.

成功: 200; 完全なソースには、最終的な通常値、ターミネーター、または orThrow のレスポンス記述子が示されています。

失敗: バリデーターの失敗はパイプラインより前に発生します。ソースで対応付けられたブロックエラーとステータス対応は、以下の完全な定義に保持されています。

完全なソースを表示
export const getOrganizationFollowersRoute = withRoute({
handler: compose(
withLogging(
applyPayloadArgs(
getOrganizationById,
[
['context', 'db', 'organizations'],
['params', 'requestParams', 'organizationId'],
],
'organization'
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
buildOrganizationFollowersByFollowOrganizationIdQuery,
[['params', 'requestParams', 'organizationId']],
'filter'
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(buildWithoutMongoIdFindOptions, [], 'options')
)
),
flatMapAsync(
withPagination(
withLogging(
applyPayloadArgs(
findProfiles,
[
['context', 'db', 'profiles'],
['context', 'data', 'filter'],
['context', 'data', 'options'],
],
'paginatedFollowers'
)
)
)
),
flatMapAsync(
withLogging(
applyPayloadArgs(
normalizeFollowers,
[
['context', 'fileStorageDriver'],
['context', 'data', 'paginatedFollowers', 'data'],
],
'normalizedFollowers'
)
)
),
flatMapAsync(
applyPayloadArgs(
applySpec({ data: nthArg(0), metadata: { pagination: nthArg(1) } }),
[
['context', 'data', 'normalizedFollowers'],
['context', 'data', 'paginatedFollowers', 'metadata'],
],
'normalizedBody'
)
),
lift(
orThrow(
[
[OrganizationNotFoundError, 404],
[OrganizationDbError, 500],
[AvatarBlockError, 500],
[ProfileDbBlockError, 500],
],
[['context', 'data', 'normalizedBody'], 200]
)
)
),
method: 'GET',
path: '/organizations/:organizationId/followers',
validators: [
isAuthenticated(),
some(
checkIdentityType(['admin']),
hasOrgRole(['owner'], ['params', 'requestParams', 'organizationId'])
),
],
});