gd-sprest-def
Advanced tools
Comparing version 0.5.1 to 0.5.2
42
main.js
@@ -456,6 +456,6 @@ let fs = require("fs"); | ||
// Directory -> File | ||
let api = []; | ||
let apiImports = []; | ||
let mapper = {}; | ||
for (let dirName in directories) { | ||
let api = []; | ||
let apiImports = []; | ||
let files = {}; | ||
@@ -610,3 +610,3 @@ let filesIndex = []; | ||
// Add the mapper | ||
let mapperKey = dirName.replace(/\./g, '_') + '_' + name + "_Collection"; | ||
let mapperKey = dirName + '.' + name + '.Collection'; | ||
mapper[mapperKey] = mapper[mapperKey] || []; | ||
@@ -663,3 +663,3 @@ mapper[mapperKey].push(methodInfo); | ||
// Add the mapper | ||
let mapperKey = dirName.replace(/\./g, '_') + '_' + name; | ||
let mapperKey = dirName + '.' + name; | ||
mapper[mapperKey] = mapper[mapperKey] || []; | ||
@@ -791,16 +791,19 @@ mapper[mapperKey].push(methodInfo); | ||
fs.appendFileSync(path + "/index.d.ts", '\n' + filesIndex.join('\n')); | ||
} | ||
// Ensure api data exists | ||
if (api.length > 0) { | ||
// Remove duplicates from the import array | ||
apiImports = apiImports.filter(function (item, pos) { return apiImports.indexOf(item) == pos; }); | ||
// Remove duplicates from the import array | ||
apiImports = apiImports.filter(function (item, pos) { return apiImports.indexOf(item) == pos; }); | ||
// Create the api file | ||
fs.appendFileSync("lib/api.d.ts", apiImports.join('\n') + '\n\n' + api.join('\n')); | ||
} | ||
} | ||
// Create the api file | ||
fs.appendFileSync("lib/api.d.ts", apiImports.join('\n') + '\n\n' + api.join('\n')); | ||
// Parse the mapper | ||
// Get the mapper keys | ||
let mapperKeys = []; | ||
for (let mapperKey in mapper) { mapperKeys.push(mapperKey); } | ||
mapperKeys = mapperKeys.sort(); | ||
// Parse the mapper names | ||
let mapperContent = []; | ||
for (let mapperKey in mapper) { | ||
for (let i = 0; i < mapperKeys.length; i++) { | ||
let mapperKey = mapperKeys[i]; | ||
let methods = []; | ||
@@ -810,9 +813,12 @@ | ||
methods.push('\/* ' + mapperKey + ' *\/'); | ||
methods.push('export interface ' + mapperKey + ' {'); | ||
methods.push('export interface ' + mapperKey.replace(/\./g, '_') + ' {'); | ||
// Add the optional properties | ||
methods.push('\tproperties?: Array<string>;'); | ||
// See if this is not a collection | ||
if (/\.Collection$/.test(mapperKey) == false) { | ||
// Add the optional properties | ||
methods.push('\tproperties?: Array<string>;'); | ||
} | ||
// See if this type is queryable | ||
if (hasCollections[mapperKey.replace('_', '.')]) { | ||
if (hasCollections[mapperKey]) { | ||
// Add the query method | ||
@@ -819,0 +825,0 @@ methods.push('\tquery: IMapper & { argNames: ["oData"] },') |
{ | ||
"name": "gd-sprest-def", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "TypeScript definition files generated from the $metadata REST endpoint in SharePoint.", | ||
@@ -5,0 +5,0 @@ "author": "Gunjan Datta <me@dattabase.com> (https://gunjandatta.github.io)", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4072094
42639