@neetru/cli 1.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.
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/commands/add.d.ts +3 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +150 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +196 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/generate-types.d.ts +3 -0
- package/dist/commands/generate-types.d.ts.map +1 -0
- package/dist/commands/generate-types.js +150 -0
- package/dist/commands/generate-types.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +149 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +104 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logs.d.ts +3 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +114 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/open.d.ts +3 -0
- package/dist/commands/open.d.ts.map +1 -0
- package/dist/commands/open.js +91 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +99 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +99 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +33 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +83 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffold/auth.d.ts +3 -0
- package/dist/scaffold/auth.d.ts.map +1 -0
- package/dist/scaffold/auth.js +228 -0
- package/dist/scaffold/auth.js.map +1 -0
- package/dist/scaffold/billing.d.ts +3 -0
- package/dist/scaffold/billing.d.ts.map +1 -0
- package/dist/scaffold/billing.js +184 -0
- package/dist/scaffold/billing.js.map +1 -0
- package/dist/scaffold/usage.d.ts +3 -0
- package/dist/scaffold/usage.d.ts.map +1 -0
- package/dist/scaffold/usage.js +173 -0
- package/dist/scaffold/usage.js.map +1 -0
- package/dist/scaffold/users.d.ts +3 -0
- package/dist/scaffold/users.d.ts.map +1 -0
- package/dist/scaffold/users.js +135 -0
- package/dist/scaffold/users.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,135 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neetru/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Neetru CLI — SDK scaffolding e DevOps para integrar seu SaaS com Neetru Core (auth, billing, usage, deploy, logs)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"neetru": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "ts-node src/index.ts",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"chalk": "^5.3.0",
|
|
22
|
+
"commander": "^12.1.0",
|
|
23
|
+
"inquirer": "^9.2.23",
|
|
24
|
+
"ora": "^8.1.0",
|
|
25
|
+
"fs-extra": "^11.2.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/fs-extra": "^11.0.4",
|
|
29
|
+
"@types/inquirer": "^9.0.7",
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"typescript": "^5.4.0",
|
|
32
|
+
"ts-node": "^10.9.2"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"neetru",
|
|
39
|
+
"saas",
|
|
40
|
+
"oauth",
|
|
41
|
+
"billing",
|
|
42
|
+
"cli",
|
|
43
|
+
"sdk",
|
|
44
|
+
"devops",
|
|
45
|
+
"deploy",
|
|
46
|
+
"metered-billing"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"homepage": "https://github.com/neetru/cli#readme",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/neetru/cli.git"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/neetru/cli/issues"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
60
|
+
}
|