@neetru/cli 1.0.0 → 2.0.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 (135) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/README.md +109 -152
  3. package/dist/commands/add.d.ts +8 -3
  4. package/dist/commands/add.js +70 -143
  5. package/dist/commands/add.js.map +1 -1
  6. package/dist/commands/ai.d.ts +4 -0
  7. package/dist/commands/ai.js +88 -0
  8. package/dist/commands/ai.js.map +1 -0
  9. package/dist/commands/autocomplete.d.ts +7 -0
  10. package/dist/commands/autocomplete.js +107 -0
  11. package/dist/commands/autocomplete.js.map +1 -0
  12. package/dist/commands/build.d.ts +18 -0
  13. package/dist/commands/build.js +288 -0
  14. package/dist/commands/build.js.map +1 -0
  15. package/dist/commands/config.d.ts +3 -0
  16. package/dist/commands/config.js +70 -0
  17. package/dist/commands/config.js.map +1 -0
  18. package/dist/commands/db.d.ts +14 -0
  19. package/dist/commands/db.js +187 -0
  20. package/dist/commands/db.js.map +1 -0
  21. package/dist/commands/deploy.d.ts +16 -3
  22. package/dist/commands/deploy.js +400 -180
  23. package/dist/commands/deploy.js.map +1 -1
  24. package/dist/commands/doctor.d.ts +27 -0
  25. package/dist/commands/doctor.js +211 -0
  26. package/dist/commands/doctor.js.map +1 -0
  27. package/dist/commands/env.d.ts +15 -0
  28. package/dist/commands/env.js +56 -0
  29. package/dist/commands/env.js.map +1 -0
  30. package/dist/commands/fn.d.ts +6 -0
  31. package/dist/commands/fn.js +87 -0
  32. package/dist/commands/fn.js.map +1 -0
  33. package/dist/commands/init.d.ts +10 -3
  34. package/dist/commands/init.js +212 -143
  35. package/dist/commands/init.js.map +1 -1
  36. package/dist/commands/login.d.ts +6 -3
  37. package/dist/commands/login.js +222 -92
  38. package/dist/commands/login.js.map +1 -1
  39. package/dist/commands/logout.d.ts +1 -0
  40. package/dist/commands/logout.js +28 -0
  41. package/dist/commands/logout.js.map +1 -0
  42. package/dist/commands/logs.d.ts +14 -3
  43. package/dist/commands/logs.js +132 -106
  44. package/dist/commands/logs.js.map +1 -1
  45. package/dist/commands/mocks.d.ts +5 -0
  46. package/dist/commands/mocks.js +23 -0
  47. package/dist/commands/mocks.js.map +1 -0
  48. package/dist/commands/open.d.ts +4 -3
  49. package/dist/commands/open.js +53 -85
  50. package/dist/commands/open.js.map +1 -1
  51. package/dist/commands/promote.d.ts +9 -0
  52. package/dist/commands/promote.js +114 -0
  53. package/dist/commands/promote.js.map +1 -0
  54. package/dist/commands/publish.d.ts +14 -0
  55. package/dist/commands/publish.js +180 -0
  56. package/dist/commands/publish.js.map +1 -0
  57. package/dist/commands/status.d.ts +5 -3
  58. package/dist/commands/status.js +91 -93
  59. package/dist/commands/status.js.map +1 -1
  60. package/dist/commands/upgrade.d.ts +12 -0
  61. package/dist/commands/upgrade.js +77 -0
  62. package/dist/commands/upgrade.js.map +1 -0
  63. package/dist/commands/validate.d.ts +1 -3
  64. package/dist/commands/validate.js +83 -91
  65. package/dist/commands/validate.js.map +1 -1
  66. package/dist/commands/whoami.d.ts +5 -3
  67. package/dist/commands/whoami.js +76 -28
  68. package/dist/commands/whoami.js.map +1 -1
  69. package/dist/index.d.ts +0 -1
  70. package/dist/index.js +337 -36
  71. package/dist/index.js.map +1 -1
  72. package/dist/lib/ai/context.d.ts +11 -0
  73. package/dist/lib/ai/context.js +112 -0
  74. package/dist/lib/ai/context.js.map +1 -0
  75. package/dist/lib/ai/orchestrator.d.ts +10 -0
  76. package/dist/lib/ai/orchestrator.js +92 -0
  77. package/dist/lib/ai/orchestrator.js.map +1 -0
  78. package/dist/lib/api-client.d.ts +21 -0
  79. package/dist/lib/api-client.js +65 -0
  80. package/dist/lib/api-client.js.map +1 -0
  81. package/dist/lib/auth.d.ts +15 -0
  82. package/dist/lib/auth.js +98 -0
  83. package/dist/lib/auth.js.map +1 -0
  84. package/dist/lib/config-schema.d.ts +165 -0
  85. package/dist/lib/config-schema.js +57 -0
  86. package/dist/lib/config-schema.js.map +1 -0
  87. package/dist/lib/config.d.ts +15 -0
  88. package/dist/lib/config.js +33 -0
  89. package/dist/lib/config.js.map +1 -0
  90. package/dist/utils/logger.d.ts +13 -0
  91. package/dist/utils/logger.js +27 -0
  92. package/dist/utils/logger.js.map +1 -0
  93. package/package.json +35 -33
  94. package/templates/auth/callback.ts +22 -0
  95. package/templates/auth/sign-in.tsx +41 -0
  96. package/templates/billing/checkout.ts +22 -0
  97. package/templates/billing/page.tsx +43 -0
  98. package/templates/support/ticket-form.tsx +68 -0
  99. package/templates/usage/track.ts +30 -0
  100. package/templates/users/profile.tsx +43 -0
  101. package/LICENSE +0 -21
  102. package/dist/commands/add.d.ts.map +0 -1
  103. package/dist/commands/deploy.d.ts.map +0 -1
  104. package/dist/commands/generate-types.d.ts +0 -3
  105. package/dist/commands/generate-types.d.ts.map +0 -1
  106. package/dist/commands/generate-types.js +0 -150
  107. package/dist/commands/generate-types.js.map +0 -1
  108. package/dist/commands/init.d.ts.map +0 -1
  109. package/dist/commands/login.d.ts.map +0 -1
  110. package/dist/commands/logs.d.ts.map +0 -1
  111. package/dist/commands/open.d.ts.map +0 -1
  112. package/dist/commands/status.d.ts.map +0 -1
  113. package/dist/commands/validate.d.ts.map +0 -1
  114. package/dist/commands/whoami.d.ts.map +0 -1
  115. package/dist/config.d.ts +0 -14
  116. package/dist/config.d.ts.map +0 -1
  117. package/dist/config.js +0 -83
  118. package/dist/config.js.map +0 -1
  119. package/dist/index.d.ts.map +0 -1
  120. package/dist/scaffold/auth.d.ts +0 -3
  121. package/dist/scaffold/auth.d.ts.map +0 -1
  122. package/dist/scaffold/auth.js +0 -228
  123. package/dist/scaffold/auth.js.map +0 -1
  124. package/dist/scaffold/billing.d.ts +0 -3
  125. package/dist/scaffold/billing.d.ts.map +0 -1
  126. package/dist/scaffold/billing.js +0 -184
  127. package/dist/scaffold/billing.js.map +0 -1
  128. package/dist/scaffold/usage.d.ts +0 -3
  129. package/dist/scaffold/usage.d.ts.map +0 -1
  130. package/dist/scaffold/usage.js +0 -173
  131. package/dist/scaffold/usage.js.map +0 -1
  132. package/dist/scaffold/users.d.ts +0 -3
  133. package/dist/scaffold/users.d.ts.map +0 -1
  134. package/dist/scaffold/users.js +0 -135
  135. package/dist/scaffold/users.js.map +0 -1
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.scaffoldUsers = scaffoldUsers;
37
- const fs = __importStar(require("fs-extra"));
38
- const path = __importStar(require("path"));
39
- async function scaffoldUsers(config, outDir) {
40
- const content = `/**
41
- * Neetru Users API — gerado por neetru add users
42
- * Acesso ao perfil e preferências do usuário via Neetru Core.
43
- */
44
-
45
- const NEETRU_CORE_URL = process.env.NEETRU_CORE_URL ?? '${config.coreUrl}';
46
- const CLIENT_ID = process.env.NEETRU_CLIENT_ID ?? '${config.clientId}';
47
-
48
- export interface NeetruUserProfile {
49
- uid: string;
50
- email: string;
51
- displayName?: string;
52
- photoURL?: string;
53
- phoneNumber?: string;
54
- tenantId?: string;
55
- metadata: {
56
- creationTime: string;
57
- lastSignInTime: string;
58
- };
59
- customClaims?: Record<string, unknown>;
60
- }
61
-
62
- export interface NeetruUserPreferences {
63
- language?: string;
64
- timezone?: string;
65
- notifications?: {
66
- email: boolean;
67
- sms: boolean;
68
- push: boolean;
69
- };
70
- theme?: 'light' | 'dark' | 'system';
71
- }
72
-
73
- async function apiGet<T>(endpoint: string, accessToken: string): Promise<T> {
74
- const res = await fetch(\`\${NEETRU_CORE_URL}\${endpoint}\`, {
75
- headers: {
76
- Authorization: \`Bearer \${accessToken}\`,
77
- 'X-Client-ID': CLIENT_ID,
78
- },
79
- });
80
- if (!res.ok) throw new Error(\`Neetru Users API error: \${res.status}\`);
81
- return res.json() as Promise<T>;
82
- }
83
-
84
- async function apiPatch<T>(endpoint: string, accessToken: string, body: unknown): Promise<T> {
85
- const res = await fetch(\`\${NEETRU_CORE_URL}\${endpoint}\`, {
86
- method: 'PATCH',
87
- headers: {
88
- Authorization: \`Bearer \${accessToken}\`,
89
- 'X-Client-ID': CLIENT_ID,
90
- 'Content-Type': 'application/json',
91
- },
92
- body: JSON.stringify(body),
93
- });
94
- if (!res.ok) throw new Error(\`Neetru Users API error: \${res.status}\`);
95
- return res.json() as Promise<T>;
96
- }
97
-
98
- export const neetruUsers = {
99
- /**
100
- * Retorna o perfil completo do usuário autenticado.
101
- */
102
- async getProfile(accessToken: string): Promise<NeetruUserProfile> {
103
- return apiGet<NeetruUserProfile>('/api/v1/users/me', accessToken);
104
- },
105
-
106
- /**
107
- * Retorna preferências do usuário.
108
- */
109
- async getPreferences(accessToken: string): Promise<NeetruUserPreferences> {
110
- return apiGet<NeetruUserPreferences>('/api/v1/users/me/preferences', accessToken);
111
- },
112
-
113
- /**
114
- * Atualiza preferências do usuário.
115
- */
116
- async updatePreferences(
117
- accessToken: string,
118
- prefs: Partial<NeetruUserPreferences>
119
- ): Promise<NeetruUserPreferences> {
120
- return apiPatch<NeetruUserPreferences>('/api/v1/users/me/preferences', accessToken, prefs);
121
- },
122
-
123
- /**
124
- * Retorna outros usuários do mesmo tenant (requer permissão).
125
- */
126
- async listTenantUsers(accessToken: string): Promise<NeetruUserProfile[]> {
127
- return apiGet<NeetruUserProfile[]>('/api/v1/users', accessToken);
128
- },
129
- };
130
- `;
131
- const filePath = path.join(outDir, 'users.ts');
132
- await fs.writeFile(filePath, content, 'utf-8');
133
- return [path.relative(process.cwd(), filePath)];
134
- }
135
- //# sourceMappingURL=users.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/scaffold/users.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,sCAgGC;AApGD,6CAA+B;AAC/B,2CAA6B;AAGtB,KAAK,UAAU,aAAa,CAAC,MAAoB,EAAE,MAAc;IACtE,MAAM,OAAO,GAAG;;;;;0DAKwC,MAAM,CAAC,OAAO;qDACnB,MAAM,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFnE,CAAC;IAEA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AAClD,CAAC"}