-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
317 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
// media/ibmi_common.ts | ||
|
||
import { object_toQueryString, string_rtrim, string_matchGeneric } from 'sr_core_ts'; | ||
import axios from 'axios'; | ||
|
||
export interface iDspfd_mbrlist | ||
{ | ||
FILENAME: string, | ||
LIBNAME: string, | ||
MBRNAME: string, | ||
NUMRCDS: number, | ||
CRTDATE: string, | ||
CHGDATE: string, | ||
CHGTIME: string, | ||
MBRTEXT: string, | ||
SRCTYPE: string | ||
}; | ||
|
||
// --------------------- as400_compile ----------------------- | ||
export async function as400_compile(config:{ serverUrl:string, CURLIB:string, LIBL:string}, | ||
srcfName:string, srcfLib:string, srcmbr:string) : | ||
Promise<{compMsg:string, compile:string[], joblog:string[]}> | ||
{ | ||
const promise = new Promise<{ compMsg: string, compile: string[], joblog: string[] }> | ||
( async (resolve, reject) => | ||
{ | ||
srcfName = srcfName || ''; | ||
srcfLib = srcfLib || ''; | ||
srcmbr = srcmbr || ''; | ||
const libl = string_rtrim(config.LIBL); | ||
const curlib = config.CURLIB; | ||
let compMsg = ''; | ||
let compile:string[] = [] ; | ||
let joblog:string[] = [] ; | ||
|
||
const url = `${config.serverUrl}/coder/common/json_getManyRows.php`; | ||
const params = | ||
{ | ||
libl, proc: 'utl7960_compile', | ||
outParm1: compMsg, parm2: srcfName, | ||
parm3: srcfLib, parm4: srcmbr, parm5: curlib | ||
} | ||
const query = object_toQueryString(params) ; | ||
const url_query = url + '?' + query ; | ||
|
||
const response = await axios({ | ||
method: 'get', url: url_query, responseType: 'json' | ||
}); | ||
|
||
let data = await response.data; | ||
let outSet = data.outSet; | ||
compMsg = outSet.outParm1; | ||
compile = data.set1 || [] ; | ||
joblog = data.set2 || [] ; | ||
resolve( { compMsg, compile, joblog }); | ||
}); | ||
|
||
return promise; | ||
} | ||
|
||
// --------------------- as400_srcfList ----------------------- | ||
export function as400_srcfList(objName: string, libName: string) : Promise<{}[]> | ||
{ | ||
const promise = new Promise<{}[]> (async (resolve, reject) => | ||
{ | ||
const libl = 'couri7 aplusb1fcc qtemp'; | ||
const url = 'http://173.54.20.170:10080/coder/common/json_getManyRows.php'; | ||
const params = | ||
{ | ||
libl, proc: 'utl8020_srcfList', | ||
parm1: objName, parm2: libName, debug: 'N' | ||
}; | ||
// const query = object_toQueryString(params); | ||
// const url_query = url + '?' + query; | ||
|
||
const response = await axios({ | ||
method: 'get', url, data: params, responseType: 'json' | ||
}); | ||
|
||
const respText = await response.data; | ||
const rows = JSON.parse(respText); | ||
|
||
resolve(rows); | ||
}); | ||
|
||
return promise; | ||
} | ||
|
||
// --------------------- as400_routines ----------------------- | ||
export function as400_routines(libName: string, routineName: string): Promise<{}[]> | ||
{ | ||
const promise = new Promise<{}[]>(async (resolve, reject) => | ||
{ | ||
const libl = 'couri7 aplusb1fcc qtemp'; | ||
const url = 'http://173.54.20.170:10080/coder/common/json_getManyRows.php'; | ||
const params = | ||
{ | ||
libl, proc: 'utl8020_routines', | ||
parm1: libName, parm2: routineName, debug: 'N' | ||
}; | ||
|
||
const response = await axios({ | ||
method: 'get', url, data: params, responseType: 'json' | ||
}); | ||
|
||
const respText = await response.data; | ||
const rows = JSON.parse(respText); | ||
|
||
resolve(rows); | ||
}); | ||
|
||
return promise; | ||
} | ||
|
||
// --------------------- as400_srcmbrLines ----------------------- | ||
export async function as400_srcmbrLines(libName: string, fileName: string, mbrName: string) | ||
: Promise<{ SEQNBR: string, CHGDATE: string, TEXT: string }[]> | ||
{ | ||
const promise = new Promise < { SEQNBR: string, CHGDATE: string, TEXT: string }[] >(async (resolve, reject) => | ||
{ | ||
|
||
const libl = 'couri7 aplusb1fcc qtemp'; | ||
const url = 'http://173.54.20.170:10080/coder/common/json_getManyRows.php'; | ||
const sql = 'select a.seqnbr, char(a.chgdate,iso) chgdate, a.text ' + | ||
'from table(system_srcmbr_lines(?,?,?)) a ' + | ||
'order by a.seqnbr '; | ||
|
||
const params = | ||
{ | ||
libl, sql, | ||
parm1: fileName, parm2: libName, parm3: mbrName, debug: 'N' | ||
}; | ||
|
||
const query = object_toQueryString(params); | ||
const url_query = url + '?' + query; | ||
|
||
const response = await axios({ | ||
method: 'get', url: url_query, responseType: 'json' | ||
}); | ||
|
||
const rows = await response.data; | ||
|
||
resolve(rows); | ||
}) ; | ||
return promise ; | ||
} | ||
|
||
// --------------------- as400_srcmbrList ----------------------- | ||
// return array of srcmbrs of a srcfile. | ||
export async function as400_srcmbrList(libName: string, fileName: string, mbrName: string = '') | ||
: Promise<iDspfd_mbrlist[]> | ||
{ | ||
const promise = new Promise< iDspfd_mbrlist[]>(async (resolve, reject) => | ||
{ | ||
const libl = 'couri7 aplusb1fcc qtemp'; | ||
const url = 'http://173.54.20.170:10080/coder/common/json_getManyRows.php'; | ||
const sql = 'select a.* ' + | ||
'from table(system_dspfd_mbrlist(?,?)) a ' + | ||
'order by a.mbrname '; | ||
const params = | ||
{ | ||
libl, sql, | ||
parm1: fileName, parm2: libName, debug: 'N' | ||
}; | ||
|
||
const query = object_toQueryString(params); | ||
const url_query = url + '?' + query; | ||
|
||
const response = await axios({ | ||
method: 'get', url: url_query, responseType: 'json' | ||
}); | ||
|
||
let rows = await response.data; | ||
|
||
// filter on member name. | ||
if (mbrName) | ||
{ | ||
// mbrName as generic name. | ||
|
||
rows = rows.filter((item: any) => | ||
{ | ||
const item_mbrName = item.MBRNAME.trimRight(); | ||
if (mbrName.endsWith('*')) | ||
{ | ||
return string_matchGeneric(item_mbrName, mbrName); | ||
} | ||
else | ||
{ | ||
return (string_rtrim(item.MBRNAME).indexOf(mbrName) >= 0); | ||
} | ||
}); | ||
} | ||
resolve(rows) ; | ||
}) ; | ||
return promise ; | ||
} | ||
|
||
// --------------------- as400_tablesAndViews_select ----------------------- | ||
export async function as400_tablesAndViews_select(schema: string, collName: string, maxRows: number = 500) | ||
: Promise<[{ SCHEMA: string, COLLNAME: string, COLLTYPE: string }]> | ||
{ | ||
const libl = 'couri7 aplusb1fcc qtemp'; | ||
const url = 'http://173.54.20.170:10080/coder/common/json_getManyRows.php'; | ||
const sql = 'call system_tablesAndViews_select(?,?,?) '; | ||
|
||
const params = | ||
{ | ||
libl, sql, | ||
parm1: schema, parm2: collName, parm3: maxRows, debug: 'N' | ||
}; | ||
|
||
const query = object_toQueryString(params); | ||
const url_query = url + '?' + query; | ||
|
||
const response = await axios({ | ||
method: 'get', url: url_query, responseType: 'json' | ||
}); | ||
|
||
const rows = await response.data; | ||
|
||
return rows; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { string_matchGeneric } from '../main'; | ||
import { steve_compile } from '../browser-path'; | ||
import axios from 'axios'; | ||
import { object_toQueryString, string_rtrim, string_head } from 'sr_core_ts'; | ||
|
||
as400_compile_test( ) ; | ||
|
||
async function as400_compile_test() | ||
{ | ||
const config = {serverUrl:'http://192.168.1.170:10080', CURLIB:'couri7', LIBL:'couri7 qgpl'}; | ||
const srcfName = 'QRPGLESRC' ; | ||
const srcfLib = 'COURI7' ; | ||
const srcmbr = 'UTL7140R' ; | ||
|
||
const ch5 = string_head(srcfName,5) ; | ||
|
||
|
||
const rv = await as400_compile(config, srcfName, srcfLib, srcmbr) ; | ||
console.log( rv.compMsg) ; | ||
for( let ix = 0 ; ix < rv.compile.length && ix < 25 ; ++ix ) | ||
{ | ||
const line = rv.compile[ix] ; | ||
console.log( line.LINE ) ; | ||
} | ||
} | ||
|
||
|
||
interface iCompileLine | ||
{ | ||
SKIPBFR: string, | ||
SPACEB: string, | ||
LINE: string | ||
} | ||
|
||
// --------------------- as400_compile ----------------------- | ||
export async function as400_compile(config: { serverUrl: string, CURLIB: string, LIBL: string }, | ||
srcfName: string, srcfLib: string, srcmbr: string): | ||
Promise<{ compMsg: string, compile: iCompileLine[], joblog: string[] }> | ||
{ | ||
const promise = new Promise<{ compMsg: string, compile: iCompileLine[], joblog: string[] }> | ||
(async (resolve, reject) => | ||
{ | ||
srcfName = srcfName || ''; | ||
srcfLib = srcfLib || ''; | ||
srcmbr = srcmbr || ''; | ||
const libl = string_rtrim(config.LIBL); | ||
const curlib = config.CURLIB; | ||
let compMsg = ''; | ||
let compile: iCompileLine[] = []; | ||
let joblog: string[] = []; | ||
|
||
const url = `${config.serverUrl}/coder/common/json_getManyRows.php`; | ||
const params = | ||
{ | ||
libl, proc: 'utl7960_compile', | ||
outParm1: compMsg, parm2: srcfName, | ||
parm3: srcfLib, parm4: srcmbr, parm5: curlib | ||
} | ||
const query = object_toQueryString(params); | ||
const url_query = url + '?' + query; | ||
|
||
const response = await axios({ | ||
method: 'get', url: url_query, responseType: 'json' | ||
}); | ||
|
||
let data = await response.data; | ||
let outSet = data.outSet; | ||
compMsg = outSet.outParm1; | ||
compile = data.set1 || []; | ||
joblog = data.set2 || []; | ||
resolve({ compMsg, compile, joblog }); | ||
}); | ||
|
||
return promise; | ||
} |