@uniformdev/cli 20.50.2 → 20.50.3-alpha.6

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 (2) hide show
  1. package/dist/index.mjs +24 -41
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -150,10 +150,10 @@ var createClient = (baseUrl, authToken) => {
150
150
  );
151
151
  }
152
152
  };
153
- const requestJson = async (path8, opts, schema2, allowedNon2xxStatusCodes = []) => {
153
+ const requestJson = async (path8, opts, schema, allowedNon2xxStatusCodes = []) => {
154
154
  const res = await request2(path8, opts, allowedNon2xxStatusCodes);
155
155
  const data = await res.json();
156
- const parseResult = schema2.safeParse(data);
156
+ const parseResult = schema.safeParse(data);
157
157
  if (parseResult.success) {
158
158
  return parseResult.data;
159
159
  } else {
@@ -447,7 +447,7 @@ async function chooseExistingProject({
447
447
  teamId,
448
448
  user
449
449
  }) {
450
- const projects = (user.teams.find((t) => t.team.id === teamId)?.team.sites ?? []).map((t) => ({
450
+ const projects = (user.teams.find((t) => t.id === teamId)?.projects ?? []).map((t) => ({
451
451
  name: t.name,
452
452
  value: t.id
453
453
  }));
@@ -1033,8 +1033,8 @@ async function chooseTeam(user, prompt, telemetry) {
1033
1033
  const teamId = await select3({
1034
1034
  message: prompt,
1035
1035
  choices: user.teams.map((team) => ({
1036
- name: team.team.name,
1037
- value: team.team.id
1036
+ name: team.name,
1037
+ value: team.id
1038
1038
  }))
1039
1039
  });
1040
1040
  telemetry.send("team picked", { teamId });
@@ -1042,56 +1042,39 @@ async function chooseTeam(user, prompt, telemetry) {
1042
1042
  }
1043
1043
 
1044
1044
  // src/auth/user-info.ts
1045
+ import { ProjectClient } from "@uniformdev/canvas";
1045
1046
  import { gql, request } from "graphql-request";
1046
1047
  import * as z2 from "zod/v3";
1047
- var query = gql`
1048
- query GetUserInfo($subject: String!) {
1048
+ var identityQuery = gql`
1049
+ query GetUserIdentity($subject: String!) {
1049
1050
  info: identities_by_pk(subject: $subject) {
1050
1051
  name
1051
1052
  email_address
1052
- teams: organizations_identities(order_by: { organization: { name: asc } }) {
1053
- team: organization {
1054
- name
1055
- id
1056
- sites {
1057
- name
1058
- id
1059
- }
1060
- }
1061
- }
1062
1053
  }
1063
1054
  }
1064
1055
  `;
1065
- var schema = z2.object({
1056
+ var identitySchema = z2.object({
1066
1057
  info: z2.object({
1067
1058
  name: z2.string().min(1),
1068
- email_address: z2.string().min(1).nullable(),
1069
- teams: z2.array(
1070
- z2.object({
1071
- team: z2.object({
1072
- name: z2.string().min(1),
1073
- id: z2.string().min(1),
1074
- sites: z2.array(
1075
- z2.object({
1076
- name: z2.string().min(1),
1077
- id: z2.string().min(1)
1078
- })
1079
- )
1080
- })
1081
- })
1082
- )
1059
+ email_address: z2.string().min(1).nullable()
1083
1060
  })
1084
1061
  });
1085
1062
  var getUserInfo = async (baseUrl, authToken, subject) => {
1086
1063
  try {
1087
- const endpoint = makeUrl(baseUrl, "/v1/graphql");
1088
- const res = await request(endpoint, query, { subject }, { Authorization: `Bearer ${authToken}` });
1089
- const parseResult = schema.safeParse(res);
1090
- if (parseResult.success) {
1091
- return parseResult.data.info;
1092
- } else {
1093
- throw new Error(`Invalid GraphQL response: ${parseResult.error.message}`);
1064
+ const headers = { Authorization: `Bearer ${authToken}` };
1065
+ const projectClient = new ProjectClient({ apiHost: baseUrl, bearerToken: authToken });
1066
+ const [identityRes, projectsRes] = await Promise.all([
1067
+ request(makeUrl(baseUrl, "/v1/graphql"), identityQuery, { subject }, headers),
1068
+ projectClient.getProjects()
1069
+ ]);
1070
+ const identityParsed = identitySchema.safeParse(identityRes);
1071
+ if (!identityParsed.success) {
1072
+ throw new Error(`Invalid identity response: ${identityParsed.error.message}`);
1094
1073
  }
1074
+ return {
1075
+ ...identityParsed.data.info,
1076
+ teams: projectsRes.teams
1077
+ };
1095
1078
  } catch (err) {
1096
1079
  throw new Error(`Failed to fetch user account:
1097
1080
  ${err.message}`);
@@ -1556,7 +1539,7 @@ Selected agent: ${agentType}`));
1556
1539
  if (isNonInteractive) {
1557
1540
  console.log(`\u{1F3E2} Team ID: ${teamId}`);
1558
1541
  } else {
1559
- console.log(`\u{1F3E2} Team: ${user.teams.find((t) => t.team.id === teamId)?.team.name}`);
1542
+ console.log(`\u{1F3E2} Team: ${user.teams.find((t) => t.id === teamId)?.name}`);
1560
1543
  }
1561
1544
  console.log(`\u{1F4E6} Project: ${projectName} (${projectId})`);
1562
1545
  if (agentType === "cursor") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.50.2",
3
+ "version": "20.50.3-alpha.6+3ffd0d8a44",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -28,13 +28,13 @@
28
28
  "dependencies": {
29
29
  "@inquirer/prompts": "^7.10.1",
30
30
  "@thi.ng/mime": "^2.2.23",
31
- "@uniformdev/assets": "20.50.2",
32
- "@uniformdev/canvas": "20.50.2",
33
- "@uniformdev/context": "20.50.2",
34
- "@uniformdev/files": "20.50.2",
35
- "@uniformdev/project-map": "20.50.2",
36
- "@uniformdev/redirect": "20.50.2",
37
- "@uniformdev/richtext": "20.50.2",
31
+ "@uniformdev/assets": "20.50.3-alpha.6+3ffd0d8a44",
32
+ "@uniformdev/canvas": "20.50.3-alpha.6+3ffd0d8a44",
33
+ "@uniformdev/context": "20.50.3-alpha.6+3ffd0d8a44",
34
+ "@uniformdev/files": "20.50.3-alpha.6+3ffd0d8a44",
35
+ "@uniformdev/project-map": "20.50.3-alpha.6+3ffd0d8a44",
36
+ "@uniformdev/redirect": "20.50.3-alpha.6+3ffd0d8a44",
37
+ "@uniformdev/richtext": "20.50.3-alpha.6+3ffd0d8a44",
38
38
  "call-bind": "^1.0.2",
39
39
  "colorette": "2.0.20",
40
40
  "cosmiconfig": "9.0.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "fe4b29739822916548656e4b61d51faeab3340b5"
84
+ "gitHead": "3ffd0d8a44f3ab6b90835250a33f61db016e9e19"
85
85
  }