@h3ravel/arquebus 0.4.1 → 0.6.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.
Files changed (45) hide show
  1. package/README.md +20 -1
  2. package/bin/index.cjs +225 -171
  3. package/bin/index.js +208 -122
  4. package/bin/seeders-8GJzfIIN.js +3 -0
  5. package/bin/seeders-ByeSoCAQ.cjs +131 -0
  6. package/bin/seeders-CltigymO.js +79 -0
  7. package/bin/seeders-_xJ6VGVS.cjs +3 -0
  8. package/dist/browser/index.cjs +9 -9
  9. package/dist/browser/index.d.cts +3655 -183
  10. package/dist/browser/index.d.ts +3655 -183
  11. package/dist/browser/index.js +9 -9
  12. package/dist/index.cjs +270 -135
  13. package/dist/index.d.cts +3797 -294
  14. package/dist/index.d.ts +3797 -294
  15. package/dist/index.js +263 -133
  16. package/dist/inspector/index.cjs +122 -46
  17. package/dist/inspector/index.js +119 -46
  18. package/dist/migrations/index.cjs +171 -151
  19. package/dist/migrations/index.d.cts +3510 -27
  20. package/dist/migrations/index.d.ts +3510 -27
  21. package/dist/migrations/index.js +177 -150
  22. package/dist/migrations/stubs/migration-js.stub +1 -1
  23. package/dist/migrations/stubs/migration-ts.stub +1 -1
  24. package/dist/migrations/stubs/migration.create-js.stub +5 -5
  25. package/dist/migrations/stubs/migration.create-ts.stub +5 -5
  26. package/dist/migrations/stubs/migration.update-js.stub +2 -2
  27. package/dist/migrations/stubs/migration.update-ts.stub +3 -3
  28. package/dist/seeders/index.cjs +141 -0
  29. package/dist/seeders/index.d.cts +4766 -0
  30. package/dist/seeders/index.d.ts +4766 -0
  31. package/dist/seeders/index.js +118 -0
  32. package/dist/seeders/index.ts +3 -0
  33. package/dist/seeders/runner.ts +102 -0
  34. package/dist/seeders/seeder-creator.ts +42 -0
  35. package/dist/seeders/seeder.ts +10 -0
  36. package/dist/stubs/seeder-js.stub +13 -0
  37. package/dist/stubs/seeder-ts.stub +9 -0
  38. package/package.json +15 -4
  39. package/types/builder.ts +158 -80
  40. package/types/container.ts +79 -66
  41. package/types/generics.ts +75 -36
  42. package/types/modeling.ts +213 -158
  43. package/types/query-builder.ts +223 -186
  44. package/types/query-methods.ts +160 -104
  45. package/types/utils.ts +64 -55
@@ -8,7 +8,7 @@ export default class extends Migration {
8
8
  async up(schema: SchemaBuilder) {
9
9
  await schema.table('{{ table }}', (table) => {
10
10
  //
11
- });
11
+ })
12
12
  }
13
13
 
14
14
  /**
@@ -17,6 +17,6 @@ export default class extends Migration {
17
17
  async down(schema: SchemaBuilder) {
18
18
  await schema.table('{{ table }}', (table) => {
19
19
  //
20
- });
20
+ })
21
21
  }
22
- };
22
+ }
@@ -0,0 +1,141 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ let path = require("path");
25
+ path = __toESM(path);
26
+ let node_fs_promises = require("node:fs/promises");
27
+ node_fs_promises = __toESM(node_fs_promises);
28
+ let node_path = require("node:path");
29
+ node_path = __toESM(node_path);
30
+ let node_url = require("node:url");
31
+ node_url = __toESM(node_url);
32
+
33
+ //#region src/seeders/seeder.ts
34
+ var Seeder = class {};
35
+ var seeder_default = Seeder;
36
+
37
+ //#endregion
38
+ //#region src/seeders/runner.ts
39
+ async function glob(folderPath) {
40
+ const { default: escalade } = await import("escalade");
41
+ const entries = [];
42
+ await escalade(folderPath, async (dir, names) => {
43
+ await Promise.all(names.map(async (name) => {
44
+ const p = path.default.join(dir, name);
45
+ try {
46
+ await (0, node_fs_promises.access)(p);
47
+ if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
48
+ } catch {}
49
+ }));
50
+ return "";
51
+ });
52
+ return entries;
53
+ }
54
+ var SeederRunner = class {
55
+ resolver;
56
+ connection;
57
+ paths = [];
58
+ constructor(resolver) {
59
+ this.resolver = resolver;
60
+ }
61
+ path(p) {
62
+ this.paths = Array.from(new Set([...this.paths, p]));
63
+ }
64
+ getPaths() {
65
+ return this.paths;
66
+ }
67
+ resolveConnection(connection) {
68
+ var _getInstance, _ref, _instance$connections;
69
+ const name = connection || this.connection || "default";
70
+ const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
71
+ if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
72
+ /** noop */
73
+ });
74
+ return this.resolver.fire(name);
75
+ }
76
+ setConnection(connection) {
77
+ this.connection = connection;
78
+ return this;
79
+ }
80
+ async getSeederFiles(paths) {
81
+ const files = [];
82
+ for (const p of paths) {
83
+ if (p.endsWith(".js") || p.endsWith(".ts")) {
84
+ files.push(p);
85
+ continue;
86
+ }
87
+ files.push(...await glob(p));
88
+ }
89
+ return files;
90
+ }
91
+ async resolvePath(filePath) {
92
+ try {
93
+ const mod = await import(filePath);
94
+ return new (mod.default ?? mod.Seeder)();
95
+ } catch {
96
+ return null;
97
+ }
98
+ }
99
+ async run(paths, connection) {
100
+ const files = await this.getSeederFiles(paths);
101
+ const conn = this.resolveConnection(connection);
102
+ for (const file of files) {
103
+ const seeder = await this.resolvePath(file);
104
+ if (seeder && typeof seeder.run === "function") await seeder.run(conn);
105
+ }
106
+ }
107
+ };
108
+ var runner_default = SeederRunner;
109
+
110
+ //#endregion
111
+ //#region src/seeders/seeder-creator.ts
112
+ var SeederCreator = class {
113
+ constructor(customStubPath) {
114
+ this.customStubPath = customStubPath;
115
+ }
116
+ async create(dir, name, type = "js") {
117
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
118
+ const stubPath = this.getStubPath(type);
119
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
120
+ stub = stub.replace(/{{ name }}/g, name);
121
+ const filePath = path.default.join(dir, `${name}.${type}`);
122
+ await (0, node_fs_promises.writeFile)(filePath, stub);
123
+ return filePath;
124
+ }
125
+ getStubPath(type) {
126
+ if (this.customStubPath) return path.default.join(this.customStubPath, `seeder-${type}.stub`);
127
+ const __dirname$1 = this.getDirname({});
128
+ return path.default.join(__dirname$1, "stubs", `seeder-${type}.stub`);
129
+ }
130
+ getDirname(meta) {
131
+ if (typeof __dirname !== "undefined") return __dirname;
132
+ if (meta && meta.url) return (0, node_path.dirname)((0, node_url.fileURLToPath)(meta.url));
133
+ throw new Error("Unable to determine dirname");
134
+ }
135
+ };
136
+ var seeder_creator_default = SeederCreator;
137
+
138
+ //#endregion
139
+ exports.Seeder = seeder_default;
140
+ exports.SeederCreator = seeder_creator_default;
141
+ exports.SeederRunner = runner_default;