Skip to content

Commit

Permalink
Merge branch 'main' into br-remove-custom-project-403-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brandenrodgers committed Sep 5, 2024
2 parents 39dd400 + 598faa2 commit 6a73fe2
Show file tree
Hide file tree
Showing 88 changed files with 1,291 additions and 492 deletions.
File renamed without changes.
577 changes: 577 additions & 0 deletions api/__tests__/projects.test.ts

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions api/appsDev.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import http from '../http';
import {
PublicApp,
PublicApInstallCounts,
PublicAppInstallCounts,
PublicAppDeveloperTestAccountInstallData,
FetchPublicAppsForPortalResponse,
} from '../types/Apps';

const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';

type FetchPublicAppsForPortalResponse = {
results: Array<PublicApp>;
};

export async function fetchPublicAppsForPortal(
accountId: number
): Promise<Array<PublicApp>> {
Expand All @@ -33,8 +30,8 @@ export function fetchPublicAppDeveloperTestAccountInstallData(
export function fetchPublicAppProductionInstallCounts(
appId: number,
accountId: number
): Promise<PublicApInstallCounts> {
return http.get<PublicApInstallCounts>(accountId, {
): Promise<PublicAppInstallCounts> {
return http.get<PublicAppInstallCounts>(accountId, {
url: `${APPS_DEV_API_PATH}/${appId}/install-counts-without-test-portals`,
});
}
Expand Down
20 changes: 5 additions & 15 deletions api/customObjects.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import http from '../http';
import { FetchSchemasResponse, Schema } from '../types/Schemas';
import {
FetchSchemasResponse,
Schema,
CreateObjectsResponse,
} from '../types/Schemas';

const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';

type CreateObjectsResponse = {
status: string;
startedAt: string;
completedAt: string;
results: Array<{
id: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
properties: Array<any>;
createdAt: string;
updatedAt: string;
archived: boolean;
}>;
};

export async function batchCreateObjects(
accountId: number,
objectTypeId: string,
Expand Down
16 changes: 4 additions & 12 deletions api/designManager.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import http from '../http';
import { QueryParams } from '../types/Http';
import {
FetchThemesResponse,
FetchBuiltinMappingResponse,
} from '../types/DesignManager';

const DESIGN_MANAGER_API_PATH = 'designmanager/v1';

type FetchThemesResponse = {
objects: Array<{
theme: {
path: string;
};
}>;
};

export async function fetchThemes(
accountId: number,
params: QueryParams = {}
Expand All @@ -21,10 +17,6 @@ export async function fetchThemes(
});
}

type FetchBuiltinMappingResponse = {
[key: string]: string;
};

export async function fetchBuiltinMapping(
accountId: number
): Promise<FetchBuiltinMappingResponse> {
Expand Down
4 changes: 1 addition & 3 deletions api/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, { AxiosResponse } from 'axios';
import { getDefaultUserAgentHeader } from '../http/getAxiosConfig';
import { GithubReleaseData, GithubRepoFile } from '../types/Github';
import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github';

const GITHUB_REPOS_API = 'https://api.github.com/repos';
const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
Expand All @@ -10,8 +10,6 @@ declare global {
var githubToken: string;
}

type RepoPath = `${string}/${string}`;

const GITHUB_AUTH_HEADERS = {
authorization:
global && global.githubToken ? `Bearer ${global.githubToken}` : null,
Expand Down
26 changes: 11 additions & 15 deletions api/localDevAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@ import { getAxiosConfig } from '../http/getAxiosConfig';
import http from '../http';
import { ENVIRONMENTS } from '../constants/environments';
import { Environment } from '../types/Config';
import { ScopeData } from '../types/Accounts';
import {
ScopeData,
AccessTokenResponse,
EnabledFeaturesResponse,
} from '../types/Accounts';
import axios from 'axios';
import { HUBSPOT_ACCOUNT_TYPES } from '../constants/config';
import { ValueOf } from '../types/Utils';
import { PublicAppInstallationData } from '../types/Apps';

const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';

type AccessTokenResponse = {
hubId: number;
userId: number;
oauthAccessToken: string;
expiresAtMillis: number;
enabledFeatures?: { [key: string]: number };
scopeGroups: Array<string>;
encodedOAuthRefreshToken: string;
hubName: string;
accountType: ValueOf<typeof HUBSPOT_ACCOUNT_TYPES>;
};

export async function fetchAccessToken(
personalAccessKey: string,
env: Environment = ENVIRONMENTS.PROD,
Expand Down Expand Up @@ -73,3 +63,9 @@ export async function fetchAppInstallationData(
},
});
}

export async function fetchEnabledFeatures(accountId: number) {
return http.get<EnabledFeaturesResponse>(accountId, {
url: `${LOCALDEVAUTH_API_AUTH_PATH}/enabled-features`,
});
}
41 changes: 19 additions & 22 deletions api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
FetchProjectResponse,
UploadProjectResponse,
ProjectSettings,
FetchPlatformVersionResponse,
} from '../types/Project';
import { Build, FetchProjectBuildsResponse } from '../types/Build';
import {
ComponentMetadataResponse,
ComponentStructureResponse,
ProjectComponentsMetadata,
} from '../types/ComponentStructure';
import { Deploy, ProjectDeployResponse } from '../types/Deploy';
import { ProjectLog } from '../types/ProjectLog';
Expand All @@ -21,6 +22,7 @@ import {
} from '../types/Migration';

const PROJECTS_API_PATH = 'dfs/v1/projects';
const DEVELOPER_FILE_SYSTEM_PATH = 'dfs/v1';
const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
Expand All @@ -30,7 +32,7 @@ export async function fetchProjects(
accountId: number
): Promise<FetchProjectResponse> {
return http.get(accountId, {
url: PROJECTS_API_PATH,
url: DEVELOPER_PROJECTS_API_PATH,
});
}

Expand All @@ -39,7 +41,7 @@ export async function createProject(
name: string
): Promise<Project> {
return http.post(accountId, {
url: PROJECTS_API_PATH,
url: DEVELOPER_PROJECTS_API_PATH,
data: {
name,
},
Expand All @@ -63,7 +65,7 @@ export async function uploadProject(

return http.post(accountId, {
url: `${PROJECTS_API_PATH}/upload/${encodeURIComponent(projectName)}`,
timeout: 60000,
timeout: 60_000,
data: formData,
headers: { 'Content-Type': 'multipart/form-data' },
});
Expand All @@ -74,7 +76,16 @@ export async function fetchProject(
projectName: string
): Promise<Project> {
return http.get(accountId, {
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}`,
url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${encodeURIComponent(projectName)}`,
});
}

export async function fetchProjectComponentsMetadata(
accountId: number,
projectId: number
): Promise<ProjectComponentsMetadata> {
return http.get(accountId, {
url: `${DEVELOPER_FILE_SYSTEM_PATH}/projects-deployed-build/${projectId}`,
});
}

Expand All @@ -97,15 +108,10 @@ export async function deleteProject(
projectName: string
): Promise<void> {
return http.delete(accountId, {
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}`,
url: `${DEVELOPER_PROJECTS_API_PATH}/${encodeURIComponent(projectName)}`,
});
}

type FetchPlatformVersionResponse = {
defaultPlatformVersion: string;
activePlatformVersions: Array<string>;
};

export async function fetchPlatformVersions(
accountId: number
): Promise<FetchPlatformVersionResponse> {
Expand Down Expand Up @@ -192,16 +198,7 @@ export async function fetchProjectSettings(
projectName: string
): Promise<ProjectSettings> {
return http.get(accountId, {
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/settings`,
});
}

export async function fetchDeployComponentsMetadata(
accountId: number,
projectId: number
): Promise<ComponentMetadataResponse> {
return http.get(accountId, {
url: `${PROJECTS_API_PATH}/by-id/${projectId}/deploy-components-metadata`,
url: `${DEVELOPER_PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/settings`,
});
}

Expand All @@ -216,7 +213,7 @@ export async function provisionBuild(
)}/builds/staged/provision`,
params: { platformVersion },
headers: { 'Content-Type': 'application/json' },
timeout: 50000,
timeout: 50_000,
});
}

Expand Down
5 changes: 1 addition & 4 deletions api/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import http from '../http';
import { FetchSecretsResponse } from '../types/Secrets';

const SECRETS_API_PATH = 'cms/v3/functions/secrets';

type FetchSecretsResponse = {
results: Array<string>;
};

export async function addSecret(
accountId: number,
key: string,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 4 additions & 22 deletions config/configUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import {
OAUTH_AUTH_METHOD,
PERSONAL_ACCESS_KEY_AUTH_METHOD,
} from '../constants/auth';
import { CLIConfig_NEW, Environment } from '../types/Config';
import { CLIConfig_NEW } from '../types/Config';
import {
AuthType,
CLIAccount_NEW,
APIKeyAccount_NEW,
OAuthAccount_NEW,
PersonalAccessKeyAccount_NEW,
PersonalAccessKeyOptions,
OAuthOptions,
APIKeyOptions,
} from '../types/Accounts';
import { i18n } from '../utils/lang';

Expand Down Expand Up @@ -52,12 +55,6 @@ export function getOrderedConfig(
};
}

type PersonalAccessKeyOptions = {
accountId: number;
personalAccessKey: string;
env: Environment;
};

function generatePersonalAccessKeyAccountConfig({
accountId,
personalAccessKey,
Expand All @@ -71,15 +68,6 @@ function generatePersonalAccessKeyAccountConfig({
};
}

type OAuthOptions = {
accountId: number;
clientId: string;
clientSecret: string;
refreshToken: string;
scopes: Array<string>;
env: Environment;
};

function generateOauthAccountConfig({
accountId,
clientId,
Expand All @@ -103,12 +91,6 @@ function generateOauthAccountConfig({
};
}

type APIKeyOptions = {
accountId: number;
apiKey: string;
env: Environment;
};

function generateApiKeyAccountConfig({
accountId,
apiKey,
Expand Down
5 changes: 1 addition & 4 deletions config/config_DEPRECATED.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
CLIAccount_DEPRECATED,
FlatAccountFields_DEPRECATED,
OAuthAccount_DEPRECATED,
UpdateAccountConfigOptions,
} from '../types/Accounts';
import { BaseError } from '../types/Error';
import { Mode } from '../types/Files';
Expand Down Expand Up @@ -475,10 +476,6 @@ export function removeSandboxAccountFromConfig(
return promptDefaultAccount;
}

type UpdateAccountConfigOptions = Partial<FlatAccountFields_DEPRECATED> & {
environment?: Environment;
};

/**
* @throws {Error}
*/
Expand Down
16 changes: 5 additions & 11 deletions config/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { CLIConfig_NEW, Environment } from '../types/Config';
import {
CLIConfig_NEW,
Environment,
EnvironmentConfigVariables,
} from '../types/Config';
import { logger } from '../lib/logger';
import { ENVIRONMENT_VARIABLES } from '../constants/environments';
import {
Expand All @@ -13,16 +17,6 @@ import { i18n } from '../utils/lang';

const i18nKey = 'config.environment';

type EnvironmentConfigVariables = {
apiKey?: string;
clientId?: string;
clientSecret?: string;
personalAccessKey?: string;
accountId?: number;
refreshToken?: string;
env?: Environment;
};

function getConfigVariablesFromEnv(): EnvironmentConfigVariables {
const env = process.env;

Expand Down
1 change: 1 addition & 0 deletions constants/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const ALLOWED_EXTENSIONS = new Set([
'woff2',
'graphql',
]);
export const JSR_ALLOWED_EXTENSIONS = new Set(['jsx', 'tsx', 'ts']);

export const HUBL_EXTENSIONS = new Set(['css', 'html', 'js']);
export const MODULE_EXTENSION = 'module';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6a73fe2

Please sign in to comment.