updating default templates when creating new resource
This commit is contained in:
Родитель
bac4bed859
Коммит
67c93f7af0
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Microsoft Corporation
|
||||
Copyright (c) 2020 Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -424,4 +424,4 @@
|
|||
"vscode-azureextensionui": "^0.33.1",
|
||||
"vscode-extension-telemetry": "^0.1.6"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,8 @@ export class DocumentEditor implements vscode.Disposable {
|
|||
this.fileMap[localPath] = item;
|
||||
|
||||
const result = await item.readContent();
|
||||
await fse.writeJson(localPath, result ? result.content : {}, { spaces: 4 });
|
||||
const defaultJson = DocumentEditor.getDefaultJson(item.itemKind);
|
||||
await fse.writeJson(localPath, result ? result.content : defaultJson, { spaces: 4 });
|
||||
|
||||
const doc = await vscode.workspace.openTextDocument(localPath);
|
||||
vscode.languages.setTextDocumentLanguage(doc, "json");
|
||||
|
@ -57,4 +58,94 @@ export class DocumentEditor implements vscode.Disposable {
|
|||
const buffer: Buffer = crypto.randomBytes(5);
|
||||
return buffer.toString('hex');
|
||||
}
|
||||
|
||||
private static getDefaultJson(itemKind: string): any {
|
||||
if (itemKind === 'indexes') {
|
||||
return {
|
||||
"name": "my-index",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "Edm.String",
|
||||
"key": true,
|
||||
"searchable": true,
|
||||
"filterable": false,
|
||||
"facetable": false,
|
||||
"sortable": true
|
||||
},
|
||||
{
|
||||
"name": "text",
|
||||
"type": "Edm.String",
|
||||
"sortable": false,
|
||||
"searchable": true,
|
||||
"filterable": false,
|
||||
"facetable": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
else if (itemKind === "synonym map"){
|
||||
return {
|
||||
"name": "my-synonyms",
|
||||
"format":"solr",
|
||||
"synonyms": "USA, United States, United States of America\nWashington, Wash., WA => WA\n"
|
||||
}
|
||||
}
|
||||
else if (itemKind === "data source"){
|
||||
return {
|
||||
"name": "my-datasource",
|
||||
"type": "",
|
||||
"credentials": {
|
||||
"connectionString": ""
|
||||
},
|
||||
"container": {
|
||||
"name": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (itemKind === "skillset"){
|
||||
return {
|
||||
"name": "my-skillset",
|
||||
"description": "",
|
||||
"skills":
|
||||
[
|
||||
{
|
||||
"description": "Extract text (plain and structured) from image.",
|
||||
"@odata.type": "#Microsoft.Skills.Vision.OcrSkill",
|
||||
"context": "/document/normalized_images/*",
|
||||
"defaultLanguageCode": "en",
|
||||
"detectOrientation": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"source": "/document/normalized_images/*"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
else if (itemKind === "indexer"){
|
||||
return {
|
||||
"name": "my-indexer",
|
||||
"dataSourceName": "",
|
||||
"targetIndexName": "",
|
||||
"skillsetName": "",
|
||||
"fieldMappings": [
|
||||
{
|
||||
"sourceFieldName": "",
|
||||
"targetFieldName": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
else {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче