@gdacm/querybuilder-uql 0.1.1

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.
@@ -0,0 +1,59 @@
1
+ export declare class UqlQueryBuilder {
2
+ /**
3
+ * @type {string[]}
4
+ */
5
+ _parts: string[];
6
+ constructor();
7
+ /**
8
+ * @param {Object} [options]
9
+ * @param {Boolean} [options.activate]
10
+ * @returns {UqlQueryBuilder}
11
+ */
12
+ parseJson(options?: {
13
+ activate?: boolean;
14
+ }): UqlQueryBuilder;
15
+ /**
16
+ * @param {String} name
17
+ * @param {Object} [options]
18
+ * @param {Boolean} [options.activate]
19
+ * @returns {UqlQueryBuilder}
20
+ */
21
+ scope(name: string, options?: {
22
+ activate?: boolean;
23
+ }): UqlQueryBuilder;
24
+ /**
25
+ * @param {String} name
26
+ * @param {String} expression
27
+ * @param {Object} [options]
28
+ * @param {Boolean} [options.activate]
29
+ * @returns {UqlQueryBuilder}
30
+ */
31
+ extend(name: string, expression: string, options?: {
32
+ activate?: boolean;
33
+ }): UqlQueryBuilder;
34
+ /**
35
+ * @param {String[]} names
36
+ * @param {Object} [options]
37
+ * @param {Boolean} [options.activate]
38
+ * @returns {UqlQueryBuilder}
39
+ */
40
+ project(names: string[], options?: {
41
+ activate?: boolean;
42
+ }): UqlQueryBuilder;
43
+ /**
44
+ * @param {(String|{name: String, direction: String})[]} names
45
+ * @param {Object} [options]
46
+ * @param {Boolean} [options.activate]
47
+ * @returns {UqlQueryBuilder}
48
+ */
49
+ orderBy(names: (string | {
50
+ name: string;
51
+ direction: string;
52
+ })[], options?: {
53
+ activate?: boolean;
54
+ }): UqlQueryBuilder;
55
+ /**
56
+ * @returns {String}
57
+ */
58
+ asString(): string;
59
+ }
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ //#region src/index.js
2
+ /**
3
+ * @param {Object} [options]
4
+ * @param {Boolean} [options.activate]
5
+ * @returns {Boolean}
6
+ */
7
+ var checkActivate = (options) => {
8
+ if (options && options.activate === false) return false;
9
+ return true;
10
+ };
11
+ var UqlQueryBuilder = class {
12
+ constructor() {
13
+ /**
14
+ * @type {string[]}
15
+ */
16
+ this._parts = [];
17
+ }
18
+ /**
19
+ * @param {Object} [options]
20
+ * @param {Boolean} [options.activate]
21
+ * @returns {UqlQueryBuilder}
22
+ */
23
+ parseJson(options) {
24
+ if (checkActivate(options) === false) return this;
25
+ this._parts.push(`parse-json`);
26
+ return this;
27
+ }
28
+ /**
29
+ * @param {String} name
30
+ * @param {Object} [options]
31
+ * @param {Boolean} [options.activate]
32
+ * @returns {UqlQueryBuilder}
33
+ */
34
+ scope(name, options) {
35
+ if (checkActivate(options) === false) return this;
36
+ this._parts.push(`scope "${name}"`);
37
+ return this;
38
+ }
39
+ /**
40
+ * @param {String} name
41
+ * @param {String} expression
42
+ * @param {Object} [options]
43
+ * @param {Boolean} [options.activate]
44
+ * @returns {UqlQueryBuilder}
45
+ */
46
+ extend(name, expression, options) {
47
+ if (checkActivate(options) === false) return this;
48
+ this._parts.push(`extend "${name}"=${expression}`);
49
+ return this;
50
+ }
51
+ /**
52
+ * @param {String[]} names
53
+ * @param {Object} [options]
54
+ * @param {Boolean} [options.activate]
55
+ * @returns {UqlQueryBuilder}
56
+ */
57
+ project(names, options) {
58
+ if (checkActivate(options) === false) return this;
59
+ this._parts.push(`project ${names.map((name) => `"${name}"`).join(", ")}`);
60
+ return this;
61
+ }
62
+ /**
63
+ * @param {(String|{name: String, direction: String})[]} names
64
+ * @param {Object} [options]
65
+ * @param {Boolean} [options.activate]
66
+ * @returns {UqlQueryBuilder}
67
+ */
68
+ orderBy(names, options) {
69
+ if (checkActivate(options) === false) return this;
70
+ const items = names.map((name) => {
71
+ if (typeof name === "string") return `"${name}" asc`;
72
+ else return `"${name.name}" ${name.direction}`;
73
+ });
74
+ this._parts.push(`order by ${items.join(", ")}`);
75
+ return this;
76
+ }
77
+ /**
78
+ * @returns {String}
79
+ */
80
+ asString() {
81
+ return this._parts.join("\n | ");
82
+ }
83
+ };
84
+ //#endregion
85
+ export { UqlQueryBuilder };
86
+
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["/**\n * @param {Object} [options]\n * @param {Boolean} [options.activate]\n * @returns {Boolean}\n */\nconst checkActivate = (options) => {\n if (options && options.activate === false) {\n return false;\n }\n return true;\n}\n\nexport class UqlQueryBuilder {\n constructor() {\n /**\n * @type {string[]}\n */\n this._parts = [];\n }\n /**\n * @param {Object} [options]\n * @param {Boolean} [options.activate]\n * @returns {UqlQueryBuilder}\n */\n parseJson(options) {\n if (checkActivate(options) === false) {\n return this;\n }\n this._parts.push(`parse-json`);\n return this;\n }\n \n /**\n * @param {String} name\n * @param {Object} [options]\n * @param {Boolean} [options.activate] \n * @returns {UqlQueryBuilder}\n */\n scope(name, options) {\n if (checkActivate(options) === false) {\n return this;\n }\n this._parts.push(`scope \"${name}\"`);\n return this;\n }\n\n /**\n * @param {String} name\n * @param {String} expression\n * @param {Object} [options]\n * @param {Boolean} [options.activate]\n * @returns {UqlQueryBuilder}\n */\n extend(name, expression, options) {\n if (checkActivate(options) === false) {\n return this;\n }\n this._parts.push(`extend \"${name}\"=${expression}`);\n return this;\n }\n\n /**\n * @param {String[]} names\n * @param {Object} [options]\n * @param {Boolean} [options.activate]\n * @returns {UqlQueryBuilder}\n */\n project(names, options) {\n if (checkActivate(options) === false) {\n return this;\n }\n this._parts.push(`project ${names.map(name => `\"${name}\"`).join(', ')}`);\n return this;\n }\n\n /**\n * @param {(String|{name: String, direction: String})[]} names\n * @param {Object} [options]\n * @param {Boolean} [options.activate]\n * @returns {UqlQueryBuilder}\n */\n orderBy(names, options) {\n if (checkActivate(options) === false) {\n return this;\n }\n const items = names.map(name => {\n if (typeof name === 'string') {\n return `\"${name}\" asc`;\n } else {\n return `\"${name.name}\" ${name.direction}`;\n }\n });\n this._parts.push(`order by ${items.join(', ')}`);\n return this;\n }\n\n /**\n * @returns {String}\n */\n asString() {\n return this._parts.join('\\n | ');\n }\n}"],"mappings":";;;;;;AAKA,IAAM,iBAAiB,YAAY;CAC/B,IAAI,WAAW,QAAQ,aAAa,OAChC,OAAO;CAEX,OAAO;AACX;AAEA,IAAa,kBAAb,MAA6B;CACzB,cAAc;;;;EAIV,KAAK,SAAS,CAAC;CACnB;;;;;;CAMA,UAAU,SAAS;EACf,IAAI,cAAc,OAAO,MAAM,OAC3B,OAAO;EAEX,KAAK,OAAO,KAAK,YAAY;EAC7B,OAAO;CACX;;;;;;;CAQA,MAAM,MAAM,SAAS;EACjB,IAAI,cAAc,OAAO,MAAM,OAC3B,OAAO;EAEX,KAAK,OAAO,KAAK,UAAU,KAAK,EAAE;EAClC,OAAO;CACX;;;;;;;;CASA,OAAO,MAAM,YAAY,SAAS;EAC9B,IAAI,cAAc,OAAO,MAAM,OAC3B,OAAO;EAEX,KAAK,OAAO,KAAK,WAAW,KAAK,IAAI,YAAY;EACjD,OAAO;CACX;;;;;;;CAQA,QAAQ,OAAO,SAAS;EACpB,IAAI,cAAc,OAAO,MAAM,OAC3B,OAAO;EAEX,KAAK,OAAO,KAAK,WAAW,MAAM,KAAI,SAAQ,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,GAAG;EACvE,OAAO;CACX;;;;;;;CAQA,QAAQ,OAAO,SAAS;EACpB,IAAI,cAAc,OAAO,MAAM,OAC3B,OAAO;EAEX,MAAM,QAAQ,MAAM,KAAI,SAAQ;GAC5B,IAAI,OAAO,SAAS,UAChB,OAAO,IAAI,KAAK;QAEhB,OAAO,IAAI,KAAK,KAAK,IAAI,KAAK;EAEtC,CAAC;EACD,KAAK,OAAO,KAAK,YAAY,MAAM,KAAK,IAAI,GAAG;EAC/C,OAAO;CACX;;;;CAKA,WAAW;EACP,OAAO,KAAK,OAAO,KAAK,QAAQ;CACpC;AACJ"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@gdacm/querybuilder-uql",
3
+ "version": "0.1.1",
4
+ "author": "gissehel",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "license": "MIT",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "clean:local": "rm -rf dist .turbo",
20
+ "dev": "vite build --watch",
21
+ "build:js": "vite build",
22
+ "build:types": "tsc -p tsconfig.types.json",
23
+ "build": "yarn build:js && yarn build:types"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^7.0.2",
27
+ "vite": "^8.2.0"
28
+ }
29
+ }