@geode/opengeodeweb-microservice 1.0.0-rc.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Geode-solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ <h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
2
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
3
+
4
+ <p align="center">
5
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
6
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
7
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
8
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
9
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
10
+ </p>
11
+
12
+ <p align="center">
13
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
14
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
15
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
16
+ </p>
17
+
18
+ ---
19
+
20
+ ## Introduction
21
+
22
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
23
+
24
+ ## Changelog
25
+
26
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
27
+
28
+ ## License
29
+
30
+ [MIT](https://opensource.org/licenses/MIT)
31
+
32
+ Copyright (c) 2019 - 2025, Geode-solutions
@@ -0,0 +1,122 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const glob = require("glob");
4
+ const process = require("process");
5
+
6
+ console.log("process.argv", process.argv);
7
+
8
+ var projectName = process.argv[2];
9
+ console.log("projectName", projectName);
10
+ var folderName = process.argv[3];
11
+ console.log("folderName", folderName);
12
+ var key = process.argv[4];
13
+ console.log("key", key);
14
+ var separator = process.argv[5];
15
+ console.log("separator", separator);
16
+
17
+ const findDirectoryPath = (targetDirectoryName, folderName) => {
18
+ const pathToCheck = path.join(
19
+ process.cwd(),
20
+ "/src",
21
+ "/",
22
+ targetDirectoryName
23
+ );
24
+ console.log("pathToCheck", pathToCheck);
25
+
26
+ const folders = fs
27
+ .readdirSync(pathToCheck, { withFileTypes: true })
28
+ .filter(
29
+ (folder) =>
30
+ folder.isDirectory() &&
31
+ !folder.name.endsWith(".egg-info") &&
32
+ folder.name != "tests" &&
33
+ folder.name != "__pycache__" &&
34
+ folder.name.includes(folderName)
35
+ )
36
+ .map((folder) => ({
37
+ name: folder.name,
38
+ path: path.join(pathToCheck, folder.name),
39
+ }));
40
+ console.log("folders", folders);
41
+ const routesDirectory = path.join(folders[0].path);
42
+ return routesDirectory;
43
+ };
44
+
45
+ const directoryPath = findDirectoryPath(projectName, folderName);
46
+
47
+ const outputFile = path.join(process.cwd(), `${projectName}_schemas.json`);
48
+
49
+ function return_json_schema(directoryPath, folder_path, projectName) {
50
+ console.log("return_json_schema", directoryPath, folder_path, projectName);
51
+
52
+ const folders = fs
53
+ .readdirSync(path.normalize(directoryPath), { withFileTypes: true })
54
+ .filter((folder) => folder.isDirectory() && folder.name != "__pycache__")
55
+ .map((folder) => ({
56
+ name: folder.name,
57
+ path: path.join(directoryPath, folder.name),
58
+ }));
59
+ var folders_schemas = {};
60
+ folders.forEach((folder) => {
61
+ if (folder.name == "schemas") {
62
+ const jsonFiles = glob.sync(path.join(folder.path, "**/*.json"));
63
+ var schemas = {};
64
+ jsonFiles.forEach((filePath) => {
65
+ try {
66
+ const fileContent = fs.readFileSync(filePath, "utf8");
67
+ var jsonData = JSON.parse(fileContent);
68
+ var filename = filePath
69
+ .replace(/^.*[\\/]/, "")
70
+ .replace(/\.[^/.]+$/, "");
71
+ var route = jsonData[key];
72
+ console.log("FOLDER PATH", projectName);
73
+ var values = [projectName, folder_path, route];
74
+ console.log("values", values);
75
+ values = values.map(function (x) {
76
+ console.log("x", x);
77
+ return x.replace("/", "").replace(".", "");
78
+ }); // first replace first . / by empty string
79
+ values = values.map(function (x) {
80
+ console.log("x", x);
81
+ return x.replaceAll("/", separator).replaceAll(".", separator);
82
+ }); // then replace all . / by separator
83
+ console.log("values", values);
84
+ jsonData["$id"] = values
85
+ .filter(function (val) {
86
+ return val;
87
+ })
88
+ .join(separator);
89
+ schemas[filename] = jsonData;
90
+ } catch (error) {
91
+ console.error(
92
+ `Erreur lors de la lecture du fichier ${filePath}:`,
93
+ error
94
+ );
95
+ }
96
+ });
97
+ folders_schemas = Object.keys(schemas).reduce((acc, key) => {
98
+ const currentSchema = schemas[key];
99
+ const modifiedSchema = {
100
+ $id: path.join(folder_path, currentSchema["$id"]),
101
+ ...currentSchema,
102
+ };
103
+ acc[key] = modifiedSchema;
104
+ return acc;
105
+ }, folders_schemas);
106
+ } else {
107
+ var new_folder_path = folder_path + "/" + folder.name;
108
+ var test = return_json_schema(folder.path, new_folder_path, projectName);
109
+ folders_schemas[folder.name] = test;
110
+ }
111
+ });
112
+ return folders_schemas;
113
+ }
114
+
115
+ if (fs.existsSync(outputFile)) {
116
+ fs.unlinkSync(outputFile);
117
+ }
118
+
119
+ const finalJson = {};
120
+ finalJson[projectName] = return_json_schema(directoryPath, "", projectName);
121
+
122
+ fs.writeFileSync(outputFile, JSON.stringify(finalJson, null, 2));
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@geode/opengeodeweb-microservice",
3
+ "version": "1.0.0-rc.2",
4
+ "description": "Shared utilities and schema generator for OpenGeodeWeb ecosystem",
5
+ "main": "generate_schemas.js",
6
+ "bin": {
7
+ "ogw-generate-schemas": "./generate_schemas.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 0",
11
+ "build": "echo \"Error: no test specified\" && exit 0"
12
+ },
13
+ "dependencies": {
14
+ "glob": "^11.0.3"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Geode-solutions/OpenGeodeWeb-Microservice.git"
19
+ },
20
+ "author": {
21
+ "name": "Geode-solutions",
22
+ "email": "contact@geode-solutions.com",
23
+ "url": "https://geode-solutions.com/"
24
+ },
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/issues"
28
+ },
29
+ "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "files": [
34
+ "generate_schemas.js"
35
+ ]
36
+ }