@h3ravel/arquebus 0.6.7 → 0.6.8

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 (44) hide show
  1. package/bin/index.cjs +5772 -0
  2. package/bin/index.d.cts +1 -0
  3. package/bin/index.d.mts +1 -0
  4. package/bin/index.mjs +5746 -0
  5. package/bin/seeders-C0schOjT.mjs +3 -0
  6. package/bin/seeders-D-v59HCz.cjs +3 -0
  7. package/dist/browser/index.cjs +1263 -0
  8. package/dist/browser/index.d.cts +4932 -0
  9. package/dist/browser/index.d.mts +4932 -0
  10. package/dist/browser/index.mjs +1211 -0
  11. package/dist/index.cjs +5675 -0
  12. package/dist/index.d.cts +5129 -0
  13. package/dist/index.d.mts +5129 -0
  14. package/dist/index.mjs +5611 -0
  15. package/dist/inspector/index.cjs +4877 -0
  16. package/dist/inspector/index.d.cts +83 -0
  17. package/dist/inspector/index.d.mts +83 -0
  18. package/dist/inspector/index.mjs +4853 -0
  19. package/dist/migrations/chunk-BD38OWEx.mjs +15 -0
  20. package/dist/migrations/index.cjs +5433 -0
  21. package/dist/migrations/index.d.cts +4965 -0
  22. package/dist/migrations/index.d.mts +4962 -0
  23. package/dist/migrations/index.mjs +5387 -0
  24. package/dist/migrations/stubs/migration-js.stub +21 -0
  25. package/dist/migrations/stubs/migration-ts.stub +18 -0
  26. package/dist/migrations/stubs/migration.create-js.stub +24 -0
  27. package/dist/migrations/stubs/migration.create-ts.stub +21 -0
  28. package/dist/migrations/stubs/migration.update-js.stub +25 -0
  29. package/dist/migrations/stubs/migration.update-ts.stub +22 -0
  30. package/dist/seeders/index.cjs +137 -0
  31. package/dist/seeders/index.d.cts +4766 -0
  32. package/dist/seeders/index.d.mts +4766 -0
  33. package/dist/seeders/index.mjs +117 -0
  34. package/dist/seeders/index.ts +3 -0
  35. package/dist/seeders/runner.ts +101 -0
  36. package/dist/seeders/seeder-creator.ts +42 -0
  37. package/dist/seeders/seeder.ts +10 -0
  38. package/dist/stubs/arquebus.config-js.stub +25 -0
  39. package/dist/stubs/arquebus.config-ts.stub +24 -0
  40. package/dist/stubs/model-js.stub +5 -0
  41. package/dist/stubs/model-ts.stub +5 -0
  42. package/dist/stubs/seeder-js.stub +13 -0
  43. package/dist/stubs/seeder-ts.stub +14 -0
  44. package/package.json +2 -2
@@ -0,0 +1,21 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+
3
+ export default class extends Migration {
4
+ /**
5
+ * Run the migrations.
6
+ *
7
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
8
+ */
9
+ async up(schema) {
10
+ //
11
+ }
12
+
13
+ /**
14
+ * Reverse the migrations.
15
+ *
16
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
17
+ */
18
+ async down(schema) {
19
+ //
20
+ }
21
+ }
@@ -0,0 +1,18 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+ import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
3
+
4
+ export default class extends Migration {
5
+ /**
6
+ * Run the migrations.
7
+ */
8
+ async up (schema: SchemaBuilder) {
9
+ //
10
+ }
11
+
12
+ /**
13
+ * Reverse the migrations.
14
+ */
15
+ async down (schema: SchemaBuilder) {
16
+ //
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+
3
+ export default class extends Migration {
4
+ /**
5
+ * Run the migrations.
6
+ *
7
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
8
+ */
9
+ async up(schema) {
10
+ await schema.createTable('{{ table }}', (table) => {
11
+ table.increments('id')
12
+ table.timestamps()
13
+ })
14
+ }
15
+
16
+ /**
17
+ * Reverse the migrations.
18
+ *
19
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
20
+ */
21
+ async down(schema) {
22
+ await schema.dropTableIfExists('{{ table }}')
23
+ }
24
+ }
@@ -0,0 +1,21 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+ import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
3
+
4
+ export default class extends Migration {
5
+ /**
6
+ * Run the migrations.
7
+ */
8
+ async up(schema: SchemaBuilder) {
9
+ await schema.createTable('{{ table }}', (table) => {
10
+ table.increments('id')
11
+ table.timestamps()
12
+ })
13
+ }
14
+
15
+ /**
16
+ * Reverse the migrations.
17
+ */
18
+ async down(schema: SchemaBuilder) {
19
+ await schema.dropTableIfExists('{{ table }}')
20
+ }
21
+ }
@@ -0,0 +1,25 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+
3
+ export default class extends Migration {
4
+ /**
5
+ * Run the migrations.
6
+ *
7
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
8
+ */
9
+ async up(schema) {
10
+ await schema.table('{{ table }}', (table) => {
11
+ //
12
+ })
13
+ }
14
+
15
+ /**
16
+ * Reverse the migrations.
17
+ *
18
+ * @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
19
+ */
20
+ async down(schema) {
21
+ await schema.table('{{ table }}', (table) => {
22
+ //
23
+ })
24
+ }
25
+ };
@@ -0,0 +1,22 @@
1
+ import { Migration } from '@h3ravel/arquebus'
2
+ import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
3
+
4
+ export default class extends Migration {
5
+ /**
6
+ * Run the migrations.
7
+ */
8
+ async up(schema: SchemaBuilder) {
9
+ await schema.table('{{ table }}', (table) => {
10
+ //
11
+ })
12
+ }
13
+
14
+ /**
15
+ * Reverse the migrations.
16
+ */
17
+ async down(schema: SchemaBuilder) {
18
+ await schema.table('{{ table }}', (table) => {
19
+ //
20
+ })
21
+ }
22
+ }
@@ -0,0 +1,137 @@
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 node_fs_promises = require("node:fs/promises");
25
+ let path = require("path");
26
+ path = __toESM(path);
27
+ let node_path = require("node:path");
28
+ let node_url = require("node:url");
29
+
30
+ //#region src/seeders/seeder.ts
31
+ var Seeder = class {};
32
+ var seeder_default = Seeder;
33
+
34
+ //#endregion
35
+ //#region src/seeders/runner.ts
36
+ async function glob(folderPath) {
37
+ const { default: escalade } = await import("escalade");
38
+ const entries = [];
39
+ await escalade(folderPath, async (dir, names) => {
40
+ await Promise.all(names.map(async (name) => {
41
+ const p = path.default.join(dir, name);
42
+ try {
43
+ await (0, node_fs_promises.access)(p);
44
+ if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
45
+ } catch {}
46
+ }));
47
+ return "";
48
+ });
49
+ return entries;
50
+ }
51
+ var SeederRunner = class {
52
+ resolver;
53
+ connection;
54
+ paths = [];
55
+ constructor(resolver) {
56
+ this.resolver = resolver;
57
+ }
58
+ path(p) {
59
+ this.paths = Array.from(new Set([...this.paths, p]));
60
+ }
61
+ getPaths() {
62
+ return this.paths;
63
+ }
64
+ resolveConnection(connection) {
65
+ var _getInstance, _ref, _instance$connections;
66
+ const name = connection || this.connection || "default";
67
+ const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
68
+ if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
69
+ /** noop */
70
+ });
71
+ return this.resolver.fire(name);
72
+ }
73
+ setConnection(connection) {
74
+ this.connection = connection;
75
+ return this;
76
+ }
77
+ async getSeederFiles(paths) {
78
+ const files = [];
79
+ for (const p of paths) {
80
+ if (p.endsWith(".js") || p.endsWith(".ts")) {
81
+ files.push(p);
82
+ continue;
83
+ }
84
+ files.push(...await glob(p));
85
+ }
86
+ return files;
87
+ }
88
+ async resolvePath(filePath) {
89
+ try {
90
+ const mod = await import(filePath);
91
+ return new (mod.default ?? mod.Seeder)();
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
96
+ async run(paths, connection) {
97
+ const files = await this.getSeederFiles(paths);
98
+ const conn = this.resolveConnection(connection);
99
+ for (const file of files) {
100
+ const seeder = await this.resolvePath(file);
101
+ if (seeder && typeof seeder.run === "function") await seeder.run(conn);
102
+ }
103
+ }
104
+ };
105
+ var runner_default = SeederRunner;
106
+
107
+ //#endregion
108
+ //#region src/seeders/seeder-creator.ts
109
+ var SeederCreator = class {
110
+ constructor(customStubPath) {
111
+ this.customStubPath = customStubPath;
112
+ }
113
+ async create(dir, name, type = "js") {
114
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
115
+ let stub = await (0, node_fs_promises.readFile)(this.getStubPath(type), "utf-8");
116
+ stub = stub.replace(/{{ name }}/g, name);
117
+ const filePath = path.default.join(dir, `${name}.${type}`);
118
+ await (0, node_fs_promises.writeFile)(filePath, stub);
119
+ return filePath;
120
+ }
121
+ getStubPath(type) {
122
+ if (this.customStubPath) return path.default.join(this.customStubPath, `seeder-${type}.stub`);
123
+ const __dirname$1 = this.getDirname({});
124
+ return path.default.join(__dirname$1, "stubs", `seeder-${type}.stub`);
125
+ }
126
+ getDirname(meta) {
127
+ if (typeof __dirname !== "undefined") return __dirname;
128
+ if (meta && meta.url) return (0, node_path.dirname)((0, node_url.fileURLToPath)(meta.url));
129
+ throw new Error("Unable to determine dirname");
130
+ }
131
+ };
132
+ var seeder_creator_default = SeederCreator;
133
+
134
+ //#endregion
135
+ exports.Seeder = seeder_default;
136
+ exports.SeederCreator = seeder_creator_default;
137
+ exports.SeederRunner = runner_default;