@griddo/ax 12.12.2 → 12.13.0-rc.0

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/README.md CHANGED
@@ -9,29 +9,27 @@
9
9
 
10
10
  ### Desarrollo
11
11
 
12
- - `yarn start` - Alias para `start:dev`
13
- - `yarn start:local` - Inicia el servidor de desarrollo en entorno local
14
- - `yarn start:dev` - Inicia el servidor de desarrollo en entorno de desarrollo
15
- - `yarn start:staging` - Inicia el servidor de desarrollo en entorno de staging
12
+ - `pnpm start` - Alias para `start:dev`
13
+ - `pnpm start:local` - Inicia el servidor de desarrollo en entorno local
14
+ - `pnpm start:dev` - Inicia el servidor de desarrollo en entorno de desarrollo
15
+ - `pnpm start:staging` - Inicia el servidor de desarrollo en entorno de staging
16
16
 
17
17
  ### Build
18
18
 
19
- - `yarn build` - Construye la aplicación para producción
20
- - `yarn build:dev` - Construye la aplicación para desarrollo
19
+ - `pnpm build` - Construye la aplicación para producción
20
+ - `pnpm build:dev` - Construye la aplicación para desarrollo
21
21
 
22
22
  ### Testing
23
23
 
24
- - `yarn test` - Ejecuta los tests con Jest
25
- - `yarn test:watch` - Ejecuta los tests en modo watch
26
- - `yarn test:ci` - Ejecuta los tests en modo CI (sin paralelización)
27
- - `yarn test:coverage` - Ejecuta los tests y genera reporte de cobertura
28
- - `yarn test:dev` - Ejecuta los tests en modo watch (alias de `test:watch`)
29
- - `yarn test:dev:coverage` - Ejecuta los tests con cobertura en modo watch
24
+ - `pnpm test` - Ejecuta los tests con Jest
25
+ - `pnpm test:watch` - Ejecuta los tests en modo watch
26
+ - `pnpm test:ci` - Ejecuta los tests en modo CI (sin paralelización)
27
+ - `pnpm test:coverage` - Ejecuta los tests y genera reporte de cobertura
30
28
 
31
29
  ### Linting y Formato
32
30
 
33
- - `yarn lint` - Verifica el código con Biome (sin escribir)
34
- - `yarn format:write` - Formatea el código con Biome (escribiendo)
31
+ - `pnpm lint` - Verifica el código con Biome (sin escribir)
32
+ - `pnpm format:write` - Formatea el código con Biome (escribiendo)
35
33
 
36
34
  ¿Quieres comprobar solo una regla o categoría específica?
37
35
  ```bash
@@ -22,8 +22,6 @@ const webpackConfig = read(path.join(configDir, "webpack.config.js"));
22
22
  const devServerConfig = read(path.join(configDir, "webpackDevServer.config.js"));
23
23
  const startScript = read(path.join(scriptsDir, "start.js"));
24
24
  const buildScript = read(path.join(scriptsDir, "build.js"));
25
- const schemasConfig = read(path.join(configDir, "webpackSchemas.config.js"));
26
- const syncSchemasScript = read(path.join(scriptsDir, "griddo-sync-schemas.js"));
27
25
  const pkgJson = JSON.parse(read(pkgJsonPath));
28
26
 
29
27
  // ---------------------------------------------------------------------------
@@ -314,27 +312,7 @@ describe("scripts/build.js — wp5 best practices", () => {
314
312
  });
315
313
 
316
314
  // ---------------------------------------------------------------------------
317
- // 6. config/webpackSchemas.config.js — compiler.close()
318
- // ---------------------------------------------------------------------------
319
- describe("config/webpackSchemas.config.js — wp5 best practices", () => {
320
- test("calls compiler.close() after compiler.run()", () => {
321
- expect(schemasConfig).toContain("compiler.close(");
322
- });
323
-
324
- // wp4 ignored output.library for commonjs2; wp5 appends it to the prefix, so a name
325
- // would move the parsed config to module.exports.griddo and break the consumer below.
326
- test("sets no library name, so the bundle stays module.exports = <exports>", () => {
327
- expect(schemasConfig).toContain('libraryTarget: "commonjs2"');
328
- expect(schemasConfig).not.toMatch(/library:\s*"/);
329
- });
330
-
331
- test("scripts/griddo-sync-schemas.js reads the bundle default export", () => {
332
- expect(syncSchemasScript).toContain("_griddoConfig.default");
333
- });
334
- });
335
-
336
- // ---------------------------------------------------------------------------
337
- // 7. package.json — dependencies
315
+ // 6. package.json — dependencies
338
316
  // ---------------------------------------------------------------------------
339
317
  describe("package.json — wp5 dependencies", () => {
340
318
  const allDeps = {
@@ -421,7 +399,7 @@ describe("package.json — wp5 dependencies", () => {
421
399
  });
422
400
 
423
401
  // ---------------------------------------------------------------------------
424
- // 8. package.json — no --openssl-legacy-provider in scripts
402
+ // 7. package.json — no --openssl-legacy-provider in scripts
425
403
  // ---------------------------------------------------------------------------
426
404
  describe("package.json — no openssl legacy provider", () => {
427
405
  test("no script uses --openssl-legacy-provider", () => {
@@ -433,7 +411,7 @@ describe("package.json — no openssl legacy provider", () => {
433
411
  });
434
412
 
435
413
  // ---------------------------------------------------------------------------
436
- // 9. Deleted files must not exist
414
+ // 8. Deleted files must not exist
437
415
  // ---------------------------------------------------------------------------
438
416
  describe("deleted wp4-only files", () => {
439
417
  test("config/pnpTs.js does not exist", () => {
@@ -83,7 +83,7 @@ const hasJsxRuntime = (() => {
83
83
 
84
84
  // This is the production and development configuration.
85
85
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
86
- module.exports = function (webpackEnv) {
86
+ module.exports = (webpackEnv) => {
87
87
  const isEnvDevelopment = webpackEnv === "development";
88
88
  const isEnvProduction = webpackEnv === "production";
89
89
 
@@ -381,7 +381,8 @@ module.exports = function (webpackEnv) {
381
381
  {
382
382
  test: /\.(js|mjs|jsx|ts|tsx)$/,
383
383
  include: [paths.appSrc, paths.componentsPath],
384
- exclude: [/node_modules\/(?!@griddo).*/],
384
+ // pnpm installs ax under node_modules/.pnpm/<id>/node_modules/@griddo/ax.
385
+ exclude: [/node_modules\/(?!(\.pnpm\/[^/]+\/node_modules\/)?@griddo).*/],
385
386
  loader: require.resolve("babel-loader"),
386
387
  options: {
387
388
  customize: require.resolve("babel-preset-react-app/webpack-overrides"),
package/package.json CHANGED
@@ -1,81 +1,64 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "12.12.2",
5
- "authors": [
6
- "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
- "Diego M. Béjar <diego.bejar@secuoyas.com>",
8
- "Francis Vega <francis.vega@secuoyas.com>",
9
- "Gonzalo Hernández <gonzalo.hernandez@secuoyas.com>",
10
- "Sergio Ródenas <sergio.rodenas@secuoyas.com>",
11
- "Txema León <txema.leon@secuoyas.com>"
12
- ],
4
+ "version": "12.13.0-rc.0",
13
5
  "homepage": "https://griddo.io",
14
6
  "repository": {
15
7
  "type": "git",
16
8
  "url": "https://github.com/griddo/griddo"
17
9
  },
18
10
  "bin": {
19
- "griddo": "./scripts/griddo.js",
20
- "griddo-sync-schemas": "./scripts/griddo-sync-schemas.js"
11
+ "griddo": "./scripts/griddo.js"
21
12
  },
22
13
  "scripts": {
23
- "// START": "",
24
14
  "start": "npm run start:dev",
25
15
  "start:local": "node --env-file=./env/.env.local ./scripts/start.js",
26
16
  "start:dev": "node --env-file=./env/.env.development ./scripts/start.js",
27
17
  "start:staging": "node --env-file=./env/.env.staging ./scripts/start.js",
28
- "// BUILD": "",
29
18
  "build": "node ./scripts/build.js",
30
19
  "build:dev": "node --env-file=./env/.env.development ./scripts/build.js",
31
- "// TEST": "",
32
20
  "test": "vitest run",
33
21
  "test:watch": "vitest",
34
22
  "test:ci": "vitest run --no-file-parallelism",
35
23
  "test:coverage": "vitest run --coverage",
36
- "test:dev": "vitest",
37
- "test:dev:coverage": "vitest --coverage",
38
- "// TYPES": "",
39
24
  "typecheck": "tsc --noEmit",
40
- "// LINT": "",
41
25
  "lint": "biome check",
42
26
  "format:write": "biome format --write"
43
27
  },
44
28
  "dependencies": {
29
+ "@babel/core": "7.29.7",
45
30
  "@dnd-kit/core": "6.3.1",
46
31
  "@dnd-kit/sortable": "10.0.0",
47
- "@griddo/api-types": "1.1.3",
32
+ "@dnd-kit/utilities": "3.2.2",
33
+ "@griddo/api-types": "1.3.2",
48
34
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.17",
49
- "@styled-system/prop-types": "5.1.5",
50
- "@styled-system/theme-get": "5.1.2",
51
35
  "@svgr/webpack": "8.1.0",
52
36
  "@testing-library/jest-dom": "5.17.0",
53
37
  "@testing-library/react": "13.4.0",
54
- "@testing-library/user-event": "14.6.6",
38
+ "@testing-library/user-event": "14.6.7",
55
39
  "@types/compress.js": "1.1.3",
56
40
  "@types/draft-js": "0.11.20",
57
41
  "@types/lodash.isequal": "4.5.8",
58
42
  "@types/markdown-draft-js": "2.2.7",
59
- "@types/node": "20.19.43",
43
+ "@types/node": "24.12.4",
60
44
  "@types/react": "18.2.79",
61
- "@types/react-beautiful-dnd": "13.1.8",
62
45
  "@types/react-datepicker": "4.19.6",
63
46
  "@types/react-dom": "18.2.25",
64
47
  "@types/react-draft-wysiwyg": "1.13.9",
65
48
  "@types/react-redux": "7.1.34",
49
+ "@types/react-router": "5.1.20",
66
50
  "@types/react-router-dom": "5.3.3",
67
51
  "@types/react-slick": "0.23.13",
68
- "@types/react-test-renderer": "17.0.9",
69
52
  "@types/styled-components": "5.1.36",
53
+ "@types/testing-library__jest-dom": "5.14.9",
70
54
  "@types/uuid": "8.3.4",
71
- "@types/webpack-env": "1.18.8",
72
55
  "axios": "0.19.0",
73
56
  "babel-loader": "9.2.1",
74
57
  "babel-plugin-named-asset-import": "0.3.8",
75
- "babel-plugin-root-import": "6.6.0",
76
58
  "babel-plugin-styled-components": "2.3.0",
77
59
  "babel-preset-react-app": "10.1.0",
78
60
  "case-sensitive-paths-webpack-plugin": "2.4.0",
61
+ "chalk": "4.1.2",
79
62
  "compress.js": "1.2.2",
80
63
  "connected-react-router": "6.9.3",
81
64
  "css-loader": "6.11.0",
@@ -86,30 +69,27 @@
86
69
  "draft-js": "0.11.7",
87
70
  "draft-js-import-html": "1.4.1",
88
71
  "draftjs-to-html": "0.9.1",
89
- "enhanced-resolve": "5.18.1",
90
- "env-cmd": "10.1.0",
91
72
  "find-up": "5.0.0",
73
+ "froala-editor": "4.0.4",
92
74
  "fs-extra": "7.0.1",
75
+ "history": "4.10.1",
93
76
  "html-to-draftjs": "1.5.0",
94
- "html-to-image": "1.11.7",
77
+ "html-to-image": "1.11.13",
95
78
  "html-webpack-plugin": "5.6.8",
96
- "ignore-loader": "0.1.2",
97
- "is-wsl": "3.1.0",
79
+ "immutable": "3.7.6",
98
80
  "jsdom": "20.0.3",
99
- "jsdom-global": "3.0.2",
100
81
  "lodash.isequal": "4.5.0",
101
82
  "markdown-draft-js": "2.4.0",
102
83
  "mini-css-extract-plugin": "2.10.2",
103
84
  "node-polyfill-webpack-plugin": "3.0.0",
104
85
  "pkg-dir": "5.0.0",
105
86
  "polished": "3.7.2",
106
- "postcss": "8.5.26",
87
+ "postcss": "8.5.28",
107
88
  "postcss-flexbugs-fixes": "5.0.2",
108
89
  "postcss-loader": "7.3.4",
109
90
  "postcss-normalize": "7.0.1",
110
91
  "postcss-preset-env": "6.7.2",
111
92
  "react": "18.2.0",
112
- "react-app-polyfill": "1.0.6",
113
93
  "react-datepicker": "4.25.0",
114
94
  "react-dev-utils": "12.0.1",
115
95
  "react-dom": "18.2.0",
@@ -120,6 +100,7 @@
120
100
  "react-qr-code": "2.2.0",
121
101
  "react-redux": "7.2.9",
122
102
  "react-refresh": "0.14.2",
103
+ "react-router": "5.3.4",
123
104
  "react-router-dom": "5.3.4",
124
105
  "react-select": "5.10.2",
125
106
  "react-slick": "0.30.3",
@@ -128,50 +109,37 @@
128
109
  "redux": "4.2.1",
129
110
  "redux-devtools-extension": "2.13.9",
130
111
  "redux-persist": "6.0.0",
131
- "reflect-metadata": "0.1.13",
112
+ "redux-thunk": "2.4.2",
132
113
  "resolve": "1.22.12",
133
114
  "resolve-url-loader": "4.0.0",
134
- "sass-alias": "1.0.5",
135
115
  "sass-loader": "16.0.8",
136
116
  "semver": "7.8.5",
137
117
  "slick-carousel": "1.8.1",
138
- "source-map-loader": "1.1.3",
139
- "string-replace-loader": "3.1.0",
140
118
  "style-loader": "3.3.4",
141
119
  "styled-components": "5.3.11",
142
120
  "styled-reset": "4.0.1",
143
- "styled-system": "5.1.5",
144
121
  "terser-webpack-plugin": "5.6.1",
145
122
  "typescript": "6.0.3",
146
123
  "uuid": "8.3.2",
147
- "webpack": "5.109.2",
124
+ "webpack": "5.111.1",
148
125
  "webpack-dev-server": "4.15.2",
149
126
  "webpack-manifest-plugin": "5.0.1"
150
127
  },
151
128
  "devDependencies": {
152
- "@babel/core": "7.29.7",
153
- "@babel/helper-environment-visitor": "7.24.7",
154
- "@babel/helper-function-name": "7.24.7",
155
- "@babel/helper-hoist-variables": "7.24.7",
156
- "@babel/helper-split-export-declaration": "7.24.7",
157
- "@babel/plugin-transform-optional-chaining": "7.29.7",
158
- "@babel/preset-env": "7.29.7",
159
- "@babel/preset-react": "7.29.7",
160
- "@babel/preset-typescript": "7.29.7",
161
- "@biomejs/biome": "2.5.14",
129
+ "@biomejs/biome": "2.5.15",
130
+ "@griddo/core": "12.13.0-rc.0",
162
131
  "@types/redux-mock-store": "1.5.0",
163
132
  "@vitest/coverage-v8": "4.1.11",
164
133
  "axios-mock-adapter": "1.22.0",
165
- "prettier": "3.4.2",
166
- "react-test-renderer": "18.2.0",
167
134
  "redux-mock-store": "1.5.5",
168
- "redux-thunk": "2.4.2",
169
- "ts-node": "10.9.2",
170
135
  "vite": "8.3.1",
171
136
  "vitest": "4.1.11",
172
137
  "vitest-mock-extended": "5.1.1",
173
138
  "vitest-styled-components": "1.0.0"
174
139
  },
140
+ "peerDependencies": {
141
+ "@griddo/core": "12.13.0-rc.0"
142
+ },
175
143
  "babel": {
176
144
  "presets": [
177
145
  "react-app"
@@ -189,9 +157,11 @@
189
157
  "last 1 safari version"
190
158
  ]
191
159
  },
160
+ "engines": {
161
+ "node": ">=24.12.0"
162
+ },
192
163
  "files": [
193
164
  "config",
194
- "patches",
195
165
  "public",
196
166
  "scripts",
197
167
  "src",
@@ -201,5 +171,5 @@
201
171
  "publishConfig": {
202
172
  "access": "public"
203
173
  },
204
- "gitHead": "031c5296aa83d7bcd7df5753aea1d8f832236817"
174
+ "gitHead": "df2c1bce4ff38b1d085a89b3d3cbba591200acde"
205
175
  }
package/src/global.d.ts CHANGED
@@ -3,7 +3,6 @@ declare module "components";
3
3
  declare module "froala-editor";
4
4
  declare module "react-froala-wysiwyg";
5
5
  declare module "lodash.isequal";
6
- declare module "is-wsl";
7
6
  declare module "react-draft-wysiwyg";
8
7
  declare module "history";
9
8
  declare module "draftjs-to-html";
@@ -1,7 +1,10 @@
1
1
  import type React from "react";
2
2
 
3
- import type { IModal } from "@ax/types";
4
3
  import { FieldsBehavior, Modal } from "@ax/components";
4
+ import type { IModal } from "@ax/types";
5
+
6
+ import type { ExportFormat } from "@griddo/api-types";
7
+
5
8
  import type { IDownloadFormState } from "..";
6
9
 
7
10
  import * as S from "./style";
@@ -14,7 +17,7 @@ const DownloadModal = (props: IDownloadModalProps) => {
14
17
  const setEndDate = (endDate: string) => setForm((state) => ({ ...state, endDate }));
15
18
  const setStartTime = (startTime: string) => setForm((state) => ({ ...state, startTime }));
16
19
  const setMaxEvents = (maxEvents: number) => setForm((state) => ({ ...state, maxEvents }));
17
- const setFormat = (format: string) => setForm((state) => ({ ...state, format }));
20
+ const setFormat = (format: ExportFormat) => setForm((state) => ({ ...state, format }));
18
21
 
19
22
  const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
20
23
 
@@ -1,19 +1,20 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from "react";
2
2
  import { connect } from "react-redux";
3
- import { format, subDays } from "date-fns";
4
3
 
5
- import type { LogActivityExportRequest, LogActivityPaginationRequest } from "@griddo/api-types";
6
- import type { ILogItemsByDay, ILogItemsByUser, IQueryValue, IRootState, IStructuredData } from "@ax/types";
7
4
  import { EmptyState, ErrorToast, FilterTagsBar, MainWrapper, SearchTagsBar, Select, TableList } from "@ax/components";
8
5
  import { activityLogActions } from "@ax/containers/ActivityLog";
9
6
  import { structuredDataActions } from "@ax/containers/StructuredData";
10
7
  import { useModal } from "@ax/hooks";
8
+ import type { ILogItemsByDay, ILogItemsByUser, IQueryValue, IRootState, IStructuredData } from "@ax/types";
9
+
10
+ import type { ExportFormat, LogActivityExportRequest, LogActivityPaginationRequest } from "@griddo/api-types";
11
+ import { format, subDays } from "date-fns";
11
12
 
13
+ import DownloadModal from "./DownloadModal";
12
14
  import { useFilterQuery } from "./hooks";
13
- import TableHeader from "./TableHeader";
14
15
  import ItemLog from "./ItemLog";
15
16
  import ItemLogUser from "./ItemLogUser";
16
- import DownloadModal from "./DownloadModal";
17
+ import TableHeader from "./TableHeader";
17
18
 
18
19
  import * as S from "./style";
19
20
 
@@ -290,7 +291,7 @@ export interface IDownloadFormState {
290
291
  dateRange: string;
291
292
  startTime: string | null;
292
293
  maxEvents: number | null;
293
- format: string;
294
+ format: ExportFormat;
294
295
  startDate: string | null;
295
296
  endDate: string | null;
296
297
  }
package/tsconfig.json CHANGED
@@ -15,15 +15,7 @@
15
15
  "useUnknownInCatchVariables": false,
16
16
  "noEmit": true,
17
17
  "jsx": "react-jsx",
18
- "types": [
19
- "vitest/globals",
20
- "react",
21
- "reflect-metadata",
22
- "node",
23
- "webpack-env",
24
- "react-dom",
25
- "@testing-library/jest-dom"
26
- ]
18
+ "types": ["vitest/globals", "react", "node", "react-dom", "@testing-library/jest-dom"]
27
19
  },
28
20
  "include": ["src"],
29
21
  "extends": "./tsconfig.paths.json"
@@ -1,69 +0,0 @@
1
- const webpack = require("webpack");
2
-
3
- const { griddoComponentsLibAliases } = require("../config/griddo-config");
4
-
5
- const createConfig = ({ input, output }) => ({
6
- entry: input,
7
- output: {
8
- ...output,
9
- // No library name on purpose: webpack 4 ignored it for commonjs2, but webpack 5
10
- // appends it to the prefix (module.exports.griddo = ...), which would break the
11
- // `_griddoConfig.default` read in scripts/griddo-sync-schemas.js.
12
- libraryTarget: "commonjs2",
13
- },
14
- resolve: {
15
- alias: {
16
- ...griddoComponentsLibAliases,
17
- },
18
- },
19
- plugins: [new webpack.ProgressPlugin()],
20
- module: {
21
- rules: [
22
- {
23
- test: /\.m?[tj]s$/,
24
- resolve: { extensions: [".ts", ".js"] },
25
- exclude: /(node_modules|bower_components)/,
26
- use: {
27
- loader: "babel-loader",
28
- options: {
29
- presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"],
30
- plugins: ["@babel/plugin-transform-optional-chaining"],
31
- },
32
- },
33
- },
34
-
35
- // This is for ignoring images defined in the schemas in order to prevent
36
- // API crashing (it hasn't webpack)
37
- {
38
- test: /\.(png|jpe?g|gif)$/i,
39
- use: [{ loader: "ignore-loader" }],
40
- },
41
- ],
42
- },
43
- });
44
-
45
- module.exports = (withExternalConfig) => {
46
- const config = createConfig(withExternalConfig);
47
-
48
- const compiler = webpack(config);
49
-
50
- return new Promise((resolve, reject) => {
51
- compiler.run((err, stats) => {
52
- // Flush webpack 5's persistent cache before resolving/rejecting.
53
- compiler.close(() => {});
54
-
55
- if (err) {
56
- console.log(err);
57
- return reject(err);
58
- }
59
-
60
- if (stats.compilation.errors && stats.compilation.errors.length) {
61
- return reject(stats.compilation.errors[0]);
62
- }
63
-
64
- return resolve({
65
- stats,
66
- });
67
- });
68
- });
69
- };
@@ -1,163 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const findUp = require("find-up");
4
- const axios = require("axios");
5
- const chalk = require("chalk");
6
- const dotenv = require("dotenv");
7
- const path = require("path");
8
- const fs = require("fs");
9
- const compiler = require("../config/webpackSchemas.config");
10
- const { resolveComponentsPath, resolveComponentsGriddoConfig } = require("../config/griddo-config");
11
-
12
- dotenv.config({ path: findUp.sync(".env") });
13
-
14
- const { API_URL, REACT_APP_API_ENDPOINT, GRIDDO_API_URL, developerKey } = process.env;
15
- const apiURL = API_URL || REACT_APP_API_ENDPOINT || GRIDDO_API_URL;
16
- const tempFile = "__griddo_config_parsed__.js";
17
- const REQUIRED_API_VERSION = "11.1.1";
18
- let failedCount = 0;
19
- const maximumFailedAttempts = 5;
20
-
21
- (async () => {
22
- console.clear();
23
-
24
- const instanceGriddoConfigFile = resolveComponentsGriddoConfig();
25
- const inputFile = instanceGriddoConfigFile;
26
- const outputFile = `${__dirname}/${tempFile}`;
27
-
28
- try {
29
- // Check if the API is in the correct version. If not, it waits for a minute and checks again.
30
- await checkIfAPIisInCorrectVersion();
31
-
32
- if (fs.existsSync(outputFile)) {
33
- fs.unlinkSync(outputFile);
34
- }
35
-
36
- if (!fs.existsSync(inputFile)) {
37
- throw new Error(`Griddo config file not found: ${inputFile}`);
38
- }
39
-
40
- await compiler({
41
- input: instanceGriddoConfigFile,
42
- output: { filename: tempFile, path: __dirname },
43
- });
44
-
45
- if (!fs.existsSync(outputFile)) {
46
- throw new Error(`Unknown error when parsing ${inputFile}`);
47
- }
48
- } catch (err) {
49
- console.log(`\n${chalk.red("ERROR:")} ${err.message}\n`);
50
- process.exit(1);
51
- }
52
-
53
- const _griddoConfig = require(path.resolve(__dirname, `./${tempFile}`));
54
- const griddoConfig = _griddoConfig.default;
55
-
56
- const griddoSchemas = griddoConfig.schemas;
57
-
58
- // La propiedad computed en los schemas de datos estructurados se perderá si
59
- // no la stringificamos primero.
60
- parseComputedPropInStructuredDataSchemas(griddoSchemas.contentTypes.structuredData);
61
-
62
- const { version } = require(resolveComponentsPath("package.json"));
63
-
64
- const emptySchemas = {
65
- config: {
66
- menus: [],
67
- themes: [],
68
- languages: {},
69
- menuItems: {},
70
- moduleCategories: [],
71
- richTextConfig: {},
72
- },
73
- ui: { components: {}, modules: {}, templates: {} },
74
- contentTypes: {
75
- dataPacks: {},
76
- dataPacksCategories: {},
77
- structuredData: {},
78
- },
79
- forms: { templates: {}, fields: {}, categories: [] },
80
- };
81
-
82
- const data = { version, ...emptySchemas, ...griddoSchemas };
83
-
84
- try {
85
- await axios({
86
- url: `${apiURL}/schemas`,
87
- headers: { authorization: developerKey },
88
- method: "PUT",
89
- data,
90
- });
91
- console.log(`${chalk.green(" ✔")} Schemas`);
92
- } catch (e) {
93
- console.log(chalk.red("ERROR:"), e.response?.data?.message || e.response || e.message);
94
- process.exit(1);
95
- }
96
- })();
97
-
98
- /**
99
- * Parse the computed property of structured data schemas to string.
100
- * @mutates
101
- */
102
- function parseComputedPropInStructuredDataSchemas(schemas) {
103
- for (const schema in schemas) {
104
- const fields = schemas[schema].schema?.fields;
105
-
106
- if (!fields) continue;
107
-
108
- for (const field of fields) {
109
- const { computed = null } = field;
110
-
111
- if (computed) field.computed = computed.toString();
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Check if the API is in the correct version. If not, it waits for a minute and checks again.
118
- */
119
-
120
- async function checkIfAPIisInCorrectVersion() {
121
- const actualVersion = await getCurrentAPIVersion();
122
- const isCorrect = checkNewVersionIsGreaterThanLast(actualVersion, REQUIRED_API_VERSION);
123
-
124
- if (!isCorrect) {
125
- console.log(failedCount);
126
- failedCount++;
127
-
128
- console.log(
129
- chalk.yellow(
130
- `API is not in the correct version. Expected version greater than "${REQUIRED_API_VERSION}" and got "${actualVersion}".\n Retry in a minute...\n`,
131
- ),
132
- );
133
-
134
- if (failedCount >= maximumFailedAttempts) {
135
- console.log(chalk.red(`API is not in the correct version after ${maximumFailedAttempts} attempts. Exiting...`));
136
- process.exit(1);
137
- }
138
-
139
- await new Promise((resolve) => setTimeout(resolve, 60000)); // Waits for a minute
140
- await checkIfAPIisInCorrectVersion();
141
- } else {
142
- console.log(chalk.green("✓ API is in the correct version."));
143
- }
144
- }
145
-
146
- /**
147
- * Compare two versions and return true if the actual version is greater than the required version.
148
- */
149
- const checkNewVersionIsGreaterThanLast = (actualVersion, requiredVersion) => {
150
- const [majorA, minorA, patchA] = actualVersion.split(".").map(Number);
151
- const [majorB, minorB, patchB] = requiredVersion.split(".").map(Number);
152
-
153
- return (
154
- majorA > majorB ||
155
- (majorA === majorB && minorA > minorB) ||
156
- (majorA === majorB && minorA === minorB && patchA >= patchB) // Asegura que 11.1.1 sea válido
157
- );
158
- };
159
-
160
- async function getCurrentAPIVersion() {
161
- const response = await axios.get(`${apiURL}/settings`);
162
- return response.data.apiVersion;
163
- }