@mindline/sync 1.0.12 → 1.0.13
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/index.js +87 -2
- package/package.json +1 -1
- package/sync.d.ts +1 -0
- package/workspaces.json +3 -3
package/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export function helloNpm() {
|
|
|
8
8
|
return "hello NPM";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const FILTER_FIELD = "WorkspaceIDs";
|
|
12
|
+
|
|
11
13
|
export class User {
|
|
12
14
|
constructor(){
|
|
13
15
|
this.oid = "";
|
|
@@ -54,15 +56,96 @@ export class Workspace {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
export class PortalConfigInfo {
|
|
57
|
-
constructor(){
|
|
59
|
+
constructor() {
|
|
58
60
|
this.us = {};
|
|
59
61
|
this.ts = {};
|
|
60
62
|
this.cs = {};
|
|
61
63
|
this.ws = {};
|
|
62
64
|
}
|
|
65
|
+
tagWithWorkspaces() {
|
|
66
|
+
// for each Workspace tag associated User, Target, Config with Workspace.id
|
|
67
|
+
for (let workspace of this.ws) {
|
|
68
|
+
// find matching Users to tag with this workspace
|
|
69
|
+
for (let userID of workspace.associatedUsers) {
|
|
70
|
+
let user = this.us.find((currentUser) => currentUser.oid === userID);
|
|
71
|
+
if (user !== undefined) {
|
|
72
|
+
// we found the user
|
|
73
|
+
if (user[FILTER_FIELD] === undefined) {
|
|
74
|
+
// the user does not have the filter field yet
|
|
75
|
+
try {
|
|
76
|
+
user[FILTER_FIELD] = workspace.id;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
debugger;
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
// the user does have the filter field
|
|
83
|
+
user[FILTER_FIELD] += ", ";
|
|
84
|
+
user[FILTER_FIELD] += workspace.id;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
// we should not have PCI that does not have Workspace component objects
|
|
88
|
+
debugger;
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// find matching Targets to tag with this workspace
|
|
93
|
+
for (let targetID of workspace.associatedTargets) {
|
|
94
|
+
let target = this.ts.find(
|
|
95
|
+
(currentTarget) => currentTarget.tid === targetID
|
|
96
|
+
);
|
|
97
|
+
if (target !== undefined) {
|
|
98
|
+
// we found the target
|
|
99
|
+
if (target[FILTER_FIELD] === undefined) {
|
|
100
|
+
// the target does not have the filter field yet
|
|
101
|
+
try {
|
|
102
|
+
target[FILTER_FIELD] = workspace.id;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
debugger;
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
// the target does have the filter field
|
|
109
|
+
target[FILTER_FIELD] += ", ";
|
|
110
|
+
target[FILTER_FIELD] += workspace.id;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// we should not have PCI that does not have Workspace component objects
|
|
114
|
+
debugger;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// find matching Configs to tag with this workspace
|
|
119
|
+
for (let configID of workspace.associatedConfigs) {
|
|
120
|
+
let config = this.cs.find(
|
|
121
|
+
(currentConfig) => currentConfig.id === configID
|
|
122
|
+
);
|
|
123
|
+
if (config !== undefined) {
|
|
124
|
+
// we found the config
|
|
125
|
+
if (config[FILTER_FIELD] === undefined) {
|
|
126
|
+
// the config does not have the filter field yet
|
|
127
|
+
try {
|
|
128
|
+
config[FILTER_FIELD] = workspace.id;
|
|
129
|
+
} catch (e) {
|
|
130
|
+
debugger;
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
// the config does have the filter field
|
|
135
|
+
config[FILTER_FIELD] += ", ";
|
|
136
|
+
config[FILTER_FIELD] += workspace.id;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
// we should not have PCI that does not have Workspace component objects
|
|
140
|
+
debugger;
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
63
147
|
}
|
|
64
148
|
|
|
65
|
-
|
|
66
149
|
import { deserializeArray } from 'class-transformer';
|
|
67
150
|
import users from "./users.json";
|
|
68
151
|
import targets from "./targets.json";
|
|
@@ -83,6 +166,8 @@ export function InitPortal(user, portalConfigInfo)
|
|
|
83
166
|
portalConfigInfo.ts = deserializeArray(Target, targetsString);
|
|
84
167
|
portalConfigInfo.cs = deserializeArray(Config, configsString);
|
|
85
168
|
portalConfigInfo.ws = deserializeArray(Workspace, workspacesString);
|
|
169
|
+
portalConfigInfo.tagWithWorkspaces();
|
|
170
|
+
debugger;
|
|
86
171
|
} catch (e) {
|
|
87
172
|
debugger;
|
|
88
173
|
return false;
|
package/package.json
CHANGED
package/sync.d.ts
CHANGED
package/workspaces.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
{
|
|
3
3
|
"id": "1",
|
|
4
4
|
"name": "Default",
|
|
5
|
-
"associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b"],
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b" ],
|
|
6
|
+
"associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e" ],
|
|
7
|
+
"associatedConfigs": [ "1" ]
|
|
8
8
|
}
|
|
9
9
|
]
|