Skip to content

Commit a249f95

Browse files
feat!: drop node8 support, support for async iterators (#440)
BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM. New feature: methods with pagination now support async iteration.
1 parent 655fddf commit a249f95

12 files changed

Lines changed: 114 additions & 114 deletions

File tree

dlp/deid.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,11 @@ async function reidentifyWithFpe(
402402
// [END dlp_reidentify_fpe]
403403
}
404404

405-
const cli = require(`yargs`)
405+
const cli = require('yargs')
406406
.demand(1)
407407
.command(
408-
`deidMask <string>`,
409-
`Deidentify sensitive data in a string by masking it with a character.`,
408+
'deidMask <string>',
409+
'Deidentify sensitive data in a string by masking it with a character.',
410410
{
411411
maskingCharacter: {
412412
type: 'string',
@@ -428,8 +428,8 @@ const cli = require(`yargs`)
428428
)
429429
)
430430
.command(
431-
`deidFpe <string> <wrappedKey> <keyName>`,
432-
`Deidentify sensitive data in a string using Format Preserving Encryption (FPE).`,
431+
'deidFpe <string> <wrappedKey> <keyName>',
432+
'Deidentify sensitive data in a string using Format Preserving Encryption (FPE).',
433433
{
434434
alphabet: {
435435
type: 'string',
@@ -459,8 +459,8 @@ const cli = require(`yargs`)
459459
)
460460
)
461461
.command(
462-
`reidFpe <string> <surrogateType> <wrappedKey> <keyName>`,
463-
`Reidentify sensitive data in a string using Format Preserving Encryption (FPE).`,
462+
'reidFpe <string> <surrogateType> <wrappedKey> <keyName>',
463+
'Reidentify sensitive data in a string using Format Preserving Encryption (FPE).',
464464
{
465465
alphabet: {
466466
type: 'string',
@@ -485,8 +485,8 @@ const cli = require(`yargs`)
485485
)
486486
)
487487
.command(
488-
`deidDateShift <inputCsvFile> <outputCsvFile> <lowerBoundDays> <upperBoundDays> [dateFields...]`,
489-
`Deidentify dates in a CSV file by pseudorandomly shifting them.`,
488+
'deidDateShift <inputCsvFile> <outputCsvFile> <lowerBoundDays> <upperBoundDays> [dateFields...]',
489+
'Deidentify dates in a CSV file by pseudorandomly shifting them.',
490490
{
491491
contextFieldId: {
492492
type: 'string',
@@ -524,19 +524,19 @@ const cli = require(`yargs`)
524524
alias: 'callingProjectId',
525525
default: process.env.GCLOUD_PROJECT || '',
526526
})
527-
.example(`node $0 deidMask "My SSN is 372819127"`)
527+
.example('node $0 deidMask "My SSN is 372819127"')
528528
.example(
529-
`node $0 deidFpe "My SSN is 372819127" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring -s SSN_TOKEN`
529+
'node $0 deidFpe "My SSN is 372819127" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring -s SSN_TOKEN'
530530
)
531531
.example(
532-
`node $0 reidFpe "My SSN is SSN_TOKEN(9):#########" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring SSN_TOKEN -a NUMERIC`
532+
'node $0 reidFpe "My SSN is SSN_TOKEN(9):#########" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring SSN_TOKEN -a NUMERIC'
533533
)
534534
.example(
535-
`node $0 deidDateShift dates.csv dates-shifted.csv 30 30 birth_date register_date [-w <YOUR_ENCRYPTED_AES_256_KEY> -n projects/my-project/locations/global/keyrings/my-keyring]`
535+
'node $0 deidDateShift dates.csv dates-shifted.csv 30 30 birth_date register_date [-w <YOUR_ENCRYPTED_AES_256_KEY> -n projects/my-project/locations/global/keyrings/my-keyring]'
536536
)
537537
.wrap(120)
538538
.recommendCommands()
539-
.epilogue(`For more information, see https://cloud.google.com/dlp/docs.`);
539+
.epilogue('For more information, see https://cloud.google.com/dlp/docs.');
540540

541541
if (module === require.main) {
542542
cli.help().strict().argv; // eslint-disable-line

dlp/inspect.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function inspectString(
7575
const [response] = await dlp.inspectContent(request);
7676
const findings = response.result.findings;
7777
if (findings.length > 0) {
78-
console.log(`Findings:`);
78+
console.log('Findings:');
7979
findings.forEach(finding => {
8080
if (includeQuote) {
8181
console.log(`\tQuote: ${finding.quote}`);
@@ -84,7 +84,7 @@ async function inspectString(
8484
console.log(`\tLikelihood: ${finding.likelihood}`);
8585
});
8686
} else {
87-
console.log(`No findings.`);
87+
console.log('No findings.');
8888
}
8989
} catch (err) {
9090
console.log(`Error in inspectString: ${err.message || err}`);
@@ -168,7 +168,7 @@ async function inspectFile(
168168
const [response] = await dlp.inspectContent(request);
169169
const findings = response.result.findings;
170170
if (findings.length > 0) {
171-
console.log(`Findings:`);
171+
console.log('Findings:');
172172
findings.forEach(finding => {
173173
if (includeQuote) {
174174
console.log(`\tQuote: ${finding.quote}`);
@@ -177,7 +177,7 @@ async function inspectFile(
177177
console.log(`\tLikelihood: ${finding.likelihood}`);
178178
});
179179
} else {
180-
console.log(`No findings.`);
180+
console.log('No findings.');
181181
}
182182
} catch (err) {
183183
console.log(`Error in inspectFile: ${err.message || err}`);
@@ -300,7 +300,7 @@ async function inspectGCSFile(
300300
});
301301

302302
setTimeout(() => {
303-
console.log(`Waiting for DLP job to fully complete`);
303+
console.log('Waiting for DLP job to fully complete');
304304
}, 500);
305305
const [job] = await dlp.getDlpJob({name: jobName});
306306
console.log(`Job ${job.name} status: ${job.state}`);
@@ -313,7 +313,7 @@ async function inspectGCSFile(
313313
);
314314
});
315315
} else {
316-
console.log(`No findings.`);
316+
console.log('No findings.');
317317
}
318318
} catch (err) {
319319
console.log(`Error in inspectGCSFile: ${err.message || err}`);
@@ -446,7 +446,7 @@ async function inspectDatastore(
446446
});
447447
// Wait for DLP job to fully complete
448448
setTimeout(() => {
449-
console.log(`Waiting for DLP job to fully complete`);
449+
console.log('Waiting for DLP job to fully complete');
450450
}, 500);
451451
const [job] = await dlp.getDlpJob({name: jobName});
452452
console.log(`Job ${job.name} status: ${job.state}`);
@@ -459,7 +459,7 @@ async function inspectDatastore(
459459
);
460460
});
461461
} else {
462-
console.log(`No findings.`);
462+
console.log('No findings.');
463463
}
464464
} catch (err) {
465465
console.log(`Error in inspectDatastore: ${err.message || err}`);
@@ -590,7 +590,7 @@ async function inspectBigquery(
590590
});
591591
// Wait for DLP job to fully complete
592592
setTimeout(() => {
593-
console.log(`Waiting for DLP job to fully complete`);
593+
console.log('Waiting for DLP job to fully complete');
594594
}, 500);
595595
const [job] = await dlp.getDlpJob({name: jobName});
596596
console.log(`Job ${job.name} status: ${job.state}`);
@@ -603,7 +603,7 @@ async function inspectBigquery(
603603
);
604604
});
605605
} else {
606-
console.log(`No findings.`);
606+
console.log('No findings.');
607607
}
608608
} catch (err) {
609609
console.log(`Error in inspectBigquery: ${err.message || err}`);
@@ -615,8 +615,8 @@ async function inspectBigquery(
615615
const cli = require(`yargs`) // eslint-disable-line
616616
.demand(1)
617617
.command(
618-
`string <string>`,
619-
`Inspect a string using the Data Loss Prevention API.`,
618+
'string <string>',
619+
'Inspect a string using the Data Loss Prevention API.',
620620
{},
621621
opts =>
622622
inspectString(
@@ -630,8 +630,8 @@ const cli = require(`yargs`) // eslint-disable-line
630630
)
631631
)
632632
.command(
633-
`file <filepath>`,
634-
`Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API.`,
633+
'file <filepath>',
634+
'Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API.',
635635
{},
636636
opts =>
637637
inspectFile(
@@ -645,8 +645,8 @@ const cli = require(`yargs`) // eslint-disable-line
645645
)
646646
)
647647
.command(
648-
`gcsFile <bucketName> <fileName> <topicId> <subscriptionId>`,
649-
`Inspects a text file stored on Google Cloud Storage with the Data Loss Prevention API, using Pub/Sub for job notifications.`,
648+
'gcsFile <bucketName> <fileName> <topicId> <subscriptionId>',
649+
'Inspects a text file stored on Google Cloud Storage with the Data Loss Prevention API, using Pub/Sub for job notifications.',
650650
{},
651651
opts =>
652652
inspectGCSFile(
@@ -662,8 +662,8 @@ const cli = require(`yargs`) // eslint-disable-line
662662
)
663663
)
664664
.command(
665-
`bigquery <datasetName> <tableName> <topicId> <subscriptionId>`,
666-
`Inspects a BigQuery table using the Data Loss Prevention API using Pub/Sub for job notifications.`,
665+
'bigquery <datasetName> <tableName> <topicId> <subscriptionId>',
666+
'Inspects a BigQuery table using the Data Loss Prevention API using Pub/Sub for job notifications.',
667667
{},
668668
opts => {
669669
inspectBigquery(
@@ -681,8 +681,8 @@ const cli = require(`yargs`) // eslint-disable-line
681681
}
682682
)
683683
.command(
684-
`datastore <kind> <topicId> <subscriptionId>`,
685-
`Inspect a Datastore instance using the Data Loss Prevention API using Pub/Sub for job notifications.`,
684+
'datastore <kind> <topicId> <subscriptionId>',
685+
'Inspect a Datastore instance using the Data Loss Prevention API using Pub/Sub for job notifications.',
686686
{
687687
namespaceId: {
688688
type: 'string',
@@ -781,15 +781,15 @@ const cli = require(`yargs`) // eslint-disable-line
781781
type: 'string',
782782
global: true,
783783
})
784-
.example(`node $0 string "My email address is me@somedomain.com"`)
785-
.example(`node $0 file resources/test.txt`)
786-
.example(`node $0 gcsFile my-bucket my-file.txt my-topic my-subscription`)
787-
.example(`node $0 bigquery my-dataset my-table my-topic my-subscription`)
788-
.example(`node $0 datastore my-datastore-kind my-topic my-subscription`)
784+
.example('node $0 string "My email address is me@somedomain.com"')
785+
.example('node $0 file resources/test.txt')
786+
.example('node $0 gcsFile my-bucket my-file.txt my-topic my-subscription')
787+
.example('node $0 bigquery my-dataset my-table my-topic my-subscription')
788+
.example('node $0 datastore my-datastore-kind my-topic my-subscription')
789789
.wrap(120)
790790
.recommendCommands()
791791
.epilogue(
792-
`For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/InspectConfig`
792+
'For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/InspectConfig'
793793
);
794794

795795
if (module === require.main) {

dlp/jobs.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function deleteJob(jobName) {
8686
const cli = require(`yargs`) // eslint-disable-line
8787
.demand(1)
8888
.command(
89-
`list <filter>`,
90-
`List Data Loss Prevention API jobs corresponding to a given filter.`,
89+
'list <filter>',
90+
'List Data Loss Prevention API jobs corresponding to a given filter.',
9191
{
9292
jobType: {
9393
type: 'string',
@@ -98,8 +98,8 @@ const cli = require(`yargs`) // eslint-disable-line
9898
opts => listJobs(opts.callingProject, opts.filter, opts.jobType)
9999
)
100100
.command(
101-
`delete <jobName>`,
102-
`Delete results of a Data Loss Prevention API job.`,
101+
'delete <jobName>',
102+
'Delete results of a Data Loss Prevention API job.',
103103
{},
104104
opts => deleteJob(opts.jobName)
105105
)
@@ -108,11 +108,11 @@ const cli = require(`yargs`) // eslint-disable-line
108108
alias: 'callingProject',
109109
default: process.env.GCLOUD_PROJECT || '',
110110
})
111-
.example(`node $0 list "state=DONE" -t RISK_ANALYSIS_JOB`)
112-
.example(`node $0 delete projects/YOUR_GCLOUD_PROJECT/dlpJobs/X-#####`)
111+
.example('node $0 list "state=DONE" -t RISK_ANALYSIS_JOB')
112+
.example('node $0 delete projects/YOUR_GCLOUD_PROJECT/dlpJobs/X-#####')
113113
.wrap(120)
114114
.recommendCommands()
115-
.epilogue(`For more information, see https://cloud.google.com/dlp/docs.`);
115+
.epilogue('For more information, see https://cloud.google.com/dlp/docs.');
116116

117117
if (module === require.main) {
118118
cli.help().strict().argv; // eslint-disable-line

dlp/metadata.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ async function listInfoTypes(languageCode, filter) {
3333
filter: filter,
3434
});
3535
const infoTypes = response.infoTypes;
36-
console.log(`Info types:`);
36+
console.log('Info types:');
3737
infoTypes.forEach(infoType => {
3838
console.log(`\t${infoType.name} (${infoType.displayName})`);
3939
});
4040

4141
// [END dlp_list_info_types]
4242
}
4343

44-
const cli = require(`yargs`)
44+
const cli = require('yargs')
4545
.demand(1)
4646
.command(
47-
`infoTypes [filter]`,
48-
`List the types of sensitive information the DLP API supports.`,
47+
'infoTypes [filter]',
48+
'List the types of sensitive information the DLP API supports.',
4949
{},
5050
opts => listInfoTypes(opts.languageCode, opts.filter)
5151
)
@@ -55,10 +55,10 @@ const cli = require(`yargs`)
5555
type: 'string',
5656
global: true,
5757
})
58-
.example(`node $0 infoTypes "supported_by=INSPECT"`)
58+
.example('node $0 infoTypes "supported_by=INSPECT"')
5959
.wrap(120)
6060
.recommendCommands()
61-
.epilogue(`For more information, see https://cloud.google.com/dlp/docs`);
61+
.epilogue('For more information, see https://cloud.google.com/dlp/docs');
6262

6363
if (module === require.main) {
6464
cli.help().strict().argv; // eslint-disable-line

dlp/quickstart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function quickStart() {
6262
const [response] = await dlp.inspectContent(request);
6363
const findings = response.result.findings;
6464
if (findings.length > 0) {
65-
console.log(`Findings:`);
65+
console.log('Findings:');
6666
findings.forEach(finding => {
6767
if (includeQuote) {
6868
console.log(`\tQuote: ${finding.quote}`);
@@ -71,7 +71,7 @@ async function quickStart() {
7171
console.log(`\tLikelihood: ${finding.likelihood}`);
7272
});
7373
} else {
74-
console.log(`No findings.`);
74+
console.log('No findings.');
7575
}
7676
// [END dlp_quickstart]
7777
}

dlp/redact.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ async function redactImage(
130130
// [END dlp_redact_image]
131131
}
132132

133-
const cli = require(`yargs`)
133+
const cli = require('yargs')
134134
.demand(1)
135135
.command(
136-
`string <string>`,
137-
`Redact a string using the Data Loss Prevention API.`,
136+
'string <string>',
137+
'Redact a string using the Data Loss Prevention API.',
138138
{},
139139
opts =>
140140
redactText(
@@ -145,8 +145,8 @@ const cli = require(`yargs`)
145145
)
146146
)
147147
.command(
148-
`image <filepath> <outputPath>`,
149-
`Redact sensitive data from an image using the Data Loss Prevention API.`,
148+
'image <filepath> <outputPath>',
149+
'Redact sensitive data from an image using the Data Loss Prevention API.',
150150
{},
151151
opts =>
152152
redactImage(
@@ -187,11 +187,11 @@ const cli = require(`yargs`)
187187
type: 'string',
188188
global: true,
189189
})
190-
.example(`node $0 image resources/test.png result.png -t MALE_NAME`)
190+
.example('node $0 image resources/test.png result.png -t MALE_NAME')
191191
.wrap(120)
192192
.recommendCommands()
193193
.epilogue(
194-
`For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/projects.image/redact#ImageRedactionConfig`
194+
'For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/projects.image/redact#ImageRedactionConfig'
195195
);
196196

197197
if (module === require.main) {

0 commit comments

Comments
 (0)