Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit e47d1fe

Browse files
committed
ESM compatibility issues
Replace dot prop with methods. Fix the issues with long and downgrade escapeStringRegexp.
1 parent 6a8ef36 commit e47d1fe

6 files changed

Lines changed: 44 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"arrify": "^2.0.0",
6060
"concat-stream": "^2.0.0",
6161
"dot-prop": "^6.0.0",
62-
"escape-string-regexp": "^4.0.0",
62+
"escape-string-regexp": "3.0.0",
6363
"extend": "^3.0.2",
6464
"google-gax": "^4.0.3",
6565
"grpc-gcp": "^1.0.1",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,8 @@ export class Bigtable {
648648
'A cluster was provided with both `encryption` and `key` defined.'
649649
);
650650
}
651-
ClusterUtils.validateClusterMetadata(cluster);
652-
clusters[cluster.id!] =
651+
ClusterUtils.validateClusterMetadata(cluster as ClusterInfo);
652+
clusters[(cluster as ClusterInfo).id!] =
653653
ClusterUtils.getClusterBaseConfigWithFullLocation(
654654
cluster,
655655
this.projectId,

src/mutation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import arrify = require('arrify');
1616
import * as is from 'is';
17-
import * as Long from 'long';
17+
const Long = require('long');
1818

1919
import {google as btTypes} from '../protos/protos';
2020

src/row-data-utils.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
const dotProp = require('dot-prop');
15+
import * as dotProp from 'dot-prop';
1616
import {Filter, RawFilter} from './filter';
1717
import {
1818
CreateRulesCallback,
@@ -46,6 +46,41 @@ export interface RowProperties {
4646
reqOpts: TabularApiSurfaceRequest;
4747
}
4848

49+
function getNestedValue(obj: any, path: any) {
50+
if (!obj || typeof obj !== 'object' || !path) {
51+
return undefined;
52+
}
53+
54+
const keys = path.split('.');
55+
let current = obj;
56+
57+
for (const key of keys) {
58+
if (current && typeof current === 'object' && key in current) {
59+
current = current[key];
60+
} else {
61+
return undefined; // Path not found
62+
}
63+
}
64+
65+
return current;
66+
}
67+
68+
function getValueFromData(data: any, column: any) {
69+
const path = column.replace(':', '.');
70+
const nestedValue = getNestedValue(data, path);
71+
72+
if (
73+
Array.isArray(nestedValue) &&
74+
nestedValue.length > 0 &&
75+
nestedValue[0] &&
76+
'value' in nestedValue[0]
77+
) {
78+
return nestedValue[0].value;
79+
}
80+
81+
return undefined; // Or handle the case where the path or structure is not as expected
82+
}
83+
4984
/**
5085
* RowDataUtils is a class containing functionality needed by the Row and
5186
* AuthorizedView classes. Its static methods need to be contained in a class
@@ -247,7 +282,7 @@ class RowDataUtils {
247282
return;
248283
}
249284
const data = this.formatFamilies_Util(resp!.row!.families!);
250-
const value = dotProp.get(data, column.replace(':', '.'))[0].value;
285+
const value = getValueFromData(data, column);
251286

252287
callback(null, value, resp);
253288
});

test/chunktransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import * as assert from 'assert';
1616
import {describe, it, before, beforeEach, afterEach} from 'mocha';
17-
import * as Long from 'long';
17+
const Long = require('long');
1818
import * as proxyquire from 'proxyquire';
1919
import * as sn from 'sinon';
2020

test/mutation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
import * as assert from 'assert';
1616
import {beforeEach, describe, it, afterEach} from 'mocha';
17-
import * as Long from 'long';
1817
import * as sinon from 'sinon';
1918

19+
const Long = require('long');
20+
2021
import {IMutateRowRequest, Mutation, IMutation} from '../src/mutation.js';
2122

2223
const sandbox = sinon.createSandbox();

0 commit comments

Comments
 (0)