Skip to content

Commit

Permalink
chore: initial build of document ai library
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Sep 12, 2019
0 parents commit 5d54669
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
6 changes: 6 additions & 0 deletions document-ai/snippets/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
rules:
no-console: off
node/no-missing-require: off
node/no-extraneous-require: off

22 changes: 22 additions & 0 deletions document-ai/snippets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "nodejs-document-ai-samples",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=8"
},
"files": [
"*.js"
],
"scripts": {
"test": "mocha test/*.js"
},
"dependencies": {
"@google-cloud/document-ai": "^1.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^6.2.0"
}
}
39 changes: 39 additions & 0 deletions document-ai/snippets/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2019, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* DESCRIBE WHAT THIS SAMPLE DOES.
* @param {string} LIST EXPECTED ARGUMENTS.
*/
async function main() {
// [START LIBRARY_NAME_quickstart]
async function batchProcessDocument() {
const {
DocumentUnderstandingServiceClient,
} = require('@google-cloud/document');
const client = new DocumentUnderstandingServiceClient();
// TODO: write sample here that demonstrates batch processing of documents.
console.info(client);
}
// [END LIBRARY_NAME_quickstart]
await batchProcessDocument();
}

main(...process.argv.slice(2)).catch(err => {
console.error(err);
process.exitCode = 1;
});
5 changes: 5 additions & 0 deletions document-ai/snippets/test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
env:
mocha: true
rules:
node/no-extraneous-require: off
31 changes: 31 additions & 0 deletions document-ai/snippets/test/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright 2019, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const path = require('path');
const {assert} = require('chai');
const cp = require('child_process');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cwd = path.join(__dirname, '..');

describe('Quickstart', () => {
it('should run quickstart', async () => {
const stdout = execSync(`node ./quickstart.js`, {cwd});
assert.ok(stdout);
});
});

0 comments on commit 5d54669

Please sign in to comment.