@keystrokehq/cli 0.0.134 → 0.0.136
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/index.mjs +38 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2105,7 +2105,6 @@ const UserOrganizationSchema = object({
|
|
|
2105
2105
|
});
|
|
2106
2106
|
const ActiveOrganizationResponseSchema = object({ organization: UserOrganizationSchema.nullable() });
|
|
2107
2107
|
const ListOrganizationsResponseSchema = object({ organizations: array(UserOrganizationSchema) });
|
|
2108
|
-
const SetActiveOrganizationRequestSchema = object({ organizationId: string().min(1) });
|
|
2109
2108
|
const CreateOrganizationRequestSchema = object({
|
|
2110
2109
|
name: string().trim().min(1),
|
|
2111
2110
|
/** Format-only at the wire boundary; reserved-name checks run in platform-database. */
|
|
@@ -5071,10 +5070,22 @@ function createHealthResource(http) {
|
|
|
5071
5070
|
} };
|
|
5072
5071
|
}
|
|
5073
5072
|
function createOrganizationsResource(http, options = {}) {
|
|
5073
|
+
async function get(organizationId) {
|
|
5074
|
+
try {
|
|
5075
|
+
const data = await http.get(`/api/organizations/${organizationId}`).json();
|
|
5076
|
+
const organization = ActiveOrganizationResponseSchema.parse(data).organization;
|
|
5077
|
+
if (!organization) throw new Error("Organization was not returned");
|
|
5078
|
+
return organization;
|
|
5079
|
+
} catch (error) {
|
|
5080
|
+
throw await toPlatformError(error);
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5074
5083
|
async function update(input) {
|
|
5075
5084
|
const body = UpdateOrganizationRequestSchema.parse(input);
|
|
5085
|
+
const organizationId = options.getActiveOrganizationId?.();
|
|
5086
|
+
if (!organizationId) throw new Error("No active organization");
|
|
5076
5087
|
try {
|
|
5077
|
-
const data = await http.patch(
|
|
5088
|
+
const data = await http.patch(`/api/organizations/${organizationId}`, { json: body }).json();
|
|
5078
5089
|
const organization = ActiveOrganizationResponseSchema.parse(data).organization;
|
|
5079
5090
|
if (!organization) throw new Error("Active organization was not returned");
|
|
5080
5091
|
return organization;
|
|
@@ -5091,34 +5102,27 @@ function createOrganizationsResource(http, options = {}) {
|
|
|
5091
5102
|
throw await toPlatformError(error);
|
|
5092
5103
|
}
|
|
5093
5104
|
},
|
|
5105
|
+
get,
|
|
5094
5106
|
async getActive() {
|
|
5107
|
+
const organizationId = options.getActiveOrganizationId?.();
|
|
5108
|
+
if (!organizationId) return null;
|
|
5095
5109
|
try {
|
|
5096
|
-
|
|
5097
|
-
return ActiveOrganizationResponseSchema.parse(data).organization;
|
|
5110
|
+
return await get(organizationId);
|
|
5098
5111
|
} catch (error) {
|
|
5099
|
-
if (
|
|
5100
|
-
|
|
5112
|
+
if (error instanceof PlatformError && (error.status === 401 || error.status === 403)) return null;
|
|
5113
|
+
if (isHTTPError(error) && (error.response.status === 401 || error.response.status === 403)) return null;
|
|
5114
|
+
throw error instanceof PlatformError ? error : await toPlatformError(error);
|
|
5101
5115
|
}
|
|
5102
5116
|
},
|
|
5103
5117
|
async setActive(input) {
|
|
5104
|
-
const
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
options.onActiveOrganizationChange?.(organization.organization.id);
|
|
5110
|
-
return organization;
|
|
5111
|
-
} catch (error) {
|
|
5112
|
-
throw await toPlatformError(error);
|
|
5113
|
-
}
|
|
5118
|
+
const organizationId = input.organizationId.trim();
|
|
5119
|
+
if (!organizationId) throw new Error("Organization id is required");
|
|
5120
|
+
const membership = await get(organizationId);
|
|
5121
|
+
options.onActiveOrganizationChange?.(organizationId);
|
|
5122
|
+
return membership;
|
|
5114
5123
|
},
|
|
5115
5124
|
async clearActive() {
|
|
5116
|
-
|
|
5117
|
-
await http.delete("/api/organizations/active");
|
|
5118
|
-
options.onActiveOrganizationChange?.(null);
|
|
5119
|
-
} catch (error) {
|
|
5120
|
-
throw await toPlatformError(error);
|
|
5121
|
-
}
|
|
5125
|
+
options.onActiveOrganizationChange?.(null);
|
|
5122
5126
|
},
|
|
5123
5127
|
update,
|
|
5124
5128
|
async create(input) {
|
|
@@ -5130,9 +5134,9 @@ function createOrganizationsResource(http, options = {}) {
|
|
|
5130
5134
|
throw await toPlatformError(error);
|
|
5131
5135
|
}
|
|
5132
5136
|
},
|
|
5133
|
-
async checkSlug(slug,
|
|
5137
|
+
async checkSlug(slug, slugOptions = {}) {
|
|
5134
5138
|
const searchParams = new URLSearchParams({ slug });
|
|
5135
|
-
if (
|
|
5139
|
+
if (slugOptions.excludeOrganizationId) searchParams.set("excludeOrganizationId", slugOptions.excludeOrganizationId);
|
|
5136
5140
|
try {
|
|
5137
5141
|
const data = await http.get(`/api/organizations/slug-available?${searchParams}`).json();
|
|
5138
5142
|
return SlugAvailabilityResponseSchema.parse(data);
|
|
@@ -7740,19 +7744,24 @@ async function presignPutAndFinalize(input) {
|
|
|
7740
7744
|
throw await input.toPlatformError(error);
|
|
7741
7745
|
}
|
|
7742
7746
|
}
|
|
7743
|
-
function createOrganizationSidebarBrandingResource(http) {
|
|
7747
|
+
function createOrganizationSidebarBrandingResource(http, options = {}) {
|
|
7748
|
+
function brandingPath() {
|
|
7749
|
+
const organizationId = options.getActiveOrganizationId?.();
|
|
7750
|
+
if (!organizationId) throw new Error("No active organization");
|
|
7751
|
+
return `/api/organizations/${organizationId}/branding`;
|
|
7752
|
+
}
|
|
7744
7753
|
async function presignLogoUpload(variant, contentType) {
|
|
7745
7754
|
const body = PresignOrgLogoRequestSchema.parse({
|
|
7746
7755
|
variant,
|
|
7747
7756
|
contentType
|
|
7748
7757
|
});
|
|
7749
|
-
const data = await http.post(
|
|
7758
|
+
const data = await http.post(`${brandingPath()}/logo/presign`, { json: body }).json();
|
|
7750
7759
|
return PresignOrgLogoResponseSchema.parse(data);
|
|
7751
7760
|
}
|
|
7752
7761
|
return {
|
|
7753
7762
|
async get() {
|
|
7754
7763
|
try {
|
|
7755
|
-
const data = await http.get(
|
|
7764
|
+
const data = await http.get(brandingPath()).json();
|
|
7756
7765
|
return OrganizationSidebarBrandingSchema.parse(data);
|
|
7757
7766
|
} catch (error) {
|
|
7758
7767
|
throw await toPlatformError(error);
|
|
@@ -7779,7 +7788,7 @@ function createOrganizationSidebarBrandingResource(http) {
|
|
|
7779
7788
|
async update(patch) {
|
|
7780
7789
|
const body = OrganizationSidebarBrandingPatchSchema.parse(patch);
|
|
7781
7790
|
try {
|
|
7782
|
-
const data = await http.patch(
|
|
7791
|
+
const data = await http.patch(brandingPath(), { json: body }).json();
|
|
7783
7792
|
return OrganizationSidebarBrandingSchema.parse(data);
|
|
7784
7793
|
} catch (error) {
|
|
7785
7794
|
throw await toPlatformError(error);
|
|
@@ -8596,7 +8605,7 @@ function createPlatformClient(options) {
|
|
|
8596
8605
|
recents: createRecentsResource(http),
|
|
8597
8606
|
userPreferences: createUserPreferencesResource({ getCurrentUserId: options.getCurrentUserId }),
|
|
8598
8607
|
userAvatar: createUserAvatarResource(http),
|
|
8599
|
-
organizationSidebarBranding: createOrganizationSidebarBrandingResource(http),
|
|
8608
|
+
organizationSidebarBranding: createOrganizationSidebarBrandingResource(http, { getActiveOrganizationId: () => activeOrganizationId }),
|
|
8600
8609
|
getActiveOrganizationId: () => activeOrganizationId,
|
|
8601
8610
|
setActiveOrganizationId
|
|
8602
8611
|
};
|