mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-20 15:25:07 +01:00
* add Materialized Views feature flag * fetch MV properties from RP API and capture them in our data models * AddMaterializedViewPanel * undefined check * subpartition keys * Partition Key, Throughput, Unique Keys * All views associated with a container (#2063) and Materialized View Target Container (#2065) Identified Source container and Target container Created tabs in Scale and Settings respectively Changed the Icon of target container * Add MV Panel * format * format * styling * add tests * tests * test files (#2074) Co-authored-by: nishthaAhujaa * fix type error * fix tests * merge conflict * Panel Integration (#2075) * integrated panel * edited header text --------- Co-authored-by: nishthaAhujaa <nishtha17354@iiittd.ac.in> Co-authored-by: Asier Isayas <aisayas@microsoft.com> * updated tests (#2077) Co-authored-by: nishthaAhujaa * fix tests * update treeNodeUtil test snap * update settings component test snap * fixed source container in global "New Materialized View" * source container check (#2079) Co-authored-by: nishthaAhujaa * renamed Materialized Views to Global Secondary Index * more renaming * fix import * fix typo * disable materialized views for Fabric * updated input validation --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com> Co-authored-by: Nishtha Ahuja <45535788+nishthaAhujaa@users.noreply.github.com> Co-authored-by: nishthaAhujaa <nishtha17354@iiittd.ac.in>
75 lines
2.5 KiB
TypeScript
75 lines
2.5 KiB
TypeScript
import { constructRpOptions } from "Common/dataAccess/createCollection";
|
|
import { handleError } from "Common/ErrorHandlingUtils";
|
|
import { Collection, CreateMaterializedViewsParams as CreateGlobalSecondaryIndexParams } from "Contracts/DataModels";
|
|
import { userContext } from "UserContext";
|
|
import { createUpdateSqlContainer } from "Utils/arm/generatedClients/cosmos/sqlResources";
|
|
import {
|
|
CreateUpdateOptions,
|
|
SqlContainerResource,
|
|
SqlDatabaseCreateUpdateParameters,
|
|
} from "Utils/arm/generatedClients/cosmos/types";
|
|
import { logConsoleInfo, logConsoleProgress } from "Utils/NotificationConsoleUtils";
|
|
|
|
export const createGlobalSecondaryIndex = async (params: CreateGlobalSecondaryIndexParams): Promise<Collection> => {
|
|
const clearMessage = logConsoleProgress(
|
|
`Creating a new global secondary index ${params.materializedViewId} for database ${params.databaseId}`,
|
|
);
|
|
|
|
const options: CreateUpdateOptions = constructRpOptions(params);
|
|
|
|
const resource: SqlContainerResource = {
|
|
id: params.materializedViewId,
|
|
};
|
|
if (params.materializedViewDefinition) {
|
|
resource.materializedViewDefinition = params.materializedViewDefinition;
|
|
}
|
|
if (params.analyticalStorageTtl) {
|
|
resource.analyticalStorageTtl = params.analyticalStorageTtl;
|
|
}
|
|
if (params.indexingPolicy) {
|
|
resource.indexingPolicy = params.indexingPolicy;
|
|
}
|
|
if (params.partitionKey) {
|
|
resource.partitionKey = params.partitionKey;
|
|
}
|
|
if (params.uniqueKeyPolicy) {
|
|
resource.uniqueKeyPolicy = params.uniqueKeyPolicy;
|
|
}
|
|
if (params.vectorEmbeddingPolicy) {
|
|
resource.vectorEmbeddingPolicy = params.vectorEmbeddingPolicy;
|
|
}
|
|
if (params.fullTextPolicy) {
|
|
resource.fullTextPolicy = params.fullTextPolicy;
|
|
}
|
|
|
|
const rpPayload: SqlDatabaseCreateUpdateParameters = {
|
|
properties: {
|
|
resource,
|
|
options,
|
|
},
|
|
};
|
|
|
|
try {
|
|
const createResponse = await createUpdateSqlContainer(
|
|
userContext.subscriptionId,
|
|
userContext.resourceGroup,
|
|
userContext.databaseAccount.name,
|
|
params.databaseId,
|
|
params.materializedViewId,
|
|
rpPayload,
|
|
);
|
|
logConsoleInfo(`Successfully created global secondary index ${params.materializedViewId}`);
|
|
|
|
return createResponse && (createResponse.properties.resource as Collection);
|
|
} catch (error) {
|
|
handleError(
|
|
error,
|
|
"CreateGlobalSecondaryIndex",
|
|
`Error while creating global secondary index ${params.materializedViewId}`,
|
|
);
|
|
throw error;
|
|
} finally {
|
|
clearMessage();
|
|
}
|
|
};
|