mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 22:50:20 +08:00
[vision][ios] add apiKeyOverride property
This commit is contained in:
@@ -84,6 +84,20 @@ describe('mlkit.vision.document.text', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if apiKeyOverride is not a string', async () => {
|
||||
try {
|
||||
await firebase.vision().cloudDocumentTextRecognizerProcessImage(testImageFile, {
|
||||
apiKeyOverride: true,
|
||||
});
|
||||
return Promise.reject(new Error('Did not throw Error.'));
|
||||
} catch (e) {
|
||||
e.message.should.containEql(
|
||||
"'cloudDocumentTextRecognizerOptions.apiKeyOverride' expected a string value",
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
it('throws if languageHints is not an array', async () => {
|
||||
try {
|
||||
await firebase.vision().cloudDocumentTextRecognizerProcessImage(testImageFile, {
|
||||
|
||||
@@ -210,5 +210,21 @@ describe('mlkit.vision.label', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('apiKeyOverride', () => {
|
||||
it('throws if apiKeyOverride is not a string', async () => {
|
||||
try {
|
||||
await firebase.vision().cloudImageLabelerProcessImage(testImageFile, {
|
||||
apiKeyOverride: true,
|
||||
});
|
||||
return Promise.reject(new Error('Did not throw Error.'));
|
||||
} catch (e) {
|
||||
e.message.should.containEql(
|
||||
"'cloudImageLabelerOptions.apiKeyOverride' expected a string value",
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,6 +92,20 @@ describe('mlkit.vision.landmark', () => {
|
||||
enforceCertFingerprintMatch: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if apiKeyOverride is not a string', async () => {
|
||||
try {
|
||||
await firebase.vision().cloudLandmarkRecognizerProcessImage(testImageFile, {
|
||||
apiKeyOverride: true,
|
||||
});
|
||||
return Promise.reject(new Error('Did not throw Error.'));
|
||||
} catch (e) {
|
||||
e.message.should.containEql(
|
||||
"'cloudLandmarkRecognizerOptions.apiKeyOverride' expected a string value",
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('maxResults', () => {
|
||||
|
||||
@@ -144,6 +144,22 @@ describe('mlkit.vision.text', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('apiKeyOverride', () => {
|
||||
it('throws if apiKeyOverride is not a string', async () => {
|
||||
try {
|
||||
await firebase.vision().cloudTextRecognizerProcessImage(testImageFile, {
|
||||
apiKeyOverride: true,
|
||||
});
|
||||
return Promise.reject(new Error('Did not throw Error.'));
|
||||
} catch (e) {
|
||||
e.message.should.containEql(
|
||||
"'cloudTextRecognizerOptions.apiKeyOverride' expected a string value",
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('languageHints', () => {
|
||||
it('throws if not array', async () => {
|
||||
try {
|
||||
|
||||
@@ -55,6 +55,10 @@ RCT_EXPORT_METHOD(cloudDocumentTextRecognizerProcessImage:
|
||||
options.languageHints = cloudDocumentTextRecognizerOptions[@"hintedLanguages"];
|
||||
}
|
||||
|
||||
if (cloudDocumentTextRecognizerOptions[@"apiKeyOverride"]) {
|
||||
options.APIKeyOverride = cloudDocumentTextRecognizerOptions[@"apiKeyOverride"];
|
||||
}
|
||||
|
||||
FIRVisionDocumentTextRecognizer *textRecognizer = [vision cloudDocumentTextRecognizerWithOptions:options];
|
||||
[textRecognizer processImage:visionImage completion:^(FIRVisionDocumentText *_Nullable result, NSError *error) {
|
||||
if (error != nil) {
|
||||
|
||||
@@ -99,6 +99,10 @@ RCT_EXPORT_METHOD(cloudImageLabelerProcessImage:
|
||||
options.confidenceThreshold = [cloudImageLabelerOptions[@"confidenceThreshold"] floatValue];
|
||||
}
|
||||
|
||||
if (cloudImageLabelerOptions[@"apiKeyOverride"]) {
|
||||
options.APIKeyOverride = cloudImageLabelerOptions[@"apiKeyOverride"];
|
||||
}
|
||||
|
||||
FIRVisionImageLabeler *labeler = [vision cloudImageLabelerWithOptions:options];
|
||||
[labeler processImage:visionImage completion:^(NSArray<FIRVisionImageLabel *> *_Nullable labels, NSError *error) {
|
||||
if (error != nil) {
|
||||
|
||||
@@ -51,6 +51,10 @@ RCT_EXPORT_METHOD(cloudLandmarkRecognizerProcessImage:
|
||||
FIRVisionCloudDetectorOptions *options = [[FIRVisionCloudDetectorOptions alloc] init];
|
||||
options.maxResults = [cloudLandmarkRecognizerOptions[@"maxResults"] unsignedIntegerValue];
|
||||
|
||||
if (cloudLandmarkRecognizerOptions[@"apiKeyOverride"]) {
|
||||
options.APIKeyOverride = cloudLandmarkRecognizerOptions[@"apiKeyOverride"];
|
||||
}
|
||||
|
||||
NSInteger *model = [cloudLandmarkRecognizerOptions[@"model"] pointerValue];
|
||||
|
||||
if (model == (NSInteger *) 1) {
|
||||
|
||||
@@ -88,6 +88,10 @@ RCT_EXPORT_METHOD(cloudTextRecognizerProcessImage:
|
||||
options.languageHints = cloudTextRecognizerOptions[@"hintedLanguages"];
|
||||
}
|
||||
|
||||
if (cloudTextRecognizerOptions[@"apiKeyOverride"]) {
|
||||
options.APIKeyOverride = cloudTextRecognizerOptions[@"apiKeyOverride"];
|
||||
}
|
||||
|
||||
NSInteger *modelType = [cloudTextRecognizerOptions[@"modelType"] pointerValue];
|
||||
if (modelType == (NSInteger *) 1) {
|
||||
options.modelType = FIRVisionCloudTextModelTypeSparse;
|
||||
|
||||
@@ -50,6 +50,16 @@ export default function visionCloudDocumentTextRecognizerOptions(
|
||||
cloudDocumentTextRecognizerOptions.enforceCertFingerprintMatch;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(cloudDocumentTextRecognizerOptions, 'apiKeyOverride')) {
|
||||
if (!isString(cloudDocumentTextRecognizerOptions.apiKeyOverride)) {
|
||||
throw new Error(
|
||||
"'cloudDocumentTextRecognizerOptions.apiKeyOverride' expected a string value.",
|
||||
);
|
||||
}
|
||||
|
||||
out.apiKeyOverride = cloudDocumentTextRecognizerOptions.apiKeyOverride;
|
||||
}
|
||||
|
||||
if (cloudDocumentTextRecognizerOptions.languageHints) {
|
||||
if (
|
||||
!isArray(cloudDocumentTextRecognizerOptions.languageHints) ||
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
isBoolean,
|
||||
isNumber,
|
||||
isObject,
|
||||
isString,
|
||||
isUndefined,
|
||||
} from '@react-native-firebase/common';
|
||||
|
||||
@@ -47,6 +48,14 @@ export default function visionCloudImageLabelerOptions(cloudImageLabelerOptions)
|
||||
out.enforceCertFingerprintMatch = cloudImageLabelerOptions.enforceCertFingerprintMatch;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(cloudImageLabelerOptions, 'apiKeyOverride')) {
|
||||
if (!isString(cloudImageLabelerOptions.apiKeyOverride)) {
|
||||
throw new Error("'cloudImageLabelerOptions.apiKeyOverride' expected a string value.");
|
||||
}
|
||||
|
||||
out.apiKeyOverride = cloudImageLabelerOptions.apiKeyOverride;
|
||||
}
|
||||
|
||||
if (cloudImageLabelerOptions.confidenceThreshold) {
|
||||
if (!isNumber(cloudImageLabelerOptions.confidenceThreshold)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
isBoolean,
|
||||
isNumber,
|
||||
isObject,
|
||||
isString,
|
||||
isUndefined,
|
||||
} from '@react-native-firebase/common';
|
||||
|
||||
@@ -50,6 +51,14 @@ export default function visionCloudLandmarkRecognizerOptions(cloudLandmarkRecogn
|
||||
out.enforceCertFingerprintMatch = cloudLandmarkRecognizerOptions.enforceCertFingerprintMatch;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(cloudLandmarkRecognizerOptions, 'apiKeyOverride')) {
|
||||
if (!isString(cloudLandmarkRecognizerOptions.apiKeyOverride)) {
|
||||
throw new Error("'cloudLandmarkRecognizerOptions.apiKeyOverride' expected a string value.");
|
||||
}
|
||||
|
||||
out.apiKeyOverride = cloudLandmarkRecognizerOptions.apiKeyOverride;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(cloudLandmarkRecognizerOptions, 'maxResults')) {
|
||||
if (!isNumber(cloudLandmarkRecognizerOptions.maxResults)) {
|
||||
throw new Error("'cloudLandmarkRecognizerOptions.maxResults' expected a number value.");
|
||||
|
||||
@@ -50,6 +50,14 @@ export default function visionCloudTextRecognizerOptions(cloudTextRecognizerOpti
|
||||
out.enforceCertFingerprintMatch = cloudTextRecognizerOptions.enforceCertFingerprintMatch;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(cloudTextRecognizerOptions, 'apiKeyOverride')) {
|
||||
if (!isString(cloudTextRecognizerOptions.apiKeyOverride)) {
|
||||
throw new Error("'cloudTextRecognizerOptions.apiKeyOverride' expected a string value.");
|
||||
}
|
||||
|
||||
out.apiKeyOverride = cloudTextRecognizerOptions.apiKeyOverride;
|
||||
}
|
||||
|
||||
if (cloudTextRecognizerOptions.modelType) {
|
||||
if (
|
||||
cloudTextRecognizerOptions.modelType !== VisionCloudTextRecognizerModelType.DENSE_MODEL &&
|
||||
|
||||
@@ -35,24 +35,24 @@ console.log(`Android AVD: ${config.configurations['android.emu.debug'].name}`);
|
||||
|
||||
const PACKAGES = [
|
||||
'app',
|
||||
'dynamic-links',
|
||||
'iid',
|
||||
'perf',
|
||||
'fiam',
|
||||
'functions',
|
||||
'analytics',
|
||||
'config',
|
||||
'crashlytics',
|
||||
'utils',
|
||||
'ml-natural-language',
|
||||
// 'dynamic-links',
|
||||
// 'iid',
|
||||
// 'perf',
|
||||
// 'fiam',
|
||||
// 'functions',
|
||||
// 'analytics',
|
||||
// 'config',
|
||||
// 'crashlytics',
|
||||
// 'utils',
|
||||
// 'ml-natural-language',
|
||||
'ml-vision',
|
||||
'fiam',
|
||||
'auth',
|
||||
'database',
|
||||
'storage',
|
||||
'indexing',
|
||||
'messaging',
|
||||
'firestore',
|
||||
// 'fiam',
|
||||
// 'auth',
|
||||
// 'database',
|
||||
// 'storage',
|
||||
// 'indexing',
|
||||
// 'messaging',
|
||||
// 'firestore',
|
||||
];
|
||||
|
||||
for (let i = 0; i < PACKAGES.length; i++) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
--timeout 260000
|
||||
--reporter spec
|
||||
--slow 2000
|
||||
--retries 3
|
||||
--retries 0
|
||||
--bail
|
||||
--exit
|
||||
--require node_modules/jet/platform/node
|
||||
|
||||
Reference in New Issue
Block a user