New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@useparagon/cli

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@useparagon/cli - npm Package Compare versions

Comparing version 0.0.1-canary.3 to 0.0.1-canary.4

import { IEvent } from '@useparagon/core/event';
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
import { IntegrationWorkflowMeta } from '../apis/api.types';
export type ProjectDependencies = {

@@ -9,2 +11,12 @@ events: Record<string, IEvent>;

};
workflowMeta: IntegrationWorkflowMeta;
sharedInputs: SerializedInput[];
inputSources: InputSource[];
};
export type StepDependencies = {
sharedInputs: SerializedInput[];
inputs: SerializedInput[];
inputSources: InputSource[];
stepIdToVariableMap: Record<string, string>;
events: Record<string, IEvent>;
};

@@ -1,4 +0,4 @@

import { BuildOutput, IntegrationOutput, ProjectDependencies } from '../compilers/compiler.types';
export declare const wrapMultilineString: (value: string) => string;
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput: IntegrationOutput, projectDependencies: ProjectDependencies, projectRoot: string) => Promise<void>;
export declare const generateProjectFiles: (projectBuild: BuildOutput, projectRoot: string) => Promise<void>;
import { IntegrationBuild, ProjectBuild } from '../apis/api.types';
import { ProjectDependencies } from '../compiler/compiler.types';
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput: IntegrationBuild, projectDependencies: ProjectDependencies, projectRoot: string) => Promise<void>;
export declare const generateProjectFiles: (projectBuild: ProjectBuild, projectRoot: string) => Promise<void>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateProjectFiles = exports.generateIntegrationFiles = exports.wrapMultilineString = void 0;
exports.generateProjectFiles = exports.generateIntegrationFiles = void 0;
const tslib_1 = require("tslib");
const importSortOrderPlugin = tslib_1.__importStar(require("@trivago/prettier-plugin-sort-imports"));
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const prettier_1 = tslib_1.__importDefault(require("prettier"));
const organiseImportPlugin = tslib_1.__importStar(require("prettier-plugin-organize-imports"));
const file_1 = require("../helpers/file");
const event_codegen_1 = require("./codegens/event.codegen");
const integration_codegen_1 = require("./codegens/integration.codegen");
const persona_codegen_1 = require("./codegens/persona.codegen");
const workflow_codegen_1 = require("./codegens/workflow.codegen");
const writeSourceToFile = (filePath, fileName, sourceCode) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const sanitizeFileName = fileName;
const formattedCode = prettier_1.default.format(sourceCode, {
parser: 'typescript',
semi: true,
trailingComma: 'all',
singleQuote: true,
plugins: [organiseImportPlugin, importSortOrderPlugin],
importOrder: ['^@useparagon/(.*)$', '^[./]'],
importOrderSeparation: true,
importOrderCaseInsensitive: true,
});
yield fs_extra_1.default.promises.writeFile(path_1.default.join(filePath, `${sanitizeFileName}.ts`), formattedCode);
});
const wrapMultilineString = (value) => {
return '`' + value + '`';
};
exports.wrapMultilineString = wrapMultilineString;
const generateIntegrationFiles = (integrationName, integrationOutput, projectDependencies, projectRoot) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d;
const { events } = projectDependencies;
const integrationPath = path_1.default.join(projectRoot, 'integrations', integrationName);

@@ -36,7 +19,18 @@ yield fs_extra_1.default.promises.mkdir(integrationPath, {

});
const sharedInputs = (_b = (_a = integrationOutput.config.values.sharedMeta) === null || _a === void 0 ? void 0 : _a.inputs) !== null && _b !== void 0 ? _b : [];
const integrationDependencies = {
inputSources: (_c = integrationOutput.inputs) !== null && _c !== void 0 ? _c : [],
};
const configCode = (0, integration_codegen_1.integrationConfigToCode)(integrationOutput.config, integrationName);
yield writeSourceToFile(integrationPath, 'config', configCode);
const workflowOutputs = Object.values(integrationOutput.workflows);
const inputsSouceCode = (0, integration_codegen_1.integrationInputsToCode)(sharedInputs, integrationDependencies.inputSources);
const integrationTypesCode = (0, integration_codegen_1.typesForIntegration)(integrationDependencies);
yield Promise.all([
(0, file_1.writeSourceToFile)(integrationPath, 'config', configCode),
(0, file_1.writeSourceToFile)(integrationPath, 'inputs', inputsSouceCode),
(0, file_1.writeSourceToFile)(integrationPath, 'types', integrationTypesCode),
]);
const workflowMetas = (_d = integrationOutput.config.values.workflowMeta) !== null && _d !== void 0 ? _d : {};
const workflows = Object.values(integrationOutput.workflows);
const workflowPath = path_1.default.join(integrationPath, 'workflows');
if (workflowOutputs.length) {
if (workflows.length) {
fs_extra_1.default.promises.mkdir(workflowPath, {

@@ -46,5 +40,14 @@ recursive: true,

}
for (const workflowOutput of workflowOutputs) {
const workflowCode = (0, workflow_codegen_1.workflowToCode)(workflowOutput, Object.assign(Object.assign({}, projectDependencies), { integration: { name: integrationName } }));
yield writeSourceToFile(workflowPath, workflowOutput.name, workflowCode);
for (const workflow of workflows) {
const workflowCode = (0, workflow_codegen_1.workflowToCode)(workflow, {
events,
integration: { name: integrationName },
sharedInputs,
inputSources: integrationDependencies.inputSources,
workflowMeta: workflowMetas[workflow.id] || {
id: workflow.id,
inputs: [],
},
});
yield (0, file_1.writeSourceToFile)(workflowPath, workflow.name, workflowCode);
}

@@ -54,3 +57,2 @@ });

const generateProjectFiles = (projectBuild, projectRoot) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield fs_extra_1.default.promises.mkdir(projectRoot, { recursive: true });
const events = Object.values(projectBuild.events);

@@ -65,7 +67,11 @@ const eventPath = path_1.default.join(projectRoot, 'events');

const eventSourceCode = (0, event_codegen_1.eventToCode)(event);
yield writeSourceToFile(eventPath, event.name, eventSourceCode);
yield (0, file_1.writeSourceToFile)(eventPath, event.name, eventSourceCode);
}
yield (0, file_1.writeSourceToFile)(projectRoot, 'persona.meta', (0, persona_codegen_1.personaToCode)(projectBuild.persona));
const integrationOutputs = Object.entries(projectBuild.integrations);
for (const [integrationName, integrationOutput] of integrationOutputs) {
yield (0, exports.generateIntegrationFiles)(integrationName, integrationOutput, { events: projectBuild.events }, projectRoot);
yield (0, exports.generateIntegrationFiles)(integrationName, integrationOutput, {
events: projectBuild.events,
projectId: projectBuild.projectId,
}, projectRoot);
}

@@ -72,0 +78,0 @@ });

import { OperatorCondition } from '@useparagon/core/resolvers';
export declare const conditionToCode: (operatorCondition: OperatorCondition, stepIdToVariableMap: Record<string, string>) => string;
import { StepDependencies } from '../codegen.types';
export declare const conditionToCode: (operatorCondition: OperatorCondition, dependencies: StepDependencies) => string;

@@ -6,17 +6,103 @@ "use strict";

const source_codegen_1 = require("./source.codegen");
const conditionToCode = (operatorCondition, stepIdToVariableMap) => {
const conditionToCode = (operatorCondition, dependencies) => {
let code = '';
const condition = operatorCondition.condition;
let parameters = (0, source_codegen_1.convertSourceToCode)(condition.variable, dependencies);
if ('argument' in condition) {
parameters = `${parameters},${(0, source_codegen_1.convertSourceToCode)(condition.argument, dependencies)}`;
}
switch (condition.operator) {
case resolvers_1.Operator.BooleanTrue: {
const variable = (0, source_codegen_1.convertSourceToCode)(condition.variable, stepIdToVariableMap);
code = `Operators.BooleanTrue(${variable})`;
case resolvers_1.Operator.ArrayIsEmpty:
code = `Operators.ArrayIsEmpty(${parameters})`;
break;
}
case resolvers_1.Operator.StringContains: {
const variable = (0, source_codegen_1.convertSourceToCode)(condition.variable, stepIdToVariableMap);
const argument = (0, source_codegen_1.convertSourceToCode)(condition.argument, stepIdToVariableMap);
code = `Operators.StringContains(${variable},${argument})`;
case resolvers_1.Operator.ArrayIsIn:
code = `Operators.ArrayIsIn(${parameters})`;
break;
}
case resolvers_1.Operator.ArrayIsNotEmpty:
code = `Operators.ArrayIsNotEmpty(${parameters})`;
break;
case resolvers_1.Operator.ArrayIsNotIn:
code = `Operators.ArrayIsNotIn(${parameters})`;
break;
case resolvers_1.Operator.BooleanFalse:
code = `Operators.BooleanFalse(${parameters})`;
break;
case resolvers_1.Operator.BooleanTrue:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.DateTimeAfter:
code = `Operators.DateTimeAfter(${parameters})`;
break;
case resolvers_1.Operator.DateTimeBefore:
code = `Operators.DateTimeBefore(${parameters})`;
break;
case resolvers_1.Operator.DateTimeEquals:
code = `Operators.DateTimeEquals(${parameters})`;
break;
case resolvers_1.Operator.DoesNotExist:
code = `Operators.DoesNotExist(${parameters})`;
break;
case resolvers_1.Operator.Exists:
code = `Operators.Exists(${parameters})`;
break;
case resolvers_1.Operator.IsNotNull:
code = `Operators.IsNotNull(${parameters})`;
break;
case resolvers_1.Operator.IsNull:
code = `Operators.IsNull(${parameters})`;
break;
case resolvers_1.Operator.NumberDoesNotEqual:
code = `Operators.NumberDoesNotEqual(${parameters})`;
break;
case resolvers_1.Operator.NumberEquals:
code = `Operators.NumberEquals(${parameters})`;
break;
case resolvers_1.Operator.NumberGreaterThan:
code = `Operators.NumberGreaterThan(${parameters})`;
break;
case resolvers_1.Operator.NumberGreaterThanOrEqualTo:
code = `Operators.NumberGreaterThanOrEqualTo(${parameters})`;
break;
case resolvers_1.Operator.NumberLessThan:
code = `Operators.NumberLessThan(${parameters})`;
break;
case resolvers_1.Operator.NumberLessThanOrEqualTo:
code = `Operators.NumberLessThanOrEqualTo(${parameters})`;
break;
case resolvers_1.Operator.StringContains:
code = `Operators.StringContains(${parameters})`;
break;
case resolvers_1.Operator.StringDoesNotContain:
code = `Operators.StringDoesNotContain(${parameters})`;
break;
case resolvers_1.Operator.StringDoesNotEndWith:
code = `Operators.StringDoesNotEndWith(${parameters})`;
break;
case resolvers_1.Operator.StringDoesNotExactlyMatch:
code = `Operators.StringDoesNotExactlyMatch(${parameters})`;
break;
case resolvers_1.Operator.StringDoesNotStartWith:
code = `Operators.StringDoesNotStartWith(${parameters})`;
break;
case resolvers_1.Operator.StringEndsWith:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.StringExactlyMatches:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.StringGreaterThan:
code = `Operators.StringContains(${parameters})`;
break;
case resolvers_1.Operator.StringIsIn:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.StringIsNotIn:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.StringLessThan:
code = `Operators.BooleanTrue(${parameters})`;
break;
case resolvers_1.Operator.StringStartsWith:
code = `Operators.BooleanTrue(${parameters})`;
break;
default:

@@ -23,0 +109,0 @@ code = 'undefined';

@@ -7,15 +7,8 @@ "use strict";

const sourceCode = `
import { IEvent } from '@useparagon/core/event';
import { IEventInit } from '@useparagon/core/event';
export type EventSchema = {
};
export type EventSchema = ${(0, json_1.stringifyObject)(event.schema)};
const event: IEvent<EventSchema> = {
const event: IEventInit<EventSchema> = {
/**
* This property is maintained by Paragon. Do not edit this property.
*/
id: '${event.id}',
/**
* name of event

@@ -22,0 +15,0 @@ */

@@ -1,2 +0,5 @@

import { IntegrationOutput } from '../../compilers/compiler.types';
export declare const integrationConfigToCode: (config: IntegrationOutput['config'], integrationName: string) => string;
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
import { IntegrationBuild, IntegrationDependencies } from '../../apis/api.types';
export declare const integrationConfigToCode: (config: IntegrationBuild['config'], integrationName: string) => string;
export declare const integrationInputsToCode: (inputs: SerializedInput[], inputSources: InputSource[]) => string;
export declare const typesForIntegration: (integrationDependencies: IntegrationDependencies) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.integrationConfigToCode = void 0;
exports.typesForIntegration = exports.integrationInputsToCode = exports.integrationConfigToCode = void 0;
const inputs_1 = require("@useparagon/core/inputs");
const json_1 = require("../../helpers/json");
const integrationConfigToCode = (config, integrationName) => {
const sourceCode = `
import { IIntegrationConfig } from '@useparagon/core';
import { IIntegrationConfig } from '@useparagon/core/integration';

@@ -12,3 +13,7 @@ /**

*/
const config: IIntegrationConfig = ${(0, json_1.stringifyObject)(config || {})}
const config: IIntegrationConfig = ${(0, json_1.stringifyObject)({
description: config.values.description,
overviewText: config.values.overview,
showWatermark: config.values.paragonLink || true,
})}

@@ -19,2 +24,84 @@ export default config;`;

exports.integrationConfigToCode = integrationConfigToCode;
const integrationInputsToCode = (inputs, inputSources) => {
const sourceCode = `
import { createInputs } from './types';
/**
* define inputs here which can be used across workflows
*/
const integrationInputs = createInputs(${(0, json_1.stringifyObject)((0, inputs_1.mapUserDefinedInputsWithTitle)((0, inputs_1.convertSerializedInputsToUserDefinedInputs)(inputs, inputSources)))});
export default integrationInputs;
`;
return sourceCode;
};
exports.integrationInputsToCode = integrationInputsToCode;
const typesForIntegration = (integrationDependencies) => {
const { inputSources } = integrationDependencies;
const supportedInputTypes = inputs_1.BASIC_INPUT_NAMES.concat(inputSources.map(inputs_1.getInputTypeForUI));
const sourceCode = `
/**
* ############### WARNING ######################
* ##### DO NOT DELETE/RENAME THIS FILE ########
* ##### DO NOT UPDATE THIS FILE CONTENT ########
* ############### WARNING ######################
*/
import { UserDefinedInput } from '@useparagon/core/inputs';
/**
* supported input names
*/
export type InputType = ${supportedInputTypes
.map((inputType) => [`'${inputType}'`])
.join(' | ')};
/**
* map b/w input type to result
*/
export type InputResultMap = {
'email' : string;
'url' : string;
'password' : string;
'boolean' : boolean;
'text' : string;
${inputSources
.map((source) => {
let result = 'string';
if (source.type === 'COMBO_INPUT_DATA_SOURCE') {
result = `
{
'${(0, inputs_1.getInputTypeForUI)(source.mainInputSource)}' : string;
'${(0, inputs_1.getInputTypeForUI)(source.dependentInputSource)}' : string;
}
`;
}
else if (source.type === 'FIELD_MAPPER_DATA_SOURCE') {
result = `
{
'${(0, inputs_1.getInputTypeForUI)(source.recordSource)}' : string;
'${(0, inputs_1.getInputTypeForUI)(source.fieldSource)}' : string;
}
`;
}
return [`'${(0, inputs_1.getInputTypeForUI)(source)}'`, result].join(' : ');
})
.join(';')}
}
/**
* pass { variableName for input => Input }
* this should be used whenever we are creating inputs for integrations/workflows
* as it will infer proper types
*/
export const createInputs = <
T extends Record<string, UserDefinedInput<InputType>>,
>(
inputs: T,
) => inputs;
`;
return sourceCode;
};
exports.typesForIntegration = typesForIntegration;
//# sourceMappingURL=integration.codegen.js.map

@@ -1,5 +0,7 @@

import { DataType, KeyedSource, Source, TokenizedSource } from '@useparagon/core/resolvers';
import { DataType, InputConnectCredentialSource, KeyedSource, Source, TokenizedSource } from '@useparagon/core/resolvers';
import { StepDependencies } from '../codegen.types';
export declare const EMPTY_TOKENIZED_SOURCE: TokenizedSource<DataType.STRING>;
export declare const convertSourceToCode: (source: Source, stepIdToVariableMap: Record<string, string>, isTokenizedPart?: boolean) => string;
export declare const convertKeyedSourceToCode: (source: KeyedSource, stepIdToVariableMap: Record<string, string>) => [string, string];
export declare const covertKeyedSourceParamsToCode: (parameters: KeyedSource<DataType>[], stepIdToVariableMap: Record<string, string>) => string;
export declare const convertInputSourceToCode: (source: InputConnectCredentialSource, dependencies: StepDependencies) => string;
export declare const convertSourceToCode: (source: Source, dependencies: StepDependencies, isTokenizedPart?: boolean) => string;
export declare const convertKeyedSourceToCode: (source: KeyedSource, dependencies: StepDependencies) => [string, string];
export declare const covertKeyedSourceParamsToCode: (parameters: KeyedSource<DataType>[], dependencies: StepDependencies) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.covertKeyedSourceParamsToCode = exports.convertKeyedSourceToCode = exports.convertSourceToCode = exports.EMPTY_TOKENIZED_SOURCE = void 0;
exports.covertKeyedSourceParamsToCode = exports.convertKeyedSourceToCode = exports.convertSourceToCode = exports.convertInputSourceToCode = exports.EMPTY_TOKENIZED_SOURCE = void 0;
const inputs_1 = require("@useparagon/core/inputs");
const resolvers_1 = require("@useparagon/core/resolvers");

@@ -16,15 +17,79 @@ const condition_codegen_1 = require("./condition.codegen");

};
const convertSourceToCode = (source, stepIdToVariableMap, isTokenizedPart = false) => {
const convertValueToCode = (source) => {
switch (source.dataType) {
case resolvers_1.DataType.ARRAY:
return `[${source.value.join(',')}]`;
case resolvers_1.DataType.NUMBER:
case resolvers_1.DataType.NON_DECIMAL:
return `${source.value}`;
default:
return `"${source.value}"`;
}
};
const convertInputSourceToCode = (source, dependencies) => {
var _a, _b;
const inputs = source.fieldType === 'SHARED_WORKFLOW_SETTING'
? dependencies.sharedInputs
: dependencies.inputs;
const titleToInput = (0, inputs_1.mapUserDefinedInputsWithTitle)(inputs);
const [inputKey, input] = Object.entries(titleToInput).find(([, input]) => input.id === source.inputId) || [];
if (!input) {
return '';
}
let value = source.fieldType === 'SHARED_WORKFLOW_SETTING'
? `context.getSharedInput(sharedInputs.${inputKey})`
: `context.getInput(this.inputs.${inputKey})`;
if (!input['sourceType']) {
return value;
}
const inputSource = dependencies.inputSources.find((source) => (0, inputs_1.getSourceKey)(source) === input['sourceType']);
if (!inputSource) {
return value;
}
switch (input.type) {
case inputs_1.SidebarInputType.ComboInput:
let path = ((_a = source.path) !== null && _a !== void 0 ? _a : [])[0];
if (path === 'mainInput') {
const mainInputName = (0, inputs_1.getInputTypeForUI)(inputSource.mainInputSource);
value = `${value}.${mainInputName}`;
}
else if (path === 'dependentInput') {
const dependentInputName = (0, inputs_1.getInputTypeForUI)(inputSource.dependentInputSource);
value = `${value}.${dependentInputName}`;
}
break;
case inputs_1.SidebarInputType.FieldMapper:
let [fieldPath, fieldName] = (_b = source.path) !== null && _b !== void 0 ? _b : [];
if (fieldPath === 'objectMapping') {
const recordSourceName = (0, inputs_1.getInputTypeForUI)(inputSource.recordSource);
value = `${value}.${recordSourceName}`;
}
else if (fieldPath === 'fieldMappings') {
const fieldSourceName = (0, inputs_1.getInputTypeForUI)(inputSource.fieldSource);
value = `${value}.${fieldSourceName}${fieldName ? `['${fieldName}']` : ''}`;
}
break;
default:
break;
}
return value;
};
exports.convertInputSourceToCode = convertInputSourceToCode;
const convertSourceToCode = (source, dependencies, isTokenizedPart = false) => {
var _a;
const { stepIdToVariableMap } = dependencies;
let value = '';
switch (source.type) {
case 'VALUE':
value = '"' + source.value + '"';
case 'VALUE': {
value = convertValueToCode(source);
break;
case 'TOKENIZED':
}
case 'TOKENIZED': {
value = source.parts.reduce((acc, currentSource) => {
return `${acc}${(0, exports.convertSourceToCode)(currentSource, stepIdToVariableMap, true)}`;
return `${acc}${(0, exports.convertSourceToCode)(currentSource, dependencies, true)}`;
}, '');
value = '`' + value + '`';
break;
case 'VARIABLE':
}
case 'VARIABLE': {
const sanitizedPaths = source.path.filter((path) => Boolean(path));

@@ -36,2 +101,3 @@ value = `context.getOutput(${stepIdToVariableMap[source.stepId]})${sanitizedPaths.length ? `?.${sanitizedPaths.join('?.')}` : ''}`;

break;
}
case 'CONDITION':

@@ -51,18 +117,18 @@ const conditionWrapper = source.condition;

.filter((conditions) => conditions.length);
const convertAndConditionsToCode = (conditions, stepIdToVariableMap) => {
const convertAndConditionsToCode = (conditions) => {
return conditions.reduce((accumulator, condition, index) => {
const conditionCode = (0, condition_codegen_1.conditionToCode)(condition, stepIdToVariableMap);
const conditionCode = (0, condition_codegen_1.conditionToCode)(condition, dependencies);
if (index === conditions.length - 1) {
return `${accumulator}${conditionCode}]`;
return `${accumulator}${conditionCode})`;
}
return `${accumulator}${conditionCode},`;
}, '[');
}, 'Operators.And(');
};
if (conditions.length === 1 && conditions[0].length === 1) {
const condition = conditions[0][0];
value = (0, condition_codegen_1.conditionToCode)(condition, stepIdToVariableMap);
value = (0, condition_codegen_1.conditionToCode)(condition, dependencies);
}
else if (conditions.length === 1) {
const andConditions = conditions[0];
value = convertAndConditionsToCode(andConditions, stepIdToVariableMap);
value = convertAndConditionsToCode(andConditions);
}

@@ -72,21 +138,46 @@ else {

value = orConditions.reduce((accumulator, andConditions, index) => {
const andConditionCode = convertAndConditionsToCode(andConditions, stepIdToVariableMap);
const andConditionCode = convertAndConditionsToCode(andConditions);
if (index === orConditions.length - 1) {
return `${accumulator}${andConditionCode}]`;
return `${accumulator}${andConditionCode})`;
}
return `${accumulator}${andConditionCode},`;
}, '[');
}, 'Operators.Or(');
}
break;
case 'ENVIRONMENT_SECRET':
value = `context.getEnvironmentSecret(${source.environmentSecretId})`;
break;
case 'PERSONA_METADATA': {
const sanitizedPaths = ((_a = source.path) !== null && _a !== void 0 ? _a : []).filter((path) => Boolean(path));
value = `context.getPersona('meta')${sanitizedPaths.length ? `.${sanitizedPaths.join('.')}` : ''}`;
break;
}
case 'CONNECT_CREDENTIAL_FIELD': {
switch (source.fieldType) {
case 'EXTERNAL_USER_ID':
value = `context.getPersona('userId')`;
break;
case 'WORKFLOW_SETTING':
case 'SHARED_WORKFLOW_SETTING':
value = (0, exports.convertInputSourceToCode)(source, dependencies);
break;
default:
throw new Error(`Field type ${source.fieldType} not supported.`);
}
break;
}
default:
throw new Error(`source type ${source.type} not implemented.`);
throw new Error(`source type ${source['type']} not implemented.`);
}
if (!isTokenizedPart && value.trim() === '') {
value = "''";
}
return value;
};
exports.convertSourceToCode = convertSourceToCode;
const convertKeyedSourceToCode = (source, stepIdToVariableMap) => {
return [source.key, (0, exports.convertSourceToCode)(source.source, stepIdToVariableMap)];
const convertKeyedSourceToCode = (source, dependencies) => {
return [source.key, (0, exports.convertSourceToCode)(source.source, dependencies)];
};
exports.convertKeyedSourceToCode = convertKeyedSourceToCode;
const covertKeyedSourceParamsToCode = (parameters, stepIdToVariableMap) => {
const covertKeyedSourceParamsToCode = (parameters, dependencies) => {
if (!parameters.length) {

@@ -96,10 +187,11 @@ return '{}';

const value = parameters.reduce((accumulator, keyedSource, index) => {
const [key, value] = (0, exports.convertKeyedSourceToCode)(keyedSource, stepIdToVariableMap);
const [key, value] = (0, exports.convertKeyedSourceToCode)(keyedSource, dependencies);
if (index > 0) {
accumulator += ',';
}
const currentKeyValue = key.trim() ? `${key} : ${value}` : '';
if (index === parameters.length - 1) {
return `${accumulator}${key} : ${value}}`;
return `${accumulator}${currentKeyValue}}`;
}
return `${accumulator}${key} : ${value}`;
return `${accumulator}${currentKeyValue}`;
}, '{');

@@ -106,0 +198,0 @@ return value;

@@ -1,3 +0,3 @@

import { WorkflowOutput } from '../../compilers/compiler.types';
import { WorkflowBuild } from '../../apis';
import { WorkflowDependencies } from '../codegen.types';
export declare const workflowToCode: (workflowBuild: WorkflowOutput, dependencies: WorkflowDependencies) => string;
export declare const workflowToCode: (workflowBuild: WorkflowBuild, dependencies: WorkflowDependencies) => string;

@@ -6,3 +6,6 @@ "use strict";

const core_1 = require("@useparagon/core");
const inputs_1 = require("@useparagon/core/inputs");
const steps_1 = require("@useparagon/core/steps");
const cron_1 = require("@useparagon/core/triggers/cron");
const utils_1 = require("@useparagon/core/utils");
const json_1 = require("../../helpers/json");

@@ -12,53 +15,122 @@ const logger_1 = tslib_1.__importDefault(require("../../logger"));

const workflowToCode = (workflowBuild, dependencies) => {
const { id: workflowId, name: workflowName, stateMachine } = workflowBuild;
const startStepId = stateMachine.sequenceMap[stateMachine.start].start;
if (!startStepId) {
const { id: workflowId, name: workflowName, steps } = workflowBuild;
const { events, workflowMeta, inputSources, sharedInputs } = dependencies;
const triggerStep = (0, steps_1.getTriggerStep)(steps);
if (!triggerStep) {
logger_1.default.fatal(`Workflow ${workflowName} with no start step id.`);
return '';
}
const stepIdToVariableMap = {};
const startStepId = triggerStep.id;
const stepIdToVariableMap = (0, steps_1.mapStepIdToVariableName)(steps);
const stepDependencies = {
stepIdToVariableMap,
events,
inputs: workflowMeta.inputs,
sharedInputs,
inputSources,
};
const imports = [
'import { IContext} from "@useparagon/core/execution";',
'import { Workflow, ActionStep, CronStep, DelayStep, EventStep, FunctionStep, ConditionalStep, FanOutStep, ResponseStep, RequestStep, IntegrationEnabledStep} from "@useparagon/core";',
'import { IContext , IPermissionContext} from "@useparagon/core/execution";',
`import { ${[
'Workflow',
'CronStep',
'DelayStep',
'EventStep',
'FunctionStep',
'ConditionalStep',
'FanOutStep',
'ResponseStep',
'RequestStep',
'IntegrationEnabledStep',
'UnselectedStep',
'EndpointStep',
'IntegrationRequestStep',
].join(',')} } from "@useparagon/core";`,
`import { IPersona } from '@useparagon/core/persona';`,
'import * as Operators from "@useparagon/core/operator";',
`import { ConditionalInput } from '@useparagon/core/steps/library/conditional';`,
`import { IIntegration } from '@useparagon/core/integration';`,
`import personaMeta from '../../../persona.meta';`,
`import sharedInputs from '../inputs`,
`import { createInputs, InputResultMap } from '../types';`,
];
const statements = [];
const stepCode = getStepCodeParts(startStepId, stateMachine.stepMap, stepIdToVariableMap, dependencies);
imports.push(...new Set(stepCode.imports));
statements.push(...stepCode.varDeclarations);
const stepCode = getStepCodeParts(startStepId, (0, utils_1.indexBy)('id', steps), stepDependencies);
const sourceCode = `
${imports.join('\n')}
${[...imports, ...stepCode.imports].join('\n')}
/**
* ${workflowName} Workflow impolementation
*/
export default class extends Workflow<any> {
* define inputs here which can be used in this workflow only
*/
const inputs = createInputs(${(0, json_1.stringifyObject)((0, inputs_1.mapUserDefinedInputsWithTitle)((0, inputs_1.convertSerializedInputsToUserDefinedInputs)(workflowMeta.inputs, inputSources)))});
/**
* ${workflowName} Workflow impolementation
*/
export default class extends Workflow<any, IPersona<typeof personaMeta>, InputResultMap> {
/**
* This property is maintained by Paragon. Do not edit this property.
*/
readonly id: '${workflowId}'
readonly id: string = '${workflowId}';
/**
* defines the workflow
* @param integration
* @param context
* @param user
* name shown in workflow editor
*/
define(_integration: any, context: IContext) {
name: string = '${workflowName}';
/**
* declare all steps here
* description shown in connect portal for workflow
*/
${statements.join('\n')}
description: string = '${workflowMeta.infoText ||
'Add a user-facing description of this workflow'}';
/**
* chain steps correctly here
* inputs used in workflows
*/
${stepCode.stepChains}
inputs = inputs;
/**
* pass all steps here so that paragon can keep track of changes
* if set to true , workflow will be automatically be enable
* after integration connect
*/
return this.register({ ${Object.values(stepIdToVariableMap).join(', ')} });
defaultEnabled: boolean = ${workflowMeta.defaultEnabled || false};
/**
* if true , workflow will be hidden from connect portal
*/
hidden: boolean = ${workflowMeta.hidden || false};
/**
* defines the workflow
* @param integration
* @param context
* @param user
*/
define(integration: IIntegration, context: IContext<IPersona<typeof personaMeta>,InputResultMap>) {
/**
* declare all steps here
*/
${stepCode.varDeclarations.join('\n')}
/**
* chain steps correctly here
*/
${stepCode.stepChains}
/**
* pass all steps here so that paragon can keep track of changes
*/
return this.register({ ${Object.values(stepIdToVariableMap).join(', ')} });
}
/**
* define permissions for workflow
* @param context
*/
definePermissions(${workflowMeta.permissions ? 'context' : '_context'} : IPermissionContext<IPersona<typeof personaMeta>>): ConditionalInput | undefined {
return ${workflowMeta.permissions
? (0, source_codegen_1.convertSourceToCode)({
type: 'CONDITION',
condition: workflowMeta.permissions,
}, stepDependencies)
: 'undefined'}
}
}

@@ -69,17 +141,12 @@ `;

exports.workflowToCode = workflowToCode;
const getStepCodeParts = (startStepId, stepMap, stepIdToVariableMap, dependencies) => {
var _a;
const getStepCodeParts = (startStepId, stepMap, dependencies) => {
const imports = [];
const varDeclarations = [];
const { stepIdToVariableMap } = dependencies;
let stepChains = '';
let currentStep = stepMap[startStepId];
let stepCount = 1;
const totalKeys = Object.values(stepIdToVariableMap).length;
const prefix = totalKeys ? `${totalKeys}_` : '';
const variableChains = [];
while (currentStep != undefined) {
const variableName = (((_a = currentStep._migrations) === null || _a === void 0 ? void 0 : _a['name']) ||
`step${prefix}${stepCount}`);
stepIdToVariableMap[currentStep.id] = variableName;
const stepCode = getStepCodePart(currentStep, stepIdToVariableMap, stepMap, dependencies);
const variableName = stepIdToVariableMap[currentStep.id];
const stepCode = getStepCodePart(currentStep, stepMap, dependencies);
imports.push(...stepCode.imports);

@@ -100,3 +167,2 @@ varDeclarations.push(...stepCode.varDeclarations);

}
stepCount += 1;
}

@@ -122,6 +188,8 @@ if (variableChains.length) {

};
const getStepCodePart = (step, stepIdToVariableMap, stepMap, dependencies) => {
var _a, _b, _c, _d, _e, _f;
const getStepCodePart = (step, stepMap, dependencies) => {
var _a, _b, _c, _d, _e, _f, _g;
const { stepIdToVariableMap } = dependencies;
const varDeclarations = [];
const imports = [];
const variableName = stepIdToVariableMap[step.id];
let stepChains = '';

@@ -131,13 +199,15 @@ switch (step.type) {

varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:ActionStep = new ActionStep({
actionType : ${step.parameters.actionType},
intent : ${step.parameters.intent},
parameters : ${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.actionParameters, stepIdToVariableMap)}
});
`);
const ${variableName} = integration.withIntent('${step.parameters.intent}',${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.actionParameters, dependencies)});
`);
break;
case core_1.StepType.ACTION_TRIGGER:
varDeclarations.push(`
const ${variableName} = integration.withTrigger('${step.parameters.intent}',${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.actionParameters, dependencies)});
`);
break;
case core_1.StepType.CRON:
const cronOptions = (0, cron_1.getCronOptions)(step.parameters.schedule);
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:CronStep = new CronStep(${(0, json_1.stringifyObject)((0, cron_1.getCronOptions)(step.parameters.schedule))});
`);
const ${variableName} = new CronStep(${(0, json_1.stringifyObject)(cronOptions)});
`);
break;

@@ -147,24 +217,26 @@ case core_1.StepType.CUSTOM_INTEGRATION_REQUEST:

varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}: RequestStep = new RequestStep({
path: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.url, stepIdToVariableMap)},
params:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, stepIdToVariableMap)},
headers:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, stepIdToVariableMap)},
body:${['xml', 'raw'].includes(requestBodyType)
? (0, source_codegen_1.convertSourceToCode)(step.parameters.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, stepIdToVariableMap)
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.body, stepIdToVariableMap)},
${step.parameters.pagination ? '' : ''}
});
`);
const ${variableName} = new IntegrationRequestStep({
path: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.url, dependencies)},
params:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, dependencies)},
headers:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, dependencies)},
body:${['xml', 'raw'].includes(requestBodyType)
? (0, source_codegen_1.convertSourceToCode)(step.parameters.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.body, dependencies)},
description:"${step.description || ''}",
${((_b = step.parameters.paginations) === null || _b === void 0 ? void 0 : _b.enabled) ? `` : ''}
});
`);
break;
case core_1.StepType.DELAY:
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:DelayStep = new DelayStep({
unit: '${step.parameters.unit}',
value: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.value, stepIdToVariableMap)},
});
`);
const ${variableName} = new DelayStep({
unit: '${step.parameters.unit}',
value: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.value, dependencies)},
description:"${step.description || ''}"
});
`);
break;
case core_1.StepType.ENDPOINT:
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:EndpointStep = new EndpointStep({
const ${variableName} = new EndpointStep({
allowArbitraryPayload : ${step.parameters.allowArbitraryPayload},

@@ -185,19 +257,20 @@ ${step.parameters.allowArbitraryPayload

varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:EventStep = new EventStep(event);
`);
const ${variableName} = new EventStep(event);
`);
break;
case core_1.StepType.FUNCTION:
const paramsCode = (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.parameters, stepIdToVariableMap);
const paramsCode = (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.parameters, dependencies);
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:FunctionStep = new FunctionStep({
code: ${step.parameters.code},
parameters: ${paramsCode}
});
`);
const ${variableName} = new FunctionStep({
code: ${step.parameters.code},
parameters: ${paramsCode},
description:"${step.description || ''}",
});
`);
break;
case core_1.StepType.IFELSE:
const ifStepId = (_b = step.parameters.choices.find((choice) => choice.label === 'Yes')) === null || _b === void 0 ? void 0 : _b.next;
const elseStepId = (_c = step.parameters.choices.find((choice) => choice.label === 'No')) === null || _c === void 0 ? void 0 : _c.next;
const ifStepId = (_c = step.parameters.choices.find((choice) => choice.label === 'Yes')) === null || _c === void 0 ? void 0 : _c.next;
const elseStepId = (_d = step.parameters.choices.find((choice) => choice.label === 'No')) === null || _d === void 0 ? void 0 : _d.next;
if (ifStepId) {
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(ifStepId, stepMap, stepIdToVariableMap, dependencies);
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(ifStepId, stepMap, dependencies);
imports.push(...nextIterateImports);

@@ -208,3 +281,3 @@ varDeclarations.push(...nextIterateVarDeclartions);

if (elseStepId) {
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(elseStepId, stepMap, stepIdToVariableMap, dependencies);
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(elseStepId, stepMap, dependencies);
imports.push(...nextIterateImports);

@@ -216,6 +289,6 @@ varDeclarations.push(...nextIterateVarDeclartions);

}
const ifCondition = (_d = step.parameters.choices.find((choice) => choice.label === 'Yes')) === null || _d === void 0 ? void 0 : _d.conditionWrapper;
const ifCondition = (_e = step.parameters.choices.find((choice) => choice.label === 'Yes')) === null || _e === void 0 ? void 0 : _e.conditionWrapper;
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:ConditionalStep = new ConditionalStep({
if : ${!ifCondition
const ${variableName} = new ConditionalStep({
if : ${!ifCondition
? 'undefined'

@@ -225,9 +298,10 @@ : (0, source_codegen_1.convertSourceToCode)({

condition: ifCondition,
}, stepIdToVariableMap)}
});
`);
}, dependencies)},
description:"${step.description || ''}",
});
`);
break;
case core_1.StepType.INTEGRATION_ENABLED:
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:IntegrationEnabledStep = new IntegrationEnabledStep({});
const ${variableName} = new IntegrationEnabledStep({});
`);

@@ -238,3 +312,3 @@ break;

if (nextStepId) {
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(nextStepId, stepMap, stepIdToVariableMap, dependencies);
const { imports: nextIterateImports, varDeclarations: nextIterateVarDeclartions, stepChains: nextIterationStepChains, } = getStepCodeParts(nextStepId, stepMap, dependencies);
imports.push(...nextIterateImports);

@@ -245,38 +319,46 @@ varDeclarations.push(...nextIterateVarDeclartions);

varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}:FanOutStep = new FanOutStep({
iterator : ${(0, source_codegen_1.convertSourceToCode)(step.parameters.iterator, stepIdToVariableMap)},
});
`);
const ${variableName} = new FanOutStep({
description:"${step.description || ''}",
iterator : ${(0, source_codegen_1.convertSourceToCode)(step.parameters.iterator, dependencies)},
});
`);
break;
case core_1.StepType.RESPONSE:
const responseType = (_e = step.parameters.responseType) !== null && _e !== void 0 ? _e : 'JSON';
const responseType = (_f = step.parameters.responseType) !== null && _f !== void 0 ? _f : 'JSON';
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}: ResponseStep = new ResponseStep({
statusCode:${step.parameters.statusCode},
responseType:"${responseType}",
body: ${responseType === 'FILE'
const ${variableName} = new ResponseStep({
description:"${step.description || ''}",
statusCode:${step.parameters.statusCode},
responseType:"${responseType}",
body: ${responseType === 'FILE'
? step.parameters.bodyFile
? (0, source_codegen_1.convertSourceToCode)(step.parameters.bodyFile || source_codegen_1.EMPTY_TOKENIZED_SOURCE, stepIdToVariableMap)
? (0, source_codegen_1.convertSourceToCode)(step.parameters.bodyFile || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
: '""'
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.bodyData, stepIdToVariableMap)}
});
`);
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.bodyData, dependencies)}
});
`);
break;
case core_1.StepType.REQUEST:
const bodyType = (_f = step.parameters.bodyType) !== null && _f !== void 0 ? _f : 'json';
const bodyType = (_g = step.parameters.bodyType) !== null && _g !== void 0 ? _g : 'json';
varDeclarations.push(`
const ${stepIdToVariableMap[step.id]}: RequestStep = new RequestStep({
url: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.url, stepIdToVariableMap)},
method:"${step.parameters.httpMethod}",
params:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, stepIdToVariableMap)},
headers:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, stepIdToVariableMap)},
${step.parameters.httpMethod === 'GET'
const ${variableName} = new RequestStep({
description:"${step.description || ''}",
url: ${(0, source_codegen_1.convertSourceToCode)(step.parameters.url, dependencies)},
method:"${step.parameters.httpMethod}",
params:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, dependencies)},
headers:${(0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.params, dependencies)},
${step.parameters.httpMethod === 'GET'
? ''
: `
body:${['xml', 'raw'].includes(bodyType)
? (0, source_codegen_1.convertSourceToCode)(step.parameters.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, stepIdToVariableMap)
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.body, stepIdToVariableMap)}`}
});
`);
body:${['xml', 'raw'].includes(bodyType)
? (0, source_codegen_1.convertSourceToCode)(step.parameters.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
: (0, source_codegen_1.covertKeyedSourceParamsToCode)(step.parameters.body, dependencies)}`}
});
`);
break;
case core_1.StepType.UNSELECTED_TRIGGER:
varDeclarations.push(`
const ${variableName} = new UnselectedStep();
`);
break;
default:

@@ -283,0 +365,0 @@ logger_1.default.fatal(`Invalid step type "${step['type']}`);

@@ -0,3 +1,3 @@

import { ProjectCompiler } from '../../compiler/compilers/project.compiler';
import { IAction } from '../command.interface';
import { ProjectCompiler } from '../../compilers/project.compiler';
import { BuildCommandOptions } from './build.types';

@@ -4,0 +4,0 @@ export declare class BuildAction implements IAction<BuildCommandOptions, void> {

@@ -5,9 +5,10 @@ "use strict";

const tslib_1 = require("tslib");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const fs_1 = tslib_1.__importDefault(require("fs"));
const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
const ts_compiler_1 = tslib_1.__importDefault(require("../../compilers/ts.compiler"));
const project_compiler_1 = require("../../compilers/project.compiler");
const project_compiler_1 = require("../../compiler/compilers/project.compiler");
const ts_compiler_1 = tslib_1.__importDefault(require("../../compiler/ts.compiler"));
const config_1 = require("../../config");
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
const build_utils_1 = require("./build.utils");
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
class BuildAction {

@@ -18,20 +19,18 @@ constructor() {

handle(options) {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (options.language === 'typescript') {
yield (0, build_utils_1.getProjectRoot)('ts');
spinners_1.default.add('build-typescript', {
text: 'Building Typescript project...',
});
ts_compiler_1.default.run({ configPath: options.path });
spinners_1.default.succeed('build-typescript', {
text: 'Typescript project successfully built.',
});
}
const { projectId } = yield (0, config_1.getParagraphProjectDetails)();
yield (0, build_utils_1.getProjectRoot)('ts');
spinners_1.default.add('build-typescript', {
text: 'Building Typescript project...',
});
ts_compiler_1.default.run({ configPath: options.path });
spinners_1.default.succeed('build-typescript', {
text: 'Typescript project successfully built.',
});
const projectRoot = yield (0, build_utils_1.getProjectRoot)();
const output = yield this.projectCompiler.compile({
projectRoot,
integrations: (_a = options.integration) !== null && _a !== void 0 ? _a : [],
projectId,
});
const outputFileName = `${Date.now()}-build.json`;
const outputFileName = 'build.json';
spinners_1.default.add('writing-output', {

@@ -42,4 +41,4 @@ text: `Writiing build in ./out/${outputFileName} file.`,

yield (0, rimraf_1.default)(outputPath);
yield fs_1.default.promises.mkdir(outputPath);
yield fs_1.default.promises.writeFile(path_1.default.resolve(outputPath, outputFileName), JSON.stringify(output, null, 2));
yield fs_extra_1.default.promises.mkdir(outputPath);
yield fs_extra_1.default.promises.writeFile(path_1.default.resolve(outputPath, outputFileName), JSON.stringify(output, null, 2));
spinners_1.default.succeed('writing-output', {

@@ -46,0 +45,0 @@ text: `Created build in ./out/${outputFileName} file.`,

@@ -5,2 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const base_api_1 = require("../../apis/base.api");
const build_action_1 = require("./build.action");

@@ -15,6 +16,4 @@ class BuildCommand {

.description('Build project')
.option('--integration <integration...>', 'Build only specified integration')
.option('-p, --path [path]', 'Path to tsconfig file.')
.option('-l,--language [language]', 'Programming language to be used (TypeScript or JavaScript).', 'typescript')
.action((rawOptions) => tslib_1.__awaiter(this, void 0, void 0, function* () {
yield (0, base_api_1.getToken)();
const options = this.sanitizeOptions(rawOptions);

@@ -21,0 +20,0 @@ return this.actionHandler.handle(options);

@@ -6,2 +6,3 @@ "use strict";

const glob_1 = require("glob");
const logger_1 = tslib_1.__importDefault(require("../../logger"));
const getProjectRoot = (extension = 'js') => tslib_1.__awaiter(void 0, void 0, void 0, function* () {

@@ -12,3 +13,3 @@ const integrationPaths = yield (0, glob_1.glob)(`${process.cwd()}/**/integrations/*/config.${extension}`, {

if (!integrationPaths.length) {
throw new Error('');
logger_1.default.fatal('No integration found for project.');
}

@@ -15,0 +16,0 @@ const projectRoot = integrationPaths[0].split('/integrations/')[0];

@@ -5,12 +5,14 @@ "use strict";

const tslib_1 = require("tslib");
const logger_1 = tslib_1.__importDefault(require("../logger"));
const auth_1 = require("./auth");
const build_1 = require("./build");
const login_1 = require("./login");
const init_1 = require("./init");
const logger_1 = tslib_1.__importDefault(require("../logger"));
const push_1 = require("./push");
class CommandLoader {
static load(program) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
new auth_1.AuthCommand().load(program);
new build_1.BuildCommand().load(program);
new login_1.LoginCommand().load(program);
new init_1.InitCommand().load(program);
new push_1.PushCommand().load(program);
this.handleInvalidCommand(program);

@@ -17,0 +19,0 @@ });

@@ -1,2 +0,2 @@

export * from './login/login.command';
export * from './auth/login/login.command';
export * from './build/build.command';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./login/login.command"), exports);
tslib_1.__exportStar(require("./auth/login/login.command"), exports);
tslib_1.__exportStar(require("./build/build.command"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { ProjectCompiler } from '../../compilers/project.compiler';
import { ProjectCompiler } from '../../compiler/compilers/project.compiler';
import { IAction } from '../command.interface';

@@ -3,0 +3,0 @@ import { InitCommandOptions } from './init.types';

@@ -8,4 +8,5 @@ "use strict";

const prompts_1 = tslib_1.__importDefault(require("prompts"));
const project_api_1 = require("../../apis/project.api");
const codegen_utils_1 = require("../../codegen/codegen.utils");
const project_compiler_1 = require("../../compilers/project.compiler");
const project_compiler_1 = require("../../compiler/compilers/project.compiler");
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));

@@ -32,10 +33,5 @@ const logger_1 = tslib_1.__importDefault(require("../../logger"));

return tslib_1.__awaiter(this, void 0, void 0, function* () {
spinners_1.default.add('get-projects', { text: 'Fetching projects...' });
yield (0, init_utils_1.sleep)(3);
spinners_1.default.succeed('get-projects', { text: 'Fetched projects' });
const projects = [
{ title: 'project-1', value: 'project-1' },
{ title: 'project-2', value: 'project-2' },
{ title: 'project-3', value: 'project-3' },
];
spinners_1.default.add('get-projects', { text: 'Fetching project lists...' });
const projects = yield (0, project_api_1.getProjectList)();
spinners_1.default.succeed('get-projects', { text: 'Fetched project lists' });
const { projectId } = yield (0, prompts_1.default)({

@@ -45,17 +41,26 @@ type: 'select',

message: 'Select project',
choices: projects,
choices: projects.map((project) => ({
title: project.title,
value: project.id,
})),
});
const projectName = (0, init_utils_1.sanitizeAppName)(projects.find(({ value }) => value === projectId).title);
if (!projectId) {
logger_1.default.fatal('No project selected.');
}
const projectName = (0, init_utils_1.sanitizeAppName)(projects.find(({ id }) => id === projectId).title);
const projectRoot = path_1.default.join(process.cwd(), projectName);
const projectSrcPath = path_1.default.join(projectRoot, 'src');
yield fs_extra_1.default.promises.mkdir(projectSrcPath, { recursive: true });
yield fs_extra_1.default.writeFile(path_1.default.join(projectRoot, 'paragon.json'), JSON.stringify({
projectId,
}));
spinners_1.default.add('fetch-project-data', {
text: 'Fetching integrations...',
text: 'Fetching project...',
});
yield (0, init_utils_1.sleep)(3);
const project = yield (0, project_api_1.getProjectBuild)(projectId);
spinners_1.default.succeed('fetch-project-data', {
text: 'Fetched integrations',
text: 'Fetched project',
});
const json = require(path_1.default.join(__dirname, '../../..', 'sample/sample.js')).samplebuild;
spinners_1.default.add('build-project', { text: 'Building Project...' });
yield (0, codegen_utils_1.generateProjectFiles)(json, projectSrcPath);
yield (0, codegen_utils_1.generateProjectFiles)(project, projectSrcPath);
spinners_1.default.succeed('build-project', { text: 'Built Project' });

@@ -70,2 +75,5 @@ yield this.installDependencies(projectRoot, options);

.trim();
if (process.cwd() === projectRoot) {
logger_1.default.fatal('Provide project name in init command - para init projectname');
}
yield fs_extra_1.default.promises.mkdir(projectRoot, { recursive: true });

@@ -72,0 +80,0 @@ const templatePath = path_1.default.resolve(__dirname, `../../templates/${options.language}`);

@@ -5,2 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const base_api_1 = require("../../apis/base.api");
const init_action_1 = require("./init.action");

@@ -20,2 +21,3 @@ class InitCommand {

const options = this.sanitizeOptions(rawOptions);
yield (0, base_api_1.getToken)();
return this.actionHandler.handle(Object.assign(Object.assign({}, options), { extraArgs: program.args }));

@@ -22,0 +24,0 @@ }));

@@ -17,6 +17,8 @@ "use strict";

'@trivago/prettier-plugin-sort-imports': '^4.2.0',
prettier: '^2.2.1',
prettier: '^3.1.0',
'prettier-plugin-organize-imports': '^3.2.3',
'@types/node': '^18.13.0',
typescript: '^5.3.2',
},
};
//# sourceMappingURL=init.constants.js.map

@@ -1,4 +0,2 @@

import { IProjectConfig } from './config.types';
export declare const SYSTEM_CONFIG_DIR_PATH: string;
export declare const DEFAULT_PROJECT_CONFIG: IProjectConfig;
export declare const DEFAULT_PROFILE: string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_PROFILE = exports.DEFAULT_PROJECT_CONFIG = exports.SYSTEM_CONFIG_DIR_PATH = void 0;
exports.DEFAULT_PROFILE = exports.SYSTEM_CONFIG_DIR_PATH = void 0;
const tslib_1 = require("tslib");
const os = tslib_1.__importStar(require("node:os"));
const node_os_1 = require("node:os");
const path = tslib_1.__importStar(require("node:path"));
exports.SYSTEM_CONFIG_DIR_PATH = path.resolve(os.homedir(), '.paragon');
exports.DEFAULT_PROJECT_CONFIG = {
config_path: exports.SYSTEM_CONFIG_DIR_PATH,
};
exports.SYSTEM_CONFIG_DIR_PATH = path.resolve((0, node_os_1.homedir)(), '.paragon');
exports.DEFAULT_PROFILE = 'default';
//# sourceMappingURL=config.constants.js.map

@@ -6,14 +6,14 @@ export declare enum SystemFile {

export declare const SystemFileToPathMap: Record<SystemFile, string>;
export interface IAuth {
username: string;
password: string;
}
export interface IProfileAuth extends IAuth {
export type SystemFileToConfig = {
[SystemFile.CREDENTIALS]: IProfileCredential;
[SystemFile.PROFILES]: IProfile;
};
export interface IProfileCredential {
profile: string;
token: string;
}
export interface IAuthConfig extends Record<string, IAuth> {
export interface ICredentialConfig extends Record<string, IProfileCredential> {
}
export declare enum Service {
HERMES = "hermes",
DASHBOARD = "dashboard",
ZEUS = "zeus"

@@ -25,9 +25,7 @@ }

environment?: Record<string, string>;
services?: Record<Service, string>;
services: Record<Service, string>;
}
export interface IProfileConfig extends Record<string, IProfile> {
export interface ParagraphProjectJSON {
projectId: string;
profile: string;
}
export interface IProjectConfig {
config_path?: string;
profile?: string;
}

@@ -8,3 +8,3 @@ "use strict";

SystemFile["PROFILES"] = "PROFILES";
})(SystemFile = exports.SystemFile || (exports.SystemFile = {}));
})(SystemFile || (exports.SystemFile = SystemFile = {}));
exports.SystemFileToPathMap = {

@@ -16,5 +16,5 @@ [SystemFile.CREDENTIALS]: 'credentials.json',

(function (Service) {
Service["HERMES"] = "hermes";
Service["DASHBOARD"] = "dashboard";
Service["ZEUS"] = "zeus";
})(Service = exports.Service || (exports.Service = {}));
})(Service || (exports.Service = Service = {}));
//# sourceMappingURL=config.types.js.map

@@ -1,9 +0,9 @@

import { IAuth, IProfile, IProfileAuth, IProfileConfig, IProjectConfig, SystemFile } from './config.types';
export declare function initializeSystemFiles(systemDirectoryPath?: string): Promise<void>;
export declare function initializeSystemDirectory(systemDirectoryPath: string): Promise<void>;
export declare function initializeOrUpdateFile(file: SystemFile, systemDirectoryPath: string, fileContents?: string): Promise<void>;
export declare function loadProfileConfig(projectConfig: IProjectConfig): Promise<IProfileConfig>;
export declare function loadProfile(projectConfig: IProjectConfig): Promise<IProfile>;
export declare function loadProjectConfig(): Promise<IProjectConfig>;
export declare function loadAuthForProfile(projectConfig: IProjectConfig): Promise<IAuth>;
export declare function updateAuthForProfile(auth: IProfileAuth, projectConfig: IProjectConfig): Promise<void>;
import { ProjectBuild } from '../apis/api.types';
import { ParagraphProjectJSON, SystemFile, SystemFileToConfig } from './config.types';
export declare const initializeSystemFiles: (systemDirectoryPath?: string) => Promise<void>;
export declare const initializeSystemDirectory: (systemDirectoryPath: string) => Promise<void>;
export declare const upsertConfigFile: <T extends SystemFile>(file: T, config: SystemFileToConfig[T]) => Promise<void>;
export declare const removeProfile: (_profile: string) => Promise<void>;
export declare const getConfigForProfile: <T extends SystemFile>(file: T, profileName: string) => Promise<SystemFileToConfig[T]>;
export declare const getParagraphProjectDetails: () => Promise<ParagraphProjectJSON>;
export declare const getLocalProjectBuild: () => Promise<ProjectBuild>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateAuthForProfile = exports.loadAuthForProfile = exports.loadProjectConfig = exports.loadProfile = exports.loadProfileConfig = exports.initializeOrUpdateFile = exports.initializeSystemDirectory = exports.initializeSystemFiles = void 0;
exports.getLocalProjectBuild = exports.getParagraphProjectDetails = exports.getConfigForProfile = exports.removeProfile = exports.upsertConfigFile = exports.initializeSystemDirectory = exports.initializeSystemFiles = void 0;
const tslib_1 = require("tslib");
const fs = tslib_1.__importStar(require("fs-extra"));
const path = tslib_1.__importStar(require("node:path"));
const fs = tslib_1.__importStar(require("fs-extra"));
const logger_1 = tslib_1.__importDefault(require("../logger"));
const config_constants_1 = require("./config.constants");
const config_types_1 = require("./config.types");
function initializeSystemFiles(systemDirectoryPath = config_constants_1.SYSTEM_CONFIG_DIR_PATH) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
logger_1.default.info('Initializing system files...');
yield initializeSystemDirectory(systemDirectoryPath);
const systemFiles = Object.values(config_types_1.SystemFile);
yield Promise.all(systemFiles.map((file) => initializeOrUpdateFile(file, systemDirectoryPath)));
});
}
const initializeSystemFiles = (systemDirectoryPath = config_constants_1.SYSTEM_CONFIG_DIR_PATH) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
logger_1.default.debug('Initializing system files...');
yield (0, exports.initializeSystemDirectory)(systemDirectoryPath);
const systemFiles = Object.values(config_types_1.SystemFile);
yield Promise.all(systemFiles.map((file) => initializeOrUpdateFile(file, systemDirectoryPath)));
});
exports.initializeSystemFiles = initializeSystemFiles;
function initializeSystemDirectory(systemDirectoryPath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
logger_1.default.info('Initializing system directory...', { systemDirectoryPath });
const isDir = yield fs.exists(systemDirectoryPath);
if (!isDir) {
logger_1.default.info('Initialized system directory.');
yield fs.mkdir(systemDirectoryPath);
}
});
}
const initializeSystemDirectory = (systemDirectoryPath) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
logger_1.default.debug('Initializing system directory...', { systemDirectoryPath });
const isDir = yield fs.exists(systemDirectoryPath);
if (!isDir) {
logger_1.default.debug('Initialized system directory.');
yield fs.mkdir(systemDirectoryPath);
}
});
exports.initializeSystemDirectory = initializeSystemDirectory;
function initializeOrUpdateFile(file, systemDirectoryPath, fileContents) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
logger_1.default.info('Initializing or updating file...', {
file,
systemDirectoryPath,
});
const filePath = path.resolve(systemDirectoryPath, config_types_1.SystemFileToPathMap[file]);
const doesExist = yield fs.exists(filePath);
if (!doesExist || fileContents) {
logger_1.default.info('Initialized or updated file.');
yield fs.writeFile(filePath, fileContents || '{}', { encoding: 'utf-8' });
}
const initializeOrUpdateFile = (file, systemDirectoryPath, fileContents) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
logger_1.default.debug('Initializing or updating file...', {
file,
systemDirectoryPath,
});
}
exports.initializeOrUpdateFile = initializeOrUpdateFile;
function readFile(file, systemDirectoryPath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
logger_1.default.info('Reading file...', { file, systemDirectoryPath });
const filePath = path.resolve(systemDirectoryPath, config_types_1.SystemFileToPathMap[file]);
const fileContents = yield fs.readFile(filePath, 'utf-8');
return JSON.parse(fileContents);
});
}
function createDefaultProfile(projectConfig) {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const profile = {
name: config_constants_1.DEFAULT_PROFILE,
default: true,
};
const configPath = (_a = projectConfig.config_path) !== null && _a !== void 0 ? _a : config_constants_1.SYSTEM_CONFIG_DIR_PATH;
const currentProfileConfig = yield readFile(config_types_1.SystemFile.PROFILES, configPath);
const updatedProfileConfig = Object.assign(Object.assign({}, currentProfileConfig), { [profile.name]: profile });
const stringifiedUpdatedProfileConfig = JSON.stringify(updatedProfileConfig, null, 2);
yield initializeOrUpdateFile(config_types_1.SystemFile.PROFILES, configPath, stringifiedUpdatedProfileConfig);
return profile;
});
}
function loadProfileConfig(projectConfig) {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const configPath = (_a = projectConfig.config_path) !== null && _a !== void 0 ? _a : config_constants_1.SYSTEM_CONFIG_DIR_PATH;
return readFile(config_types_1.SystemFile.PROFILES, configPath);
});
}
exports.loadProfileConfig = loadProfileConfig;
function loadProfile(projectConfig) {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const profileConfig = yield loadProfileConfig(projectConfig);
const profileName = (_a = projectConfig.profile) !== null && _a !== void 0 ? _a : config_constants_1.DEFAULT_PROFILE;
let profile = (_b = profileConfig[profileName]) !== null && _b !== void 0 ? _b : Object.values(profileConfig).find((profile) => profile.default);
if (!profile) {
profile = yield createDefaultProfile(projectConfig);
}
return profile;
});
}
exports.loadProfile = loadProfile;
function loadProjectConfig() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cwd = process.cwd();
const projectConfigFilePath = path.resolve(cwd, 'paragon.json');
const doesProjectConfigFileExist = yield fs.exists(projectConfigFilePath);
let projectConfig;
if (doesProjectConfigFileExist) {
const projectConfigString = yield fs.readFile(projectConfigFilePath, 'utf-8');
projectConfig = JSON.parse(projectConfigString);
if (projectConfig.config_path) {
projectConfig.config_path = path.resolve(process.cwd(), projectConfig.config_path);
}
}
else {
projectConfig = config_constants_1.DEFAULT_PROJECT_CONFIG;
}
yield initializeSystemFiles(projectConfig.config_path);
return projectConfig;
});
}
exports.loadProjectConfig = loadProjectConfig;
function loadAuthForProfile(projectConfig) {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const configPath = (_a = projectConfig.config_path) !== null && _a !== void 0 ? _a : config_constants_1.SYSTEM_CONFIG_DIR_PATH;
const authConfig = yield readFile(config_types_1.SystemFile.CREDENTIALS, configPath);
const profileName = (_b = projectConfig.profile) !== null && _b !== void 0 ? _b : config_constants_1.DEFAULT_PROFILE;
const auth = authConfig[profileName];
if (!auth) {
throw new Error('No authentication configured for profile');
}
return auth;
});
}
exports.loadAuthForProfile = loadAuthForProfile;
function updateAuthForProfile(auth, projectConfig) {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const configPath = (_a = projectConfig.config_path) !== null && _a !== void 0 ? _a : config_constants_1.SYSTEM_CONFIG_DIR_PATH;
const authConfig = yield readFile(config_types_1.SystemFile.CREDENTIALS, configPath);
const profileName = (_b = projectConfig.profile) !== null && _b !== void 0 ? _b : config_constants_1.DEFAULT_PROFILE;
authConfig[profileName] = auth;
const serializedAuthConfig = JSON.stringify(authConfig, null, 2);
yield initializeOrUpdateFile(config_types_1.SystemFile.CREDENTIALS, configPath, serializedAuthConfig);
});
}
exports.updateAuthForProfile = updateAuthForProfile;
const filePath = path.resolve(systemDirectoryPath, config_types_1.SystemFileToPathMap[file]);
const doesExist = yield fs.exists(filePath);
if (!doesExist || fileContents) {
logger_1.default.debug('Initialized or updated file.');
yield fs.writeFile(filePath, fileContents || '{}', { encoding: 'utf-8' });
}
});
const readFile = (file, systemDirectoryPath = config_constants_1.SYSTEM_CONFIG_DIR_PATH) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
logger_1.default.debug('Reading file...', { file, systemDirectoryPath });
const filePath = path.resolve(systemDirectoryPath, config_types_1.SystemFileToPathMap[file]);
const fileContents = yield fs.readFile(filePath, 'utf-8');
return JSON.parse(fileContents);
});
const upsertConfigFile = (file, config) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
let previousFileContent = undefined;
try {
previousFileContent = yield readFile(file);
}
catch (_a) { }
const profileName = file === config_types_1.SystemFile.PROFILES ? config['name'] : config['profile'];
let concatedConfig = {
[profileName]: config,
};
if (previousFileContent) {
concatedConfig = Object.assign(Object.assign({}, previousFileContent), concatedConfig);
}
yield initializeOrUpdateFile(file, config_constants_1.SYSTEM_CONFIG_DIR_PATH, JSON.stringify(concatedConfig, null, 2));
});
exports.upsertConfigFile = upsertConfigFile;
const removeProfile = (_profile) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield Promise.all([
initializeOrUpdateFile(config_types_1.SystemFile.PROFILES, config_constants_1.SYSTEM_CONFIG_DIR_PATH, '{}'),
initializeOrUpdateFile(config_types_1.SystemFile.CREDENTIALS, config_constants_1.SYSTEM_CONFIG_DIR_PATH, '{}'),
]);
});
exports.removeProfile = removeProfile;
const getConfigForProfile = (file, profileName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const config = yield readFile(file);
if (!config[profileName]) {
throw new Error(`Profiles not found for profile - ${profileName}`);
}
return config[profileName];
});
exports.getConfigForProfile = getConfigForProfile;
const getParagraphProjectDetails = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
try {
const projectJson = JSON.parse(yield fs.readFile(path.join(process.cwd(), 'paragon.json'), 'utf-8'));
return projectJson;
}
catch (err) {
logger_1.default.fatal('Not a paragraph project.');
}
});
exports.getParagraphProjectDetails = getParagraphProjectDetails;
const getLocalProjectBuild = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const buildPath = path.join(process.cwd(), 'out', 'build.json');
try {
const fileString = yield fs.readFile(buildPath, 'utf-8');
return JSON.parse(fileString);
}
catch (_b) {
logger_1.default.fatal('Project build not found , please run "para build" to create one.');
}
});
exports.getLocalProjectBuild = getLocalProjectBuild;
//# sourceMappingURL=config.utils.js.map

@@ -0,2 +1,3 @@

export * from './config.constants';
export * from './config.types';
export * from './config.utils';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./config.constants"), exports);
tslib_1.__exportStar(require("./config.types"), exports);
tslib_1.__exportStar(require("./config.utils"), exports);
//# sourceMappingURL=index.js.map
export declare const capitalizeFirstLetter: (value: string) => string;
export declare const wrapMultilineString: (value: string) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.capitalizeFirstLetter = void 0;
exports.wrapMultilineString = exports.capitalizeFirstLetter = void 0;
const capitalizeFirstLetter = (value) => {

@@ -8,2 +8,6 @@ return value.charAt(0).toUpperCase() + value.slice(1);

exports.capitalizeFirstLetter = capitalizeFirstLetter;
const wrapMultilineString = (value) => {
return '`' + value + '`';
};
exports.wrapMultilineString = wrapMultilineString;
//# sourceMappingURL=strings.js.map

@@ -13,2 +13,3 @@ "use strict";

LOG_LEVEL[LOG_LEVEL["WARNING"] = 5] = "WARNING";
LOG_LEVEL[LOG_LEVEL["DEBUG"] = 6] = "DEBUG";
})(LOG_LEVEL || (LOG_LEVEL = {}));

@@ -36,17 +37,53 @@ const logWithColor = (logLevel, ...messages) => {

console.log('❌ ', chalk_1.default.red(completeMessage));
process.exit(1);
break;
case LOG_LEVEL.SUCCESS:
console.log('✅ ', chalk_1.default.green(completeMessage));
break;
case LOG_LEVEL.DEBUG:
break;
}
};
const paragonLogoText = `
...........
........@@@.........
........@@@@@@@@@@@@@........
........@@@@@@@@@@@@@@@@@@@@@........
........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@........
........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.......
....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....
.........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@........
....@........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@........@....
....@@@@@@.......@@@@@@@@@@@@@@@@@@@@@........@@@@@....
....@@@@@@@@@@........@@@@@@@@@@@@.......@@@@@@@@@@....
......@@@@@@@@@@@@........@@@........@@@@@@@@@@@@@.....
..........@@@@@@@@@@@@...........@@@@@@@@@@@@@.........
....@@........@@@@@@@@@@@@@@@@@@@@@@@@@@@........@@....
....@@@@@@@.......@@@@@@@@@@@@@@@@@@@.......@@@@@@@....
....@@@@@@@@@@@........@@@@@@@@@........@@@@@@@@@@@....
.......@@@@@@@@@@@@.................@@@@@@@@@@@@@......
...........@@@@@@@@@@@@.........@@@@@@@@@@@@@........
....@@@........@@@@@@@@@@@@@@@@@@@@@@@@@........
....@@@@@@@@........@@@@@@@@@@@@@@@@........
....@@@@@@@@@@@@........@@@@@@@@...........
.......@@@@@@@@@@@@...............@@@@....
........@@@@@@@@@@@@@.....@@@@@@@@@....
........@@@@@@@@@@@@@@@@@@@@@@.....
........@@@@@@@@@@@@@........
........@@@@@........
.............
`;
const logger = {
error: (...messages) => logWithColor(LOG_LEVEL.ERROR, ...messages),
fatal: (...messages) => logWithColor(LOG_LEVEL.FATAL, ...messages),
fatal: (...messages) => {
logWithColor(LOG_LEVEL.FATAL, ...messages);
process.exit(1);
},
info: (...messages) => logWithColor(LOG_LEVEL.INFO, ...messages),
log: console.log,
debug: (...messages) => logWithColor(LOG_LEVEL.DEBUG, ...messages),
success: (...messages) => logWithColor(LOG_LEVEL.SUCCESS, ...messages),
warn: (...messages) => logWithColor(LOG_LEVEL.WARNING, ...messages),
printParagon: () => console.log(paragonLogoText),
};
exports.default = logger;
//# sourceMappingURL=logger.js.map
export type Logger = {
error: (...messages: any[]) => void;
fatal: (...messages: any[]) => void;
fatal: (...messages: any[]) => never;
info: (...messages: any[]) => void;
debug: (...messages: any[]) => void;
log: (...messages: any[]) => void;
success: (...messages: any[]) => void;
warn: (...messages: any[]) => void;
printParagon: () => void;
};

@@ -1,2 +0,2 @@

import { IEvent } from '@useparagon/core/event';
import { IEventInit } from '@useparagon/core/event';

@@ -7,3 +7,3 @@ type EventSchema = {

const event: IEvent<EventSchema> = {
const event: IEventInit<EventSchema> = {
/**

@@ -10,0 +10,0 @@ * name of event

{
"name": "@useparagon/cli",
"version": "0.0.1-canary.3",
"version": "0.0.1-canary.4",
"description": "CLI for WaC (Workflows as Code)",

@@ -20,3 +20,2 @@ "repository": "https://github.com/useparagon/paragraph",

"clean": "rimraf ./dist",
"prepare": "yarn build",
"release:publish:canary": "yarn npm publish --access restricted --tag next",

@@ -28,12 +27,14 @@ "start:dev": "ts-node -r tsconfig-paths/register src/index.ts"

"@types/prompts": "^2.4.6",
"@useparagon/core": "0.0.1-canary.3",
"axios": "^1.3.4",
"@useparagon/core": "0.0.1-canary.4",
"axios": "^1.6.1",
"chalk": "4.1.2",
"commander": "^10.0.0",
"express": "^4.18.2",
"figlet": "^1.6.0",
"fs-extra": "^11.1.0",
"glob": "^10.3.10",
"out-url": "^1.1.3",
"pino": "^8.11.0",
"pino-pretty": "^10.0.0",
"prettier": "^2.2.1",
"prettier": "^3.1.0",
"prettier-plugin-organize-imports": "^3.2.3",

@@ -46,2 +47,3 @@ "prompts": "^2.4.2",

"devDependencies": {
"@types/express": "^4.17.21",
"@types/figlet": "^1.5.6",

@@ -60,4 +62,4 @@ "@types/fs-extra": "^11.0.1",

"tsconfig-paths": "^4.2.0",
"typescript": "^4.4.4"
"typescript": "^5.3.2"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet