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
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../src/query/helpers/builders.ts"],"names":[],"mappings":";;;AAkBA,2CAYsB;AACtB,4CAMuB;AACvB,kCAA6C;AAE7C,+BAA+B;AAC/B;;;;;;;;;;;;;KAaK;AACE,IAAM,aAAa,GAAG,UACzB,UAAkB,EAClB,MAA8B,EAC9B,OAAoB,EACpB,KAAwB,EACxB,OAAkC,EAClC,KAAc,EACd,MAAe,EACf,OAAkB,EAClB,WAAwB,EACxB,WAAwB,EACxB,UAA6B,EAC7B,aAAsB;IAEtB,IAAI;QACA,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,MAAM,CAAC;SACjB;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,IAAI,GAAG,IAAA,4BAAoB,EAAC,MAAM,CAAC,CAAC;SACvC;QACD,IAAM,WAAW,GACb,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAA,MAAK,UAAY,CAAA,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;YACtC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAChC,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,MAAK,UAAU,MAAI,CAAC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AAG,UAAC,QAA2B;IAC9C,IAAI,QAAQ,EAAE;QACV,IAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;aACnC,GAAG,CAAC,UAAC,KAAa;YACf,QAAQ,KAAK,EAAE;gBACX,KAAK,OAAO;oBACR,OAAO,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC/C,KAAK,aAAa,CAAC;gBACnB,KAAK,aAAa;oBACd,OAAO,OAAI,KAAK,YAAM,QAAQ,CAAC,KAAK,CAAG,CAAC;gBAC5C;oBACI,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAClE;QACL,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAS,UAAU,MAAG,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD;IACD,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF;;KAEK;AACL,IAAM,kBAAkB,GAAG,UAAC,aAAwB;IAChD,IAAI,aAAa,EAAE;QACf,OAAO,gBAAY,eAAe,CAAC,aAAa,CAAG,CAAC;KACvD;AACL,CAAC,CAAC;AAEF,iCAAiC","sourcesContent":["import {\n CollectionExpressionType,\n CollectionInWithinOperator,\n CollectionInWithinOperatorType,\n CollectionInWithinOperatorValue,\n CollectionSelectOperator,\n ComparisonWhereExpr,\n IField,\n IGroupBy,\n IIndexOnParams,\n IIndexWithParams,\n ILetExpr,\n IndexType,\n ISelectAggType,\n ISelectType,\n LogicalWhereExpr,\n SortType,\n} from '../interface/query.types';\nimport {\n AggDict,\n CollectionInWithinOperatorDict,\n CollectionSatisfiesOperatorDict,\n CollectionSelectOperatorDict,\n ComparisonEmptyOperatorDict,\n ComparisonMultipleOperatorDict,\n ComparisonSingleOperatorDict,\n ComparisonSingleStringOperatorDict,\n LogicalOperatorDict,\n ResultExprDict,\n ReturnResultDict,\n} from './dictionary';\nimport {\n InWithinOperatorExceptions,\n QueryGroupByParamsException,\n QueryOperatorNotFoundException,\n SelectClauseException,\n WhereClauseException,\n} from '../exceptions';\nimport {escapeReservedWords} from '../utils';\n\n// select expressions functions\n/**\n * Build a SELECT N1QL query from user-specified parameters.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/select-syntax.html}\n * @param collection Collection name\n * @param select SELECT Clause param\n * @param letExpr LET Clause param\n * @param where WHERE Clause param\n * @param orderBy ORDER BY Clause param\n * @param limit LIMIT Clause param\n * @param offset OFFSET Clause param\n * @param useExpr USE Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const selectBuilder = (\n collection: string,\n select: ISelectType[] | string,\n letExpr?: ILetExpr[],\n where?: LogicalWhereExpr,\n orderBy?: Record<string, SortType>,\n limit?: number,\n offset?: number,\n useExpr?: string[],\n groupByExpr?: IGroupBy[],\n lettingExpr?: ILetExpr[],\n havingExpr?: LogicalWhereExpr,\n plainJoinExpr?: string\n): string => {\n try {\n let expr = '';\n if (typeof select === 'string') {\n expr = select;\n }\n if (Array.isArray(select)) {\n expr = buildSelectArrayExpr(select);\n }\n const _collection =\n collection.indexOf(' ') !== -1\n ? `\\`${collection}`.replace(' ', '` ')\n : collection.indexOf('`') !== -1\n ? collection\n : `\\`${collection}\\``;\n return `SELECT ${expr} FROM ${_collection}${\n plainJoinExpr ? ` ${plainJoinExpr} ` : ''\n }${_buildUseKeysExpr(useExpr)}${_buildLetExpr(letExpr)}${buildWhereExpr(\n where\n )}${_buildGroupByExpr(groupByExpr, lettingExpr, havingExpr)}${_buildOrderByExpr(\n orderBy\n )}${_buildLimitExpr(limit)}${_buildOffsetExpr(offset)}`;\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new SelectClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildAS = (c: ISelectAggType | IField) => {\n return c.hasOwnProperty('as') ? ` AS ${c['as']}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildField = (clause: IField | string) => {\n if (clause.hasOwnProperty('name')) {\n return `${escapeReservedWords(clause['name'])}${_buildAS(clause as IField)}`;\n }\n return `${escapeReservedWords(clause as string)}`;\n};\n\n/**\n * Create N1QL queries from select array params\n * @param clause SELECT Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const buildSelectArrayExpr = (clause: ISelectType[]): string => {\n return `${clause.map((c) => buildSelectExpr('', c)).join(',')}`;\n};\n\n/**\n * Recursive function to create N1QL queries.\n * @param n1ql N1QL Query String\n * @param clause SELECT Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const buildSelectExpr = (n1ql: string, clause: ISelectType): string => {\n try {\n if (clause.hasOwnProperty('$field')) {\n return _buildField(clause['$field']);\n }\n const key = Object.keys(clause)[0];\n if (ReturnResultDict.hasOwnProperty(key)) {\n return `${ReturnResultDict[key]} ${buildSelectExpr(n1ql, clause[key])}`;\n }\n if (ResultExprDict.hasOwnProperty(key)) {\n return `${ResultExprDict[key]} ${buildSelectExpr(n1ql, clause[key])}`;\n }\n if (AggDict.hasOwnProperty(key)) {\n // todo check if have AS expr inside of Agg function.\n return `${AggDict[key]}(${_buildAggDictExpr(\n clause as ISelectAggType,\n key\n )}${buildSelectExpr(n1ql, clause[key])})${_buildAS(clause[key])}`;\n }\n throw new SelectClauseException();\n } catch {\n throw new SelectClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildAggDictExpr = (clause: ISelectAggType, key: string) => {\n if (AggDict.hasOwnProperty(key)) {\n if (clause[key].hasOwnProperty('ro')) {\n return `${ReturnResultDict[clause[key]['ro']]} `;\n }\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst _buildLetExpr = (letExpr: ILetExpr[] | undefined, clause?: string) => {\n return Array.isArray(letExpr)\n ? ` ${clause ? clause : 'LET'} ${letExpr\n .map((value: ILetExpr) => `${escapeReservedWords(value.key)}=${value.value}`)\n .join(',')}`\n : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildOrderByExpr = (orderExpr: Record<string, SortType> | undefined) => {\n return !!orderExpr\n ? ` ORDER BY ${Object.keys(orderExpr)\n .map((value: string) => `${escapeReservedWords(value)} ${orderExpr[value]}`)\n .join(',')}`\n : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildLimitExpr = (limit: number | undefined) => {\n return Number.isInteger(limit) ? ` LIMIT ${limit}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildOffsetExpr = (offset: number | undefined) => {\n return Number.isInteger(offset) ? ` OFFSET ${offset}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildUseKeysExpr = (useKeys: string[] | undefined) => {\n return Array.isArray(useKeys) ? ` USE KEYS ${stringifyValues(useKeys)}` : '';\n};\n\n// end select expression functions\n\n//group by expression functions\n/**\n *@ignore\n */\nconst _buildGroupByExpr = (\n groupByExpr?: IGroupBy[],\n lettingExpr?: ILetExpr[],\n havingExpr?: LogicalWhereExpr\n) => {\n try {\n if ((lettingExpr || havingExpr) && !groupByExpr) {\n throw new QueryGroupByParamsException();\n }\n if (!groupByExpr) {\n return '';\n }\n return ` ${_buildGroupBy(groupByExpr)}${_buildLetExpr(\n lettingExpr,\n 'LETTING'\n )}${buildWhereExpr(havingExpr as LogicalWhereExpr, 'HAVING')}`;\n } catch {\n throw new QueryGroupByParamsException();\n }\n};\n\n/**\n *@ignore\n */\nconst _buildGroupBy = (groupByExpr: IGroupBy[]) => {\n return `GROUP BY ${groupByExpr\n .map((value: IGroupBy) => {\n return `${escapeReservedWords(value.expr)}${value.as ? ` AS ${value.as}` : ''}`;\n })\n .join(',')}`;\n};\n\n//end group by expression functions\n\n// where expression functions\n\n/**\n * Create WHERE N1QL Expressions.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/where.html}\n * @param clause WHERE Clause param\n * @return N1QL WHERE Expression\n * */\nexport const buildWhereExpr = (expr: LogicalWhereExpr | undefined, clause?: string): string => {\n return expr ? ` ${clause ? clause : 'WHERE'} ${buildWhereClauseExpr('', expr)}` : '';\n};\n\n/**\n * @ignore\n *\n **/\nexport const verifyWhereObjectKey = (clause: LogicalWhereExpr) => {\n let exist = false;\n for (const key in clause) {\n if (['$and', '$or', '$not', '$any', '$$every', '$in', '$within'].includes(key)) {\n exist = true;\n break;\n }\n }\n return exist;\n};\n\n/**\n * Recursive function to create WHERE N1QL Expressions.\n * @param n1ql N1QL Query String\n * @param clause WHERE Clause param\n *\n * @return N1QL WHERE Expression\n * */\nexport const buildWhereClauseExpr = (n1ql: string, clause: LogicalWhereExpr): string => {\n try {\n if (!verifyWhereObjectKey(clause)) {\n return _buildFieldClauseExpr(\n clause as Record<string, string | number | boolean | ComparisonWhereExpr>\n );\n }\n\n return Object.keys(clause)\n .map((key) => {\n if (CollectionSelectOperatorDict[key]) {\n return `${_buildWhereCollectionExpr(\n key as CollectionSelectOperator,\n clause[key]\n )}`;\n }\n if (CollectionInWithinOperatorDict[key]) {\n return `${_buildCollectionInWithinOperator(\n key as CollectionInWithinOperator,\n clause[key]\n )}`;\n }\n if (Array.isArray(clause[key])) {\n const prefix = key === '$not' ? `${LogicalOperatorDict[key]} ` : '';\n const joinOp = key === '$not' ? ` AND ` : ` ${LogicalOperatorDict[key]} `;\n return `${prefix}(${clause[key]\n .map((value) => buildWhereClauseExpr(n1ql, value as LogicalWhereExpr))\n .join(joinOp)})`;\n } else {\n return `${buildWhereClauseExpr(n1ql, {[key]: clause[key]})}`;\n }\n })\n .join(' AND ');\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildFieldClauseExpr = (\n field: Record<string, string | number | boolean | ComparisonWhereExpr>\n) => {\n try {\n const expr = Object.keys(field).map((value: string) => {\n if (typeof field[value] === 'object' && !Array.isArray(field[value])) {\n return `${_buildComparisionClauseExpr(value, field[value] as ComparisonWhereExpr)}`;\n }\n if (!value.includes('$')) {\n if (typeof field[value] === 'string') {\n return `${escapeReservedWords(value)}=${stringifyValues(field[value])}`;\n }\n if (\n typeof field[value] === 'number' ||\n typeof field[value] === 'boolean' ||\n Array.isArray(field[value])\n ) {\n return `${escapeReservedWords(value)}=${stringifyValues(field[value])}`;\n }\n }\n throw new QueryOperatorNotFoundException(value);\n });\n return expr.join(' AND ');\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildComparisionClauseExpr = (fieldName: string, comparison: ComparisonWhereExpr) => {\n try {\n const expr = Object.keys(comparison)\n .map((value: string) => {\n if (!!comparison[value]) {\n if (ComparisonEmptyOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonEmptyOperatorDict[value]\n }`;\n }\n if (ComparisonSingleOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)}${\n ComparisonSingleOperatorDict[value]\n }${stringifyValues(comparison[value])}`;\n }\n if (ComparisonSingleStringOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonSingleStringOperatorDict[value]\n } ${stringifyValues(comparison[value])}`;\n }\n if (\n ComparisonMultipleOperatorDict.hasOwnProperty(value) &&\n Array.isArray(comparison[value])\n ) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonMultipleOperatorDict[value]\n } ${comparison[value].map((v) => stringifyValues(v)).join(' AND ')}`;\n }\n }\n throw new QueryOperatorNotFoundException(value);\n })\n .join(` AND `);\n return Object.keys(comparison).length > 1 ? `(${expr})` : expr;\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildCollectionInWithinOperator = (\n op: CollectionInWithinOperator,\n expr: CollectionInWithinOperatorValue,\n excludeOperator?: boolean\n): string => {\n if (!op || !expr.target_expr || !expr.search_expr) {\n throw new InWithinOperatorExceptions();\n }\n return `${expr.search_expr}${!excludeOperator && expr.$not ? ' NOT ' : ' '}${\n CollectionInWithinOperatorDict[op]\n } ${excludeOperator ? expr.target_expr : stringifyValues(expr.target_expr)}`;\n};\n\nconst stringifyValues = (value: unknown) => {\n return JSON.stringify(value).replace(/\\\\/gi, '');\n};\n\n/**\n * @ignore\n * */\nconst _buildCollectionInWithIn = (collection: CollectionInWithinOperatorType) => {\n const op = collection.$in ? '$in' : collection.$within ? '$within' : undefined;\n if (!op) {\n throw new Error(\n 'The Collection Operator needs to have the following clauses declared (IN | WITHIN) and SATISFIES.'\n );\n }\n return `${_buildCollectionInWithinOperator(\n op,\n collection[op] as CollectionInWithinOperatorValue,\n true\n )}`;\n};\n\n/**\n * @ignore\n * */\nconst _buildWhereCollectionExpr = (\n op: CollectionSelectOperator,\n expr: CollectionExpressionType\n) => {\n return `${CollectionSelectOperatorDict[op]} ${expr.$expr\n .map((value) => _buildCollectionInWithIn(value))\n .join(',')} ${CollectionSatisfiesOperatorDict['$satisfies']} ${buildWhereClauseExpr(\n '',\n expr.$satisfied\n )} END`;\n};\n\n// end where expression functions\n\n// index expression functions\n\n/**\n * Build a INDEX N1QL query from user-specified parameters.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/createindex.html}\n * @param collection Collection name\n * @param type INDEX clause types can be 'CREATE' | 'BUILD' | 'DROP' | 'CREATE PRIMARY'\n * @param on ON Clause param\n * @param where WHERE Clause param\n * @param usingGSI use a Global Secondary Index(GSI).\n * @param withExpr WITH Clause param\n *\n * @return N1QL INDEX Query\n * */\nexport const buildIndexExpr = (\n collection: string,\n type: IndexType,\n name: string,\n on?: IIndexOnParams[],\n where?: LogicalWhereExpr,\n usingGSI?: boolean,\n withExpr?: IIndexWithParams\n): string => {\n if (['BUILD', 'CREATE', 'CREATE PRIMARY'].includes(type) && on) {\n return `${type} INDEX \\`${name}\\` ON \\`${collection}\\`(${buildOnExpr(on)})${buildWhereExpr(\n where\n )} ${usingGSI ? 'USING GSI' : ''} ${buildWithExpr(withExpr)}`;\n } else {\n return `${type} INDEX \\`${collection}\\`.\\`${name}\\`${usingGSI ? ' USING GSI' : ''}`;\n }\n};\n\n/**\n * @ignore\n * */\nconst buildOnExpr = (on: IIndexOnParams[]) => {\n return on\n .map((value: IIndexOnParams) => {\n return `${escapeReservedWords(value.name)}${buildOnSortExpr(value)}`;\n })\n .join(',');\n};\n\n/**\n * @ignore\n * */\nconst buildOnSortExpr = (onExpr?: IIndexOnParams) => {\n if (onExpr && onExpr.hasOwnProperty('sort')) {\n return `[\"${onExpr.sort}\"]`;\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst buildWithExpr = (withExpr?: IIndexWithParams) => {\n if (withExpr) {\n const resultExpr = Object.keys(withExpr)\n .map((value: string) => {\n switch (value) {\n case 'nodes':\n return buildWithNodesExpr(withExpr[value]);\n case 'defer_build':\n case 'num_replica':\n return `\"${value}\": ${withExpr[value]}`;\n default:\n throw new Error('The WITH clause has an incorrect syntax');\n }\n })\n .join(',');\n return !!resultExpr ? `WITH {${resultExpr}}` : '';\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst buildWithNodesExpr = (withNodesExpr?: string[]) => {\n if (withNodesExpr) {\n return `\"nodes\": ${stringifyValues(withNodesExpr)}`;\n }\n};\n\n// end index expression functions\n"]}
1
+ {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../src/query/helpers/builders.ts"],"names":[],"mappings":";;;AAkBA,4CAMuB;AACvB,kCAA6C;AAE7C,2CAYsB;AAEtB,+BAA+B;AAC/B;;;;;;;;;;;;;KAaK;AACE,IAAM,aAAa,GAAG,UACzB,UAAkB,EAClB,MAA8B,EAC9B,OAAoB,EACpB,KAAwB,EACxB,OAAkC,EAClC,KAAc,EACd,MAAe,EACf,OAAkB,EAClB,WAAwB,EACxB,WAAwB,EACxB,UAA6B,EAC7B,aAAsB;IAEtB,IAAI;QACA,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,MAAM,CAA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ator,\n CollectionInWithinOperatorType,\n CollectionInWithinOperatorValue,\n CollectionSelectOperator,\n ComparisonWhereExpr,\n IField,\n IGroupBy,\n IIndexOnParams,\n IIndexWithParams,\n ILetExpr,\n IndexType,\n ISelectAggType,\n ISelectType,\n LogicalWhereExpr,\n SortType,\n} from '../interface/query.types';\nimport {\n InWithinOperatorExceptions,\n QueryGroupByParamsException,\n QueryOperatorNotFoundException,\n SelectClauseException,\n WhereClauseException,\n} from '../exceptions';\nimport {escapeReservedWords} from '../utils';\n\nimport {\n AggDict,\n CollectionInWithinOperatorDict,\n CollectionSatisfiesOperatorDict,\n CollectionSelectOperatorDict,\n ComparisonEmptyOperatorDict,\n ComparisonMultipleOperatorDict,\n ComparisonSingleOperatorDict,\n ComparisonSingleStringOperatorDict,\n LogicalOperatorDict,\n ResultExprDict,\n ReturnResultDict,\n} from './dictionary';\n\n// select expressions functions\n/**\n * Build a SELECT N1QL query from user-specified parameters.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/select-syntax.html}\n * @param collection Collection name\n * @param select SELECT Clause param\n * @param letExpr LET Clause param\n * @param where WHERE Clause param\n * @param orderBy ORDER BY Clause param\n * @param limit LIMIT Clause param\n * @param offset OFFSET Clause param\n * @param useExpr USE Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const selectBuilder = (\n collection: string,\n select: ISelectType[] | string,\n letExpr?: ILetExpr[],\n where?: LogicalWhereExpr,\n orderBy?: Record<string, SortType>,\n limit?: number,\n offset?: number,\n useExpr?: string[],\n groupByExpr?: IGroupBy[],\n lettingExpr?: ILetExpr[],\n havingExpr?: LogicalWhereExpr,\n plainJoinExpr?: string\n): string => {\n try {\n let expr = '';\n if (typeof select === 'string') {\n expr = select;\n }\n if (Array.isArray(select)) {\n expr = buildSelectArrayExpr(select);\n }\n const _collection =\n collection.indexOf(' ') !== -1\n ? `\\`${collection}`.replace(' ', '` ')\n : collection.indexOf('`') !== -1\n ? collection\n : `\\`${collection}\\``;\n return `SELECT ${expr} FROM ${_collection}${\n plainJoinExpr ? ` ${plainJoinExpr} ` : ''\n }${_buildUseKeysExpr(useExpr)}${_buildLetExpr(letExpr)}${buildWhereExpr(\n where\n )}${_buildGroupByExpr(groupByExpr, lettingExpr, havingExpr)}${_buildOrderByExpr(\n orderBy\n )}${_buildLimitExpr(limit)}${_buildOffsetExpr(offset)}`;\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new SelectClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildAS = (c: ISelectAggType | IField) => {\n return c.hasOwnProperty('as') ? ` AS ${c['as']}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildField = (clause: IField | string) => {\n if (clause.hasOwnProperty('name')) {\n return `${escapeReservedWords(clause['name'])}${_buildAS(clause as IField)}`;\n }\n return `${escapeReservedWords(clause as string)}`;\n};\n\n/**\n * Create N1QL queries from select array params\n * @param clause SELECT Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const buildSelectArrayExpr = (clause: ISelectType[]): string => {\n return `${clause.map((c) => buildSelectExpr('', c)).join(',')}`;\n};\n\n/**\n * Recursive function to create N1QL queries.\n * @param n1ql N1QL Query String\n * @param clause SELECT Clause param\n *\n * @return N1QL SELECT Query\n * */\nexport const buildSelectExpr = (n1ql: string, clause: ISelectType): string => {\n try {\n if (clause.hasOwnProperty('$field')) {\n return _buildField(clause['$field']);\n }\n const key = Object.keys(clause)[0];\n if (ReturnResultDict.hasOwnProperty(key)) {\n return `${ReturnResultDict[key]} ${buildSelectExpr(n1ql, clause[key])}`;\n }\n if (ResultExprDict.hasOwnProperty(key)) {\n return `${ResultExprDict[key]} ${buildSelectExpr(n1ql, clause[key])}`;\n }\n if (AggDict.hasOwnProperty(key)) {\n // todo check if have AS expr inside of Agg function.\n return `${AggDict[key]}(${_buildAggDictExpr(\n clause as ISelectAggType,\n key\n )}${buildSelectExpr(n1ql, clause[key])})${_buildAS(clause[key])}`;\n }\n throw new SelectClauseException();\n } catch {\n throw new SelectClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildAggDictExpr = (clause: ISelectAggType, key: string) => {\n if (AggDict.hasOwnProperty(key)) {\n if (clause[key].hasOwnProperty('ro')) {\n return `${ReturnResultDict[clause[key]['ro']]} `;\n }\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst _buildLetExpr = (letExpr: ILetExpr[] | undefined, clause?: string) => {\n return Array.isArray(letExpr)\n ? ` ${clause ? clause : 'LET'} ${letExpr\n .map((value: ILetExpr) => `${escapeReservedWords(value.key)}=${value.value}`)\n .join(',')}`\n : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildOrderByExpr = (orderExpr: Record<string, SortType> | undefined) => {\n return !!orderExpr\n ? ` ORDER BY ${Object.keys(orderExpr)\n .map((value: string) => `${escapeReservedWords(value)} ${orderExpr[value]}`)\n .join(',')}`\n : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildLimitExpr = (limit: number | undefined) => {\n return Number.isInteger(limit) ? ` LIMIT ${limit}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildOffsetExpr = (offset: number | undefined) => {\n return Number.isInteger(offset) ? ` OFFSET ${offset}` : '';\n};\n\n/**\n * @ignore\n * */\nconst _buildUseKeysExpr = (useKeys: string[] | undefined) => {\n return Array.isArray(useKeys) ? ` USE KEYS ${stringifyValues(useKeys)}` : '';\n};\n\n// end select expression functions\n\n//group by expression functions\n/**\n *@ignore\n */\nconst _buildGroupByExpr = (\n groupByExpr?: IGroupBy[],\n lettingExpr?: ILetExpr[],\n havingExpr?: LogicalWhereExpr\n) => {\n try {\n if ((lettingExpr || havingExpr) && !groupByExpr) {\n throw new QueryGroupByParamsException();\n }\n if (!groupByExpr) {\n return '';\n }\n return ` ${_buildGroupBy(groupByExpr)}${_buildLetExpr(\n lettingExpr,\n 'LETTING'\n )}${buildWhereExpr(havingExpr as LogicalWhereExpr, 'HAVING')}`;\n } catch {\n throw new QueryGroupByParamsException();\n }\n};\n\n/**\n *@ignore\n */\nconst _buildGroupBy = (groupByExpr: IGroupBy[]) => {\n return `GROUP BY ${groupByExpr\n .map((value: IGroupBy) => {\n return `${escapeReservedWords(value.expr)}${value.as ? ` AS ${value.as}` : ''}`;\n })\n .join(',')}`;\n};\n\n//end group by expression functions\n\n// where expression functions\n\n/**\n * Create WHERE N1QL Expressions.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/where.html}\n * @param clause WHERE Clause param\n * @return N1QL WHERE Expression\n * */\nexport const buildWhereExpr = (expr: LogicalWhereExpr | undefined, clause?: string): string => {\n return expr ? ` ${clause ? clause : 'WHERE'} ${buildWhereClauseExpr('', expr)}` : '';\n};\n\n/**\n * @ignore\n *\n **/\nexport const verifyWhereObjectKey = (clause: LogicalWhereExpr) => {\n let exist = false;\n for (const key in clause) {\n if (['$and', '$or', '$not', '$any', '$$every', '$in', '$within'].includes(key)) {\n exist = true;\n break;\n }\n }\n return exist;\n};\n\n/**\n * Recursive function to create WHERE N1QL Expressions.\n * @param n1ql N1QL Query String\n * @param clause WHERE Clause param\n *\n * @return N1QL WHERE Expression\n * */\nexport const buildWhereClauseExpr = (n1ql: string, clause: LogicalWhereExpr): string => {\n try {\n if (!verifyWhereObjectKey(clause)) {\n return _buildFieldClauseExpr(\n clause as Record<string, string | number | boolean | ComparisonWhereExpr>\n );\n }\n\n return Object.keys(clause)\n .map((key) => {\n if (CollectionSelectOperatorDict[key]) {\n return `${_buildWhereCollectionExpr(\n key as CollectionSelectOperator,\n clause[key]\n )}`;\n }\n if (CollectionInWithinOperatorDict[key]) {\n return `${_buildCollectionInWithinOperator(\n key as CollectionInWithinOperator,\n clause[key]\n )}`;\n }\n if (Array.isArray(clause[key])) {\n const prefix = key === '$not' ? `${LogicalOperatorDict[key]} ` : '';\n const joinOp = key === '$not' ? ` AND ` : ` ${LogicalOperatorDict[key]} `;\n return `${prefix}(${clause[key]\n .map((value) => buildWhereClauseExpr(n1ql, value as LogicalWhereExpr))\n .join(joinOp)})`;\n } else {\n return `${buildWhereClauseExpr(n1ql, {[key]: clause[key]})}`;\n }\n })\n .join(' AND ');\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildFieldClauseExpr = (\n field: Record<string, string | number | boolean | ComparisonWhereExpr>\n) => {\n try {\n const expr = Object.keys(field).map((value: string) => {\n if (typeof field[value] === 'object' && !Array.isArray(field[value])) {\n return `${_buildComparisionClauseExpr(value, field[value] as ComparisonWhereExpr)}`;\n }\n if (!value.includes('$')) {\n if (typeof field[value] === 'string') {\n return `${escapeReservedWords(value)}=${stringifyValues(field[value])}`;\n }\n if (\n typeof field[value] === 'number' ||\n typeof field[value] === 'boolean' ||\n Array.isArray(field[value])\n ) {\n return `${escapeReservedWords(value)}=${stringifyValues(field[value])}`;\n }\n }\n throw new QueryOperatorNotFoundException(value);\n });\n return expr.join(' AND ');\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildComparisionClauseExpr = (fieldName: string, comparison: ComparisonWhereExpr) => {\n try {\n const expr = Object.keys(comparison)\n .map((value: string) => {\n if (!!comparison[value]) {\n if (ComparisonEmptyOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonEmptyOperatorDict[value]\n }`;\n }\n if (ComparisonSingleOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)}${\n ComparisonSingleOperatorDict[value]\n }${stringifyValues(comparison[value])}`;\n }\n if (ComparisonSingleStringOperatorDict.hasOwnProperty(value)) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonSingleStringOperatorDict[value]\n } ${stringifyValues(comparison[value])}`;\n }\n if (\n ComparisonMultipleOperatorDict.hasOwnProperty(value) &&\n Array.isArray(comparison[value])\n ) {\n return `${escapeReservedWords(fieldName)} ${\n ComparisonMultipleOperatorDict[value]\n } ${comparison[value].map((v) => stringifyValues(v)).join(' AND ')}`;\n }\n }\n throw new QueryOperatorNotFoundException(value);\n })\n .join(` AND `);\n return Object.keys(comparison).length > 1 ? `(${expr})` : expr;\n } catch (exception) {\n if (exception instanceof WhereClauseException) {\n throw exception;\n }\n throw new WhereClauseException();\n }\n};\n\n/**\n * @ignore\n * */\nconst _buildCollectionInWithinOperator = (\n op: CollectionInWithinOperator,\n expr: CollectionInWithinOperatorValue,\n excludeOperator?: boolean\n): string => {\n if (!op || !expr.target_expr || !expr.search_expr) {\n throw new InWithinOperatorExceptions();\n }\n return `${expr.search_expr}${!excludeOperator && expr.$not ? ' NOT ' : ' '}${\n CollectionInWithinOperatorDict[op]\n } ${excludeOperator ? expr.target_expr : stringifyValues(expr.target_expr)}`;\n};\n\nconst stringifyValues = (value: unknown) => {\n return JSON.stringify(value).replace(/\\\\/gi, '');\n};\n\n/**\n * @ignore\n * */\nconst _buildCollectionInWithIn = (collection: CollectionInWithinOperatorType) => {\n const op = collection.$in ? '$in' : collection.$within ? '$within' : undefined;\n if (!op) {\n throw new Error(\n 'The Collection Operator needs to have the following clauses declared (IN | WITHIN) and SATISFIES.'\n );\n }\n return `${_buildCollectionInWithinOperator(\n op,\n collection[op] as CollectionInWithinOperatorValue,\n true\n )}`;\n};\n\n/**\n * @ignore\n * */\nconst _buildWhereCollectionExpr = (\n op: CollectionSelectOperator,\n expr: CollectionExpressionType\n) => {\n return `${CollectionSelectOperatorDict[op]} ${expr.$expr\n .map((value) => _buildCollectionInWithIn(value))\n .join(',')} ${CollectionSatisfiesOperatorDict['$satisfies']} ${buildWhereClauseExpr(\n '',\n expr.$satisfied\n )} END`;\n};\n\n// end where expression functions\n\n// index expression functions\n\n/**\n * Build a INDEX N1QL query from user-specified parameters.\n * {@link https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/createindex.html}\n * @param collection Collection name\n * @param type INDEX clause types can be 'CREATE' | 'BUILD' | 'DROP' | 'CREATE PRIMARY'\n * @param on ON Clause param\n * @param where WHERE Clause param\n * @param usingGSI use a Global Secondary Index(GSI).\n * @param withExpr WITH Clause param\n *\n * @return N1QL INDEX Query\n * */\nexport const buildIndexExpr = (\n collection: string,\n type: IndexType,\n name: string,\n on?: IIndexOnParams[],\n where?: LogicalWhereExpr,\n usingGSI?: boolean,\n withExpr?: IIndexWithParams\n): string => {\n if (['BUILD', 'CREATE', 'CREATE PRIMARY'].includes(type) && on) {\n return `${type} INDEX \\`${name}\\` ON \\`${collection}\\`(${buildOnExpr(on)})${buildWhereExpr(\n where\n )} ${usingGSI ? 'USING GSI' : ''} ${buildWithExpr(withExpr)}`;\n } else {\n return `${type} INDEX \\`${collection}\\`.\\`${name}\\`${usingGSI ? ' USING GSI' : ''}`;\n }\n};\n\n/**\n * @ignore\n * */\nconst buildOnExpr = (on: IIndexOnParams[]) => {\n return on\n .map((value: IIndexOnParams) => {\n return `${escapeReservedWords(value.name)}${buildOnSortExpr(value)}`;\n })\n .join(',');\n};\n\n/**\n * @ignore\n * */\nconst buildOnSortExpr = (onExpr?: IIndexOnParams) => {\n if (onExpr && onExpr.hasOwnProperty('sort')) {\n return `[\"${onExpr.sort}\"]`;\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst buildWithExpr = (withExpr?: IIndexWithParams) => {\n if (withExpr) {\n const resultExpr = Object.keys(withExpr)\n .map((value: string) => {\n switch (value) {\n case 'nodes':\n return buildWithNodesExpr(withExpr[value]);\n case 'defer_build':\n case 'num_replica':\n return `\"${value}\": ${withExpr[value]}`;\n default:\n throw new Error('The WITH clause has an incorrect syntax');\n }\n })\n .join(',');\n return !!resultExpr ? `WITH {${resultExpr}}` : '';\n }\n return '';\n};\n\n/**\n * @ignore\n * */\nconst buildWithNodesExpr = (withNodesExpr?: string[]) => {\n if (withNodesExpr) {\n return `\"nodes\": ${stringifyValues(withNodesExpr)}`;\n }\n};\n\n// end index expression functions\n"]}
@@ -0,0 +1,45 @@
1
+ import { AggType, CollectionSelectOperator, CollectionInWithinOperator, ComparisonEmptyOperatorType, ComparisonMultipleOperatorType, ComparisonSingleOperatorType, ComparisonSingleStringOperatorType, LogicalOperatorType, ResultExprType, ReturnResultType, CollectionSatisfiesOperator } from '../interface/query.types';
2
+ /**
3
+ * Dictionary for handling aggregation functions.
4
+ * */
5
+ export declare const AggDict: Record<AggType, string>;
6
+ /**
7
+ * Dictionary for handling result expressions RAW | ELEMENT | VALUE
8
+ * */
9
+ export declare const ResultExprDict: Record<ResultExprType, string>;
10
+ /**
11
+ * Dictionary for handling result expressions ALL | DISTINCT
12
+ * */
13
+ export declare const ReturnResultDict: Record<ReturnResultType, string>;
14
+ /**
15
+ * Dictionary for handling Boolean comparison operators
16
+ * */
17
+ export declare const ComparisonEmptyOperatorDict: Record<ComparisonEmptyOperatorType, string>;
18
+ /**
19
+ * Dictionary for handling Numeric comparison operators
20
+ * */
21
+ export declare const ComparisonSingleOperatorDict: Record<ComparisonSingleOperatorType, string>;
22
+ /**
23
+ * Dictionary for handling String comparison operators
24
+ * */
25
+ export declare const ComparisonSingleStringOperatorDict: Record<ComparisonSingleStringOperatorType, string>;
26
+ /**
27
+ * Dictionary for handling Range comparison operators
28
+ * */
29
+ export declare const ComparisonMultipleOperatorDict: Record<ComparisonMultipleOperatorType, string>;
30
+ /**
31
+ * Dictionary for handling logical operators
32
+ * */
33
+ export declare const LogicalOperatorDict: Record<LogicalOperatorType, string>;
34
+ /**
35
+ * Dictionary for handling collection select operators
36
+ * */
37
+ export declare const CollectionSelectOperatorDict: Record<CollectionSelectOperator, string>;
38
+ /**
39
+ * Dictionary for handling collection (in | within) operators
40
+ * */
41
+ export declare const CollectionInWithinOperatorDict: Record<CollectionInWithinOperator, string>;
42
+ /**
43
+ * Dictionary for handling collection satisfies operators
44
+ * */
45
+ export declare const CollectionSatisfiesOperatorDict: Record<CollectionSatisfiesOperator, string>;
@@ -0,0 +1,3 @@
1
+ export { selectBuilder, buildSelectExpr, buildWhereClauseExpr, buildIndexExpr, buildSelectArrayExpr, } from './builders';
2
+ export { AggDict, ResultExprDict, ReturnResultDict } from './dictionary';
3
+ export { n1qlReservedWords } from './reservedWords';
@@ -0,0 +1 @@
1
+ export declare const n1qlReservedWords: string[];
@@ -0,0 +1,5 @@
1
+ export { selectBuilder, buildSelectExpr, buildWhereClauseExpr, buildIndexExpr, buildSelectArrayExpr, AggDict, ResultExprDict, ReturnResultDict, } from './helpers';
2
+ export { SelectClauseException, MultipleQueryTypesException, WhereClauseException, QueryOperatorNotFoundException, IndexParamsUsingGSIExceptions, InWithinOperatorExceptions, QueryGroupByParamsException, IndexParamsOnExceptions, } from './exceptions';
3
+ export { QueryBuilder } from './query';
4
+ export { ILetExpr, SortType, ISelectType, LogicalWhereExpr, ComparisonWhereExpr, IField, IIndexOnParams, IIndexWithParams, IndexType, ISelectAggType, AggType, ComparisonEmptyOperatorType, ComparisonMultipleOperatorType, ComparisonSingleStringOperatorType, ComparisonSingleOperatorType, LogicalOperatorType, ResultExprType, ReturnResultType, } from './interface/query.types';
5
+ export { parseStringSelectExpr, escapeReservedWords } from './utils';
@@ -0,0 +1,236 @@
1
+ export declare type SortType = 'ASC' | 'DESC';
2
+ /**
3
+ * Result expressions ALL | DISTINCT
4
+ * */
5
+ export declare type ReturnResultType = '$all' | '$distinct';
6
+ /**
7
+ * Result expressions RAW | ELEMENT | VALUE
8
+ * */
9
+ export declare type ResultExprType = '$raw' | '$element' | '$value';
10
+ /**
11
+ * List of aggregation functions.
12
+ * */
13
+ export declare type AggType = '$arrayAgg' | '$avg' | '$mean' | '$count' | '$countn' | '$max' | '$median' | '$min' | '$stddev' | '$stddevPop' | '$stddevSamp' | '$sum' | '$variance' | '$variancePop' | '$varianceSamp' | '$varPop' | '$varSamp';
14
+ /**
15
+ * List of Boolean comparison operators.
16
+ * */
17
+ export declare type ComparisonEmptyOperatorType = '$isNull' | '$isNotNull' | '$isMissing' | '$isNotMissing' | '$isValued' | '$isNotValued';
18
+ /**
19
+ * List of Numeric comparison operators.
20
+ * */
21
+ export declare type ComparisonSingleOperatorType = '$eq' | '$neq' | '$gt' | '$gte' | '$lt' | '$lte';
22
+ /**
23
+ * List of String comparison operators.
24
+ * */
25
+ export declare type ComparisonSingleStringOperatorType = '$like' | '$notLike';
26
+ /**
27
+ * List of Range comparison operators.
28
+ * */
29
+ export declare type ComparisonMultipleOperatorType = '$btw' | '$notBtw';
30
+ /**
31
+ * List of Logical operators.
32
+ * */
33
+ export declare type LogicalOperatorType = '$and' | '$or' | '$not';
34
+ /**
35
+ * Collection Select Operator.
36
+ * */
37
+ export declare type CollectionSelectOperator = '$any' | '$every';
38
+ /**
39
+ * Collection IN and WITHIN Operators.
40
+ * */
41
+ export declare type CollectionInWithinOperator = '$in' | '$within';
42
+ /**
43
+ * List of Collection IN and WITHIN Operators.
44
+ * */
45
+ export declare type CollectionSatisfiesOperator = '$satisfies';
46
+ export interface CollectionInWithinOperatorValue {
47
+ search_expr: unknown;
48
+ target_expr: unknown;
49
+ $not?: boolean;
50
+ }
51
+ /**
52
+ * Structure of the collection in within operator
53
+ *
54
+ * @example
55
+ * ```
56
+ * {$in:{search_expr: 'search', target_expr: 'address', $not: true}}
57
+ * ```
58
+ * */
59
+ export declare type CollectionInWithinOperatorType = {
60
+ [key in CollectionInWithinOperator]?: CollectionInWithinOperatorValue;
61
+ };
62
+ /**
63
+ * Structure of the collection expression
64
+ *
65
+ * */
66
+ export interface CollectionExpressionType {
67
+ $expr: CollectionInWithinOperatorType[];
68
+ $satisfied: FieldWhereExpr;
69
+ }
70
+ /**
71
+ * Structure of the collection in within operator
72
+ *
73
+ * @example
74
+ * ```
75
+ * {$any: {$expr: [{$in:{search_expr: 'search', target_expr: 'address', $not: true} }], $satisfied:{address: '10'}}}
76
+ * ```
77
+ * */
78
+ export declare type CollectionSelectOperatorType = {
79
+ [key in CollectionSelectOperator]?: CollectionExpressionType;
80
+ };
81
+ /**
82
+ * Structure of the comparison operators.
83
+ *
84
+ * @example
85
+ * ```
86
+ * {operator: value} -> e.g { $like: '%ottoman%'}
87
+ * ```
88
+ *
89
+ * */
90
+ export declare type ComparisonWhereExpr = {
91
+ [key in ComparisonEmptyOperatorType | ComparisonSingleOperatorType | ComparisonMultipleOperatorType | ComparisonSingleStringOperatorType]?: string | number | boolean | (number | string)[];
92
+ };
93
+ /**
94
+ * Structure of WHERE field expression
95
+ *
96
+ * @example
97
+ * ```
98
+ * {field: {operator: value}} -> e.g { address: {$like: '%ottoman%'}} | {$or: [{ address: {$like: '%ottoman%'}}]}
99
+ * ```
100
+ *
101
+ * */
102
+ export declare type FieldWhereExpr = Record<string, string | number | boolean | ComparisonWhereExpr> | LogicalWhereExpr;
103
+ /**
104
+ * Structure of Logical WHERE expression
105
+ *
106
+ * @example
107
+ * ```
108
+ * {field: {operator: value}} -> e.g {$or: [{ address: {$like: '%ottoman%'}}]}
109
+ * ```
110
+ *
111
+ * */
112
+ export declare type LogicalWhereExpr = {
113
+ [key in LogicalOperatorType]?: FieldWhereExpr[];
114
+ } | {
115
+ [key: string]: FieldWhereExpr;
116
+ } | {
117
+ [key: string]: unknown;
118
+ } | CollectionSelectOperatorType | CollectionInWithinOperatorType;
119
+ /**
120
+ * SELECT field structure
121
+ *
122
+ * @example
123
+ * ```
124
+ * e.g { name: 'address', as: 'addr'}
125
+ * ```
126
+ *
127
+ * */
128
+ export interface IField {
129
+ name: string;
130
+ as?: string;
131
+ }
132
+ /**
133
+ * SELECT aggregation expression
134
+ *
135
+ * @example
136
+ * ```
137
+ * {$count: {$field: {name: 'address'}, as: 'addr'}} | {$count: {$field: 'address'}}
138
+ * ```
139
+ *
140
+ * */
141
+ export declare type ISelectAggType = {
142
+ [key in AggType]?: ISelectFieldType;
143
+ };
144
+ /**
145
+ * SELECT field expression
146
+ *
147
+ * @example
148
+ * ```
149
+ * {$field: {name: 'address'}, as: 'addr'}
150
+ * ```
151
+ *
152
+ * */
153
+ export interface ISelectFieldType {
154
+ $field: IField | string;
155
+ as?: string;
156
+ ro?: ReturnResultType;
157
+ }
158
+ /**
159
+ * SELECT result expression
160
+ *
161
+ * @example
162
+ * ```
163
+ * {$raw: {$field: {name: 'address'}, as: 'addr'}}
164
+ * ```
165
+ *
166
+ * */
167
+ export declare type ISelectResultExprType = {
168
+ [key in ResultExprType]?: ISelectAggType | ISelectFieldType;
169
+ };
170
+ /**
171
+ * SELECT result expression
172
+ *
173
+ * @example
174
+ * ```
175
+ * {$all: {$field: {name: 'address'}, as: 'addr'}}
176
+ * ```
177
+ *
178
+ * */
179
+ export declare type ISelectReturnResultType = {
180
+ [key in ReturnResultType]?: ISelectResultExprType | ISelectAggType | ISelectFieldType;
181
+ };
182
+ /**
183
+ * SELECT expression
184
+ *
185
+ * @example
186
+ * ```
187
+ * {$all: {$field: {name: 'address'}, as: 'addr'}, $field: 'type', $field: {name: 'count'}}
188
+ * ```
189
+ *
190
+ * */
191
+ export declare type ISelectType = ISelectReturnResultType | ISelectResultExprType | ISelectAggType | ISelectFieldType;
192
+ /**
193
+ * LET expression
194
+ * */
195
+ export interface ILetExpr {
196
+ key: string;
197
+ value: unknown;
198
+ }
199
+ export interface IGroupBy {
200
+ expr: string;
201
+ as?: string;
202
+ }
203
+ /**
204
+ * List of params to build a SELECT clause
205
+ * */
206
+ export interface IConditionExpr {
207
+ select?: ISelectType[] | string;
208
+ let?: ILetExpr[];
209
+ where?: LogicalWhereExpr;
210
+ orderBy?: Record<string, SortType>;
211
+ limit?: number;
212
+ offset?: number;
213
+ use?: string[];
214
+ groupBy?: IGroupBy[];
215
+ letting?: ILetExpr[];
216
+ having?: LogicalWhereExpr;
217
+ }
218
+ /**
219
+ * Types of supported index statements
220
+ * */
221
+ export declare type IndexType = 'CREATE' | 'BUILD' | 'DROP' | 'CREATE PRIMARY';
222
+ /**
223
+ * Index ON clause types
224
+ * */
225
+ export interface IIndexOnParams {
226
+ name: string;
227
+ sort?: SortType;
228
+ }
229
+ /**
230
+ * Index WITH clause
231
+ * */
232
+ export interface IIndexWithParams {
233
+ nodes?: string[];
234
+ defer_build?: boolean;
235
+ num_replica?: number;
236
+ }
@@ -0,0 +1,14 @@
1
+ import { QueryResult } from 'couchbase';
2
+ /**
3
+ * Query couchbase db
4
+ * @param query
5
+ *
6
+ const query = `
7
+ SELECT airportname, city FROM \`travel-sample\`
8
+ WHERE type=$1
9
+ AND city=$2
10
+ `;
11
+ const options = {parameters: ['airport', 'San Jose']};
12
+ * @param options
13
+ */
14
+ export declare function QueryCluster(query: string, options?: any): Promise<QueryResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"query.cluster.js","sourceRoot":"","sources":["../../src/query/query.cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,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';\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 {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"]}