@oliasoft-open-source/node-json-migrator 3.0.0-beta-4 → 3.0.0-beta-6

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.
Files changed (3) hide show
  1. package/dist/index.cjs +180 -34
  2. package/dist/index.mjs +180 -34
  3. package/package.json +2 -3
package/dist/index.cjs CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  var path$1 = require('path');
4
4
  var fs = require('fs');
5
- var ajv$1 = require('ajv');
6
- var ajvErrors = require('ajv-errors');
7
5
  var moduleFromString = require('module-from-string');
8
6
  var crypto = require('crypto');
9
7
  var node_url = require('node:url');
@@ -2079,42 +2077,190 @@ var xor = baseRest(function(arrays) {
2079
2077
  return baseXor(arrayFilter(arrays, isArrayLikeObject));
2080
2078
  });
2081
2079
 
2082
- var type = "array";
2083
- var items = {
2084
- type: "object",
2085
- properties: {
2086
- fileHash: {
2087
- type: [
2088
- "string"
2089
- ]
2090
- },
2091
- fileName: {
2092
- type: "string"
2093
- },
2094
- sequence: {
2095
- type: "string",
2096
- pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$"
2097
- }
2098
- },
2099
- required: [
2100
- "fileHash",
2101
- "fileName",
2102
- "sequence"
2103
- ],
2104
- additionalProperties: false
2105
- };
2106
- var planSchema = {
2107
- type: type,
2108
- items: items
2080
+ const planSchemaValidator = validate14;
2081
+ const schema32 = {
2082
+ items: {
2083
+ properties: {
2084
+ fileHash: { type: ["string"] }}}
2109
2085
  };
2086
+ const pattern0 = new RegExp("^[1-9][0-9]*(.[1-9][0-9]*)*$", "u");
2087
+ function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2088
+ let vErrors = null;
2089
+ let errors = 0;
2090
+ if (Array.isArray(data)) {
2091
+ const len0 = data.length;
2092
+ for (let i0 = 0; i0 < len0; i0++) {
2093
+ let data0 = data[i0];
2094
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
2095
+ if (data0.fileHash === void 0) {
2096
+ const err0 = {
2097
+ instancePath: instancePath + "/" + i0,
2098
+ schemaPath: "#/items/required",
2099
+ keyword: "required",
2100
+ params: { missingProperty: "fileHash" },
2101
+ message: "must have required property 'fileHash'"
2102
+ };
2103
+ if (vErrors === null) {
2104
+ vErrors = [err0];
2105
+ } else {
2106
+ vErrors.push(err0);
2107
+ }
2108
+ errors++;
2109
+ }
2110
+ if (data0.fileName === void 0) {
2111
+ const err1 = {
2112
+ instancePath: instancePath + "/" + i0,
2113
+ schemaPath: "#/items/required",
2114
+ keyword: "required",
2115
+ params: { missingProperty: "fileName" },
2116
+ message: "must have required property 'fileName'"
2117
+ };
2118
+ if (vErrors === null) {
2119
+ vErrors = [err1];
2120
+ } else {
2121
+ vErrors.push(err1);
2122
+ }
2123
+ errors++;
2124
+ }
2125
+ if (data0.sequence === void 0) {
2126
+ const err2 = {
2127
+ instancePath: instancePath + "/" + i0,
2128
+ schemaPath: "#/items/required",
2129
+ keyword: "required",
2130
+ params: { missingProperty: "sequence" },
2131
+ message: "must have required property 'sequence'"
2132
+ };
2133
+ if (vErrors === null) {
2134
+ vErrors = [err2];
2135
+ } else {
2136
+ vErrors.push(err2);
2137
+ }
2138
+ errors++;
2139
+ }
2140
+ for (const key0 in data0) {
2141
+ if (!(key0 === "fileHash" || key0 === "fileName" || key0 === "sequence")) {
2142
+ const err3 = {
2143
+ instancePath: instancePath + "/" + i0,
2144
+ schemaPath: "#/items/additionalProperties",
2145
+ keyword: "additionalProperties",
2146
+ params: { additionalProperty: key0 },
2147
+ message: "must NOT have additional properties"
2148
+ };
2149
+ if (vErrors === null) {
2150
+ vErrors = [err3];
2151
+ } else {
2152
+ vErrors.push(err3);
2153
+ }
2154
+ errors++;
2155
+ }
2156
+ }
2157
+ if (data0.fileHash !== void 0) {
2158
+ if (typeof data0.fileHash !== "string") {
2159
+ const err4 = {
2160
+ instancePath: instancePath + "/" + i0 + "/fileHash",
2161
+ schemaPath: "#/items/properties/fileHash/type",
2162
+ keyword: "type",
2163
+ params: { type: schema32.items.properties.fileHash.type },
2164
+ message: "must be string"
2165
+ };
2166
+ if (vErrors === null) {
2167
+ vErrors = [err4];
2168
+ } else {
2169
+ vErrors.push(err4);
2170
+ }
2171
+ errors++;
2172
+ }
2173
+ }
2174
+ if (data0.fileName !== void 0) {
2175
+ if (typeof data0.fileName !== "string") {
2176
+ const err5 = {
2177
+ instancePath: instancePath + "/" + i0 + "/fileName",
2178
+ schemaPath: "#/items/properties/fileName/type",
2179
+ keyword: "type",
2180
+ params: { type: "string" },
2181
+ message: "must be string"
2182
+ };
2183
+ if (vErrors === null) {
2184
+ vErrors = [err5];
2185
+ } else {
2186
+ vErrors.push(err5);
2187
+ }
2188
+ errors++;
2189
+ }
2190
+ }
2191
+ if (data0.sequence !== void 0) {
2192
+ let data3 = data0.sequence;
2193
+ if (typeof data3 === "string") {
2194
+ if (!pattern0.test(data3)) {
2195
+ const err6 = {
2196
+ instancePath: instancePath + "/" + i0 + "/sequence",
2197
+ schemaPath: "#/items/properties/sequence/pattern",
2198
+ keyword: "pattern",
2199
+ params: { pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$" },
2200
+ message: 'must match pattern "^[1-9][0-9]*(.[1-9][0-9]*)*$"'
2201
+ };
2202
+ if (vErrors === null) {
2203
+ vErrors = [err6];
2204
+ } else {
2205
+ vErrors.push(err6);
2206
+ }
2207
+ errors++;
2208
+ }
2209
+ } else {
2210
+ const err7 = {
2211
+ instancePath: instancePath + "/" + i0 + "/sequence",
2212
+ schemaPath: "#/items/properties/sequence/type",
2213
+ keyword: "type",
2214
+ params: { type: "string" },
2215
+ message: "must be string"
2216
+ };
2217
+ if (vErrors === null) {
2218
+ vErrors = [err7];
2219
+ } else {
2220
+ vErrors.push(err7);
2221
+ }
2222
+ errors++;
2223
+ }
2224
+ }
2225
+ } else {
2226
+ const err8 = {
2227
+ instancePath: instancePath + "/" + i0,
2228
+ schemaPath: "#/items/type",
2229
+ keyword: "type",
2230
+ params: { type: "object" },
2231
+ message: "must be object"
2232
+ };
2233
+ if (vErrors === null) {
2234
+ vErrors = [err8];
2235
+ } else {
2236
+ vErrors.push(err8);
2237
+ }
2238
+ errors++;
2239
+ }
2240
+ }
2241
+ } else {
2242
+ const err9 = {
2243
+ instancePath,
2244
+ schemaPath: "#/type",
2245
+ keyword: "type",
2246
+ params: { type: "array" },
2247
+ message: "must be array"
2248
+ };
2249
+ if (vErrors === null) {
2250
+ vErrors = [err9];
2251
+ } else {
2252
+ vErrors.push(err9);
2253
+ }
2254
+ errors++;
2255
+ }
2256
+ validate14.errors = vErrors;
2257
+ return errors === 0;
2258
+ }
2110
2259
 
2111
2260
  const isNonEmptyString = (input) => isString(input) && input.length > 0;
2112
- const ajv = new ajv$1.Ajv({ allErrors: true });
2113
- ajvErrors(ajv);
2114
- const planValidator = ajv.compile(planSchema);
2115
2261
  const validatePlan = (plan) => {
2116
- const valid = planValidator(plan);
2117
- const { errors } = planValidator;
2262
+ const valid = planSchemaValidator(plan);
2263
+ const errors = planSchemaValidator.errors;
2118
2264
  if (errors?.length) {
2119
2265
  errors.forEach(
2120
2266
  (e) => console.error(
package/dist/index.mjs CHANGED
@@ -1,7 +1,5 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import path$1 from 'path';
2
2
  import { realpathSync as realpathSync$1, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, promises } from 'fs';
3
- import { Ajv } from 'ajv';
4
- import ajvErrors from 'ajv-errors';
5
3
  import { importFromString } from 'module-from-string';
6
4
  import { createHash } from 'crypto';
7
5
  import { fileURLToPath } from 'node:url';
@@ -2058,42 +2056,190 @@ var xor = baseRest(function(arrays) {
2058
2056
  return baseXor(arrayFilter(arrays, isArrayLikeObject));
2059
2057
  });
2060
2058
 
2061
- var type = "array";
2062
- var items = {
2063
- type: "object",
2064
- properties: {
2065
- fileHash: {
2066
- type: [
2067
- "string"
2068
- ]
2069
- },
2070
- fileName: {
2071
- type: "string"
2072
- },
2073
- sequence: {
2074
- type: "string",
2075
- pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$"
2076
- }
2077
- },
2078
- required: [
2079
- "fileHash",
2080
- "fileName",
2081
- "sequence"
2082
- ],
2083
- additionalProperties: false
2084
- };
2085
- var planSchema = {
2086
- type: type,
2087
- items: items
2059
+ const planSchemaValidator = validate14;
2060
+ const schema32 = {
2061
+ items: {
2062
+ properties: {
2063
+ fileHash: { type: ["string"] }}}
2088
2064
  };
2065
+ const pattern0 = new RegExp("^[1-9][0-9]*(.[1-9][0-9]*)*$", "u");
2066
+ function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2067
+ let vErrors = null;
2068
+ let errors = 0;
2069
+ if (Array.isArray(data)) {
2070
+ const len0 = data.length;
2071
+ for (let i0 = 0; i0 < len0; i0++) {
2072
+ let data0 = data[i0];
2073
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
2074
+ if (data0.fileHash === void 0) {
2075
+ const err0 = {
2076
+ instancePath: instancePath + "/" + i0,
2077
+ schemaPath: "#/items/required",
2078
+ keyword: "required",
2079
+ params: { missingProperty: "fileHash" },
2080
+ message: "must have required property 'fileHash'"
2081
+ };
2082
+ if (vErrors === null) {
2083
+ vErrors = [err0];
2084
+ } else {
2085
+ vErrors.push(err0);
2086
+ }
2087
+ errors++;
2088
+ }
2089
+ if (data0.fileName === void 0) {
2090
+ const err1 = {
2091
+ instancePath: instancePath + "/" + i0,
2092
+ schemaPath: "#/items/required",
2093
+ keyword: "required",
2094
+ params: { missingProperty: "fileName" },
2095
+ message: "must have required property 'fileName'"
2096
+ };
2097
+ if (vErrors === null) {
2098
+ vErrors = [err1];
2099
+ } else {
2100
+ vErrors.push(err1);
2101
+ }
2102
+ errors++;
2103
+ }
2104
+ if (data0.sequence === void 0) {
2105
+ const err2 = {
2106
+ instancePath: instancePath + "/" + i0,
2107
+ schemaPath: "#/items/required",
2108
+ keyword: "required",
2109
+ params: { missingProperty: "sequence" },
2110
+ message: "must have required property 'sequence'"
2111
+ };
2112
+ if (vErrors === null) {
2113
+ vErrors = [err2];
2114
+ } else {
2115
+ vErrors.push(err2);
2116
+ }
2117
+ errors++;
2118
+ }
2119
+ for (const key0 in data0) {
2120
+ if (!(key0 === "fileHash" || key0 === "fileName" || key0 === "sequence")) {
2121
+ const err3 = {
2122
+ instancePath: instancePath + "/" + i0,
2123
+ schemaPath: "#/items/additionalProperties",
2124
+ keyword: "additionalProperties",
2125
+ params: { additionalProperty: key0 },
2126
+ message: "must NOT have additional properties"
2127
+ };
2128
+ if (vErrors === null) {
2129
+ vErrors = [err3];
2130
+ } else {
2131
+ vErrors.push(err3);
2132
+ }
2133
+ errors++;
2134
+ }
2135
+ }
2136
+ if (data0.fileHash !== void 0) {
2137
+ if (typeof data0.fileHash !== "string") {
2138
+ const err4 = {
2139
+ instancePath: instancePath + "/" + i0 + "/fileHash",
2140
+ schemaPath: "#/items/properties/fileHash/type",
2141
+ keyword: "type",
2142
+ params: { type: schema32.items.properties.fileHash.type },
2143
+ message: "must be string"
2144
+ };
2145
+ if (vErrors === null) {
2146
+ vErrors = [err4];
2147
+ } else {
2148
+ vErrors.push(err4);
2149
+ }
2150
+ errors++;
2151
+ }
2152
+ }
2153
+ if (data0.fileName !== void 0) {
2154
+ if (typeof data0.fileName !== "string") {
2155
+ const err5 = {
2156
+ instancePath: instancePath + "/" + i0 + "/fileName",
2157
+ schemaPath: "#/items/properties/fileName/type",
2158
+ keyword: "type",
2159
+ params: { type: "string" },
2160
+ message: "must be string"
2161
+ };
2162
+ if (vErrors === null) {
2163
+ vErrors = [err5];
2164
+ } else {
2165
+ vErrors.push(err5);
2166
+ }
2167
+ errors++;
2168
+ }
2169
+ }
2170
+ if (data0.sequence !== void 0) {
2171
+ let data3 = data0.sequence;
2172
+ if (typeof data3 === "string") {
2173
+ if (!pattern0.test(data3)) {
2174
+ const err6 = {
2175
+ instancePath: instancePath + "/" + i0 + "/sequence",
2176
+ schemaPath: "#/items/properties/sequence/pattern",
2177
+ keyword: "pattern",
2178
+ params: { pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$" },
2179
+ message: 'must match pattern "^[1-9][0-9]*(.[1-9][0-9]*)*$"'
2180
+ };
2181
+ if (vErrors === null) {
2182
+ vErrors = [err6];
2183
+ } else {
2184
+ vErrors.push(err6);
2185
+ }
2186
+ errors++;
2187
+ }
2188
+ } else {
2189
+ const err7 = {
2190
+ instancePath: instancePath + "/" + i0 + "/sequence",
2191
+ schemaPath: "#/items/properties/sequence/type",
2192
+ keyword: "type",
2193
+ params: { type: "string" },
2194
+ message: "must be string"
2195
+ };
2196
+ if (vErrors === null) {
2197
+ vErrors = [err7];
2198
+ } else {
2199
+ vErrors.push(err7);
2200
+ }
2201
+ errors++;
2202
+ }
2203
+ }
2204
+ } else {
2205
+ const err8 = {
2206
+ instancePath: instancePath + "/" + i0,
2207
+ schemaPath: "#/items/type",
2208
+ keyword: "type",
2209
+ params: { type: "object" },
2210
+ message: "must be object"
2211
+ };
2212
+ if (vErrors === null) {
2213
+ vErrors = [err8];
2214
+ } else {
2215
+ vErrors.push(err8);
2216
+ }
2217
+ errors++;
2218
+ }
2219
+ }
2220
+ } else {
2221
+ const err9 = {
2222
+ instancePath,
2223
+ schemaPath: "#/type",
2224
+ keyword: "type",
2225
+ params: { type: "array" },
2226
+ message: "must be array"
2227
+ };
2228
+ if (vErrors === null) {
2229
+ vErrors = [err9];
2230
+ } else {
2231
+ vErrors.push(err9);
2232
+ }
2233
+ errors++;
2234
+ }
2235
+ validate14.errors = vErrors;
2236
+ return errors === 0;
2237
+ }
2089
2238
 
2090
2239
  const isNonEmptyString = (input) => isString(input) && input.length > 0;
2091
- const ajv = new Ajv({ allErrors: true });
2092
- ajvErrors(ajv);
2093
- const planValidator = ajv.compile(planSchema);
2094
2240
  const validatePlan = (plan) => {
2095
- const valid = planValidator(plan);
2096
- const { errors } = planValidator;
2241
+ const valid = planSchemaValidator(plan);
2242
+ const errors = planSchemaValidator.errors;
2097
2243
  if (errors?.length) {
2098
2244
  errors.forEach(
2099
2245
  (e) => console.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/node-json-migrator",
3
- "version": "3.0.0-beta-4",
3
+ "version": "3.0.0-beta-6",
4
4
  "description": "A library for JSON migrations",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/node-postgresql-migrator",
6
6
  "bugs": {
@@ -31,6 +31,7 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "build": "pkgroll --clean-dist",
34
+ "compile:validators": "tsx scripts/compile-validators.ts",
34
35
  "lint:check": "npx eslint '**/*.{js,ts,json}'",
35
36
  "lint:fix": "npx eslint --fix '**/*.{js,ts,json}'",
36
37
  "prepare": "husky",
@@ -74,8 +75,6 @@
74
75
  "typescript-eslint": "^8.26.1"
75
76
  },
76
77
  "peerDependencies": {
77
- "ajv": "^8",
78
- "ajv-errors": "^3",
79
78
  "pg-promise": "^10||^11"
80
79
  },
81
80
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"