@artilingo/artiframe-cli 1.2.1 → 1.3.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.
@@ -275,7 +275,8 @@
275
275
  <a href="#cli-new">new</a>
276
276
  <a href="#cli-view">make:view</a>
277
277
  <a href="#cli-api">make:api</a>
278
- <a href="#cli-class">make:class</a>
278
+ <a href="#cli-class">make:class</a>
279
+ <a href="#cli-table">table:</a>
279
280
  <a href="#cli-cliv">cli v</a>
280
281
  <a href="#cli-show">show</a>
281
282
  <a href="#cli-list">list</a>
@@ -308,7 +309,8 @@
308
309
  <a href="#vh-maskemail">maskEmail()</a>
309
310
  <a href="#vh-maskphone">maskPhone()</a>
310
311
  <a href="#vh-slugify">slugify()</a>
311
- <a href="#vh-money">money()</a>
312
+ <a href="#vh-money">money()</a>
313
+ <a href="#vh-uuid">uuid()</a>
312
314
  <div class="sb-cat">System Helpers</div>
313
315
  <div class="sb-subcat">Response &amp; Debug</div>
314
316
  <a href="#sh-apiresponse">apiResponse()</a>
@@ -344,7 +346,8 @@
344
346
  <a href="#sh-formatid">formatId()</a>
345
347
  <a href="#sh-intid">intId()</a>
346
348
  <a href="#sh-bigintid">bigintId()</a>
347
- <a href="#sh-stringer">stringer()</a>
349
+ <a href="#sh-stringer">stringer()</a>
350
+ <a href="#sh-otpcoder">OTP Coder</a>
348
351
  <div class="sb-cat">API Security</div>
349
352
  <a href="#api-methods">HTTP Method Control</a>
350
353
  <a href="#api-cors">CORS</a>
@@ -454,7 +457,15 @@
454
457
  btn.style.border = 'none';
455
458
  }
456
459
  </script>
457
- </section>
460
+
461
+ <h3 style="margin-top: 30px;">Additional Commands</h3>
462
+ <p><strong>List Tables:</strong> To see all available table templates and their descriptions:</p>
463
+ <pre><code>artiframe&gt; <span class="fn">table</span> <span class="st">list</span></code></pre>
464
+
465
+ <p><strong>Preview Table Content:</strong> To inspect the SQL content in the terminal before adding it to the <code>schema.sql</code> file, you can append the <code>check</code> parameter:</p>
466
+ <pre><code>artiframe&gt; <span class="fn">table:</span><span class="st">users</span> <span class="st">check</span></code></pre>
467
+
468
+ </section>
458
469
  <!-- ====== KURULUM ====== -->
459
470
  <section id="kurulum">
460
471
  <h2>Setup</h2>
@@ -762,7 +773,100 @@ project-name/
762
773
  ❌ Hata: Sınıfın oluşturulacağı dizin belirtilmeli! (örn: /app veya /src)
763
774
  Example: /src/Service/PaymentService</code></pre>
764
775
  </section>
765
- <!-- cli v -->
776
+
777
+ <!-- table: -->
778
+ <section id="cli-table">
779
+ <h2><code>table:</code> <span class="tag b-cli">CLI Command</span></h2>
780
+ <p>Allows you to quickly append standard and relational database tables to your project's <code>schema.sql</code> file. The templates are read from the global <code>stubs/sql.stub</code> file.</p>
781
+ <pre><code>artiframe&gt; <span class="fn">table:</span><span class="st">users</span></code></pre>
782
+ <p>Currently supported standard tables:</p>
783
+ <div class="table-tabs-container" style="margin-top: 20px;">
784
+ <div class="tabs-header" style="display: flex; gap: 10px; margin-bottom: 10px; overflow-x: auto; padding-bottom: 5px;">
785
+ <button class="table-tab-btn active" onclick="switchTableTab('tab-users', this)" style="white-space: nowrap; padding: 10px 20px; background: #00c88c; color: #000; font-weight: 600; border: none; border-radius: 5px; cursor: pointer;">users</button>
786
+ <button class="table-tab-btn" onclick="switchTableTab('tab-sessions', this)" style="white-space: nowrap; padding: 10px 20px; background: #1c2128; color: #fff; border: 1px solid #30363d; border-radius: 5px; cursor: pointer;">user_sessions</button>
787
+ <button class="table-tab-btn" onclick="switchTableTab('tab-prefs', this)" style="white-space: nowrap; padding: 10px 20px; background: #1c2128; color: #fff; border: 1px solid #30363d; border-radius: 5px; cursor: pointer;">user_preferences</button>
788
+ </div>
789
+
790
+ <!-- Tab: users -->
791
+ <div id="tab-users" class="table-tab-content" style="display: block;">
792
+ <pre><code><span class="kw">CREATE TABLE `users` (
793
+ `id` binary(16) NOT NULL,
794
+ `email` varchar(255) NOT NULL,
795
+ `password` varchar(255) NOT NULL,
796
+ `name` varchar(255) DEFAULT NULL,
797
+ `role` enum('user','admin','moderator') NOT NULL DEFAULT 'user',
798
+ `status` tinyint(1) NOT NULL DEFAULT '1',
799
+ `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
800
+ `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
801
+ PRIMARY KEY (`id`),
802
+ UNIQUE KEY `email` (`email`)
803
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;</span></code></pre>
804
+ </div>
805
+
806
+ <!-- Tab: user_sessions -->
807
+ <div id="tab-sessions" class="table-tab-content" style="display: none;">
808
+ <pre><code><span class="kw">CREATE TABLE `user_sessions` (
809
+ `id` binary(16) NOT NULL,
810
+ `user_id` binary(16) NOT NULL,
811
+ `token` varchar(255) NOT NULL,
812
+ `ip_address` varchar(45) DEFAULT NULL,
813
+ `user_agent` varchar(255) DEFAULT NULL,
814
+ `expires_at` timestamp NULL DEFAULT NULL,
815
+ `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
816
+ PRIMARY KEY (`id`),
817
+ UNIQUE KEY `token` (`token`),
818
+ KEY `user_id` (`user_id`),
819
+ CONSTRAINT `fk_user_sessions_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
820
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;</span></code></pre>
821
+ </div>
822
+
823
+ <!-- Tab: user_preferences -->
824
+ <div id="tab-prefs" class="table-tab-content" style="display: none;">
825
+ <pre><code><span class="kw">CREATE TABLE `user_preferences` (
826
+ `id` binary(16) NOT NULL,
827
+ `user_id` binary(16) NOT NULL,
828
+ `language` varchar(10) NOT NULL DEFAULT 'tr',
829
+ `theme` varchar(20) NOT NULL DEFAULT 'light',
830
+ `push_notifications` tinyint(1) NOT NULL DEFAULT '1',
831
+ `email_notifications` tinyint(1) NOT NULL DEFAULT '1',
832
+ `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
833
+ `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
834
+ PRIMARY KEY (`id`),
835
+ UNIQUE KEY `user_id` (`user_id`),
836
+ CONSTRAINT `fk_user_prefs_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
837
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;</span></code></pre>
838
+ </div>
839
+ </div>
840
+
841
+ <script>
842
+ function switchTableTab(tabId, btn) {
843
+ const container = btn.closest('.table-tabs-container');
844
+ container.querySelectorAll('.table-tab-content').forEach(el => el.style.display = 'none');
845
+ container.querySelectorAll('.table-tab-btn').forEach(el => {
846
+ el.style.background = '#1c2128';
847
+ el.style.color = '#fff';
848
+ el.style.border = '1px solid #30363d';
849
+ el.style.fontWeight = '400';
850
+ });
851
+
852
+ container.querySelector('#' + tabId).style.display = 'block';
853
+ btn.style.background = '#00c88c';
854
+ btn.style.color = '#000';
855
+ btn.style.fontWeight = '600';
856
+ btn.style.border = 'none';
857
+ }
858
+ </script>
859
+
860
+ <h3 style="margin-top: 30px;">Additional Commands</h3>
861
+ <p><strong>List Tables:</strong> To see all available table templates and their descriptions:</p>
862
+ <pre><code>artiframe&gt; <span class="fn">table</span> <span class="st">list</span></code></pre>
863
+
864
+ <p><strong>Preview Table Content:</strong> To inspect the SQL content in the terminal before adding it to the <code>schema.sql</code> file, you can append the <code>check</code> parameter:</p>
865
+ <pre><code>artiframe&gt; <span class="fn">table:</span><span class="st">users</span> <span class="st">check</span></code></pre>
866
+
867
+ </section>
868
+
869
+ <!-- cli v -->
766
870
  <section id="cli-cliv">
767
871
  <h2><code>cli v</code> (or <code>cli version</code>) <span class="tag b-cli">CLI Komutu</span></h2>
768
872
  <p>ArtiFrame CLI controls its own (global) version of the tool. Not only shows the current version, <strong>NPM Registry</strong> It also checks whether the most up-to-date version is available. If there is a new version, it can update itself globally with one click (y/n).<code>npm install -g @artilingo/artiframe-cli@latest</code>).</p>
@@ -3981,7 +4085,15 @@ if ($response['status'] === 'success') {
3981
4085
 
3982
4086
  &lt;span&gt;&lt;?= <span class="fn">money</span>(<span class="var">$product</span>[<span class="st">'price'</span>], <span class="st">'usd'</span>) ?&gt;&lt;/span&gt;
3983
4087
  <span class="cm">&lt;!-- Output: $1,250.00 --&gt;</span></code></pre>
3984
- </section>
4088
+ </section>
4089
+
4090
+ <section id="vh-uuid">
4091
+ <h2>View Helpers - <code>uuid()</code> <span class="tag b-view">ViewMethod</span></h2>
4092
+ <p>Converts a 16-byte binary UUID from the database into a 36-character format and prints it to the screen with XSS protection.</p>
4093
+ <pre><code><span class="cm">&lt;!-- Output: 0190ed84-3f12-7a91-8bc4-91823741abcd --&gt;</span>
4094
+ &lt;div&gt;<span class="kw">&lt;?=</span> <span class="fn">uuid</span>(<span class="var">$pull</span>[<span class="st">'id'</span>]) <span class="kw">?&gt;</span>&lt;/div&gt;</code></pre>
4095
+ </section>
4096
+
3985
4097
  <!-- ====== SYSTEM HELPERS ====== -->
3986
4098
  <section id="sh-apiresponse">
3987
4099
  <h2>System Helpers— <code>apiResponse()</code> <span class="tag b-api">SystemMethod</span></h2>
@@ -4024,7 +4136,29 @@ if ($response['status'] === 'success') {
4024
4136
  <span class="cm">// Error response</span>
4025
4137
  <span class="fn">jsonResponse</span>([<span class="st">'status'</span> =&gt; <span class="st">'error'</span>, <span class="st">'message'</span> =&gt; <span class="st">'Unauthorized access.'</span>], <span class="nu">401</span>);</code></pre>
4026
4138
  </section>
4027
- <section id="sh-generatecsrf">
4139
+
4140
+ <section id="sh-dd">
4141
+ <h2>System Helpers— <code>dd()</code> <span class="tag b-api">SystemMethod</span></h2>
4142
+ <p>Dump &amp; Die. During the development phase, the variables were displayed on the screen in a dark mode, readable and stylish way. <code>&lt;pre&gt;</code> tag and stops the execution of the code at that line (exit). It can take unlimited parameters (Variadic).</p>
4143
+ <span class="ret">void dd(mixed ...$vars)</span>
4144
+ <pre><code><span class="fn">dd</span>(<span class="var">$_POST</span>, <span class="var">$user_id</span>);
4145
+ <span class="cm">// Prints the values ​​to the screen and stops the system.</span></code></pre>
4146
+ </section>
4147
+ <!-- ====== ID GENERATION & UTILITIES ====== -->
4148
+ <section id="id-generation-utilities">
4149
+ </section>
4150
+
4151
+
4152
+ <section id="sh-redirect">
4153
+ <h2>System Helpers— <code>redirect()</code> <span class="tag b-api">SystemMethod</span></h2>
4154
+ <span class="ret">void redirect(string $url)</span>
4155
+ <p>to the desired page <code>header("Location: ...")</code> It instantly redirects and stops working with (<code>exit</code>).</p>
4156
+ <pre><code><span class="kw">if</span> (!<span class="var">$isLoggedIn</span>) {
4157
+ <span class="fn">redirect</span>(<span class="st">'/login'</span>);
4158
+ }</code></pre>
4159
+ </section>
4160
+
4161
+ <section id="sh-generatecsrf">
4028
4162
  <h2>System Helpers— <code>generateCsrf()</code> <span class="tag b-api">SystemMethod</span></h2>
4029
4163
  <p>It generates a brand new session-based secure CSRF token, 32 bytes long. To add as hidden input to forms <code>csrfField()</code> It is recommended to use (View Helper).</p>
4030
4164
  <span class="ret">string generateCsrf()</span>
@@ -4110,14 +4244,7 @@ if ($response['status'] === 'success') {
4110
4244
  <p>Detects the user's real IP address. Cloudflare (<code>HTTP_CF_CONNECTING_IP</code>), Proxy (<code>HTTP_X_FORWARDED_FOR</code>) and standard (<code>REMOTE_ADDR</code>) resolves all connections automatically.</p>
4111
4245
  <pre><code><span class="var">$ip</span> = <span class="fn">getClientIp</span>(); <span class="cm">// Ex: 192.168.1.1</span></code></pre>
4112
4246
  </section>
4113
- <section id="sh-redirect">
4114
- <h2>System Helpers— <code>redirect()</code> <span class="tag b-api">SystemMethod</span></h2>
4115
- <span class="ret">void redirect(string $url)</span>
4116
- <p>to the desired page <code>header("Location: ...")</code> It instantly redirects and stops working with (<code>exit</code>).</p>
4117
- <pre><code><span class="kw">if</span> (!<span class="var">$isLoggedIn</span>) {
4118
- <span class="fn">redirect</span>(<span class="st">'/login'</span>);
4119
- }</code></pre>
4120
- </section>
4247
+
4121
4248
  <section id="sh-verifyemail">
4122
4249
  <h2>System Helpers— <code>verifyEmail()</code> <span class="tag b-api">SystemMethod</span></h2>
4123
4250
  <p>It verifies whether the given email address is actually a valid email address based on DNS or format.</p>
@@ -4159,16 +4286,10 @@ if ($response['status'] === 'success') {
4159
4286
  <pre><code><span class="var">$postData</span> = <span class="fn">arrayOnly</span>(<span class="var">$_POST</span>, [<span class="st">'user_name'</span>, <span class="st">'password'</span>, <span class="st">'e-mail'</span>]);
4160
4287
  <span class="cm">// Externally manipulated values ​​such as ID and role are automatically destroyed.</span></code></pre>
4161
4288
  </section>
4162
- <section id="sh-dd">
4163
- <h2>System Helpers— <code>dd()</code> <span class="tag b-api">SystemMethod</span></h2>
4164
- <p>Dump &amp; Die. During the development phase, the variables were displayed on the screen in a dark mode, readable and stylish way. <code>&lt;pre&gt;</code> tag and stops the execution of the code at that line (exit). It can take unlimited parameters (Variadic).</p>
4165
- <span class="ret">void dd(mixed ...$vars)</span>
4166
- <pre><code><span class="fn">dd</span>(<span class="var">$_POST</span>, <span class="var">$user_id</span>);
4167
- <span class="cm">// Prints the values ​​to the screen and stops the system.</span></code></pre>
4168
- </section>
4169
- <!-- ====== ID GENERATION & UTILITIES ====== -->
4170
- <section id="id-generation-utilities">
4171
- <h2 id="sh-byteid">System Helpers - <code>byteId()</code> <span class="tag b-api">SystemMethod</span></h2>
4289
+
4290
+
4291
+ <section id="sh-byteid">
4292
+ <h2>System Helpers - <code>byteId()</code> <span class="tag b-api">SystemMethod</span></h2>
4172
4293
  <div class="info-box">
4173
4294
  Native, high-performance and time-ordered raw 16-byte <strong>UUIDv7</strong> produces.
4174
4295
  </div>
@@ -4184,7 +4305,10 @@ if ($response['status'] === 'success') {
4184
4305
 
4185
4306
  <span class="var">$db</span>-&gt;<span class="fn">prepare</span>(<span class="st">"INSERT INTO users (id, name) VALUES (?, ?)"</span>)-&gt;<span class="fn">execute</span>([<span class="var">$rawId</span>, <span class="st">'Triumph'</span>]);</code></pre>
4186
4307
  </div>
4187
- <h2 id="sh-makeid">System Helpers - <code>makeId()</code> <span class="tag b-api">SystemMethod</span></h2>
4308
+ </section>
4309
+
4310
+ <section id="sh-makeid">
4311
+ <h2>System Helpers - <code>makeId()</code> <span class="tag b-api">SystemMethod</span></h2>
4188
4312
  <div class="info-box">
4189
4313
  Native, standard 36 characters <strong>UUIDv7</strong> produces the string.
4190
4314
  </div>
@@ -4198,7 +4322,10 @@ if ($response['status'] === 'success') {
4198
4322
  <span class="var">$stringId</span> = SystemMethod::<span class="fn">makeId</span>();
4199
4323
  <span class="cm">// Sample Output: 0190ed84-3f12-7a91-8bc4-91823741abcd</span></code></pre>
4200
4324
  </div>
4201
- <h2 id="sh-formatid">System Helpers - <code>formatId()</code> <span class="tag b-api">SystemMethod</span></h2>
4325
+ </section>
4326
+
4327
+ <section id="sh-formatid">
4328
+ <h2>System Helpers - <code>formatId()</code> <span class="tag b-api">SystemMethod</span></h2>
4202
4329
  <div class="info-box">
4203
4330
  Converts raw 16-byte binary UUIDs to a standard 36-character string.
4204
4331
  </div>
@@ -4213,7 +4340,10 @@ if ($response['status'] === 'success') {
4213
4340
  <span class="var">$readableId</span> = SystemMethod::<span class="fn">formatId</span>(<span class="var">$user</span>[<span class="st">'ID'</span>]);
4214
4341
  <span class="cm">// Sample Output: 0190ed84-3f12-7a91-8bc4-91823741abcd</span></code></pre>
4215
4342
  </div>
4216
- <h2 id="sh-intid">System Helpers - <code>intId()</code> <span class="tag b-api">SystemMethod</span></h2>
4343
+ </section>
4344
+
4345
+ <section id="sh-intid">
4346
+ <h2>System Helpers - <code>intId()</code> <span class="tag b-api">SystemMethod</span></h2>
4217
4347
  <div class="info-box">
4218
4348
  Safe, random <code>INT</code> Generates ID. (Max 9 Digits)
4219
4349
  </div>
@@ -4225,7 +4355,10 @@ if ($response['status'] === 'success') {
4225
4355
  <pre><code><span class="var">$id</span> = <span class="fn">intId</span>(8);
4226
4356
  <span class="cm">// Sample Output: 49201834</span></code></pre>
4227
4357
  </div>
4228
- <h2 id="sh-bigintid">System Helpers - <code>bigintId()</code> <span class="tag b-api">SystemMethod</span></h2>
4358
+ </section>
4359
+
4360
+ <section id="sh-bigintid">
4361
+ <h2>System Helpers - <code>bigintId()</code> <span class="tag b-api">SystemMethod</span></h2>
4229
4362
  <div class="info-box">
4230
4363
  Safe, random <code>BIGINT</code> Generates ID. (Default 15 digits - safe limit for JS)
4231
4364
  </div>
@@ -4237,7 +4370,10 @@ if ($response['status'] === 'success') {
4237
4370
  <pre><code><span class="var">$id</span> = <span class="fn">bigintId</span>(); <span class="cm">// Returns 15 digit INT</span>
4238
4371
  <span class="var">$massiveId</span> = <span class="fn">bigintId</span>(18, <span class="kw">true</span>); <span class="cm">// returns 18 digit STRING (JS safe)</span></code></pre>
4239
4372
  </div>
4240
- <h2 id="sh-stringer">System Helpers - <code>stringer()</code> <span class="tag b-api">SystemMethod</span></h2>
4373
+ </section>
4374
+
4375
+ <section id="sh-stringer">
4376
+ <h2>System Helpers - <code>stringer()</code> <span class="tag b-api">SystemMethod</span></h2>
4241
4377
  <div class="info-box">
4242
4378
  Wraps values ​​into strings to protect against Javascript's huge number (BIGINT) insensitivity.
4243
4379
  </div>
@@ -4249,7 +4385,25 @@ if ($response['status'] === 'success') {
4249
4385
  <pre><code><span class="cm">&lt;!-- We wrap it with a stringer to prevent JS from corrupting it --&gt;</span>
4250
4386
  &lt;button data-id=<span class="st">"&lt;?=</span> <span class="fn">Stringer</span>(<span class="var">$data</span>[<span class="st">'ID'</span>]) <span class="st">?&gt;"</span>&gt;Sil&lt;/button&gt;</code></pre>
4251
4387
  </div>
4252
- </section>
4388
+
4389
+
4390
+ <section id="sh-otpcoder">
4391
+ <h2>System Helpers - OTP Coder <span class="tag b-api">SystemMethod</span></h2>
4392
+ <div class="info-box">Generates random, cryptographically secure One-Time Passwords (OTP).</div>
4393
+ <div class="code-block">
4394
+ <pre><code><span class="cm">// 6-digit random number</span>
4395
+ <span class="var">$code</span> = <span class="fn">otpInt</span>(<span class="nu">6</span>); <span class="cm">// 482910</span>
4396
+
4397
+ <span class="cm">// 8-digit letters only ('c': lowercase, 'C': uppercase, 'cC': mixed)</span>
4398
+ <span class="var">$code</span> = <span class="fn">otpStr</span>(<span class="nu">8</span>, <span class="st">'C'</span>); <span class="cm">// PKLMDZRA</span>
4399
+
4400
+ <span class="cm">// 6-digit alphanumeric</span>
4401
+ <span class="var">$code</span> = <span class="fn">otpMix</span>(<span class="nu">6</span>, <span class="st">'C'</span>); <span class="cm">// 9A4X2Z</span></code></pre>
4402
+ </div>
4403
+ </section>
4404
+
4405
+
4406
+ </section>
4253
4407
  <!-- ====== API GÜVENLİĞİ ====== -->
4254
4408
  <section id="api-methods">
4255
4409
  <h2>API — HTTP Method Control <span class="tag b-sec">ApiControl</span></h2>