@hpcc-js/marshaller 2.28.7 → 2.28.9

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.
Files changed (55) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.es6.js +25 -13
  3. package/dist/index.es6.js.map +1 -1
  4. package/dist/index.js +25 -13
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +2 -2
  7. package/dist/index.min.js.map +1 -1
  8. package/package.json +14 -14
  9. package/src/__package__.ts +3 -3
  10. package/src/dashy.css +239 -239
  11. package/src/dashy.ts +521 -521
  12. package/src/ddl1/DDLApi.ts +229 -229
  13. package/src/ddl1/FlyoutButton.ts +120 -120
  14. package/src/ddl1/Graph.ts +93 -93
  15. package/src/ddl1/HTML.ts +77 -77
  16. package/src/ddl1/HipieDDL.ts +2437 -2437
  17. package/src/ddl1/HipieDDLMixin.ts +380 -380
  18. package/src/ddl1/Tabbed.ts +91 -91
  19. package/src/ddl1/TargetMarshaller.ts +57 -57
  20. package/src/ddl2/PopupManager.ts +89 -89
  21. package/src/ddl2/activities/activity.ts +431 -431
  22. package/src/ddl2/activities/databomb.ts +237 -237
  23. package/src/ddl2/activities/datasource.ts +52 -52
  24. package/src/ddl2/activities/dspicker.ts +106 -106
  25. package/src/ddl2/activities/filter.ts +542 -542
  26. package/src/ddl2/activities/form.ts +153 -153
  27. package/src/ddl2/activities/groupby.ts +439 -439
  28. package/src/ddl2/activities/hipiepipeline.ts +114 -114
  29. package/src/ddl2/activities/limit.ts +49 -49
  30. package/src/ddl2/activities/logicalfile.ts +62 -62
  31. package/src/ddl2/activities/nullview.ts +12 -12
  32. package/src/ddl2/activities/project.ts +764 -764
  33. package/src/ddl2/activities/rest.ts +568 -568
  34. package/src/ddl2/activities/roxie.ts +490 -490
  35. package/src/ddl2/activities/sampledata.json +16264 -16264
  36. package/src/ddl2/activities/sort.ts +176 -176
  37. package/src/ddl2/activities/wuresult.ts +395 -395
  38. package/src/ddl2/dashboard.css +13 -13
  39. package/src/ddl2/dashboard.ts +330 -330
  40. package/src/ddl2/dashboardDockPanel.ts +123 -123
  41. package/src/ddl2/dashboardGrid.ts +202 -202
  42. package/src/ddl2/ddl.ts +410 -410
  43. package/src/ddl2/ddleditor.ts +60 -60
  44. package/src/ddl2/dsTable.ts +238 -238
  45. package/src/ddl2/dvTable.ts +31 -31
  46. package/src/ddl2/graphadapter.ts +297 -297
  47. package/src/ddl2/javascriptadapter.ts +354 -354
  48. package/src/ddl2/model/element.ts +398 -398
  49. package/src/ddl2/model/visualization.ts +351 -351
  50. package/src/ddl2/model/vizChartPanel.ts +149 -149
  51. package/src/ddl2/pipelinePanel.css +4 -4
  52. package/src/ddl2/pipelinePanel.ts +465 -465
  53. package/src/index.ts +26 -26
  54. package/types/__package__.d.ts +2 -2
  55. package/types-3.4/__package__.d.ts +2 -2
@@ -1,237 +1,237 @@
1
- import { DDL2 } from "@hpcc-js/ddl-shim";
2
- import { IDatasource } from "@hpcc-js/dgrid";
3
- import { isArray } from "@hpcc-js/util";
4
- import { csvParse as d3CsvParse, tsvParse as d3TsvParse } from "d3-dsv";
5
- import { Activity } from "./activity";
6
- import { Datasource } from "./datasource";
7
- import { FormField } from "./form";
8
-
9
- function fieldType(field: any): DDL2.IFieldType {
10
- if (isArray(field)) {
11
- return "dataset";
12
- }
13
- const type = typeof field;
14
- switch (type) {
15
- case "boolean":
16
- case "number":
17
- case "string":
18
- case "object":
19
- return type;
20
- }
21
- return "string";
22
- }
23
-
24
- export function rowToFields(row: object, _jsonData): DDL2.IField[] {
25
- // TODO: This heuristic will fail if there are empty nested rows in the first row...
26
- const retVal: DDL2.IField[] = [];
27
- for (const key in row) {
28
- const field = {
29
- type: fieldType(row[key]),
30
- id: key
31
- } as DDL2.IField;
32
- switch (field.type) {
33
- case "object":
34
- for (const row of _jsonData) {
35
- let found = false;
36
- for (const _childKey in row[key]) {
37
- const rowFields = rowToFields(row[key], [row[key]]);
38
- field.fields = {};
39
- if (rowFields.length) {
40
- rowFields.forEach(rf => field.fields[rf.id] = rf);
41
- found = true;
42
- }
43
- break;
44
- }
45
- if (found) break;
46
- }
47
- break;
48
- case "dataset":
49
- for (const row of _jsonData) {
50
- if (row[key] && row[key].length) {
51
- field.children = rowToFields(row[key][0], row[key]);
52
- break;
53
- }
54
- }
55
- break;
56
- }
57
- retVal.push(field);
58
- }
59
- return retVal;
60
- }
61
-
62
- export class Databomb extends Datasource {
63
-
64
- private _jsonData: ReadonlyArray<object> = [];
65
-
66
- constructor() {
67
- super();
68
- }
69
-
70
- toDDL(skipPayload: boolean = false): DDL2.IDatabomb {
71
- return {
72
- type: "databomb",
73
- id: this.id(),
74
- format: this.format(),
75
- payload: skipPayload ? undefined : this.payload(),
76
- fields: this.validFields().map(f => f.toDDL())
77
- };
78
- }
79
-
80
- fromDDL(ddl: DDL2.IDatabomb, skipID = false): this {
81
- (skipID ? this : this.id(ddl.id))
82
- .format(ddl.format)
83
- .payload(ddl.payload)
84
- .databombFields(ddl.fields.map(FormField.fromDDL))
85
- ;
86
- return this;
87
- }
88
-
89
- static fromDDL(ddl: DDL2.IDatabomb, skipID = false): Databomb {
90
- return new Databomb().fromDDL(ddl, skipID);
91
- }
92
-
93
- validFields(): FormField[] {
94
- return this.databombFields().filter(f => f.valid());
95
- }
96
-
97
- updateJsonData() {
98
- try {
99
- switch (this.format()) {
100
- case "csv":
101
- this._jsonData = d3CsvParse(this.payload());
102
- break;
103
- case "tsv":
104
- this._jsonData = d3TsvParse(this.payload());
105
- break;
106
- case "json":
107
- default:
108
- this._jsonData = JSON.parse(this.payload());
109
- break;
110
- }
111
- this.databombFields(this.preCalcFields().map(FormField.fromDDL));
112
- } catch (e) {
113
- this.databombFields([]);
114
- this._jsonData = [];
115
- }
116
- }
117
-
118
- hash(more: object): string {
119
- return super.hash({
120
- ddl: this.toDDL(true),
121
- ...more
122
- }) + this.payload();
123
- }
124
-
125
- refreshMeta(): Promise<void> {
126
- return Promise.resolve();
127
- }
128
-
129
- label(): string {
130
- return "Databomb";
131
- }
132
-
133
- private preCalcFields(): DDL2.IField[] {
134
- if (this._jsonData.length === 0) return [];
135
- return rowToFields(this._jsonData[0], this._jsonData);
136
- }
137
-
138
- computeFields(inFields: ReadonlyArray<DDL2.IField>): () => ReadonlyArray<DDL2.IField> {
139
- return () => this.validFields().map(f => f.toDDL());
140
- }
141
-
142
- exec(): Promise<void> {
143
- return Promise.resolve();
144
- }
145
-
146
- computeData(): ReadonlyArray<object> {
147
- const coarceFuncMap = {};
148
- this.validFields().forEach(field => {
149
- coarceFuncMap[field.fieldID()] = field.coerceFunc();
150
- });
151
- return this._jsonData.map(row => {
152
- const retVal = {};
153
- for (const key in coarceFuncMap) {
154
- retVal[key] = coarceFuncMap[key](row[key]);
155
- }
156
- return retVal;
157
- });
158
- }
159
-
160
- // ===
161
- total(): number {
162
- return this._jsonData.length;
163
- }
164
- }
165
- Databomb.prototype._class += " Databomb";
166
-
167
- export interface Databomb {
168
- format(): "json" | "csv" | "tsv";
169
- format(_: "json" | "csv" | "tsv"): this;
170
- payload(): string;
171
- payload(_: string): this;
172
- databombFields(): FormField[];
173
- databombFields(_: FormField[]): this;
174
- }
175
-
176
- Databomb.prototype.publish("format", "json", "set", "Databomb Format", ["json", "csv", "tsv"]);
177
- Databomb.prototype.publish("payload", "", "string", "Databomb array", null, { multiline: true });
178
- Databomb.prototype.publish("databombFields", [], "propertyArray", "Multi Fields", null, { autoExpand: FormField });
179
-
180
- const payloadFormat = Databomb.prototype.format;
181
- Databomb.prototype.format = function (this: Databomb, _?) {
182
- const retVal = payloadFormat.apply(this, arguments);
183
- if (arguments.length) {
184
- this.updateJsonData();
185
- }
186
- return retVal;
187
- };
188
-
189
- const databombPayloadOrig = Databomb.prototype.payload;
190
- Databomb.prototype.payload = function (this: Databomb, _?) {
191
- const retVal = databombPayloadOrig.apply(this, arguments);
192
- if (arguments.length) {
193
- this.updateJsonData();
194
- }
195
- return retVal;
196
- };
197
-
198
- export const emptyDatabomb = new Databomb().id("Empty").payload("[]");
199
-
200
- export class DatasourceAdapt implements IDatasource {
201
- private _activity: Activity;
202
-
203
- constructor(activity: Activity) {
204
- this._activity = activity || emptyDatabomb;
205
- }
206
-
207
- exec(): Promise<void> {
208
- return this._activity.refreshMeta().then(() => {
209
- return this._activity.exec();
210
- });
211
- }
212
-
213
- id(): string {
214
- return this._activity.id();
215
- }
216
- hash(more: { [key: string]: any } = {}): string {
217
- return this._activity.hash(more);
218
- }
219
- label(): string {
220
- return this._activity.label();
221
- }
222
- outFields(): DDL2.IField[] {
223
- return this._activity && this._activity.outFields ? this._activity.outFields() as DDL2.IField[] : [];
224
- }
225
- total(): number {
226
- return this._activity ? this._activity.outData().length : 0;
227
- }
228
- fetch(from: number, count: number): Promise<ReadonlyArray<object>> {
229
- return this.exec().then(() => {
230
- const data = this._activity.outData();
231
- if (from === 0 && data.length <= count) {
232
- return Promise.resolve(data);
233
- }
234
- return Promise.resolve(data.slice(from, from + count));
235
- });
236
- }
237
- }
1
+ import { DDL2 } from "@hpcc-js/ddl-shim";
2
+ import { IDatasource } from "@hpcc-js/dgrid";
3
+ import { isArray } from "@hpcc-js/util";
4
+ import { csvParse as d3CsvParse, tsvParse as d3TsvParse } from "d3-dsv";
5
+ import { Activity } from "./activity";
6
+ import { Datasource } from "./datasource";
7
+ import { FormField } from "./form";
8
+
9
+ function fieldType(field: any): DDL2.IFieldType {
10
+ if (isArray(field)) {
11
+ return "dataset";
12
+ }
13
+ const type = typeof field;
14
+ switch (type) {
15
+ case "boolean":
16
+ case "number":
17
+ case "string":
18
+ case "object":
19
+ return type;
20
+ }
21
+ return "string";
22
+ }
23
+
24
+ export function rowToFields(row: object, _jsonData): DDL2.IField[] {
25
+ // TODO: This heuristic will fail if there are empty nested rows in the first row...
26
+ const retVal: DDL2.IField[] = [];
27
+ for (const key in row) {
28
+ const field = {
29
+ type: fieldType(row[key]),
30
+ id: key
31
+ } as DDL2.IField;
32
+ switch (field.type) {
33
+ case "object":
34
+ for (const row of _jsonData) {
35
+ let found = false;
36
+ for (const _childKey in row[key]) {
37
+ const rowFields = rowToFields(row[key], [row[key]]);
38
+ field.fields = {};
39
+ if (rowFields.length) {
40
+ rowFields.forEach(rf => field.fields[rf.id] = rf);
41
+ found = true;
42
+ }
43
+ break;
44
+ }
45
+ if (found) break;
46
+ }
47
+ break;
48
+ case "dataset":
49
+ for (const row of _jsonData) {
50
+ if (row[key] && row[key].length) {
51
+ field.children = rowToFields(row[key][0], row[key]);
52
+ break;
53
+ }
54
+ }
55
+ break;
56
+ }
57
+ retVal.push(field);
58
+ }
59
+ return retVal;
60
+ }
61
+
62
+ export class Databomb extends Datasource {
63
+
64
+ private _jsonData: ReadonlyArray<object> = [];
65
+
66
+ constructor() {
67
+ super();
68
+ }
69
+
70
+ toDDL(skipPayload: boolean = false): DDL2.IDatabomb {
71
+ return {
72
+ type: "databomb",
73
+ id: this.id(),
74
+ format: this.format(),
75
+ payload: skipPayload ? undefined : this.payload(),
76
+ fields: this.validFields().map(f => f.toDDL())
77
+ };
78
+ }
79
+
80
+ fromDDL(ddl: DDL2.IDatabomb, skipID = false): this {
81
+ (skipID ? this : this.id(ddl.id))
82
+ .format(ddl.format)
83
+ .payload(ddl.payload)
84
+ .databombFields(ddl.fields.map(FormField.fromDDL))
85
+ ;
86
+ return this;
87
+ }
88
+
89
+ static fromDDL(ddl: DDL2.IDatabomb, skipID = false): Databomb {
90
+ return new Databomb().fromDDL(ddl, skipID);
91
+ }
92
+
93
+ validFields(): FormField[] {
94
+ return this.databombFields().filter(f => f.valid());
95
+ }
96
+
97
+ updateJsonData() {
98
+ try {
99
+ switch (this.format()) {
100
+ case "csv":
101
+ this._jsonData = d3CsvParse(this.payload());
102
+ break;
103
+ case "tsv":
104
+ this._jsonData = d3TsvParse(this.payload());
105
+ break;
106
+ case "json":
107
+ default:
108
+ this._jsonData = JSON.parse(this.payload());
109
+ break;
110
+ }
111
+ this.databombFields(this.preCalcFields().map(FormField.fromDDL));
112
+ } catch (e) {
113
+ this.databombFields([]);
114
+ this._jsonData = [];
115
+ }
116
+ }
117
+
118
+ hash(more: object): string {
119
+ return super.hash({
120
+ ddl: this.toDDL(true),
121
+ ...more
122
+ }) + this.payload();
123
+ }
124
+
125
+ refreshMeta(): Promise<void> {
126
+ return Promise.resolve();
127
+ }
128
+
129
+ label(): string {
130
+ return "Databomb";
131
+ }
132
+
133
+ private preCalcFields(): DDL2.IField[] {
134
+ if (this._jsonData.length === 0) return [];
135
+ return rowToFields(this._jsonData[0], this._jsonData);
136
+ }
137
+
138
+ computeFields(inFields: ReadonlyArray<DDL2.IField>): () => ReadonlyArray<DDL2.IField> {
139
+ return () => this.validFields().map(f => f.toDDL());
140
+ }
141
+
142
+ exec(): Promise<void> {
143
+ return Promise.resolve();
144
+ }
145
+
146
+ computeData(): ReadonlyArray<object> {
147
+ const coarceFuncMap = {};
148
+ this.validFields().forEach(field => {
149
+ coarceFuncMap[field.fieldID()] = field.coerceFunc();
150
+ });
151
+ return this._jsonData.map(row => {
152
+ const retVal = {};
153
+ for (const key in coarceFuncMap) {
154
+ retVal[key] = coarceFuncMap[key](row[key]);
155
+ }
156
+ return retVal;
157
+ });
158
+ }
159
+
160
+ // ===
161
+ total(): number {
162
+ return this._jsonData.length;
163
+ }
164
+ }
165
+ Databomb.prototype._class += " Databomb";
166
+
167
+ export interface Databomb {
168
+ format(): "json" | "csv" | "tsv";
169
+ format(_: "json" | "csv" | "tsv"): this;
170
+ payload(): string;
171
+ payload(_: string): this;
172
+ databombFields(): FormField[];
173
+ databombFields(_: FormField[]): this;
174
+ }
175
+
176
+ Databomb.prototype.publish("format", "json", "set", "Databomb Format", ["json", "csv", "tsv"]);
177
+ Databomb.prototype.publish("payload", "", "string", "Databomb array", null, { multiline: true });
178
+ Databomb.prototype.publish("databombFields", [], "propertyArray", "Multi Fields", null, { autoExpand: FormField });
179
+
180
+ const payloadFormat = Databomb.prototype.format;
181
+ Databomb.prototype.format = function (this: Databomb, _?) {
182
+ const retVal = payloadFormat.apply(this, arguments);
183
+ if (arguments.length) {
184
+ this.updateJsonData();
185
+ }
186
+ return retVal;
187
+ };
188
+
189
+ const databombPayloadOrig = Databomb.prototype.payload;
190
+ Databomb.prototype.payload = function (this: Databomb, _?) {
191
+ const retVal = databombPayloadOrig.apply(this, arguments);
192
+ if (arguments.length) {
193
+ this.updateJsonData();
194
+ }
195
+ return retVal;
196
+ };
197
+
198
+ export const emptyDatabomb = new Databomb().id("Empty").payload("[]");
199
+
200
+ export class DatasourceAdapt implements IDatasource {
201
+ private _activity: Activity;
202
+
203
+ constructor(activity: Activity) {
204
+ this._activity = activity || emptyDatabomb;
205
+ }
206
+
207
+ exec(): Promise<void> {
208
+ return this._activity.refreshMeta().then(() => {
209
+ return this._activity.exec();
210
+ });
211
+ }
212
+
213
+ id(): string {
214
+ return this._activity.id();
215
+ }
216
+ hash(more: { [key: string]: any } = {}): string {
217
+ return this._activity.hash(more);
218
+ }
219
+ label(): string {
220
+ return this._activity.label();
221
+ }
222
+ outFields(): DDL2.IField[] {
223
+ return this._activity && this._activity.outFields ? this._activity.outFields() as DDL2.IField[] : [];
224
+ }
225
+ total(): number {
226
+ return this._activity ? this._activity.outData().length : 0;
227
+ }
228
+ fetch(from: number, count: number): Promise<ReadonlyArray<object>> {
229
+ return this.exec().then(() => {
230
+ const data = this._activity.outData();
231
+ if (from === 0 && data.length <= count) {
232
+ return Promise.resolve(data);
233
+ }
234
+ return Promise.resolve(data.slice(from, from + count));
235
+ });
236
+ }
237
+ }
@@ -1,52 +1,52 @@
1
- import { publish } from "@hpcc-js/common";
2
- import { DDL2 } from "@hpcc-js/ddl-shim";
3
- import { Activity } from "./activity";
4
- import { Databomb } from "./databomb";
5
- import { Form } from "./form";
6
- import { LogicalFile } from "./logicalfile";
7
- import { RestResult, RestService } from "./rest";
8
- import { RoxieResult, RoxieService } from "./roxie";
9
- import { WU, WUResult } from "./wuresult";
10
-
11
- let datasourceID = 0;
12
- export class Datasource extends Activity {
13
-
14
- constructor() {
15
- super();
16
- this._id = `ds_${++datasourceID}`;
17
- }
18
- }
19
-
20
- export type DatasourceRefType = Databomb | Form | LogicalFile | RoxieResult | WUResult | RestResult;
21
- export type DatasourceType = Databomb | Form | LogicalFile | RoxieService | WU | RestService;
22
-
23
- export class DatasourceRef extends Activity {
24
- @publish(null, "widget", "Datasource Reference", null, { internal: true })
25
- _datasource: DatasourceRefType;
26
- datasource(): DatasourceRefType;
27
- datasource(_: DatasourceRefType): this;
28
- datasource(_?: DatasourceRefType): this | DatasourceRefType {
29
- if (!arguments.length) return this._datasource;
30
- this._datasource = _;
31
- this.sourceActivity(_);
32
- return this;
33
- }
34
-
35
- constructor() {
36
- super();
37
- }
38
-
39
- hash(more: { [key: string]: any } = {}): string {
40
- return super.hash({
41
- datasource: this._datasource ? this._datasource.hash(more) : undefined,
42
- ...more
43
- });
44
- }
45
-
46
- toDDL(): DDL2.IDatabombRef {
47
- return {
48
- id: this.datasource().id()
49
- };
50
- }
51
- }
52
- DatasourceRef.prototype._class += " DatasourceRef";
1
+ import { publish } from "@hpcc-js/common";
2
+ import { DDL2 } from "@hpcc-js/ddl-shim";
3
+ import { Activity } from "./activity";
4
+ import { Databomb } from "./databomb";
5
+ import { Form } from "./form";
6
+ import { LogicalFile } from "./logicalfile";
7
+ import { RestResult, RestService } from "./rest";
8
+ import { RoxieResult, RoxieService } from "./roxie";
9
+ import { WU, WUResult } from "./wuresult";
10
+
11
+ let datasourceID = 0;
12
+ export class Datasource extends Activity {
13
+
14
+ constructor() {
15
+ super();
16
+ this._id = `ds_${++datasourceID}`;
17
+ }
18
+ }
19
+
20
+ export type DatasourceRefType = Databomb | Form | LogicalFile | RoxieResult | WUResult | RestResult;
21
+ export type DatasourceType = Databomb | Form | LogicalFile | RoxieService | WU | RestService;
22
+
23
+ export class DatasourceRef extends Activity {
24
+ @publish(null, "widget", "Datasource Reference", null, { internal: true })
25
+ _datasource: DatasourceRefType;
26
+ datasource(): DatasourceRefType;
27
+ datasource(_: DatasourceRefType): this;
28
+ datasource(_?: DatasourceRefType): this | DatasourceRefType {
29
+ if (!arguments.length) return this._datasource;
30
+ this._datasource = _;
31
+ this.sourceActivity(_);
32
+ return this;
33
+ }
34
+
35
+ constructor() {
36
+ super();
37
+ }
38
+
39
+ hash(more: { [key: string]: any } = {}): string {
40
+ return super.hash({
41
+ datasource: this._datasource ? this._datasource.hash(more) : undefined,
42
+ ...more
43
+ });
44
+ }
45
+
46
+ toDDL(): DDL2.IDatabombRef {
47
+ return {
48
+ id: this.datasource().id()
49
+ };
50
+ }
51
+ }
52
+ DatasourceRef.prototype._class += " DatasourceRef";