rads-db 3.0.68 → 3.0.70

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/dist/index.d.ts CHANGED
@@ -59,7 +59,7 @@ interface GetManyResponse<EN extends keyof EntityMeta, A extends GetArgs<EN>> {
59
59
  type GetResponse<EN extends keyof EntityMeta, A extends GetArgs<EN>> = A extends {
60
60
  include: any;
61
61
  } ? GetResponseInclude<EN, A['include']> : GetResponseNoInclude<EN>;
62
- type Get<EntityName extends keyof EntityMeta, Include extends keyof EntityMeta[EntityName]['relations'] | GetArgsInclude<EntityName> = {}> = Include extends GetArgsInclude<EntityName> ? GetResponse<EntityName, {
62
+ type Get<EntityName extends keyof EntityMeta, Include extends keyof EntityMeta[EntityName]['relations'] | GetArgsInclude<EntityName> = {}> = [Include] extends [Record<string, any>] ? GetResponse<EntityName, {
63
63
  include: Include;
64
64
  }> : GetResponse<EntityName, {
65
65
  include: {
@@ -36,8 +36,10 @@ export const schema = ${JSON.stringify(schema)}
36
36
  await _promises.default.writeFile(_nodePath.default.join(radsDbPath, "./index.js"), indexJsText);
37
37
  await _promises.default.writeFile(_nodePath.default.join(radsDbPath, "./index.mjs"), indexMjsText);
38
38
  await _promises.default.writeFile(_nodePath.default.join(radsDbPath, "./index.d.ts"), indexDtsText);
39
+ const schemaHash = getStringHashCode(indexMjsText);
39
40
  await _promises.default.writeFile(_nodePath.default.join(radsDbPath, "./package.json"), JSON.stringify({
40
41
  name: "_rads-db",
42
+ version: `0.1.${schemaHash}`,
41
43
  main: "./index.js",
42
44
  module: "./index.mjs",
43
45
  types: "./index.d.ts"
@@ -266,4 +268,16 @@ function getWhereFieldsForPrimitive(schema, type, fieldKey) {
266
268
  }
267
269
  function getWhereFieldsForString(name) {
268
270
  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`];
271
+ }
272
+ function getStringHashCode(str) {
273
+ if (!str) return 0;
274
+ let hash = 0;
275
+ let chr;
276
+ if (str.length === 0) return hash;
277
+ for (let i = 0; i < str.length; i++) {
278
+ chr = str.charCodeAt(i);
279
+ hash = (hash << 5) - hash + chr;
280
+ hash |= 0;
281
+ }
282
+ return hash;
269
283
  }
@@ -28,11 +28,13 @@ export const schema = ${JSON.stringify(schema)}
28
28
  await fs.writeFile(path.join(radsDbPath, "./index.js"), indexJsText);
29
29
  await fs.writeFile(path.join(radsDbPath, "./index.mjs"), indexMjsText);
30
30
  await fs.writeFile(path.join(radsDbPath, "./index.d.ts"), indexDtsText);
31
+ const schemaHash = getStringHashCode(indexMjsText);
31
32
  await fs.writeFile(
32
33
  path.join(radsDbPath, "./package.json"),
33
34
  JSON.stringify(
34
35
  {
35
36
  name: "_rads-db",
37
+ version: `0.1.${schemaHash}`,
36
38
  main: "./index.js",
37
39
  module: "./index.mjs",
38
40
  types: "./index.d.ts"
@@ -294,3 +296,17 @@ function getWhereFieldsForString(name) {
294
296
  `${name}_lte?: string`
295
297
  ];
296
298
  }
299
+ function getStringHashCode(str) {
300
+ if (!str)
301
+ return 0;
302
+ let hash = 0;
303
+ let chr;
304
+ if (str.length === 0)
305
+ return hash;
306
+ for (let i = 0; i < str.length; i++) {
307
+ chr = str.charCodeAt(i);
308
+ hash = (hash << 5) - hash + chr;
309
+ hash |= 0;
310
+ }
311
+ return hash;
312
+ }
@@ -15,9 +15,13 @@ function radsDbVite(options) {
15
15
  configureServer(server) {
16
16
  server.middlewares.use((req, res, next) => {
17
17
  if (req.url?.includes("/_rads-db/")) {
18
- req.url += Date.now();
18
+ const index = req.url.indexOf("?v=");
19
+ req.url = req.url.slice(0, index);
20
+ req.url += `?t=${Date.now()}`;
19
21
  res.setHeader("Expires", "0");
20
22
  res.setHeader("Pragma", "no-cache");
23
+ res.setHeader("cache-control", "no-cache, no-store");
24
+ res.setHeader("etag", Date.now());
21
25
  }
22
26
  next();
23
27
  });
@@ -11,9 +11,13 @@ export function radsDbVite(options) {
11
11
  configureServer(server) {
12
12
  server.middlewares.use((req, res, next) => {
13
13
  if (req.url?.includes("/_rads-db/")) {
14
- req.url += Date.now();
14
+ const index = req.url.indexOf("?v=");
15
+ req.url = req.url.slice(0, index);
16
+ req.url += `?t=${Date.now()}`;
15
17
  res.setHeader("Expires", "0");
16
18
  res.setHeader("Pragma", "no-cache");
19
+ res.setHeader("cache-control", "no-cache, no-store");
20
+ res.setHeader("etag", Date.now());
17
21
  }
18
22
  next();
19
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.0.68",
3
+ "version": "3.0.70",
4
4
  "packageManager": "pnpm@8.6.1",
5
5
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
6
6
  "author": "",