Files
azuredatastudio/extensions/sql-database-projects/src/sqldbproj.d.ts
Benjin Dubishar 15c0c68e44 SQL Database Projects backend swap to DacFx/Tools Service (#22451)
* Move call to STS move api into project.ts (#22071)

* move call to STS move api into project.ts

* remove undefined

* Remove convert to sdk style code (#22081)

* remove convert to sdk style code

* remove from package.json

* Merging latest from main (#22097)

* [SQL-Migration] Login migrations telemetry (#22038)

This PR enhances telemetry for login migrations (and in the following ways:

Add details for starting migration (number of logins migrating, type of logins)
Log Migration result (number of errors per step, duration of each step, type of logins, if system error occurred)
Add sql-migration extension to our telemetry
Adds details when trying to connect to target
Tracks clicking "done" from the wizard
Fixes bucketizing for navigating telemetry in the login migration wizard
Sample usage of kusto query for new telemetry:
RawEventsADS
| where EventName contains 'sql-migration'
| extend view = tostring(Properties['view'])
| extend action = tostring(Properties['action'])
| extend buttonPressed = tostring(Properties['buttonpressed'])
| extend pageTitle = tostring(Properties['pagetitle'])
| extend adsVersion = tostring(Properties['common.adsversion'])
| extend targetType = tostring(Properties['targettype'])
| extend tenantId = tostring(Properties['tenantid'])
| extend subscriptionId = tostring(Properties['subscriptionid'])
| where view contains "login"
//| where adsVersion contains "1.42.0-insider"
| where ClientTimestamp >= ago(18h)
| project EventName, ClientTimestamp, SessionId, view, pageTitle, action, buttonPressed, targetType
, tenantId, subscriptionId
, adsVersion, OSVersion, Properties

* Add Secure Enclaves dropdown with customizable Advanced options (#22019)

* Update extension READMEs (#22079)

* Fix query-history README images (#22084)

* [Loc] update to mssql and sql-migration xlf files (#22087)

* [Loc] small fix to Portuguese lcl file (#22088)

* [Loc] small fix to Portuguese lcl file

* remove newline

* Adding None bindings to the sqlProjects service (#22085)

* Adding None bindings

* updating names of None bindings

---------

Co-authored-by: AkshayMata <akam520@gmail.com>
Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com>
Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
Co-authored-by: Alex Ma <alma1@microsoft.com>

* Swap add and update sqlcmd variables in sql projects to use STS apis (#22086)

* delete sqlcmd variable working

* undo add

* remove variable from add and update sqlcmd variable apis

* hookup add and edit sqlcmd variable

* update vscode-mssql.d.ts

* move add and edit to project.ts

* update STS and tests

* move delete sqlcmd variable to project.ts (#22104)

* add test for add and edit sqlcmd variable (#22107)

* Swapping property access to STS (#22115)

* checkpoint

* Adding sqlproj property bindings

* Swapping out property loading and setting

* consolidating to this.sqlProjService

* Update dacpac reference to use STS api (#22116)

* Update add dacpac reference to use STS api

* remove changes for project ref

* validate unset settings from add database reference dialog

* update one more place getting sqlprojservice

* addressing comments

* fix path for dacpac reference (#22143)

* Swap add project reference to call STS (#22148)

* initial changes for swapping add project reference

* fix include path

* move common logic to helper function

* read sqlcmd variables from STS (#22147)

* Swapping .sqlproj- and crossplat compatibility-related functions to use STS (#22146)

* Supporting roundtrip

* Updating sqlproj style checks and cross-platform compatibility to use STS

* removing unnecessary awaits

* Fixing assertions

* Adding roundtrip update confirmations

* test cleanup

* cleaning up comment; localizing error

* Swap add system db reference (#22171)

* swap adding system database references

* fix tests

* remove only in test

* Read database references from STS (#22179)

* Read database references from STS

* fix system dacpac names

* fix project reference name

* Swap changeTargetPlatform to call STS (#22172)

* swap changeTargetPlatform to call STS

* Address comments

* De-duplicating enum for SystemDatabase (#22196)

* Deudping SystemDatabase enum

* simplifying enum refs

* Removing the now-unused imports code from SqlProjects (#22199)

* Removing unused importTargets entries

* whitespace; also to retrigger github checks on correct branch

* Hooking in Move() for Nones and PublishProfiles (#22200)

* Swap delete database reference to call STS (#22215)

* initial changes

* update contracts

* remove unnecessary info from SystemDatabaseReferenceProjectEntry

* uppercase master and msdb

* cleanup

* update test

* update comment

* undo change in projectController.ts

* remove unused system dacpac helper functions (#22204)

* more cleanup of project.ts (#22242)

* fix a couple database reference tests (#22248)

* Organizing sqlcmd variable and db reference code (#22284)

* organize database references and sqlcmd variable functions

* separate database reference tests

* Script and folder get + add support (#22166)

* Initial sqlobjectscripts

* adding mock filter

* test fixing

* another test passing

* swapping pre/post/none checkpoint

* awaiters

* convert addExistingItem

* swapping folders

* removing print

* stripping out project folder and file readers

* adding some regions

* Updating sqlproj style checks and cross-platform compatibility to use STS

* Updating sqlproj style checks and cross-platform compatibility to use STS

* added type property to tree items

* projectController swapovers

* removing imported targets

* Deleting the last of the TS XML parsing!

* Removing old functions

* renamed readNoneScripts to readNoneItems

* fixing path passed to STS calls

* remove system dacpac tests that were moved to DacFx (#22299)

* fix error when opening file after adding a file to sql project (#22309)

* fix error when opening file after adding a file to sql project

* remove unused import

* fix exclude for table and externalStreamingJob (#22310)

* add reload project (#22313)

* set DSP from STS (#22320)

* fix adding post-deployment script and existing item (#22317)

* Test cleanup for .sqlproj content operations (#22330)

* Fixing up tests

* sqlproj content operations tests

* remove only

* Cleanup

* Correcting collation

* cleanup constants.ts (#22336)

* fix folders not showing in project tree (#22319)

* Fix project controller tests (#22327)

* fixing ProjectController tests after swap

* remove only from database reference tests

* change system dbs back to lowercase in sql projects (#22353)

* Bump tools service

* Updated yarn.lock file

* pass SystemDacpacsLocation when building legacy style sql projects (#22329)

* Benjin/fix types (#22365)

* Updated yarn.lock file

* Fixing types

* fix projectController tests (#22375)

* Fixing the deletion flow for files and folders (#22366)

* checkpoint

* PR feedback

* Fixing up SDK-style operations project test group (#22377)

* Fixing up SDK-style project test group

* Removing .only

* Fixing up database reference tests (#22380)

* Fixing DB reference test group

* Extra cleanup

* removing only

* Consolidating None and PublishProfile; lighting up test (#22382)

* Lighting up project property tests (#22395)

* Checkpoint

* Lighting up project property tests

* removing timeout

* Fixing buildHelper test (#22400)

* Unskipping up roundtrip test (#22397)

* Refactoring database references to split literalVariable from databaseName (#22412)

* refactoring database references to split databaseVariableLiteralValue out from databaseName

* renaming more properties

* Removing branch in entry population

* removing only

* Fixing baselines for delete test

* PR feedback

* Fixing up ProjectTree tests (#22419)

* Fixing up projectTree tests

* remove only

* Updating projectController exclude test (#22413)

* Updating test

* moving filtering for external folders to readFolders() method

* Removing EntryType import

* fix ups (#22435)

* adding extra info for test failure

* hide exclude folder from context menu until it's supported (#22454)

* Adding current test name to generated folder to avoid conflicts (#22478)

* Adding current test name to generated folder to avoid conflicts

* passing correct test parameter in

* Adding trimming and entropy

* Deleting unused baselines (#22497)

* Replacing addToProject() with addSqlObjectScripts() (#22489)

* checkpoint

* Fixing test

* Updating file scraper function to filter only to .sql files (no folders, no txt)

* changing var names to reflect that the lists only contain .sql scripts

---------

Co-authored-by: Kim Santiago <31145923+kisantia@users.noreply.github.com>
Co-authored-by: AkshayMata <akam520@gmail.com>
Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com>
Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
Co-authored-by: Alex Ma <alma1@microsoft.com>
2023-03-28 13:39:57 -07:00

378 lines
11 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'sqldbproj' {
import * as vscode from 'vscode';
import { DeploymentOptions as mssqlDeploymentOptions } from 'mssql';
import { DeploymentOptions as vscodeMssqlDeploymentOptions } from 'vscode-mssql';
export const enum extension {
name = 'Microsoft.sql-database-projects',
vsCodeName = 'ms-mssql.sql-database-projects-vscode'
}
/**
* sql database projects extension
*/
export interface IExtension {
/**
* Create a project
* @param name name of the project
* @param location the parent directory
* @param projectTypeId the ID of the project/template
* @param targetPlatform the target platform for the project. Default is SQL Server 2019
* @param sdkStyle whether the project is sdk-style. Default is false
* @returns Uri of the newly created project file
*/
createProject(name: string, location: vscode.Uri, projectTypeId: string, targetPlatform: SqlTargetPlatform, sdkStyle?: boolean): Promise<vscode.Uri>;
/**
* Opens and loads a .sqlproj file
*/
openProject(projectFilePath: string): Promise<ISqlProject>;
/**
* Opens the data workspace new project dialog with only the sql database template
* @param allowedTargetPlatforms specific target platforms to allow. If not specified, all target platforms for sql will be listed
* @returns uri of the created the project or undefined if no project was created
*/
openSqlNewProjectDialog(allowedTargetPlatforms?: SqlTargetPlatform[]): Promise<vscode.Uri | undefined>;
/**
* Gets the list of .sql scripts contained in a project
* @param projectFilePath
*/
getProjectScriptFiles(projectFilePath: string): Promise<string[]>;
/**
* Gets the Database Schema Provider version for a SQL project
*/
getProjectDatabaseSchemaProvider(projectFilePath: string): Promise<string>;
/**
* Generate project from OpenAPI specification file
* @param options Options to use when generating a project from an OpenAPI spec
* @returns the generated sql project
*/
generateProjectFromOpenApiSpec(options?: GenerateProjectFromOpenApiSpecOptions): Promise<ISqlProject | undefined>;
/**
* Prompts the user to add a new item to the specified project
* @param project The project to add the item to
* @param relativeFilePath The relative path in the project where the item should be added
* @param options The additional options to use
*/
addItemPrompt(project: ISqlProject, relativeFilePath: string, options?: AddItemOptions): Promise<void>;
/**
* Gathers information required for publishing a project to a docker container, prompting the user as necessary
* @param project The Project being published
*/
getPublishToDockerSettings(project: ISqlProject): Promise<IPublishToDockerSettings | undefined>;
/**
* Gets the information required to start a docker container for publishing to
* @param projectName The name of the project being published
* @param baseImage The base docker image being deployed
* @param imageUniqueId The unique ID to use in the name, default is a random GUID
*/
getDockerImageSpec(projectName: string, baseImage: string, imageUniqueId?: string): DockerImageSpec;
/**
* Checks if any containers with the specified label already exist, and if they do prompt the user whether they want to clean them up
* @param imageLabel The label of the container to search for
*/
cleanDockerObjectsIfNeeded(imageLabel: string): Promise<void>;
}
export interface AddItemOptions {
/**
* The type of item to add. If not specified the user will choose from a list of available types
*/
itemType?: string,
/**
* The default name to display in the name prompt
*/
defaultName?: string
}
/**
* The type of an item in a SQL Project
*/
export const enum ItemType {
script = 'script',
table = 'table',
view = 'view',
storedProcedure = 'storedProcedure',
dataSource = 'dataSource',
fileFormat = 'fileFormat',
externalStream = 'externalStream',
externalStreamingJob = 'externalStreamingJob',
folder = 'folder',
preDeployScript = 'preDeployScript',
postDeployScript = 'postDeployScript'
}
/**
* Options to use when generating a project from an OpenAPI spec
*/
export type GenerateProjectFromOpenApiSpecOptions = {
/**
* The OpenAPI spec file to use instead of having the user select it
*/
openApiSpecFile?: vscode.Uri,
/**
* The default name to give the generated project in the name input prompt
*/
defaultProjectName?: string,
/**
* The default location to show when the user is selecting the output location of the project
*/
defaultOutputLocation?: vscode.Uri,
/**
* If true then the project will not be opened in the workspace after being created
*/
doNotOpenInWorkspace?: boolean,
/**
* Create SQL Project SDK style or non SDK style. The default is non SDK style.
*/
isSDKStyle?: boolean
};
export interface ISqlProject {
/**
* Reads the project setting and contents from the file
*/
readProjFile(): Promise<void>;
/**
* Adds a pre-deployment script
* @param relativePath
*/
addPreDeploymentScript(relativePath: string): Promise<void>;
/**
* Adds a post-deployment script
* @param relativePath
*/
addPostDeploymentScript(relativePath: string): Promise<void>;
/**
* Add a SQL object script that will be included in the schema
* @param relativePath
*/
addSqlObjectScript(relativePath: string): Promise<void>;
/**
* Adds multiple SQL object scripts that will be included in the schema
* @param relativePaths Array of paths relative to the .sqlproj file
*/
addSqlObjectScripts(relativePaths: string[]): Promise<void>;
/**
* Adds a folder to the project, and saves the project file
*
* @param relativeFolderPath Relative path of the folder
*/
addFolder(relativeFolderPath: string): Promise<void>;
/**
* Writes a file to disk if contents are provided, adds that file to the project, and writes it to disk
*
* @param relativeFilePath Relative path of the file
* @param contents Contents to be written to the new file
* @param itemType Type of the project entry to add. This maps to the build action for the item.
*/
addScriptItem(relativeFilePath: string, contents?: string, itemType?: string): Promise<IFileProjectEntry>;
/**
* Adds a SQLCMD variable to the project
* @param name name of the variable
* @param defaultValue
*/
addSqlCmdVariable(name: string, defaultValue: string): Promise<void>;
/**
* Appends given database source to the DatabaseSource property element.
* If property element does not exist, then new one will be created.
*
* @param databaseSource Source of the database to add
*/
addDatabaseSource(databaseSource: string): Promise<void>;
/**
* Removes database source from the DatabaseSource property element.
* If no sources remain, then property element will be removed from the project file.
*
* @param databaseSource Source of the database to remove
*/
removeDatabaseSource(databaseSource: string): Promise<void>;
/**
* returns the sql version the project is targeting
*/
getProjectTargetVersion(): string;
/**
* Gets the default database collation set in the project.
*
* @returns Default collation for the database set in the project.
*/
getDatabaseDefaultCollation(): string;
/**
* Path where dacpac is output to after a successful build
*/
readonly dacpacOutputPath: string;
/**
* Path to folder containing the project file
*/
readonly projectFolderPath: string;
/**
* Project file path
*/
readonly projectFilePath: string;
/**
* Project file name
*/
readonly projectFileName: string;
/**
* Files and folders that are included in the project
*/
readonly files: IFileProjectEntry[];
/**
* SqlCmd variables and their values
*/
readonly sqlCmdVariables: Record<string, string>;
/**
* Pre-deployment scripts in this project
*/
readonly preDeployScripts: IFileProjectEntry[];
/**
* Post-deployment scripts in this project
*/
readonly postDeployScripts: IFileProjectEntry[];
/**
* "None" scripts in this project (scripts ignored by the build)
*/
readonly noneDeployScripts: IFileProjectEntry[];
readonly databaseReferences: IDatabaseReferenceProjectEntry[];
}
export const enum EntryType {
File,
Folder,
DatabaseReference,
SqlCmdVariable
}
export interface IProjectEntry {
type: EntryType;
}
/**
* Represents an entry in a project file
*/
export interface IFileProjectEntry extends IProjectEntry {
fsUri: vscode.Uri;
relativePath: string;
pathForSqlProj(): string;
}
/**
* Represents a database reference entry in a project file
*/
export interface IDatabaseReferenceProjectEntry extends IFileProjectEntry {
referenceName: string;
databaseVariableLiteralValue?: string;
suppressMissingDependenciesErrors: boolean;
}
/**
* Target platforms for a sql project
*/
export const enum SqlTargetPlatform {
sqlServer2012 = 'SQL Server 2012',
sqlServer2014 = 'SQL Server 2014',
sqlServer2016 = 'SQL Server 2016',
sqlServer2017 = 'SQL Server 2017',
sqlServer2019 = 'SQL Server 2019',
sqlServer2022 = 'SQL Server 2022',
sqlAzure = 'Azure SQL Database',
sqlDW = 'Azure Synapse SQL Pool',
sqlEdge = 'Azure SQL Edge'
}
export interface ISqlConnectionProperties {
tenantId?: string,
accountId?: string
serverName: string,
userName: string,
password: string,
port: number,
dbName: string,
profileName?: string,
connectionRetryTimeout?: number
}
/**
* Settings for creating the docker container a project is being published to
*/
export interface IDockerSettings extends ISqlConnectionProperties {
dockerBaseImage: string,
dockerBaseImageEula: string,
}
/**
* Settings for publishing a SQL Project to a docker container
*/
export interface IPublishToDockerSettings {
dockerSettings: IDockerSettings;
sqlProjectPublishSettings: ISqlProjectPublishSettings;
}
export type DeploymentOptions = mssqlDeploymentOptions | vscodeMssqlDeploymentOptions;
/**
* Settings to use when publishing a SQL Project
*/
export interface ISqlProjectPublishSettings {
databaseName: string;
serverName: string;
connectionUri: string;
sqlCmdVariables?: Record<string, string>;
deploymentOptions?: DeploymentOptions;
profileUsed?: boolean;
}
/**
* Information for deploying a new docker container
*/
interface DockerImageSpec {
/**
* The label to apply to the container
*/
label: string;
/**
* The full name to give the container
*/
containerName: string;
/**
* The tag to apply to the container
*/
tag: string
}
}