couchbase 3.2.2 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/binding.gyp +5 -0
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +84 -17
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/minimal/query.c +9 -7
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
- package/deps/lcb/include/libcouchbase/error.h +6 -1
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +353 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
- package/deps/lcb/src/capi/cmd_counter.hh +18 -0
- package/deps/lcb/src/capi/cmd_exists.hh +18 -0
- package/deps/lcb/src/capi/cmd_get.hh +17 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
- package/deps/lcb/src/capi/cmd_query.cc +13 -0
- package/deps/lcb/src/capi/cmd_query.hh +22 -14
- package/deps/lcb/src/capi/cmd_remove.hh +18 -0
- package/deps/lcb/src/capi/cmd_search.hh +6 -0
- package/deps/lcb/src/capi/cmd_store.hh +28 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
- package/deps/lcb/src/capi/cmd_touch.hh +18 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
- package/deps/lcb/src/cntl.cc +42 -8
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/internal.h +2 -1
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/mcserver/mcserver.cc +8 -5
- package/deps/lcb/src/mcserver/negotiate.cc +42 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/n1ql.cc +5 -1
- package/deps/lcb/src/n1ql/query_handle.cc +80 -44
- package/deps/lcb/src/n1ql/query_handle.hh +41 -3
- package/deps/lcb/src/operations/counter.cc +13 -1
- package/deps/lcb/src/operations/exists.cc +14 -2
- package/deps/lcb/src/operations/get.cc +14 -2
- package/deps/lcb/src/operations/get_replica.cc +18 -6
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/remove.cc +13 -1
- package/deps/lcb/src/operations/store.cc +13 -1
- package/deps/lcb/src/operations/subdoc.cc +13 -2
- package/deps/lcb/src/operations/touch.cc +14 -2
- package/deps/lcb/src/operations/unlock.cc +14 -2
- package/deps/lcb/src/search/search_handle.cc +26 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/ssl/ssl_common.c +7 -8
- package/deps/lcb/src/tracing/span.cc +43 -10
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +21 -0
- package/deps/lcb/src/utilities.h +3 -0
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -1
- package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
- package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
- package/deps/lcb/tests/iotests/serverparams.h +7 -2
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +14 -4
- package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
- package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +342 -0
- package/deps/lcb/tests/iotests/testutil.h +164 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsexecutor.js +2 -2
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +2 -0
- package/dist/binding.js +1 -1
- package/dist/bindingutilities.js +9 -1
- package/dist/bucketmanager.d.ts +32 -23
- package/dist/bucketmanager.js +197 -189
- package/dist/cluster.js +37 -36
- package/dist/collection.js +17 -23
- package/dist/collectionmanager.js +181 -200
- package/dist/connection.js +6 -3
- package/dist/connspec.js +5 -1
- package/dist/couchbase.js +7 -14
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +26 -2
- package/dist/eventingfunctionmanager.js +267 -294
- package/dist/httpexecutor.js +31 -38
- package/dist/logging.js +1 -1
- package/dist/queryexecutor.js +3 -3
- package/dist/queryindexmanager.js +236 -263
- package/dist/scope.js +8 -2
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +250 -263
- package/dist/utilities.d.ts +3 -2
- package/dist/utilities.js +16 -4
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/connection.cpp +2 -0
- package/src/constants.cpp +2 -0
- package/src/instance.cpp +8 -1
- package/src/instance.h +1 -0
- package/src/uv-plugin-all.cpp +1 -0
- package/dist/cas.d.ts +0 -0
- package/dist/cas.js +0 -1
@@ -1,13 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.EventingFunctionManager = exports.EventingState = exports.EventingFunctionState = exports.EventingFunction = exports.EventingFunctionSettings = exports.EventingFunctionConstantBinding = exports.EventingFunctionUrlBinding = exports.EventingFunctionUrlAuthBearer = exports.EventingFunctionUrlAuthDigest = exports.EventingFunctionUrlAuthBasic = exports.EventingFunctionBucketBinding = exports.EventingFunctionKeyspace = exports.EventingFunctionUrlAuthMethod = exports.EventingFunctionBucketAccess = exports.EventingFunctionLogLevel = exports.EventingFunctionLanguageCompatibility = exports.EventingFunctionStatus = exports.EventingFunctionProcessingStatus = exports.EventingFunctionDeploymentStatus = exports.EventingFunctionDcpBoundary = void 0;
|
13
4
|
const errors_1 = require("./errors");
|
@@ -659,45 +650,43 @@ class EventingFunctionManager {
|
|
659
650
|
* @param options Optional parameters for this operation.
|
660
651
|
* @param callback A node-style callback to be invoked after execution.
|
661
652
|
*/
|
662
|
-
upsertFunction(functionDefinition, options, callback) {
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
throw new errors_1.CollectionNotFoundError(undefined, errCtx);
|
690
|
-
}
|
691
|
-
if (errText.includes('err_src_mb_same')) {
|
692
|
-
throw new errors_1.EventingFunctionIdenticalKeyspaceError(undefined, errCtx);
|
693
|
-
}
|
694
|
-
if (errText.includes('err_handler_compilation')) {
|
695
|
-
throw new errors_1.EventingFunctionCompilationFailureError(undefined, errCtx);
|
696
|
-
}
|
697
|
-
throw new errors_1.CouchbaseError('failed to upsert function', undefined, errCtx);
|
653
|
+
async upsertFunction(functionDefinition, options, callback) {
|
654
|
+
if (options instanceof Function) {
|
655
|
+
callback = arguments[1];
|
656
|
+
options = undefined;
|
657
|
+
}
|
658
|
+
if (!options) {
|
659
|
+
options = {};
|
660
|
+
}
|
661
|
+
const functionName = functionDefinition.name;
|
662
|
+
const parentSpan = options.parentSpan;
|
663
|
+
const timeout = options.timeout;
|
664
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
665
|
+
const encodedData = EventingFunction._toEvtData(functionDefinition);
|
666
|
+
const res = await this._http.request({
|
667
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
668
|
+
method: httpexecutor_1.HttpMethod.Post,
|
669
|
+
path: `/api/v1/functions/${functionName}`,
|
670
|
+
contentType: 'application/json',
|
671
|
+
body: JSON.stringify(encodedData),
|
672
|
+
parentSpan: parentSpan,
|
673
|
+
timeout: timeout,
|
674
|
+
});
|
675
|
+
if (res.statusCode !== 200) {
|
676
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
677
|
+
const errText = res.body.toString().toLowerCase();
|
678
|
+
if (errText.includes('err_collection_missing')) {
|
679
|
+
throw new errors_1.CollectionNotFoundError(undefined, errCtx);
|
698
680
|
}
|
699
|
-
|
700
|
-
|
681
|
+
if (errText.includes('err_src_mb_same')) {
|
682
|
+
throw new errors_1.EventingFunctionIdenticalKeyspaceError(undefined, errCtx);
|
683
|
+
}
|
684
|
+
if (errText.includes('err_handler_compilation')) {
|
685
|
+
throw new errors_1.EventingFunctionCompilationFailureError(undefined, errCtx);
|
686
|
+
}
|
687
|
+
throw new errors_1.CouchbaseError('failed to upsert function', undefined, errCtx);
|
688
|
+
}
|
689
|
+
}, callback);
|
701
690
|
}
|
702
691
|
/**
|
703
692
|
* Deletes an eventing function.
|
@@ -706,42 +695,40 @@ class EventingFunctionManager {
|
|
706
695
|
* @param options Optional parameters for this operation.
|
707
696
|
* @param callback A node-style callback to be invoked after execution.
|
708
697
|
*/
|
709
|
-
dropFunction(name, options, callback) {
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
734
|
-
}
|
735
|
-
if (errText.includes('err_app_not_deployed')) {
|
736
|
-
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
737
|
-
}
|
738
|
-
if (errText.includes('err_app_not_undeployed')) {
|
739
|
-
throw new errors_1.EventingFunctionDeployedError(undefined, errCtx);
|
740
|
-
}
|
741
|
-
throw new errors_1.CouchbaseError('failed to drop function', undefined, errCtx);
|
698
|
+
async dropFunction(name, options, callback) {
|
699
|
+
if (options instanceof Function) {
|
700
|
+
callback = arguments[1];
|
701
|
+
options = undefined;
|
702
|
+
}
|
703
|
+
if (!options) {
|
704
|
+
options = {};
|
705
|
+
}
|
706
|
+
const functionName = name;
|
707
|
+
const parentSpan = options.parentSpan;
|
708
|
+
const timeout = options.timeout;
|
709
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
710
|
+
const res = await this._http.request({
|
711
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
712
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
713
|
+
path: `/api/v1/functions/${functionName}`,
|
714
|
+
parentSpan: parentSpan,
|
715
|
+
timeout: timeout,
|
716
|
+
});
|
717
|
+
if (res.statusCode !== 200) {
|
718
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
719
|
+
const errText = res.body.toString().toLowerCase();
|
720
|
+
if (errText.includes('err_app_not_found_ts')) {
|
721
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
742
722
|
}
|
743
|
-
|
744
|
-
|
723
|
+
if (errText.includes('err_app_not_deployed')) {
|
724
|
+
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
725
|
+
}
|
726
|
+
if (errText.includes('err_app_not_undeployed')) {
|
727
|
+
throw new errors_1.EventingFunctionDeployedError(undefined, errCtx);
|
728
|
+
}
|
729
|
+
throw new errors_1.CouchbaseError('failed to drop function', undefined, errCtx);
|
730
|
+
}
|
731
|
+
}, callback);
|
745
732
|
}
|
746
733
|
/**
|
747
734
|
* Fetches all eventing functions.
|
@@ -749,34 +736,32 @@ class EventingFunctionManager {
|
|
749
736
|
* @param options Optional parameters for this operation.
|
750
737
|
* @param callback A node-style callback to be invoked after execution.
|
751
738
|
*/
|
752
|
-
getAllFunctions(options, callback) {
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
739
|
+
async getAllFunctions(options, callback) {
|
740
|
+
if (options instanceof Function) {
|
741
|
+
callback = arguments[0];
|
742
|
+
options = undefined;
|
743
|
+
}
|
744
|
+
if (!options) {
|
745
|
+
options = {};
|
746
|
+
}
|
747
|
+
const parentSpan = options.parentSpan;
|
748
|
+
const timeout = options.timeout;
|
749
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
750
|
+
const res = await this._http.request({
|
751
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
752
|
+
method: httpexecutor_1.HttpMethod.Get,
|
753
|
+
path: `/api/v1/functions`,
|
754
|
+
parentSpan: parentSpan,
|
755
|
+
timeout: timeout,
|
756
|
+
});
|
757
|
+
if (res.statusCode !== 200) {
|
758
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
759
|
+
throw new errors_1.CouchbaseError('failed to get functions', undefined, errCtx);
|
760
760
|
}
|
761
|
-
const
|
762
|
-
const
|
763
|
-
return
|
764
|
-
|
765
|
-
type: httpexecutor_1.HttpServiceType.Eventing,
|
766
|
-
method: httpexecutor_1.HttpMethod.Get,
|
767
|
-
path: `/api/v1/functions`,
|
768
|
-
parentSpan: parentSpan,
|
769
|
-
timeout: timeout,
|
770
|
-
});
|
771
|
-
if (res.statusCode !== 200) {
|
772
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
773
|
-
throw new errors_1.CouchbaseError('failed to get functions', undefined, errCtx);
|
774
|
-
}
|
775
|
-
const functionsData = JSON.parse(res.body.toString());
|
776
|
-
const functions = functionsData.map((functionData) => EventingFunction._fromEvtData(functionData));
|
777
|
-
return functions;
|
778
|
-
}), callback);
|
779
|
-
});
|
761
|
+
const functionsData = JSON.parse(res.body.toString());
|
762
|
+
const functions = functionsData.map((functionData) => EventingFunction._fromEvtData(functionData));
|
763
|
+
return functions;
|
764
|
+
}, callback);
|
780
765
|
}
|
781
766
|
/**
|
782
767
|
* Fetches a specific eventing function.
|
@@ -785,38 +770,36 @@ class EventingFunctionManager {
|
|
785
770
|
* @param options Optional parameters for this operation.
|
786
771
|
* @param callback A node-style callback to be invoked after execution.
|
787
772
|
*/
|
788
|
-
getFunction(name, options, callback) {
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
813
|
-
}
|
814
|
-
throw new errors_1.CouchbaseError('failed to get function', undefined, errCtx);
|
773
|
+
async getFunction(name, options, callback) {
|
774
|
+
if (options instanceof Function) {
|
775
|
+
callback = arguments[1];
|
776
|
+
options = undefined;
|
777
|
+
}
|
778
|
+
if (!options) {
|
779
|
+
options = {};
|
780
|
+
}
|
781
|
+
const functionName = name;
|
782
|
+
const parentSpan = options.parentSpan;
|
783
|
+
const timeout = options.timeout;
|
784
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
785
|
+
const res = await this._http.request({
|
786
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
787
|
+
method: httpexecutor_1.HttpMethod.Get,
|
788
|
+
path: `/api/v1/functions/${functionName}`,
|
789
|
+
parentSpan: parentSpan,
|
790
|
+
timeout: timeout,
|
791
|
+
});
|
792
|
+
if (res.statusCode !== 200) {
|
793
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
794
|
+
const errText = res.body.toString().toLowerCase();
|
795
|
+
if (errText.includes('err_app_not_found_ts')) {
|
796
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
815
797
|
}
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
798
|
+
throw new errors_1.CouchbaseError('failed to get function', undefined, errCtx);
|
799
|
+
}
|
800
|
+
const functionData = JSON.parse(res.body.toString());
|
801
|
+
return EventingFunction._fromEvtData(functionData);
|
802
|
+
}, callback);
|
820
803
|
}
|
821
804
|
/**
|
822
805
|
* Deploys an eventing function.
|
@@ -825,39 +808,37 @@ class EventingFunctionManager {
|
|
825
808
|
* @param options Optional parameters for this operation.
|
826
809
|
* @param callback A node-style callback to be invoked after execution.
|
827
810
|
*/
|
828
|
-
deployFunction(name, options, callback) {
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
853
|
-
}
|
854
|
-
if (errText.includes('err_app_not_bootstrapped')) {
|
855
|
-
throw new errors_1.EventingFunctionNotBootstrappedError(undefined, errCtx);
|
856
|
-
}
|
857
|
-
throw new errors_1.CouchbaseError('failed to deploy function', undefined, errCtx);
|
811
|
+
async deployFunction(name, options, callback) {
|
812
|
+
if (options instanceof Function) {
|
813
|
+
callback = arguments[1];
|
814
|
+
options = undefined;
|
815
|
+
}
|
816
|
+
if (!options) {
|
817
|
+
options = {};
|
818
|
+
}
|
819
|
+
const functionName = name;
|
820
|
+
const parentSpan = options.parentSpan;
|
821
|
+
const timeout = options.timeout;
|
822
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
823
|
+
const res = await this._http.request({
|
824
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
825
|
+
method: httpexecutor_1.HttpMethod.Post,
|
826
|
+
path: `/api/v1/functions/${functionName}/deploy`,
|
827
|
+
parentSpan: parentSpan,
|
828
|
+
timeout: timeout,
|
829
|
+
});
|
830
|
+
if (res.statusCode !== 200) {
|
831
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
832
|
+
const errText = res.body.toString().toLowerCase();
|
833
|
+
if (errText.includes('err_app_not_found_ts')) {
|
834
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
858
835
|
}
|
859
|
-
|
860
|
-
|
836
|
+
if (errText.includes('err_app_not_bootstrapped')) {
|
837
|
+
throw new errors_1.EventingFunctionNotBootstrappedError(undefined, errCtx);
|
838
|
+
}
|
839
|
+
throw new errors_1.CouchbaseError('failed to deploy function', undefined, errCtx);
|
840
|
+
}
|
841
|
+
}, callback);
|
861
842
|
}
|
862
843
|
/**
|
863
844
|
* Undeploys an eventing function.
|
@@ -866,39 +847,37 @@ class EventingFunctionManager {
|
|
866
847
|
* @param options Optional parameters for this operation.
|
867
848
|
* @param callback A node-style callback to be invoked after execution.
|
868
849
|
*/
|
869
|
-
undeployFunction(name, options, callback) {
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
894
|
-
}
|
895
|
-
if (errText.includes('err_app_not_deployed')) {
|
896
|
-
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
897
|
-
}
|
898
|
-
throw new errors_1.CouchbaseError('failed to undeploy function', undefined, errCtx);
|
850
|
+
async undeployFunction(name, options, callback) {
|
851
|
+
if (options instanceof Function) {
|
852
|
+
callback = arguments[1];
|
853
|
+
options = undefined;
|
854
|
+
}
|
855
|
+
if (!options) {
|
856
|
+
options = {};
|
857
|
+
}
|
858
|
+
const functionName = name;
|
859
|
+
const parentSpan = options.parentSpan;
|
860
|
+
const timeout = options.timeout;
|
861
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
862
|
+
const res = await this._http.request({
|
863
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
864
|
+
method: httpexecutor_1.HttpMethod.Post,
|
865
|
+
path: `/api/v1/functions/${functionName}/undeploy`,
|
866
|
+
parentSpan: parentSpan,
|
867
|
+
timeout: timeout,
|
868
|
+
});
|
869
|
+
if (res.statusCode !== 200) {
|
870
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
871
|
+
const errText = res.body.toString().toLowerCase();
|
872
|
+
if (errText.includes('err_app_not_found_ts')) {
|
873
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
899
874
|
}
|
900
|
-
|
901
|
-
|
875
|
+
if (errText.includes('err_app_not_deployed')) {
|
876
|
+
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
877
|
+
}
|
878
|
+
throw new errors_1.CouchbaseError('failed to undeploy function', undefined, errCtx);
|
879
|
+
}
|
880
|
+
}, callback);
|
902
881
|
}
|
903
882
|
/**
|
904
883
|
* Pauses an eventing function.
|
@@ -907,39 +886,37 @@ class EventingFunctionManager {
|
|
907
886
|
* @param options Optional parameters for this operation.
|
908
887
|
* @param callback A node-style callback to be invoked after execution.
|
909
888
|
*/
|
910
|
-
pauseFunction(name, options, callback) {
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
935
|
-
}
|
936
|
-
if (errText.includes('err_app_not_bootstrapped')) {
|
937
|
-
throw new errors_1.EventingFunctionNotBootstrappedError(undefined, errCtx);
|
938
|
-
}
|
939
|
-
throw new errors_1.CouchbaseError('failed to pause function', undefined, errCtx);
|
889
|
+
async pauseFunction(name, options, callback) {
|
890
|
+
if (options instanceof Function) {
|
891
|
+
callback = arguments[1];
|
892
|
+
options = undefined;
|
893
|
+
}
|
894
|
+
if (!options) {
|
895
|
+
options = {};
|
896
|
+
}
|
897
|
+
const functionName = name;
|
898
|
+
const parentSpan = options.parentSpan;
|
899
|
+
const timeout = options.timeout;
|
900
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
901
|
+
const res = await this._http.request({
|
902
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
903
|
+
method: httpexecutor_1.HttpMethod.Post,
|
904
|
+
path: `/api/v1/functions/${functionName}/pause`,
|
905
|
+
parentSpan: parentSpan,
|
906
|
+
timeout: timeout,
|
907
|
+
});
|
908
|
+
if (res.statusCode !== 200) {
|
909
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
910
|
+
const errText = res.body.toString().toLowerCase();
|
911
|
+
if (errText.includes('err_app_not_found_ts')) {
|
912
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
940
913
|
}
|
941
|
-
|
942
|
-
|
914
|
+
if (errText.includes('err_app_not_bootstrapped')) {
|
915
|
+
throw new errors_1.EventingFunctionNotBootstrappedError(undefined, errCtx);
|
916
|
+
}
|
917
|
+
throw new errors_1.CouchbaseError('failed to pause function', undefined, errCtx);
|
918
|
+
}
|
919
|
+
}, callback);
|
943
920
|
}
|
944
921
|
/**
|
945
922
|
* Resumes an eventing function.
|
@@ -948,39 +925,37 @@ class EventingFunctionManager {
|
|
948
925
|
* @param options Optional parameters for this operation.
|
949
926
|
* @param callback A node-style callback to be invoked after execution.
|
950
927
|
*/
|
951
|
-
resumeFunction(name, options, callback) {
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
976
|
-
}
|
977
|
-
if (errText.includes('err_app_not_deployed')) {
|
978
|
-
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
979
|
-
}
|
980
|
-
throw new errors_1.CouchbaseError('failed to resume function', undefined, errCtx);
|
928
|
+
async resumeFunction(name, options, callback) {
|
929
|
+
if (options instanceof Function) {
|
930
|
+
callback = arguments[1];
|
931
|
+
options = undefined;
|
932
|
+
}
|
933
|
+
if (!options) {
|
934
|
+
options = {};
|
935
|
+
}
|
936
|
+
const functionName = name;
|
937
|
+
const parentSpan = options.parentSpan;
|
938
|
+
const timeout = options.timeout;
|
939
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
940
|
+
const res = await this._http.request({
|
941
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
942
|
+
method: httpexecutor_1.HttpMethod.Post,
|
943
|
+
path: `/api/v1/functions/${functionName}/resume`,
|
944
|
+
parentSpan: parentSpan,
|
945
|
+
timeout: timeout,
|
946
|
+
});
|
947
|
+
if (res.statusCode !== 200) {
|
948
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
949
|
+
const errText = res.body.toString().toLowerCase();
|
950
|
+
if (errText.includes('err_app_not_found_ts')) {
|
951
|
+
throw new errors_1.EventingFunctionNotFoundError(undefined, errCtx);
|
981
952
|
}
|
982
|
-
|
983
|
-
|
953
|
+
if (errText.includes('err_app_not_deployed')) {
|
954
|
+
throw new errors_1.EventingFunctionNotDeployedError(undefined, errCtx);
|
955
|
+
}
|
956
|
+
throw new errors_1.CouchbaseError('failed to resume function', undefined, errCtx);
|
957
|
+
}
|
958
|
+
}, callback);
|
984
959
|
}
|
985
960
|
/**
|
986
961
|
* Fetches the status of all eventing functions.
|
@@ -988,33 +963,31 @@ class EventingFunctionManager {
|
|
988
963
|
* @param options Optional parameters for this operation.
|
989
964
|
* @param callback A node-style callback to be invoked after execution.
|
990
965
|
*/
|
991
|
-
functionsStatus(options, callback) {
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
966
|
+
async functionsStatus(options, callback) {
|
967
|
+
if (options instanceof Function) {
|
968
|
+
callback = arguments[0];
|
969
|
+
options = undefined;
|
970
|
+
}
|
971
|
+
if (!options) {
|
972
|
+
options = {};
|
973
|
+
}
|
974
|
+
const parentSpan = options.parentSpan;
|
975
|
+
const timeout = options.timeout;
|
976
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
977
|
+
const res = await this._http.request({
|
978
|
+
type: httpexecutor_1.HttpServiceType.Eventing,
|
979
|
+
method: httpexecutor_1.HttpMethod.Get,
|
980
|
+
path: `/api/v1/status`,
|
981
|
+
parentSpan: parentSpan,
|
982
|
+
timeout: timeout,
|
983
|
+
});
|
984
|
+
if (res.statusCode !== 200) {
|
985
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
986
|
+
throw new errors_1.CouchbaseError('failed to fetch functions status', undefined, errCtx);
|
999
987
|
}
|
1000
|
-
const
|
1001
|
-
|
1002
|
-
|
1003
|
-
const res = yield this._http.request({
|
1004
|
-
type: httpexecutor_1.HttpServiceType.Eventing,
|
1005
|
-
method: httpexecutor_1.HttpMethod.Get,
|
1006
|
-
path: `/api/v1/status`,
|
1007
|
-
parentSpan: parentSpan,
|
1008
|
-
timeout: timeout,
|
1009
|
-
});
|
1010
|
-
if (res.statusCode !== 200) {
|
1011
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
1012
|
-
throw new errors_1.CouchbaseError('failed to fetch functions status', undefined, errCtx);
|
1013
|
-
}
|
1014
|
-
const statusData = JSON.parse(res.body.toString());
|
1015
|
-
return EventingState._fromEvtData(statusData);
|
1016
|
-
}), callback);
|
1017
|
-
});
|
988
|
+
const statusData = JSON.parse(res.body.toString());
|
989
|
+
return EventingState._fromEvtData(statusData);
|
990
|
+
}, callback);
|
1018
991
|
}
|
1019
992
|
}
|
1020
993
|
exports.EventingFunctionManager = EventingFunctionManager;
|