couchset 0.0.3 → 0.0.4

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.
Files changed (49) hide show
  1. package/dist/automate/index.d.ts +4 -0
  2. package/dist/automate/middlewares/index.d.ts +1 -0
  3. package/dist/automate/middlewares/isAuth.d.ts +7 -0
  4. package/dist/automate/middlewares/isAuth.js.map +1 -1
  5. package/dist/automate/model/client.d.ts +12 -0
  6. package/dist/automate/model/client.js +1 -1
  7. package/dist/automate/model/client.js.map +1 -1
  8. package/dist/automate/model/index.d.ts +44 -0
  9. package/dist/automate/model/index.js +1 -1
  10. package/dist/automate/model/index.js.map +1 -1
  11. package/dist/automate/morpheus/index.d.ts +14 -0
  12. package/dist/automate/morpheus/index.js.map +1 -1
  13. package/dist/automate/writer/index.d.ts +10 -0
  14. package/dist/config/index.d.ts +3 -0
  15. package/dist/connection.d.ts +36 -0
  16. package/dist/index.d.ts +14 -0
  17. package/dist/model/index.d.ts +107 -0
  18. package/dist/model/index.js.map +1 -1
  19. package/dist/pagination/index.d.ts +1 -0
  20. package/dist/pagination/pagination.d.ts +19 -0
  21. package/dist/query/base-query.d.ts +17 -0
  22. package/dist/query/exceptions.d.ts +24 -0
  23. package/dist/query/helpers/builders.d.ts +64 -0
  24. package/dist/query/helpers/builders.js +1 -1
  25. package/dist/query/helpers/builders.js.map +1 -1
  26. package/dist/query/helpers/dictionary.d.ts +45 -0
  27. package/dist/query/helpers/index.d.ts +3 -0
  28. package/dist/query/helpers/reservedWords.d.ts +1 -0
  29. package/dist/query/index.d.ts +5 -0
  30. package/dist/query/interface/query.types.d.ts +236 -0
  31. package/dist/query/query.cluster.d.ts +14 -0
  32. package/dist/query/query.cluster.js.map +1 -1
  33. package/dist/query/query.d.ts +321 -0
  34. package/dist/query/utils.d.ts +8 -0
  35. package/dist/search/customQuery.d.ts +17 -0
  36. package/dist/search/index.d.ts +1 -0
  37. package/dist/shared/ContextType.d.ts +27 -0
  38. package/dist/shared/ContextType.js.map +1 -1
  39. package/dist/shared/common.model.d.ts +37 -0
  40. package/dist/shared/common.model.js.map +1 -1
  41. package/dist/shared/index.d.ts +2 -0
  42. package/dist/utils/awaitTo.d.ts +17 -0
  43. package/dist/utils/date.d.ts +11 -0
  44. package/dist/utils/index.d.ts +5 -0
  45. package/dist/utils/log.d.ts +9 -0
  46. package/dist/utils/text.utils.d.ts +14 -0
  47. package/dist/utils/utils.schema.d.ts +6 -0
  48. package/dist/uuid.d.ts +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,321 @@
1
+ import { BaseQuery } from './base-query';
2
+ import { IConditionExpr, IGroupBy, IIndexOnParams, IIndexWithParams, ILetExpr, IndexType, ISelectType, LogicalWhereExpr, SortType } from './interface/query.types';
3
+ export declare class QueryBuilder extends BaseQuery {
4
+ /**
5
+ * SELECT Expression.
6
+ */
7
+ private selectExpr?;
8
+ /**
9
+ * WHERE Expression.
10
+ */
11
+ private whereExpr?;
12
+ /**
13
+ * ORDER BY Expression.
14
+ */
15
+ private orderExpr?;
16
+ /**
17
+ * LIMIT Expression.
18
+ */
19
+ private limitExpr?;
20
+ /**
21
+ * OFFSET Expression.
22
+ */
23
+ private offSetExpr?;
24
+ /**
25
+ * LET Expression.
26
+ */
27
+ private letExpr?;
28
+ /**
29
+ * GROUP BY Expression.
30
+ */
31
+ private groupByExpr?;
32
+ /**
33
+ * LETTING Expression.
34
+ */
35
+ private lettingExpr?;
36
+ /**
37
+ * HAVING Expression.
38
+ */
39
+ private havingExpr?;
40
+ /**
41
+ * Plain JOIN Expression.
42
+ */
43
+ private plainJoinExpr?;
44
+ /**
45
+ * USE Expression.
46
+ */
47
+ private useKeysExpr?;
48
+ /**
49
+ * Available query types.
50
+ */
51
+ private queryType?;
52
+ /**
53
+ * INDEX ON Expression.
54
+ */
55
+ private indexOn?;
56
+ /**
57
+ * Types of supported index statements.
58
+ */
59
+ private indexType?;
60
+ /**
61
+ * Index name.
62
+ */
63
+ private indexName?;
64
+ /**
65
+ * INDEX USING GSI Expression.
66
+ */
67
+ private indexUsingGSI?;
68
+ /**
69
+ * INDEX USING GSI Expression.
70
+ */
71
+ private indexWith?;
72
+ /**
73
+ * @summary Create an instance of QueryBuilder.
74
+ * @name QueryBuilder
75
+ * @class
76
+ * @public
77
+ *
78
+ * @param conditions List of SELECT clause conditions
79
+ * @param collection Collection name
80
+ * @returns QueryBuilder
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const query = new QueryBuilder({$select: [{$field: 'address'}], $where: {$nill: [{ address: { $like: '%57-59%' } }, { free_breakfast: true }, { free_lunch: [1] }]}}, 'travel-sample');
85
+ * ```
86
+ */
87
+ constructor(conditions: IConditionExpr, collection: string);
88
+ /**
89
+ * Add result selectors to SELECT clause.
90
+ * @method
91
+ * @public
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const query = new QueryBuilder({}, 'travel-sample');
96
+ * const result = query.select([{$field: 'address'}]).build()
97
+ * console.log(result)
98
+ * ```
99
+ * > SELECT address FROM `travel-sample`
100
+ */
101
+ select(value?: ISelectType[] | string | undefined): QueryBuilder;
102
+ /**
103
+ * Add index type and name to INDEX clause.
104
+ * @method
105
+ * @public
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const result = new QueryBuilder({}, 'travel-sample').index('DROP', 'travel_sample_id_test').build();
110
+ * console.log(result)
111
+ * ```
112
+ * > DROP INDEX `travel-sample`.`travel_sample_id_test`
113
+ */
114
+ index(type: IndexType, name: string): QueryBuilder;
115
+ /**
116
+ * Add items to ON clause in INDEX clause.
117
+ * @method
118
+ * @public
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const on = [{ name: 'travel-sample.callsing', sort: 'ASC' }];
123
+ * const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').on(on).build();
124
+ * console.log(result)
125
+ * ```
126
+ * > CREATE INDEX `travel_sample_id_test` ON `travel-sample`(`travel-sample.callsing`['ASC'])
127
+ */
128
+ on(value: IIndexOnParams[]): QueryBuilder;
129
+ /**
130
+ * Create INDEX using General Secondary Index(GSI).
131
+ * @method
132
+ * @public
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').usingGSI().build();
137
+ * console.log(result)
138
+ * ```
139
+ * > CREATE INDEX `travel_sample_id_test` USING GSI)
140
+ */
141
+ usingGSI(): QueryBuilder;
142
+ /**
143
+ * Add items to WITH clause in INDEX clause.
144
+ * @method
145
+ * @public
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * const withExpr = {nodes: ['192.168.1.1:8078'],defer_build: true,num_replica: 2};
150
+ * const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').with(withExpr).build();
151
+ * console.log(result)
152
+ * ```
153
+ * > CREATE INDEX `travel_sample_id_test` WITH {'nodes': ['192.168.1.1:8078'],'defer_build': true,'num_replica': 2})
154
+ */
155
+ with(value: IIndexWithParams): QueryBuilder;
156
+ /**
157
+ * Add WHERE expression to SELECT clause.
158
+ * @method
159
+ * @public
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * const expr_where = {$or: [{ address: { $like: '%57-59%' } }, { free_breakfast: true }]};
164
+ * const query = new QueryBuilder({}, 'travel-sample');
165
+ * const result = query.select([{$field: 'address'}]).where(expr_where).build()
166
+ * console.log(result)
167
+ * ```
168
+ * > SELECT address FROM `travel-sample WHERE (address LIKE '%57-59%' OR free_breakfast = true)`
169
+ */
170
+ where(value: LogicalWhereExpr): QueryBuilder;
171
+ /**
172
+ * Add JOIN expression to SELECT clause.
173
+ * @method
174
+ * @public
175
+ *
176
+ * @example
177
+ * ```tS
178
+ * const query = new QueryBuilder({}, 'beer-sample brewery');
179
+ * const result = query.select([{$field: 'address'}]).plainJoin('JOIN `beer-sample` beer ON beer.brewery_id = LOWER(REPLACE(brewery.name, " ", "_"))').build()
180
+ * console.log(result)
181
+ * ```
182
+ * > SELECT address FROM `beer-sample brewery` JOIN `beer-sample` beer ON beer.brewery_id = LOWER(REPLACE(brewery.name, " ", "_")) LIMIT 1`
183
+ */
184
+ plainJoin(value: string): QueryBuilder;
185
+ /**
186
+ * Add ORDER BY expression to SELECT clause.
187
+ * @method
188
+ * @public
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * const query = new QueryBuilder({}, 'travel-sample');
193
+ * const result = query.select([{$field: 'address'}]).orderBy({ size: 'DESC' }).build()
194
+ * console.log(result)
195
+ * ```
196
+ * > SELECT address FROM `travel-sample ORDER BY size = 'DESC'`
197
+ */
198
+ orderBy(value: Record<string, SortType>): QueryBuilder;
199
+ /**
200
+ * Add LIMIT expression to SELECT clause.
201
+ * @method
202
+ * @public
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * const query = new QueryBuilder({}, 'travel-sample');
207
+ * const result = query.select([{$field: 'address'}]).limit(10).build()
208
+ * console.log(result)
209
+ * ```
210
+ * > SELECT address FROM `travel-sample LIMIT 10`
211
+ */
212
+ limit(value: number): QueryBuilder;
213
+ /**
214
+ * Add OFFSET expression to SELECT clause.
215
+ * @method
216
+ * @public
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const query = new QueryBuilder({}, 'travel-sample');
221
+ * const result = query.select([{$field: 'address'}]).offset(10).build()
222
+ * console.log(result)
223
+ * ```
224
+ * > SELECT address FROM `travel-sample OFFSET 10`
225
+ */
226
+ offset(value: number): QueryBuilder;
227
+ /**
228
+ * Add LET expression to SELECT clause.
229
+ * @method
230
+ * @public
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * const letExpr = [{ key: 'amount_val', value: 10 }];
235
+ * const query = new QueryBuilder({}, 'travel-sample');
236
+ * const result = query.select([{$field: 'address'}]).let(letExpr).build()
237
+ * console.log(result)
238
+ * ```
239
+ * > SELECT address FROM `travel-sample LET amount_val = 10`
240
+ */
241
+ let(value: ILetExpr[]): QueryBuilder;
242
+ /**
243
+ * Add GROUP BY expression to GROUP BY clause.
244
+ * @method
245
+ * @public
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
250
+ * const query = new QueryBuilder({}, 'travel-sample');
251
+ * const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).build()
252
+ * console.log(result)
253
+ * ```
254
+ * > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount`
255
+ */
256
+ groupBy(value: IGroupBy[]): QueryBuilder;
257
+ /**
258
+ * Add LETTING expression to GROUP BY clause.
259
+ * @method
260
+ * @public
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
265
+ * const letExpr = [{ key: 'amount_val', value: 10 }];
266
+ * const query = new QueryBuilder({}, 'travel-sample');
267
+ * const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).let(letExpr).build()
268
+ * console.log(result)
269
+ * ```
270
+ * > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount LETTING amount = 10`
271
+ */
272
+ letting(value: ILetExpr[]): QueryBuilder;
273
+ /**
274
+ * Add HAVING expression to GROUP BY clause.
275
+ * @method
276
+ * @public
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
281
+ * const having = {address: {$like: '%58%'}};
282
+ * const query = new QueryBuilder({}, 'travel-sample');
283
+ * const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).having(having).build()
284
+ * console.log(result)
285
+ * ```
286
+ * > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount HAVING address LIKE '%58%'`
287
+ */
288
+ having(value: LogicalWhereExpr): QueryBuilder;
289
+ /**
290
+ * Add USE KEYS expression to SELECT clause.
291
+ * @method
292
+ * @public
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * const query = new QueryBuilder({}, 'travel-sample');
297
+ * const result = query.select([{$field: 'address'}]).useKeys(['airlineR_8093']).build()
298
+ * console.log(result)
299
+ * ```
300
+ * > SELECT address FROM `travel-sample USE KEYS ['airlineR_8093']`
301
+ */
302
+ useKeys(value: string[]): QueryBuilder;
303
+ /**
304
+ * Converts the conditional parameters passed to the constructor to the properties of the N1QL QueryBuilder.
305
+ * @method
306
+ * @public
307
+ *
308
+ */
309
+ compileFromConditions(conditionals: IConditionExpr): void;
310
+ /**
311
+ * Build a n1ql query from the defined parameters.
312
+ * @method
313
+ * @public
314
+ *
315
+ */
316
+ build(): string;
317
+ get conditions(): IConditionExpr;
318
+ set conditions(value: IConditionExpr);
319
+ get collection(): string;
320
+ set collection(value: string);
321
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Convert select expression into an Array of selection keys
3
+ * */
4
+ export declare const parseStringSelectExpr: (expr: string) => string[];
5
+ /**
6
+ * @ignore
7
+ */
8
+ export declare const escapeReservedWords: (field: string) => string;
@@ -0,0 +1,17 @@
1
+ export interface CustomQueryArgs {
2
+ query: any;
3
+ limit: number;
4
+ params: any;
5
+ }
6
+ export interface CustomQueryPagination {
7
+ hasNext: boolean;
8
+ params: any;
9
+ }
10
+ /**
11
+ * Common pagination
12
+ * query,
13
+ bucketName = "",
14
+ select = ["id", "owner"] || "*"
15
+ * @param args PaginationArgs
16
+ */
17
+ export declare const CustomQuery: <T>(args: CustomQueryArgs) => Promise<[T[], CustomQueryPagination]>;
@@ -0,0 +1 @@
1
+ export * from './customQuery';
@@ -0,0 +1,27 @@
1
+ import { Request, Response } from 'express';
2
+ import { RedisPubSub } from 'graphql-redis-subscriptions';
3
+ export interface ContextType {
4
+ req: Request;
5
+ res: Response;
6
+ payload?: any;
7
+ pubsub: RedisPubSub;
8
+ }
9
+ /**
10
+ * GraphQL Types start
11
+ */
12
+ /**
13
+ * ResType
14
+ */
15
+ export declare class ResType {
16
+ success: boolean;
17
+ message?: string;
18
+ data?: any;
19
+ }
20
+ export declare class GeoType {
21
+ lat: number;
22
+ lon: number;
23
+ }
24
+ export interface GeoLocationType {
25
+ lat: number;
26
+ lon: number;
27
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ContextType.js","sourceRoot":"","sources":["../../src/shared/ContextType.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAA0D;AAC1D,wEAA4C;AAS5C;;GAEG;AAEH;;GAEG;AAEH;IAAA;IAUA,CAAC;IARG;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,OAAO,EAAP,CAAO,CAAC;4CACJ;IAGjB;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;4CACrB;IAIjB;QADC,IAAA,oBAAK,EAAC,UAAC,IAAI,IAAK,OAAA,2BAAW,EAAX,CAAW,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;yCACpC;IATF,OAAO;QADnB,IAAA,yBAAU,GAAE;OACA,OAAO,CAUnB;IAAD,cAAC;CAAA,AAVD,IAUC;AAVY,0BAAO;AAcpB;IAAA;IAMA,CAAC;IAJG;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;wCAC1B;IAGZ;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;wCAC1B;IALH,OAAO;QAFnB,IAAA,wBAAS,EAAC,cAAc,CAAC;QACzB,IAAA,yBAAU,GAAE;OACA,OAAO,CAMnB;IAAD,cAAC;CAAA,AAND,IAMC;AANY,0BAAO","sourcesContent":["import {Request, Response} from 'express';\nimport {ObjectType, Field, InputType} from 'type-graphql';\nimport GraphQLJSON from 'graphql-type-json';\nimport {RedisPubSub} from 'graphql-redis-subscriptions';\nexport interface ContextType {\n req: Request;\n res: Response;\n payload?: any;\n pubsub: RedisPubSub;\n}\n\n/**\n * GraphQL Types start\n */\n\n/**\n * ResType\n */\n@ObjectType()\nexport class ResType {\n @Field(() => Boolean)\n success: boolean;\n\n @Field(() => String, {nullable: true})\n message?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n @Field((type) => GraphQLJSON, {nullable: true})\n data?: any;\n}\n\n@InputType('GeoTypeInput')\n@ObjectType()\nexport class GeoType {\n @Field(() => Number, {nullable: true})\n lat: number;\n\n @Field(() => Number, {nullable: true})\n lon: number;\n}\n\nexport interface GeoLocationType {\n lat: number;\n lon: number;\n}\n"]}
1
+ {"version":3,"file":"ContextType.js","sourceRoot":"","sources":["../../src/shared/ContextType.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAA0D;AAC1D,wEAA4C;AAU5C;;GAEG;AAEH;;GAEG;AAEH;IAAA;IAUA,CAAC;IARG;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,OAAO,EAAP,CAAO,CAAC;4CACJ;IAGjB;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;4CACrB;IAIjB;QADC,IAAA,oBAAK,EAAC,UAAC,IAAI,IAAK,OAAA,2BAAW,EAAX,CAAW,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;yCACpC;IATF,OAAO;QADnB,IAAA,yBAAU,GAAE;OACA,OAAO,CAUnB;IAAD,cAAC;CAAA,AAVD,IAUC;AAVY,0BAAO;AAcpB;IAAA;IAMA,CAAC;IAJG;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;wCAC1B;IAGZ;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;wCAC1B;IALH,OAAO;QAFnB,IAAA,wBAAS,EAAC,cAAc,CAAC;QACzB,IAAA,yBAAU,GAAE;OACA,OAAO,CAMnB;IAAD,cAAC;CAAA,AAND,IAMC;AANY,0BAAO","sourcesContent":["import {Request, Response} from 'express';\nimport {ObjectType, Field, InputType} from 'type-graphql';\nimport GraphQLJSON from 'graphql-type-json';\nimport {RedisPubSub} from 'graphql-redis-subscriptions';\n\nexport interface ContextType {\n req: Request;\n res: Response;\n payload?: any;\n pubsub: RedisPubSub;\n}\n\n/**\n * GraphQL Types start\n */\n\n/**\n * ResType\n */\n@ObjectType()\nexport class ResType {\n @Field(() => Boolean)\n success: boolean;\n\n @Field(() => String, {nullable: true})\n message?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n @Field((type) => GraphQLJSON, {nullable: true})\n data?: any;\n}\n\n@InputType('GeoTypeInput')\n@ObjectType()\nexport class GeoType {\n @Field(() => Number, {nullable: true})\n lat: number;\n\n @Field(() => Number, {nullable: true})\n lon: number;\n}\n\nexport interface GeoLocationType {\n lat: number;\n lon: number;\n}\n"]}
@@ -0,0 +1,37 @@
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
+ interface CreateUpdate {
19
+ model: Model;
20
+ id?: string;
21
+ owner?: string;
22
+ data: any;
23
+ }
24
+ 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
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"common.model.js","sourceRoot":"","sources":["../../src/shared/common.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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AAF,wBAAE;gBACF,SAAS;gBACT,qBAAM,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,EAAA;;gBADhC,SAAS;gBACT,SAAgC,CAAC;gBACjC,sBAAO,IAAI,EAAC;oBAGI,qBAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAA;;gBAAtC,WAAW,GAAG,SAAwB;gBAC5C,sBAAO,WAAW,EAAC;;;gBAEnB,OAAO,CAAC,KAAK,CAAC,wBAAsB,KAAK,CAAC,cAAgB,EAAE,OAAK,CAAC,CAAC;gBACnE,sBAAO,IAAI,EAAC;;;;KAEnB,CAAC;AAfW,QAAA,YAAY,gBAevB;AAEF;;;;GAIG;AACI,IAAM,aAAa,GAAG,UAAI,CAAI;IAEjC;QAAA;QASA,CAAC;QAPG;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDACjB;QAGlB;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,OAAO,EAAP,CAAO,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;mDACrB;QAGlB;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,2BAAW,EAAX,CAAW,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;kDAC9B;QARX,UAAU;YADf,IAAA,yBAAU,EAAK,CAAS,CAAC,IAAI,eAAY,CAAC;WACrC,UAAU,CASf;QAAD,iBAAC;KAAA,AATD,IASC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB;AAQW,QAAA,eAAe,OAAG,qBAAG,0KAAA,sGAMjC,KAAC","sourcesContent":["import {ObjectType, Field} from 'type-graphql';\nimport GraphQLJSON from 'graphql-type-json';\nimport gql from 'graphql-tag';\nimport {Model} from '../model';\n\n@ObjectType()\nexport class CommonType {\n @Field(() => String, {nullable: true})\n id?: string;\n\n @Field(() => String, {nullable: true})\n env?: string;\n\n @Field(() => String, {nullable: true})\n owner?: string;\n\n @Field(() => Date, {nullable: true})\n createdAt?: Date;\n\n @Field(() => Date, {nullable: true})\n updatedAt?: Date;\n\n @Field(() => Boolean, {nullable: true})\n deleted?: boolean;\n}\n\nexport const CommonSchema = {\n id: String,\n env: String,\n owner: String,\n createdAt: Date,\n updatedAt: Date,\n deleted: Boolean,\n};\n\ninterface CreateUpdate {\n model: Model;\n id?: string;\n owner?: string;\n data: any;\n}\n\nexport const createUpdate = async <T>(args: CreateUpdate): Promise<T | null> => {\n const {model, id, data} = args;\n try {\n if (id) {\n // update\n await model.updateById(id, data);\n return data;\n }\n // create\n const createdItem = await model.create(data);\n return createdItem;\n } catch (error) {\n console.error(`error creating for ${model.collectionName}`, error);\n return null;\n }\n};\n\n/**\n * Creates a [className]Pagination ObjectType\n * @param c class\n * @returns\n */\nexport const getPagination = <T>(c: T): any => {\n @ObjectType(`${(c as any).name}Pagination`)\n class Pagination {\n @Field(() => [c], {nullable: true})\n items: [typeof c];\n\n @Field(() => Boolean, {nullable: true})\n hasNext?: boolean;\n\n @Field(() => GraphQLJSON, {nullable: true})\n params?: any;\n }\n return Pagination;\n};\n\nexport interface IResType {\n success: boolean;\n message?: string;\n data?: any;\n}\n\nexport const ResTypeFragment = gql`\n fragment ResTypeFragment on ResType {\n success\n message\n data\n }\n`;\n"]}
1
+ {"version":3,"file":"common.model.js","sourceRoot":"","sources":["../../src/shared/common.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+C;AAC/C,wEAA4C;AAC5C,4DAA8B;AAK9B;IAAA;IAkBA,CAAC;IAhBG;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;0CAC1B;IAGZ;QADC,IAAA,oBAAK,EAAC,cAAM,OAAA,MAAM,E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CAAC,KAAK,CAAC,wBAAsB,KAAK,CAAC,cAAgB,EAAE,OAAK,CAAC,CAAC;gBACnE,sBAAO,IAAI,EAAC;;;;KAEnB,CAAC;AAfW,QAAA,YAAY,gBAevB;AAEF;;;;GAIG;AACI,IAAM,aAAa,GAAG,UAAI,CAAI;IAEjC;QAAA;QASA,CAAC;QAPG;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDACjB;QAGlB;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,OAAO,EAAP,CAAO,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;mDACrB;QAGlB;YADC,IAAA,oBAAK,EAAC,cAAM,OAAA,2BAAW,EAAX,CAAW,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;kDAC9B;QARX,UAAU;YADf,IAAA,yBAAU,EAAK,CAAS,CAAC,IAAI,eAAY,CAAC;WACrC,UAAU,CASf;QAAD,iBAAC;KAAA,AATD,IASC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB;AAQW,QAAA,eAAe,OAAG,qBAAG,0KAAA,sGAMjC,KAAC","sourcesContent":["import {ObjectType, Field} from 'type-graphql';\nimport GraphQLJSON from 'graphql-type-json';\nimport gql from 'graphql-tag';\n\nimport {Model} from '../model';\n\n@ObjectType()\nexport class CommonType {\n @Field(() => String, {nullable: true})\n id?: string;\n\n @Field(() => String, {nullable: true})\n env?: string;\n\n @Field(() => String, {nullable: true})\n owner?: string;\n\n @Field(() => Date, {nullable: true})\n createdAt?: Date;\n\n @Field(() => Date, {nullable: true})\n updatedAt?: Date;\n\n @Field(() => Boolean, {nullable: true})\n deleted?: boolean;\n}\n\nexport const CommonSchema = {\n id: String,\n env: String,\n owner: String,\n createdAt: Date,\n updatedAt: Date,\n deleted: Boolean,\n};\n\ninterface CreateUpdate {\n model: Model;\n id?: string;\n owner?: string;\n data: any;\n}\n\nexport const createUpdate = async <T>(args: CreateUpdate): Promise<T | null> => {\n const {model, id, data} = args;\n try {\n if (id) {\n // update\n await model.updateById(id, data);\n return data;\n }\n // create\n const createdItem = await model.create(data);\n return createdItem;\n } catch (error) {\n console.error(`error creating for ${model.collectionName}`, error);\n return null;\n }\n};\n\n/**\n * Creates a [className]Pagination ObjectType\n * @param c class\n * @returns\n */\nexport const getPagination = <T>(c: T): any => {\n @ObjectType(`${(c as any).name}Pagination`)\n class Pagination {\n @Field(() => [c], {nullable: true})\n items: [typeof c];\n\n @Field(() => Boolean, {nullable: true})\n hasNext?: boolean;\n\n @Field(() => GraphQLJSON, {nullable: true})\n params?: any;\n }\n return Pagination;\n};\n\nexport interface IResType {\n success: boolean;\n message?: string;\n data?: any;\n}\n\nexport const ResTypeFragment = gql`\n fragment ResTypeFragment on ResType {\n success\n message\n data\n }\n`;\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './ContextType';
2
+ export * from './common.model';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Async await wrapper for easy error handling
3
+ * @param { Promise } promise
4
+ * @param { Object= } errorExt - Additional Information you can pass to the err object
5
+ * @return { Promise }
6
+ *
7
+ let err, user, savedTask;
8
+
9
+ [ err, user ] = await awaitTo(UserModel.findById(1));
10
+ if(!user) return cb('No user found');
11
+
12
+ [ err, savedTask ] = await awaitTo(TaskModel({userId: user.id, name: 'Demo Task'}));
13
+ if(err) return cb('Error occurred while saving task');
14
+
15
+ */
16
+ export declare function awaitTo<T, U = Error>(promise: Promise<T>, errorExt?: Record<string, any>): Promise<[U, undefined] | [null, T]>;
17
+ export default awaitTo;
@@ -0,0 +1,11 @@
1
+ interface DataWithDates {
2
+ createdAt: Date;
3
+ updatedAt: Date;
4
+ date: Date;
5
+ }
6
+ /**
7
+ * Convert date strings to data objects
8
+ * @param data
9
+ */
10
+ export declare const convertDates: (data: DataWithDates) => any;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './date';
2
+ export * from './text.utils';
3
+ export * from './utils.schema';
4
+ export * from './awaitTo';
5
+ export * from './log';
@@ -0,0 +1,9 @@
1
+ import debug from 'debug';
2
+ /**
3
+ * Use to log in general case
4
+ */
5
+ export declare const log: debug.Debugger;
6
+ /**
7
+ * Use for verbose log
8
+ */
9
+ export declare const verbose: debug.Debugger;
@@ -0,0 +1,14 @@
1
+ export declare const JSONDATA: (data: any) => Record<string, any> | string | null;
2
+ /**
3
+ * CapitalizeFirstLetter
4
+ * @param txt
5
+ * @returns
6
+ */
7
+ export declare function capText(txt: string): string;
8
+ /**
9
+ * To Snake case and in upper case
10
+ * @param txt
11
+ * @returns
12
+ */
13
+ export declare const toSnakeUpper: (txt: string) => string;
14
+ export default JSONDATA;
@@ -0,0 +1,6 @@
1
+ export declare type SchemaTypes = 'string' | 'number' | 'date' | 'object';
2
+ /**
3
+ * Convert date strings to data objects
4
+ * @param data
5
+ */
6
+ export declare const parseSchema: (schema: any, iItem: any) => any;
package/dist/uuid.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const generateUUID: () => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "couchset",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Couchbase ORM & Automatic GraphQL API(Resolver/Queries)",
5
5
  "private": false,
6
6
  "main": "dist/index.js",