@stacksjs/database 0.51.0 → 0.52.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
@@ -38,7 +38,7 @@ pnpm test
38
38
 
39
39
  Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
40
40
 
41
- ## 💪🏼 Contributing
41
+ ## 🚜 Contributing
42
42
 
43
43
  Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
44
44
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export * from './factory';
2
- export * from './migrations';
3
- export * from './seeder';
1
+ declare function generateFactoryFile(modelName: string, fileName: string, path: string): void;
2
+
3
+ declare function seed(): Promise<void>;
4
+
5
+ export { generateFactoryFile, seed };
package/dist/index.mjs CHANGED
@@ -1,3 +1,23 @@
1
- export * from "./factory/index.mjs";
2
- export * from "./migrations/index.mjs";
3
- export * from "./seeder/index.mjs";
1
+ import { filesystem } from '@stacksjs/storage';
2
+
3
+ const { fs } = filesystem;
4
+ function generateFactoryFile(modelName, fileName, path) {
5
+ const generateMethodName = "generate";
6
+ const factoryCode = `import faker from 'faker';
7
+ import type { SeedData } from '@stacksjs/types'
8
+
9
+ function ${generateMethodName}(): SeedData {
10
+ return {
11
+ // fields here
12
+ }
13
+ }
14
+
15
+ export { ${generateMethodName} };
16
+ `;
17
+ fs.writeFileSync(`${path}/${fileName}`, factoryCode);
18
+ }
19
+
20
+ async function seed() {
21
+ }
22
+
23
+ export { generateFactoryFile, seed };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@stacksjs/database",
3
3
  "type": "module",
4
- "version": "0.51.0",
5
- "packageManager": "pnpm@7.26.3",
4
+ "version": "0.52.0",
5
+ "packageManager": "pnpm@8.5.1",
6
6
  "description": "The Stacks database integration.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -24,10 +24,14 @@
24
24
  "planetScale",
25
25
  "supabase",
26
26
  "singleStore",
27
- "prisma",
28
27
  "stacks"
29
28
  ],
30
- "main": "dist/index.mjs",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.mjs"
33
+ }
34
+ },
31
35
  "module": "dist/index.mjs",
32
36
  "types": "dist/index.d.ts",
33
37
  "contributors": [
@@ -37,22 +41,23 @@
37
41
  "dist",
38
42
  "README.md"
39
43
  ],
40
- "engines": {
41
- "node": ">=v18.14.0",
42
- "pnpm": ">=7.26.3"
43
- },
44
44
  "peerDependencies": {
45
- "@prisma/client": "^4.9.0",
46
- "@stacksjs/utils": "0.51.0"
45
+ "@stacksjs/faker": "0.52.0",
46
+ "@stacksjs/path": "0.52.0",
47
+ "@stacksjs/query-builder": "0.52.0",
48
+ "@stacksjs/storage": "0.52.0",
49
+ "@stacksjs/strings": "0.52.0",
50
+ "@stacksjs/utils": "0.52.0"
51
+ },
52
+ "dependencies": {
53
+ "@stacksjs/config": "0.52.0"
47
54
  },
48
55
  "devDependencies": {
49
- "mkdist": "^1.1.0",
50
- "typescript": "^4.9.5",
51
- "@stacksjs/testing": "0.51.0"
56
+ "@stacksjs/development": "0.52.0"
52
57
  },
53
58
  "scripts": {
54
- "build": "mkdist -d",
55
- "dev": "mkdist -d",
59
+ "build": "unbuild",
60
+ "dev": "unbuild --stub",
56
61
  "typecheck": "tsc --noEmit"
57
62
  }
58
63
  }
@@ -1,14 +0,0 @@
1
- import type { Result } from '@stacksjs/types';
2
- declare class Factory {
3
- private factory;
4
- private noOfItems;
5
- private items;
6
- private columns;
7
- constructor(factory: string);
8
- define(params: any): this;
9
- count(count?: number): this;
10
- make(count?: number): Promise<Result<Object, Error>>;
11
- create(count?: number): Promise<Result<Object, Error>>;
12
- initiateColumns(): void;
13
- }
14
- export { Factory as factory, Factory };
@@ -1,53 +0,0 @@
1
- import { collect } from "@stacksjs/collections";
2
- import { loop } from "@stacksjs/utils";
3
- import { PrismaClient } from "@prisma/client";
4
- import { ResultAsync } from "@stacksjs/error-handling";
5
- const prisma = new PrismaClient();
6
- class Factory {
7
- constructor(factory) {
8
- this.noOfItems = 5;
9
- this.items = [];
10
- this.columns = [];
11
- this.factory = factory;
12
- }
13
- define(params) {
14
- this.columns = params;
15
- return this;
16
- }
17
- count(count = 5) {
18
- this.noOfItems = count;
19
- return this;
20
- }
21
- async make(count = 0) {
22
- if (count)
23
- this.noOfItems = count;
24
- this.initiateColumns();
25
- return ResultAsync.fromPromise(
26
- await prisma[this.factory].createMany(
27
- this.items,
28
- true
29
- ),
30
- () => new Error("Failed to create the data")
31
- );
32
- }
33
- async create(count = 0) {
34
- if (count)
35
- this.noOfItems = count;
36
- this.initiateColumns();
37
- return ResultAsync.fromPromise(
38
- await prisma[this.factory].createMany(
39
- this.items,
40
- false
41
- ),
42
- () => new Error("Failed to create the data")
43
- );
44
- }
45
- initiateColumns() {
46
- const items = collect();
47
- loop(this.noOfItems, () => {
48
- items.push(this.columns);
49
- });
50
- this.items = items;
51
- }
52
- }
53
- export { Factory as factory, Factory };
@@ -1,2 +0,0 @@
1
- declare function migrations(): void;
2
- export { migrations };
@@ -1,3 +0,0 @@
1
- function migrations() {
2
- }
3
- export { migrations };
@@ -1,2 +0,0 @@
1
- declare function seeder(factoryName: any, count?: number): Promise<Result<Object, Error>>;
2
- export { seeder };
@@ -1,5 +0,0 @@
1
- import { Factory } from "../factory/index.mjs";
2
- function seeder(factoryName, count = 5) {
3
- return new Factory(factoryName).make(count);
4
- }
5
- export { seeder };