@golemio/playgrounds 1.0.3-dev.486221468 → 1.0.3-dev.488256458
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/db/example/.config.json +3 -0
- package/db/example/00_truncate_tables.sql +6 -0
- package/db/example/01_playgrounds.sql +30 -0
- package/db/migrations/postgresql/.config.json +3 -0
- package/db/migrations/postgresql/20220223135414-playgrounds-to-postgres.js +53 -0
- package/db/migrations/postgresql/package.json +3 -0
- package/db/migrations/postgresql/sqls/20220223135414-playgrounds-to-postgres-down.sql +3 -0
- package/db/migrations/postgresql/sqls/20220223135414-playgrounds-to-postgres-up.sql +52 -0
- package/db/migrations/postgresql/sqls/package.json +3 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/integration-engine/PlaygroundsDataSource.d.ts +5 -0
- package/dist/integration-engine/PlaygroundsDataSource.js +21 -0
- package/dist/integration-engine/PlaygroundsDataSource.js.map +1 -0
- package/dist/integration-engine/PlaygroundsTransformation.d.ts +6 -1
- package/dist/integration-engine/PlaygroundsTransformation.js +35 -27
- package/dist/integration-engine/PlaygroundsTransformation.js.map +1 -1
- package/dist/integration-engine/PlaygroundsWorker.d.ts +7 -1
- package/dist/integration-engine/PlaygroundsWorker.js +114 -81
- package/dist/integration-engine/PlaygroundsWorker.js.map +1 -1
- package/dist/integration-engine/helpers/AddressHelper.d.ts +11 -0
- package/dist/integration-engine/helpers/AddressHelper.js +68 -0
- package/dist/integration-engine/helpers/AddressHelper.js.map +1 -0
- package/dist/integration-engine/models/CityDistrictsModel.d.ts +4 -0
- package/dist/integration-engine/models/CityDistrictsModel.js +22 -0
- package/dist/integration-engine/models/CityDistrictsModel.js.map +1 -0
- package/dist/integration-engine/models/PlaygroundPropertyModel.d.ts +4 -0
- package/dist/integration-engine/models/PlaygroundPropertyModel.js +21 -0
- package/dist/integration-engine/models/PlaygroundPropertyModel.js.map +1 -0
- package/dist/integration-engine/models/PlaygroundsModel.d.ts +12 -0
- package/dist/integration-engine/models/PlaygroundsModel.js +47 -0
- package/dist/integration-engine/models/PlaygroundsModel.js.map +1 -0
- package/dist/integration-engine/models/PropertyModel.d.ts +4 -0
- package/dist/integration-engine/models/PropertyModel.js +21 -0
- package/dist/integration-engine/models/PropertyModel.js.map +1 -0
- package/dist/integration-engine/queueDefinitions.js +3 -3
- package/dist/integration-engine/queueDefinitions.js.map +1 -1
- package/dist/output-gateway/PlaygroundsRouter.d.ts +2 -1
- package/dist/output-gateway/PlaygroundsRouter.js +6 -4
- package/dist/output-gateway/PlaygroundsRouter.js.map +1 -1
- package/dist/output-gateway/index.d.ts +1 -1
- package/dist/output-gateway/index.js +1 -1
- package/dist/output-gateway/index.js.map +1 -1
- package/dist/output-gateway/models/FilterHelper.d.ts +8 -0
- package/dist/output-gateway/models/FilterHelper.js +49 -0
- package/dist/output-gateway/models/FilterHelper.js.map +1 -0
- package/dist/output-gateway/models/PlaygroundPropertyModel.d.ts +6 -0
- package/dist/output-gateway/models/PlaygroundPropertyModel.js +22 -0
- package/dist/output-gateway/models/PlaygroundPropertyModel.js.map +1 -0
- package/dist/output-gateway/models/PlaygroundsModel.d.ts +15 -0
- package/dist/output-gateway/models/PlaygroundsModel.js +87 -0
- package/dist/output-gateway/models/PlaygroundsModel.js.map +1 -0
- package/dist/output-gateway/models/PropertyModel.d.ts +6 -0
- package/dist/output-gateway/models/PropertyModel.js +22 -0
- package/dist/output-gateway/models/PropertyModel.js.map +1 -0
- package/dist/schema-definitions/PlaygroundSchemaTables.d.ts +5 -0
- package/dist/schema-definitions/PlaygroundSchemaTables.js +10 -0
- package/dist/schema-definitions/PlaygroundSchemaTables.js.map +1 -0
- package/dist/schema-definitions/PlaygroundsInfo.d.ts +12 -0
- package/dist/schema-definitions/PlaygroundsInfo.js +41 -0
- package/dist/schema-definitions/PlaygroundsInfo.js.map +1 -0
- package/dist/schema-definitions/json-schema/OutputSchemaProvider.d.ts +9 -0
- package/dist/schema-definitions/json-schema/OutputSchemaProvider.js +58 -0
- package/dist/schema-definitions/json-schema/OutputSchemaProvider.js.map +1 -0
- package/dist/schema-definitions/json-schema/SourceSchemaProvider.d.ts +5 -0
- package/dist/schema-definitions/json-schema/SourceSchemaProvider.js +48 -0
- package/dist/schema-definitions/json-schema/SourceSchemaProvider.js.map +1 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlayground.d.ts +14 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlayground.js +3 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlayground.js.map +1 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlaygroundCategory.d.ts +4 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlaygroundCategory.js +3 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourcePlaygroundCategory.js.map +1 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourceResponse.d.ts +8 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourceResponse.js +3 -0
- package/dist/schema-definitions/json-schema/interfaces/ISourceResponse.js.map +1 -0
- package/dist/schema-definitions/output/IOutputPlaygroundProperties.d.ts +24 -0
- package/dist/schema-definitions/output/IOutputPlaygroundProperties.js +3 -0
- package/dist/schema-definitions/output/IOutputPlaygroundProperties.js.map +1 -0
- package/dist/schema-definitions/output/OutputPlayground.d.ts +9 -0
- package/dist/schema-definitions/output/OutputPlayground.js +38 -0
- package/dist/schema-definitions/output/OutputPlayground.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/Playground.d.ts +24 -0
- package/dist/schema-definitions/sequelize-models/Playground.js +30 -0
- package/dist/schema-definitions/sequelize-models/Playground.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/PlaygroundProperty.d.ts +7 -0
- package/dist/schema-definitions/sequelize-models/PlaygroundProperty.js +27 -0
- package/dist/schema-definitions/sequelize-models/PlaygroundProperty.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/Property.d.ts +7 -0
- package/dist/schema-definitions/sequelize-models/Property.js +12 -0
- package/dist/schema-definitions/sequelize-models/Property.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlayground.d.ts +20 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlayground.js +3 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlayground.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlaygroundProperty.d.ts +4 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlaygroundProperty.js +3 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IPlaygroundProperty.js.map +1 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IProperty.d.ts +4 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IProperty.js +3 -0
- package/dist/schema-definitions/sequelize-models/interfaces/IProperty.js.map +1 -0
- package/package.json +6 -4
- package/db/example/mongo_data/dataplatform/playgrounds.bson +0 -0
- package/db/example/mongo_data/dataplatform/playgrounds.metadata.json +0 -1
- package/dist/output-gateway/PlaygroundsModel.d.ts +0 -7
- package/dist/output-gateway/PlaygroundsModel.js +0 -17
- package/dist/output-gateway/PlaygroundsModel.js.map +0 -1
- package/dist/schema-definitions/index.d.ts +0 -12
- package/dist/schema-definitions/index.js +0 -66
- package/dist/schema-definitions/index.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CityDistrictsModel } from "../models/CityDistrictsModel";
|
|
2
|
+
import { IPlayground } from "../../schema-definitions/sequelize-models/interfaces/IPlayground";
|
|
3
|
+
import { Playground } from "../../schema-definitions/sequelize-models/Playground";
|
|
4
|
+
import { Point } from "geojson";
|
|
5
|
+
export declare class AddressHelper {
|
|
6
|
+
static isLocationChanged: (point1: Point, point2: Point) => boolean;
|
|
7
|
+
static isMissing: (playground: Playground) => boolean;
|
|
8
|
+
static needsUpdate: (newPlayground: IPlayground, currentDbPlayground: Playground) => boolean;
|
|
9
|
+
static updateAddress(dbData: Playground): Promise<void>;
|
|
10
|
+
static updateDistrict(dbData: Playground, cityDistrictsModel: CityDistrictsModel): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AddressHelper = void 0;
|
|
16
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
17
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
18
|
+
const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
|
|
19
|
+
class AddressHelper {
|
|
20
|
+
static updateAddress(dbData) {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
const address = yield integration_engine_1.GeocodeApi.getAddressByLatLng(dbData.location.coordinates[1], dbData.location.coordinates[0]);
|
|
25
|
+
if (address) {
|
|
26
|
+
dbData.address_country = (_a = address.address_country) !== null && _a !== void 0 ? _a : "";
|
|
27
|
+
dbData.address_formatted = (_b = address.address_formatted) !== null && _b !== void 0 ? _b : "";
|
|
28
|
+
dbData.address_locality = (_c = address.address_locality) !== null && _c !== void 0 ? _c : "";
|
|
29
|
+
dbData.address_region = (_d = address.address_region) !== null && _d !== void 0 ? _d : "";
|
|
30
|
+
dbData.street_address = (_e = address.street_address) !== null && _e !== void 0 ? _e : "";
|
|
31
|
+
dbData.postal_code = (_f = address.postal_code) !== null && _f !== void 0 ? _f : "";
|
|
32
|
+
}
|
|
33
|
+
yield dbData.save();
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new golemio_errors_1.CustomError("Error while updating address.", true, this.constructor.name, 5001, err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
static updateDistrict(dbData, cityDistrictsModel) {
|
|
41
|
+
var _a;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const result = yield cityDistrictsModel.findOne({
|
|
45
|
+
// find district by coordinates
|
|
46
|
+
where: sequelize_1.default.fn("ST_Intersects", sequelize_1.default.col("geom"), sequelize_1.default.fn("ST_SetSRID", sequelize_1.default.fn("ST_MakePoint", dbData.location.coordinates[0], dbData.location.coordinates[1]), 4326)),
|
|
47
|
+
});
|
|
48
|
+
dbData.district = result ? (_a = result.dataValues.slug) !== null && _a !== void 0 ? _a : result.dataValues.district_name : null;
|
|
49
|
+
yield dbData.save();
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
throw new golemio_errors_1.CustomError("Error while updating district.", true, this.constructor.name, 5001, err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.AddressHelper = AddressHelper;
|
|
58
|
+
AddressHelper.isLocationChanged = (point1, point2) => {
|
|
59
|
+
return point1.coordinates[0] !== point2.coordinates[0] || point1.coordinates[1] !== point2.coordinates[1];
|
|
60
|
+
};
|
|
61
|
+
AddressHelper.isMissing = (playground) => {
|
|
62
|
+
return !playground.address_formatted || !playground.address_country || !playground.district;
|
|
63
|
+
};
|
|
64
|
+
AddressHelper.needsUpdate = (newPlayground, currentDbPlayground) => {
|
|
65
|
+
return (AddressHelper.isLocationChanged(newPlayground.location, currentDbPlayground.location) ||
|
|
66
|
+
AddressHelper.isMissing(currentDbPlayground));
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=AddressHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressHelper.js","sourceRoot":"","sources":["../../../src/integration-engine/helpers/AddressHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,8EAAmE;AACnE,6EAAuE;AACvE,oFAA4D;AAG5D,MAAa,aAAa;IAgBf,MAAM,CAAO,aAAa,CAAC,MAAkB;;;YAChD,IAAI;gBACA,MAAM,OAAO,GAAG,MAAM,+BAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpH,IAAI,OAAO,EAAE;oBACT,MAAM,CAAC,eAAe,GAAG,MAAA,OAAO,CAAC,eAAe,mCAAI,EAAE,CAAC;oBACvD,MAAM,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,EAAE,CAAC;oBAC3D,MAAM,CAAC,gBAAgB,GAAG,MAAA,OAAO,CAAC,gBAAgB,mCAAI,EAAE,CAAC;oBACzD,MAAM,CAAC,cAAc,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,EAAE,CAAC;oBACrD,MAAM,CAAC,cAAc,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,EAAE,CAAC;oBACrD,MAAM,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,EAAE,CAAC;iBAClD;gBAED,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;aACvB;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,4BAAW,CAAC,+BAA+B,EAAE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AAsB,EAAW,EAAE;IAC1D,OAAO,CAAC,UAAU,CAAC,iBAAiB,IAAI,CAAC,UAAU,CAAC,eAAe,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;AAChG,CAAC,CAAC;AAEY,yBAAW,GAAG,CAAC,aAA0B,EAAE,mBAA+B,EAAW,EAAE;IACjG,OAAO,CACH,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,CAAC;QACrF,aAAa,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAC/C,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CityDistrictsModel = void 0;
|
|
4
|
+
const schema_definitions_1 = require("@golemio/city-districts/dist/schema-definitions");
|
|
5
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
6
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
7
|
+
class CityDistrictsModel extends integration_engine_1.PostgresModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(schema_definitions_1.CityDistricts.name + "PGModel", {
|
|
10
|
+
outputSequelizeAttributes: schema_definitions_1.CityDistricts.postgres.outputSequelizeAttributes,
|
|
11
|
+
pgTableName: schema_definitions_1.CityDistricts.postgres.pgTableName,
|
|
12
|
+
savingType: "insertOnly",
|
|
13
|
+
pgSchema: "common",
|
|
14
|
+
sequelizeAdditionalSettings: {
|
|
15
|
+
schema: "common",
|
|
16
|
+
timestamps: false,
|
|
17
|
+
},
|
|
18
|
+
}, new golemio_validator_1.Validator(schema_definitions_1.CityDistricts.name + "ModelPGValidator", schema_definitions_1.CityDistricts.postgres.outputMongooseSchemaObject));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CityDistrictsModel = CityDistrictsModel;
|
|
22
|
+
//# sourceMappingURL=CityDistrictsModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CityDistrictsModel.js","sourceRoot":"","sources":["../../../src/integration-engine/models/CityDistrictsModel.ts"],"names":[],"mappings":";;;AAAA,wFAAgF;AAChF,8EAA8E;AAC9E,mFAAwE;AAExE,MAAa,kBAAmB,SAAQ,kCAAa;IACjD;QACI,KAAK,CACD,kCAAa,CAAC,IAAI,GAAG,SAAS,EAC9B;YACI,yBAAyB,EAAE,kCAAa,CAAC,QAAQ,CAAC,yBAAyB;YAC3E,WAAW,EAAE,kCAAa,CAAC,QAAQ,CAAC,WAAW;YAC/C,UAAU,EAAE,YAAY;YACxB,QAAQ,EAAE,QAAQ;YAClB,2BAA2B,EAAE;gBACzB,MAAM,EAAE,QAAQ;gBAChB,UAAU,EAAE,KAAK;aACpB;SACJ,EACD,IAAI,6BAAS,CAAC,kCAAa,CAAC,IAAI,GAAG,kBAAkB,EAAE,kCAAa,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAC5G,CAAC;IACN,CAAC;CACJ;AAjBD,gDAiBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaygroundPropertyModel = void 0;
|
|
4
|
+
const OutputSchemaProvider_1 = require("../../schema-definitions/json-schema/OutputSchemaProvider");
|
|
5
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
6
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
7
|
+
const PlaygroundProperty_1 = require("../../schema-definitions/sequelize-models/PlaygroundProperty");
|
|
8
|
+
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
9
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
10
|
+
class PlaygroundPropertyModel extends models_1.PostgresModel {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.playgroundPropertiesModelName, {
|
|
13
|
+
outputSequelizeAttributes: PlaygroundProperty_1.PlaygroundProperty.attributeModel,
|
|
14
|
+
pgTableName: PlaygroundSchemaTables_1.PlaygroundSchemaTables.PlaygroundProperties,
|
|
15
|
+
pgSchema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
16
|
+
savingType: "insertOrUpdate",
|
|
17
|
+
}, new golemio_validator_1.JSONSchemaValidator("PlaygroundsPropertyModelValidator", OutputSchemaProvider_1.OutputSchemaProvider.playgroundProperty, true));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.PlaygroundPropertyModel = PlaygroundPropertyModel;
|
|
21
|
+
//# sourceMappingURL=PlaygroundPropertyModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundPropertyModel.js","sourceRoot":"","sources":["../../../src/integration-engine/models/PlaygroundPropertyModel.ts"],"names":[],"mappings":";;;AAAA,oGAA6E;AAC7E,4FAAqE;AACrE,8EAAuD;AACvD,qGAA8E;AAC9E,yEAAqF;AACrF,mFAAkF;AAElF,MAAa,uBAAwB,SAAQ,sBAAa;IACtD;QACI,KAAK,CACD,iCAAe,CAAC,6BAA6B,EAC7C;YACI,yBAAyB,EAAE,uCAAkB,CAAC,cAAc;YAC5D,WAAW,EAAE,+CAAsB,CAAC,oBAAoB;YACxD,QAAQ,EAAE,iCAAe,CAAC,UAAU;YACpC,UAAU,EAAE,gBAAgB;SAC/B,EACD,IAAI,uCAAmB,CAAC,mCAAmC,EAAE,2CAAoB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAC9G,CAAC;IACN,CAAC;CACJ;AAbD,0DAaC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Playground } from "../../schema-definitions/sequelize-models/Playground";
|
|
2
|
+
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
3
|
+
import sequelize from "@golemio/core/dist/shared/sequelize";
|
|
4
|
+
import { PlaygroundPropertyModel } from "./PlaygroundPropertyModel";
|
|
5
|
+
import { PropertyModel } from "./PropertyModel";
|
|
6
|
+
export declare class PlaygroundsModel extends PostgresModel implements IModel {
|
|
7
|
+
propertiesModel: PropertyModel;
|
|
8
|
+
playgroundPropertyModel: PlaygroundPropertyModel;
|
|
9
|
+
constructor();
|
|
10
|
+
getPlaygroundId: (external_id: number, t?: sequelize.Transaction | undefined) => Promise<number | undefined>;
|
|
11
|
+
getPlayground(external_id: number, t?: sequelize.Transaction | undefined): Promise<Playground | null>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PlaygroundsModel = void 0;
|
|
13
|
+
const OutputSchemaProvider_1 = require("../../schema-definitions/json-schema/OutputSchemaProvider");
|
|
14
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
15
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
16
|
+
const Playground_1 = require("../../schema-definitions/sequelize-models/Playground");
|
|
17
|
+
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
18
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
19
|
+
const PlaygroundPropertyModel_1 = require("./PlaygroundPropertyModel");
|
|
20
|
+
const PropertyModel_1 = require("./PropertyModel");
|
|
21
|
+
class PlaygroundsModel extends models_1.PostgresModel {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.playgroundsModelName, {
|
|
24
|
+
outputSequelizeAttributes: Playground_1.Playground.attributesModel,
|
|
25
|
+
pgTableName: PlaygroundSchemaTables_1.PlaygroundSchemaTables.Playground,
|
|
26
|
+
pgSchema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
27
|
+
savingType: "insertOrUpdate",
|
|
28
|
+
}, new golemio_validator_1.JSONSchemaValidator("PlaygroundsModelValidator", OutputSchemaProvider_1.OutputSchemaProvider.playgroundOutput, true));
|
|
29
|
+
this.getPlaygroundId = (external_id, t) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const playground = yield this.getPlayground(external_id, t);
|
|
31
|
+
return playground ? playground.internal_id : undefined;
|
|
32
|
+
});
|
|
33
|
+
this.propertiesModel = new PropertyModel_1.PropertyModel();
|
|
34
|
+
this.playgroundPropertyModel = new PlaygroundPropertyModel_1.PlaygroundPropertyModel();
|
|
35
|
+
PlaygroundsInfo_1.PlaygroundsInfo.associateTables(this.sequelizeModel, this.propertiesModel["sequelizeModel"], this.playgroundPropertyModel["sequelizeModel"]);
|
|
36
|
+
}
|
|
37
|
+
getPlayground(external_id, t) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return yield this.sequelizeModel.findOne({
|
|
40
|
+
where: { external_id: external_id },
|
|
41
|
+
transaction: t,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.PlaygroundsModel = PlaygroundsModel;
|
|
47
|
+
//# sourceMappingURL=PlaygroundsModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundsModel.js","sourceRoot":"","sources":["../../../src/integration-eng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AA;CACJ;AArCD,4CAqCC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyModel = void 0;
|
|
4
|
+
const OutputSchemaProvider_1 = require("../../schema-definitions/json-schema/OutputSchemaProvider");
|
|
5
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
6
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
7
|
+
const Property_1 = require("../../schema-definitions/sequelize-models/Property");
|
|
8
|
+
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
9
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
10
|
+
class PropertyModel extends integration_engine_1.PostgresModel {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.propertiesModelName, {
|
|
13
|
+
outputSequelizeAttributes: Property_1.Property.attributeModel,
|
|
14
|
+
pgTableName: PlaygroundSchemaTables_1.PlaygroundSchemaTables.Properties,
|
|
15
|
+
pgSchema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
16
|
+
savingType: "insertOrUpdate",
|
|
17
|
+
}, new golemio_validator_1.JSONSchemaValidator("PropertyModelValidator", OutputSchemaProvider_1.OutputSchemaProvider.property, true));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.PropertyModel = PropertyModel;
|
|
21
|
+
//# sourceMappingURL=PropertyModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyModel.js","sourceRoot":"","sources":["../../../src/integration-engine/models/PropertyModel.ts"],"names":[],"mappings":";;;AAAA,oGAA6E;AAC7E,4FAAqE;AACrE,8EAAuD;AACvD,iFAA0D;AAC1D,8EAA8E;AAC9E,mFAAkF;AAElF,MAAa,aAAc,SAAQ,kCAAa;IAC5C;QACI,KAAK,CACD,iCAAe,CAAC,mBAAmB,EACnC;YACI,yBAAyB,EAAE,mBAAQ,CAAC,cAAc;YAClD,WAAW,EAAE,+CAAsB,CAAC,UAAU;YAC9C,QAAQ,EAAE,iCAAe,CAAC,UAAU;YACpC,UAAU,EAAE,gBAAgB;SAC/B,EACD,IAAI,uCAAmB,CAAC,wBAAwB,EAAE,2CAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CACzF,CAAC;IACN,CAAC;CACJ;AAbD,sCAaC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.queueDefinitions = void 0;
|
|
4
4
|
const config_1 = require("@golemio/core/dist/integration-engine/config");
|
|
5
|
-
const index_1 = require("../schema-definitions/index");
|
|
6
5
|
const PlaygroundsWorker_1 = require("./PlaygroundsWorker");
|
|
6
|
+
const PlaygroundsInfo_1 = require("../schema-definitions/PlaygroundsInfo");
|
|
7
7
|
const queueDefinitions = [
|
|
8
8
|
{
|
|
9
|
-
name:
|
|
10
|
-
queuePrefix: config_1.config.RABBIT_EXCHANGE_NAME + "." +
|
|
9
|
+
name: PlaygroundsInfo_1.PlaygroundsInfo.moduleName,
|
|
10
|
+
queuePrefix: config_1.config.RABBIT_EXCHANGE_NAME + "." + PlaygroundsInfo_1.PlaygroundsInfo.moduleName.toLowerCase(),
|
|
11
11
|
queues: [
|
|
12
12
|
{
|
|
13
13
|
name: "refreshDataInDB",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueDefinitions.js","sourceRoot":"","sources":["../../src/integration-engine/queueDefinitions.ts"],"names":[],"mappings":";;;AAAA,yEAAsE;AAEtE,
|
|
1
|
+
{"version":3,"file":"queueDefinitions.js","sourceRoot":"","sources":["../../src/integration-engine/queueDefinitions.ts"],"names":[],"mappings":";;;AAAA,yEAAsE;AAEtE,2DAA0D;AAC1D,2EAAuD;AAEvD,MAAM,gBAAgB,GAAuB;IACzC;QACI,IAAI,EAAE,iCAAe,CAAC,UAAU;QAChC,WAAW,EAAE,eAAM,CAAC,oBAAoB,GAAG,GAAG,GAAG,iCAAe,CAAC,UAAU,CAAC,WAAW,EAAE;QACzF,MAAM,EAAE;YACJ;gBACI,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE;oBACL,kBAAkB,EAAE,eAAM,CAAC,oBAAoB;oBAC/C,oBAAoB,EAAE,MAAM;oBAC5B,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,WAAW;iBAC/C;gBACD,MAAM,EAAE,qCAAiB;gBACzB,YAAY,EAAE,iBAAiB;aAClC;YACD;gBACI,IAAI,EAAE,0BAA0B;gBAChC,OAAO,EAAE;oBACL,kBAAkB,EAAE,eAAM,CAAC,oBAAoB;oBAC/C,oBAAoB,EAAE,MAAM;oBAC5B,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,WAAW;iBAC/C;gBACD,MAAM,EAAE,qCAAiB;gBACzB,YAAY,EAAE,0BAA0B;aAC3C;SACJ;KACJ;CACJ,CAAC;AAEO,4CAAgB"}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* Handles web logic (http request, response). Sets response headers, handles error responses.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="express" />
|
|
8
|
+
import { GeoJsonRouter } from "@golemio/core/dist/output-gateway";
|
|
8
9
|
import { NextFunction, Request, Response, Router } from "@golemio/core/dist/shared/express";
|
|
9
|
-
import { GeoJsonRouter } from "@golemio/core/dist/output-gateway/routes";
|
|
10
10
|
export declare class PlaygroundsRouter extends GeoJsonRouter {
|
|
11
|
+
router: Router;
|
|
11
12
|
constructor();
|
|
12
13
|
GetProperties: (req: Request, res: Response, next: NextFunction) => void;
|
|
13
14
|
}
|
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.playgroundsRouter = exports.PlaygroundsRouter = void 0;
|
|
10
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
10
11
|
const redis_1 = require("@golemio/core/dist/output-gateway/redis");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
class PlaygroundsRouter extends
|
|
12
|
+
const express_1 = require("@golemio/core/dist/shared/express");
|
|
13
|
+
const PlaygroundsModel_1 = require("./models/PlaygroundsModel");
|
|
14
|
+
class PlaygroundsRouter extends output_gateway_1.GeoJsonRouter {
|
|
14
15
|
constructor() {
|
|
15
|
-
super(new
|
|
16
|
+
super(new PlaygroundsModel_1.PlaygroundsModel());
|
|
17
|
+
this.router = (0, express_1.Router)();
|
|
16
18
|
this.GetProperties = (req, res, next) => {
|
|
17
19
|
this.model
|
|
18
20
|
.GetProperties()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaygroundsRouter.js","sourceRoot":"","sources":["../../src/output-gateway/PlaygroundsRouter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"PlaygroundsRouter.js","sourceRoot":"","sources":["../../src/output-gateway/PlaygroundsRouter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sEAAkE;AAClE,mEAA6E;AAC7E,+DAA4F;AAC5F,gEAA6D;AAE7D,MAAa,iBAAkB,SAAQ,8BAAa;IAGhD;QACI,KAAK,CAAC,IAAI,mCAAgB,EAAE,CAAC,CAAC;QAH3B,WAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;QAQ1B,kBAAa,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI,CAAC,KAA0B;iBAC3B,aAAa,EAAE;iBACf,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACX,IAAI,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;QACX,CAAC,CAAC;QAbE,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,IAAA,0BAAkB,GAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7E,CAAC;CAYJ;AAnBD,8CAmBC;AAED,MAAM,iBAAiB,GAAW,IAAI,iBAAiB,EAAE,CAAC,MAAM,CAAC;AAExD,8CAAiB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./PlaygroundsModel";
|
|
1
|
+
export * from "./models/PlaygroundsModel";
|
|
2
2
|
export * from "./PlaygroundsRouter";
|
|
@@ -10,6 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./PlaygroundsModel"), exports);
|
|
13
|
+
__exportStar(require("./models/PlaygroundsModel"), exports);
|
|
14
14
|
__exportStar(require("./PlaygroundsRouter"), exports);
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAA0C;AAC1C,sDAAoC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IGeoJsonAllFilterParameters } from "@golemio/core/dist/output-gateway";
|
|
2
|
+
import { WhereOptions } from "@golemio/core/dist/shared/sequelize";
|
|
3
|
+
export declare class FilterHelper {
|
|
4
|
+
static prepareFilterForIds(options: IGeoJsonAllFilterParameters): WhereOptions[];
|
|
5
|
+
static prepareFilterForDistricts(options: IGeoJsonAllFilterParameters): WhereOptions[];
|
|
6
|
+
static prepareFilterForUpdateSince(options: IGeoJsonAllFilterParameters): WhereOptions[];
|
|
7
|
+
static prepareFilterForLocation(options: IGeoJsonAllFilterParameters): WhereOptions[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FilterHelper = void 0;
|
|
7
|
+
const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
|
|
8
|
+
class FilterHelper {
|
|
9
|
+
static prepareFilterForIds(options) {
|
|
10
|
+
return options.ids && options.ids.length > 0
|
|
11
|
+
? [
|
|
12
|
+
{
|
|
13
|
+
external_id: { [sequelize_1.default.Op.in]: options.ids },
|
|
14
|
+
},
|
|
15
|
+
]
|
|
16
|
+
: [];
|
|
17
|
+
}
|
|
18
|
+
static prepareFilterForDistricts(options) {
|
|
19
|
+
return options.districts && options.districts.length > 0
|
|
20
|
+
? [
|
|
21
|
+
{
|
|
22
|
+
district: {
|
|
23
|
+
[sequelize_1.default.Op.in]: options.districts,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
: [];
|
|
28
|
+
}
|
|
29
|
+
static prepareFilterForUpdateSince(options) {
|
|
30
|
+
return options.updatedSince
|
|
31
|
+
? [
|
|
32
|
+
{
|
|
33
|
+
updated_at: {
|
|
34
|
+
[sequelize_1.default.Op.gt]: options === null || options === void 0 ? void 0 : options.updatedSince,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
: [];
|
|
39
|
+
}
|
|
40
|
+
static prepareFilterForLocation(options) {
|
|
41
|
+
return options.lat && options.lng && options.range
|
|
42
|
+
? [
|
|
43
|
+
sequelize_1.default.fn("ST_DWithin", sequelize_1.default.col("location"), sequelize_1.default.cast(sequelize_1.default.fn("ST_SetSRID", sequelize_1.default.fn("ST_MakePoint", options.lat, options.lng), 4326), "geography"), options.range),
|
|
44
|
+
]
|
|
45
|
+
: [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.FilterHelper = FilterHelper;
|
|
49
|
+
//# sourceMappingURL=FilterHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterHelper.js","sourceRoot":"","sources":["../../../src/output-gateway/models/FilterHelper.ts"],"names":[],"mappings":";;;;;;AACA,oFAA8E;AAE9E,MAAa,YAAY;IACd,MAAM,CAAC,mBAAmB,CAAC,OAAoC;QAClE,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;YACxC,CAAC,CAAC;gBACI;oBACI,WAAW,EAAE,EAAE,CAAC,mBAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE;iBAClD;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,yBAAyB,CAAC,OAAoC;QACxE,OAAO,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;YACpD,CAAC,CAAC;gBACI;oBACI,QAAQ,EAAE;wBACN,CAAC,mBAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,SAAS;qBACvC;iBACJ;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,2BAA2B,CAAC,OAAoC;QAC1E,OAAO,OAAO,CAAC,YAAY;YACvB,CAAC,CAAC;gBACI;oBACI,UAAU,EAAE;wBACR,CAAC,mBAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY;qBAC3C;iBACJ;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,wBAAwB,CAAC,OAAoC;QACvE,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,KAAK;YAC9C,CAAC,CAAC;gBACI,mBAAS,CAAC,EAAE,CACR,YAAY,EACZ,mBAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EACzB,mBAAS,CAAC,IAAI,CACV,mBAAS,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAS,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EACxF,WAAW,CACd,EACD,OAAO,CAAC,KAAK,CAChB;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;CACJ;AAlDD,oCAkDC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaygroundPropertyModel = void 0;
|
|
4
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
5
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
6
|
+
const PlaygroundProperty_1 = require("../../schema-definitions/sequelize-models/PlaygroundProperty");
|
|
7
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
8
|
+
class PlaygroundPropertyModel extends output_gateway_1.SequelizeModel {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.playgroundPropertiesModelName, PlaygroundSchemaTables_1.PlaygroundSchemaTables.PlaygroundProperties, PlaygroundProperty_1.PlaygroundProperty.attributeModel, {
|
|
11
|
+
schema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
GetAll(options) {
|
|
15
|
+
throw new Error("Method not implemented.");
|
|
16
|
+
}
|
|
17
|
+
GetOne(id) {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PlaygroundPropertyModel = PlaygroundPropertyModel;
|
|
22
|
+
//# sourceMappingURL=PlaygroundPropertyModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundPropertyModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/PlaygroundPropertyModel.ts"],"names":[],"mappings":";;;AAAA,4FAAqE;AACrE,8EAAuD;AACvD,qGAA8E;AAC9E,sEAAmE;AAEnE,MAAa,uBAAwB,SAAQ,+BAAc;IACvD;QACI,KAAK,CACD,iCAAe,CAAC,6BAA6B,EAC7C,+CAAsB,CAAC,oBAAoB,EAC3C,uCAAkB,CAAC,cAAc,EACjC;YACI,MAAM,EAAE,iCAAe,CAAC,UAAU;SACrC,CACJ,CAAC;IACN,CAAC;IAED,MAAM,CAAC,OAAa;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,CAAC,EAAO;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CACJ;AAlBD,0DAkBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IGeoJsonAllFilterParameters, IGeoJSONFeature, IGeoJSONFeatureCollection, IPropertyResponseModel, SequelizeModel } from "@golemio/core/dist/output-gateway";
|
|
2
|
+
import { IGeoJsonModel } from "@golemio/core/dist/output-gateway/models/interfaces/IGeoJsonModel";
|
|
3
|
+
import { PlaygroundPropertyModel } from "./PlaygroundPropertyModel";
|
|
4
|
+
import { PropertyModel } from "./PropertyModel";
|
|
5
|
+
export declare class PlaygroundsModel extends SequelizeModel implements IGeoJsonModel {
|
|
6
|
+
propertiesModel: PropertyModel;
|
|
7
|
+
playgroundPropertyModel: PlaygroundPropertyModel;
|
|
8
|
+
constructor();
|
|
9
|
+
IsPrimaryIdNumber(idKey: string): Promise<boolean>;
|
|
10
|
+
PrimaryIdentifierSelection(inId: string): object;
|
|
11
|
+
GetAll: (options?: IGeoJsonAllFilterParameters | undefined) => Promise<IGeoJSONFeatureCollection>;
|
|
12
|
+
GetOne: (id: any) => Promise<IGeoJSONFeature | undefined>;
|
|
13
|
+
GetProperties: () => Promise<IPropertyResponseModel[]>;
|
|
14
|
+
private CreateOutputItem;
|
|
15
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PlaygroundsModel = void 0;
|
|
16
|
+
const OutputPlayground_1 = require("../../schema-definitions/output/OutputPlayground");
|
|
17
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
18
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
19
|
+
const Playground_1 = require("../../schema-definitions/sequelize-models/Playground");
|
|
20
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
21
|
+
const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
|
|
22
|
+
const FilterHelper_1 = require("./FilterHelper");
|
|
23
|
+
const PlaygroundPropertyModel_1 = require("./PlaygroundPropertyModel");
|
|
24
|
+
const PropertyModel_1 = require("./PropertyModel");
|
|
25
|
+
class PlaygroundsModel extends output_gateway_1.SequelizeModel {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.playgroundsModelName, PlaygroundSchemaTables_1.PlaygroundSchemaTables.Playground, Playground_1.Playground.attributesModel, {
|
|
28
|
+
schema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
29
|
+
});
|
|
30
|
+
this.GetAll = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const result = yield this.sequelizeModel.findAll({
|
|
32
|
+
attributes: {
|
|
33
|
+
include: ["updated_at"],
|
|
34
|
+
},
|
|
35
|
+
include: "properties",
|
|
36
|
+
where: options
|
|
37
|
+
? {
|
|
38
|
+
[sequelize_1.default.Op.and]: [
|
|
39
|
+
...FilterHelper_1.FilterHelper.prepareFilterForLocation(options),
|
|
40
|
+
...FilterHelper_1.FilterHelper.prepareFilterForUpdateSince(options),
|
|
41
|
+
...FilterHelper_1.FilterHelper.prepareFilterForDistricts(options),
|
|
42
|
+
],
|
|
43
|
+
}
|
|
44
|
+
: {},
|
|
45
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
46
|
+
offset: Number.isInteger(options === null || options === void 0 ? void 0 : options.offset) ? options === null || options === void 0 ? void 0 : options.offset : undefined,
|
|
47
|
+
});
|
|
48
|
+
return (0, output_gateway_1.buildGeojsonFeatureCollection)(result.map((element) => this.CreateOutputItem(element)));
|
|
49
|
+
});
|
|
50
|
+
this.GetOne = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const result = yield this.sequelizeModel.findOne({
|
|
52
|
+
attributes: {
|
|
53
|
+
include: ["updated_at"],
|
|
54
|
+
},
|
|
55
|
+
where: { external_id: id },
|
|
56
|
+
include: "properties",
|
|
57
|
+
});
|
|
58
|
+
return this.CreateOutputItem(result);
|
|
59
|
+
});
|
|
60
|
+
this.GetProperties = () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const result = yield this.propertiesModel.sequelizeModel.findAll();
|
|
62
|
+
return result.map((x) => {
|
|
63
|
+
const property = {
|
|
64
|
+
id: x.id,
|
|
65
|
+
title: x.description,
|
|
66
|
+
};
|
|
67
|
+
return property;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
this.CreateOutputItem = (result) => {
|
|
71
|
+
if (!result)
|
|
72
|
+
return undefined;
|
|
73
|
+
return new OutputPlayground_1.OutputPlayground(result);
|
|
74
|
+
};
|
|
75
|
+
this.propertiesModel = new PropertyModel_1.PropertyModel();
|
|
76
|
+
this.playgroundPropertyModel = new PlaygroundPropertyModel_1.PlaygroundPropertyModel();
|
|
77
|
+
PlaygroundsInfo_1.PlaygroundsInfo.associateTables(this.sequelizeModel, this.propertiesModel.sequelizeModel, this.playgroundPropertyModel.sequelizeModel);
|
|
78
|
+
}
|
|
79
|
+
IsPrimaryIdNumber(idKey) {
|
|
80
|
+
return Promise.resolve(true);
|
|
81
|
+
}
|
|
82
|
+
PrimaryIdentifierSelection(inId) {
|
|
83
|
+
return { internal_id: inId };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.PlaygroundsModel = PlaygroundsModel;
|
|
87
|
+
//# sourceMappingURL=PlaygroundsModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundsModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/PlaygroundsModel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uFAAgE;AAChE,4FAAqE;AACrE,8EAAuD;AAEvD,qFAA8D;AAE9D,sEAO2C;AAE3C,oFAA4D;AAC5D,iD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C;IACjC,CAAC;CAqDJ;AA7ED,4CA6EC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyModel = void 0;
|
|
4
|
+
const PlaygroundSchemaTables_1 = require("../../schema-definitions/PlaygroundSchemaTables");
|
|
5
|
+
const PlaygroundsInfo_1 = require("../../schema-definitions/PlaygroundsInfo");
|
|
6
|
+
const Property_1 = require("../../schema-definitions/sequelize-models/Property");
|
|
7
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
8
|
+
class PropertyModel extends output_gateway_1.SequelizeModel {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(PlaygroundsInfo_1.PlaygroundsInfo.propertiesModelName, PlaygroundSchemaTables_1.PlaygroundSchemaTables.Properties, Property_1.Property.attributeModel, {
|
|
11
|
+
schema: PlaygroundsInfo_1.PlaygroundsInfo.schemaName,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
GetAll(options) {
|
|
15
|
+
throw new Error("Method not implemented.");
|
|
16
|
+
}
|
|
17
|
+
GetOne(id) {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PropertyModel = PropertyModel;
|
|
22
|
+
//# sourceMappingURL=PropertyModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/PropertyModel.ts"],"names":[],"mappings":";;;AAAA,4FAAqE;AACrE,8EAAuD;AACvD,iFAA0D;AAC1D,sEAAmE;AAEnE,MAAa,aAAc,SAAQ,+BAAc;IAC7C;QACI,KAAK,CAAC,iCAAe,CAAC,mBAAmB,EAAE,+CAAsB,CAAC,UAAU,EAAE,mBAAQ,CAAC,cAAc,EAAE;YACnG,MAAM,EAAE,iCAAe,CAAC,UAAU;SACrC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,OAAa;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,CAAC,EAAO;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CACJ;AAbD,sCAaC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaygroundSchemaTables = void 0;
|
|
4
|
+
var PlaygroundSchemaTables;
|
|
5
|
+
(function (PlaygroundSchemaTables) {
|
|
6
|
+
PlaygroundSchemaTables["Playground"] = "playground";
|
|
7
|
+
PlaygroundSchemaTables["Properties"] = "properties";
|
|
8
|
+
PlaygroundSchemaTables["PlaygroundProperties"] = "playground_properties";
|
|
9
|
+
})(PlaygroundSchemaTables = exports.PlaygroundSchemaTables || (exports.PlaygroundSchemaTables = {}));
|
|
10
|
+
//# sourceMappingURL=PlaygroundSchemaTables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaygroundSchemaTables.js","sourceRoot":"","sources":["../../src/schema-definitions/PlaygroundSchemaTables.ts"],"names":[],"mappings":";;;AAAA,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAC9B,mDAAyB,CAAA;IACzB,mDAAyB,CAAA;IACzB,wEAA8C,CAAA;AAClD,CAAC,EAJW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAIjC"}
|