Tables query
This commit is contained in:
Родитель
63aa9b421d
Коммит
e74b445453
|
@ -0,0 +1,13 @@
|
|||
[
|
||||
{
|
||||
// A very simple org, not an enterprise cloud product.
|
||||
"name": "OpenContoso",
|
||||
|
||||
// To simplify smaller installations, this indicates that at startup, all
|
||||
// configured modern GItHub Apps should iterate through their installations
|
||||
// to identify the installation ID and other information about this org.
|
||||
// This will also backfill the organization ID value in the config.
|
||||
"startupDiscover": true,
|
||||
"active": true
|
||||
}
|
||||
]
|
|
@ -215,12 +215,12 @@ export class Operations
|
|||
(d.hasFeature(OrganizationFeature.Ignore) && d.hasFeature(OrganizationFeature.Invisible))
|
||||
);
|
||||
this._organizationSettings = unignoredDynamicOrganizations;
|
||||
this._dynamicOrganizationIds = new Set(
|
||||
unignoredDynamicOrganizations.map((org) => Number(org.organizationId))
|
||||
);
|
||||
// Discover of installations at startup
|
||||
const toDiscover = organizationSettings.filter((os) => os.hasFeature('startupDiscover'));
|
||||
await this.startupDiscoverInstallations(toDiscover);
|
||||
this._dynamicOrganizationIds = new Set(
|
||||
unignoredDynamicOrganizations.map((org) => Number(org.organizationId))
|
||||
);
|
||||
}
|
||||
if (this._organizationSettings && organizationSettingsProvider) {
|
||||
DynamicRestartCheckHandle = setInterval(
|
||||
|
@ -388,19 +388,19 @@ export class Operations
|
|||
const centralOperationsToken = this.config.github.operations.centralOperationsToken;
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const name = names[i];
|
||||
let dynamicSettings: OrganizationSetting = null;
|
||||
this._organizationSettings.map((dos) => {
|
||||
let settings: OrganizationSetting = null;
|
||||
for (const dos of this._organizationSettings) {
|
||||
if (
|
||||
dos.active &&
|
||||
dos.organizationName.toLowerCase() === name.toLowerCase() &&
|
||||
!dos.hasFeature(OrganizationFeature.Invisible)
|
||||
) {
|
||||
dynamicSettings = dos;
|
||||
settings = dos;
|
||||
}
|
||||
});
|
||||
}
|
||||
const organization = this.createOrganization(
|
||||
name,
|
||||
dynamicSettings,
|
||||
settings,
|
||||
centralOperationsToken,
|
||||
GitHubAppAuthenticationType.BestAvailable
|
||||
);
|
||||
|
|
|
@ -31,6 +31,7 @@ import {
|
|||
import { PostgresSettings, PostgresConfiguration } from '../lib/entityMetadataProvider/postgres';
|
||||
import { IDictionary } from '../interfaces';
|
||||
import { CreateError, ErrorHelper } from '../transitional';
|
||||
import { MemoryConfiguration, TableConfiguration } from '../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('OrganizationAnnotation');
|
||||
const thisProviderType = type;
|
||||
|
@ -152,7 +153,13 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityInstantiat
|
|||
});
|
||||
EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnName, organizationId);
|
||||
|
||||
// NOTE: No memory mapping for this type that is only in Postgres
|
||||
const defaultTableName = defaultPostgresTableName;
|
||||
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
|
||||
EntityMetadataMappings.Register(
|
||||
type,
|
||||
|
|
|
@ -19,6 +19,9 @@ import {
|
|||
PostgresConfiguration,
|
||||
} from '../../lib/entityMetadataProvider/postgres';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { TableConfiguration, TableSettings } from '../../lib/entityMetadataProvider';
|
||||
import { odata, TableEntityQueryOptions } from '@azure/data-tables';
|
||||
import { CreateError } from '../../transitional';
|
||||
|
||||
const type = new EntityMetadataType('OrganizationMemberCache');
|
||||
|
||||
|
@ -41,6 +44,8 @@ const Field: IOrganizationMemberCacheProperties = {
|
|||
|
||||
const fieldNames = Object.getOwnPropertyNames(Field);
|
||||
|
||||
const defaultTableName = 'organizationmembercache';
|
||||
|
||||
export class OrganizationMemberCacheEntity implements IOrganizationMemberCacheProperties {
|
||||
uniqueId: string;
|
||||
cacheUpdated: Date;
|
||||
|
@ -116,7 +121,11 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnNa
|
|||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMapping, fieldNames, []);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'organizationmembercache');
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(
|
||||
type,
|
||||
PostgresSettings.PostgresDefaultTypeColumnName,
|
||||
|
@ -215,6 +224,58 @@ EntityMetadataMappings.Register(
|
|||
}
|
||||
);
|
||||
|
||||
EntityMetadataMappings.Register(
|
||||
type,
|
||||
TableSettings.TableQueries,
|
||||
(query: IEntityMetadataFixedQuery, fixedPartitionKey: string) => {
|
||||
switch (query.fixedQueryType) {
|
||||
case FixedQueryType.OrganizationMemberCacheGetAll: {
|
||||
return {
|
||||
filter: odata`PartitionKey eq ${fixedPartitionKey}`,
|
||||
} as TableEntityQueryOptions;
|
||||
}
|
||||
case FixedQueryType.OrganizationMemberCacheDeleteByOrganizationId: {
|
||||
const { organizationId } = query as OrganizationMemberCacheDeleteByOrganizationId;
|
||||
throw CreateError.ServerError('Not implemented yet. Requires delete query hack or refactor.');
|
||||
}
|
||||
case FixedQueryType.OrganizationCacheGetAllBasics: {
|
||||
throw CreateError.ServerError('Not implemented.');
|
||||
}
|
||||
case FixedQueryType.OrganizationOwnersCacheByOrganizationId: {
|
||||
const { organizationId } = query as OrganizationMemberCacheFixedQueryByOrganizationId;
|
||||
if (!organizationId) {
|
||||
throw new Error('organizationId required');
|
||||
}
|
||||
return {
|
||||
filter: odata`PartitionKey eq ${fixedPartitionKey} and role eq 'admin' and organizationid eq ${organizationId}`,
|
||||
} as TableEntityQueryOptions;
|
||||
}
|
||||
case FixedQueryType.OrganizationMemberCacheByOrganizationId: {
|
||||
const { organizationId } = query as OrganizationMemberCacheFixedQueryByOrganizationId;
|
||||
if (!organizationId) {
|
||||
throw new Error('organizationId required');
|
||||
}
|
||||
return {
|
||||
filter: odata`PartitionKey eq ${fixedPartitionKey} and organizationid eq ${organizationId}`,
|
||||
} as TableEntityQueryOptions;
|
||||
}
|
||||
case FixedQueryType.OrganizationMemberCacheByUserId: {
|
||||
const { userId } = query as OrganizationMemberCacheFixedQueryByUserId;
|
||||
if (!userId) {
|
||||
throw new Error('userId required');
|
||||
}
|
||||
return {
|
||||
filter: odata`PartitionKey eq ${fixedPartitionKey} and userid eq ${userId}`,
|
||||
} as TableEntityQueryOptions;
|
||||
}
|
||||
default:
|
||||
throw new Error(
|
||||
`The fixed query type "${query.fixedQueryType}" is not implemented by this provider for the type ${type}, or is of an unknown type`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Runtime validation of FieldNames
|
||||
for (let i = 0; i < fieldNames.length; i++) {
|
||||
const fn = fieldNames[i];
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
import { stringOrNumberAsString } from '../../utils';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { Operations } from '../../business/operations';
|
||||
import { TableConfiguration } from '../../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('RepositoryCache');
|
||||
|
||||
|
@ -99,7 +100,13 @@ EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMappin
|
|||
repositoryId,
|
||||
]);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'repositorycache');
|
||||
const defaultTableName = 'repositorycache';
|
||||
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(type, PostgresSettings.PostgresDefaultTypeColumnName, 'repositorycache');
|
||||
PostgresConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
PostgresConfiguration.ValidateMappings(type, fieldNames, [repositoryId]);
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from '../../lib/entityMetadataProvider/postgres';
|
||||
import { stringOrNumberAsString } from '../../utils';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { TableConfiguration } from '../../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('RepositoryCollaboratorCache');
|
||||
|
||||
|
@ -155,7 +156,13 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnNa
|
|||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMapping, fieldNames, []);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'repositorycollaboratorcache');
|
||||
const defaultTableName = 'repositorycollaboratorcache';
|
||||
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(
|
||||
type,
|
||||
PostgresSettings.PostgresDefaultTypeColumnName,
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
PostgresSettings,
|
||||
PostgresConfiguration,
|
||||
} from '../../lib/entityMetadataProvider/postgres';
|
||||
import { TableSettings } from '../../lib/entityMetadataProvider/table';
|
||||
import { TableConfiguration, TableSettings } from '../../lib/entityMetadataProvider/table';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { odata, TableEntityQueryOptions } from '@azure/data-tables';
|
||||
|
||||
|
@ -294,47 +294,10 @@ EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMappin
|
|||
repositoryId,
|
||||
]);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'repositorymetadata');
|
||||
const defaultTableName = 'repositorymetadata';
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(type, PostgresSettings.PostgresDefaultTypeColumnName, 'repository');
|
||||
PostgresConfiguration.MapFieldsToColumnNames(
|
||||
type,
|
||||
new Map<string, string>([
|
||||
[Field.createdByThirdPartyId, (Field.createdByThirdPartyId as string).toLowerCase()],
|
||||
[Field.createdByThirdPartyUsername, (Field.createdByThirdPartyUsername as string).toLowerCase()],
|
||||
|
||||
[Field.createdByCorporateDisplayName, (Field.createdByCorporateDisplayName as string).toLowerCase()],
|
||||
[Field.createdByCorporateId, (Field.createdByCorporateId as string).toLowerCase()],
|
||||
[Field.createdByCorporateUsername, (Field.createdByCorporateUsername as string).toLowerCase()],
|
||||
|
||||
[Field.created, (Field.created as string).toLowerCase()],
|
||||
|
||||
[Field.organizationName, (Field.organizationName as string).toLowerCase()],
|
||||
[Field.organizationId, (Field.organizationId as string).toLowerCase()], // net new
|
||||
|
||||
[Field.repositoryName, (Field.repositoryName as string).toLowerCase()],
|
||||
// [repositoryId, azureTableRepositoryIdField], // in table, RowKey is not the repo ID
|
||||
|
||||
[Field.initialTeamPermissions, (Field.initialTeamPermissions as string).toLowerCase()], // special processing case
|
||||
[Field.initialAdministrators, (Field.initialAdministrators as string).toLowerCase()], // special processing case
|
||||
|
||||
[Field.initialRepositoryDescription, (Field.initialRepositoryDescription as string).toLowerCase()],
|
||||
[Field.initialRepositoryVisibility, (Field.initialRepositoryVisibility as string).toLowerCase()],
|
||||
[Field.initialRepositoryHomepage, (Field.initialRepositoryHomepage as string).toLowerCase()],
|
||||
|
||||
[Field.initialLicense, (Field.initialLicense as string).toLowerCase()],
|
||||
[Field.initialTemplate, (Field.initialTemplate as string).toLowerCase()],
|
||||
[Field.initialGitIgnoreTemplate, (Field.initialGitIgnoreTemplate as string).toLowerCase()],
|
||||
[Field.initialCorrelationId, (Field.initialCorrelationId as string).toLowerCase()],
|
||||
|
||||
[Field.projectType, (Field.projectType as string).toLowerCase()],
|
||||
[Field.releaseReviewJustification, (Field.releaseReviewJustification as string).toLowerCase()],
|
||||
[Field.releaseReviewType, (Field.releaseReviewType as string).toLowerCase()],
|
||||
[Field.releaseReviewUrl, (Field.releaseReviewUrl as string).toLowerCase()],
|
||||
|
||||
[Field.lockdownState, Field.lockdownState.toLowerCase()],
|
||||
[Field.transferSource, Field.transferSource.toLowerCase()],
|
||||
])
|
||||
);
|
||||
PostgresConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
PostgresConfiguration.ValidateMappings(type, fieldNames, [repositoryId]);
|
||||
|
||||
EntityMetadataMappings.Register(
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from '../../lib/entityMetadataProvider/postgres';
|
||||
import { stringOrNumberAsString } from '../../utils';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { TableConfiguration } from '../../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('RepositoryTeamCache');
|
||||
|
||||
|
@ -147,6 +148,8 @@ export class RepositoryTeamCacheFixedQueryByRepositoryId implements IEntityMetad
|
|||
}
|
||||
}
|
||||
|
||||
const defaultTableName = 'repositoryteamcache';
|
||||
|
||||
EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityInstantiate, () => {
|
||||
return new RepositoryTeamCacheEntity();
|
||||
});
|
||||
|
@ -155,7 +158,11 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnNa
|
|||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMapping, fieldNames, []);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'repositoryteamcache');
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(type, PostgresSettings.PostgresDefaultTypeColumnName, 'repositoryteamcache');
|
||||
PostgresConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
PostgresConfiguration.ValidateMappings(type, fieldNames, []);
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
import { TeamCacheFixedQueryByOrganizationId, TeamCacheDeleteByOrganizationId } from '.';
|
||||
import { stringOrNumberAsString } from '../../utils';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { TableConfiguration } from '../../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('TeamCache');
|
||||
|
||||
|
@ -58,6 +59,8 @@ export class TeamCacheEntity implements ITeamCacheProperties {
|
|||
}
|
||||
}
|
||||
|
||||
const defaultTableName = 'teamcache';
|
||||
|
||||
EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityInstantiate, () => {
|
||||
return new TeamCacheEntity();
|
||||
});
|
||||
|
@ -66,7 +69,11 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnNa
|
|||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMapping, fieldNames, [teamId]);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'teamcache');
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(type, PostgresSettings.PostgresDefaultTypeColumnName, 'teamcache');
|
||||
PostgresConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
PostgresConfiguration.ValidateMappings(type, fieldNames, [teamId]);
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
} from '../../lib/entityMetadataProvider/postgres';
|
||||
import { stringOrNumberAsString } from '../../utils';
|
||||
import { MemoryConfiguration, MemorySettings } from '../../lib/entityMetadataProvider/memory';
|
||||
import { TableConfiguration } from '../../lib/entityMetadataProvider';
|
||||
|
||||
const type = new EntityMetadataType('TeamMemberCache');
|
||||
|
||||
|
@ -42,6 +43,8 @@ interface ITeamMemberCacheProperties {
|
|||
|
||||
const teamId = 'teamId';
|
||||
|
||||
const defaultTableName = 'teammembercache';
|
||||
|
||||
const Field: ITeamMemberCacheProperties = {
|
||||
uniqueId: 'uniqueId',
|
||||
cacheUpdated: 'cacheUpdated',
|
||||
|
@ -89,9 +92,15 @@ EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityInstantiat
|
|||
return new TeamMemberCacheEntity();
|
||||
});
|
||||
EntityMetadataMappings.Register(type, MetadataMappingDefinition.EntityIdColumnName, Field.uniqueId);
|
||||
|
||||
MemoryConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
EntityMetadataMappings.RuntimeValidateMappings(type, MemorySettings.MemoryMapping, fieldNames, []);
|
||||
PostgresConfiguration.SetDefaultTableName(type, 'teammembercache');
|
||||
|
||||
TableConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
TableConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
TableConfiguration.SetFixedPartitionKey(type, defaultTableName);
|
||||
|
||||
PostgresConfiguration.SetDefaultTableName(type, defaultTableName);
|
||||
EntityMetadataMappings.Register(type, PostgresSettings.PostgresDefaultTypeColumnName, 'teammembercache');
|
||||
PostgresConfiguration.MapFieldsToColumnNamesFromListLowercased(type, fieldNames);
|
||||
PostgresConfiguration.ValidateMappings(type, fieldNames, []);
|
||||
|
|
Загрузка…
Ссылка в новой задаче