@superoffice/webapi 11.7.727 → 11.9.1204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +15 -15
- package/README.md +184 -184
- package/__tests__/Appointment63-notz.json +1925 -1925
- package/__tests__/Appointment63-utctz.json +1925 -1925
- package/__tests__/Appointment63.json +1925 -1925
- package/__tests__/AppointmentTzTest.ts +115 -115
- package/__tests__/AxiosNockTest.ts +28 -28
- package/__tests__/ContactDefault.json +699 -699
- package/__tests__/ContactEntity.json +272 -272
- package/__tests__/ContactRestTest.ts +144 -144
- package/__tests__/ContactTest.ts +395 -395
- package/__tests__/ConvertersTest.ts +97 -97
- package/__tests__/DocumentTest.ts +101 -101
- package/__tests__/Person210-notz.json +1932 -1932
- package/__tests__/Person210-utctz.json +1932 -1932
- package/__tests__/Person210.json +1932 -1932
- package/__tests__/PersonImageData.nock +22 -22
- package/__tests__/PersonTest.ts +41 -41
- package/__tests__/PersonTzTest.ts +113 -113
- package/__tests__/RecurrenceInfo.json +55 -55
- package/__tests__/ResponseCallbackTest.ts +23 -23
- package/__tests__/TableRights.json +441 -441
- package/__tests__/WebapiTest.ts +264 -264
- package/__tests__/Webhook.json +16 -16
- package/__tests__/WebhookTest.ts +209 -209
- package/dist/cjs/AIAgent.d.ts +62 -0
- package/dist/cjs/AIAgent.d.ts.map +1 -1
- package/dist/cjs/AIAgent.js +149 -0
- package/dist/cjs/AIAgent.js.map +1 -1
- package/dist/cjs/Carriers.d.ts +640 -14
- package/dist/cjs/Carriers.d.ts.map +1 -1
- package/dist/cjs/Converters.d.ts +24 -0
- package/dist/cjs/Converters.d.ts.map +1 -1
- package/dist/cjs/Converters.js +388 -17
- package/dist/cjs/Converters.js.map +1 -1
- package/dist/cjs/DiagnosticsAgent.d.ts +38 -0
- package/dist/cjs/DiagnosticsAgent.d.ts.map +1 -1
- package/dist/cjs/DiagnosticsAgent.js +91 -0
- package/dist/cjs/DiagnosticsAgent.js.map +1 -1
- package/dist/cjs/Enums.d.ts +77 -1
- package/dist/cjs/Enums.d.ts.map +1 -1
- package/dist/cjs/Enums.js +83 -4
- package/dist/cjs/Enums.js.map +1 -1
- package/dist/cjs/ListAgent.d.ts +71 -6
- package/dist/cjs/ListAgent.d.ts.map +1 -1
- package/dist/cjs/ListAgent.js +157 -0
- package/dist/cjs/ListAgent.js.map +1 -1
- package/dist/cjs/MarketingAgent.d.ts +68 -0
- package/dist/cjs/MarketingAgent.d.ts.map +1 -1
- package/dist/cjs/MarketingAgent.js +157 -0
- package/dist/cjs/MarketingAgent.js.map +1 -1
- package/dist/cjs/TicketAgent.d.ts +23 -0
- package/dist/cjs/TicketAgent.d.ts.map +1 -1
- package/dist/cjs/TicketAgent.js +65 -0
- package/dist/cjs/TicketAgent.js.map +1 -1
- package/dist/esm/AIAgent.d.ts +62 -0
- package/dist/esm/AIAgent.d.ts.map +1 -1
- package/dist/esm/AIAgent.js +150 -1
- package/dist/esm/AIAgent.js.map +1 -1
- package/dist/esm/Carriers.d.ts +640 -14
- package/dist/esm/Carriers.d.ts.map +1 -1
- package/dist/esm/Converters.d.ts +24 -0
- package/dist/esm/Converters.d.ts.map +1 -1
- package/dist/esm/Converters.js +346 -0
- package/dist/esm/Converters.js.map +1 -1
- package/dist/esm/DiagnosticsAgent.d.ts +38 -0
- package/dist/esm/DiagnosticsAgent.d.ts.map +1 -1
- package/dist/esm/DiagnosticsAgent.js +91 -0
- package/dist/esm/DiagnosticsAgent.js.map +1 -1
- package/dist/esm/Enums.d.ts +77 -1
- package/dist/esm/Enums.d.ts.map +1 -1
- package/dist/esm/Enums.js +79 -0
- package/dist/esm/Enums.js.map +1 -1
- package/dist/esm/ListAgent.d.ts +71 -6
- package/dist/esm/ListAgent.d.ts.map +1 -1
- package/dist/esm/ListAgent.js +157 -0
- package/dist/esm/ListAgent.js.map +1 -1
- package/dist/esm/MarketingAgent.d.ts +68 -0
- package/dist/esm/MarketingAgent.d.ts.map +1 -1
- package/dist/esm/MarketingAgent.js +157 -0
- package/dist/esm/MarketingAgent.js.map +1 -1
- package/dist/esm/TicketAgent.d.ts +23 -0
- package/dist/esm/TicketAgent.d.ts.map +1 -1
- package/dist/esm/TicketAgent.js +65 -0
- package/dist/esm/TicketAgent.js.map +1 -1
- package/examples-js/hello.js +12 -12
- package/examples-ts/hello.ts +8 -8
- package/package.json +93 -93
- package/scripts/postbuild.js +22 -22
- package/scripts/setVersion.js +44 -44
- package/src/AIAgent.ts +2239 -1992
- package/src/AppointmentAgent.ts +6263 -6263
- package/src/AppointmentRestApi.ts +225 -225
- package/src/ArchiveAgent.ts +1950 -1950
- package/src/AssociateAgent.ts +422 -422
- package/src/AxiosCacheHandler.ts +74 -74
- package/src/BLOBAgent.ts +2100 -2100
- package/src/Base64.ts +285 -285
- package/src/BatchAgent.ts +910 -910
- package/src/BulkUpdateAgent.ts +504 -504
- package/src/CRMScriptAgent.ts +1390 -1390
- package/src/Carriers.ts +53121 -52274
- package/src/ChatAgent.ts +1422 -1422
- package/src/ConfigurationAgent.ts +2228 -2228
- package/src/ContactAgent.ts +1756 -1756
- package/src/ContactRestApi.ts +237 -237
- package/src/Converters.ts +23496 -23090
- package/src/CustomerServiceAgent.ts +1799 -1799
- package/src/DashAgent.ts +1674 -1674
- package/src/DatabaseAgent.ts +120 -120
- package/src/DatabaseTableAgent.ts +534 -534
- package/src/Day_js.ts +41 -41
- package/src/DiagnosticsAgent.ts +1384 -1240
- package/src/DocumentAgent.ts +5079 -5079
- package/src/DocumentMigrationAgent.ts +524 -524
- package/src/DocumentRestApi.ts +259 -259
- package/src/EMailAgent.ts +5328 -5328
- package/src/Enums.ts +6998 -6916
- package/src/ErpSyncAgent.ts +2658 -2658
- package/src/FavouriteAgent.ts +720 -720
- package/src/FindAgent.ts +2330 -2330
- package/src/ForeignSystemAgent.ts +1710 -1710
- package/src/FreeTextAgent.ts +372 -372
- package/src/ImportAgent.ts +304 -304
- package/src/LicenseAgent.ts +1230 -1230
- package/src/ListAgent.ts +11451 -11237
- package/src/MDOAgent.ts +748 -748
- package/src/MarketingAgent.ts +1146 -890
- package/src/MessagingAgent.ts +384 -384
- package/src/NavigatorAgent.ts +140 -140
- package/src/NumberAllocationAgent.ts +296 -296
- package/src/PersonAgent.ts +3287 -3287
- package/src/PersonRestApi.ts +241 -241
- package/src/PhoneListAgent.ts +458 -458
- package/src/PocketAgent.ts +780 -780
- package/src/PreferenceAgent.ts +1900 -1900
- package/src/PreviewsAgent.ts +116 -116
- package/src/ProjectAgent.ts +2391 -2391
- package/src/ProjectRestApi.ts +239 -239
- package/src/QuoteAgent.ts +5159 -5159
- package/src/RelationAgent.ts +220 -220
- package/src/ReportAgent.ts +154 -154
- package/src/ResourceAgent.ts +358 -358
- package/src/SaintAgent.ts +601 -601
- package/src/SaleAgent.ts +2034 -2034
- package/src/SaleRestApi.ts +233 -233
- package/src/SelectionAgent.ts +3195 -3195
- package/src/SentryAgent.ts +462 -462
- package/src/SoApiConstants.ts +8 -8
- package/src/TargetsAgent.ts +1104 -1104
- package/src/TicketAgent.ts +3708 -3638
- package/src/TimeZoneAgent.ts +528 -528
- package/src/TooltipsAgent.ts +116 -116
- package/src/UserAgent.ts +4856 -4856
- package/src/UserDefinedFieldInfoAgent.ts +1764 -1764
- package/src/ViewStateAgent.ts +858 -858
- package/src/WebApi.ts +872 -872
- package/src/WebApiBase.ts +565 -565
- package/src/WebhookAgent.ts +388 -388
- package/src/WorkflowAgent.ts +1338 -1338
- package/tsconfig.esm.json +8 -8
- package/tsconfig.jest.json +8 -8
- package/tsconfig.json +34 -34
|
@@ -1,534 +1,534 @@
|
|
|
1
|
-
// <auto-generated>
|
|
2
|
-
// SuperOffice Code Generator
|
|
3
|
-
// modelling\templates\servicestswebapi\tswebapiagents.tt
|
|
4
|
-
// </auto-generated>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/* tslint:disable */
|
|
8
|
-
//----------------------------------------------------------------------------
|
|
9
|
-
// G E N E R A T E D F I L E ! D O N O T E D I T !
|
|
10
|
-
//----------------------------------------------------------------------------
|
|
11
|
-
//
|
|
12
|
-
// File: WebApi/DatabaseTableAgent.ts
|
|
13
|
-
//
|
|
14
|
-
//----------------------------------------------------------------------------
|
|
15
|
-
// Copyright (C) SuperOffice AS
|
|
16
|
-
//----------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
import { AxiosRequestConfig } from 'axios';
|
|
19
|
-
import { Duration } from 'dayjs/plugin/duration';
|
|
20
|
-
import * as enums from './Enums';
|
|
21
|
-
import * as base from './WebApiBase';
|
|
22
|
-
import * as carriers from './Carriers';
|
|
23
|
-
import * as converters from './Converters';
|
|
24
|
-
import { FromBase64ToString, ToBase64 } from './Base64';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.
|
|
28
|
-
*/
|
|
29
|
-
export interface IDatabaseTableAgent {
|
|
30
|
-
readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
31
|
-
readRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
32
|
-
insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
33
|
-
insertRowAsync(tableName: string, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
34
|
-
updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
35
|
-
updateRowAsync(tableName: string, id: number, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
36
|
-
deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
37
|
-
deleteRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
38
|
-
insertAsync(request: carriers.DatabaseTable_InsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
39
|
-
insertAsync(tableName: string, columns: string[], data: string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
40
|
-
truncateAsync(request: carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
41
|
-
truncateAsync(tableName: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
42
|
-
upsertAsync(request: carriers.DatabaseTable_UpsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
43
|
-
upsertAsync(tableName: string, columns: string[], keys: string[], data: string[][], nomatchAction: enums.UpsertNomatchAction, returnRowStatus: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
44
|
-
deleteAsync(request: carriers.DatabaseTable_DeleteRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
45
|
-
deleteAsync(tableName: string, ids: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
46
|
-
} // interface IDatabaseTableAgent
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.
|
|
53
|
-
*/
|
|
54
|
-
export class DatabaseTableAgent extends base.WebApiBase implements IDatabaseTableAgent {
|
|
55
|
-
constructor(baseUrl?: string, languageCode?:string, cultureCode?: string);
|
|
56
|
-
constructor(baseUrl?: string, resourceParsing?: base.ResourceParsing);
|
|
57
|
-
constructor(baseUrl: string, resourceManager:any);
|
|
58
|
-
constructor(baseUrl: string, config:AxiosRequestConfig, resourceManager:any);
|
|
59
|
-
constructor(baseUrl: string, config:AxiosRequestConfig, resourceParsing?: base.ResourceParsing);
|
|
60
|
-
constructor(baseUrl: string, config:AxiosRequestConfig, languageCode?:string, cultureCode?: string);
|
|
61
|
-
constructor(options: base.WebApiOptions);
|
|
62
|
-
|
|
63
|
-
constructor(baseUrlOrOptions: string|base.WebApiOptions|undefined,
|
|
64
|
-
langOrconfigOrRM?: string|base.ResourceParsing|AxiosRequestConfig|any,
|
|
65
|
-
langOrResourceOrRM?:string|base.ResourceParsing|any,
|
|
66
|
-
cultureCode?: string,
|
|
67
|
-
) {
|
|
68
|
-
const options = base.WebApiBase.FigureOutOptions(baseUrlOrOptions, langOrconfigOrRM, langOrResourceOrRM, cultureCode);
|
|
69
|
-
options.basePath = "v1/Agents/DatabaseTable/";
|
|
70
|
-
super(options);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
private async _readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord > {
|
|
76
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
77
|
-
base.WebApiBase.SetPending(options);
|
|
78
|
-
return new Promise< carriers.TableRecord >(async (resolve, reject) => {
|
|
79
|
-
try {
|
|
80
|
-
config.baseURL = this._options.baseUrl;
|
|
81
|
-
const response = await this._axios.post("ReadRow", request , config);
|
|
82
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
83
|
-
const res : carriers.TableRecord = converters.Create_TableRecord_From( response.data );
|
|
84
|
-
resolve(res);
|
|
85
|
-
}
|
|
86
|
-
catch( err ) {
|
|
87
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
88
|
-
reject(err);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Read a row from a table
|
|
97
|
-
* @param request - TableName, Id
|
|
98
|
-
* @returns The row from the table
|
|
99
|
-
*/
|
|
100
|
-
public async readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Read a row from a table
|
|
104
|
-
* @param tableName - The name of the table to fetch; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
105
|
-
* @param id - The id of the row to fetch
|
|
106
|
-
* @returns The row from the table
|
|
107
|
-
*/
|
|
108
|
-
public async readRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
109
|
-
|
|
110
|
-
public async readRowAsync(tableName:string|carriers.DatabaseTable_ReadRowRequest, id?:number|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord > {
|
|
111
|
-
let _request : carriers.DatabaseTable_ReadRowRequest = null;
|
|
112
|
-
let _options : base.WebApiRequestOptions = null;
|
|
113
|
-
const first : any = tableName;
|
|
114
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' ) )
|
|
115
|
-
{
|
|
116
|
-
_request = tableName as carriers.DatabaseTable_ReadRowRequest;
|
|
117
|
-
_options = id as base.WebApiRequestOptions;
|
|
118
|
-
}
|
|
119
|
-
else
|
|
120
|
-
{
|
|
121
|
-
_request = {
|
|
122
|
-
tableName: tableName as string,
|
|
123
|
-
id: id as number,
|
|
124
|
-
};
|
|
125
|
-
_options = webapi_options;
|
|
126
|
-
}
|
|
127
|
-
return this._readRowAsync( _request, _options );
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
private async _insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, options?:base.WebApiRequestOptions) : Promise< number > {
|
|
132
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
133
|
-
base.WebApiBase.SetPending(options);
|
|
134
|
-
return new Promise< number >(async (resolve, reject) => {
|
|
135
|
-
try {
|
|
136
|
-
config.baseURL = this._options.baseUrl;
|
|
137
|
-
const response = await this._axios.post("InsertRow", request , config);
|
|
138
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
139
|
-
const res : number = response.data as number;
|
|
140
|
-
resolve(res);
|
|
141
|
-
}
|
|
142
|
-
catch( err ) {
|
|
143
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
144
|
-
reject(err);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Insert a row into a table
|
|
153
|
-
* @param request - TableName, Values
|
|
154
|
-
* @returns The id of the newly inserted row
|
|
155
|
-
*/
|
|
156
|
-
public async insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Insert a row into a table
|
|
160
|
-
* @param tableName - The name of the table to insert into; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
161
|
-
* @param values - A StringDictionary with the values to insert. You do not need to specify all the values in the table. The omitted ones will get default values
|
|
162
|
-
* @returns The id of the newly inserted row
|
|
163
|
-
*/
|
|
164
|
-
public async insertRowAsync(tableName: string, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
165
|
-
|
|
166
|
-
public async insertRowAsync(tableName:string|carriers.DatabaseTable_InsertRowRequest, values?:carriers.StringDictionary|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< number > {
|
|
167
|
-
let _request : carriers.DatabaseTable_InsertRowRequest = null;
|
|
168
|
-
let _options : base.WebApiRequestOptions = null;
|
|
169
|
-
const first : any = tableName;
|
|
170
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.values)!='undefined' ) )
|
|
171
|
-
{
|
|
172
|
-
_request = tableName as carriers.DatabaseTable_InsertRowRequest;
|
|
173
|
-
_options = values as base.WebApiRequestOptions;
|
|
174
|
-
}
|
|
175
|
-
else
|
|
176
|
-
{
|
|
177
|
-
_request = {
|
|
178
|
-
tableName: tableName as string,
|
|
179
|
-
values: values as carriers.StringDictionary,
|
|
180
|
-
};
|
|
181
|
-
_options = webapi_options;
|
|
182
|
-
}
|
|
183
|
-
return this._insertRowAsync( _request, _options );
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
private async _updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
188
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
189
|
-
base.WebApiBase.SetPending(options);
|
|
190
|
-
return new Promise< void >(async (resolve, reject) => {
|
|
191
|
-
try {
|
|
192
|
-
config.baseURL = this._options.baseUrl;
|
|
193
|
-
const response = await this._axios.post("UpdateRow", request , config);
|
|
194
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
195
|
-
const res = response.data;
|
|
196
|
-
resolve(res);
|
|
197
|
-
}
|
|
198
|
-
catch( err ) {
|
|
199
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
200
|
-
reject(err);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Update a row in a table
|
|
209
|
-
* @param request - TableName, Id, Values
|
|
210
|
-
* @returns
|
|
211
|
-
*/
|
|
212
|
-
public async updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Update a row in a table
|
|
216
|
-
* @param tableName - The name of the table to update; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
217
|
-
* @param id - The id of the row to update
|
|
218
|
-
* @param values - A StringDictionary with the values to update. You do not need to specify all the values in the table. The omitted ones will remain unchanged
|
|
219
|
-
* @returns
|
|
220
|
-
*/
|
|
221
|
-
public async updateRowAsync(tableName: string, id: number, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
222
|
-
|
|
223
|
-
public async updateRowAsync(tableName:string|carriers.DatabaseTable_UpdateRowRequest, id?:number|base.WebApiRequestOptions, values?:carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
224
|
-
let _request : carriers.DatabaseTable_UpdateRowRequest = null;
|
|
225
|
-
let _options : base.WebApiRequestOptions = null;
|
|
226
|
-
const first : any = tableName;
|
|
227
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' || typeof(first.values)!='undefined' ) )
|
|
228
|
-
{
|
|
229
|
-
_request = tableName as carriers.DatabaseTable_UpdateRowRequest;
|
|
230
|
-
_options = id as base.WebApiRequestOptions;
|
|
231
|
-
}
|
|
232
|
-
else
|
|
233
|
-
{
|
|
234
|
-
_request = {
|
|
235
|
-
tableName: tableName as string,
|
|
236
|
-
id: id as number,
|
|
237
|
-
values: values as carriers.StringDictionary,
|
|
238
|
-
};
|
|
239
|
-
_options = webapi_options;
|
|
240
|
-
}
|
|
241
|
-
return this._updateRowAsync( _request, _options );
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
private async _deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
246
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
247
|
-
base.WebApiBase.SetPending(options);
|
|
248
|
-
return new Promise< void >(async (resolve, reject) => {
|
|
249
|
-
try {
|
|
250
|
-
config.baseURL = this._options.baseUrl;
|
|
251
|
-
const response = await this._axios.post("DeleteRow", request , config);
|
|
252
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
253
|
-
const res = response.data;
|
|
254
|
-
resolve(res);
|
|
255
|
-
}
|
|
256
|
-
catch( err ) {
|
|
257
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
258
|
-
reject(err);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Delete a row from a table
|
|
267
|
-
* @param request - TableName, Id
|
|
268
|
-
* @returns
|
|
269
|
-
*/
|
|
270
|
-
public async deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Delete a row from a table
|
|
274
|
-
* @param tableName - The name of the table to delete from; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
275
|
-
* @param id - The id of the row to delete
|
|
276
|
-
* @returns
|
|
277
|
-
*/
|
|
278
|
-
public async deleteRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
279
|
-
|
|
280
|
-
public async deleteRowAsync(tableName:string|carriers.DatabaseTable_DeleteRowRequest, id?:number|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
281
|
-
let _request : carriers.DatabaseTable_DeleteRowRequest = null;
|
|
282
|
-
let _options : base.WebApiRequestOptions = null;
|
|
283
|
-
const first : any = tableName;
|
|
284
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' ) )
|
|
285
|
-
{
|
|
286
|
-
_request = tableName as carriers.DatabaseTable_DeleteRowRequest;
|
|
287
|
-
_options = id as base.WebApiRequestOptions;
|
|
288
|
-
}
|
|
289
|
-
else
|
|
290
|
-
{
|
|
291
|
-
_request = {
|
|
292
|
-
tableName: tableName as string,
|
|
293
|
-
id: id as number,
|
|
294
|
-
};
|
|
295
|
-
_options = webapi_options;
|
|
296
|
-
}
|
|
297
|
-
return this._deleteRowAsync( _request, _options );
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
private async _insertAsync(request: carriers.DatabaseTable_InsertRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
302
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
303
|
-
base.WebApiBase.SetPending(options);
|
|
304
|
-
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
305
|
-
try {
|
|
306
|
-
config.baseURL = this._options.baseUrl;
|
|
307
|
-
const response = await this._axios.post("Insert", request , config);
|
|
308
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
309
|
-
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
310
|
-
resolve(res);
|
|
311
|
-
}
|
|
312
|
-
catch( err ) {
|
|
313
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
314
|
-
reject(err);
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Mass-insert rows, with or without primary keys specified. Works on physical tables with no special processing for udef etc.; traveltransactionlog and WebHooks are supported
|
|
323
|
-
* @param request - TableName, Columns, Data
|
|
324
|
-
* @returns Summary of results
|
|
325
|
-
*/
|
|
326
|
-
public async insertAsync(request: carriers.DatabaseTable_InsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Mass-insert rows, with or without primary keys specified. Works on physical tables with no special processing for udef etc.; traveltransactionlog and WebHooks are supported
|
|
330
|
-
* @param tableName - The name of the table where rows should be inserted
|
|
331
|
-
* @param columns - List of column names, in the same order as in the Data parameter
|
|
332
|
-
* @param data - Outer array = rows, inner = columns in specified order; use CultureDataFormatter to format values that aren't string or int
|
|
333
|
-
* @returns Summary of results
|
|
334
|
-
*/
|
|
335
|
-
public async insertAsync(tableName: string, columns: string[], data: string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
336
|
-
|
|
337
|
-
public async insertAsync(tableName:string|carriers.DatabaseTable_InsertRequest, columns?:string[]|base.WebApiRequestOptions, data?:string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
338
|
-
let _request : carriers.DatabaseTable_InsertRequest = null;
|
|
339
|
-
let _options : base.WebApiRequestOptions = null;
|
|
340
|
-
const first : any = tableName;
|
|
341
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.columns)!='undefined' || typeof(first.data)!='undefined' ) )
|
|
342
|
-
{
|
|
343
|
-
_request = tableName as carriers.DatabaseTable_InsertRequest;
|
|
344
|
-
_options = columns as base.WebApiRequestOptions;
|
|
345
|
-
}
|
|
346
|
-
else
|
|
347
|
-
{
|
|
348
|
-
_request = {
|
|
349
|
-
tableName: tableName as string,
|
|
350
|
-
columns: columns as string[],
|
|
351
|
-
data: data as string[][],
|
|
352
|
-
};
|
|
353
|
-
_options = webapi_options;
|
|
354
|
-
}
|
|
355
|
-
return this._insertAsync( _request, _options );
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
private async _truncateAsync(request: carriers.DatabaseTable_TruncateRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
360
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
361
|
-
base.WebApiBase.SetPending(options);
|
|
362
|
-
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
363
|
-
try {
|
|
364
|
-
config.baseURL = this._options.baseUrl;
|
|
365
|
-
const response = await this._axios.post("Truncate", request , config);
|
|
366
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
367
|
-
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
368
|
-
resolve(res);
|
|
369
|
-
}
|
|
370
|
-
catch( err ) {
|
|
371
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
372
|
-
reject(err);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls
|
|
381
|
-
* @param request - TableName
|
|
382
|
-
* @returns Summary of results
|
|
383
|
-
*/
|
|
384
|
-
public async truncateAsync(request: carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls
|
|
388
|
-
* @param tableName - Name of table to be truncated
|
|
389
|
-
* @returns Summary of results
|
|
390
|
-
*/
|
|
391
|
-
public async truncateAsync(tableName: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
392
|
-
|
|
393
|
-
public async truncateAsync(tableName:string|carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
394
|
-
let _request : carriers.DatabaseTable_TruncateRequest = null;
|
|
395
|
-
let _options : base.WebApiRequestOptions = null;
|
|
396
|
-
const first : any = tableName;
|
|
397
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' ) )
|
|
398
|
-
{
|
|
399
|
-
_request = tableName as carriers.DatabaseTable_TruncateRequest;
|
|
400
|
-
_options = webapi_options as base.WebApiRequestOptions;
|
|
401
|
-
}
|
|
402
|
-
else
|
|
403
|
-
{
|
|
404
|
-
_request = {
|
|
405
|
-
tableName: tableName as string,
|
|
406
|
-
};
|
|
407
|
-
_options = webapi_options;
|
|
408
|
-
}
|
|
409
|
-
return this._truncateAsync( _request, _options );
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
private async _upsertAsync(request: carriers.DatabaseTable_UpsertRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
414
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
415
|
-
base.WebApiBase.SetPending(options);
|
|
416
|
-
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
417
|
-
try {
|
|
418
|
-
config.baseURL = this._options.baseUrl;
|
|
419
|
-
const response = await this._axios.post("Upsert", request , config);
|
|
420
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
421
|
-
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
422
|
-
resolve(res);
|
|
423
|
-
}
|
|
424
|
-
catch( err ) {
|
|
425
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
426
|
-
reject(err);
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Insert or update rows, optionally deleting/zeroing 'leftover' rows. Special support for UDEF, as well as optional extensive information return. Traveltransactionlog and WebHooks are supported
|
|
435
|
-
* @param request - TableName, Columns, Keys, Data, NomatchAction, ReturnRowStatus
|
|
436
|
-
* @returns Summary of results
|
|
437
|
-
*/
|
|
438
|
-
public async upsertAsync(request: carriers.DatabaseTable_UpsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Insert or update rows, optionally deleting/zeroing 'leftover' rows. Special support for UDEF, as well as optional extensive information return. Traveltransactionlog and WebHooks are supported
|
|
442
|
-
* @param tableName - The name of the table where rows should be inserted or updated
|
|
443
|
-
* @param columns - List of column names, in the same order as in the data
|
|
444
|
-
* @param keys - List of columns that are to be used as keys, to match any existing rows
|
|
445
|
-
* @param data - Outer array = row, inner = column in specified order; use CultureDataFormatter to format values
|
|
446
|
-
* @param nomatchAction - Action to take on rows in the target table, that are not matched by any rows in the incoming data. Use the deletion options with care. NEVER use deletion if your Upsert is so large you need to divide it into multiple batches.
|
|
447
|
-
* @param returnRowStatus - If true, then the 'RowStatus' member of the return carrier will be populated with a per-row status, for each incoming row
|
|
448
|
-
* @returns Summary of results
|
|
449
|
-
*/
|
|
450
|
-
public async upsertAsync(tableName: string, columns: string[], keys: string[], data: string[][], nomatchAction: enums.UpsertNomatchAction, returnRowStatus: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
451
|
-
|
|
452
|
-
public async upsertAsync(tableName:string|carriers.DatabaseTable_UpsertRequest, columns?:string[]|base.WebApiRequestOptions, keys?:string[], data?:string[][], nomatchAction?:enums.UpsertNomatchAction, returnRowStatus?:boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
453
|
-
let _request : carriers.DatabaseTable_UpsertRequest = null;
|
|
454
|
-
let _options : base.WebApiRequestOptions = null;
|
|
455
|
-
const first : any = tableName;
|
|
456
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.columns)!='undefined' || typeof(first.keys)!='undefined' || typeof(first.data)!='undefined' || typeof(first.nomatchAction)!='undefined' || typeof(first.returnRowStatus)!='undefined' ) )
|
|
457
|
-
{
|
|
458
|
-
_request = tableName as carriers.DatabaseTable_UpsertRequest;
|
|
459
|
-
_options = columns as base.WebApiRequestOptions;
|
|
460
|
-
}
|
|
461
|
-
else
|
|
462
|
-
{
|
|
463
|
-
_request = {
|
|
464
|
-
tableName: tableName as string,
|
|
465
|
-
columns: columns as string[],
|
|
466
|
-
keys: keys as string[],
|
|
467
|
-
data: data as string[][],
|
|
468
|
-
nomatchAction: nomatchAction as enums.UpsertNomatchAction,
|
|
469
|
-
returnRowStatus: returnRowStatus as boolean,
|
|
470
|
-
};
|
|
471
|
-
_options = webapi_options;
|
|
472
|
-
}
|
|
473
|
-
return this._upsertAsync( _request, _options );
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
private async _deleteAsync(request: carriers.DatabaseTable_DeleteRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
478
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
479
|
-
base.WebApiBase.SetPending(options);
|
|
480
|
-
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
481
|
-
try {
|
|
482
|
-
config.baseURL = this._options.baseUrl;
|
|
483
|
-
const response = await this._axios.post("Delete", request , config);
|
|
484
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
485
|
-
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
486
|
-
resolve(res);
|
|
487
|
-
}
|
|
488
|
-
catch( err ) {
|
|
489
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
490
|
-
reject(err);
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Delete rows, by primary key; traveltransactionlog and WebHooks are supported
|
|
499
|
-
* @param request - TableName, IDs
|
|
500
|
-
* @returns Summary of results
|
|
501
|
-
*/
|
|
502
|
-
public async deleteAsync(request: carriers.DatabaseTable_DeleteRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Delete rows, by primary key; traveltransactionlog and WebHooks are supported
|
|
506
|
-
* @param tableName - The name of the table where rows should be deleted
|
|
507
|
-
* @param ids - Primary keys of the rows to be deleted
|
|
508
|
-
* @returns Summary of results
|
|
509
|
-
*/
|
|
510
|
-
public async deleteAsync(tableName: string, ids: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
511
|
-
|
|
512
|
-
public async deleteAsync(tableName:string|carriers.DatabaseTable_DeleteRequest, ids?:number[]|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
513
|
-
let _request : carriers.DatabaseTable_DeleteRequest = null;
|
|
514
|
-
let _options : base.WebApiRequestOptions = null;
|
|
515
|
-
const first : any = tableName;
|
|
516
|
-
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.ids)!='undefined' ) )
|
|
517
|
-
{
|
|
518
|
-
_request = tableName as carriers.DatabaseTable_DeleteRequest;
|
|
519
|
-
_options = ids as base.WebApiRequestOptions;
|
|
520
|
-
}
|
|
521
|
-
else
|
|
522
|
-
{
|
|
523
|
-
_request = {
|
|
524
|
-
tableName: tableName as string,
|
|
525
|
-
ids: ids as number[],
|
|
526
|
-
};
|
|
527
|
-
_options = webapi_options;
|
|
528
|
-
}
|
|
529
|
-
return this._deleteAsync( _request, _options );
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
} // class v1DatabaseTableAgentController
|
|
533
|
-
|
|
534
|
-
|
|
1
|
+
// <auto-generated>
|
|
2
|
+
// SuperOffice Code Generator
|
|
3
|
+
// modelling\templates\servicestswebapi\tswebapiagents.tt
|
|
4
|
+
// </auto-generated>
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/* tslint:disable */
|
|
8
|
+
//----------------------------------------------------------------------------
|
|
9
|
+
// G E N E R A T E D F I L E ! D O N O T E D I T !
|
|
10
|
+
//----------------------------------------------------------------------------
|
|
11
|
+
//
|
|
12
|
+
// File: WebApi/DatabaseTableAgent.ts
|
|
13
|
+
//
|
|
14
|
+
//----------------------------------------------------------------------------
|
|
15
|
+
// Copyright (C) SuperOffice AS
|
|
16
|
+
//----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
import { AxiosRequestConfig } from 'axios';
|
|
19
|
+
import { Duration } from 'dayjs/plugin/duration';
|
|
20
|
+
import * as enums from './Enums';
|
|
21
|
+
import * as base from './WebApiBase';
|
|
22
|
+
import * as carriers from './Carriers';
|
|
23
|
+
import * as converters from './Converters';
|
|
24
|
+
import { FromBase64ToString, ToBase64 } from './Base64';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.
|
|
28
|
+
*/
|
|
29
|
+
export interface IDatabaseTableAgent {
|
|
30
|
+
readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
31
|
+
readRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
32
|
+
insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
33
|
+
insertRowAsync(tableName: string, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
34
|
+
updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
35
|
+
updateRowAsync(tableName: string, id: number, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
36
|
+
deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
37
|
+
deleteRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
38
|
+
insertAsync(request: carriers.DatabaseTable_InsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
39
|
+
insertAsync(tableName: string, columns: string[], data: string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
40
|
+
truncateAsync(request: carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
41
|
+
truncateAsync(tableName: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
42
|
+
upsertAsync(request: carriers.DatabaseTable_UpsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
43
|
+
upsertAsync(tableName: string, columns: string[], keys: string[], data: string[][], nomatchAction: enums.UpsertNomatchAction, returnRowStatus: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
44
|
+
deleteAsync(request: carriers.DatabaseTable_DeleteRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
45
|
+
deleteAsync(tableName: string, ids: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
46
|
+
} // interface IDatabaseTableAgent
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.
|
|
53
|
+
*/
|
|
54
|
+
export class DatabaseTableAgent extends base.WebApiBase implements IDatabaseTableAgent {
|
|
55
|
+
constructor(baseUrl?: string, languageCode?:string, cultureCode?: string);
|
|
56
|
+
constructor(baseUrl?: string, resourceParsing?: base.ResourceParsing);
|
|
57
|
+
constructor(baseUrl: string, resourceManager:any);
|
|
58
|
+
constructor(baseUrl: string, config:AxiosRequestConfig, resourceManager:any);
|
|
59
|
+
constructor(baseUrl: string, config:AxiosRequestConfig, resourceParsing?: base.ResourceParsing);
|
|
60
|
+
constructor(baseUrl: string, config:AxiosRequestConfig, languageCode?:string, cultureCode?: string);
|
|
61
|
+
constructor(options: base.WebApiOptions);
|
|
62
|
+
|
|
63
|
+
constructor(baseUrlOrOptions: string|base.WebApiOptions|undefined,
|
|
64
|
+
langOrconfigOrRM?: string|base.ResourceParsing|AxiosRequestConfig|any,
|
|
65
|
+
langOrResourceOrRM?:string|base.ResourceParsing|any,
|
|
66
|
+
cultureCode?: string,
|
|
67
|
+
) {
|
|
68
|
+
const options = base.WebApiBase.FigureOutOptions(baseUrlOrOptions, langOrconfigOrRM, langOrResourceOrRM, cultureCode);
|
|
69
|
+
options.basePath = "v1/Agents/DatabaseTable/";
|
|
70
|
+
super(options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
private async _readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord > {
|
|
76
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
77
|
+
base.WebApiBase.SetPending(options);
|
|
78
|
+
return new Promise< carriers.TableRecord >(async (resolve, reject) => {
|
|
79
|
+
try {
|
|
80
|
+
config.baseURL = this._options.baseUrl;
|
|
81
|
+
const response = await this._axios.post("ReadRow", request , config);
|
|
82
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
83
|
+
const res : carriers.TableRecord = converters.Create_TableRecord_From( response.data );
|
|
84
|
+
resolve(res);
|
|
85
|
+
}
|
|
86
|
+
catch( err ) {
|
|
87
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
88
|
+
reject(err);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Read a row from a table
|
|
97
|
+
* @param request - TableName, Id
|
|
98
|
+
* @returns The row from the table
|
|
99
|
+
*/
|
|
100
|
+
public async readRowAsync(request: carriers.DatabaseTable_ReadRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Read a row from a table
|
|
104
|
+
* @param tableName - The name of the table to fetch; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
105
|
+
* @param id - The id of the row to fetch
|
|
106
|
+
* @returns The row from the table
|
|
107
|
+
*/
|
|
108
|
+
public async readRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord >;
|
|
109
|
+
|
|
110
|
+
public async readRowAsync(tableName:string|carriers.DatabaseTable_ReadRowRequest, id?:number|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.TableRecord > {
|
|
111
|
+
let _request : carriers.DatabaseTable_ReadRowRequest = null;
|
|
112
|
+
let _options : base.WebApiRequestOptions = null;
|
|
113
|
+
const first : any = tableName;
|
|
114
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' ) )
|
|
115
|
+
{
|
|
116
|
+
_request = tableName as carriers.DatabaseTable_ReadRowRequest;
|
|
117
|
+
_options = id as base.WebApiRequestOptions;
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
{
|
|
121
|
+
_request = {
|
|
122
|
+
tableName: tableName as string,
|
|
123
|
+
id: id as number,
|
|
124
|
+
};
|
|
125
|
+
_options = webapi_options;
|
|
126
|
+
}
|
|
127
|
+
return this._readRowAsync( _request, _options );
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
private async _insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, options?:base.WebApiRequestOptions) : Promise< number > {
|
|
132
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
133
|
+
base.WebApiBase.SetPending(options);
|
|
134
|
+
return new Promise< number >(async (resolve, reject) => {
|
|
135
|
+
try {
|
|
136
|
+
config.baseURL = this._options.baseUrl;
|
|
137
|
+
const response = await this._axios.post("InsertRow", request , config);
|
|
138
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
139
|
+
const res : number = response.data as number;
|
|
140
|
+
resolve(res);
|
|
141
|
+
}
|
|
142
|
+
catch( err ) {
|
|
143
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
144
|
+
reject(err);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Insert a row into a table
|
|
153
|
+
* @param request - TableName, Values
|
|
154
|
+
* @returns The id of the newly inserted row
|
|
155
|
+
*/
|
|
156
|
+
public async insertRowAsync(request: carriers.DatabaseTable_InsertRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Insert a row into a table
|
|
160
|
+
* @param tableName - The name of the table to insert into; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
161
|
+
* @param values - A StringDictionary with the values to insert. You do not need to specify all the values in the table. The omitted ones will get default values
|
|
162
|
+
* @returns The id of the newly inserted row
|
|
163
|
+
*/
|
|
164
|
+
public async insertRowAsync(tableName: string, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
|
|
165
|
+
|
|
166
|
+
public async insertRowAsync(tableName:string|carriers.DatabaseTable_InsertRowRequest, values?:carriers.StringDictionary|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< number > {
|
|
167
|
+
let _request : carriers.DatabaseTable_InsertRowRequest = null;
|
|
168
|
+
let _options : base.WebApiRequestOptions = null;
|
|
169
|
+
const first : any = tableName;
|
|
170
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.values)!='undefined' ) )
|
|
171
|
+
{
|
|
172
|
+
_request = tableName as carriers.DatabaseTable_InsertRowRequest;
|
|
173
|
+
_options = values as base.WebApiRequestOptions;
|
|
174
|
+
}
|
|
175
|
+
else
|
|
176
|
+
{
|
|
177
|
+
_request = {
|
|
178
|
+
tableName: tableName as string,
|
|
179
|
+
values: values as carriers.StringDictionary,
|
|
180
|
+
};
|
|
181
|
+
_options = webapi_options;
|
|
182
|
+
}
|
|
183
|
+
return this._insertRowAsync( _request, _options );
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
private async _updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
188
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
189
|
+
base.WebApiBase.SetPending(options);
|
|
190
|
+
return new Promise< void >(async (resolve, reject) => {
|
|
191
|
+
try {
|
|
192
|
+
config.baseURL = this._options.baseUrl;
|
|
193
|
+
const response = await this._axios.post("UpdateRow", request , config);
|
|
194
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
195
|
+
const res = response.data;
|
|
196
|
+
resolve(res);
|
|
197
|
+
}
|
|
198
|
+
catch( err ) {
|
|
199
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
200
|
+
reject(err);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Update a row in a table
|
|
209
|
+
* @param request - TableName, Id, Values
|
|
210
|
+
* @returns
|
|
211
|
+
*/
|
|
212
|
+
public async updateRowAsync(request: carriers.DatabaseTable_UpdateRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Update a row in a table
|
|
216
|
+
* @param tableName - The name of the table to update; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
217
|
+
* @param id - The id of the row to update
|
|
218
|
+
* @param values - A StringDictionary with the values to update. You do not need to specify all the values in the table. The omitted ones will remain unchanged
|
|
219
|
+
* @returns
|
|
220
|
+
*/
|
|
221
|
+
public async updateRowAsync(tableName: string, id: number, values: carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
222
|
+
|
|
223
|
+
public async updateRowAsync(tableName:string|carriers.DatabaseTable_UpdateRowRequest, id?:number|base.WebApiRequestOptions, values?:carriers.StringDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
224
|
+
let _request : carriers.DatabaseTable_UpdateRowRequest = null;
|
|
225
|
+
let _options : base.WebApiRequestOptions = null;
|
|
226
|
+
const first : any = tableName;
|
|
227
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' || typeof(first.values)!='undefined' ) )
|
|
228
|
+
{
|
|
229
|
+
_request = tableName as carriers.DatabaseTable_UpdateRowRequest;
|
|
230
|
+
_options = id as base.WebApiRequestOptions;
|
|
231
|
+
}
|
|
232
|
+
else
|
|
233
|
+
{
|
|
234
|
+
_request = {
|
|
235
|
+
tableName: tableName as string,
|
|
236
|
+
id: id as number,
|
|
237
|
+
values: values as carriers.StringDictionary,
|
|
238
|
+
};
|
|
239
|
+
_options = webapi_options;
|
|
240
|
+
}
|
|
241
|
+
return this._updateRowAsync( _request, _options );
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
private async _deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
246
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
247
|
+
base.WebApiBase.SetPending(options);
|
|
248
|
+
return new Promise< void >(async (resolve, reject) => {
|
|
249
|
+
try {
|
|
250
|
+
config.baseURL = this._options.baseUrl;
|
|
251
|
+
const response = await this._axios.post("DeleteRow", request , config);
|
|
252
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
253
|
+
const res = response.data;
|
|
254
|
+
resolve(res);
|
|
255
|
+
}
|
|
256
|
+
catch( err ) {
|
|
257
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
258
|
+
reject(err);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Delete a row from a table
|
|
267
|
+
* @param request - TableName, Id
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
public async deleteRowAsync(request: carriers.DatabaseTable_DeleteRowRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Delete a row from a table
|
|
274
|
+
* @param tableName - The name of the table to delete from; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable
|
|
275
|
+
* @param id - The id of the row to delete
|
|
276
|
+
* @returns
|
|
277
|
+
*/
|
|
278
|
+
public async deleteRowAsync(tableName: string, id: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
279
|
+
|
|
280
|
+
public async deleteRowAsync(tableName:string|carriers.DatabaseTable_DeleteRowRequest, id?:number|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
281
|
+
let _request : carriers.DatabaseTable_DeleteRowRequest = null;
|
|
282
|
+
let _options : base.WebApiRequestOptions = null;
|
|
283
|
+
const first : any = tableName;
|
|
284
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.id)!='undefined' ) )
|
|
285
|
+
{
|
|
286
|
+
_request = tableName as carriers.DatabaseTable_DeleteRowRequest;
|
|
287
|
+
_options = id as base.WebApiRequestOptions;
|
|
288
|
+
}
|
|
289
|
+
else
|
|
290
|
+
{
|
|
291
|
+
_request = {
|
|
292
|
+
tableName: tableName as string,
|
|
293
|
+
id: id as number,
|
|
294
|
+
};
|
|
295
|
+
_options = webapi_options;
|
|
296
|
+
}
|
|
297
|
+
return this._deleteRowAsync( _request, _options );
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
private async _insertAsync(request: carriers.DatabaseTable_InsertRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
302
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
303
|
+
base.WebApiBase.SetPending(options);
|
|
304
|
+
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
305
|
+
try {
|
|
306
|
+
config.baseURL = this._options.baseUrl;
|
|
307
|
+
const response = await this._axios.post("Insert", request , config);
|
|
308
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
309
|
+
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
310
|
+
resolve(res);
|
|
311
|
+
}
|
|
312
|
+
catch( err ) {
|
|
313
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
314
|
+
reject(err);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Mass-insert rows, with or without primary keys specified. Works on physical tables with no special processing for udef etc.; traveltransactionlog and WebHooks are supported
|
|
323
|
+
* @param request - TableName, Columns, Data
|
|
324
|
+
* @returns Summary of results
|
|
325
|
+
*/
|
|
326
|
+
public async insertAsync(request: carriers.DatabaseTable_InsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Mass-insert rows, with or without primary keys specified. Works on physical tables with no special processing for udef etc.; traveltransactionlog and WebHooks are supported
|
|
330
|
+
* @param tableName - The name of the table where rows should be inserted
|
|
331
|
+
* @param columns - List of column names, in the same order as in the Data parameter
|
|
332
|
+
* @param data - Outer array = rows, inner = columns in specified order; use CultureDataFormatter to format values that aren't string or int
|
|
333
|
+
* @returns Summary of results
|
|
334
|
+
*/
|
|
335
|
+
public async insertAsync(tableName: string, columns: string[], data: string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
336
|
+
|
|
337
|
+
public async insertAsync(tableName:string|carriers.DatabaseTable_InsertRequest, columns?:string[]|base.WebApiRequestOptions, data?:string[][], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
338
|
+
let _request : carriers.DatabaseTable_InsertRequest = null;
|
|
339
|
+
let _options : base.WebApiRequestOptions = null;
|
|
340
|
+
const first : any = tableName;
|
|
341
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.columns)!='undefined' || typeof(first.data)!='undefined' ) )
|
|
342
|
+
{
|
|
343
|
+
_request = tableName as carriers.DatabaseTable_InsertRequest;
|
|
344
|
+
_options = columns as base.WebApiRequestOptions;
|
|
345
|
+
}
|
|
346
|
+
else
|
|
347
|
+
{
|
|
348
|
+
_request = {
|
|
349
|
+
tableName: tableName as string,
|
|
350
|
+
columns: columns as string[],
|
|
351
|
+
data: data as string[][],
|
|
352
|
+
};
|
|
353
|
+
_options = webapi_options;
|
|
354
|
+
}
|
|
355
|
+
return this._insertAsync( _request, _options );
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
private async _truncateAsync(request: carriers.DatabaseTable_TruncateRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
360
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
361
|
+
base.WebApiBase.SetPending(options);
|
|
362
|
+
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
363
|
+
try {
|
|
364
|
+
config.baseURL = this._options.baseUrl;
|
|
365
|
+
const response = await this._axios.post("Truncate", request , config);
|
|
366
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
367
|
+
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
368
|
+
resolve(res);
|
|
369
|
+
}
|
|
370
|
+
catch( err ) {
|
|
371
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
372
|
+
reject(err);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls
|
|
381
|
+
* @param request - TableName
|
|
382
|
+
* @returns Summary of results
|
|
383
|
+
*/
|
|
384
|
+
public async truncateAsync(request: carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls
|
|
388
|
+
* @param tableName - Name of table to be truncated
|
|
389
|
+
* @returns Summary of results
|
|
390
|
+
*/
|
|
391
|
+
public async truncateAsync(tableName: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
392
|
+
|
|
393
|
+
public async truncateAsync(tableName:string|carriers.DatabaseTable_TruncateRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
394
|
+
let _request : carriers.DatabaseTable_TruncateRequest = null;
|
|
395
|
+
let _options : base.WebApiRequestOptions = null;
|
|
396
|
+
const first : any = tableName;
|
|
397
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' ) )
|
|
398
|
+
{
|
|
399
|
+
_request = tableName as carriers.DatabaseTable_TruncateRequest;
|
|
400
|
+
_options = webapi_options as base.WebApiRequestOptions;
|
|
401
|
+
}
|
|
402
|
+
else
|
|
403
|
+
{
|
|
404
|
+
_request = {
|
|
405
|
+
tableName: tableName as string,
|
|
406
|
+
};
|
|
407
|
+
_options = webapi_options;
|
|
408
|
+
}
|
|
409
|
+
return this._truncateAsync( _request, _options );
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
private async _upsertAsync(request: carriers.DatabaseTable_UpsertRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
414
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
415
|
+
base.WebApiBase.SetPending(options);
|
|
416
|
+
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
417
|
+
try {
|
|
418
|
+
config.baseURL = this._options.baseUrl;
|
|
419
|
+
const response = await this._axios.post("Upsert", request , config);
|
|
420
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
421
|
+
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
422
|
+
resolve(res);
|
|
423
|
+
}
|
|
424
|
+
catch( err ) {
|
|
425
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
426
|
+
reject(err);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Insert or update rows, optionally deleting/zeroing 'leftover' rows. Special support for UDEF, as well as optional extensive information return. Traveltransactionlog and WebHooks are supported
|
|
435
|
+
* @param request - TableName, Columns, Keys, Data, NomatchAction, ReturnRowStatus
|
|
436
|
+
* @returns Summary of results
|
|
437
|
+
*/
|
|
438
|
+
public async upsertAsync(request: carriers.DatabaseTable_UpsertRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Insert or update rows, optionally deleting/zeroing 'leftover' rows. Special support for UDEF, as well as optional extensive information return. Traveltransactionlog and WebHooks are supported
|
|
442
|
+
* @param tableName - The name of the table where rows should be inserted or updated
|
|
443
|
+
* @param columns - List of column names, in the same order as in the data
|
|
444
|
+
* @param keys - List of columns that are to be used as keys, to match any existing rows
|
|
445
|
+
* @param data - Outer array = row, inner = column in specified order; use CultureDataFormatter to format values
|
|
446
|
+
* @param nomatchAction - Action to take on rows in the target table, that are not matched by any rows in the incoming data. Use the deletion options with care. NEVER use deletion if your Upsert is so large you need to divide it into multiple batches.
|
|
447
|
+
* @param returnRowStatus - If true, then the 'RowStatus' member of the return carrier will be populated with a per-row status, for each incoming row
|
|
448
|
+
* @returns Summary of results
|
|
449
|
+
*/
|
|
450
|
+
public async upsertAsync(tableName: string, columns: string[], keys: string[], data: string[][], nomatchAction: enums.UpsertNomatchAction, returnRowStatus: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
451
|
+
|
|
452
|
+
public async upsertAsync(tableName:string|carriers.DatabaseTable_UpsertRequest, columns?:string[]|base.WebApiRequestOptions, keys?:string[], data?:string[][], nomatchAction?:enums.UpsertNomatchAction, returnRowStatus?:boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
453
|
+
let _request : carriers.DatabaseTable_UpsertRequest = null;
|
|
454
|
+
let _options : base.WebApiRequestOptions = null;
|
|
455
|
+
const first : any = tableName;
|
|
456
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.columns)!='undefined' || typeof(first.keys)!='undefined' || typeof(first.data)!='undefined' || typeof(first.nomatchAction)!='undefined' || typeof(first.returnRowStatus)!='undefined' ) )
|
|
457
|
+
{
|
|
458
|
+
_request = tableName as carriers.DatabaseTable_UpsertRequest;
|
|
459
|
+
_options = columns as base.WebApiRequestOptions;
|
|
460
|
+
}
|
|
461
|
+
else
|
|
462
|
+
{
|
|
463
|
+
_request = {
|
|
464
|
+
tableName: tableName as string,
|
|
465
|
+
columns: columns as string[],
|
|
466
|
+
keys: keys as string[],
|
|
467
|
+
data: data as string[][],
|
|
468
|
+
nomatchAction: nomatchAction as enums.UpsertNomatchAction,
|
|
469
|
+
returnRowStatus: returnRowStatus as boolean,
|
|
470
|
+
};
|
|
471
|
+
_options = webapi_options;
|
|
472
|
+
}
|
|
473
|
+
return this._upsertAsync( _request, _options );
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
private async _deleteAsync(request: carriers.DatabaseTable_DeleteRequest, options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
478
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
479
|
+
base.WebApiBase.SetPending(options);
|
|
480
|
+
return new Promise< carriers.MassOperationResult >(async (resolve, reject) => {
|
|
481
|
+
try {
|
|
482
|
+
config.baseURL = this._options.baseUrl;
|
|
483
|
+
const response = await this._axios.post("Delete", request , config);
|
|
484
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
485
|
+
const res : carriers.MassOperationResult = converters.Create_MassOperationResult_From( response.data );
|
|
486
|
+
resolve(res);
|
|
487
|
+
}
|
|
488
|
+
catch( err ) {
|
|
489
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
490
|
+
reject(err);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Delete rows, by primary key; traveltransactionlog and WebHooks are supported
|
|
499
|
+
* @param request - TableName, IDs
|
|
500
|
+
* @returns Summary of results
|
|
501
|
+
*/
|
|
502
|
+
public async deleteAsync(request: carriers.DatabaseTable_DeleteRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Delete rows, by primary key; traveltransactionlog and WebHooks are supported
|
|
506
|
+
* @param tableName - The name of the table where rows should be deleted
|
|
507
|
+
* @param ids - Primary keys of the rows to be deleted
|
|
508
|
+
* @returns Summary of results
|
|
509
|
+
*/
|
|
510
|
+
public async deleteAsync(tableName: string, ids: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult >;
|
|
511
|
+
|
|
512
|
+
public async deleteAsync(tableName:string|carriers.DatabaseTable_DeleteRequest, ids?:number[]|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.MassOperationResult > {
|
|
513
|
+
let _request : carriers.DatabaseTable_DeleteRequest = null;
|
|
514
|
+
let _options : base.WebApiRequestOptions = null;
|
|
515
|
+
const first : any = tableName;
|
|
516
|
+
if( typeof( first ) === "object" && first && ( typeof(first.tableName)!='undefined' || typeof(first.ids)!='undefined' ) )
|
|
517
|
+
{
|
|
518
|
+
_request = tableName as carriers.DatabaseTable_DeleteRequest;
|
|
519
|
+
_options = ids as base.WebApiRequestOptions;
|
|
520
|
+
}
|
|
521
|
+
else
|
|
522
|
+
{
|
|
523
|
+
_request = {
|
|
524
|
+
tableName: tableName as string,
|
|
525
|
+
ids: ids as number[],
|
|
526
|
+
};
|
|
527
|
+
_options = webapi_options;
|
|
528
|
+
}
|
|
529
|
+
return this._deleteAsync( _request, _options );
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
} // class v1DatabaseTableAgentController
|
|
533
|
+
|
|
534
|
+
|