@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.
- package/LICENSE +43 -43
- package/dist/index.es6.js +25 -13
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +25 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/package.json +14 -14
- package/src/__package__.ts +3 -3
- package/src/dashy.css +239 -239
- package/src/dashy.ts +521 -521
- package/src/ddl1/DDLApi.ts +229 -229
- package/src/ddl1/FlyoutButton.ts +120 -120
- package/src/ddl1/Graph.ts +93 -93
- package/src/ddl1/HTML.ts +77 -77
- package/src/ddl1/HipieDDL.ts +2437 -2437
- package/src/ddl1/HipieDDLMixin.ts +380 -380
- package/src/ddl1/Tabbed.ts +91 -91
- package/src/ddl1/TargetMarshaller.ts +57 -57
- package/src/ddl2/PopupManager.ts +89 -89
- package/src/ddl2/activities/activity.ts +431 -431
- package/src/ddl2/activities/databomb.ts +237 -237
- package/src/ddl2/activities/datasource.ts +52 -52
- package/src/ddl2/activities/dspicker.ts +106 -106
- package/src/ddl2/activities/filter.ts +542 -542
- package/src/ddl2/activities/form.ts +153 -153
- package/src/ddl2/activities/groupby.ts +439 -439
- package/src/ddl2/activities/hipiepipeline.ts +114 -114
- package/src/ddl2/activities/limit.ts +49 -49
- package/src/ddl2/activities/logicalfile.ts +62 -62
- package/src/ddl2/activities/nullview.ts +12 -12
- package/src/ddl2/activities/project.ts +764 -764
- package/src/ddl2/activities/rest.ts +568 -568
- package/src/ddl2/activities/roxie.ts +490 -490
- package/src/ddl2/activities/sampledata.json +16264 -16264
- package/src/ddl2/activities/sort.ts +176 -176
- package/src/ddl2/activities/wuresult.ts +395 -395
- package/src/ddl2/dashboard.css +13 -13
- package/src/ddl2/dashboard.ts +330 -330
- package/src/ddl2/dashboardDockPanel.ts +123 -123
- package/src/ddl2/dashboardGrid.ts +202 -202
- package/src/ddl2/ddl.ts +410 -410
- package/src/ddl2/ddleditor.ts +60 -60
- package/src/ddl2/dsTable.ts +238 -238
- package/src/ddl2/dvTable.ts +31 -31
- package/src/ddl2/graphadapter.ts +297 -297
- package/src/ddl2/javascriptadapter.ts +354 -354
- package/src/ddl2/model/element.ts +398 -398
- package/src/ddl2/model/visualization.ts +351 -351
- package/src/ddl2/model/vizChartPanel.ts +149 -149
- package/src/ddl2/pipelinePanel.css +4 -4
- package/src/ddl2/pipelinePanel.ts +465 -465
- package/src/index.ts +26 -26
- package/types/__package__.d.ts +2 -2
- package/types-3.4/__package__.d.ts +2 -2
|
@@ -1,431 +1,431 @@
|
|
|
1
|
-
import { IMonitorHandle, PropertyExt } from "@hpcc-js/common";
|
|
2
|
-
import { IField as WsEclField } from "@hpcc-js/comms";
|
|
3
|
-
import { DDL2 } from "@hpcc-js/ddl-shim";
|
|
4
|
-
import { hashSum, update } from "@hpcc-js/util";
|
|
5
|
-
|
|
6
|
-
export function stringify(obj_from_json) {
|
|
7
|
-
if (Array.isArray(obj_from_json)) {
|
|
8
|
-
// not an object, stringify using native function
|
|
9
|
-
return "[" + obj_from_json.map(stringify).join(", ") + "]";
|
|
10
|
-
}
|
|
11
|
-
if (typeof obj_from_json !== "object" || obj_from_json === null || obj_from_json === undefined) {
|
|
12
|
-
// not an object, stringify using native function
|
|
13
|
-
return JSON.stringify(obj_from_json);
|
|
14
|
-
}
|
|
15
|
-
// Implements recursive object serialization according to JSON spec
|
|
16
|
-
// but without quotes around the keys.
|
|
17
|
-
const props = Object
|
|
18
|
-
.keys(obj_from_json)
|
|
19
|
-
.map(key => `${key}: ${stringify(obj_from_json[key])}`)
|
|
20
|
-
.join(", ");
|
|
21
|
-
return `{ ${props} }`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function schemaType2IFieldType(type): "boolean" | "number" | "number64" | "range" | "string" {
|
|
25
|
-
switch (type) {
|
|
26
|
-
case "boolean":
|
|
27
|
-
return "boolean";
|
|
28
|
-
case "xs:byte":
|
|
29
|
-
case "xs:double":
|
|
30
|
-
case "xs:decimal":
|
|
31
|
-
case "xs:float":
|
|
32
|
-
case "xs:int":
|
|
33
|
-
case "xs:short":
|
|
34
|
-
case "xs:unsignedInt":
|
|
35
|
-
case "xs:unsignedShort":
|
|
36
|
-
case "xs:unsignedByte":
|
|
37
|
-
case "number":
|
|
38
|
-
return "number";
|
|
39
|
-
case "xs:integer":
|
|
40
|
-
case "xs:long":
|
|
41
|
-
case "xs:negativeInteger":
|
|
42
|
-
case "xs:nonNegativeInteger":
|
|
43
|
-
case "xs:nonPositiveInteger":
|
|
44
|
-
case "xs:positiveInteger":
|
|
45
|
-
case "xs:unsignedLong":
|
|
46
|
-
return "number64";
|
|
47
|
-
case "string":
|
|
48
|
-
return "string";
|
|
49
|
-
case "range":
|
|
50
|
-
return "range";
|
|
51
|
-
}
|
|
52
|
-
return "string";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function schemaRow2IField(row: any): DDL2.IField {
|
|
56
|
-
if (row._children && row._children.length) {
|
|
57
|
-
return {
|
|
58
|
-
type: "dataset",
|
|
59
|
-
id: row.name,
|
|
60
|
-
children: row._children.map(schemaRow2IField)
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
return {
|
|
64
|
-
id: row.name,
|
|
65
|
-
type: schemaType2IFieldType(row.type)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function wsEclSchemaRow2IField(row: WsEclField): DDL2.IField {
|
|
71
|
-
return row;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type ReferencedFields = {
|
|
75
|
-
inputs: { [activityID: string]: string[] },
|
|
76
|
-
outputs: { [activityID: string]: string[] }
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export interface IActivityError {
|
|
80
|
-
source: string;
|
|
81
|
-
msg: string;
|
|
82
|
-
hint: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/*
|
|
86
|
-
export const ROW_ID = "__##__"; // TODO: Should be Symbol
|
|
87
|
-
export function rowID(row: Readonly<object>): undefined | number {
|
|
88
|
-
return row[ROW_ID] || row["__lparam"];
|
|
89
|
-
}
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export abstract class Activity extends PropertyExt {
|
|
93
|
-
private _sourceActivity: Activity;
|
|
94
|
-
|
|
95
|
-
fixInt64(data) {
|
|
96
|
-
if (!data || data.length === 0) return [];
|
|
97
|
-
const int64Fields = this.outFields().filter(field => {
|
|
98
|
-
switch (field.type) {
|
|
99
|
-
case "number":
|
|
100
|
-
// Test actual data for integer64 cases.
|
|
101
|
-
return typeof data[0][field.id] !== "number";
|
|
102
|
-
case "number64":
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
return false;
|
|
106
|
-
});
|
|
107
|
-
if (int64Fields.length) {
|
|
108
|
-
return data.map(row => {
|
|
109
|
-
for (const int64Field of int64Fields) {
|
|
110
|
-
row[int64Field.id] = +row[int64Field.id];
|
|
111
|
-
}
|
|
112
|
-
return row;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return data;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
sourceActivity(): Activity;
|
|
119
|
-
sourceActivity(_: Activity): this;
|
|
120
|
-
sourceActivity(_?: Activity): Activity | this {
|
|
121
|
-
if (!arguments.length) return this._sourceActivity;
|
|
122
|
-
this._sourceActivity = _;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
hash(more: object = {}): string {
|
|
127
|
-
return hashSum({
|
|
128
|
-
...more
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
refreshMeta(): Promise<void> {
|
|
133
|
-
return this._sourceActivity ? this._sourceActivity.refreshMeta() : Promise.resolve();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
exists(): boolean {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
validate(): IActivityError[] {
|
|
141
|
-
return [];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
label(): string {
|
|
145
|
-
return this.id();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
updatedBy(): string[] {
|
|
149
|
-
return [];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private _emptyFields: ReadonlyArray<DDL2.IField> = [];
|
|
153
|
-
inFields(): ReadonlyArray<DDL2.IField> {
|
|
154
|
-
return this._sourceActivity ? this._sourceActivity.outFields() : this._emptyFields;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
computeFields(inFields: ReadonlyArray<DDL2.IField>): () => ReadonlyArray<DDL2.IField> {
|
|
158
|
-
return () => inFields;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
outFields(): ReadonlyArray<DDL2.IField> {
|
|
162
|
-
return this.computeFields(this.inFields())();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
localFields(): DDL2.IField[] {
|
|
166
|
-
const inFieldIDs = this.inFields().map(field => field.id);
|
|
167
|
-
return this.outFields().filter(field => inFieldIDs.indexOf(field.id) < 0);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
fieldOrigin(fieldID: string): Activity | null {
|
|
171
|
-
if (this.localFields().filter(field => field.id === fieldID).length) {
|
|
172
|
-
return this;
|
|
173
|
-
} else if (this.sourceActivity()) {
|
|
174
|
-
return this.sourceActivity().fieldOrigin(fieldID);
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
180
|
-
for (const fieldID of fieldIDs) {
|
|
181
|
-
const fieldOrigin = this.fieldOrigin(fieldID);
|
|
182
|
-
if (fieldOrigin) {
|
|
183
|
-
if (!refs.outputs[fieldOrigin.id()]) {
|
|
184
|
-
refs.outputs[fieldOrigin.id()] = [];
|
|
185
|
-
}
|
|
186
|
-
if (refs.outputs[fieldOrigin.id()].indexOf(fieldID) < 0) {
|
|
187
|
-
refs.outputs[fieldOrigin.id()].push(fieldID);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
194
|
-
return this._sourceActivity && this._sourceActivity.resolveFields(refs, fieldIDs);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
referencedFields(refs: ReferencedFields): void {
|
|
198
|
-
this._sourceActivity && this._sourceActivity.referencedFields(refs);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
exec(): Promise<void> {
|
|
202
|
-
return this._sourceActivity ? this._sourceActivity.exec() : Promise.resolve();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
_emptyData: ReadonlyArray<object> = [];
|
|
206
|
-
inData(): ReadonlyArray<object> {
|
|
207
|
-
return this._sourceActivity ? this._sourceActivity.outData() || this._emptyData : this._emptyData;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
computeData(): ReadonlyArray<object> {
|
|
211
|
-
return this.inData();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
private _prevDataHash: string = "";
|
|
215
|
-
private _prevInData: ReadonlyArray<object> = [];
|
|
216
|
-
private _prevData: ReadonlyArray<object> = [];
|
|
217
|
-
private cachedComputeData(inData: ReadonlyArray<object>): ReadonlyArray<object> {
|
|
218
|
-
const hash = this.hash();
|
|
219
|
-
if (this._prevDataHash !== hash || this._prevInData !== inData) {
|
|
220
|
-
this._prevDataHash = hash;
|
|
221
|
-
this._prevInData = inData;
|
|
222
|
-
this._prevData = update(this._prevData, this.computeData());
|
|
223
|
-
}
|
|
224
|
-
return this._prevData;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
outData(): ReadonlyArray<object> {
|
|
228
|
-
return this.cachedComputeData(this.inData());
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export class ActivityArray extends Activity {
|
|
233
|
-
private _activities: Activity[] = [];
|
|
234
|
-
|
|
235
|
-
activities(): Activity[];
|
|
236
|
-
activities(_: Activity[]): this;
|
|
237
|
-
activities(_?: Activity[]): Activity[] | this {
|
|
238
|
-
if (!arguments.length) return this._activities;
|
|
239
|
-
this._activities = _;
|
|
240
|
-
return this;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
ActivityArray.prototype._class += " ActivityArray";
|
|
244
|
-
|
|
245
|
-
export class ActivityPipeline extends ActivityArray {
|
|
246
|
-
|
|
247
|
-
activities(): Activity[];
|
|
248
|
-
activities(_: Activity[]): this;
|
|
249
|
-
activities(_?: Activity[]): Activity[] | this {
|
|
250
|
-
if (!arguments.length) return super.activities();
|
|
251
|
-
super.activities(_);
|
|
252
|
-
let prevActivity: Activity;
|
|
253
|
-
for (const activity of _) {
|
|
254
|
-
if (prevActivity) {
|
|
255
|
-
activity.sourceActivity(prevActivity);
|
|
256
|
-
}
|
|
257
|
-
prevActivity = activity;
|
|
258
|
-
}
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
first(): Activity {
|
|
263
|
-
const retVal = this.activities();
|
|
264
|
-
return retVal[0];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
last(): Activity | null {
|
|
268
|
-
const retVal = this.activities();
|
|
269
|
-
return retVal[retVal.length - 1];
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
protected calcUpdatedGraph(activity: Activity): Array<{ from: string, to: Activity }> {
|
|
273
|
-
return activity.updatedBy().map(source => {
|
|
274
|
-
return {
|
|
275
|
-
from: source,
|
|
276
|
-
to: activity
|
|
277
|
-
};
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
updatedByGraph(): Array<{ from: string, to: Activity }> {
|
|
282
|
-
let retVal: Array<{ from: string, to: Activity }> = [];
|
|
283
|
-
for (const activity of this.activities()) {
|
|
284
|
-
retVal = retVal.concat(this.calcUpdatedGraph(activity));
|
|
285
|
-
}
|
|
286
|
-
return retVal;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
fetch(from: number = 0, count: number = Number.MAX_VALUE): Promise<ReadonlyArray<object>> {
|
|
290
|
-
return this.exec().then(() => {
|
|
291
|
-
const data = this.outData();
|
|
292
|
-
if (from === 0 && data.length <= count) {
|
|
293
|
-
return data;
|
|
294
|
-
}
|
|
295
|
-
return data.slice(from, from + count);
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Activity overrides ---
|
|
300
|
-
hash(more: { [key: string]: any } = {}): string {
|
|
301
|
-
return hashSum({
|
|
302
|
-
activities: [this.activities().map(activity => activity.hash())],
|
|
303
|
-
...more
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
refreshMeta(): Promise<void> {
|
|
308
|
-
return this.last().refreshMeta();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
updatedBy(): string[] {
|
|
312
|
-
let retVal: string[] = [];
|
|
313
|
-
for (const activity of this.activities()) {
|
|
314
|
-
retVal = retVal.concat(activity.updatedBy());
|
|
315
|
-
}
|
|
316
|
-
return retVal;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
inFields(): ReadonlyArray<DDL2.IField> {
|
|
320
|
-
return this.first().inFields();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
outFields(): ReadonlyArray<DDL2.IField> {
|
|
324
|
-
return this.last().outFields();
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
localFields(): DDL2.IField[] {
|
|
328
|
-
return this.last().localFields();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
fieldOrigin(fieldID: string): Activity | null {
|
|
332
|
-
return this.last().fieldOrigin(fieldID);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
referencedFields(refs: ReferencedFields) {
|
|
336
|
-
this.last().referencedFields(refs);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
340
|
-
this.last().resolveInFields(refs, fieldIDs);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
344
|
-
this.last().resolveFields(refs, fieldIDs);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
exec(): Promise<void> {
|
|
348
|
-
return this.last().exec();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
outData(): ReadonlyArray<object> {
|
|
352
|
-
return this.last().outData();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
ActivityPipeline.prototype._class += " ActivitySequence";
|
|
356
|
-
|
|
357
|
-
export class ActivitySelection extends ActivityArray {
|
|
358
|
-
private _selection: Activity;
|
|
359
|
-
private _monitorHandle: IMonitorHandle;
|
|
360
|
-
|
|
361
|
-
selection(): Activity;
|
|
362
|
-
selection(_: Activity): this;
|
|
363
|
-
selection(_?: Activity): Activity | this {
|
|
364
|
-
if (_ === undefined) return this._selection;
|
|
365
|
-
if (this._monitorHandle) {
|
|
366
|
-
this._monitorHandle.remove();
|
|
367
|
-
}
|
|
368
|
-
this._selection = _;
|
|
369
|
-
this._monitorHandle = _.monitor((id, newVal, oldVal) => {
|
|
370
|
-
this.broadcast(id, newVal, oldVal, _);
|
|
371
|
-
});
|
|
372
|
-
return this;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// Activity overrides ---
|
|
376
|
-
hash(more: { [key: string]: any } = {}): string {
|
|
377
|
-
return hashSum({
|
|
378
|
-
selection: this.selection().hash(),
|
|
379
|
-
...more
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
label(): string {
|
|
384
|
-
return this.selection().label();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
refreshMeta(): Promise<void> {
|
|
388
|
-
return this.selection().refreshMeta();
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
updatedBy(): string[] {
|
|
392
|
-
return this.selection().updatedBy();
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
inFields(): ReadonlyArray<DDL2.IField> {
|
|
396
|
-
return this.selection().inFields();
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
outFields(): ReadonlyArray<DDL2.IField> {
|
|
400
|
-
return this.selection().outFields();
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
localFields(): DDL2.IField[] {
|
|
404
|
-
return this.selection().localFields();
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
fieldOrigin(fieldID: string): Activity | null {
|
|
408
|
-
return this.selection().fieldOrigin(fieldID);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
referencedFields(refs: ReferencedFields) {
|
|
412
|
-
this.selection().referencedFields(refs);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
416
|
-
this.selection().resolveInFields(refs, fieldIDs);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
420
|
-
this.selection().resolveFields(refs, fieldIDs);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
exec(): Promise<void> {
|
|
424
|
-
return this.selection().exec();
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
outData(): ReadonlyArray<object> {
|
|
428
|
-
return this.selection().outData();
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
ActivitySelection.prototype._class += " ActivitySelection";
|
|
1
|
+
import { IMonitorHandle, PropertyExt } from "@hpcc-js/common";
|
|
2
|
+
import { IField as WsEclField } from "@hpcc-js/comms";
|
|
3
|
+
import { DDL2 } from "@hpcc-js/ddl-shim";
|
|
4
|
+
import { hashSum, update } from "@hpcc-js/util";
|
|
5
|
+
|
|
6
|
+
export function stringify(obj_from_json) {
|
|
7
|
+
if (Array.isArray(obj_from_json)) {
|
|
8
|
+
// not an object, stringify using native function
|
|
9
|
+
return "[" + obj_from_json.map(stringify).join(", ") + "]";
|
|
10
|
+
}
|
|
11
|
+
if (typeof obj_from_json !== "object" || obj_from_json === null || obj_from_json === undefined) {
|
|
12
|
+
// not an object, stringify using native function
|
|
13
|
+
return JSON.stringify(obj_from_json);
|
|
14
|
+
}
|
|
15
|
+
// Implements recursive object serialization according to JSON spec
|
|
16
|
+
// but without quotes around the keys.
|
|
17
|
+
const props = Object
|
|
18
|
+
.keys(obj_from_json)
|
|
19
|
+
.map(key => `${key}: ${stringify(obj_from_json[key])}`)
|
|
20
|
+
.join(", ");
|
|
21
|
+
return `{ ${props} }`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function schemaType2IFieldType(type): "boolean" | "number" | "number64" | "range" | "string" {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case "boolean":
|
|
27
|
+
return "boolean";
|
|
28
|
+
case "xs:byte":
|
|
29
|
+
case "xs:double":
|
|
30
|
+
case "xs:decimal":
|
|
31
|
+
case "xs:float":
|
|
32
|
+
case "xs:int":
|
|
33
|
+
case "xs:short":
|
|
34
|
+
case "xs:unsignedInt":
|
|
35
|
+
case "xs:unsignedShort":
|
|
36
|
+
case "xs:unsignedByte":
|
|
37
|
+
case "number":
|
|
38
|
+
return "number";
|
|
39
|
+
case "xs:integer":
|
|
40
|
+
case "xs:long":
|
|
41
|
+
case "xs:negativeInteger":
|
|
42
|
+
case "xs:nonNegativeInteger":
|
|
43
|
+
case "xs:nonPositiveInteger":
|
|
44
|
+
case "xs:positiveInteger":
|
|
45
|
+
case "xs:unsignedLong":
|
|
46
|
+
return "number64";
|
|
47
|
+
case "string":
|
|
48
|
+
return "string";
|
|
49
|
+
case "range":
|
|
50
|
+
return "range";
|
|
51
|
+
}
|
|
52
|
+
return "string";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function schemaRow2IField(row: any): DDL2.IField {
|
|
56
|
+
if (row._children && row._children.length) {
|
|
57
|
+
return {
|
|
58
|
+
type: "dataset",
|
|
59
|
+
id: row.name,
|
|
60
|
+
children: row._children.map(schemaRow2IField)
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
return {
|
|
64
|
+
id: row.name,
|
|
65
|
+
type: schemaType2IFieldType(row.type)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function wsEclSchemaRow2IField(row: WsEclField): DDL2.IField {
|
|
71
|
+
return row;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type ReferencedFields = {
|
|
75
|
+
inputs: { [activityID: string]: string[] },
|
|
76
|
+
outputs: { [activityID: string]: string[] }
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export interface IActivityError {
|
|
80
|
+
source: string;
|
|
81
|
+
msg: string;
|
|
82
|
+
hint: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
export const ROW_ID = "__##__"; // TODO: Should be Symbol
|
|
87
|
+
export function rowID(row: Readonly<object>): undefined | number {
|
|
88
|
+
return row[ROW_ID] || row["__lparam"];
|
|
89
|
+
}
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
export abstract class Activity extends PropertyExt {
|
|
93
|
+
private _sourceActivity: Activity;
|
|
94
|
+
|
|
95
|
+
fixInt64(data) {
|
|
96
|
+
if (!data || data.length === 0) return [];
|
|
97
|
+
const int64Fields = this.outFields().filter(field => {
|
|
98
|
+
switch (field.type) {
|
|
99
|
+
case "number":
|
|
100
|
+
// Test actual data for integer64 cases.
|
|
101
|
+
return typeof data[0][field.id] !== "number";
|
|
102
|
+
case "number64":
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
});
|
|
107
|
+
if (int64Fields.length) {
|
|
108
|
+
return data.map(row => {
|
|
109
|
+
for (const int64Field of int64Fields) {
|
|
110
|
+
row[int64Field.id] = +row[int64Field.id];
|
|
111
|
+
}
|
|
112
|
+
return row;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return data;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
sourceActivity(): Activity;
|
|
119
|
+
sourceActivity(_: Activity): this;
|
|
120
|
+
sourceActivity(_?: Activity): Activity | this {
|
|
121
|
+
if (!arguments.length) return this._sourceActivity;
|
|
122
|
+
this._sourceActivity = _;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
hash(more: object = {}): string {
|
|
127
|
+
return hashSum({
|
|
128
|
+
...more
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
refreshMeta(): Promise<void> {
|
|
133
|
+
return this._sourceActivity ? this._sourceActivity.refreshMeta() : Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exists(): boolean {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
validate(): IActivityError[] {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
label(): string {
|
|
145
|
+
return this.id();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
updatedBy(): string[] {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private _emptyFields: ReadonlyArray<DDL2.IField> = [];
|
|
153
|
+
inFields(): ReadonlyArray<DDL2.IField> {
|
|
154
|
+
return this._sourceActivity ? this._sourceActivity.outFields() : this._emptyFields;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
computeFields(inFields: ReadonlyArray<DDL2.IField>): () => ReadonlyArray<DDL2.IField> {
|
|
158
|
+
return () => inFields;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
outFields(): ReadonlyArray<DDL2.IField> {
|
|
162
|
+
return this.computeFields(this.inFields())();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
localFields(): DDL2.IField[] {
|
|
166
|
+
const inFieldIDs = this.inFields().map(field => field.id);
|
|
167
|
+
return this.outFields().filter(field => inFieldIDs.indexOf(field.id) < 0);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fieldOrigin(fieldID: string): Activity | null {
|
|
171
|
+
if (this.localFields().filter(field => field.id === fieldID).length) {
|
|
172
|
+
return this;
|
|
173
|
+
} else if (this.sourceActivity()) {
|
|
174
|
+
return this.sourceActivity().fieldOrigin(fieldID);
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
180
|
+
for (const fieldID of fieldIDs) {
|
|
181
|
+
const fieldOrigin = this.fieldOrigin(fieldID);
|
|
182
|
+
if (fieldOrigin) {
|
|
183
|
+
if (!refs.outputs[fieldOrigin.id()]) {
|
|
184
|
+
refs.outputs[fieldOrigin.id()] = [];
|
|
185
|
+
}
|
|
186
|
+
if (refs.outputs[fieldOrigin.id()].indexOf(fieldID) < 0) {
|
|
187
|
+
refs.outputs[fieldOrigin.id()].push(fieldID);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
194
|
+
return this._sourceActivity && this._sourceActivity.resolveFields(refs, fieldIDs);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
referencedFields(refs: ReferencedFields): void {
|
|
198
|
+
this._sourceActivity && this._sourceActivity.referencedFields(refs);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
exec(): Promise<void> {
|
|
202
|
+
return this._sourceActivity ? this._sourceActivity.exec() : Promise.resolve();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_emptyData: ReadonlyArray<object> = [];
|
|
206
|
+
inData(): ReadonlyArray<object> {
|
|
207
|
+
return this._sourceActivity ? this._sourceActivity.outData() || this._emptyData : this._emptyData;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
computeData(): ReadonlyArray<object> {
|
|
211
|
+
return this.inData();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private _prevDataHash: string = "";
|
|
215
|
+
private _prevInData: ReadonlyArray<object> = [];
|
|
216
|
+
private _prevData: ReadonlyArray<object> = [];
|
|
217
|
+
private cachedComputeData(inData: ReadonlyArray<object>): ReadonlyArray<object> {
|
|
218
|
+
const hash = this.hash();
|
|
219
|
+
if (this._prevDataHash !== hash || this._prevInData !== inData) {
|
|
220
|
+
this._prevDataHash = hash;
|
|
221
|
+
this._prevInData = inData;
|
|
222
|
+
this._prevData = update(this._prevData, this.computeData());
|
|
223
|
+
}
|
|
224
|
+
return this._prevData;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
outData(): ReadonlyArray<object> {
|
|
228
|
+
return this.cachedComputeData(this.inData());
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export class ActivityArray extends Activity {
|
|
233
|
+
private _activities: Activity[] = [];
|
|
234
|
+
|
|
235
|
+
activities(): Activity[];
|
|
236
|
+
activities(_: Activity[]): this;
|
|
237
|
+
activities(_?: Activity[]): Activity[] | this {
|
|
238
|
+
if (!arguments.length) return this._activities;
|
|
239
|
+
this._activities = _;
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
ActivityArray.prototype._class += " ActivityArray";
|
|
244
|
+
|
|
245
|
+
export class ActivityPipeline extends ActivityArray {
|
|
246
|
+
|
|
247
|
+
activities(): Activity[];
|
|
248
|
+
activities(_: Activity[]): this;
|
|
249
|
+
activities(_?: Activity[]): Activity[] | this {
|
|
250
|
+
if (!arguments.length) return super.activities();
|
|
251
|
+
super.activities(_);
|
|
252
|
+
let prevActivity: Activity;
|
|
253
|
+
for (const activity of _) {
|
|
254
|
+
if (prevActivity) {
|
|
255
|
+
activity.sourceActivity(prevActivity);
|
|
256
|
+
}
|
|
257
|
+
prevActivity = activity;
|
|
258
|
+
}
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
first(): Activity {
|
|
263
|
+
const retVal = this.activities();
|
|
264
|
+
return retVal[0];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
last(): Activity | null {
|
|
268
|
+
const retVal = this.activities();
|
|
269
|
+
return retVal[retVal.length - 1];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
protected calcUpdatedGraph(activity: Activity): Array<{ from: string, to: Activity }> {
|
|
273
|
+
return activity.updatedBy().map(source => {
|
|
274
|
+
return {
|
|
275
|
+
from: source,
|
|
276
|
+
to: activity
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
updatedByGraph(): Array<{ from: string, to: Activity }> {
|
|
282
|
+
let retVal: Array<{ from: string, to: Activity }> = [];
|
|
283
|
+
for (const activity of this.activities()) {
|
|
284
|
+
retVal = retVal.concat(this.calcUpdatedGraph(activity));
|
|
285
|
+
}
|
|
286
|
+
return retVal;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
fetch(from: number = 0, count: number = Number.MAX_VALUE): Promise<ReadonlyArray<object>> {
|
|
290
|
+
return this.exec().then(() => {
|
|
291
|
+
const data = this.outData();
|
|
292
|
+
if (from === 0 && data.length <= count) {
|
|
293
|
+
return data;
|
|
294
|
+
}
|
|
295
|
+
return data.slice(from, from + count);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Activity overrides ---
|
|
300
|
+
hash(more: { [key: string]: any } = {}): string {
|
|
301
|
+
return hashSum({
|
|
302
|
+
activities: [this.activities().map(activity => activity.hash())],
|
|
303
|
+
...more
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
refreshMeta(): Promise<void> {
|
|
308
|
+
return this.last().refreshMeta();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
updatedBy(): string[] {
|
|
312
|
+
let retVal: string[] = [];
|
|
313
|
+
for (const activity of this.activities()) {
|
|
314
|
+
retVal = retVal.concat(activity.updatedBy());
|
|
315
|
+
}
|
|
316
|
+
return retVal;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
inFields(): ReadonlyArray<DDL2.IField> {
|
|
320
|
+
return this.first().inFields();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
outFields(): ReadonlyArray<DDL2.IField> {
|
|
324
|
+
return this.last().outFields();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
localFields(): DDL2.IField[] {
|
|
328
|
+
return this.last().localFields();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
fieldOrigin(fieldID: string): Activity | null {
|
|
332
|
+
return this.last().fieldOrigin(fieldID);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
referencedFields(refs: ReferencedFields) {
|
|
336
|
+
this.last().referencedFields(refs);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
340
|
+
this.last().resolveInFields(refs, fieldIDs);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
344
|
+
this.last().resolveFields(refs, fieldIDs);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
exec(): Promise<void> {
|
|
348
|
+
return this.last().exec();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
outData(): ReadonlyArray<object> {
|
|
352
|
+
return this.last().outData();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
ActivityPipeline.prototype._class += " ActivitySequence";
|
|
356
|
+
|
|
357
|
+
export class ActivitySelection extends ActivityArray {
|
|
358
|
+
private _selection: Activity;
|
|
359
|
+
private _monitorHandle: IMonitorHandle;
|
|
360
|
+
|
|
361
|
+
selection(): Activity;
|
|
362
|
+
selection(_: Activity): this;
|
|
363
|
+
selection(_?: Activity): Activity | this {
|
|
364
|
+
if (_ === undefined) return this._selection;
|
|
365
|
+
if (this._monitorHandle) {
|
|
366
|
+
this._monitorHandle.remove();
|
|
367
|
+
}
|
|
368
|
+
this._selection = _;
|
|
369
|
+
this._monitorHandle = _.monitor((id, newVal, oldVal) => {
|
|
370
|
+
this.broadcast(id, newVal, oldVal, _);
|
|
371
|
+
});
|
|
372
|
+
return this;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Activity overrides ---
|
|
376
|
+
hash(more: { [key: string]: any } = {}): string {
|
|
377
|
+
return hashSum({
|
|
378
|
+
selection: this.selection().hash(),
|
|
379
|
+
...more
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
label(): string {
|
|
384
|
+
return this.selection().label();
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
refreshMeta(): Promise<void> {
|
|
388
|
+
return this.selection().refreshMeta();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
updatedBy(): string[] {
|
|
392
|
+
return this.selection().updatedBy();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
inFields(): ReadonlyArray<DDL2.IField> {
|
|
396
|
+
return this.selection().inFields();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
outFields(): ReadonlyArray<DDL2.IField> {
|
|
400
|
+
return this.selection().outFields();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
localFields(): DDL2.IField[] {
|
|
404
|
+
return this.selection().localFields();
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
fieldOrigin(fieldID: string): Activity | null {
|
|
408
|
+
return this.selection().fieldOrigin(fieldID);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
referencedFields(refs: ReferencedFields) {
|
|
412
|
+
this.selection().referencedFields(refs);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
resolveInFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
416
|
+
this.selection().resolveInFields(refs, fieldIDs);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
resolveFields(refs: ReferencedFields, fieldIDs: string[]) {
|
|
420
|
+
this.selection().resolveFields(refs, fieldIDs);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
exec(): Promise<void> {
|
|
424
|
+
return this.selection().exec();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
outData(): ReadonlyArray<object> {
|
|
428
|
+
return this.selection().outData();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
ActivitySelection.prototype._class += " ActivitySelection";
|