@antasphere/chassis-cli 0.0.0-stage → 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 +82 -0
- package/dist/commands/auth.d.ts +6 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +582 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/completion.d.ts +5 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +85 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/demo.d.ts +12 -0
- package/dist/commands/demo.d.ts.map +1 -0
- package/dist/commands/demo.js +210 -0
- package/dist/commands/demo.js.map +1 -0
- package/dist/commands/files.d.ts +21 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +178 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/projects.d.ts +38 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +386 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/teams.d.ts +46 -0
- package/dist/commands/teams.d.ts.map +1 -0
- package/dist/commands/teams.js +265 -0
- package/dist/commands/teams.js.map +1 -0
- package/dist/commands/workspaces.d.ts +22 -0
- package/dist/commands/workspaces.d.ts.map +1 -0
- package/dist/commands/workspaces.js +116 -0
- package/dist/commands/workspaces.js.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +152 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +456 -0
- package/dist/context.js.map +1 -0
- package/dist/identity.d.ts +36 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +18 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.d.ts +46 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.js +2 -0
- package/dist/kit.js.map +1 -0
- package/dist/open.d.ts +27 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +45 -0
- package/dist/open.js.map +1 -0
- package/dist/owner-session.d.ts +34 -0
- package/dist/owner-session.d.ts.map +1 -0
- package/dist/owner-session.js +106 -0
- package/dist/owner-session.js.map +1 -0
- package/dist/program.d.ts +5 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +150 -0
- package/dist/program.js.map +1 -0
- package/dist/safe-write.d.ts +46 -0
- package/dist/safe-write.d.ts.map +1 -0
- package/dist/safe-write.js +127 -0
- package/dist/safe-write.js.map +1 -0
- package/dist/stdin.d.ts +4 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +36 -0
- package/dist/stdin.js.map +1 -0
- package/dist/testing/index.d.ts +70 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +67 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/workspace.d.ts +79 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +139 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +43 -3
- package/src/commands/auth.ts +687 -0
- package/src/commands/completion.ts +102 -0
- package/src/commands/demo.ts +271 -0
- package/src/commands/files.ts +197 -0
- package/src/commands/projects.ts +460 -0
- package/src/commands/teams.ts +320 -0
- package/src/commands/workspaces.ts +140 -0
- package/src/config.ts +81 -0
- package/src/context.ts +616 -0
- package/src/identity.ts +48 -0
- package/src/index.ts +70 -0
- package/src/kit.ts +50 -0
- package/src/open.ts +48 -0
- package/src/owner-session.ts +152 -0
- package/src/program.ts +183 -0
- package/src/safe-write.ts +136 -0
- package/src/stdin.ts +39 -0
- package/src/testing/index.ts +129 -0
- package/src/workspace.ts +229 -0
- package/test/host/identity.test.ts +229 -0
- package/test/host/minimal-host.ts +16 -0
- package/test/host/minimal-tool.ts +40 -0
- package/test/suite/cli.test.ts +301 -0
- package/test/suite/config.test.ts +59 -0
- package/test/suite/demo.test.ts +467 -0
- package/test/suite/hub-profile-shared.test.ts +123 -0
- package/test/suite/login.test.ts +743 -0
- package/test/suite/logout.test.ts +247 -0
- package/test/suite/migration.test.ts +109 -0
- package/test/suite/open.test.ts +59 -0
- package/test/suite/profiles.test.ts +380 -0
- package/test/suite/projects.test.ts +550 -0
- package/test/suite/recovery.test.ts +348 -0
- package/test/suite/security.test.ts +199 -0
- package/test/suite/signin-fixtures.ts +204 -0
- package/test/suite/teams.test.ts +354 -0
- package/test/suite/whoami.test.ts +159 -0
- package/test/suite/workspace.test.ts +402 -0
- package/README.md +0 -3
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { PlatformApiError } from '@antasphere/chassis-sdk';
|
|
2
|
+
import { CliApiRefusal, CliUsageError, drainPages, printJson, table } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* The server's team refusals as sentences. Returns the line, or null when the
|
|
5
|
+
* error is not one of them (the runner's generic handling is then the honest
|
|
6
|
+
* answer).
|
|
7
|
+
*/
|
|
8
|
+
export function explainTeamRefusal(e, ctx) {
|
|
9
|
+
switch (e.code) {
|
|
10
|
+
case 'forbidden':
|
|
11
|
+
return e.status === 403 ? 'Only an owner or an admin manages teams.' : null;
|
|
12
|
+
case 'hub_managed': {
|
|
13
|
+
const url = e.details?.manageUrl;
|
|
14
|
+
return typeof url === 'string' && url
|
|
15
|
+
? `Teams of this workspace are managed on the Antasphere account site: ${url}`
|
|
16
|
+
: 'Teams of this workspace are managed on the Antasphere account site.';
|
|
17
|
+
}
|
|
18
|
+
case 'slug_taken':
|
|
19
|
+
return ctx.slug !== undefined
|
|
20
|
+
? `A team of this workspace already uses the slug "${ctx.slug}".`
|
|
21
|
+
: 'A team of this workspace already uses the slug this name makes; pass --slug.';
|
|
22
|
+
case 'already_member':
|
|
23
|
+
return `${ctx.who ?? 'That person'} is already in this team.`;
|
|
24
|
+
case 'member_not_found':
|
|
25
|
+
return ctx.lookup === 'team-member'
|
|
26
|
+
? 'That person is not a member of this team.'
|
|
27
|
+
: 'No active member of this workspace matches — check the user id or email. Only a member of the workspace can join a team.';
|
|
28
|
+
case 'not_found':
|
|
29
|
+
return 'No such team in this workspace.';
|
|
30
|
+
case 'guest_forbidden':
|
|
31
|
+
return 'You are a guest of this workspace, and guests do not take part in its teams.';
|
|
32
|
+
default:
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Run a team call, turning the known refusals into sentences. */
|
|
37
|
+
export async function explainedTeam(ctx, run) {
|
|
38
|
+
try {
|
|
39
|
+
return await run();
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
if (e instanceof PlatformApiError) {
|
|
43
|
+
const line = explainTeamRefusal(e, ctx);
|
|
44
|
+
if (line)
|
|
45
|
+
throw new CliApiRefusal(line, e.status);
|
|
46
|
+
}
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Every team of the workspace, page after page. */
|
|
51
|
+
export async function allTeams(client) {
|
|
52
|
+
const first = await client.teams();
|
|
53
|
+
return drainPages({ rows: first.teams, nextCursor: first.nextCursor }, async (cursor) => {
|
|
54
|
+
const page = await client.teams({ cursor });
|
|
55
|
+
return { rows: page.teams, nextCursor: page.nextCursor };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
59
|
+
/**
|
|
60
|
+
* A team named by its slug or its id (the hub's `findTeam`). An id is read
|
|
61
|
+
* directly; a slug, or an id the server does not know (a slug may look like
|
|
62
|
+
* one), is looked up in the workspace's list, by slug first, then by id.
|
|
63
|
+
*/
|
|
64
|
+
export async function resolveTeam(client, ref) {
|
|
65
|
+
return explainedTeam({ lookup: 'team' }, async () => {
|
|
66
|
+
if (UUID.test(ref)) {
|
|
67
|
+
try {
|
|
68
|
+
return await client.team(ref);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
if (!(e instanceof PlatformApiError && (e.status === 404 || e.status === 400)))
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const teams = await allTeams(client);
|
|
76
|
+
const team = teams.find((t) => t.slug === ref) ?? teams.find((t) => t.id === ref);
|
|
77
|
+
if (!team)
|
|
78
|
+
throw new CliApiRefusal(`No team of this workspace has the slug or id "${ref}".`, 404);
|
|
79
|
+
return team;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** An `@` makes the argument an email, anything else a user id (as `projects members add`). */
|
|
83
|
+
function personRef(value) {
|
|
84
|
+
return value.includes('@') ? { email: value } : { userId: value };
|
|
85
|
+
}
|
|
86
|
+
/** The date part of an ISO 8601 timestamp (`2026-10-23`). */
|
|
87
|
+
function fmtDate(iso) {
|
|
88
|
+
return iso.slice(0, 10);
|
|
89
|
+
}
|
|
90
|
+
/** A team's name, marked when the Antasphere account site owns it. */
|
|
91
|
+
export function teamName(t) {
|
|
92
|
+
return t.hubTeamId ? `${t.name} (Antasphere)` : t.name;
|
|
93
|
+
}
|
|
94
|
+
/** One team, as the human sees it. */
|
|
95
|
+
function teamLines(t) {
|
|
96
|
+
return (`${teamName(t)}\n` +
|
|
97
|
+
` id: ${t.id}\n` +
|
|
98
|
+
` slug: ${t.slug}\n` +
|
|
99
|
+
` members: ${t.membersCount}\n` +
|
|
100
|
+
` yours: ${t.isMember ? 'yes' : 'no'}\n` +
|
|
101
|
+
(t.hubTeamId ? ` managed: on the Antasphere account site\n` : '') +
|
|
102
|
+
` created: ${t.createdAt}\n`);
|
|
103
|
+
}
|
|
104
|
+
/** Every member of one team, page after page. */
|
|
105
|
+
async function allTeamMembers(client, teamId) {
|
|
106
|
+
const first = await client.teamMembers(teamId);
|
|
107
|
+
return drainPages({ rows: first.members, nextCursor: first.nextCursor }, async (cursor) => {
|
|
108
|
+
const page = await client.teamMembers(teamId, { cursor });
|
|
109
|
+
return { rows: page.members, nextCursor: page.nextCursor };
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function registerTeamCommands(kit, program, io) {
|
|
113
|
+
const { requireApiKey, resolveContext } = kit;
|
|
114
|
+
const teams = program
|
|
115
|
+
.command('teams')
|
|
116
|
+
.description('The teams of the workspace (named groups of its members)')
|
|
117
|
+
.addHelpText('after', '\nEvery member reads the teams; an owner or an admin creates, renames and deletes them and\n' +
|
|
118
|
+
'seats people. In a workspace the Antasphere account site manages, the teams are read here\n' +
|
|
119
|
+
'and managed there.\n');
|
|
120
|
+
// ── teams list ────────────────────────────────────────────────────────────
|
|
121
|
+
teams
|
|
122
|
+
.command('list')
|
|
123
|
+
.description("List the workspace's teams (every page)")
|
|
124
|
+
.action(async (_opts, cmd) => {
|
|
125
|
+
const ctx = resolveContext(cmd, io);
|
|
126
|
+
await requireApiKey(ctx);
|
|
127
|
+
const rows = await explainedTeam({ lookup: 'team' }, () => allTeams(ctx.client));
|
|
128
|
+
if (ctx.json)
|
|
129
|
+
return printJson(io, { teams: rows, nextCursor: null });
|
|
130
|
+
if (rows.length === 0) {
|
|
131
|
+
io.out.write('No teams.\n');
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
io.out.write(table([
|
|
135
|
+
['SLUG', 'NAME', 'MEMBERS', 'YOURS', 'CREATED'],
|
|
136
|
+
...rows.map((t) => [
|
|
137
|
+
t.slug,
|
|
138
|
+
teamName(t),
|
|
139
|
+
String(t.membersCount),
|
|
140
|
+
t.isMember ? 'yes' : 'no',
|
|
141
|
+
fmtDate(t.createdAt)
|
|
142
|
+
])
|
|
143
|
+
]));
|
|
144
|
+
});
|
|
145
|
+
// ── teams get ─────────────────────────────────────────────────────────────
|
|
146
|
+
teams
|
|
147
|
+
.command('get <team>')
|
|
148
|
+
.description('Show one team (<team> is a slug or an id)')
|
|
149
|
+
.action(async (ref, _opts, cmd) => {
|
|
150
|
+
const ctx = resolveContext(cmd, io);
|
|
151
|
+
await requireApiKey(ctx);
|
|
152
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
153
|
+
if (ctx.json)
|
|
154
|
+
return printJson(io, team);
|
|
155
|
+
io.out.write(teamLines(team));
|
|
156
|
+
});
|
|
157
|
+
// ── teams create ──────────────────────────────────────────────────────────
|
|
158
|
+
teams
|
|
159
|
+
.command('create <name>')
|
|
160
|
+
.description('Create a team (owner or admin; the slug is derived from the name when --slug is absent)')
|
|
161
|
+
.option('--slug <slug>', 'the team slug (lowercase words joined by dashes)')
|
|
162
|
+
.action(async (name, opts, cmd) => {
|
|
163
|
+
const ctx = resolveContext(cmd, io);
|
|
164
|
+
await requireApiKey(ctx);
|
|
165
|
+
const team = await explainedTeam({ lookup: 'team', slug: opts.slug || undefined }, () => ctx.client.createTeam({ name, ...(opts.slug ? { slug: opts.slug } : {}) }));
|
|
166
|
+
if (ctx.json)
|
|
167
|
+
return printJson(io, team);
|
|
168
|
+
io.out.write(`Created team ${team.slug}.\n${teamLines(team)}`);
|
|
169
|
+
});
|
|
170
|
+
// ── teams rename ──────────────────────────────────────────────────────────
|
|
171
|
+
teams
|
|
172
|
+
.command('rename <team>')
|
|
173
|
+
.description('Rename a team or change its slug (owner or admin; <team> is a slug or an id)')
|
|
174
|
+
.option('--name <name>', 'the new name')
|
|
175
|
+
.option('--slug <slug>', 'the new slug')
|
|
176
|
+
.action(async (ref, opts, cmd) => {
|
|
177
|
+
if (opts.name === undefined && opts.slug === undefined) {
|
|
178
|
+
throw new CliUsageError('Nothing to change — pass --name <name>, --slug <slug>, or both.');
|
|
179
|
+
}
|
|
180
|
+
const ctx = resolveContext(cmd, io);
|
|
181
|
+
await requireApiKey(ctx);
|
|
182
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
183
|
+
const updated = await explainedTeam({ lookup: 'team', slug: opts.slug }, () => ctx.client.updateTeam(team.id, {
|
|
184
|
+
...(opts.name !== undefined ? { name: opts.name } : {}),
|
|
185
|
+
...(opts.slug !== undefined ? { slug: opts.slug } : {})
|
|
186
|
+
}));
|
|
187
|
+
if (ctx.json)
|
|
188
|
+
return printJson(io, updated);
|
|
189
|
+
io.out.write(`Team ${updated.slug}: ${updated.name}\n`);
|
|
190
|
+
});
|
|
191
|
+
// ── teams delete ──────────────────────────────────────────────────────────
|
|
192
|
+
teams
|
|
193
|
+
.command('delete <team>')
|
|
194
|
+
.description('Delete a team; its members stay in the workspace (owner or admin; <team> is a slug or an id)')
|
|
195
|
+
.option('--yes', 'confirm the deletion', false)
|
|
196
|
+
.action(async (ref, opts, cmd) => {
|
|
197
|
+
if (!opts.yes) {
|
|
198
|
+
throw new CliUsageError(`Deleting a team cannot be undone: rerun with --yes to delete "${ref}".`);
|
|
199
|
+
}
|
|
200
|
+
const ctx = resolveContext(cmd, io);
|
|
201
|
+
await requireApiKey(ctx);
|
|
202
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
203
|
+
const deleted = await explainedTeam({ lookup: 'team' }, () => ctx.client.deleteTeam(team.id));
|
|
204
|
+
if (ctx.json)
|
|
205
|
+
return printJson(io, deleted);
|
|
206
|
+
io.out.write(`Deleted team ${deleted.slug}. Its members stay in the workspace.\n`);
|
|
207
|
+
});
|
|
208
|
+
// ── teams members ─────────────────────────────────────────────────────────
|
|
209
|
+
teams
|
|
210
|
+
.command('members <team>')
|
|
211
|
+
.description("List a team's members (every page; <team> is a slug or an id)")
|
|
212
|
+
.action(async (ref, _opts, cmd) => {
|
|
213
|
+
const ctx = resolveContext(cmd, io);
|
|
214
|
+
await requireApiKey(ctx);
|
|
215
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
216
|
+
const rows = await explainedTeam({ lookup: 'team' }, () => allTeamMembers(ctx.client, team.id));
|
|
217
|
+
if (ctx.json)
|
|
218
|
+
return printJson(io, { members: rows, nextCursor: null });
|
|
219
|
+
if (rows.length === 0) {
|
|
220
|
+
io.out.write(`Team ${team.slug} has no members.\n`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
io.out.write(table([
|
|
224
|
+
['USER ID', 'EMAIL', 'ROLE', 'ADDED', 'NAME'],
|
|
225
|
+
...rows.map((m) => [m.userId, m.email, m.role, fmtDate(m.addedAt), m.name || '-'])
|
|
226
|
+
]));
|
|
227
|
+
});
|
|
228
|
+
// ── teams add ─────────────────────────────────────────────────────────────
|
|
229
|
+
teams
|
|
230
|
+
.command('add <team> <userIdOrEmail>')
|
|
231
|
+
.description('Seat a member of the workspace in a team (owner or admin; an @ makes it an email)')
|
|
232
|
+
.action(async (ref, who, _opts, cmd) => {
|
|
233
|
+
const ctx = resolveContext(cmd, io);
|
|
234
|
+
await requireApiKey(ctx);
|
|
235
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
236
|
+
const added = await explainedTeam({ lookup: 'workspace-member', who }, () => ctx.client.addTeamMember(team.id, personRef(who)));
|
|
237
|
+
if (ctx.json)
|
|
238
|
+
return printJson(io, added);
|
|
239
|
+
io.out.write(`Added ${added.name} <${added.email}> to team ${team.slug}.\n`);
|
|
240
|
+
});
|
|
241
|
+
// ── teams remove ──────────────────────────────────────────────────────────
|
|
242
|
+
teams
|
|
243
|
+
.command('remove <team> <userIdOrEmail>')
|
|
244
|
+
.description('Remove a member from a team; they stay in the workspace (owner or admin)')
|
|
245
|
+
.action(async (ref, who, _opts, cmd) => {
|
|
246
|
+
const ctx = resolveContext(cmd, io);
|
|
247
|
+
await requireApiKey(ctx);
|
|
248
|
+
const team = await resolveTeam(ctx.client, ref);
|
|
249
|
+
// The route takes a user id; an email is looked up among the team's members.
|
|
250
|
+
let userId = who;
|
|
251
|
+
if (who.includes('@')) {
|
|
252
|
+
const wanted = who.trim().toLowerCase();
|
|
253
|
+
const members = await explainedTeam({ lookup: 'team' }, () => allTeamMembers(ctx.client, team.id));
|
|
254
|
+
const hit = members.find((m) => m.email.toLowerCase() === wanted);
|
|
255
|
+
if (!hit)
|
|
256
|
+
throw new CliApiRefusal('That person is not a member of this team.', 404);
|
|
257
|
+
userId = hit.userId;
|
|
258
|
+
}
|
|
259
|
+
const removed = await explainedTeam({ lookup: 'team-member', who }, () => ctx.client.removeTeamMember(team.id, userId));
|
|
260
|
+
if (ctx.json)
|
|
261
|
+
return printJson(io, removed);
|
|
262
|
+
io.out.write(`Removed ${removed.name} <${removed.email}> from team ${team.slug}.\n`);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/commands/teams.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,eAAe,CAAC;AA2BvG;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAmB,EAAE,GAAuB;IAC7E,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9E,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,GAAG,GAAI,CAAC,CAAC,OAA+C,EAAE,SAAS,CAAC;YAC1E,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG;gBACnC,CAAC,CAAC,uEAAuE,GAAG,EAAE;gBAC9E,CAAC,CAAC,qEAAqE,CAAC;QAC5E,CAAC;QACD,KAAK,YAAY;YACf,OAAO,GAAG,CAAC,IAAI,KAAK,SAAS;gBAC3B,CAAC,CAAC,mDAAmD,GAAG,CAAC,IAAI,IAAI;gBACjE,CAAC,CAAC,8EAA8E,CAAC;QACrF,KAAK,gBAAgB;YACnB,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,aAAa,2BAA2B,CAAC;QAChE,KAAK,kBAAkB;YACrB,OAAO,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QAChD,6EAA6E;QAC7E,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACnG,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC;YAClE,IAAI,CAAC,GAAG;gBAAE,MAAM,IAAI,aAAa,CAAC,2CAA2C,EAAE,GAAG,CAAC,CAAC;YACpF,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACtB,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CACvE,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAC7C,CAAC;QACF,IAAI,GAAG,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAC5C,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,KAAK,eAAe,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type ChassisClient } from '@antasphere/chassis-sdk';
|
|
3
|
+
import { type CliIo } from '../context.js';
|
|
4
|
+
import type { CliKit } from '../kit.js';
|
|
5
|
+
/**
|
|
6
|
+
* Which workspace the commands run in (PRDCT-2419, PRDCT-2947): `workspaces`
|
|
7
|
+
* lists the memberships with the organization ids `--org` takes, and
|
|
8
|
+
* `workspace default` (PRDCT-2815) sets what the SERVER resolves for the
|
|
9
|
+
* person when a request names none, for every credential of theirs: set
|
|
10
|
+
* here on a self-hosted instance; on the cloud it is a setting of the
|
|
11
|
+
* Antasphere account, and the refusal names the page. Nothing is saved on
|
|
12
|
+
* this machine: a command names its organization with `--org` or its
|
|
13
|
+
* workspace with `--workspace`, or runs in the default (one organization
|
|
14
|
+
* notion, the hub's).
|
|
15
|
+
*
|
|
16
|
+
* Both talk to `/me` WITHOUT the selection (`workspace: false`): they are the
|
|
17
|
+
* commands a person repairs a stale selection with, so a selection the
|
|
18
|
+
* server refuses must never stop them. There is deliberately no
|
|
19
|
+
* `workspaces create`: `POST /workspaces` is a session-only act.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerWorkspaceCommands<TClient extends ChassisClient<string>>(kit: CliKit<TClient>, program: Command, io: CliIo): void;
|
|
22
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/commands/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAA2C,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,aAAa,CAAC,MAAM,CAAC,EAC7E,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,EACpB,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,KAAK,GACR,IAAI,CAgHN"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PlatformApiError } from '@antasphere/chassis-sdk';
|
|
2
|
+
import { CliApiRefusal, CliUsageError, printJson } from '../context.js';
|
|
3
|
+
import { findWorkspace, matchWorkspace } from '../workspace.js';
|
|
4
|
+
/**
|
|
5
|
+
* Which workspace the commands run in (PRDCT-2419, PRDCT-2947): `workspaces`
|
|
6
|
+
* lists the memberships with the organization ids `--org` takes, and
|
|
7
|
+
* `workspace default` (PRDCT-2815) sets what the SERVER resolves for the
|
|
8
|
+
* person when a request names none, for every credential of theirs: set
|
|
9
|
+
* here on a self-hosted instance; on the cloud it is a setting of the
|
|
10
|
+
* Antasphere account, and the refusal names the page. Nothing is saved on
|
|
11
|
+
* this machine: a command names its organization with `--org` or its
|
|
12
|
+
* workspace with `--workspace`, or runs in the default (one organization
|
|
13
|
+
* notion, the hub's).
|
|
14
|
+
*
|
|
15
|
+
* Both talk to `/me` WITHOUT the selection (`workspace: false`): they are the
|
|
16
|
+
* commands a person repairs a stale selection with, so a selection the
|
|
17
|
+
* server refuses must never stop them. There is deliberately no
|
|
18
|
+
* `workspaces create`: `POST /workspaces` is a session-only act.
|
|
19
|
+
*/
|
|
20
|
+
export function registerWorkspaceCommands(kit, program, io) {
|
|
21
|
+
const { requireApiKey, resolveContext, workspaceSource } = kit;
|
|
22
|
+
const { describeSelection } = kit.workspace;
|
|
23
|
+
program
|
|
24
|
+
.command('workspaces')
|
|
25
|
+
.description('List your workspaces (the one the commands run in marked *)')
|
|
26
|
+
.action(async (_opts, cmd) => {
|
|
27
|
+
const ctx = resolveContext(cmd, io);
|
|
28
|
+
await requireApiKey(ctx, { workspace: false });
|
|
29
|
+
const me = await ctx.client.me();
|
|
30
|
+
const selection = ctx.workspaceSelection;
|
|
31
|
+
const source = workspaceSource(ctx);
|
|
32
|
+
// With a selection, the mark is the membership it names; without one,
|
|
33
|
+
// the workspace the server resolved (its default, or the key's pin).
|
|
34
|
+
const selected = selection
|
|
35
|
+
? (findWorkspace(me.workspaces, selection.value).match?.id ?? null)
|
|
36
|
+
: me.activeWorkspaceId;
|
|
37
|
+
if (selection && selected === null) {
|
|
38
|
+
io.err.write(`Warning: "${selection.value}" (selected by ${describeSelection(selection)}) names none of these ` +
|
|
39
|
+
'workspaces, so commands that use it are refused.\n');
|
|
40
|
+
}
|
|
41
|
+
if (ctx.json) {
|
|
42
|
+
return printJson(io, { workspaces: me.workspaces, selectedWorkspaceId: selected, source });
|
|
43
|
+
}
|
|
44
|
+
if (me.workspaces.length === 0) {
|
|
45
|
+
io.out.write('No workspaces.\n');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let anyOrg = false;
|
|
49
|
+
for (const w of me.workspaces) {
|
|
50
|
+
const org = w.centralAccountId ?? null;
|
|
51
|
+
if (org)
|
|
52
|
+
anyOrg = true;
|
|
53
|
+
const flags = [w.default ? '(default)' : null, w.suspended ? '[suspended]' : null]
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.join(' ');
|
|
56
|
+
io.out.write(`${w.id === selected ? '*' : ' '} ${w.id} ${w.role.padEnd(6)} ${w.name}${flags ? ` ${flags}` : ''}` +
|
|
57
|
+
`${org ? ` organization ${org}` : ''}\n`);
|
|
58
|
+
}
|
|
59
|
+
const chosenBy = !selection
|
|
60
|
+
? 'the server (nothing is selected; --org or --workspace selects one per command)'
|
|
61
|
+
: selected === null
|
|
62
|
+
? `${describeSelection(selection)}; none is marked, the selection names none of these`
|
|
63
|
+
: describeSelection(selection);
|
|
64
|
+
io.out.write(`\n* = the workspace the commands run in, chosen by ${chosenBy}\n` +
|
|
65
|
+
(me.workspaces.some((w) => w.default)
|
|
66
|
+
? '(default) = what a request naming no workspace resolves to\n'
|
|
67
|
+
: '') +
|
|
68
|
+
(anyOrg ? 'organization = the Antasphere id --org takes (or its name)\n' : ''));
|
|
69
|
+
});
|
|
70
|
+
const workspace = program
|
|
71
|
+
.command('workspace')
|
|
72
|
+
.description('Your default workspace: what the server uses when a command names none');
|
|
73
|
+
workspace
|
|
74
|
+
.command('default [workspace]')
|
|
75
|
+
.description('Choose the workspace (id or name) the server uses when a command names none')
|
|
76
|
+
.option('--clear', 'remove the choice (back to the workspace you joined first)', false)
|
|
77
|
+
.action(async (value, opts, cmd) => {
|
|
78
|
+
if ((value !== undefined) === opts.clear) {
|
|
79
|
+
throw new CliUsageError('Pass exactly one of <workspace> (an id or a name) or --clear.');
|
|
80
|
+
}
|
|
81
|
+
const ctx = resolveContext(cmd, io);
|
|
82
|
+
await requireApiKey(ctx, { workspace: false });
|
|
83
|
+
const target = opts.clear ? null : matchWorkspace((await ctx.client.me()).workspaces, value);
|
|
84
|
+
try {
|
|
85
|
+
await ctx.client.setDefaultWorkspace(target?.id ?? null);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
if (e instanceof PlatformApiError && e.code === 'hub_managed') {
|
|
89
|
+
const url = e.details?.manageUrl;
|
|
90
|
+
throw new CliApiRefusal('Your default workspace is a setting of your Antasphere account' +
|
|
91
|
+
(typeof url === 'string' && url ? `: choose it on ${url}` : '.') +
|
|
92
|
+
'\nTo run one command elsewhere, pass --org <organization id or name>.', e.status);
|
|
93
|
+
}
|
|
94
|
+
if (e instanceof PlatformApiError && e.code === 'key_pinned') {
|
|
95
|
+
throw new CliApiRefusal('This key is pinned to one workspace and cannot change your default workspace. Use a key that is not pinned.', e.status);
|
|
96
|
+
}
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
if (ctx.json) {
|
|
100
|
+
return printJson(io, {
|
|
101
|
+
defaultWorkspaceId: target?.id ?? null,
|
|
102
|
+
...(target ? { workspace: { id: target.id, name: target.name, role: target.role } } : {})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
io.out.write(target
|
|
106
|
+
? `"${target.name}" (${target.id}) is now your default workspace: a command naming none runs in it.\n`
|
|
107
|
+
: 'No default workspace is chosen: a command naming none runs in the workspace you joined first.\n');
|
|
108
|
+
// A selection still wins over the server's default; say so rather than
|
|
109
|
+
// let the next command land somewhere else in silence.
|
|
110
|
+
const selection = ctx.workspaceSelection;
|
|
111
|
+
if (selection && (!target || findWorkspace([target], selection.value).match === null)) {
|
|
112
|
+
io.err.write(`Note: ${describeSelection(selection)} selects another workspace and wins over the default while it is set.\n`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/commands/workspaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,UAAU,yBAAyB,CACvC,GAAoB,EACpB,OAAgB,EAChB,EAAS;IAET,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC;IAC/D,MAAM,EAAE,iBAAiB,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC;IAE5C,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,6DAA6D,CAAC;SAC1E,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;QACpC,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACpC,MAAM,aAAa,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,GAAG,CAAC,kBAAkB,CAAC;QACzC,MAAM,MAAM,G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MAAM,CAAC,CAAC;QACV,CAAC;QACD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,EAAE,EAAE;gBACnB,kBAAkB,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI;gBACtC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1F,CAAC,CAAC;QACL,CAAC;QACD,EAAE,CAAC,GAAG,CAAC,KAAK,CACV,MAAM;YACJ,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,MAAM,CAAC,EAAE,sEAAsE;YACtG,CAAC,CAAC,iGAAiG,CACtG,CAAC;QACF,uEAAuE;QACvE,uDAAuD;QACvD,MAAM,SAAS,GAAG,GAAG,CAAC,kBAAkB,CAAC;QACzC,IAAI,SAAS,IAAI,CAAC,CAAC,MAAM,IAAI,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAC;YACtF,EAAE,CAAC,GAAG,CAAC,KAAK,CACV,SAAS,iBAAiB,CAAC,SAAS,CAAC,yEAAyE,CAC/G,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CliConfig, type CliEnv } from '@antasphere/cli-core';
|
|
2
|
+
import type { CliIdentity } from './identity.js';
|
|
3
|
+
/**
|
|
4
|
+
* The tool CLI's profiles live in the tool's own namespace (`identity.tool`)
|
|
5
|
+
* of the shared Antasphere config home owned by @antasphere/cli-core:
|
|
6
|
+
* `$XDG_CONFIG_HOME/antasphere/tools/<tool>.json` (default
|
|
7
|
+
* `~/.config/antasphere/tools/<tool>.json`), 0700 dirs / 0600 file, fully
|
|
8
|
+
* env-injected. The store's behavior (multi-profile, activeProfile, tolerant
|
|
9
|
+
* parsing) is byte-for-byte the old local one — cli-core was extracted from
|
|
10
|
+
* it.
|
|
11
|
+
*
|
|
12
|
+
* Migration: the pre-cli-core config lived at
|
|
13
|
+
* `$XDG_CONFIG_HOME/<legacyConfigDir>/config.json`. On any config read, if that file
|
|
14
|
+
* still exists, holds at least one profile, and the shared home has no
|
|
15
|
+
* profiles of the tool yet, it is imported once, NON-destructively (the legacy
|
|
16
|
+
* file stays in place for older CLI builds; it just stops being read).
|
|
17
|
+
*/
|
|
18
|
+
export { redactKey } from '@antasphere/cli-core';
|
|
19
|
+
export type { CliConfig, CliConnectKey, CliEnv, CliProfile } from '@antasphere/cli-core';
|
|
20
|
+
/** The config functions of one tool (its namespace, its legacy directory). */
|
|
21
|
+
export interface CliConfigStore {
|
|
22
|
+
configPath(env: CliEnv): string | null;
|
|
23
|
+
loadConfig(env: CliEnv): CliConfig;
|
|
24
|
+
saveConfig(env: CliEnv, config: CliConfig): string;
|
|
25
|
+
clearConfig(env: CliEnv): void;
|
|
26
|
+
removeConnectKey(env: CliEnv, profileName: string, hubProfileName: string): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function createConfig(identity: CliIdentity): CliConfigStore;
|
|
29
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEzF,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;IACnD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;CACrF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,cAAc,CAwClE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { clearConfig as coreClearConfig, configPath as coreConfigPath, loadConfig as coreLoadConfig, migrateLegacyConfig, removeConnectKey as coreRemoveConnectKey, saveConfig as coreSaveConfig } from '@antasphere/cli-core';
|
|
2
|
+
/**
|
|
3
|
+
* The tool CLI's profiles live in the tool's own namespace (`identity.tool`)
|
|
4
|
+
* of the shared Antasphere config home owned by @antasphere/cli-core:
|
|
5
|
+
* `$XDG_CONFIG_HOME/antasphere/tools/<tool>.json` (default
|
|
6
|
+
* `~/.config/antasphere/tools/<tool>.json`), 0700 dirs / 0600 file, fully
|
|
7
|
+
* env-injected. The store's behavior (multi-profile, activeProfile, tolerant
|
|
8
|
+
* parsing) is byte-for-byte the old local one — cli-core was extracted from
|
|
9
|
+
* it.
|
|
10
|
+
*
|
|
11
|
+
* Migration: the pre-cli-core config lived at
|
|
12
|
+
* `$XDG_CONFIG_HOME/<legacyConfigDir>/config.json`. On any config read, if that file
|
|
13
|
+
* still exists, holds at least one profile, and the shared home has no
|
|
14
|
+
* profiles of the tool yet, it is imported once, NON-destructively (the legacy
|
|
15
|
+
* file stays in place for older CLI builds; it just stops being read).
|
|
16
|
+
*/
|
|
17
|
+
export { redactKey } from '@antasphere/cli-core';
|
|
18
|
+
export function createConfig(identity) {
|
|
19
|
+
const TOOL = identity.tool;
|
|
20
|
+
const LEGACY = { tool: TOOL, legacyDir: identity.legacyConfigDir };
|
|
21
|
+
/** Where the config lives for this environment; null when no home is known. */
|
|
22
|
+
function configPath(env) {
|
|
23
|
+
return coreConfigPath(env, TOOL);
|
|
24
|
+
}
|
|
25
|
+
/** Load the config (after the one-shot legacy import); corrupt/missing = empty. */
|
|
26
|
+
function loadConfig(env) {
|
|
27
|
+
try {
|
|
28
|
+
migrateLegacyConfig(env, LEGACY);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// A failed import must never break a read — worst case the user signs
|
|
32
|
+
// in again; the legacy file is untouched either way.
|
|
33
|
+
}
|
|
34
|
+
return coreLoadConfig(env, TOOL);
|
|
35
|
+
}
|
|
36
|
+
/** Persist the config (0700 dirs / 0600 file). Throws when no home is known. */
|
|
37
|
+
function saveConfig(env, config) {
|
|
38
|
+
return coreSaveConfig(env, TOOL, config);
|
|
39
|
+
}
|
|
40
|
+
/** Delete the config file (config clear). No-op when absent. */
|
|
41
|
+
function clearConfig(env) {
|
|
42
|
+
coreClearConfig(env, TOOL);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Drop one hub profile's cached connect key from a profile (the hub-connect
|
|
46
|
+
* logout — cli-core config.ts `connectKeys`; the key is USER-scoped, one per
|
|
47
|
+
* hub profile, valid for every org).
|
|
48
|
+
*/
|
|
49
|
+
function removeConnectKey(env, profileName, hubProfileName) {
|
|
50
|
+
return coreRemoveConnectKey(env, TOOL, profileName, hubProfileName);
|
|
51
|
+
}
|
|
52
|
+
return { configPath, loadConfig, saveConfig, clearConfig, removeConnectKey };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sour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