diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index 3ade3a1f5..f333fd933 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -524,13 +524,13 @@ function runTest(spec: ConformanceProto) { * as strings to a proper protobuf type since protobufJS does not support it at * the moment. */ -function normalizeTimestamp(obj: {[key: string]: {}}) { +function normalizeTimestamp(obj: Record) { const fieldNames = ['updateTime', 'createTime', 'readTime']; for (const key of Object.keys(obj)) { if (fieldNames.includes(key) && typeof obj[key] === 'string') { obj[key] = convertTimestamp(obj[key] as string); } else if (typeof obj[key] === 'object') { - normalizeTimestamp(obj[key]); + normalizeTimestamp(obj[key] as Record); } } } @@ -563,7 +563,7 @@ function convertTimestamp(text: string): {[key: string]: number} { * Value type, but the 'limit' field in 'query' has Int32Value type, resulting * in the need for an extra layer of specificity. */ -function normalizeInt32Value(obj: {[key: string]: {}}, parent = '') { +function normalizeInt32Value(obj: Record, parent = '') { const fieldNames = ['limit']; const parentNames = ['query']; for (const key of Object.keys(obj)) { @@ -576,7 +576,7 @@ function normalizeInt32Value(obj: {[key: string]: {}}, parent = '') { value: obj[key], }; } else if (typeof obj[key] === 'object') { - normalizeInt32Value(obj[key], key); + normalizeInt32Value(obj[key] as Record, key); } } } diff --git a/dev/src/reference/collection-reference.ts b/dev/src/reference/collection-reference.ts index 9a50a1709..f3fb919c9 100644 --- a/dev/src/reference/collection-reference.ts +++ b/dev/src/reference/collection-reference.ts @@ -183,11 +183,10 @@ export class CollectionReference< }; return this.firestore - .request( - 'listDocuments', - request, - tag - ) + .request< + api.IListDocumentsRequest, + api.IDocument[] + >('listDocuments', request, tag) .then(documents => { // Note that the backend already orders these documents by name, // so we do not need to manually sort them. diff --git a/dev/src/reference/document-reference.ts b/dev/src/reference/document-reference.ts index 48c2799aa..0af5e549e 100644 --- a/dev/src/reference/document-reference.ts +++ b/dev/src/reference/document-reference.ts @@ -257,11 +257,10 @@ export class DocumentReference< pageSize: Math.pow(2, 16) - 1, }; return this._firestore - .request( - 'listCollectionIds', - request, - tag - ) + .request< + api.IListCollectionIdsRequest, + string[] + >('listCollectionIds', request, tag) .then(collectionIds => { const collections: Array = []; diff --git a/dev/test/gapic_firestore_admin_v1.ts b/dev/test/gapic_firestore_admin_v1.ts index 6d577b987..c3b5f21b1 100644 --- a/dev/test/gapic_firestore_admin_v1.ts +++ b/dev/test/gapic_firestore_admin_v1.ts @@ -3745,9 +3745,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -3796,9 +3796,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -3839,9 +3839,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -3881,9 +3881,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -4050,9 +4050,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listFields.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -4101,9 +4101,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listFields.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -4144,9 +4144,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listFields.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -4186,9 +4186,9 @@ describe('v1.FirestoreAdminClient', () => { assert( (client.descriptors.page.listFields.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); diff --git a/dev/test/gapic_firestore_v1.ts b/dev/test/gapic_firestore_v1.ts index df6a2f4dc..006f11f32 100644 --- a/dev/test/gapic_firestore_v1.ts +++ b/dev/test/gapic_firestore_v1.ts @@ -2254,9 +2254,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2305,9 +2305,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2353,9 +2353,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2398,9 +2398,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -2564,9 +2564,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2610,9 +2610,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2653,9 +2653,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2693,9 +2693,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -2844,9 +2844,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2890,9 +2890,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2929,9 +2929,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2969,9 +2969,9 @@ describe('v1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts index e6431944f..5e168c725 100644 --- a/dev/test/gapic_firestore_v1beta1.ts +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -2088,9 +2088,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2142,9 +2142,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2190,9 +2190,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2235,9 +2235,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listDocuments.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -2404,9 +2404,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2453,9 +2453,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2496,9 +2496,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2536,9 +2536,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -2687,9 +2687,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2733,9 +2733,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2772,9 +2772,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2812,9 +2812,9 @@ describe('v1beta1.FirestoreClient', () => { assert( (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); diff --git a/package.json b/package.json index 9ed6b98f4..1a37b9c2a 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,9 @@ "chai-as-promised": "^7.1.1", "codecov": "^3.6.1", "duplexify": "^4.0.0", + "execa": "^5.1.1", "extend": "^3.0.2", + "fs-extra": "7.0.1", "gapic-tools": "^0.4.0", "gts": "^5.0.1", "jsdoc": "^4.0.0", @@ -92,6 +94,7 @@ "jsdoc-region-tag": "^3.0.0", "length-prefixed-json-stream": "^1.0.1", "linkinator": "^3.0.0", + "mkdirp": "^1.0.4", "mocha": "^9.2.2", "protobufjs-cli": "^1.1.2", "proxyquire": "^2.1.3",