Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Layer => JSON Schema #39

Merged
merged 7 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"@typescript-eslint/ban-ts-comment": 1
"@typescript-eslint/ban-ts-comment": 1,
"@typescript-eslint/no-explicit-any": 1
}
}
42 changes: 32 additions & 10 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,61 @@
import minimist from 'minimist';

const argv = minimist(process.argv, {
string: ['approach'],
string: ['approach', 'header'],
boolean: ['help']
});

if (argv.help) {
console.log();
console.log('Usage:');
console.log(' node cli.js [--help] [--approach=bbox]');
console.log(' node cli.js [mode] [--help]');
console.log();
console.log('Args:');
console.log(' --help Display this message');
console.log('Mode: fetch [--approach] <url>');
console.log(' --header \'key=value\' IE --header \'Content-Type=123\'');
console.log(' --approach [approach] Download Approach');
console.log(' "bbox" Download features by iterating over bboxes');
console.log(' slowest but most reliable approach');
console.log(' "iter" Iterate over OIDs');
console.log(' faster but not supported by all servers');
console.log('Mode: schema <url>');
console.log();
process.exit();
}

const url = argv._[2];
if (!argv._[2]) throw new Error('Mode required');

const url = argv._[3];
if (!url) throw new Error('url required');

const headers: any = {};

Check warning on line 34 in cli.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
if (argv.header) {
if (typeof argv.header === 'string') argv.header = [ argv.header ];
for (const header of argv.header) {
const parsed = header.split('=');
headers[parsed[0]] = parsed.slice(1, parsed.length).join('=');
}
}


const esri = new EsriDump(url, {
approach: argv.approach
approach: argv.approach,
headers
});

esri.on('error', (err) => {
throw err;
}).on('feature', (feature) => {
console.log(JSON.stringify(feature));
});

await esri.fetch();
if (argv._[2] === 'fetch') {
esri.on('error', (err) => {
throw err;
}).on('feature', (feature) => {
console.log(JSON.stringify(feature));
});

await esri.fetch();
} else if (argv._[2] === 'schema') {
await esri.schema();
} else {
throw new Error('Unknown Mode');
}

43 changes: 33 additions & 10 deletions dist/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cli.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 67 additions & 24 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading