@cyklang/cli 0.7.5 → 0.8.3
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/build/Cmd.js +11 -5
- package/build/CronCommand.d.ts +4 -0
- package/build/CronCommand.js +43 -0
- package/build/QueryCommand.js +42 -0
- package/build/TableCommand.js +12 -3
- package/build/TestCommand.js +2 -1
- package/build/console.js +1 -0
- package/build/index.js +4 -1
- package/clean_test.sh +20 -0
- package/package.json +3 -3
- package/run_test.sh +11 -0
- package/src/Cmd.ts +8 -3
- package/src/CronCommand.ts +40 -0
- package/src/QueryCommand.ts +42 -0
- package/src/TableCommand.ts +16 -6
- package/src/TestCommand.ts +11 -10
- package/src/console.ts +1 -0
- package/src/index.ts +4 -1
- package/test/db/schema.xsd +74 -0
- package/test/db/t10.output +23 -0
- package/test/{t10.xml → db/t10.xml} +25 -24
- package/test/db/t13.output +2 -0
- package/test/db/t13.xml +36 -0
- package/test/{t14.output → db/t14.output} +2 -0
- package/test/{t14.xml → db/t14.xml} +2 -2
- package/test/db/t15.output +10 -0
- package/test/db/t15.xml +47 -0
- package/test/db/t16.output +16 -0
- package/test/{t16.xml → db/t16.xml} +6 -6
- package/test/{t20.xml → db/t20.xml} +1 -1
- package/test/{t22.xml → db/t22.xml} +7 -7
- package/test/{t23.xml → db/t23.xml} +4 -4
- package/test/db/test_schema.xml +15 -0
- package/test/t09.output +1 -1
- package/test/t09.xml +1 -1
- package/test/t27.output +2 -0
- package/test/t27.xml +22 -1
- package/build/TableData.d.ts +0 -5
- package/build/TableData.js +0 -61
- package/build/TestCommand copy.d.ts +0 -5
- package/build/TestCommand copy.js +0 -111
- package/build/cykquery.d.ts +0 -2
- package/build/cykquery.js +0 -145
- package/build/cyktable.d.ts +0 -2
- package/build/cyktable.js +0 -133
- package/build/module.d.ts +0 -2
- package/build/module.js +0 -290
- package/test/cyklang.xsd +0 -1090
- package/test/t13.xml +0 -23
- package/test/t15.xml +0 -47
- package/test/t16.output +0 -49
- package/test/t19.xml +0 -234
- /package/test/{t14.xsd → db/t14.xsd} +0 -0
- /package/test/{t20.output → db/t20.output} +0 -0
- /package/test/{t21.output → db/t21.output} +0 -0
- /package/test/{t21.xml → db/t21.xml} +0 -0
- /package/test/{t22.output → db/t22.output} +0 -0
- /package/test/{t23.output → db/t23.output} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<?xml-model href="cyklang.xsd" ?>
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
2
|
<module>
|
|
3
3
|
|
|
4
|
-
<db.table name="
|
|
4
|
+
<db.table name="t_actor">
|
|
5
5
|
<number name="actor_id" type="int" primary="" generated='by default'/>
|
|
6
6
|
<string name="first_name" type="varchar(50)"/>
|
|
7
7
|
<string name="last_name" type="text" />
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<boolean name="cyk_disable" type="boolean"/>
|
|
11
11
|
</db.table>
|
|
12
12
|
|
|
13
|
-
<db.table name="
|
|
13
|
+
<db.table name="t_film">
|
|
14
14
|
<number name="film_id" type="int" primary="" generated='by default'/>
|
|
15
15
|
<string name="title" type="varchar(255)" />
|
|
16
16
|
<string name="description" type="text" />
|
|
@@ -19,25 +19,26 @@
|
|
|
19
19
|
<number name="language_id" type="int"/>
|
|
20
20
|
</db.table>
|
|
21
21
|
|
|
22
|
-
<db.table name="
|
|
23
|
-
<number name="
|
|
24
|
-
<number name="
|
|
22
|
+
<db.table name="t_film_actor">
|
|
23
|
+
<number name="id" type="int" primary="" generated="by default"/>
|
|
24
|
+
<number name="actor_id" type="int"/>
|
|
25
|
+
<number name="film_id" type="int"/>
|
|
25
26
|
<number name="length" type="int"/>
|
|
26
27
|
</db.table>
|
|
27
28
|
|
|
28
|
-
<
|
|
29
|
+
<query name="t_films_actors">
|
|
29
30
|
<number name="length_from">0</number>
|
|
30
31
|
<number name="length_to">999</number>
|
|
31
|
-
<string name="__entities__">"
|
|
32
|
+
<string name="__entities__">"t_actor t_film"</string>
|
|
32
33
|
<string name="__sql__" literal="">
|
|
33
|
-
SELECT * FROM public.
|
|
34
|
-
join
|
|
35
|
-
join
|
|
36
|
-
where
|
|
34
|
+
SELECT * FROM public.t_actor
|
|
35
|
+
join t_film_actor on t_film_actor.actor_id = t_actor.actor_id
|
|
36
|
+
join t_film on t_film_actor.film_id = t_film.film_id
|
|
37
|
+
where t_film.length between {{ length_from }} and {{ length_to }}
|
|
37
38
|
-- and actor.actor_id = 2
|
|
38
|
-
ORDER BY
|
|
39
|
+
ORDER BY t_actor.actor_id ASC ;
|
|
39
40
|
</string>
|
|
40
|
-
</
|
|
41
|
+
</query>
|
|
41
42
|
|
|
42
43
|
<object name="actor_maria">
|
|
43
44
|
<string name="first_name">"Maria" </string>
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
<object name="actor">actor_maria</object>
|
|
50
51
|
</db.execute> -->
|
|
51
52
|
|
|
52
|
-
<db.insert table="
|
|
53
|
+
<db.insert table="t_actor" returning_into="actor_maria">
|
|
53
54
|
<object name="actor">actor_maria</object>
|
|
54
55
|
</db.insert>
|
|
55
56
|
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
<object> new_film </object>
|
|
66
67
|
</db.execute> -->
|
|
67
68
|
|
|
68
|
-
<db.insert table="
|
|
69
|
+
<db.insert table="t_film" returning_into="new_film">
|
|
69
70
|
<object>new_film</object>
|
|
70
71
|
</db.insert>
|
|
71
72
|
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
<object name="film"> new_film </object>
|
|
78
79
|
</db.execute> -->
|
|
79
80
|
|
|
80
|
-
<db.update table="
|
|
81
|
+
<db.update table="t_film">
|
|
81
82
|
<object name="film"> new_film </object>
|
|
82
83
|
</db.update>
|
|
83
84
|
|
|
@@ -88,7 +89,7 @@
|
|
|
88
89
|
</object>
|
|
89
90
|
</db.execute> -->
|
|
90
91
|
|
|
91
|
-
<db.insert table="
|
|
92
|
+
<db.insert table="t_film_actor">
|
|
92
93
|
<object>
|
|
93
94
|
<number name="actor_id">actor_maria.actor_id</number>
|
|
94
95
|
<number name="film_id">new_film.film_id</number>
|
|
@@ -102,24 +103,24 @@
|
|
|
102
103
|
<number name="length_to">60</number>
|
|
103
104
|
</db.execute> -->
|
|
104
105
|
|
|
105
|
-
<
|
|
106
|
+
<runquery name="t_films_actors" result="films_actors">
|
|
106
107
|
<number name="length_from">60</number>
|
|
107
108
|
<number name="length_to">60</number>
|
|
108
|
-
</
|
|
109
|
+
</runquery>
|
|
109
110
|
|
|
110
|
-
<print>"films_actors.resultset.at(0).
|
|
111
|
+
<print>"films_actors.resultset.at(0).t_actor.last_name " + films_actors.resultset.at(0).t_actor.last_name</print>
|
|
111
112
|
<call object="films_actors.resultset" method="foreach">
|
|
112
113
|
<function>
|
|
113
114
|
<object name="result" />
|
|
114
115
|
<block>
|
|
115
|
-
<print>"actor " + result.
|
|
116
|
-
+ ", film " + result.
|
|
116
|
+
<print>"actor " + result.t_actor.actor_id + " " + result.t_actor.first_name + " " + result.t_actor.last_name
|
|
117
|
+
+ ", film " + result.t_film.film_id + " " + result.t_film.title
|
|
117
118
|
</print>
|
|
118
119
|
</block>
|
|
119
120
|
</function>
|
|
120
121
|
</call>
|
|
121
122
|
|
|
122
|
-
<print>"string(films_actors) : "+string(films_actors)</print>
|
|
123
|
+
<print>"string(films_actors.resultset) : "+string(films_actors.resultset)</print>
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
</module>
|
package/test/db/t13.xml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<object name="films_actors" />
|
|
4
|
+
<number name="index">2</number>
|
|
5
|
+
<while>
|
|
6
|
+
<condition>index > 0</condition>
|
|
7
|
+
<then>
|
|
8
|
+
<set name="index">index - 1</set>
|
|
9
|
+
<!-- <db.execute query="films_actors" result="films_actors">
|
|
10
|
+
<number name="length_from">60</number>
|
|
11
|
+
<number name="length_to">60</number>
|
|
12
|
+
</db.execute> -->
|
|
13
|
+
<query name="t_films_actors">
|
|
14
|
+
<number name="length_from">0</number>
|
|
15
|
+
<number name="length_to">999</number>
|
|
16
|
+
<string name="__entities__">"t_actor t_film"</string>
|
|
17
|
+
<string name="__sql__" literal="">
|
|
18
|
+
SELECT * FROM public.t_actor
|
|
19
|
+
join t_film_actor on t_film_actor.actor_id = t_actor.actor_id
|
|
20
|
+
join t_film on t_film_actor.film_id = t_film.film_id
|
|
21
|
+
where t_film.length between {{ length_from }} and {{ length_to }}
|
|
22
|
+
-- and actor.actor_id = 2
|
|
23
|
+
ORDER BY t_actor.actor_id ASC ;
|
|
24
|
+
</string>
|
|
25
|
+
</query>
|
|
26
|
+
<runquery name="t_films_actors" result="films_actors">
|
|
27
|
+
<number name="length_from">60</number>
|
|
28
|
+
<number name="length_to">60</number>
|
|
29
|
+
</runquery>
|
|
30
|
+
<print>"index = "+index</print>
|
|
31
|
+
<sleep>500</sleep>
|
|
32
|
+
|
|
33
|
+
</then>
|
|
34
|
+
</while>
|
|
35
|
+
|
|
36
|
+
</module>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml-model href="cyklang.xsd" ?>
|
|
1
|
+
<?xml-model href="../../../../../VueProjects/docs-vuepress/docs/.vuepress/public/cyklang.xsd" ?>
|
|
2
2
|
<module>
|
|
3
3
|
<object name="obj1">
|
|
4
4
|
<string name="name">"obj1_name"</string>
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
|
|
74
74
|
<print>"========= TEST OF newDBRow ======="</print>
|
|
75
75
|
|
|
76
|
-
<object name="actress">newDBRow("
|
|
76
|
+
<object name="actress">newDBRow("t_actor")</object>
|
|
77
77
|
<print>"actress "+string(actress)</print>
|
|
78
78
|
|
|
79
79
|
<object name="user1">newDBRow("cyk_user")</object>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
test de if()
|
|
2
|
+
2+2==4
|
|
3
|
+
<object>
|
|
4
|
+
<number name="film_id">1</number>
|
|
5
|
+
<number name="actor_id">1</number>
|
|
6
|
+
<string name="title" literal="">La mélodie du bonheur</string>
|
|
7
|
+
<string name="first_name" literal="">Maria</string>
|
|
8
|
+
<string name="last_name" literal="">CHANE YOU KAYE</string>
|
|
9
|
+
</object>
|
|
10
|
+
actors_by_film.resultset.length(): 1
|
package/test/db/t15.xml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<print>"test de if()"</print>
|
|
4
|
+
<print>if(2+2 == 4, "2+2==4", "2+2!==4")</print>
|
|
5
|
+
|
|
6
|
+
<query name="t_actors_by_film">
|
|
7
|
+
<object name="params">
|
|
8
|
+
<number name="film_id">150</number>
|
|
9
|
+
</object>
|
|
10
|
+
<string name="fields">"
|
|
11
|
+
film_id: number;
|
|
12
|
+
actor_id: number: key;
|
|
13
|
+
title: string;
|
|
14
|
+
first_name: string;
|
|
15
|
+
last_name: string
|
|
16
|
+
"
|
|
17
|
+
</string>
|
|
18
|
+
<string name="sql" literal="">
|
|
19
|
+
select t_film.film_id, title, t_actor.actor_id actor_id,
|
|
20
|
+
first_name, last_name
|
|
21
|
+
from t_film_actor join t_film on t_film.film_id = t_film_actor.film_id
|
|
22
|
+
join t_actor on t_actor.actor_id = t_film_actor.actor_id
|
|
23
|
+
where t_film_actor.film_id = {{ film_id }}
|
|
24
|
+
</string>
|
|
25
|
+
</query>
|
|
26
|
+
|
|
27
|
+
<object name="actors_by_film"/>
|
|
28
|
+
|
|
29
|
+
<!-- <db.execute query="actors_by_film" result="actors_by_film">
|
|
30
|
+
<number name="film_id">103</number>
|
|
31
|
+
</db.execute> -->
|
|
32
|
+
|
|
33
|
+
<runquery name="t_actors_by_film" result="actors_by_film">
|
|
34
|
+
<number name="film_id">1</number>
|
|
35
|
+
</runquery>
|
|
36
|
+
|
|
37
|
+
<print>string(actors_by_film.resultset)</print>
|
|
38
|
+
<print>"actors_by_film.resultset.length(): " + actors_by_film.resultset.length()</print>
|
|
39
|
+
<!-- <object name="films_actors"/>
|
|
40
|
+
<db.execute query="films_actors" result="films_actors">
|
|
41
|
+
<number name="length_from">60</number>
|
|
42
|
+
<number name="length_to">60</number>
|
|
43
|
+
</db.execute>
|
|
44
|
+
<print>"============= films_actors =========="</print>
|
|
45
|
+
<print>string(films_actors)</print> -->
|
|
46
|
+
|
|
47
|
+
</module>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
OK Février
|
|
2
|
+
test IF before
|
|
3
|
+
monthlabel Mars
|
|
4
|
+
test IF after
|
|
5
|
+
month 1 Janvier 2021 2021-01-01 -> 2021-01-31
|
|
6
|
+
month 2 Février 2021 2021-02-01 -> 2021-02-28
|
|
7
|
+
month 3 Mars 2021 2021-03-01 -> 2021-03-31
|
|
8
|
+
month 4 Avril 2021 2021-04-01 -> 2021-04-30
|
|
9
|
+
month 5 Mai 2021 2021-05-01 -> 2021-05-31
|
|
10
|
+
month 6 Juin 2021 2021-06-01 -> 2021-06-30
|
|
11
|
+
month 7 Juillet 2021 2021-07-01 -> 2021-07-31
|
|
12
|
+
month 8 Août 2021 2021-08-01 -> 2021-08-31
|
|
13
|
+
month 9 Septembre 2021 2021-09-01 -> 2021-09-30
|
|
14
|
+
month 10 Octobre 2021 2021-10-01 -> 2021-10-31
|
|
15
|
+
month 11 Novembre 2021 2021-11-01 -> 2021-11-30
|
|
16
|
+
month 12 Décembre 2021 2021-12-01 -> 2021-12-31
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
<?xml-model href="cyklang.xsd" ?>
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
2
|
<module>
|
|
3
|
-
<object name="dbresult"/>
|
|
4
|
-
<!-- <db.execute select_from_table="year" result="dbresult">
|
|
5
|
-
<string name="where">"year_num = 2021"</string>
|
|
6
|
-
</db.execute> -->
|
|
3
|
+
<!-- <object name="dbresult"/>
|
|
7
4
|
<db.select table="year" result="dbresult">
|
|
8
5
|
<string name="where">"year_num = 2021"</string>
|
|
9
6
|
</db.select>
|
|
@@ -25,7 +22,10 @@
|
|
|
25
22
|
<else>
|
|
26
23
|
<print>"TEST KO"</print>
|
|
27
24
|
</else>
|
|
28
|
-
</if>
|
|
25
|
+
</if> -->
|
|
26
|
+
|
|
27
|
+
<string name="year_begin_date">"2021-01-01"</string>
|
|
28
|
+
<string name="year_end_date">"2021-12-31"</string>
|
|
29
29
|
|
|
30
30
|
<object name="monthlabel">
|
|
31
31
|
<string name="_01">"Janvier"</string>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
-
<module
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
3
|
<function name="get_tables" returns="result: object">
|
|
4
4
|
<block>
|
|
5
5
|
|
|
6
|
-
<object name="
|
|
7
|
-
<db.select table="
|
|
8
|
-
<!-- <db.execute select_from_table="
|
|
6
|
+
<object name="result_t_actor"/>
|
|
7
|
+
<db.select table="t_actor" result="result_t_actor"/>
|
|
8
|
+
<!-- <db.execute select_from_table="t_actor" result="result_t_actor"/> -->
|
|
9
9
|
|
|
10
10
|
<object name="result_">
|
|
11
11
|
<string name="name">"CYK"</string>
|
|
12
12
|
<string name="surname">"Philippe"</string>
|
|
13
|
-
<object name="
|
|
13
|
+
<object name="t_actor">result_t_actor.t_actor</object>
|
|
14
14
|
<object name="meta">
|
|
15
|
-
<string name="
|
|
15
|
+
<string name="t_actor">result_t_actor.meta.t_actor</string>
|
|
16
16
|
</object>
|
|
17
17
|
</object>
|
|
18
18
|
<set name="result">result_</set>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
-
<module
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
3
|
<function name="call_get_tables">
|
|
4
4
|
<block>
|
|
5
|
-
<object name="
|
|
6
|
-
<db.call module="t22" method="get_tables" returns="
|
|
5
|
+
<object name="t_actor"/>
|
|
6
|
+
<db.call module="t22" method="get_tables" returns="t_actor"/>
|
|
7
7
|
|
|
8
8
|
<!-- <db.execute module="t22" method="get_tables" returns="settings">
|
|
9
9
|
</db.execute> -->
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml-model href="./schema.xsd"?>
|
|
2
|
+
<object>
|
|
3
|
+
<query name="q1">
|
|
4
|
+
<object name="params">
|
|
5
|
+
<number name="n"/>
|
|
6
|
+
|
|
7
|
+
</object>
|
|
8
|
+
<string name="sql" literal="">select * from table</string>
|
|
9
|
+
</query>
|
|
10
|
+
<number name="n1"/>
|
|
11
|
+
<string name="s1"/>
|
|
12
|
+
<object name="o1">
|
|
13
|
+
<number name="n2"/>
|
|
14
|
+
</object>
|
|
15
|
+
</object>
|
package/test/t09.output
CHANGED
package/test/t09.xml
CHANGED
package/test/t27.output
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
150
|
|
2
2
|
{"user_id":1,"user_name":"cyk","user_email":"cyk@gmail.com","user_password":"$2b$10$Et1b0DodTNKxW/jvUFC8be8JrRXULHWC5RnwOjVhUXmVKv.CyfFW.","user_access":"admin","user_appli":null,"user_disable":false,"user_lang":null}
|
|
3
|
+
Paris coordinates : <number name="lon">2.3488</number>
|
|
4
|
+
<number name="lat">48.8534</number>
|
package/test/t27.xml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml-model href="
|
|
1
|
+
<?xml-model href="../../../../VueProjects/docs-vuepress/docs/.vuepress/public/cyklang.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
|
2
2
|
<module>
|
|
3
3
|
<print>objson('150')</print>
|
|
4
4
|
<string name="chaine" literal=""><![CDATA[
|
|
@@ -15,4 +15,25 @@
|
|
|
15
15
|
]]>
|
|
16
16
|
</string>
|
|
17
17
|
<print>json(objson(chaine))</print>
|
|
18
|
+
|
|
19
|
+
<object name="resp"/>
|
|
20
|
+
|
|
21
|
+
<fetch method="get" returns="resp" >
|
|
22
|
+
<string name="origin">"https://api.openweathermap.org"</string>
|
|
23
|
+
<string name="pathname">"/data/2.5/weather"</string>
|
|
24
|
+
<object name="search">
|
|
25
|
+
<string name="q">"paris,fr"</string>
|
|
26
|
+
<string name="units">"metric"</string>
|
|
27
|
+
<string name="lang">"fr"</string>
|
|
28
|
+
<string name="APPID">env("OPENWEATHER_API_KEY")</string>
|
|
29
|
+
</object>
|
|
30
|
+
</fetch>
|
|
31
|
+
<print>'Paris coordinates : ' + string(resp.json.coord)</print>
|
|
32
|
+
<!--
|
|
33
|
+
<print>"icon: " + resp.json.weather.at(0).icon
|
|
34
|
+
+ ", description: "
|
|
35
|
+
+ resp.json.weather.at(0).description
|
|
36
|
+
+ ", temp: " + resp.json.main.temp + "°C"
|
|
37
|
+
</print> -->
|
|
38
|
+
|
|
18
39
|
</module>
|
package/build/TableData.d.ts
DELETED
package/build/TableData.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableDataCommand = void 0;
|
|
4
|
-
const Cmd_1 = require("./Cmd");
|
|
5
|
-
const DBClient_1 = require("./DBClient");
|
|
6
|
-
const TableCommand_1 = require("./TableCommand");
|
|
7
|
-
//--------------------------------------------------------------------------------------------------------------------
|
|
8
|
-
// class TableData
|
|
9
|
-
//--------------------------------------------------------------------------------------------------------------------
|
|
10
|
-
class TableDataCommand extends Cmd_1.Cmd {
|
|
11
|
-
constructor(name, description) {
|
|
12
|
-
super(name);
|
|
13
|
-
this.description(description)
|
|
14
|
-
.argument('<table>', 'table name')
|
|
15
|
-
.option('--where <clause_where_sql>', 'criteria in SQL syntax')
|
|
16
|
-
.option('-s --sort <columns>', 'sort by columns positions (begins by 0) separated by comma')
|
|
17
|
-
.option('-w --width <colwidth>', 'columns widths separated by comma')
|
|
18
|
-
.action(async (table, options) => {
|
|
19
|
-
this.commandData(table, options);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async commandData(table, options) {
|
|
23
|
-
try {
|
|
24
|
-
await this.prologue(options);
|
|
25
|
-
if (this.dbManager === undefined)
|
|
26
|
-
throw 'dbManager undefined';
|
|
27
|
-
const dbTable = await this.dbManager.dbTableExist(table);
|
|
28
|
-
if (dbTable === undefined)
|
|
29
|
-
throw 'table ' + table + ' not found';
|
|
30
|
-
let fields = '';
|
|
31
|
-
for (let ind = 0; ind < dbTable.columns.length; ind++) {
|
|
32
|
-
const dbColumn = dbTable.columns[ind];
|
|
33
|
-
let ok = false;
|
|
34
|
-
let fieldName = dbColumn.name;
|
|
35
|
-
if (dbColumn.dbType === 'text' || dbColumn.dbType === 'bytea') {
|
|
36
|
-
ok = false;
|
|
37
|
-
fieldName = 'length(' + dbColumn.name + ')';
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
ok = true;
|
|
41
|
-
}
|
|
42
|
-
if (ok === true) {
|
|
43
|
-
if (fields !== '')
|
|
44
|
-
fields += ',';
|
|
45
|
-
fields += fieldName;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
TableCommand_1.logger.debug('commandQuery', table);
|
|
49
|
-
const dbClient = new DBClient_1.DBClient(this.dbManager);
|
|
50
|
-
let title = 'Table ' + table;
|
|
51
|
-
if (options.where !== undefined) {
|
|
52
|
-
title += ' where ' + options.where;
|
|
53
|
-
}
|
|
54
|
-
dbClient.selectFromTable(title, table, { fields: fields, width: options.width, sort: options.sort || '1', where: options.where });
|
|
55
|
-
}
|
|
56
|
-
catch (err) {
|
|
57
|
-
TableCommand_1.logger.error(err);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.TableDataCommand = TableDataCommand;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.TestCommand = void 0;
|
|
26
|
-
const core_1 = require("@cyklang/core");
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const console_1 = require("./console");
|
|
29
|
-
const loglevel_1 = __importDefault(require("loglevel"));
|
|
30
|
-
const NodeCrypto_1 = require("./NodeCrypto");
|
|
31
|
-
const Cmd_1 = require("./Cmd");
|
|
32
|
-
loglevel_1.default.setLevel('debug');
|
|
33
|
-
const logger = loglevel_1.default.getLogger('TestCommand.ts');
|
|
34
|
-
class TestCommand extends Cmd_1.Cmd {
|
|
35
|
-
constructor() {
|
|
36
|
-
super('test');
|
|
37
|
-
this.description('test script').version('0.1')
|
|
38
|
-
.argument('<files...>', 'local module file(s) to test run')
|
|
39
|
-
.action(async (files, options) => {
|
|
40
|
-
await this.testRun(files, options);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async testRun(files, options) {
|
|
44
|
-
try {
|
|
45
|
-
await this.prologue(options);
|
|
46
|
-
for (let ind = 0; ind < files.length; ind++) {
|
|
47
|
-
const result = await testfile(files[ind]);
|
|
48
|
-
if (result === false) {
|
|
49
|
-
logger.debug('*********** FAILURE ' + process.argv[ind] + ' ***************');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
logger.error(err);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.TestCommand = TestCommand;
|
|
59
|
-
async function testfile(filename) {
|
|
60
|
-
let result;
|
|
61
|
-
if (filename.indexOf(".") !== -1) {
|
|
62
|
-
filename = filename.substring(0, filename.indexOf("."));
|
|
63
|
-
}
|
|
64
|
-
let xmlfilename = filename + ".xml";
|
|
65
|
-
let logfilename = filename + ".log";
|
|
66
|
-
let outfilename = filename + ".output";
|
|
67
|
-
let xml = fs.readFileSync(xmlfilename);
|
|
68
|
-
fs.writeFileSync(logfilename, "");
|
|
69
|
-
//console.log(xml.toString())
|
|
70
|
-
try {
|
|
71
|
-
if (process.env.DBREMOTE_URL === undefined)
|
|
72
|
-
throw 'DBREMOTE_URL undefined';
|
|
73
|
-
logger.trace('DBREMOTE_URL ' + process.env.DBREMOTE_URL);
|
|
74
|
-
const structure = new core_1.Structure();
|
|
75
|
-
const nodeCrypto = new NodeCrypto_1.NodeCrypto();
|
|
76
|
-
const dbRemote = new core_1.DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto);
|
|
77
|
-
const login = await dbRemote.signin(process.env.USER_NAME, undefined, process.env.USER_PASSWORD);
|
|
78
|
-
//const dbRemote = new DBRemote(structure, 'https://cyk-postgres.herokuapp.com')
|
|
79
|
-
const dbManager = new core_1.DBManager(structure.scope, dbRemote);
|
|
80
|
-
await dbManager.initialize();
|
|
81
|
-
structure.scope.addInstructionType(new console_1.PrintInstructionType(logfilename));
|
|
82
|
-
let script = new core_1.Script(structure.scope, xmlfilename, xml.toString());
|
|
83
|
-
await script.parseInstructions();
|
|
84
|
-
await script.execute();
|
|
85
|
-
// console.log(JSON.stringify(script.block.toString()))
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
if (err instanceof core_1.XmlError) {
|
|
89
|
-
let xmlError = err;
|
|
90
|
-
(0, console_1.errorconsole)(xmlError);
|
|
91
|
-
}
|
|
92
|
-
console.log(err);
|
|
93
|
-
}
|
|
94
|
-
let log = fs.readFileSync(logfilename);
|
|
95
|
-
if (fs.existsSync(outfilename) === true) {
|
|
96
|
-
let out = fs.readFileSync(outfilename);
|
|
97
|
-
if (log.toString() === out.toString()) {
|
|
98
|
-
console.log("test " + xmlfilename + " SUCCESS");
|
|
99
|
-
result = true;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
console.log("test " + xmlfilename + " FAILURE");
|
|
103
|
-
result = false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
console.log("test " + xmlfilename + " output file not found ");
|
|
108
|
-
result = false;
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
package/build/cykquery.d.ts
DELETED