This commit is contained in:
2026-04-07 14:50:23 +09:00
commit b4e485502b
4778 changed files with 2017091 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
export declare const SNYK_APP_NAME = "snykAppName";
export declare const SNYK_APP_REDIRECT_URIS = "snykAppRedirectUris";
export declare const SNYK_APP_SCOPES = "snykAppScopes";
export declare const SNYK_APP_CLIENT_ID = "snykAppClientId";
export declare const SNYK_APP_ORG_ID = "snykAppOrgId";
export declare const SNYK_APP_CONTEXT = "context";
export declare const SNYK_APP_DEBUG = "snyk:apps";
export declare enum EValidSubCommands {
CREATE = "create"
}
export declare enum EAppsURL {
CREATE_APP = 0
}
export declare const validAppsSubCommands: string[];
export declare const AppsErrorMessages: {
orgRequired: string;
nameRequired: string;
redirectUrisRequired: string;
scopesRequired: string;
invalidContext: string;
useExperimental: string;
};
export declare const CreateAppPromptData: {
SNYK_APP_NAME: {
name: string;
message: string;
};
SNYK_APP_REDIRECT_URIS: {
name: string;
message: string;
};
SNYK_APP_SCOPES: {
name: string;
message: string;
};
SNYK_APP_ORG_ID: {
name: string;
message: string;
};
SNYK_APP_CONTEXT: {
name: string;
message: string;
};
};

View File

@@ -0,0 +1,9 @@
import { ICreateAppRequest, ICreateAppOptions } from '..';
/**
* Validates and parsed the data required to create app.
* Throws error if option is not provided or is invalid
* @param {ICreateAppOptions} options required to create an app
* @returns {ICreateAppRequest} data that is used to make the request
*/
export declare function createAppDataScriptable(options: ICreateAppOptions): ICreateAppRequest;
export declare function createAppDataInteractive(): Promise<ICreateAppRequest>;

View File

@@ -0,0 +1,6 @@
export * from './constants';
export * from './prompts';
export * from './types';
export * from './rest-utils';
export * from './utils';
export * from './input-validator';

View File

@@ -0,0 +1,33 @@
/**
*
* @param {String} input of space separated URL/URI passed by
* user for redirect URIs
* @returns { String | Boolean } complying with enquirer return values, the function
* separates the string on space and validates each to see
* if a valid URL/URI. Return a string if invalid and
* boolean true if valid
*/
export declare function validateAllURL(input: string): string | boolean;
/**
* Custom validation logic which takes in consideration
* creation of Snyk Apps and thus allows localhost.com
* as a valid URL.
* @param {String} input of URI/URL value to validate using
* regex
* @returns {String | Boolean } string message is not valid
* and boolean true if valid
*/
export declare function validURL(input: string): boolean | string;
/**
* Function validates if a valid UUID (version of UUID not tacken into account)
* @param {String} input UUID to be validated
* @returns {String | Boolean } string message is not valid
* and boolean true if valid
*/
export declare function validateUUID(input: string): boolean | string;
/**
* @param {String} input
* @returns {String | Boolean } string message is not valid
* and boolean true if valid
*/
export declare function validInput(input: string): string | boolean;

View File

@@ -0,0 +1,19 @@
import { validInput } from './input-validator';
/**
* Prompts for $snyk apps create command
*/
export declare const createAppPrompts: ({
name: string;
type: string;
message: string;
validate: typeof validInput;
choices?: undefined;
initial?: undefined;
} | {
name: string;
type: string;
message: string;
choices: string[];
initial: string;
validate?: undefined;
})[];

View File

@@ -0,0 +1,8 @@
/**
* Collection of utility function for the
* $snyk apps commands
*/
import { EAppsURL, ICreateAppResponse, IGetAppsURLOpts } from '.';
export declare function getAppsURL(selection: EAppsURL, opts?: IGetAppsURLOpts): string;
export declare function handleRestError(error: any): void;
export declare function handleCreateAppRes(res: ICreateAppResponse): string;

View File

@@ -0,0 +1,56 @@
export type AppContext = 'tenant' | 'user';
export interface IGetAppsURLOpts {
orgId?: string;
clientId?: string;
}
interface IJSONApi {
version: string;
}
export interface ICreateAppResponse {
jsonapi: IJSONApi;
data: {
type: string;
id: string;
attributes: {
name: string;
client_id: string;
redirect_uris: string[];
scopes: string[];
is_public: boolean;
client_secret: string;
access_token_ttl_seconds: number;
};
links: {
self: string;
};
};
}
export interface IRestErrorResponse {
jsonapi: IJSONApi;
errors: [
{
status: string;
detail: string;
source?: any;
meta?: any;
}
];
}
export interface IGenerateAppsOptions {
interactive?: boolean;
}
export interface ICreateAppOptions extends IGenerateAppsOptions {
org?: string;
name?: string;
redirectUris?: string;
scopes?: string;
context?: AppContext;
}
export interface ICreateAppRequest {
orgId: string;
snykAppName: string;
snykAppRedirectUris: string[];
snykAppScopes: string[];
context?: AppContext;
}
export {};

View File

@@ -0,0 +1 @@
export declare function readAppsHelpMarkdown(filename: string): string;