@fraym/projections 0.8.0 → 0.8.2
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/cmd/projections.js +35 -11
- package/dist/delivery/filter.js +1 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/dist/cmd/projections.js
CHANGED
|
@@ -204,6 +204,30 @@ const getValueString = (v) => {
|
|
|
204
204
|
return `{${objectString}}`;
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
+
const addNestedTypesToSchema = (definitions, nestedTypeName, nestedTypes) => {
|
|
208
|
+
const nestedTypeDefinition = definitions[nestedTypeName];
|
|
209
|
+
if (nestedTypes.indexOf(nestedTypeName) !== -1 ||
|
|
210
|
+
(nestedTypeDefinition && nestedTypeDefinition.isProjection)) {
|
|
211
|
+
return {
|
|
212
|
+
schema: "",
|
|
213
|
+
nestedTypes: [],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
let newSchema = definitions[nestedTypeName].schema;
|
|
217
|
+
nestedTypes.push(nestedTypeName);
|
|
218
|
+
nestedTypeDefinition.nestedTypes.forEach(nestedNestedTypeName => {
|
|
219
|
+
const nestedSchemaData = addNestedTypesToSchema(definitions, nestedNestedTypeName, nestedTypes);
|
|
220
|
+
if (nestedSchemaData.schema === "") {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
newSchema += `\n${nestedSchemaData.schema}`;
|
|
224
|
+
nestedTypes.push(...nestedSchemaData.nestedTypes);
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
schema: newSchema,
|
|
228
|
+
nestedTypes: nestedTypes,
|
|
229
|
+
};
|
|
230
|
+
};
|
|
207
231
|
const migrateSchemas = async (definitions, serverAddress, namespace) => {
|
|
208
232
|
const managementClient = await (0, client_1.newManagementClient)({ serverAddress });
|
|
209
233
|
let existingProjections = (await managementClient.getAll()).filter(projectionName => !projectionName.startsWith("Crud") &&
|
|
@@ -224,12 +248,12 @@ const migrateSchemas = async (definitions, serverAddress, namespace) => {
|
|
|
224
248
|
projectionsToUpdate.push(projectionName);
|
|
225
249
|
updateSchema += `\n${definitions[projectionName].schema}`;
|
|
226
250
|
definitions[projectionName].nestedTypes.forEach(nestedTypeName => {
|
|
227
|
-
|
|
228
|
-
|
|
251
|
+
const nestedSchemaData = addNestedTypesToSchema(definitions, nestedTypeName, nestedTypesToUpdate);
|
|
252
|
+
if (nestedSchemaData.schema === "") {
|
|
229
253
|
return;
|
|
230
254
|
}
|
|
231
|
-
updateSchema += `\n${
|
|
232
|
-
nestedTypesToUpdate.push(
|
|
255
|
+
updateSchema += `\n${nestedSchemaData.schema}`;
|
|
256
|
+
nestedTypesToUpdate.push(...nestedSchemaData.nestedTypes);
|
|
233
257
|
});
|
|
234
258
|
}
|
|
235
259
|
});
|
|
@@ -240,27 +264,27 @@ const migrateSchemas = async (definitions, serverAddress, namespace) => {
|
|
|
240
264
|
projectionsToCreate.push(newName);
|
|
241
265
|
createSchema += `\n${definitions[newName].schema}`;
|
|
242
266
|
definitions[newName].nestedTypes.forEach(nestedTypeName => {
|
|
243
|
-
|
|
244
|
-
|
|
267
|
+
const nestedSchemaData = addNestedTypesToSchema(definitions, nestedTypeName, nestedTypesToCreate);
|
|
268
|
+
if (nestedSchemaData.schema === "") {
|
|
245
269
|
return;
|
|
246
270
|
}
|
|
247
|
-
createSchema += `\n${
|
|
248
|
-
nestedTypesToCreate.push(
|
|
271
|
+
createSchema += `\n${nestedSchemaData.schema}`;
|
|
272
|
+
nestedTypesToCreate.push(...nestedSchemaData.nestedTypes);
|
|
249
273
|
});
|
|
250
274
|
});
|
|
251
275
|
if (projectionsToCreate.length > 0) {
|
|
252
276
|
console.log(`Creating ${projectionsToCreate.length} projections: ${projectionsToCreate}...`);
|
|
253
|
-
await managementClient.
|
|
277
|
+
await managementClient.update(createSchema);
|
|
254
278
|
console.log(`Created ${projectionsToCreate.length} projections`);
|
|
255
279
|
}
|
|
256
280
|
if (projectionsToUpdate.length > 0) {
|
|
257
281
|
console.log(`Updating ${projectionsToUpdate.length} projections: ${projectionsToUpdate}...`);
|
|
258
|
-
await managementClient.update(updateSchema)
|
|
282
|
+
await managementClient.update(updateSchema);
|
|
259
283
|
console.log(`Updated ${projectionsToUpdate.length} projections`);
|
|
260
284
|
}
|
|
261
285
|
if (projectionsToRemove.length > 0) {
|
|
262
286
|
console.log(`Removing ${projectionsToRemove.length} projections: ${projectionsToRemove}...`);
|
|
263
|
-
await managementClient.remove(projectionsToRemove)
|
|
287
|
+
await managementClient.remove(projectionsToRemove);
|
|
264
288
|
console.log(`Removed ${projectionsToRemove.length} projections`);
|
|
265
289
|
}
|
|
266
290
|
};
|
package/dist/delivery/filter.js
CHANGED
|
@@ -5,17 +5,10 @@ const getProtobufDataFilter = (filter) => {
|
|
|
5
5
|
const fields = {};
|
|
6
6
|
for (const fieldName in filter.fields) {
|
|
7
7
|
const field = filter.fields[fieldName];
|
|
8
|
-
let value = "";
|
|
9
|
-
if (field.type === "String" && typeof field.value == "string") {
|
|
10
|
-
value = field.value;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
value = JSON.stringify(field.value);
|
|
14
|
-
}
|
|
15
8
|
fields[fieldName] = {
|
|
16
9
|
operation: field.operation,
|
|
17
10
|
type: field.type,
|
|
18
|
-
value,
|
|
11
|
+
value: JSON.stringify(field.value),
|
|
19
12
|
};
|
|
20
13
|
}
|
|
21
14
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export * from "./management/client";
|
|
|
2
2
|
export * from "./delivery/client";
|
|
3
3
|
export { Filter, FieldFilter } from "./delivery/filter";
|
|
4
4
|
export { Order } from "./delivery/order";
|
|
5
|
-
export { ClientConfig } from "./config/config";
|
|
5
|
+
export { ClientConfig, getEnvConfig } from "./config/config";
|
package/dist/index.js
CHANGED
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getEnvConfig = void 0;
|
|
17
18
|
__exportStar(require("./management/client"), exports);
|
|
18
19
|
__exportStar(require("./delivery/client"), exports);
|
|
20
|
+
var config_1 = require("./config/config");
|
|
21
|
+
Object.defineProperty(exports, "getEnvConfig", { enumerable: true, get: function () { return config_1.getEnvConfig; } });
|