@cyklang/cli 0.11.6 → 0.11.8

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 CHANGED
@@ -74,35 +74,51 @@ class Cmd extends commander_1.Command {
74
74
  */
75
75
  async updateAuthAccess(tableName, prefix, id, options) {
76
76
  try {
77
- let dclAuth;
77
+ let setAuth;
78
78
  if (options.auth) {
79
79
  if (' basic | token | cookie | any | none | null '.indexOf(' ' + options.auth + ' ') === -1) {
80
- throw 'valid authentication schemas are : basic | token | cookie | any | null';
80
+ throw 'valid authentication schemas are : basic | token | cookie | any | none | null';
81
81
  }
82
- dclAuth = `<string name='${prefix}_auth'>`;
82
+ setAuth = `<set name="record.${prefix}_auth">`;
83
83
  if (' none | null '.indexOf(' ' + options.auth + ' ') === -1)
84
- dclAuth += ` "${options.auth}" `;
84
+ setAuth += ` "${options.auth}" `;
85
85
  else
86
- dclAuth += ' null ';
87
- dclAuth += "</string>";
86
+ setAuth += ' null ';
87
+ setAuth += "</set>";
88
88
  }
89
- let dclAccess;
89
+ let setAccess;
90
90
  if (options.access) {
91
- dclAccess = `<string name='${prefix}_access'> `;
91
+ setAccess = `<set name="record.${prefix}_access">`;
92
92
  if (' null | none '.indexOf(' ' + options.access + ' ') === -1)
93
- dclAccess += `"${options.access}"`;
93
+ setAccess += ` "${options.access}" `;
94
94
  else
95
- dclAccess += ' null ';
96
- dclAccess += "</string>";
95
+ setAccess += ' null ';
96
+ setAccess += "</set>";
97
97
  }
98
98
  const inst = `
99
- <db.update table='${tableName}'>
100
- <object>
101
- <number name='${prefix}_id'>${id}</number>
102
- ${dclAuth}
103
- ${dclAccess ? dclAccess : ''}
104
- </object>
105
- </db.update>
99
+
100
+ <object name="result_select"/>
101
+
102
+ <db.select table='${tableName}' result='result_select'>
103
+ <string name='where'>"${prefix}_id = ${id}"</string>
104
+ </db.select>
105
+
106
+ <if>
107
+ <condition>result_select.resultset.length() == 0</condition>
108
+ <then>
109
+ <print>"ID not found in the table: ${id} / ${tableName}"</print>
110
+ </then>
111
+ <else>
112
+ <object name="record">result_select.resultset.at(0)</object>
113
+
114
+ ${setAuth}
115
+ ${setAccess}
116
+
117
+ <db.update table='${tableName}'>
118
+ <object>record</object>
119
+ </db.update>
120
+ </else>
121
+ </if>
106
122
  `;
107
123
  if (!this.dbManager)
108
124
  throw 'prologue() has not been called before';
package/build/index.js CHANGED
@@ -182,7 +182,7 @@ class StopCommand extends commander_1.Command {
182
182
  */
183
183
  const program = new commander_1.Command();
184
184
  program.name('cyk').description('cyklang CLI')
185
- .version('0.11.3');
185
+ .version('0.11.7');
186
186
  program.addCommand(new StartCommand('start'));
187
187
  program.addCommand(new StopCommand('stop'));
188
188
  program.addCommand(new InstallCommand_1.InstallCommand('install'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyklang/cli",
3
- "version": "0.11.6",
3
+ "version": "0.11.8",
4
4
  "description": "cyklang CLI",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "author": "",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@cyklang/core": "^0.8.7",
20
+ "@cyklang/core": "^0.8.8",
21
21
  "commander": "^9.4.0",
22
22
  "dotenv": "^16.0.1",
23
23
  "form-data": "^4.0.0",
package/src/Cmd.ts CHANGED
@@ -57,40 +57,56 @@ export class Cmd extends Command {
57
57
 
58
58
  try {
59
59
 
60
- let dclAuth: string | undefined
60
+ let setAuth: string | undefined
61
61
 
62
62
  if (options.auth) {
63
63
  if (' basic | token | cookie | any | none | null '.indexOf(' ' + options.auth + ' ') === -1) {
64
- throw 'valid authentication schemas are : basic | token | cookie | any | null'
64
+ throw 'valid authentication schemas are : basic | token | cookie | any | none | null'
65
65
  }
66
- dclAuth = `<string name='${prefix}_auth'>`
66
+ setAuth = `<set name="record.${prefix}_auth">`
67
67
  if (' none | null '.indexOf(' ' + options.auth + ' ') === -1)
68
- dclAuth += ` "${options.auth}" `
68
+ setAuth += ` "${options.auth}" `
69
69
  else
70
- dclAuth += ' null '
71
- dclAuth += "</string>"
70
+ setAuth += ' null '
71
+ setAuth += "</set>"
72
72
  }
73
73
 
74
- let dclAccess: string | undefined
74
+ let setAccess: string | undefined
75
75
 
76
76
  if (options.access) {
77
77
 
78
- dclAccess = `<string name='${prefix}_access'> `
78
+ setAccess = `<set name="record.${prefix}_access">`
79
79
  if (' null | none '.indexOf(' ' + options.access + ' ') === -1)
80
- dclAccess += `"${options.access}"`
80
+ setAccess += ` "${options.access}" `
81
81
  else
82
- dclAccess += ' null '
83
- dclAccess += "</string>"
82
+ setAccess += ' null '
83
+ setAccess += "</set>"
84
84
  }
85
85
 
86
86
  const inst = `
87
- <db.update table='${tableName}'>
88
- <object>
89
- <number name='${prefix}_id'>${id}</number>
90
- ${dclAuth}
91
- ${dclAccess ? dclAccess : ''}
92
- </object>
93
- </db.update>
87
+
88
+ <object name="result_select"/>
89
+
90
+ <db.select table='${tableName}' result='result_select'>
91
+ <string name='where'>"${prefix}_id = ${id}"</string>
92
+ </db.select>
93
+
94
+ <if>
95
+ <condition>result_select.resultset.length() == 0</condition>
96
+ <then>
97
+ <print>"ID not found in the table: ${id} / ${tableName}"</print>
98
+ </then>
99
+ <else>
100
+ <object name="record">result_select.resultset.at(0)</object>
101
+
102
+ ${setAuth}
103
+ ${setAccess}
104
+
105
+ <db.update table='${tableName}'>
106
+ <object>record</object>
107
+ </db.update>
108
+ </else>
109
+ </if>
94
110
  `
95
111
 
96
112
  if (!this.dbManager) throw 'prologue() has not been called before'
package/src/index.ts CHANGED
@@ -176,7 +176,7 @@ class StopCommand extends Command {
176
176
  */
177
177
  const program = new Command()
178
178
  program.name('cyk').description('cyklang CLI')
179
- .version('0.11.3')
179
+ .version('0.11.7')
180
180
  program.addCommand(new StartCommand('start'))
181
181
  program.addCommand(new StopCommand('stop'))
182
182
  program.addCommand(new InstallCommand('install'))