rads-db 3.1.9 → 3.1.11
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 +19 -0
- package/dist/index.cjs +37 -13
- package/dist/index.mjs +37 -13
- package/drivers/azureCosmos.cjs +35 -7
- package/drivers/azureCosmos.d.ts +1 -0
- package/drivers/azureCosmos.mjs +46 -33
- package/drivers/azureStorageBlob.cjs +2 -2
- package/drivers/azureStorageBlob.d.ts +1 -0
- package/drivers/azureStorageBlob.mjs +4 -8
- package/drivers/indexedDb.cjs +2 -2
- package/drivers/indexedDb.d.ts +1 -0
- package/drivers/indexedDb.mjs +6 -12
- package/drivers/memory.cjs +18 -11
- package/drivers/memory.d.ts +1 -0
- package/drivers/memory.mjs +46 -73
- package/drivers/restApi.cjs +1 -1
- package/drivers/restApi.d.ts +2 -1
- package/drivers/restApi.mjs +2 -4
- package/features/cache.cjs +2 -2
- package/features/cache.mjs +15 -30
- package/features/eventSourcing.cjs +2 -2
- package/features/eventSourcing.d.ts +1 -0
- package/features/eventSourcing.mjs +8 -16
- package/features/softDelete.cjs +1 -1
- package/features/softDelete.mjs +2 -4
- package/fileUploadDrivers/azureStorageBlob.cjs +1 -1
- package/fileUploadDrivers/cloudinary.cjs +1 -1
- package/fileUploadDrivers/memory.cjs +1 -1
- package/fileUploadDrivers/restApi.cjs +1 -1
- package/fileUploadDrivers/restApi.d.ts +1 -0
- package/fileUploadDrivers/restApi.mjs +1 -2
- package/fileUploadDrivers/supabaseStorage.cjs +1 -1
- package/fileUploadDrivers/supabaseStorage.mjs +3 -6
- package/integrations/node.cjs +2 -2
- package/integrations/node.mjs +12 -22
- package/integrations/nuxtModule.cjs +2 -3
- package/integrations/restEndpoints.cjs +1 -1
- package/integrations/restEndpoints.mjs +8 -16
- package/integrations/restEndpointsDev/restEndpointsDevLint.cjs +2 -3
- package/integrations/restEndpointsDev/restEndpointsDevLint.d.ts +1 -1
- package/integrations/restEndpointsDev/restEndpointsDevLint.mjs +5 -10
- package/integrations/restEndpointsDev.cjs +3 -4
- package/integrations/restEndpointsDev.d.ts +1 -1
- package/integrations/restEndpointsDev.mjs +9 -18
- package/integrations/restEndpointsDev2.cjs +3 -4
- package/integrations/restEndpointsDev2.d.ts +0 -1
- package/integrations/restEndpointsDev2.mjs +3 -6
- package/integrations/vite.mjs +3 -6
- package/package.json +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export default (options) => {
|
|
2
2
|
const { supabase } = options || {};
|
|
3
|
-
if (!supabase)
|
|
4
|
-
throw new Error(`Please provide supabase client and bucket name`);
|
|
3
|
+
if (!supabase) throw new Error(`Please provide supabase client and bucket name`);
|
|
5
4
|
const defaultBucket = options.defaultBucket || "files";
|
|
6
5
|
const driver = {
|
|
7
6
|
driverName: "supabase",
|
|
@@ -11,11 +10,9 @@ export default (options) => {
|
|
|
11
10
|
...options.uploadOptions,
|
|
12
11
|
...args.options
|
|
13
12
|
});
|
|
14
|
-
if (error)
|
|
15
|
-
throw error;
|
|
13
|
+
if (error) throw error;
|
|
16
14
|
const resultPath = data?.path;
|
|
17
|
-
if (!resultPath)
|
|
18
|
-
return { url: resultPath };
|
|
15
|
+
if (!resultPath) return { url: resultPath };
|
|
19
16
|
return { url: bucketClient.getPublicUrl(resultPath).data.publicUrl };
|
|
20
17
|
}
|
|
21
18
|
};
|
package/integrations/node.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
|
12
12
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
13
13
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
14
|
var _jiti = require("jiti");
|
|
15
|
-
function _interopRequireDefault(
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
async function generateClient() {
|
|
17
17
|
console.time('"node_modules/_rads-db" generated in');
|
|
18
18
|
const config = await loadConfig();
|
|
@@ -270,7 +270,7 @@ function getWhereFieldsForPrimitive(schema, type, fieldKey) {
|
|
|
270
270
|
throw new Error(`Unknown primitive type: ${field.type}`);
|
|
271
271
|
}
|
|
272
272
|
function getWhereFieldsForString(name) {
|
|
273
|
-
return [`${name}_istartsWith?: string`, `${name}_startsWith?: string`, `${name}_icontains?: string`, `${name}_contains?: string`, `${name}_iendsWith?: string`, `${name}_endsWith?: string`, `${name}_gt?: string`, `${name}_gte?: string`, `${name}_lt?: string`, `${name}_lte?: string`];
|
|
273
|
+
return [`${name}_ieq?: string`, `${name}_istartsWith?: string`, `${name}_startsWith?: string`, `${name}_icontains?: string`, `${name}_contains?: string`, `${name}_iendsWith?: string`, `${name}_endsWith?: string`, `${name}_gt?: string`, `${name}_gte?: string`, `${name}_lt?: string`, `${name}_lte?: string`];
|
|
274
274
|
}
|
|
275
275
|
function getStringHashCode(str) {
|
|
276
276
|
if (!str) return 0;
|
package/integrations/node.mjs
CHANGED
|
@@ -52,8 +52,7 @@ async function loadConfig() {
|
|
|
52
52
|
let config;
|
|
53
53
|
for (const p of paths) {
|
|
54
54
|
config = await jiti.import(p, { try: true });
|
|
55
|
-
if (config)
|
|
56
|
-
break;
|
|
55
|
+
if (config) break;
|
|
57
56
|
}
|
|
58
57
|
if (!config) {
|
|
59
58
|
throw new Error(
|
|
@@ -99,8 +98,7 @@ export function getIndexDtsInner(schema, rootTypeName, entitiesDir) {
|
|
|
99
98
|
const schemaTypesStr = entitiesDir ? "" : getEntityTypesStrFromSchema(schema);
|
|
100
99
|
for (const key in schema) {
|
|
101
100
|
const type = schema[key];
|
|
102
|
-
if (!type.fields)
|
|
103
|
-
continue;
|
|
101
|
+
if (!type.fields) continue;
|
|
104
102
|
if (entitiesDir && type.sourceFile) {
|
|
105
103
|
imports.push(`import type { ${type.name} } from '../../${entitiesDir}/${type.sourceFile}'`);
|
|
106
104
|
}
|
|
@@ -127,8 +125,7 @@ export function getIndexDtsInner(schema, rootTypeName, entitiesDir) {
|
|
|
127
125
|
}
|
|
128
126
|
for (const key in schema) {
|
|
129
127
|
const type = schema[key];
|
|
130
|
-
if (!type.fields)
|
|
131
|
-
continue;
|
|
128
|
+
if (!type.fields) continue;
|
|
132
129
|
const whereFields = getWhereFields(schema, type);
|
|
133
130
|
whereTypes.push(
|
|
134
131
|
`
|
|
@@ -183,15 +180,11 @@ export function getEntityTypesStrFromSchema(schema) {
|
|
|
183
180
|
} else {
|
|
184
181
|
const fields = Object.values(type.fields);
|
|
185
182
|
const fieldsStr = fields.map((f) => {
|
|
186
|
-
if (type.isExtending && schema[type.isExtending]?.fields?.[f.name])
|
|
187
|
-
return "";
|
|
183
|
+
if (type.isExtending && schema[type.isExtending]?.fields?.[f.name]) return "";
|
|
188
184
|
let fieldTypeStr = f.type;
|
|
189
|
-
if (f.isChange)
|
|
190
|
-
|
|
191
|
-
if (f.
|
|
192
|
-
fieldTypeStr = `Relation<${fieldTypeStr}>`;
|
|
193
|
-
if (f.isArray)
|
|
194
|
-
fieldTypeStr = `${fieldTypeStr}[]`;
|
|
185
|
+
if (f.isChange) fieldTypeStr = `Change<${fieldTypeStr}>`;
|
|
186
|
+
if (f.isRelation) fieldTypeStr = `Relation<${fieldTypeStr}>`;
|
|
187
|
+
if (f.isArray) fieldTypeStr = `${fieldTypeStr}[]`;
|
|
195
188
|
const fieldStr = ` ${f.name}${f.isRequired ? "" : "?"}: ${fieldTypeStr}`;
|
|
196
189
|
const commentStr2 = f.comment ? ` /** ${f.comment} */` : "";
|
|
197
190
|
return [fieldStr, commentStr2].filter((x) => x).join("\n");
|
|
@@ -226,8 +219,7 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
226
219
|
const { isRelation, isRequired, isArray, isChange } = field;
|
|
227
220
|
if (isArray) {
|
|
228
221
|
const arrayWhereFields = [`${name}_isEmpty?: boolean`];
|
|
229
|
-
if (!isRequired)
|
|
230
|
-
arrayWhereFields.push(`${name}_isNull?: boolean`);
|
|
222
|
+
if (!isRequired) arrayWhereFields.push(`${name}_isNull?: boolean`);
|
|
231
223
|
if (isPrimitive || isEnum) {
|
|
232
224
|
return [`${name}_arrayContains?: ${fieldTypeName}`, ...arrayWhereFields];
|
|
233
225
|
}
|
|
@@ -240,8 +232,7 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
240
232
|
throw new Error(`Unknown array type: ${fieldTypeName}`);
|
|
241
233
|
}
|
|
242
234
|
const commonWhereFields = [];
|
|
243
|
-
if (!isRequired)
|
|
244
|
-
commonWhereFields.push(`${name}_isNull?: boolean`);
|
|
235
|
+
if (!isRequired) commonWhereFields.push(`${name}_isNull?: boolean`);
|
|
245
236
|
if (isRelation) {
|
|
246
237
|
return [`${name}?: ${getRelationWhereType()}`, ...commonWhereFields];
|
|
247
238
|
}
|
|
@@ -298,6 +289,7 @@ function getWhereFieldsForPrimitive(schema, type, fieldKey) {
|
|
|
298
289
|
}
|
|
299
290
|
function getWhereFieldsForString(name) {
|
|
300
291
|
return [
|
|
292
|
+
`${name}_ieq?: string`,
|
|
301
293
|
`${name}_istartsWith?: string`,
|
|
302
294
|
`${name}_startsWith?: string`,
|
|
303
295
|
`${name}_icontains?: string`,
|
|
@@ -311,12 +303,10 @@ function getWhereFieldsForString(name) {
|
|
|
311
303
|
];
|
|
312
304
|
}
|
|
313
305
|
function getStringHashCode(str) {
|
|
314
|
-
if (!str)
|
|
315
|
-
return 0;
|
|
306
|
+
if (!str) return 0;
|
|
316
307
|
let hash = 0;
|
|
317
308
|
let chr;
|
|
318
|
-
if (str.length === 0)
|
|
319
|
-
return hash;
|
|
309
|
+
if (str.length === 0) return hash;
|
|
320
310
|
for (let i = 0; i < str.length; i++) {
|
|
321
311
|
chr = str.charCodeAt(i);
|
|
322
312
|
hash = (hash << 5) - hash + chr;
|
|
@@ -9,7 +9,7 @@ exports.getRestRoutes = getRestRoutes;
|
|
|
9
9
|
var _h = require("h3");
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
11
|
var _restEndpointsDev = _interopRequireDefault(require("./restEndpointsDev.cjs"));
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function getRadsUiUser(radsAuthHeader, apiKey) {
|
|
14
14
|
if (!radsAuthHeader) return void 0;
|
|
15
15
|
apiKey = apiKey || process.env.RadsApiKey;
|
|
@@ -2,8 +2,7 @@ import { createError } from "h3";
|
|
|
2
2
|
import _ from "lodash";
|
|
3
3
|
import restEndpointsDev from "./restEndpointsDev.mjs";
|
|
4
4
|
export function getRadsUiUser(radsAuthHeader, apiKey) {
|
|
5
|
-
if (!radsAuthHeader)
|
|
6
|
-
return void 0;
|
|
5
|
+
if (!radsAuthHeader) return void 0;
|
|
7
6
|
apiKey = apiKey || process.env.RadsApiKey;
|
|
8
7
|
if (!apiKey) {
|
|
9
8
|
throw createError({ statusCode: 401, message: `Please, provide "apiKey" option to "getRadsUiUser" call.` });
|
|
@@ -30,8 +29,7 @@ export function getRestRoutes(options) {
|
|
|
30
29
|
routes[`${prefix}uploadFile`] = { POST: getUploadFileHandler(db) };
|
|
31
30
|
for (const key in schema) {
|
|
32
31
|
const entity = schema[key];
|
|
33
|
-
if (!entity.decorators?.entity)
|
|
34
|
-
continue;
|
|
32
|
+
if (!entity.decorators?.entity) continue;
|
|
35
33
|
routes[`${prefix}${entity.handle}`] = {
|
|
36
34
|
POST: (args, ctx) => db[entity.handle].get(args.body, ctx),
|
|
37
35
|
PUT: (args, ctx) => db[entity.handle].put(args.body?.data, ctx)
|
|
@@ -73,8 +71,7 @@ export function getRadsTunnelHandler(options) {
|
|
|
73
71
|
const handlers = {
|
|
74
72
|
uploadFile: ({ uploadArgs }, ctx) => {
|
|
75
73
|
const blob = getBlobFromDataUrl(uploadArgs?.blobDataUrl);
|
|
76
|
-
if (!blob)
|
|
77
|
-
throw createError({ statusCode: 400, message: 'Malformed request - "blobDataUrl" is required' });
|
|
74
|
+
if (!blob) throw createError({ statusCode: 400, message: 'Malformed request - "blobDataUrl" is required' });
|
|
78
75
|
return db.uploadFile({ blob, ...uploadArgs }, ctx);
|
|
79
76
|
},
|
|
80
77
|
_schema: () => db._schema,
|
|
@@ -84,24 +81,19 @@ export function getRadsTunnelHandler(options) {
|
|
|
84
81
|
};
|
|
85
82
|
return async function radsTunnelHandler(request, ctx) {
|
|
86
83
|
const { method, entity, args } = request?.body || {};
|
|
87
|
-
if (!method)
|
|
88
|
-
throw createError({ statusCode: 400, message: "Malformed request - missing method" });
|
|
84
|
+
if (!method) throw createError({ statusCode: 400, message: "Malformed request - missing method" });
|
|
89
85
|
const handler = handlers[method];
|
|
90
|
-
if (handler)
|
|
91
|
-
return handler(request?.body || {}, ctx);
|
|
86
|
+
if (handler) return handler(request?.body || {}, ctx);
|
|
92
87
|
if (exposeFilesystem && method.startsWith("fs:")) {
|
|
93
88
|
const fsMethod = method.slice(3);
|
|
94
89
|
const devHandler = restEndpointsDev[fsMethod];
|
|
95
|
-
if (devHandler)
|
|
96
|
-
return devHandler(...args);
|
|
90
|
+
if (devHandler) return devHandler(...args);
|
|
97
91
|
}
|
|
98
92
|
if (!method || !entity)
|
|
99
93
|
throw createError({ statusCode: 400, message: 'Malformed request - missing "method" or "entity"' });
|
|
100
94
|
const handle = db[_.lowerFirst(entity)];
|
|
101
|
-
if (!handle)
|
|
102
|
-
|
|
103
|
-
if (!handle[method])
|
|
104
|
-
throw createError({ statusCode: 400, message: `Unknown method - ${method}` });
|
|
95
|
+
if (!handle) throw createError({ statusCode: 400, message: `Malformed request - entity "${entity}" not found` });
|
|
96
|
+
if (!handle[method]) throw createError({ statusCode: 400, message: `Unknown method - ${method}` });
|
|
105
97
|
return await handle[method](args, ctx);
|
|
106
98
|
};
|
|
107
99
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
let eslint;
|
|
8
8
|
let wasEslintImported = false;
|
|
9
9
|
let importEslintPromise;
|
|
10
|
-
|
|
10
|
+
module.exports = {
|
|
11
11
|
async lint(args) {
|
|
12
12
|
const {
|
|
13
13
|
text,
|
|
@@ -33,7 +33,6 @@ var _default = {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
module.exports = _default;
|
|
37
36
|
function importEslint() {
|
|
38
37
|
if (!importEslintPromise) importEslintPromise = importEslintInner();
|
|
39
38
|
return importEslintPromise;
|
|
@@ -4,27 +4,22 @@ let importEslintPromise;
|
|
|
4
4
|
export default {
|
|
5
5
|
async lint(args) {
|
|
6
6
|
const { text, filepath } = args || {};
|
|
7
|
-
if (!text || !filepath)
|
|
8
|
-
return;
|
|
7
|
+
if (!text || !filepath) return;
|
|
9
8
|
await importEslint();
|
|
10
|
-
if (!eslint)
|
|
11
|
-
return;
|
|
9
|
+
if (!eslint) return;
|
|
12
10
|
const result = await eslint.lintText(text, { filePath: filepath });
|
|
13
11
|
const fileResult = result?.[0];
|
|
14
|
-
if (!fileResult)
|
|
15
|
-
return { text };
|
|
12
|
+
if (!fileResult) return { text };
|
|
16
13
|
const { messages, output } = fileResult;
|
|
17
14
|
return { messages, text: output || text };
|
|
18
15
|
}
|
|
19
16
|
};
|
|
20
17
|
function importEslint() {
|
|
21
|
-
if (!importEslintPromise)
|
|
22
|
-
importEslintPromise = importEslintInner();
|
|
18
|
+
if (!importEslintPromise) importEslintPromise = importEslintInner();
|
|
23
19
|
return importEslintPromise;
|
|
24
20
|
}
|
|
25
21
|
async function importEslintInner() {
|
|
26
|
-
if (wasEslintImported)
|
|
27
|
-
return;
|
|
22
|
+
if (wasEslintImported) return;
|
|
28
23
|
try {
|
|
29
24
|
try {
|
|
30
25
|
const eslintModule = await import("eslint/use-at-your-own-risk");
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
var _promises = _interopRequireDefault(require("node:fs/promises"));
|
|
8
8
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
9
|
var _klaw = _interopRequireDefault(require("klaw"));
|
|
10
10
|
var _ignore = _interopRequireDefault(require("ignore"));
|
|
11
11
|
var _restEndpointsDevLint = _interopRequireDefault(require("./restEndpointsDev/restEndpointsDevLint.cjs"));
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
let gitignore;
|
|
14
14
|
const root = _nodePath.default.resolve(".");
|
|
15
|
-
|
|
15
|
+
module.exports = {
|
|
16
16
|
lint: _restEndpointsDevLint.default.lint,
|
|
17
17
|
async mkdir(filepath, options) {
|
|
18
18
|
sanitizeFilepath(filepath);
|
|
@@ -84,7 +84,6 @@ var _default = {
|
|
|
84
84
|
return await _promises.default.rename(oldFilepath, newFilepath);
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
module.exports = _default;
|
|
88
87
|
async function dirExists(path2) {
|
|
89
88
|
try {
|
|
90
89
|
await _promises.default.access(path2);
|
|
@@ -24,8 +24,7 @@ export default {
|
|
|
24
24
|
try {
|
|
25
25
|
return await readdirRecursive(filepath, options);
|
|
26
26
|
} catch (e) {
|
|
27
|
-
if (e.code === "ENOENT")
|
|
28
|
-
return [];
|
|
27
|
+
if (e.code === "ENOENT") return [];
|
|
29
28
|
throw e;
|
|
30
29
|
}
|
|
31
30
|
},
|
|
@@ -34,8 +33,7 @@ export default {
|
|
|
34
33
|
let result;
|
|
35
34
|
if (options?.lint) {
|
|
36
35
|
result = await restEndpointsDevLint.lint({ filepath: options.lintFilepath || filepath, text: data });
|
|
37
|
-
if (result?.text)
|
|
38
|
-
data = result.text;
|
|
36
|
+
if (result?.text) data = result.text;
|
|
39
37
|
}
|
|
40
38
|
const dirname = path.dirname(filepath);
|
|
41
39
|
const isExistingDir = await dirExists(dirname);
|
|
@@ -50,8 +48,7 @@ export default {
|
|
|
50
48
|
try {
|
|
51
49
|
return await fs.readFile(filepath, options);
|
|
52
50
|
} catch (e) {
|
|
53
|
-
if (e.code === "ENOENT")
|
|
54
|
-
return null;
|
|
51
|
+
if (e.code === "ENOENT") return null;
|
|
55
52
|
throw e;
|
|
56
53
|
}
|
|
57
54
|
},
|
|
@@ -60,8 +57,7 @@ export default {
|
|
|
60
57
|
try {
|
|
61
58
|
return await fs.lstat(filepath, options);
|
|
62
59
|
} catch (e) {
|
|
63
|
-
if (e.code === "ENOENT")
|
|
64
|
-
return void 0;
|
|
60
|
+
if (e.code === "ENOENT") return void 0;
|
|
65
61
|
throw e;
|
|
66
62
|
}
|
|
67
63
|
},
|
|
@@ -86,8 +82,7 @@ async function dirExists(path2) {
|
|
|
86
82
|
}
|
|
87
83
|
function sanitizeFilepath(filepath) {
|
|
88
84
|
const result = path.resolve(filepath);
|
|
89
|
-
if (!result.startsWith(root))
|
|
90
|
-
throw new Error("Invalid path");
|
|
85
|
+
if (!result.startsWith(root)) throw new Error("Invalid path");
|
|
91
86
|
}
|
|
92
87
|
async function readdirRecursive(dir, options) {
|
|
93
88
|
await initGitignore();
|
|
@@ -102,11 +97,9 @@ async function readdirRecursive(dir, options) {
|
|
|
102
97
|
});
|
|
103
98
|
const results = [];
|
|
104
99
|
for await (const file of klawIterator) {
|
|
105
|
-
if (file.stats.isSymbolicLink())
|
|
106
|
-
continue;
|
|
100
|
+
if (file.stats.isSymbolicLink()) continue;
|
|
107
101
|
const rp = path.relative(dir, file.path).replaceAll("\\", "/");
|
|
108
|
-
if (!rp)
|
|
109
|
-
continue;
|
|
102
|
+
if (!rp) continue;
|
|
110
103
|
results.push({
|
|
111
104
|
path: `./${rp}`,
|
|
112
105
|
type: file.stats.isDirectory() ? "tree" : "blob",
|
|
@@ -116,10 +109,8 @@ async function readdirRecursive(dir, options) {
|
|
|
116
109
|
return results;
|
|
117
110
|
}
|
|
118
111
|
async function initGitignore() {
|
|
119
|
-
if (gitignore)
|
|
120
|
-
return;
|
|
112
|
+
if (gitignore) return;
|
|
121
113
|
const gitignoreStr = await fs.readFile("./.gitignore", "utf-8");
|
|
122
114
|
gitignore = ignore().add(["node_modules", ".git"]);
|
|
123
|
-
if (gitignoreStr)
|
|
124
|
-
gitignore = gitignore.add(gitignoreStr.split("\n").filter((x) => x));
|
|
115
|
+
if (gitignoreStr) gitignore = gitignore.add(gitignoreStr.split("\n").filter((x) => x));
|
|
125
116
|
}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
var _promises = _interopRequireDefault(require("node:fs/promises"));
|
|
8
8
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
9
|
var _klaw = _interopRequireDefault(require("klaw"));
|
|
10
10
|
var _ignore = _interopRequireDefault(require("ignore"));
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
let gitignore;
|
|
13
|
-
|
|
13
|
+
module.exports = {
|
|
14
14
|
async fsGetFileTree() {
|
|
15
15
|
const results = [];
|
|
16
16
|
await ensureGitignoreCreated();
|
|
@@ -47,7 +47,6 @@ var _default = {
|
|
|
47
47
|
return {};
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
module.exports = _default;
|
|
51
50
|
async function ensureGitignoreCreated() {
|
|
52
51
|
if (gitignore) return;
|
|
53
52
|
const gitignoreStr = await _promises.default.readFile("./.gitignore", "utf-8");
|
|
@@ -12,14 +12,12 @@ export default {
|
|
|
12
12
|
preserveSymlinks: true,
|
|
13
13
|
filter: (p) => {
|
|
14
14
|
const rp = path.relative(".", p);
|
|
15
|
-
if (rp.startsWith(".git"))
|
|
16
|
-
return false;
|
|
15
|
+
if (rp.startsWith(".git")) return false;
|
|
17
16
|
return !gitignore.ignores(rp);
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
for await (const file of klawIterator) {
|
|
21
|
-
if (file.stats.isSymbolicLink())
|
|
22
|
-
continue;
|
|
20
|
+
if (file.stats.isSymbolicLink()) continue;
|
|
23
21
|
const rp = path.relative(".", file.path);
|
|
24
22
|
results.push({
|
|
25
23
|
sha: rp,
|
|
@@ -41,8 +39,7 @@ export default {
|
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
async function ensureGitignoreCreated() {
|
|
44
|
-
if (gitignore)
|
|
45
|
-
return;
|
|
42
|
+
if (gitignore) return;
|
|
46
43
|
const gitignoreStr = await fs.readFile("./.gitignore", "utf-8");
|
|
47
44
|
gitignore = ignore().add(gitignoreStr.split("\n").filter((x) => x));
|
|
48
45
|
}
|
package/integrations/vite.mjs
CHANGED
|
@@ -24,13 +24,11 @@ export function radsDbVite(options) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
];
|
|
27
|
-
if (options?.exposeModulesInDev)
|
|
28
|
-
result.push(exposeModulesPlugin(options.exposeModulesInDev));
|
|
27
|
+
if (options?.exposeModulesInDev) result.push(exposeModulesPlugin(options.exposeModulesInDev));
|
|
29
28
|
return result;
|
|
30
29
|
}
|
|
31
30
|
function exposeModulesPlugin(regex) {
|
|
32
|
-
if (regex === true)
|
|
33
|
-
regex = /\/src\/((services|stores)\/(.+))\.[tj]s$/i;
|
|
31
|
+
if (regex === true) regex = /\/src\/((services|stores)\/(.+))\.[tj]s$/i;
|
|
34
32
|
const regexInner = regex;
|
|
35
33
|
return {
|
|
36
34
|
name: "expose-modules-in-dev",
|
|
@@ -39,8 +37,7 @@ function exposeModulesPlugin(regex) {
|
|
|
39
37
|
const match = regexInner.exec(id);
|
|
40
38
|
if (match) {
|
|
41
39
|
let modifiedSrc = src.replace("export default ", "const _exportDefault = ");
|
|
42
|
-
if (modifiedSrc.length === src.length)
|
|
43
|
-
return;
|
|
40
|
+
if (modifiedSrc.length === src.length) return;
|
|
44
41
|
const propName = match[1];
|
|
45
42
|
const props = propName.split("/");
|
|
46
43
|
const propsPathStr = props.slice(0, -1).map((p) => `'${p}'`).join(",");
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rads-db",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"packageManager": "pnpm@8.6.1",
|
|
3
|
+
"version": "3.1.11",
|
|
5
4
|
"description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
|
|
6
5
|
"author": "",
|
|
7
6
|
"license": "ISC",
|
|
@@ -113,6 +112,7 @@
|
|
|
113
112
|
"generate-test-schema": "jiti ./src/integrations/cli",
|
|
114
113
|
"dev": "pnpm install && pnpm link-rads-db && pnpm build && pnpm generate-test-schema && vitest --ui --test-timeout 300000 --typecheck",
|
|
115
114
|
"lint": "cross-env NODE_ENV=production eslint src/**/*.* test/**/*.*",
|
|
115
|
+
"typecheck": "tsc --noEmit",
|
|
116
116
|
"build": "unbuild"
|
|
117
117
|
}
|
|
118
118
|
}
|