@difizen/libro-sql-cell 0.2.40 → 0.2.41-next.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.
- package/es/libro-formatter-sql-magic-contribution.d.ts +1 -0
- package/es/libro-formatter-sql-magic-contribution.d.ts.map +1 -1
- package/es/libro-formatter-sql-magic-contribution.js +21 -11
- package/es/libro-sql-cell-view.d.ts.map +1 -1
- package/es/libro-sql-cell-view.js +21 -1
- package/package.json +5 -5
- package/src/libro-formatter-sql-magic-contribution.ts +21 -11
- package/src/libro-sql-cell-view.tsx +26 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-formatter-sql-magic-contribution.d.ts","sourceRoot":"","sources":["../src/libro-formatter-sql-magic-contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libro-formatter-sql-magic-contribution.d.ts","sourceRoot":"","sources":["../src/libro-formatter-sql-magic-contribution.ts"],"names":[],"mappings":"AAAA,cAAc;AAGd,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBACa,6BACX,YAAW,qBAAqB,CAAC,mBAAmB,CAAC;IAErD,SAAS,SAAyB;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,SAAS,mBAAoB,MAAM,aAEjC;IACF,MAAM,WAAY,mBAAmB;;;;;MAanC;IACF,MAAM,mBAAoB,uBAAuB;;;;;;;;MAqB/C;IAEF,QAAQ,WAAY,mBAAmB,mCAErC;CACH"}
|
|
@@ -5,7 +5,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
|
|
8
|
+
/** @format */
|
|
9
|
+
|
|
9
10
|
import { concatMultilineString } from '@difizen/libro-common';
|
|
10
11
|
import { FormatterContribution } from '@difizen/libro-jupyter';
|
|
11
12
|
import { singleton } from '@difizen/mana-app';
|
|
@@ -20,7 +21,12 @@ export var FormatterSqlMagicContribution = (_dec = singleton({
|
|
|
20
21
|
return libroFormatter === _this.formatter ? 100 : 1;
|
|
21
22
|
};
|
|
22
23
|
this.encode = function (source) {
|
|
23
|
-
var
|
|
24
|
+
var sqlJson = {
|
|
25
|
+
result_variable: source.result_variable,
|
|
26
|
+
db_id: source.db_id,
|
|
27
|
+
sql_script: source.value
|
|
28
|
+
};
|
|
29
|
+
var sqlEncodedValue = "%%sql \n".concat(JSON.stringify(sqlJson));
|
|
24
30
|
return {
|
|
25
31
|
source: sqlEncodedValue,
|
|
26
32
|
metadata: {
|
|
@@ -32,15 +38,19 @@ export var FormatterSqlMagicContribution = (_dec = singleton({
|
|
|
32
38
|
var value = concatMultilineString(formatterValue.source);
|
|
33
39
|
if (value.startsWith('%%sql \n')) {
|
|
34
40
|
var run = value.split('%%sql \n')[1];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
try {
|
|
42
|
+
var runValue = JSON.parse(run);
|
|
43
|
+
var result_variable = runValue.result_variable;
|
|
44
|
+
var db_id = runValue.db_id;
|
|
45
|
+
var codeValue = runValue.sql_script;
|
|
46
|
+
return {
|
|
47
|
+
result_variable: result_variable,
|
|
48
|
+
value: codeValue,
|
|
49
|
+
db_id: db_id
|
|
50
|
+
};
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.warn('🚀 ~ e:', e);
|
|
53
|
+
}
|
|
44
54
|
}
|
|
45
55
|
return {
|
|
46
56
|
value: ''
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-sql-cell-view.d.ts","sourceRoot":"","sources":["../src/libro-sql-cell-view.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EACV,eAAe,EAGf,SAAS,EACT,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,WAAW,EACX,YAAY,EAEZ,+BAA+B,EAC/B,gBAAgB,EAIhB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACL,QAAQ,EAQR,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAsHvD,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"libro-sql-cell-view.d.ts","sourceRoot":"","sources":["../src/libro-sql-cell-view.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,uBAAuB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WAAW,sBAElB;IAEF,aAAa,CAAC,GAAG,EAAE,GAAG;IAKb,YAAY,SAAU,QAAQ,KAAG,IAAI,CAK5C;IAEF,cAAc,CAAC,KAAK,EAAE,MAAM;IAInB,MAAM,IAAI,SAAS;IASnB,KAAK,WAAY,OAAO,UAU/B;IAEO,cAAc,aAGrB;IAEa,GAAG;IAqElB,KAAK,YACM,cAAc,kBAAkB,CAAC,SAAS,CAAC,oBAClC,cAAc,aAAa,KAAK,GAAG,6CAUrD;IAEF,mBAAmB,aACP,cAAc,aAAa,eACxB,MAAM,KAAK,IAAI,UA6B5B;IAEF,iBAAiB,gDAef;CACH"}
|
|
@@ -157,7 +157,17 @@ export var LibroSqlCell = /*#__PURE__*/React.forwardRef(function SqlEditorViewCo
|
|
|
157
157
|
setEdit(false);
|
|
158
158
|
};
|
|
159
159
|
useEffect(function () {
|
|
160
|
-
instance.getDatabaseConfig()
|
|
160
|
+
instance.getDatabaseConfig().then(function () {
|
|
161
|
+
if (instance.model.dbId) {
|
|
162
|
+
setSelectedDb(instance.model.dbId);
|
|
163
|
+
} else {
|
|
164
|
+
instance.handleDbChange(instance.databases[0].id);
|
|
165
|
+
setSelectedDb(instance.databases[0].id);
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}).catch(function () {
|
|
169
|
+
//
|
|
170
|
+
});
|
|
161
171
|
}, [instance]);
|
|
162
172
|
var handleChange = function handleChange(value) {
|
|
163
173
|
instance.handleDbChange(value);
|
|
@@ -409,6 +419,16 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
|
|
|
409
419
|
return cell.model.type === 'sql';
|
|
410
420
|
}));
|
|
411
421
|
}
|
|
422
|
+
_this.parentReady.then(function () {
|
|
423
|
+
if (_this.parent.model.onRestart) {
|
|
424
|
+
_this.parent.model.onRestart(function () {
|
|
425
|
+
_this.getDatabaseConfig();
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
return;
|
|
429
|
+
}).catch(function () {
|
|
430
|
+
//
|
|
431
|
+
});
|
|
412
432
|
return _this;
|
|
413
433
|
}
|
|
414
434
|
LibroSqlCellView = inject(CodeEditorManager)(LibroSqlCellView, undefined, 4) || LibroSqlCellView;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-sql-cell",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.41-next.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-code-editor": "^0.2.
|
|
36
|
-
"@difizen/libro-jupyter": "^0.2.
|
|
37
|
-
"@difizen/libro-rendermime": "^0.2.
|
|
38
|
-
"@difizen/libro-common": "^0.2.
|
|
35
|
+
"@difizen/libro-code-editor": "^0.2.41-next.1",
|
|
36
|
+
"@difizen/libro-jupyter": "^0.2.41-next.1",
|
|
37
|
+
"@difizen/libro-rendermime": "^0.2.41-next.1",
|
|
38
|
+
"@difizen/libro-common": "^0.2.41-next.1",
|
|
39
39
|
"@ant-design/icons": "^5.1.0",
|
|
40
40
|
"@difizen/mana-app": "latest",
|
|
41
41
|
"@difizen/mana-l10n": "latest"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
2
3
|
import { concatMultilineString } from '@difizen/libro-common';
|
|
3
4
|
import { FormatterContribution } from '@difizen/libro-jupyter';
|
|
4
5
|
import type {
|
|
@@ -23,7 +24,12 @@ export class FormatterSqlMagicContribution
|
|
|
23
24
|
return libroFormatter === this.formatter ? 100 : 1;
|
|
24
25
|
};
|
|
25
26
|
encode = (source: SqlDecodedFormatter) => {
|
|
26
|
-
const
|
|
27
|
+
const sqlJson = {
|
|
28
|
+
result_variable: source.result_variable,
|
|
29
|
+
db_id: source.db_id,
|
|
30
|
+
sql_script: source.value,
|
|
31
|
+
};
|
|
32
|
+
const sqlEncodedValue = `%%sql \n${JSON.stringify(sqlJson)}`;
|
|
27
33
|
return {
|
|
28
34
|
source: sqlEncodedValue,
|
|
29
35
|
metadata: {
|
|
@@ -35,15 +41,19 @@ export class FormatterSqlMagicContribution
|
|
|
35
41
|
const value = concatMultilineString(formatterValue.source);
|
|
36
42
|
if (value.startsWith('%%sql \n')) {
|
|
37
43
|
const run = value.split('%%sql \n')[1];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
try {
|
|
45
|
+
const runValue = JSON.parse(run);
|
|
46
|
+
const result_variable: string = runValue.result_variable;
|
|
47
|
+
const db_id: string = runValue.db_id;
|
|
48
|
+
const codeValue: string = runValue.sql_script;
|
|
49
|
+
return {
|
|
50
|
+
result_variable,
|
|
51
|
+
value: codeValue,
|
|
52
|
+
db_id,
|
|
53
|
+
};
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.warn('🚀 ~ e:', e);
|
|
56
|
+
}
|
|
47
57
|
}
|
|
48
58
|
return {
|
|
49
59
|
value: '',
|
|
@@ -177,7 +177,20 @@ export const LibroSqlCell = React.forwardRef<HTMLDivElement>(
|
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
useEffect(() => {
|
|
180
|
-
instance
|
|
180
|
+
instance
|
|
181
|
+
.getDatabaseConfig()
|
|
182
|
+
.then(() => {
|
|
183
|
+
if (instance.model.dbId) {
|
|
184
|
+
setSelectedDb(instance.model.dbId);
|
|
185
|
+
} else {
|
|
186
|
+
instance.handleDbChange(instance.databases[0].id);
|
|
187
|
+
setSelectedDb(instance.databases[0].id);
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
})
|
|
191
|
+
.catch(() => {
|
|
192
|
+
//
|
|
193
|
+
});
|
|
181
194
|
}, [instance]);
|
|
182
195
|
|
|
183
196
|
const handleChange = (value: string) => {
|
|
@@ -352,6 +365,18 @@ export class LibroSqlCellView extends LibroEditableExecutableCellView {
|
|
|
352
365
|
) as LibroSqlCellView[],
|
|
353
366
|
);
|
|
354
367
|
}
|
|
368
|
+
this.parentReady
|
|
369
|
+
.then(() => {
|
|
370
|
+
if (this.parent.model.onRestart) {
|
|
371
|
+
this.parent.model.onRestart(() => {
|
|
372
|
+
this.getDatabaseConfig();
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return;
|
|
376
|
+
})
|
|
377
|
+
.catch(() => {
|
|
378
|
+
//
|
|
379
|
+
});
|
|
355
380
|
}
|
|
356
381
|
|
|
357
382
|
override onViewMount = async () => {
|