@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
@@ -0,0 +1,3 @@
1
+ import { runner_default } from "./seeders-CltigymO.js";
2
+
3
+ export { runner_default as SeederRunner };
@@ -0,0 +1,131 @@
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 __export = (all) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ return target;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
+ key = keys[i];
19
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
20
+ get: ((k) => from[k]).bind(null, key),
21
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
+ });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: true
29
+ }) : target, mod));
30
+
31
+ //#endregion
32
+ let path = require("path");
33
+ path = __toESM(path);
34
+ let node_fs_promises = require("node:fs/promises");
35
+ node_fs_promises = __toESM(node_fs_promises);
36
+ let node_path = require("node:path");
37
+ node_path = __toESM(node_path);
38
+ let node_url = require("node:url");
39
+ node_url = __toESM(node_url);
40
+
41
+ //#region src/seeders/runner.ts
42
+ async function glob(folderPath) {
43
+ const { default: escalade } = await import("escalade");
44
+ const entries = [];
45
+ await escalade(folderPath, async (dir, names) => {
46
+ await Promise.all(names.map(async (name) => {
47
+ const p = path.default.join(dir, name);
48
+ try {
49
+ await (0, node_fs_promises.access)(p);
50
+ if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
51
+ } catch {}
52
+ }));
53
+ return "";
54
+ });
55
+ return entries;
56
+ }
57
+ var SeederRunner = class {
58
+ resolver;
59
+ connection;
60
+ paths = [];
61
+ constructor(resolver) {
62
+ this.resolver = resolver;
63
+ }
64
+ path(p) {
65
+ this.paths = Array.from(new Set([...this.paths, p]));
66
+ }
67
+ getPaths() {
68
+ return this.paths;
69
+ }
70
+ resolveConnection(connection) {
71
+ var _getInstance, _ref, _instance$connections;
72
+ const name = connection || this.connection || "default";
73
+ const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
74
+ if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
75
+ /** noop */
76
+ });
77
+ return this.resolver.fire(name);
78
+ }
79
+ setConnection(connection) {
80
+ this.connection = connection;
81
+ return this;
82
+ }
83
+ async getSeederFiles(paths) {
84
+ const files = [];
85
+ for (const p of paths) {
86
+ if (p.endsWith(".js") || p.endsWith(".ts")) {
87
+ files.push(p);
88
+ continue;
89
+ }
90
+ files.push(...await glob(p));
91
+ }
92
+ return files;
93
+ }
94
+ async resolvePath(filePath) {
95
+ try {
96
+ const mod = await import(filePath);
97
+ return new (mod.default ?? mod.Seeder)();
98
+ } catch {
99
+ return null;
100
+ }
101
+ }
102
+ async run(paths, connection) {
103
+ const files = await this.getSeederFiles(paths);
104
+ const conn = this.resolveConnection(connection);
105
+ for (const file of files) {
106
+ const seeder = await this.resolvePath(file);
107
+ if (seeder && typeof seeder.run === "function") await seeder.run(conn);
108
+ }
109
+ }
110
+ };
111
+ var runner_default = SeederRunner;
112
+
113
+ //#endregion
114
+ Object.defineProperty(exports, '__export', {
115
+ enumerable: true,
116
+ get: function () {
117
+ return __export;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, '__toESM', {
121
+ enumerable: true,
122
+ get: function () {
123
+ return __toESM;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, 'runner_default', {
127
+ enumerable: true,
128
+ get: function () {
129
+ return runner_default;
130
+ }
131
+ });
@@ -0,0 +1,79 @@
1
+ import path from "path";
2
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ //#region src/seeders/runner.ts
7
+ async function glob(folderPath) {
8
+ const { default: escalade } = await import("escalade");
9
+ const entries = [];
10
+ await escalade(folderPath, async (dir, names) => {
11
+ await Promise.all(names.map(async (name) => {
12
+ const p = path.join(dir, name);
13
+ try {
14
+ await access(p);
15
+ if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
16
+ } catch {}
17
+ }));
18
+ return "";
19
+ });
20
+ return entries;
21
+ }
22
+ var SeederRunner = class {
23
+ resolver;
24
+ connection;
25
+ paths = [];
26
+ constructor(resolver) {
27
+ this.resolver = resolver;
28
+ }
29
+ path(p) {
30
+ this.paths = Array.from(new Set([...this.paths, p]));
31
+ }
32
+ getPaths() {
33
+ return this.paths;
34
+ }
35
+ resolveConnection(connection) {
36
+ var _getInstance, _ref, _instance$connections;
37
+ const name = connection || this.connection || "default";
38
+ const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
39
+ if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
40
+ /** noop */
41
+ });
42
+ return this.resolver.fire(name);
43
+ }
44
+ setConnection(connection) {
45
+ this.connection = connection;
46
+ return this;
47
+ }
48
+ async getSeederFiles(paths) {
49
+ const files = [];
50
+ for (const p of paths) {
51
+ if (p.endsWith(".js") || p.endsWith(".ts")) {
52
+ files.push(p);
53
+ continue;
54
+ }
55
+ files.push(...await glob(p));
56
+ }
57
+ return files;
58
+ }
59
+ async resolvePath(filePath) {
60
+ try {
61
+ const mod = await import(filePath);
62
+ return new (mod.default ?? mod.Seeder)();
63
+ } catch {
64
+ return null;
65
+ }
66
+ }
67
+ async run(paths, connection) {
68
+ const files = await this.getSeederFiles(paths);
69
+ const conn = this.resolveConnection(connection);
70
+ for (const file of files) {
71
+ const seeder = await this.resolvePath(file);
72
+ if (seeder && typeof seeder.run === "function") await seeder.run(conn);
73
+ }
74
+ }
75
+ };
76
+ var runner_default = SeederRunner;
77
+
78
+ //#endregion
79
+ export { runner_default };
@@ -0,0 +1,3 @@
1
+ const require_seeders = require('./seeders-ByeSoCAQ.cjs');
2
+
3
+ exports.SeederRunner = require_seeders.runner_default;
@@ -94,7 +94,7 @@ var casts_attributes_default = CastsAttributes;
94
94
  var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
95
95
  /**
96
96
  * Compose function that merges multiple classes and mixins
97
- *
97
+ *
98
98
  * @example
99
99
  * const SomePlugin = <TBase extends new (...args: any[]) => TGeneric> (Base: TBase) => {
100
100
  * return class extends Base {
@@ -131,10 +131,10 @@ var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
131
131
  * console.log(user.pluginMethod('w')) // "plugin"
132
132
  * console.log(user.pluginMethod()) // "plugin"
133
133
  * console.log(user.relationPosts()) // "hasMany Posts"
134
- *
135
- * @param Base
136
- * @param mixins
137
- * @returns
134
+ *
135
+ * @param Base
136
+ * @param mixins
137
+ * @returns
138
138
  */
139
139
  function compose$1(Base, ...mixins) {
140
140
  /**
@@ -195,10 +195,10 @@ const getAttrName = (attrMethod) => {
195
195
  };
196
196
  /**
197
197
  * Tap into a model a collection instance
198
- *
199
- * @param instance
200
- * @param callback
201
- * @returns
198
+ *
199
+ * @param instance
200
+ * @param callback
201
+ * @returns
202
202
  */
203
203
  const tap = (instance, callback) => {
204
204
  const result = callback(instance);