couchset 0.0.17 → 0.2.0
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/config/index.d.ts +0 -1
- package/dist/config/index.js +1 -3
- package/dist/config/index.js.map +1 -1
- package/dist/connection.d.ts +1 -1
- package/dist/connection.js +6 -27
- package/dist/connection.js.map +1 -1
- package/dist/couchbase.d.ts +2 -0
- package/dist/couchbase.js +13 -0
- package/dist/couchbase.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/model/index.d.ts +1 -8
- package/dist/model/index.js +2 -11
- package/dist/model/index.js.map +1 -1
- package/dist/pagination/pagination.js +1 -1
- package/dist/query/interface/query.types.d.ts +22 -22
- package/dist/query/query.cluster.d.ts +1 -1
- package/dist/query/query.cluster.js +1 -1
- package/dist/query/query.cluster.js.map +1 -1
- package/dist/search/customQuery.js +1 -1
- package/dist/shared/common.model.d.ts +0 -28
- package/dist/shared/common.model.js +5 -86
- package/dist/shared/common.model.js.map +1 -1
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/index.js +0 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/utils/edge.d.ts +1 -0
- package/dist/utils/edge.js +16 -0
- package/dist/utils/edge.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lodash.d.ts +1 -0
- package/dist/utils/lodash.js +20 -0
- package/dist/utils/lodash.js.map +1 -0
- package/dist/utils/log.js +1 -2
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/text.utils.d.ts +0 -6
- package/dist/utils/text.utils.js +1 -12
- package/dist/utils/text.utils.js.map +1 -1
- package/dist/utils/utils.schema.d.ts +1 -1
- package/package.json +5 -13
- package/dist/automate/index.d.ts +0 -4
- package/dist/automate/index.js +0 -21
- package/dist/automate/index.js.map +0 -1
- package/dist/automate/middlewares/blankMiddleware.d.ts +0 -8
- package/dist/automate/middlewares/blankMiddleware.js +0 -16
- package/dist/automate/middlewares/blankMiddleware.js.map +0 -1
- package/dist/automate/middlewares/index.d.ts +0 -2
- package/dist/automate/middlewares/index.js +0 -19
- package/dist/automate/middlewares/index.js.map +0 -1
- package/dist/automate/middlewares/isAuth.d.ts +0 -8
- package/dist/automate/middlewares/isAuth.js +0 -29
- package/dist/automate/middlewares/isAuth.js.map +0 -1
- package/dist/automate/model/client.d.ts +0 -12
- package/dist/automate/model/client.js +0 -33
- package/dist/automate/model/client.js.map +0 -1
- package/dist/automate/model/index.d.ts +0 -47
- package/dist/automate/model/index.js +0 -341
- package/dist/automate/model/index.js.map +0 -1
- package/dist/automate/morpheus/index.d.ts +0 -14
- package/dist/automate/morpheus/index.js +0 -171
- package/dist/automate/morpheus/index.js.map +0 -1
- package/dist/automate/writer/index.d.ts +0 -10
- package/dist/automate/writer/index.js +0 -72
- package/dist/automate/writer/index.js.map +0 -1
- package/dist/shared/ContextType.d.ts +0 -27
- package/dist/shared/ContextType.js +0 -55
- package/dist/shared/ContextType.js.map +0 -1
package/dist/config/index.d.ts
CHANGED
package/dist/config/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDev = exports.nodeEnv = void 0;
|
|
4
|
-
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
6
|
-
exports.nodeEnv = (0, lodash_1.get)(process.env, 'NODE_ENV');
|
|
4
|
+
exports.nodeEnv = process.env.NODE_ENV;
|
|
7
5
|
exports.isDev = exports.nodeEnv !== 'production';
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC/B,QAAA,KAAK,GAAG,eAAO,KAAK,YAAY,CAAC","sourcesContent":["export const nodeEnv = process.env.NODE_ENV;\nexport const isDev = nodeEnv !== 'production';\n"]}
|
package/dist/connection.d.ts
CHANGED
package/dist/connection.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
15
|
function step(op) {
|
|
39
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
20
|
switch (op[0]) {
|
|
@@ -58,10 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
58
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
36
|
}
|
|
60
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
61
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
42
|
exports.CouchbaseConnection = void 0;
|
|
63
|
-
|
|
64
|
-
var couchbase = __importStar(require("couchbase"));
|
|
43
|
+
var couchbase_1 = __importDefault(require("./couchbase"));
|
|
65
44
|
/**
|
|
66
45
|
* CouchbaseConnection class
|
|
67
46
|
* Only one CouchbaseConnection can exist that's why it's a singleton
|
|
@@ -89,7 +68,7 @@ var CouchbaseConnection = /** @class */ (function () {
|
|
|
89
68
|
this.bucketName = bucketName;
|
|
90
69
|
this.username = username;
|
|
91
70
|
this.password = password;
|
|
92
|
-
return [4 /*yield*/,
|
|
71
|
+
return [4 /*yield*/, couchbase_1.default.connect(connectionString, {
|
|
93
72
|
username: username,
|
|
94
73
|
password: password,
|
|
95
74
|
})];
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0DAAoC;AASpC;;;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,SAAI,GAAG,UAAO,IAAkB;;;;;wBAC5B,gBAAgB,GAAgD,IAAI,iBAApD,EAAE,QAAQ,GAAsC,IAAI,SAA1C,EAAE,QAAQ,GAA4B,IAAI,SAAhC,EAAE,KAA0B,IAAI,WAAR,EAAtB,UAAU,mBAAG,SAAS,KAAA,CAAS;wBAE5E,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;wBACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;wBAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;wBACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;wBAET,qBAAM,mBAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE;gCACtD,QAAQ,UAAA;gCACR,QAAQ,UAAA;6BACX,CAAC,EAAA;;wBAHI,OAAO,GAAG,SAGd;wBAEF,IAAI,CAAC,OAAO,GAAG,OAAc,CAAC;wBAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;wBAE9C,sBAAO,IAAI,EAAC;;;aACf,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;IA5CqB,CAAC;IAJxB,sBAAkB,+BAAQ;aAA1B;YACI,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;;;OAAA;IA+CL,0BAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,kDAAmB;AA+DhC,kBAAe,mBAAmB,CAAC","sourcesContent":["import type {Collection, Cluster, Bucket} from 'couchbase';\n\nimport couchbase from './couchbase';\n\nexport interface CouchsetArgs {\n connectionString: string;\n bucketName: string;\n username: string;\n password: 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 * 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"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var edge_1 = require("./utils/edge");
|
|
4
|
+
var couchbase;
|
|
5
|
+
var edge = (0, edge_1.isEdge)();
|
|
6
|
+
if (edge) {
|
|
7
|
+
couchbase = require('couchbase-serverless');
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
couchbase = require('couchbase');
|
|
11
|
+
}
|
|
12
|
+
exports.default = couchbase;
|
|
13
|
+
//# sourceMappingURL=couchbase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couchbase.js","sourceRoot":"","sources":["../src/couchbase.ts"],"names":[],"mappings":";;AAAA,qCAAoC;AAEpC,IAAI,SAAS,CAAC;AAEd,IAAM,IAAI,GAAG,IAAA,aAAM,GAAE,CAAC;AAEtB,IAAI,IAAI,EAAE;IACN,SAAS,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC/C;KAAM;IACH,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACpC;AAED,kBAAe,SAAS,CAAC","sourcesContent":["import {isEdge} from './utils/edge';\n\nlet couchbase;\n\nconst edge = isEdge();\n\nif (edge) {\n couchbase = require('couchbase-serverless');\n} else {\n couchbase = require('couchbase');\n}\n\nexport default couchbase;\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
28
28
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
29
|
function step(op) {
|
|
30
30
|
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
32
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
33
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
34
|
switch (op[0]) {
|
|
@@ -55,8 +55,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
56
|
exports.couchset = void 0;
|
|
57
57
|
var connection_1 = __importDefault(require("./connection"));
|
|
58
|
-
__exportStar(require("type-graphql"), exports);
|
|
59
|
-
__exportStar(require("./automate"), exports);
|
|
60
58
|
__exportStar(require("./model"), exports);
|
|
61
59
|
__exportStar(require("./connection"), exports);
|
|
62
60
|
__exportStar(require("./query"), exports);
|
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
|
|
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"]}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Collection, GetOptions, RemoveOptions, ReplaceOptions, UpsertOptions } from 'couchbase';
|
|
2
|
-
import { AutomaticMethodOptions, AutomaticOutput } from '../automate';
|
|
1
|
+
import type { Collection, GetOptions, RemoveOptions, ReplaceOptions, UpsertOptions } from 'couchbase';
|
|
3
2
|
import { CustomQueryPagination } from '../search';
|
|
4
3
|
import { SchemaTypes } from '../utils';
|
|
5
4
|
import CouchbaseConnection from '../connection';
|
|
@@ -100,11 +99,5 @@ export declare class Model {
|
|
|
100
99
|
query: string;
|
|
101
100
|
}): Promise<[T[], CustomQueryPagination]>;
|
|
102
101
|
parse<T>(data: T): T;
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param args AutomaticModelOptions
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
automate(args?: Partial<AutomaticMethodOptions>): AutomaticOutput;
|
|
109
102
|
}
|
|
110
103
|
export default Model;
|
package/dist/model/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -62,7 +62,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
62
62
|
};
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
64
|
exports.Model = void 0;
|
|
65
|
-
|
|
65
|
+
// import {AutomaticMethodOptions, AutomaticOutput, automateImplementation} from '../automate';
|
|
66
66
|
var search_1 = require("../search");
|
|
67
67
|
var utils_1 = require("../utils");
|
|
68
68
|
var connection_1 = __importDefault(require("../connection"));
|
|
@@ -333,15 +333,6 @@ var Model = /** @class */ (function () {
|
|
|
333
333
|
this.fresh(); // refresh
|
|
334
334
|
return (0, utils_1.parseSchema)(this.schema, data);
|
|
335
335
|
};
|
|
336
|
-
/**
|
|
337
|
-
*
|
|
338
|
-
* @param args AutomaticModelOptions
|
|
339
|
-
* @returns
|
|
340
|
-
*/
|
|
341
|
-
Model.prototype.automate = function (args) {
|
|
342
|
-
this.fresh(); // refresh
|
|
343
|
-
return (0, automate_1.automateImplementation)(this.graphqlType, __assign({ model: this }, args));
|
|
344
|
-
};
|
|
345
336
|
return Model;
|
|
346
337
|
}());
|
|
347
338
|
exports.Model = Model;
|
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wCAA4F;AAC5F,oCAA6D;AAC7D,kCAAkD;AAClD,6DAAgD;AAChD,4CAAyC;AACzC,gCAAqC;AAqBrC;IAUI,eAAY,IAAY,EAAE,OAAsB;QAPhD,UAAK,GAAG,UAAU,CAAC;QACnB,WAAM,GAAgC;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M,IAAA,oBAAW,EAAI;gCAClC,KAAK,OAAA;gCACL,MAAM,QAAA;gCACN,KAAK,OAAA;6BACR,CAAC,EAAA;;wBAJI,QAAQ,GAAG,SAIf;wBAEF,sBAAO,QAAQ,EAAC;;;;KACnB;IAEM,qBAAK,GAAZ,UAAgB,IAAO;QACnB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU;QACxB,OAAO,IAAA,mBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,wBAAQ,GAAf,UAAgB,IAAsC;QAClD,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU;QACxB,OAAO,IAAA,iCAAsB,EAAC,IAAI,CAAC,WAAW,aAAG,KAAK,EAAE,IAAI,IAAK,IAAI,EAAE,CAAC;IAC5E,CAAC;IACL,YAAC;AAAD,CAAC,AA1QD,IA0QC;AA1QY,sBAAK;AA4QlB,kBAAe,KAAK,CAAC","sourcesContent":["import {Collection, GetOptions, RemoveOptions, ReplaceOptions, UpsertOptions} from 'couchbase';\n\nimport {AutomaticMethodOptions, AutomaticOutput, automateImplementation} from '../automate';\nimport {CustomQuery, CustomQueryPagination} from '../search';\nimport {SchemaTypes, parseSchema} from '../utils';\nimport CouchbaseConnection from '../connection';\nimport {Pagination} from '../pagination';\nimport {generateUUID} from '../uuid';\n\nexport interface AutoModelFields {\n id: string;\n createdAt: Date;\n updatedAt?: Date;\n deleted?: Date;\n _type: string; // type for models/collections\n _scope: string; // scope for collections\n}\n\nexport interface UpdateOptions extends ReplaceOptions {\n silent?: boolean; // whether to updatedAt;\n}\n\nexport interface ModalOptions {\n scope?: string;\n schema?: Record<string, SchemaTypes>;\n graphqlType?: any;\n}\n\nexport class Model {\n collection: Collection;\n collectionName: string;\n scope = '_default';\n schema: Record<string, SchemaTypes> = {\n createdAt: 'date',\n updatedAt: 'date',\n };\n graphqlType = null;\n\n constructor(name: string, options?: ModalOptions) {\n // this.collection = CouchbaseConnection.Instance.getCollection();\n this.collectionName = name;\n if (options) {\n this.graphqlType = (options && options.graphqlType) || null;\n this.scope = (options && options.scope) || '_default';\n this.schema = {\n ...((options && options.schema) || {}),\n createdAt: 'date',\n updatedAt: 'date',\n };\n }\n }\n\n /**\n * Set setGraphqlType\n * setGraphqlType\n */\n public setGraphqlType(gqlType: any): Model {\n this.graphqlType = gqlType;\n return this;\n }\n\n /**\n * Refresh and get default collection from CouchbaseConnection\n * Because CouchbaseConnection is a singleton, sometimes it might be undefined depending when model was created\n * So we have to call it from all model methods\n * to avoid error `Cannot read property 'defaultCollection' of null`\n */\n public fresh(): void {\n // if couchbase connection has been init\n if (CouchbaseConnection.Instance.bucketName) {\n this.collection = CouchbaseConnection.Instance.getCollection();\n }\n }\n\n /** Get this collection\n * getCollection\n */\n public getBucketName(): string {\n return CouchbaseConnection.Instance?.getBucket();\n }\n\n /** Get this collection\n * getCollection\n */\n public couchbaseConnection(): CouchbaseConnection {\n return CouchbaseConnection.Instance;\n }\n\n /** Get this collection\n * getCollection\n */\n public getCollection(): Collection {\n this.fresh();\n return this.collection;\n }\n\n /**\n * create\n */\n public async create<T>(data: T, options?: UpsertOptions): Promise<T & AutoModelFields> {\n this.fresh();\n const id = generateUUID();\n const createdData = {\n id, // let id be override\n ...data,\n createdAt: new Date(),\n updatedAt: new Date(), // same as created at\n _type: this.collectionName,\n _scope: this.scope,\n };\n\n try {\n await this.collection.upsert(createdData.id, createdData, options);\n return parseSchema(this.schema, createdData);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * findById\n */\n public async findById(id: string, options?: GetOptions): Promise<any & AutoModelFields> {\n this.fresh();\n try {\n const data = await this.collection.get(id, options);\n return parseSchema(this.schema, data.content);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * update\n */\n public async updateById<T>(id: string, data: T, opt?: UpdateOptions): Promise<T> {\n this.fresh();\n\n const {silent = false, ...options} = opt || {};\n\n const updatedDocument: any = {\n ...data,\n id,\n _type: this.collectionName, // type and scope must be defined\n _scope: this.scope,\n };\n\n if (!silent) {\n updatedDocument.updatedAt = new Date();\n }\n\n try {\n await this.collection.replace(id, updatedDocument, options);\n return parseSchema(this.schema, updatedDocument);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * save\n */\n public async save<T>(data: T & {id: string}, opt?: UpdateOptions): Promise<T> {\n this.fresh();\n\n const id = data && data.id;\n\n const {silent = false, ...options} = opt || {};\n\n const updatedDocument: any = {\n ...data,\n id,\n _type: this.collectionName, // type and scope must be defined\n _scope: this.scope,\n };\n\n if (!silent) {\n updatedDocument.updatedAt = new Date();\n }\n\n try {\n if (!id) {\n throw new Error('document must have id');\n }\n await this.collection.replace(id, updatedDocument, options);\n return parseSchema(this.schema, updatedDocument);\n } catch (error) {\n console.error(error);\n throw error;\n }\n }\n\n public async delete(id: string, options?: RemoveOptions): Promise<boolean> {\n this.fresh();\n try {\n await this.collection.remove(id, options);\n return true;\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * Pagination\n * \n select = ['id', 'createdAt']\n where = {\n where: { owner: { $eq: \"stoqey\" }, _type: { $eq: \"Trade\" } },\n },\n page = 0,\n limit = 10,\n orderBy = { createdAt: \"DESC\" },\n * @param args PaginationArgs\n */\n public async pagination({\n select,\n where,\n orderBy,\n limit,\n page,\n customQuery = {},\n }: {\n select?: any[] | string;\n where?: any;\n orderBy?: any;\n limit?: number;\n page?: number;\n customQuery?: any; // can be $and or any other valid quries\n }): Promise<any[]> {\n this.fresh(); // refresh\n // Where begins here\n let whereEx = {_type: {$eq: this.collectionName}};\n\n if (where) {\n whereEx = {\n ...whereEx,\n ...where,\n };\n }\n\n const bucketName = CouchbaseConnection.Instance.bucketName;\n\n const rows = await Pagination({\n bucketName,\n select,\n where: {where: whereEx, ...customQuery},\n limit,\n page,\n orderBy,\n });\n\n return rows.map((r) => parseSchema(this.schema, r));\n }\n\n /**\n * Run a custom query with model parsing\n * @param { select, query }\n * @returns\n */\n public async customQuery<T>({\n params,\n limit,\n query,\n }: {\n params: any;\n limit: number;\n query: string;\n }): Promise<[T[], CustomQueryPagination]> {\n this.fresh(); // refresh\n // Where begins here\n\n const response = await CustomQuery<T>({\n limit,\n params,\n query,\n });\n\n return response;\n }\n\n public parse<T>(data: T): T {\n this.fresh(); // refresh\n return parseSchema(this.schema, data);\n }\n\n /**\n *\n * @param args AutomaticModelOptions\n * @returns\n */\n public automate(args?: Partial<AutomaticMethodOptions>): AutomaticOutput {\n this.fresh(); // refresh\n return automateImplementation(this.graphqlType, {model: this, ...args});\n }\n}\n\nexport default Model;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+FAA+F;AAC/F,oCAA6D;AAC7D,kCAAkD;AAClD,6DAAgD;AAChD,4CAAyC;AACzC,gCAAqC;AAqBrC;IAUI,eAAY,IAAY,EAAE,OAAsB;QAPhD,UAAK,GAAG,UAAU,CAAC;QACnB,WAAM,GAAgC;YAClC,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,MAAM;SACpB,CAAC;QACF,gBAAW,GAAG,IAAI,CAAC;QAGf,kEAAkE;QAClE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;YAC5D,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC;YACtD,IAAI,CAAC,MAAM,yBACJ,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GACpB,CAAC;SACL;IACL,CAAC;IAED;;;OAGG;IACI,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C;wBAElD,IAAI,KAAK,EAAE;4BACP,OAAO,yBACA,OAAO,GACP,KAAK,CACX,CAAC;yBACL;wBAEK,UAAU,GAAG,oBAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC;wBAE9C,qBAAM,IAAA,uBAAU,EAAC;gCAC1B,UAAU,YAAA;gCACV,MAAM,QAAA;gCACN,KAAK,aAAG,KAAK,EAAE,OAAO,IAAK,WAAW,CAAC;gCACvC,KAAK,OAAA;gCACL,IAAI,MAAA;gCACJ,OAAO,SAAA;6BACV,CAAC,EAAA;;wBAPI,IAAI,GAAG,SAOX;wBAEF,sBAAO,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,IAAA,mBAAW,EAAC,KAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAA3B,CAA2B,CAAC,EAAC;;;;KACvD;IAED;;;;OAIG;IACU,2BAAW,GAAxB,UAA4B,EAQ3B;YAPG,MAAM,YAAA,EACN,KAAK,WAAA,EACL,KAAK,WAAA;;;;;;wBAML,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU;wBAGP,qBAAM,IAAA,oBAAW,EAAI;gCAClC,KAAK,OAAA;gCACL,MAAM,QAAA;gCACN,KAAK,OAAA;6BACR,CAAC,EAAA;;wBAJI,QAAQ,GAAG,SAIf;wBAEF,sBAAO,QAAQ,EAAC;;;;KACnB;IAEM,qBAAK,GAAZ,UAAgB,IAAO;QACnB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU;QACxB,OAAO,IAAA,mBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAWL,YAAC;AAAD,CAAC,AA1QD,IA0QC;AA1QY,sBAAK;AA4QlB,kBAAe,KAAK,CAAC","sourcesContent":["import type {Collection, GetOptions, RemoveOptions, ReplaceOptions, UpsertOptions} from 'couchbase';\n\n// import {AutomaticMethodOptions, AutomaticOutput, automateImplementation} from '../automate';\nimport {CustomQuery, CustomQueryPagination} from '../search';\nimport {SchemaTypes, parseSchema} from '../utils';\nimport CouchbaseConnection from '../connection';\nimport {Pagination} from '../pagination';\nimport {generateUUID} from '../uuid';\n\nexport interface AutoModelFields {\n id: string;\n createdAt: Date;\n updatedAt?: Date;\n deleted?: Date;\n _type: string; // type for models/collections\n _scope: string; // scope for collections\n}\n\nexport interface UpdateOptions extends ReplaceOptions {\n silent?: boolean; // whether to updatedAt;\n}\n\nexport interface ModalOptions {\n scope?: string;\n schema?: Record<string, SchemaTypes>;\n graphqlType?: any;\n}\n\nexport class Model {\n collection: Collection;\n collectionName: string;\n scope = '_default';\n schema: Record<string, SchemaTypes> = {\n createdAt: 'date',\n updatedAt: 'date',\n };\n graphqlType = null;\n\n constructor(name: string, options?: ModalOptions) {\n // this.collection = CouchbaseConnection.Instance.getCollection();\n this.collectionName = name;\n if (options) {\n this.graphqlType = (options && options.graphqlType) || null;\n this.scope = (options && options.scope) || '_default';\n this.schema = {\n ...((options && options.schema) || {}),\n createdAt: 'date',\n updatedAt: 'date',\n };\n }\n }\n\n /**\n * Set setGraphqlType\n * setGraphqlType\n */\n public setGraphqlType(gqlType: any): Model {\n this.graphqlType = gqlType;\n return this;\n }\n\n /**\n * Refresh and get default collection from CouchbaseConnection\n * Because CouchbaseConnection is a singleton, sometimes it might be undefined depending when model was created\n * So we have to call it from all model methods\n * to avoid error `Cannot read property 'defaultCollection' of null`\n */\n public fresh(): void {\n // if couchbase connection has been init\n if (CouchbaseConnection.Instance.bucketName) {\n this.collection = CouchbaseConnection.Instance.getCollection();\n }\n }\n\n /** Get this collection\n * getCollection\n */\n public getBucketName(): string {\n return CouchbaseConnection.Instance?.getBucket();\n }\n\n /** Get this collection\n * getCollection\n */\n public couchbaseConnection(): CouchbaseConnection {\n return CouchbaseConnection.Instance;\n }\n\n /** Get this collection\n * getCollection\n */\n public getCollection(): Collection {\n this.fresh();\n return this.collection;\n }\n\n /**\n * create\n */\n public async create<T>(data: T, options?: UpsertOptions): Promise<T & AutoModelFields> {\n this.fresh();\n const id = generateUUID();\n const createdData = {\n id, // let id be override\n ...data,\n createdAt: new Date(),\n updatedAt: new Date(), // same as created at\n _type: this.collectionName,\n _scope: this.scope,\n };\n\n try {\n await this.collection.upsert(createdData.id, createdData, options);\n return parseSchema(this.schema, createdData);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * findById\n */\n public async findById(id: string, options?: GetOptions): Promise<any & AutoModelFields> {\n this.fresh();\n try {\n const data = await this.collection.get(id, options);\n return parseSchema(this.schema, data.content);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * update\n */\n public async updateById<T>(id: string, data: T, opt?: UpdateOptions): Promise<T> {\n this.fresh();\n\n const {silent = false, ...options} = opt || {};\n\n const updatedDocument: any = {\n ...data,\n id,\n _type: this.collectionName, // type and scope must be defined\n _scope: this.scope,\n };\n\n if (!silent) {\n updatedDocument.updatedAt = new Date();\n }\n\n try {\n await this.collection.replace(id, updatedDocument, options);\n return parseSchema(this.schema, updatedDocument);\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * save\n */\n public async save<T>(data: T & {id: string}, opt?: UpdateOptions): Promise<T> {\n this.fresh();\n\n const id = data && data.id;\n\n const {silent = false, ...options} = opt || {};\n\n const updatedDocument: any = {\n ...data,\n id,\n _type: this.collectionName, // type and scope must be defined\n _scope: this.scope,\n };\n\n if (!silent) {\n updatedDocument.updatedAt = new Date();\n }\n\n try {\n if (!id) {\n throw new Error('document must have id');\n }\n await this.collection.replace(id, updatedDocument, options);\n return parseSchema(this.schema, updatedDocument);\n } catch (error) {\n console.error(error);\n throw error;\n }\n }\n\n public async delete(id: string, options?: RemoveOptions): Promise<boolean> {\n this.fresh();\n try {\n await this.collection.remove(id, options);\n return true;\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * Pagination\n * \n select = ['id', 'createdAt']\n where = {\n where: { owner: { $eq: \"stoqey\" }, _type: { $eq: \"Trade\" } },\n },\n page = 0,\n limit = 10,\n orderBy = { createdAt: \"DESC\" },\n * @param args PaginationArgs\n */\n public async pagination({\n select,\n where,\n orderBy,\n limit,\n page,\n customQuery = {},\n }: {\n select?: any[] | string;\n where?: any;\n orderBy?: any;\n limit?: number;\n page?: number;\n customQuery?: any; // can be $and or any other valid quries\n }): Promise<any[]> {\n this.fresh(); // refresh\n // Where begins here\n let whereEx = {_type: {$eq: this.collectionName}};\n\n if (where) {\n whereEx = {\n ...whereEx,\n ...where,\n };\n }\n\n const bucketName = CouchbaseConnection.Instance.bucketName;\n\n const rows = await Pagination({\n bucketName,\n select,\n where: {where: whereEx, ...customQuery},\n limit,\n page,\n orderBy,\n });\n\n return rows.map((r) => parseSchema(this.schema, r));\n }\n\n /**\n * Run a custom query with model parsing\n * @param { select, query }\n * @returns\n */\n public async customQuery<T>({\n params,\n limit,\n query,\n }: {\n params: any;\n limit: number;\n query: string;\n }): Promise<[T[], CustomQueryPagination]> {\n this.fresh(); // refresh\n // Where begins here\n\n const response = await CustomQuery<T>({\n limit,\n params,\n query,\n });\n\n return response;\n }\n\n public parse<T>(data: T): T {\n this.fresh(); // refresh\n return parseSchema(this.schema, data);\n }\n\n // /**\n // *\n // * @param args AutomaticModelOptions\n // * @returns\n // */\n // public automate(args?: Partial<AutomaticMethodOptions>): AutomaticOutput {\n // this.fresh(); // refresh\n // return automateImplementation(this.graphqlType, {model: this, ...args});\n // }\n}\n\nexport default Model;\n"]}
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SortType = 'ASC' | 'DESC';
|
|
2
2
|
/**
|
|
3
3
|
* Result expressions ALL | DISTINCT
|
|
4
4
|
* */
|
|
5
|
-
export
|
|
5
|
+
export type ReturnResultType = '$all' | '$distinct';
|
|
6
6
|
/**
|
|
7
7
|
* Result expressions RAW | ELEMENT | VALUE
|
|
8
8
|
* */
|
|
9
|
-
export
|
|
9
|
+
export type ResultExprType = '$raw' | '$element' | '$value';
|
|
10
10
|
/**
|
|
11
11
|
* List of aggregation functions.
|
|
12
12
|
* */
|
|
13
|
-
export
|
|
13
|
+
export type AggType = '$arrayAgg' | '$avg' | '$mean' | '$count' | '$countn' | '$max' | '$median' | '$min' | '$stddev' | '$stddevPop' | '$stddevSamp' | '$sum' | '$variance' | '$variancePop' | '$varianceSamp' | '$varPop' | '$varSamp';
|
|
14
14
|
/**
|
|
15
15
|
* List of Boolean comparison operators.
|
|
16
16
|
* */
|
|
17
|
-
export
|
|
17
|
+
export type ComparisonEmptyOperatorType = '$isNull' | '$isNotNull' | '$isMissing' | '$isNotMissing' | '$isValued' | '$isNotValued';
|
|
18
18
|
/**
|
|
19
19
|
* List of Numeric comparison operators.
|
|
20
20
|
* */
|
|
21
|
-
export
|
|
21
|
+
export type ComparisonSingleOperatorType = '$eq' | '$neq' | '$gt' | '$gte' | '$lt' | '$lte';
|
|
22
22
|
/**
|
|
23
23
|
* List of String comparison operators.
|
|
24
24
|
* */
|
|
25
|
-
export
|
|
25
|
+
export type ComparisonSingleStringOperatorType = '$like' | '$notLike';
|
|
26
26
|
/**
|
|
27
27
|
* List of Range comparison operators.
|
|
28
28
|
* */
|
|
29
|
-
export
|
|
29
|
+
export type ComparisonMultipleOperatorType = '$btw' | '$notBtw';
|
|
30
30
|
/**
|
|
31
31
|
* List of Logical operators.
|
|
32
32
|
* */
|
|
33
|
-
export
|
|
33
|
+
export type LogicalOperatorType = '$and' | '$or' | '$not';
|
|
34
34
|
/**
|
|
35
35
|
* Collection Select Operator.
|
|
36
36
|
* */
|
|
37
|
-
export
|
|
37
|
+
export type CollectionSelectOperator = '$any' | '$every';
|
|
38
38
|
/**
|
|
39
39
|
* Collection IN and WITHIN Operators.
|
|
40
40
|
* */
|
|
41
|
-
export
|
|
41
|
+
export type CollectionInWithinOperator = '$in' | '$within';
|
|
42
42
|
/**
|
|
43
43
|
* List of Collection IN and WITHIN Operators.
|
|
44
44
|
* */
|
|
45
|
-
export
|
|
45
|
+
export type CollectionSatisfiesOperator = '$satisfies';
|
|
46
46
|
export interface CollectionInWithinOperatorValue {
|
|
47
47
|
search_expr: unknown;
|
|
48
48
|
target_expr: unknown;
|
|
@@ -56,7 +56,7 @@ export interface CollectionInWithinOperatorValue {
|
|
|
56
56
|
* {$in:{search_expr: 'search', target_expr: 'address', $not: true}}
|
|
57
57
|
* ```
|
|
58
58
|
* */
|
|
59
|
-
export
|
|
59
|
+
export type CollectionInWithinOperatorType = {
|
|
60
60
|
[key in CollectionInWithinOperator]?: CollectionInWithinOperatorValue;
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
@@ -75,7 +75,7 @@ export interface CollectionExpressionType {
|
|
|
75
75
|
* {$any: {$expr: [{$in:{search_expr: 'search', target_expr: 'address', $not: true} }], $satisfied:{address: '10'}}}
|
|
76
76
|
* ```
|
|
77
77
|
* */
|
|
78
|
-
export
|
|
78
|
+
export type CollectionSelectOperatorType = {
|
|
79
79
|
[key in CollectionSelectOperator]?: CollectionExpressionType;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
@@ -87,7 +87,7 @@ export declare type CollectionSelectOperatorType = {
|
|
|
87
87
|
* ```
|
|
88
88
|
*
|
|
89
89
|
* */
|
|
90
|
-
export
|
|
90
|
+
export type ComparisonWhereExpr = {
|
|
91
91
|
[key in ComparisonEmptyOperatorType | ComparisonSingleOperatorType | ComparisonMultipleOperatorType | ComparisonSingleStringOperatorType]?: string | number | boolean | (number | string)[];
|
|
92
92
|
};
|
|
93
93
|
/**
|
|
@@ -99,7 +99,7 @@ export declare type ComparisonWhereExpr = {
|
|
|
99
99
|
* ```
|
|
100
100
|
*
|
|
101
101
|
* */
|
|
102
|
-
export
|
|
102
|
+
export type FieldWhereExpr = Record<string, string | number | boolean | ComparisonWhereExpr> | LogicalWhereExpr;
|
|
103
103
|
/**
|
|
104
104
|
* Structure of Logical WHERE expression
|
|
105
105
|
*
|
|
@@ -109,7 +109,7 @@ export declare type FieldWhereExpr = Record<string, string | number | boolean |
|
|
|
109
109
|
* ```
|
|
110
110
|
*
|
|
111
111
|
* */
|
|
112
|
-
export
|
|
112
|
+
export type LogicalWhereExpr = {
|
|
113
113
|
[key in LogicalOperatorType]?: FieldWhereExpr[];
|
|
114
114
|
} | {
|
|
115
115
|
[key: string]: FieldWhereExpr;
|
|
@@ -138,7 +138,7 @@ export interface IField {
|
|
|
138
138
|
* ```
|
|
139
139
|
*
|
|
140
140
|
* */
|
|
141
|
-
export
|
|
141
|
+
export type ISelectAggType = {
|
|
142
142
|
[key in AggType]?: ISelectFieldType;
|
|
143
143
|
};
|
|
144
144
|
/**
|
|
@@ -164,7 +164,7 @@ export interface ISelectFieldType {
|
|
|
164
164
|
* ```
|
|
165
165
|
*
|
|
166
166
|
* */
|
|
167
|
-
export
|
|
167
|
+
export type ISelectResultExprType = {
|
|
168
168
|
[key in ResultExprType]?: ISelectAggType | ISelectFieldType;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
@@ -176,7 +176,7 @@ export declare type ISelectResultExprType = {
|
|
|
176
176
|
* ```
|
|
177
177
|
*
|
|
178
178
|
* */
|
|
179
|
-
export
|
|
179
|
+
export type ISelectReturnResultType = {
|
|
180
180
|
[key in ReturnResultType]?: ISelectResultExprType | ISelectAggType | ISelectFieldType;
|
|
181
181
|
};
|
|
182
182
|
/**
|
|
@@ -188,7 +188,7 @@ export declare type ISelectReturnResultType = {
|
|
|
188
188
|
* ```
|
|
189
189
|
*
|
|
190
190
|
* */
|
|
191
|
-
export
|
|
191
|
+
export type ISelectType = ISelectReturnResultType | ISelectResultExprType | ISelectAggType | ISelectFieldType;
|
|
192
192
|
/**
|
|
193
193
|
* LET expression
|
|
194
194
|
* */
|
|
@@ -218,7 +218,7 @@ export interface IConditionExpr {
|
|
|
218
218
|
/**
|
|
219
219
|
* Types of supported index statements
|
|
220
220
|
* */
|
|
221
|
-
export
|
|
221
|
+
export type IndexType = 'CREATE' | 'BUILD' | 'DROP' | 'CREATE PRIMARY';
|
|
222
222
|
/**
|
|
223
223
|
* Index ON clause types
|
|
224
224
|
* */
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.cluster.js","sourceRoot":"","sources":["../../src/query/query.cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAAgD;AAEhD;;;;;;;;;;;GAWG;AACH,SAAsB,YAAY,CAAC,KAAa,EAAE,OAAa;;;;;;oBACrD,OAAO,GAAG,oBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC;;;;oBAElC,qBAAM,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAA;;oBAA5C,MAAM,GAAG,SAAmC;oBAClD,sBAAO,MAAM,EAAC;;;oBAEd,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAK,CAAC,CAAC;oBACvC,MAAM,OAAK,CAAC;;;;;CAEnB;AATD,oCASC","sourcesContent":["import {QueryResult} from 'couchbase';\n\nimport CouchbaseConnection from '../connection';\n\n/**\n * Query couchbase db\n * @param query\n * \n const query = `\n SELECT airportname, city FROM \\`travel-sample\\`\n WHERE type=$1\n AND city=$2\n `;\n const options = {parameters: ['airport', 'San Jose']};\n * @param options\n */\nexport async function QueryCluster(query: string, options?: any): Promise<QueryResult> {\n const cluster = CouchbaseConnection.Instance.cluster;\n try {\n const result = await cluster.query(query, options);\n return result;\n } catch (error) {\n console.error('Query failed: ', error);\n throw error;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"query.cluster.js","sourceRoot":"","sources":["../../src/query/query.cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAAgD;AAEhD;;;;;;;;;;;GAWG;AACH,SAAsB,YAAY,CAAC,KAAa,EAAE,OAAa;;;;;;oBACrD,OAAO,GAAG,oBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC;;;;oBAElC,qBAAM,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAA;;oBAA5C,MAAM,GAAG,SAAmC;oBAClD,sBAAO,MAAM,EAAC;;;oBAEd,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAK,CAAC,CAAC;oBACvC,MAAM,OAAK,CAAC;;;;;CAEnB;AATD,oCASC","sourcesContent":["import type {QueryResult} from 'couchbase';\n\nimport CouchbaseConnection from '../connection';\n\n/**\n * Query couchbase db\n * @param query\n * \n const query = `\n SELECT airportname, city FROM \\`travel-sample\\`\n WHERE type=$1\n AND city=$2\n `;\n const options = {parameters: ['airport', 'San Jose']};\n * @param options\n */\nexport async function QueryCluster(query: string, options?: any): Promise<QueryResult> {\n const cluster = CouchbaseConnection.Instance.cluster;\n try {\n const result = await cluster.query(query, options);\n return result;\n } catch (error) {\n console.error('Query failed: ', error);\n throw error;\n }\n}\n"]}
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { Model } from '../model';
|
|
2
|
-
export declare class CommonType {
|
|
3
|
-
id?: string;
|
|
4
|
-
env?: string;
|
|
5
|
-
owner?: string;
|
|
6
|
-
createdAt?: Date;
|
|
7
|
-
updatedAt?: Date;
|
|
8
|
-
deleted?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const CommonSchema: {
|
|
11
|
-
id: StringConstructor;
|
|
12
|
-
env: StringConstructor;
|
|
13
|
-
owner: StringConstructor;
|
|
14
|
-
createdAt: DateConstructor;
|
|
15
|
-
updatedAt: DateConstructor;
|
|
16
|
-
deleted: BooleanConstructor;
|
|
17
|
-
};
|
|
18
2
|
interface CreateUpdate {
|
|
19
3
|
model: Model;
|
|
20
4
|
id?: string;
|
|
@@ -22,16 +6,4 @@ interface CreateUpdate {
|
|
|
22
6
|
data: any;
|
|
23
7
|
}
|
|
24
8
|
export declare const createUpdate: <T>(args: CreateUpdate) => Promise<T>;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a [className]Pagination ObjectType
|
|
27
|
-
* @param c class
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
export declare const getPagination: <T>(c: T) => any;
|
|
31
|
-
export interface IResType {
|
|
32
|
-
success: boolean;
|
|
33
|
-
message?: string;
|
|
34
|
-
data?: any;
|
|
35
|
-
}
|
|
36
|
-
export declare const ResTypeFragment: import("graphql").DocumentNode;
|
|
37
9
|
export {};
|