couchset 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection.d.ts +5 -0
- package/dist/connection.js +46 -5
- package/dist/connection.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/connection.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface CouchsetArgs {
|
|
|
4
4
|
bucketName: string;
|
|
5
5
|
username: string;
|
|
6
6
|
password: string;
|
|
7
|
+
proxy?: string;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* CouchbaseConnection class
|
|
@@ -23,6 +24,10 @@ export declare class CouchbaseConnection implements CouchsetArgs {
|
|
|
23
24
|
* start
|
|
24
25
|
*/
|
|
25
26
|
init: (args: CouchsetArgs) => Promise<CouchbaseConnection>;
|
|
27
|
+
/**
|
|
28
|
+
* start serverless start
|
|
29
|
+
*/
|
|
30
|
+
initServerless: (args: CouchsetArgs) => CouchbaseConnection;
|
|
26
31
|
/**
|
|
27
32
|
* getCollection
|
|
28
33
|
*/
|
package/dist/connection.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,12 +58,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
58
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
59
|
}
|
|
37
60
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
62
|
exports.CouchbaseConnection = void 0;
|
|
43
|
-
var
|
|
63
|
+
var couchbase = __importStar(require("couchbase"));
|
|
44
64
|
/**
|
|
45
65
|
* CouchbaseConnection class
|
|
46
66
|
* Only one CouchbaseConnection can exist that's why it's a singleton
|
|
@@ -68,7 +88,7 @@ var CouchbaseConnection = /** @class */ (function () {
|
|
|
68
88
|
this.bucketName = bucketName;
|
|
69
89
|
this.username = username;
|
|
70
90
|
this.password = password;
|
|
71
|
-
return [4 /*yield*/,
|
|
91
|
+
return [4 /*yield*/, couchbase.connect(connectionString, {
|
|
72
92
|
username: username,
|
|
73
93
|
password: password,
|
|
74
94
|
})];
|
|
@@ -80,6 +100,27 @@ var CouchbaseConnection = /** @class */ (function () {
|
|
|
80
100
|
}
|
|
81
101
|
});
|
|
82
102
|
}); };
|
|
103
|
+
/**
|
|
104
|
+
* start serverless start
|
|
105
|
+
*/
|
|
106
|
+
this.initServerless = function (args) {
|
|
107
|
+
var connectionString = args.connectionString, password = args.password, username = args.username, _a = args.bucketName, bucketName = _a === void 0 ? 'default' : _a;
|
|
108
|
+
_this.connectionString = connectionString;
|
|
109
|
+
_this.bucketName = bucketName;
|
|
110
|
+
_this.username = username;
|
|
111
|
+
_this.password = password;
|
|
112
|
+
var connectionOpt = {
|
|
113
|
+
username: username,
|
|
114
|
+
password: password,
|
|
115
|
+
};
|
|
116
|
+
if (args.proxy) {
|
|
117
|
+
connectionOpt['proxy'] = args.proxy;
|
|
118
|
+
}
|
|
119
|
+
var cluster = new couchbase.Cluster(connectionString, connectionOpt);
|
|
120
|
+
_this.cluster = cluster;
|
|
121
|
+
_this.bucket = _this.cluster.bucket(bucketName);
|
|
122
|
+
return _this;
|
|
123
|
+
};
|
|
83
124
|
/**
|
|
84
125
|
* getCollection
|
|
85
126
|
*/
|
package/dist/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAuC;AAUvC;;;GAGG;AACH;IAgBI;QAAA,iBAAwB;QAbxB,WAAM,GAAW,IAAI,CAAC;QACtB,YAAO,GAAY,IAAI,CAAC;QAExB,OAAO;QACP,qBAAgB,GAAW,IAAI,CAAC;QAChC,eAAU,GAAW,IAAI,CAAC;QAC1B,aAAQ,GAAW,IAAI,CAAC;QACxB,aAAQ,GAAW,IAAI,CAAC;QAQxB;;WAEG;QACI,S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C,GAAG,IAAI,CAAC,KAAK,CAAC;YACxC,CAAC;YAED,IAAM,OAAO,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;YAEvE,KAAI,CAAC,OAAO,GAAG,OAAc,CAAC;YAC9B,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAE9C,OAAO,KAAI,CAAC;QAChB,CAAC,CAAC;QAEF;;WAEG;QACI,kBAAa,GAAG;YACnB,OAAO,KAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC3C,CAAC,CAAC;QAEK,eAAU,GAAG;YAChB,OAAO,KAAI,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC;QAEK,cAAS,GAAG;YACf,OAAO,KAAI,CAAC,UAAU,CAAC;QAC3B,CAAC,CAAC;QAEF;;WAEG;QACI,aAAQ,GAAG;;gBACd,sBAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAC;;aAC/B,CAAC;IAxEqB,CAAC;IAJxB,sBAAkB,+BAAQ;aAA1B;YACI,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;;;OAAA;IA2EL,0BAAC;AAAD,CAAC,AAzFD,IAyFC;AAzFY,kDAAmB;AA2FhC,kBAAe,mBAAmB,CAAC","sourcesContent":["import type {Collection, Cluster, Bucket} from 'couchbase';\nimport * as couchbase from 'couchbase';\n\nexport interface CouchsetArgs {\n connectionString: string;\n bucketName: string;\n username: string;\n password: string;\n proxy?: string;\n}\n\n/**\n * CouchbaseConnection class\n * Only one CouchbaseConnection can exist that's why it's a singleton\n */\nexport class CouchbaseConnection implements CouchsetArgs {\n private static _instance: CouchbaseConnection;\n\n bucket: Bucket = null;\n cluster: Cluster = null;\n\n // Args\n connectionString: string = null;\n bucketName: string = null;\n username: string = null;\n password: string = null;\n\n public static get Instance(): CouchbaseConnection {\n return this._instance || (this._instance = new this());\n }\n\n private constructor() {}\n\n /**\n * start\n */\n public init = async (args: CouchsetArgs): Promise<CouchbaseConnection> => {\n const {connectionString, password, username, bucketName = 'default'} = args;\n\n this.connectionString = connectionString;\n this.bucketName = bucketName;\n this.username = username;\n this.password = password;\n\n const cluster = await couchbase.connect(connectionString, {\n username,\n password,\n });\n\n this.cluster = cluster as any;\n this.bucket = this.cluster.bucket(bucketName);\n\n return this;\n };\n\n /**\n * start serverless start\n */\n public initServerless = (args: CouchsetArgs): CouchbaseConnection => {\n const {connectionString, password, username, bucketName = 'default'} = args;\n\n this.connectionString = connectionString;\n this.bucketName = bucketName;\n this.username = username;\n this.password = password;\n\n const connectionOpt = {\n username,\n password,\n };\n\n if (args.proxy) {\n connectionOpt['proxy'] = args.proxy;\n }\n\n const cluster = new couchbase.Cluster(connectionString, connectionOpt);\n\n this.cluster = cluster as any;\n this.bucket = this.cluster.bucket(bucketName);\n\n return this;\n };\n\n /**\n * getCollection\n */\n public getCollection = (): Collection => {\n return this.bucket.defaultCollection();\n };\n\n public getCluster = (): Cluster => {\n return this.cluster;\n };\n\n public getBucket = (): string => {\n return this.bucketName;\n };\n\n /**\n * shutdown cluster\n */\n public shutdown = async (): Promise<void> => {\n return this.cluster.close();\n };\n}\n\nexport default CouchbaseConnection;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,9 @@ export * from './shared';
|
|
|
10
10
|
* @param @interface CouchsetArgs
|
|
11
11
|
*/
|
|
12
12
|
export declare const couchset: (args: CouchsetArgs) => Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Main function to start CouchSet
|
|
15
|
+
* @param @interface CouchsetArgs
|
|
16
|
+
*/
|
|
17
|
+
export declare const couchsetServerless: (args: CouchsetArgs) => Promise<boolean>;
|
|
13
18
|
export default couchset;
|
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
53
53
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
54
|
};
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
-
exports.couchset = void 0;
|
|
56
|
+
exports.couchsetServerless = exports.couchset = void 0;
|
|
57
57
|
var connection_1 = __importDefault(require("./connection"));
|
|
58
58
|
__exportStar(require("./model"), exports);
|
|
59
59
|
__exportStar(require("./connection"), exports);
|
|
@@ -79,5 +79,15 @@ var couchset = function (args) { return __awaiter(void 0, void 0, void 0, functi
|
|
|
79
79
|
});
|
|
80
80
|
}); };
|
|
81
81
|
exports.couchset = couchset;
|
|
82
|
+
/**
|
|
83
|
+
* Main function to start CouchSet
|
|
84
|
+
* @param @interface CouchsetArgs
|
|
85
|
+
*/
|
|
86
|
+
var couchsetServerless = function (args) {
|
|
87
|
+
var couch = connection_1.default.Instance;
|
|
88
|
+
couch.initServerless(args);
|
|
89
|
+
return Promise.resolve(true);
|
|
90
|
+
};
|
|
91
|
+
exports.couchsetServerless = couchsetServerless;
|
|
82
92
|
exports.default = exports.couchset;
|
|
83
93
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+D;AAE/D,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AAEzB;;;GAGG;AACI,IAAM,QAAQ,GAAG,UAAO,IAAkB;;;;;gBACvC,KAAK,GAAG,oBAAmB,CAAC,QAAQ,CAAC;gBAC3C,qBAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;gBAAtB,SAAsB,CAAC;gBACvB,sBAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAC;;;KAChC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEF,kBAAe,gBAAQ,CAAC","sourcesContent":["import CouchbaseConnection, {CouchsetArgs} from './connection';\n\nexport * from './model';\nexport * from './connection';\nexport * from './query';\nexport * from './search';\nexport * from './pagination';\nexport * from './shared';\n\n/**\n * Main function to start CouchSet\n * @param @interface CouchsetArgs\n */\nexport const couchset = async (args: CouchsetArgs): Promise<boolean> => {\n const couch = CouchbaseConnection.Instance;\n await couch.init(args);\n return Promise.resolve(true);\n};\n\nexport default couchset;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+D;AAE/D,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AAEzB;;;GAGG;AACI,IAAM,QAAQ,GAAG,UAAO,IAAkB;;;;;gBACvC,KAAK,GAAG,oBAAmB,CAAC,QAAQ,CAAC;gBAC3C,qBAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;gBAAtB,SAAsB,CAAC;gBACvB,sBAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAC;;;KAChC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEF;;;GAGG;AACI,IAAM,kBAAkB,GAAG,UAAC,IAAkB;IACjD,IAAM,KAAK,GAAG,oBAAmB,CAAC,QAAQ,CAAC;IAC3C,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEF,kBAAe,gBAAQ,CAAC","sourcesContent":["import CouchbaseConnection, {CouchsetArgs} from './connection';\n\nexport * from './model';\nexport * from './connection';\nexport * from './query';\nexport * from './search';\nexport * from './pagination';\nexport * from './shared';\n\n/**\n * Main function to start CouchSet\n * @param @interface CouchsetArgs\n */\nexport const couchset = async (args: CouchsetArgs): Promise<boolean> => {\n const couch = CouchbaseConnection.Instance;\n await couch.init(args);\n return Promise.resolve(true);\n};\n\n/**\n * Main function to start CouchSet\n * @param @interface CouchsetArgs\n */\nexport const couchsetServerless = (args: CouchsetArgs): Promise<boolean> => {\n const couch = CouchbaseConnection.Instance;\n couch.initServerless(args);\n return Promise.resolve(true);\n};\n\nexport default couchset;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "couchset",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Couchbase ORM",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json",
|
|
16
16
|
"build": "rimraf dist && ./node_modules/.bin/tsc --skipLibCheck",
|
|
17
17
|
"test": "mocha src/index.test.ts --exit",
|
|
18
|
+
"test:serverless": "mocha src/index.serverless.test.ts --exit",
|
|
18
19
|
"test:auto": "mocha src/automation.test.ts --exit",
|
|
19
20
|
"prepublishOnly": "npm run build",
|
|
20
21
|
"eslint": "eslint ./src --fix --ext=ts"
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@types/chai": "^4.2.14",
|
|
62
63
|
"@types/couchbase": "^2.4.9",
|
|
63
64
|
"@types/debug": "^4.1.7",
|
|
65
|
+
"@types/dotenv": "^6.1.1",
|
|
64
66
|
"@types/express": "^4.17.13",
|
|
65
67
|
"@types/lodash": "^4.17.10",
|
|
66
68
|
"@types/mocha": "^8.2.0",
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
|
71
73
|
"@typescript-eslint/parser": "^3.4.0",
|
|
72
74
|
"chai": "^4.2.0",
|
|
75
|
+
"dotenv": "^16.4.5",
|
|
73
76
|
"eslint": "7.32.0",
|
|
74
77
|
"eslint-config-prettier": "^6.11.0",
|
|
75
78
|
"eslint-loader": "^4.0.2",
|
|
@@ -92,7 +95,7 @@
|
|
|
92
95
|
},
|
|
93
96
|
"dependencies": {
|
|
94
97
|
"couchbase": "^4.4.2",
|
|
95
|
-
"couchbase-serverless": "^0.0.
|
|
98
|
+
"couchbase-serverless": "^0.0.4",
|
|
96
99
|
"debug": "^4.3.1",
|
|
97
100
|
"lodash": "^4.17.21",
|
|
98
101
|
"uuid": "^8.3.2"
|