@sankhyalabs/sankhyablocks 1.0.10 → 1.0.12
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/dist/index.js +40 -40
- package/dist/index.js.map +1 -1
- package/dist/types/application/SankhyaAppProvider.d.ts +0 -1
- package/package.json +81 -81
package/dist/index.js
CHANGED
|
@@ -1408,7 +1408,7 @@ var _location = __webpack_require__(16);
|
|
|
1408
1408
|
|
|
1409
1409
|
var _printLocation = __webpack_require__(38);
|
|
1410
1410
|
|
|
1411
|
-
function
|
|
1411
|
+
function toNormalizedOptions(args) {
|
|
1412
1412
|
const firstArg = args[0];
|
|
1413
1413
|
|
|
1414
1414
|
if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) {
|
|
@@ -1475,13 +1475,13 @@ class GraphQLError extends Error {
|
|
|
1475
1475
|
*/
|
|
1476
1476
|
|
|
1477
1477
|
/**
|
|
1478
|
-
* @deprecated Please use the `
|
|
1478
|
+
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
1479
1479
|
*/
|
|
1480
1480
|
constructor(message, ...rawArgs) {
|
|
1481
1481
|
var _this$nodes, _nodeLocations$, _ref;
|
|
1482
1482
|
|
|
1483
1483
|
const { nodes, source, positions, path, originalError, extensions } =
|
|
1484
|
-
|
|
1484
|
+
toNormalizedOptions(rawArgs);
|
|
1485
1485
|
super(message);
|
|
1486
1486
|
this.name = 'GraphQLError';
|
|
1487
1487
|
this.path = path !== null && path !== void 0 ? path : undefined;
|
|
@@ -8009,7 +8009,7 @@ class DataUnit {
|
|
|
8009
8009
|
this.dispatchAction(Action.LOADING_METADATA);
|
|
8010
8010
|
return new Promise((resolve, fail) => {
|
|
8011
8011
|
if (this.metadataLoader) {
|
|
8012
|
-
this.metadataLoader(this
|
|
8012
|
+
this.metadataLoader(this).then(metadata => {
|
|
8013
8013
|
this.metadata = metadata;
|
|
8014
8014
|
resolve(this.metadata);
|
|
8015
8015
|
}).catch(error => fail(error));
|
|
@@ -8024,7 +8024,7 @@ class DataUnit {
|
|
|
8024
8024
|
if (this.dataLoader) {
|
|
8025
8025
|
const sort = this.getSort();
|
|
8026
8026
|
const filters = this.getFilters();
|
|
8027
|
-
this.dataLoader(this
|
|
8027
|
+
this.dataLoader(this, sort, filters).then(records => {
|
|
8028
8028
|
this.records = records;
|
|
8029
8029
|
resolve(this.records);
|
|
8030
8030
|
}).catch(error => fail(error));
|
|
@@ -8039,7 +8039,7 @@ class DataUnit {
|
|
|
8039
8039
|
this.dispatchAction(Action.SAVING_DATA);
|
|
8040
8040
|
return new Promise((resolve, fail) => {
|
|
8041
8041
|
if (this.saveLoader) {
|
|
8042
|
-
this.saveLoader(this
|
|
8042
|
+
this.saveLoader(this, changes).then(records => this.dispatchAction(Action.DATA_SAVED, { changes, records })).catch(error => fail(error));
|
|
8043
8043
|
}
|
|
8044
8044
|
});
|
|
8045
8045
|
}
|
|
@@ -8047,6 +8047,10 @@ class DataUnit {
|
|
|
8047
8047
|
});
|
|
8048
8048
|
}
|
|
8049
8049
|
// API
|
|
8050
|
+
valueFromString(fieldName, value) {
|
|
8051
|
+
const descriptor = this.getField(fieldName);
|
|
8052
|
+
return descriptor ? convertType(descriptor.dataType, value) : value;
|
|
8053
|
+
}
|
|
8050
8054
|
addInterceptor(interceptor) {
|
|
8051
8055
|
this._interceptors.push(interceptor);
|
|
8052
8056
|
}
|
|
@@ -8143,6 +8147,9 @@ class DataUnit {
|
|
|
8143
8147
|
redo() {
|
|
8144
8148
|
this.dispatchAction(Action.CHANGE_REDONE);
|
|
8145
8149
|
}
|
|
8150
|
+
toString() {
|
|
8151
|
+
return this.name;
|
|
8152
|
+
}
|
|
8146
8153
|
// Actions / State manager
|
|
8147
8154
|
dispatchAction(actionType, payload) {
|
|
8148
8155
|
var _a;
|
|
@@ -8567,8 +8574,8 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8567
8574
|
key: "buldTemplates",
|
|
8568
8575
|
value: function buldTemplates() {
|
|
8569
8576
|
this.templateByQuery.set("fetchDataUnit", (0,dist.gql)(_templateObject || (_templateObject = _taggedTemplateLiteral(["query($name: String!) {\n $queryAlias$: fetchDataUnit(name: $name){\n name\n fields{\n name\n defaultValue\n label\n readOnly\n required\n dataType\n userInterface\n properties{\n name\n value\n }\n dependencies{\n masterFields\n type\n expression\n }\n }\n }\n }"]))));
|
|
8570
|
-
this.templateByQuery.set("fetchData", (0,dist.gql)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {\n $queryAlias$: fetchDataUnit(name: $dataunit){\n data(first: $first offset: $offset filters: $filter sort: $sort){\n first\n offset\n total\n hasMore\n records{\n id\n fields {\n name\n value\n
|
|
8571
|
-
this.templateByQuery.set("saveData", (0,dist.gql)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["mutation($changes: [Change!]!) {\n $queryAlias$: saveDataUnitChanges(changes: $changes){\n oldId\n id\n fields {\n name\n value\n
|
|
8577
|
+
this.templateByQuery.set("fetchData", (0,dist.gql)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {\n $queryAlias$: fetchDataUnit(name: $dataunit){\n data(first: $first offset: $offset filters: $filter sort: $sort){\n first\n offset\n total\n hasMore\n records{\n id\n fields {\n name\n value\n }\n }\n }\n }\n }"]))));
|
|
8578
|
+
this.templateByQuery.set("saveData", (0,dist.gql)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["mutation($changes: [Change!]!) {\n $queryAlias$: saveDataUnitChanges(changes: $changes){\n oldId\n id\n fields {\n name\n value\n }\n }\n }"]))));
|
|
8572
8579
|
}
|
|
8573
8580
|
}, {
|
|
8574
8581
|
key: "getDataUnit",
|
|
@@ -8577,8 +8584,8 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8577
8584
|
|
|
8578
8585
|
var dataUnit = new DataUnit("dd://".concat(entityName, "/").concat(resourceID));
|
|
8579
8586
|
|
|
8580
|
-
dataUnit.metadataLoader = function (
|
|
8581
|
-
return _this.loadMetadata(
|
|
8587
|
+
dataUnit.metadataLoader = function (dataUnit) {
|
|
8588
|
+
return _this.loadMetadata(dataUnit);
|
|
8582
8589
|
};
|
|
8583
8590
|
|
|
8584
8591
|
dataUnit.dataLoader = function (dataUnit, sort, filters) {
|
|
@@ -8599,7 +8606,7 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8599
8606
|
return new Promise(function (resolve, reject) {
|
|
8600
8607
|
HttpFetcher.get().callGraphQL({
|
|
8601
8608
|
values: {
|
|
8602
|
-
name: dataUnit
|
|
8609
|
+
name: dataUnit.name
|
|
8603
8610
|
},
|
|
8604
8611
|
query: _this2.templateByQuery.get("fetchDataUnit")
|
|
8605
8612
|
}).then(function (resp) {
|
|
@@ -8638,7 +8645,7 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8638
8645
|
return new Promise(function (resolve, reject) {
|
|
8639
8646
|
HttpFetcher.get().callGraphQL({
|
|
8640
8647
|
values: {
|
|
8641
|
-
dataunit: dataUnit,
|
|
8648
|
+
dataunit: dataUnit.name,
|
|
8642
8649
|
sort: sort,
|
|
8643
8650
|
filters: filters
|
|
8644
8651
|
},
|
|
@@ -8652,12 +8659,8 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8652
8659
|
};
|
|
8653
8660
|
responseRecord.fields.forEach(function (_ref) {
|
|
8654
8661
|
var name = _ref.name,
|
|
8655
|
-
value = _ref.value
|
|
8656
|
-
|
|
8657
|
-
duRecord[name] = description ? {
|
|
8658
|
-
value: value,
|
|
8659
|
-
label: description
|
|
8660
|
-
} : value;
|
|
8662
|
+
value = _ref.value;
|
|
8663
|
+
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
8661
8664
|
});
|
|
8662
8665
|
dataUnitRecords.push(duRecord);
|
|
8663
8666
|
});
|
|
@@ -8669,11 +8672,11 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8669
8672
|
}
|
|
8670
8673
|
}, {
|
|
8671
8674
|
key: "saveData",
|
|
8672
|
-
value: function saveData(
|
|
8675
|
+
value: function saveData(dataUnit, duChanges) {
|
|
8673
8676
|
var _this4 = this;
|
|
8674
8677
|
|
|
8675
8678
|
var changes = duChanges.map(function (change) {
|
|
8676
|
-
var
|
|
8679
|
+
var changeDU = change.dataUnit,
|
|
8677
8680
|
record = change.record,
|
|
8678
8681
|
updatingFields = change.updatingFields,
|
|
8679
8682
|
operation = change.operation;
|
|
@@ -8682,17 +8685,14 @@ var DataUnitFetcher = /*#__PURE__*/function () {
|
|
|
8682
8685
|
fieldName = _ref3[0],
|
|
8683
8686
|
value = _ref3[1];
|
|
8684
8687
|
|
|
8685
|
-
|
|
8686
|
-
value = value.toString();
|
|
8687
|
-
}
|
|
8688
|
-
|
|
8688
|
+
value = dataUnit.valueFromString(dataUnit.name === changeDU ? fieldName : "".concat(changeDU, "/").concat(fieldName), value);
|
|
8689
8689
|
return {
|
|
8690
8690
|
fieldName: fieldName,
|
|
8691
8691
|
value: value
|
|
8692
8692
|
};
|
|
8693
8693
|
});
|
|
8694
8694
|
return {
|
|
8695
|
-
dataUnit:
|
|
8695
|
+
dataUnit: changeDU,
|
|
8696
8696
|
updatingFields: parsedUpdatingFields,
|
|
8697
8697
|
operation: operation,
|
|
8698
8698
|
recordId: record.__record__id__
|
|
@@ -9275,9 +9275,7 @@ var SankhyaAppProvider = /*#__PURE__*/function (_ApplicationUtils) {
|
|
|
9275
9275
|
function SankhyaAppProvider() {
|
|
9276
9276
|
SankhyaAppProvider_classCallCheck(this, SankhyaAppProvider);
|
|
9277
9277
|
|
|
9278
|
-
|
|
9279
|
-
console.log("location.search", location.search);
|
|
9280
|
-
return _super.call(this);
|
|
9278
|
+
return _super.apply(this, arguments);
|
|
9281
9279
|
}
|
|
9282
9280
|
|
|
9283
9281
|
SankhyaAppProvider_createClass(SankhyaAppProvider, null, [{
|
|
@@ -9289,7 +9287,9 @@ var SankhyaAppProvider = /*#__PURE__*/function (_ApplicationUtils) {
|
|
|
9289
9287
|
key: "getResourceID",
|
|
9290
9288
|
value: function getResourceID() {
|
|
9291
9289
|
var defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
9292
|
-
|
|
9290
|
+
console.log("_urlParams", SankhyaAppProvider._urlParams);
|
|
9291
|
+
console.log("location.search", location.search);
|
|
9292
|
+
return SankhyaAppProvider._urlParams.get("workspaceResourceID") || SankhyaAppProvider._urlParams.get("resourceID") || defaultValue || Workspace.resourceID || "unknown.resource.id";
|
|
9293
9293
|
}
|
|
9294
9294
|
}, {
|
|
9295
9295
|
key: "temOpcional",
|
|
@@ -9332,21 +9332,21 @@ var SankhyaAppProvider = /*#__PURE__*/function (_ApplicationUtils) {
|
|
|
9332
9332
|
dataUnit.loadMetadata();
|
|
9333
9333
|
return dataUnit;
|
|
9334
9334
|
}
|
|
9335
|
-
/*public static getForm(entityName:string):any{
|
|
9336
|
-
return (<ez-button></ez-button>);
|
|
9337
|
-
//const form:EzForm = new EzForm();
|
|
9338
|
-
//TODO: Setar dataunit, aguardando merge
|
|
9339
|
-
//form.dataUnit = SankhyaAppProvider.getDataunit(entityName, true);
|
|
9340
|
-
//return form;
|
|
9335
|
+
/*public static getForm(entityName:string):any{
|
|
9336
|
+
return (<ez-button></ez-button>);
|
|
9337
|
+
//const form:EzForm = new EzForm();
|
|
9338
|
+
//TODO: Setar dataunit, aguardando merge
|
|
9339
|
+
//form.dataUnit = SankhyaAppProvider.getDataunit(entityName, true);
|
|
9340
|
+
//return form;
|
|
9341
9341
|
}*/
|
|
9342
9342
|
|
|
9343
|
-
/*public static getDataGrid(entityName:string):EzGrid{
|
|
9344
|
-
|
|
9343
|
+
/*public static getDataGrid(entityName:string):EzGrid{
|
|
9344
|
+
|
|
9345
9345
|
}*/
|
|
9346
9346
|
|
|
9347
|
-
/*TODO: Aguardar criação do painel de filtros.
|
|
9348
|
-
public static getFilterPanel(entityName:string):EzGrid{
|
|
9349
|
-
|
|
9347
|
+
/*TODO: Aguardar criação do painel de filtros.
|
|
9348
|
+
public static getFilterPanel(entityName:string):EzGrid{
|
|
9349
|
+
|
|
9350
9350
|
}*/
|
|
9351
9351
|
|
|
9352
9352
|
}]);
|