@trendify/cli 0.1.9 → 0.1.11
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/dist/app.component.js +1 -1
- package/dist/cli.entry.js +2 -2
- package/dist/shared/config/env.config.js +1 -1
- package/dist/shared/services/cli-update.service.d.ts +7 -1
- package/dist/shared/services/cli-update.service.d.ts.map +1 -1
- package/dist/shared/services/cli-update.service.js +16 -9
- package/package.json +1 -1
- package/dist/app.d.ts +0 -14
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -448
- package/dist/cli-update-service.d.ts +0 -29
- package/dist/cli-update-service.d.ts.map +0 -1
- package/dist/cli-update-service.js +0 -206
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -51
- package/dist/config/app-paths.d.ts +0 -4
- package/dist/config/app-paths.d.ts.map +0 -1
- package/dist/config/app-paths.js +0 -5
- package/dist/config/env.d.ts +0 -14
- package/dist/config/env.d.ts.map +0 -1
- package/dist/config/env.js +0 -58
- package/dist/modules/auth/auth-service.d.ts +0 -60
- package/dist/modules/auth/auth-service.d.ts.map +0 -1
- package/dist/modules/auth/auth-service.js +0 -494
- package/dist/modules/auth/auth-storage.d.ts +0 -11
- package/dist/modules/auth/auth-storage.d.ts.map +0 -1
- package/dist/modules/auth/auth-storage.js +0 -65
- package/dist/modules/auth/auth-user.d.ts +0 -3
- package/dist/modules/auth/auth-user.d.ts.map +0 -1
- package/dist/modules/auth/auth-user.js +0 -10
- package/dist/modules/auth/page/login-page.d.ts +0 -12
- package/dist/modules/auth/page/login-page.d.ts.map +0 -1
- package/dist/modules/auth/page/login-page.js +0 -22
- package/dist/modules/discovery/components/discovery-step-header.d.ts +0 -7
- package/dist/modules/discovery/components/discovery-step-header.d.ts.map +0 -1
- package/dist/modules/discovery/components/discovery-step-header.js +0 -5
- package/dist/modules/discovery/page/discovery-page.d.ts +0 -11
- package/dist/modules/discovery/page/discovery-page.d.ts.map +0 -1
- package/dist/modules/discovery/page/discovery-page.js +0 -58
- package/dist/modules/profile/page/profile-page.d.ts +0 -12
- package/dist/modules/profile/page/profile-page.d.ts.map +0 -1
- package/dist/modules/profile/page/profile-page.js +0 -180
- package/dist/modules/profile/pages/profile.page.d.ts +0 -12
- package/dist/modules/profile/pages/profile.page.d.ts.map +0 -1
- package/dist/modules/profile/pages/profile.page.js +0 -180
- package/dist/shared/components/action-menu-page.d.ts +0 -13
- package/dist/shared/components/action-menu-page.d.ts.map +0 -1
- package/dist/shared/components/action-menu-page.js +0 -7
- package/dist/shared/components/radio-select.d.ts +0 -12
- package/dist/shared/components/radio-select.d.ts.map +0 -1
- package/dist/shared/components/radio-select.js +0 -16
- package/dist/shared/components/step-header.d.ts +0 -7
- package/dist/shared/components/step-header.d.ts.map +0 -1
- package/dist/shared/components/step-header.js +0 -5
- package/dist/shared/components/text-field.d.ts +0 -12
- package/dist/shared/components/text-field.d.ts.map +0 -1
- package/dist/shared/components/text-field.js +0 -6
- package/dist/shared/constants/app-version.constant.d.ts +0 -2
- package/dist/shared/constants/app-version.constant.d.ts.map +0 -1
- package/dist/shared/constants/app-version.constant.js +0 -1
- package/dist/shared/template/app-logo.d.ts +0 -2
- package/dist/shared/template/app-logo.d.ts.map +0 -1
- package/dist/shared/template/app-logo.js +0 -13
- package/dist/shared/template/app-menu.d.ts +0 -17
- package/dist/shared/template/app-menu.d.ts.map +0 -1
- package/dist/shared/template/app-menu.js +0 -85
- package/dist/shared/template/app-shell.d.ts +0 -12
- package/dist/shared/template/app-shell.d.ts.map +0 -1
- package/dist/shared/template/app-shell.js +0 -15
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -1
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
const DEFAULT_PACKAGE_NAME = '@trendify/cli';
|
|
4
|
-
const VERSION_PATTERN = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u;
|
|
5
|
-
function getPackageManifestPath() {
|
|
6
|
-
return new URL('../package.json', import.meta.url);
|
|
7
|
-
}
|
|
8
|
-
function getNpmCommand() {
|
|
9
|
-
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
10
|
-
}
|
|
11
|
-
function toErrorMessage(error) {
|
|
12
|
-
if (error instanceof Error && error.message.trim()) {
|
|
13
|
-
return error.message;
|
|
14
|
-
}
|
|
15
|
-
return 'Nao foi possivel concluir a operacao.';
|
|
16
|
-
}
|
|
17
|
-
function readInstalledPackageMetadata() {
|
|
18
|
-
try {
|
|
19
|
-
const manifestContents = readFileSync(getPackageManifestPath(), 'utf8');
|
|
20
|
-
const manifest = JSON.parse(manifestContents);
|
|
21
|
-
const packageName = typeof manifest.name === 'string' && manifest.name.trim().length > 0
|
|
22
|
-
? manifest.name.trim()
|
|
23
|
-
: DEFAULT_PACKAGE_NAME;
|
|
24
|
-
return { packageName };
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return { packageName: DEFAULT_PACKAGE_NAME };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function parseVersion(version) {
|
|
31
|
-
const match = VERSION_PATTERN.exec(version.trim());
|
|
32
|
-
if (!match) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const [, major, minor, patch, prerelease] = match;
|
|
36
|
-
if (!major || !minor || !patch) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
major: Number.parseInt(major, 10),
|
|
41
|
-
minor: Number.parseInt(minor, 10),
|
|
42
|
-
patch: Number.parseInt(patch, 10),
|
|
43
|
-
prerelease: prerelease ?? null,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function compareVersions(left, right) {
|
|
47
|
-
const parsedLeft = parseVersion(left);
|
|
48
|
-
const parsedRight = parseVersion(right);
|
|
49
|
-
if (!parsedLeft || !parsedRight) {
|
|
50
|
-
return left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' });
|
|
51
|
-
}
|
|
52
|
-
if (parsedLeft.major !== parsedRight.major) {
|
|
53
|
-
return parsedLeft.major - parsedRight.major;
|
|
54
|
-
}
|
|
55
|
-
if (parsedLeft.minor !== parsedRight.minor) {
|
|
56
|
-
return parsedLeft.minor - parsedRight.minor;
|
|
57
|
-
}
|
|
58
|
-
if (parsedLeft.patch !== parsedRight.patch) {
|
|
59
|
-
return parsedLeft.patch - parsedRight.patch;
|
|
60
|
-
}
|
|
61
|
-
if (parsedLeft.prerelease === parsedRight.prerelease) {
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
if (parsedLeft.prerelease === null) {
|
|
65
|
-
return 1;
|
|
66
|
-
}
|
|
67
|
-
if (parsedRight.prerelease === null) {
|
|
68
|
-
return -1;
|
|
69
|
-
}
|
|
70
|
-
return parsedLeft.prerelease.localeCompare(parsedRight.prerelease, undefined, {
|
|
71
|
-
numeric: true,
|
|
72
|
-
sensitivity: 'base',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function runCommand(command, args) {
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
const child = spawn(command, [...args], {
|
|
78
|
-
env: process.env,
|
|
79
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
80
|
-
});
|
|
81
|
-
let stdout = '';
|
|
82
|
-
let stderr = '';
|
|
83
|
-
child.stdout.on('data', (chunk) => {
|
|
84
|
-
stdout += chunk.toString();
|
|
85
|
-
});
|
|
86
|
-
child.stderr.on('data', (chunk) => {
|
|
87
|
-
stderr += chunk.toString();
|
|
88
|
-
});
|
|
89
|
-
child.on('error', (error) => {
|
|
90
|
-
reject(error);
|
|
91
|
-
});
|
|
92
|
-
child.on('close', (code) => {
|
|
93
|
-
resolve({
|
|
94
|
-
code: code ?? 1,
|
|
95
|
-
stderr,
|
|
96
|
-
stdout,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
async function fetchLatestPublishedVersion(packageName) {
|
|
102
|
-
const commandResult = await runCommand(getNpmCommand(), ['view', packageName, 'version', '--json', '--silent']);
|
|
103
|
-
if (commandResult.code !== 0) {
|
|
104
|
-
const message = commandResult.stderr.trim() || commandResult.stdout.trim() || 'Falha ao consultar o npm.';
|
|
105
|
-
throw new Error(message);
|
|
106
|
-
}
|
|
107
|
-
const stdout = commandResult.stdout.trim();
|
|
108
|
-
if (!stdout) {
|
|
109
|
-
throw new Error('O npm nao retornou a versao publicada mais recente.');
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
const parsedOutput = JSON.parse(stdout);
|
|
113
|
-
if (typeof parsedOutput === 'string' && parsedOutput.trim()) {
|
|
114
|
-
return parsedOutput.trim();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
if (stdout) {
|
|
119
|
-
return stdout.replace(/^"+|"+$/gu, '').trim();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
throw new Error('Nao foi possivel interpretar a versao publicada retornada pelo npm.');
|
|
123
|
-
}
|
|
124
|
-
async function runCommandWithInheritedStdio(command, args) {
|
|
125
|
-
return new Promise((resolve, reject) => {
|
|
126
|
-
const child = spawn(command, [...args], {
|
|
127
|
-
env: process.env,
|
|
128
|
-
stdio: 'inherit',
|
|
129
|
-
});
|
|
130
|
-
child.on('error', (error) => {
|
|
131
|
-
reject(error);
|
|
132
|
-
});
|
|
133
|
-
child.on('close', (code) => {
|
|
134
|
-
resolve(code ?? 1);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
async function restartCli() {
|
|
139
|
-
const entrypoint = process.argv[1];
|
|
140
|
-
if (!entrypoint) {
|
|
141
|
-
throw new Error('Nao foi possivel identificar o entrypoint atual da CLI para reiniciar o processo.');
|
|
142
|
-
}
|
|
143
|
-
await new Promise((resolve, reject) => {
|
|
144
|
-
const child = spawn(process.execPath, [...process.execArgv, entrypoint, ...process.argv.slice(2)], {
|
|
145
|
-
env: process.env,
|
|
146
|
-
stdio: 'inherit',
|
|
147
|
-
});
|
|
148
|
-
child.on('error', (error) => {
|
|
149
|
-
reject(error);
|
|
150
|
-
});
|
|
151
|
-
child.on('spawn', () => {
|
|
152
|
-
resolve();
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
export async function checkForCliUpdate(currentVersion) {
|
|
157
|
-
const { packageName } = readInstalledPackageMetadata();
|
|
158
|
-
try {
|
|
159
|
-
const latestVersion = await fetchLatestPublishedVersion(packageName);
|
|
160
|
-
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
161
|
-
return {
|
|
162
|
-
currentVersion,
|
|
163
|
-
latestVersion,
|
|
164
|
-
packageName,
|
|
165
|
-
status: 'available',
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
currentVersion,
|
|
170
|
-
latestVersion,
|
|
171
|
-
packageName,
|
|
172
|
-
status: 'current',
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
return {
|
|
177
|
-
currentVersion,
|
|
178
|
-
message: toErrorMessage(error),
|
|
179
|
-
packageName,
|
|
180
|
-
status: 'error',
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
export async function runCliSelfUpdate(packageName, latestVersion) {
|
|
185
|
-
try {
|
|
186
|
-
const exitCode = await runCommandWithInheritedStdio(getNpmCommand(), [
|
|
187
|
-
'install',
|
|
188
|
-
'--global',
|
|
189
|
-
`${packageName}@${latestVersion}`,
|
|
190
|
-
]);
|
|
191
|
-
if (exitCode !== 0) {
|
|
192
|
-
return {
|
|
193
|
-
error: `O npm encerrou a atualizacao com codigo ${exitCode}.`,
|
|
194
|
-
ok: false,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
await restartCli();
|
|
198
|
-
return { ok: true };
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
return {
|
|
202
|
-
error: toErrorMessage(error),
|
|
203
|
-
ok: false,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":""}
|
package/dist/cli.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { render } from 'ink';
|
|
4
|
-
import { App } from './app.js';
|
|
5
|
-
import { runCliSelfUpdate } from './cli-update-service.js';
|
|
6
|
-
import { APP_VERSION } from './version.js';
|
|
7
|
-
const args = process.argv.slice(2);
|
|
8
|
-
const initialInput = args
|
|
9
|
-
.filter((arg) => !arg.startsWith('-'))
|
|
10
|
-
.join(' ')
|
|
11
|
-
.trim();
|
|
12
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
13
|
-
process.stdout.write(`CLI
|
|
14
|
-
|
|
15
|
-
Uso:
|
|
16
|
-
trendify [opcoes]
|
|
17
|
-
|
|
18
|
-
Opcoes:
|
|
19
|
-
-h, --help Mostra esta ajuda
|
|
20
|
-
-v, --version Mostra a versao instalada
|
|
21
|
-
`);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
if (args.includes('--version') || args.includes('-v')) {
|
|
25
|
-
process.stdout.write(`${APP_VERSION}\n`);
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
console.clear();
|
|
29
|
-
let appInstance;
|
|
30
|
-
function mountApp(feedback = null) {
|
|
31
|
-
appInstance = render(_jsx(App, { appVersion: APP_VERSION, initialInput: initialInput, initialNotification: feedback?.message ?? null, initialNotificationTone: feedback?.tone ?? 'success', onSelfUpdate: async (update) => {
|
|
32
|
-
appInstance.unmount();
|
|
33
|
-
console.clear();
|
|
34
|
-
process.stdout.write([
|
|
35
|
-
`Atualizando o CLI de v${update.currentVersion} para v${update.latestVersion}.`,
|
|
36
|
-
`Pacote npm: ${update.packageName}`,
|
|
37
|
-
'',
|
|
38
|
-
].join('\n'));
|
|
39
|
-
const result = await runCliSelfUpdate(update.packageName, update.latestVersion);
|
|
40
|
-
if (result.ok) {
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
process.stdout.write(`\nFalha ao atualizar automaticamente: ${result.error}\n`);
|
|
44
|
-
process.stdout.write('A CLI atual continuara disponivel.\n');
|
|
45
|
-
mountApp({
|
|
46
|
-
message: `Nao foi possivel atualizar a CLI automaticamente. ${result.error}`,
|
|
47
|
-
tone: 'error',
|
|
48
|
-
});
|
|
49
|
-
} }));
|
|
50
|
-
}
|
|
51
|
-
mountApp();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-paths.d.ts","sourceRoot":"","sources":["../../src/config/app-paths.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,QAA+B,CAAC;AAC9D,eAAO,MAAM,iBAAiB,QAAkC,CAAC;AACjE,eAAO,MAAM,0BAA0B,QAA0C,CAAC"}
|
package/dist/config/app-paths.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
export const TRENDIFY_HOME_DIR = join(homedir(), '.trendify');
|
|
4
|
-
export const TRENDIFY_AUTH_DIR = join(TRENDIFY_HOME_DIR, 'auth');
|
|
5
|
-
export const TRENDIFY_AUTH_STORAGE_FILE = join(TRENDIFY_AUTH_DIR, 'storage.json');
|
package/dist/config/env.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type CliEnv = {
|
|
2
|
-
readonly supabasePublishableDefaultKey: string;
|
|
3
|
-
readonly supabaseUrl: string;
|
|
4
|
-
};
|
|
5
|
-
export type EnvValidationResult = {
|
|
6
|
-
readonly ok: true;
|
|
7
|
-
readonly env: CliEnv;
|
|
8
|
-
} | {
|
|
9
|
-
readonly error: string;
|
|
10
|
-
readonly ok: false;
|
|
11
|
-
};
|
|
12
|
-
export declare function getCliEnvValidationResult(): EnvValidationResult;
|
|
13
|
-
export declare const CLI_APP_ROOT_DIRECTORY: string;
|
|
14
|
-
//# sourceMappingURL=env.d.ts.map
|
package/dist/config/env.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;CACpB,CAAC;AAsBN,wBAAgB,yBAAyB,IAAI,mBAAmB,CA+B/D;AAED,eAAO,MAAM,sBAAsB,QAAmB,CAAC"}
|
package/dist/config/env.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { dirname, resolve } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { config as loadEnv } from 'dotenv';
|
|
5
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
6
|
-
const currentDirectory = dirname(currentFilePath);
|
|
7
|
-
const appRootDirectory = resolve(currentDirectory, '..', '..');
|
|
8
|
-
const workspaceRootDirectory = resolve(appRootDirectory, '..', '..');
|
|
9
|
-
const ENV_FILE_PATHS = [
|
|
10
|
-
resolve(appRootDirectory, '.env'),
|
|
11
|
-
resolve(workspaceRootDirectory, '.env'),
|
|
12
|
-
resolve(process.cwd(), '.env'),
|
|
13
|
-
];
|
|
14
|
-
let envLoaded = false;
|
|
15
|
-
function loadCliEnvFiles() {
|
|
16
|
-
if (envLoaded) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
for (const envFilePath of ENV_FILE_PATHS) {
|
|
20
|
-
if (existsSync(envFilePath)) {
|
|
21
|
-
loadEnv({ override: false, path: envFilePath, quiet: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
envLoaded = true;
|
|
25
|
-
}
|
|
26
|
-
function readEnvValue(name) {
|
|
27
|
-
const value = process.env[name]?.trim();
|
|
28
|
-
return value ? value : undefined;
|
|
29
|
-
}
|
|
30
|
-
export function getCliEnvValidationResult() {
|
|
31
|
-
loadCliEnvFiles();
|
|
32
|
-
const supabaseUrl = readEnvValue('SUPABASE_URL');
|
|
33
|
-
const supabasePublishableDefaultKey = readEnvValue('SUPABASE_PUBLISHABLE_DEFAULT_KEY');
|
|
34
|
-
const missingVariables = [
|
|
35
|
-
!supabaseUrl ? 'SUPABASE_URL' : null,
|
|
36
|
-
!supabasePublishableDefaultKey ? 'SUPABASE_PUBLISHABLE_DEFAULT_KEY' : null,
|
|
37
|
-
].filter((value) => Boolean(value));
|
|
38
|
-
if (missingVariables.length > 0) {
|
|
39
|
-
return {
|
|
40
|
-
ok: false,
|
|
41
|
-
error: `Defina ${missingVariables.join(' e ')} antes de iniciar a CLI.`,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (!supabaseUrl || !supabasePublishableDefaultKey) {
|
|
45
|
-
return {
|
|
46
|
-
ok: false,
|
|
47
|
-
error: 'Nao foi possivel validar as variaveis do Supabase.',
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
ok: true,
|
|
52
|
-
env: {
|
|
53
|
-
supabaseUrl,
|
|
54
|
-
supabasePublishableDefaultKey,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export const CLI_APP_ROOT_DIRECTORY = appRootDirectory;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type AuthSession, type AuthUser, type SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { type CliEnv } from '../../config/env.js';
|
|
3
|
-
export type WorkspaceRole = 'admin' | 'member' | 'owner';
|
|
4
|
-
export type WorkspaceMembership = {
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly role: WorkspaceRole;
|
|
8
|
-
readonly slug: string;
|
|
9
|
-
};
|
|
10
|
-
export type AuthSnapshot = {
|
|
11
|
-
readonly activeWorkspace: WorkspaceMembership | null;
|
|
12
|
-
readonly requiresWorkspaceSelection: boolean;
|
|
13
|
-
readonly session: AuthSession | null;
|
|
14
|
-
readonly user: AuthUser | null;
|
|
15
|
-
readonly workspaces: readonly WorkspaceMembership[];
|
|
16
|
-
};
|
|
17
|
-
export type AuthActionResult<TData> = {
|
|
18
|
-
readonly data: TData | null;
|
|
19
|
-
readonly error: string | null;
|
|
20
|
-
readonly errorCode: string | null;
|
|
21
|
-
};
|
|
22
|
-
export type AuthBootstrapResult = {
|
|
23
|
-
readonly authService: AuthService;
|
|
24
|
-
readonly env: CliEnv;
|
|
25
|
-
readonly ok: true;
|
|
26
|
-
} | {
|
|
27
|
-
readonly error: string;
|
|
28
|
-
readonly ok: false;
|
|
29
|
-
};
|
|
30
|
-
export declare class AuthService {
|
|
31
|
-
private readonly client;
|
|
32
|
-
private readonly storage;
|
|
33
|
-
private readonly env;
|
|
34
|
-
private readonly storageFilePath;
|
|
35
|
-
static create(env: CliEnv): AuthService;
|
|
36
|
-
private constructor();
|
|
37
|
-
private activeWorkspaceId;
|
|
38
|
-
getSessionStorageFilePath(): string;
|
|
39
|
-
onAuthStateChange(listener: (snapshot: AuthSnapshot) => void): {
|
|
40
|
-
data: {
|
|
41
|
-
subscription: import("@supabase/supabase-js").Subscription;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
getActiveWorkspaceId(): string | null;
|
|
45
|
-
getWorkspaceScopedClient(): Promise<AuthActionResult<SupabaseClient>>;
|
|
46
|
-
restoreSession(): Promise<AuthActionResult<AuthSnapshot>>;
|
|
47
|
-
signInWithPassword(email: string, password: string): Promise<AuthActionResult<AuthSnapshot>>;
|
|
48
|
-
signOut(): Promise<AuthActionResult<null>>;
|
|
49
|
-
selectWorkspace(workspaceId: string): Promise<AuthActionResult<WorkspaceMembership>>;
|
|
50
|
-
updateDisplayName(displayName: string): Promise<AuthActionResult<AuthUser>>;
|
|
51
|
-
sendPasswordReauthenticationCode(): Promise<AuthActionResult<null>>;
|
|
52
|
-
updatePassword(password: string, nonce?: string): Promise<AuthActionResult<AuthUser>>;
|
|
53
|
-
private buildAuthenticatedSnapshot;
|
|
54
|
-
private listMyWorkspaces;
|
|
55
|
-
private readStoredActiveWorkspaceId;
|
|
56
|
-
private storeActiveWorkspaceId;
|
|
57
|
-
private clearStoredActiveWorkspaceId;
|
|
58
|
-
}
|
|
59
|
-
export declare function getAuthBootstrapResult(): AuthBootstrapResult;
|
|
60
|
-
//# sourceMappingURL=auth-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAA6B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7E,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IA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