Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
89 lines (75 loc) · 2.31 KB

File metadata and controls

89 lines (75 loc) · 2.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import Connection from "../connection";
import {BeaconPath} from "../utils/beaconPath";
import {ReferencesPath} from "./path";
import {CommandBase} from "../validation/commandBase";
export default class ReferenceReplacer extends CommandBase {
private beaconPath: BeaconPath;
private className?: string;
private consistencyLevel?: string
private id?: string;
private references?: any[];
private referencesPath: ReferencesPath;
private refProp?: string;
constructor(client: Connection, referencesPath: ReferencesPath, beaconPath: BeaconPath) {
super(client)
this.beaconPath = beaconPath;
this.referencesPath = referencesPath;
}
withId = (id: string) => {
this.id = id;
return this;
};
withClassName(className: string) {
this.className = className;
return this;
}
withReferences = (refs: any) => {
this.references = refs;
return this;
};
withReferenceProperty = (refProp: string) => {
this.refProp = refProp;
return this;
};
withConsistencyLevel = (cl:string) => {
this.consistencyLevel = cl;
return this;
};
validateIsSet = (prop: string | undefined | null, name: string, setter: string) => {
if (prop == undefined || prop == null || prop.length == 0) {
this.addError(`${name} must be set - set with ${setter}`)
}
};
validate = () => {
this.validateIsSet(this.id, "id", ".withId(id)");
this.validateIsSet(
this.refProp,
"referenceProperty",
".withReferenceProperty(refProp)"
);
};
payload = () => this.references;
do = () => {
this.validate();
if (this.errors.length > 0) {
return Promise.reject(
new Error("invalid usage: " + this.errors.join(", "))
);
}
var payloadPromise = Array.isArray(this.references)
? Promise.all(this.references.map(ref => this.rebuildReferencePromise(ref)))
: Promise.resolve([]);
return Promise.all([
this.referencesPath.build(this.id!, this.className!, this.refProp!, this.consistencyLevel!),
payloadPromise
]).then(results => {
const path = results[0];
const payload = results[1];
return this.client.put(path, payload, false);
});
};
rebuildReferencePromise(reference: any) {
return this.beaconPath.rebuild(reference.beacon)
.then((beacon: any) => ({ beacon }));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.