Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openfn/deploy

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfn/deploy - npm Package Compare versions

Comparing version 0.2.3 to 0.2.5

51

dist/index.d.ts
import { Logger } from '@openfn/logger';
declare type Job = {
type Job = {
id?: string;

@@ -11,3 +11,3 @@ name: string;

};
declare type Trigger = {
type Trigger = {
id?: string;

@@ -18,5 +18,5 @@ type?: string;

};
declare type StateEdge = {
type StateEdge = {
id: string;
condition: string;
condition: string | null;
source_job_id: string | null;

@@ -26,8 +26,26 @@ source_trigger_id: string | null;

};
type SpecEdge = {
condition: string | null;
source_job?: string | null;
source_trigger?: string | null;
target_job: string | null;
};
type WorkflowSpec = {
id?: string;
name: string;
jobs?: Record<string | symbol, Job>;
triggers?: Record<string | symbol, Trigger>;
edges?: Record<string | symbol, SpecEdge>;
};
interface ProjectSpec {
name: string;
description: string;
workflows: Record<string | symbol, WorkflowSpec>;
}
interface WorkflowState {
id: string;
name: string;
jobs: Record<string | symbol, Job>;
triggers: Record<string | symbol, Trigger>;
edges: Record<string | symbol, StateEdge>;
jobs: Record<string | symbol, Concrete<Job>>;
triggers: Record<string | symbol, Concrete<Trigger>>;
edges: Record<string | symbol, Concrete<StateEdge>>;
delete?: boolean;

@@ -53,3 +71,3 @@ }

}
declare type Concrete<Type> = Type & {
type Concrete<Type> = Type & {
id: string;

@@ -67,2 +85,11 @@ };

interface Error$1 {
context: any;
message: string;
path?: string[];
range?: [number, number, number];
}
declare function mergeSpecIntoState(oldState: ProjectState, spec: ProjectSpec): ProjectState;
declare function getProject(config: DeployConfig, projectId: string): Promise<{

@@ -72,3 +99,3 @@ data: ProjectPayload | null;

declare type DeployErrorName = 'VALIDATION_ERROR' | 'DEPLOY_ERROR' | 'CONFIG_ERROR' | 'STATE_ERROR' | 'SPEC_ERROR';
type DeployErrorName = 'VALIDATION_ERROR' | 'DEPLOY_ERROR' | 'CONFIG_ERROR' | 'STATE_ERROR' | 'SPEC_ERROR';
declare class DeployError extends Error {

@@ -82,4 +109,8 @@ name: DeployErrorName;

declare function getState(path: string): Promise<ProjectState>;
declare function getSpec(path: string): Promise<{
errors: Error$1[];
doc: ProjectSpec;
}>;
declare function deploy(config: DeployConfig, logger: Logger): Promise<boolean>;
export { DeployConfig, DeployError, ProjectState, deploy, getConfig, getProject, getState, validateConfig };
export { DeployConfig, DeployError, ProjectState, deploy, getConfig, getProject, getSpec, getState, mergeSpecIntoState, validateConfig };

140

dist/index.js

@@ -8,35 +8,2 @@ // src/index.ts

import YAML, { isMap, isPair } from "yaml";
// src/utils.ts
var uuidRegex = new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
"i"
);
function splitZip(l, r) {
return concatKeys(l, r).map((key) => {
return [key, l[key], r[key]];
});
}
function concatKeys(...objs) {
return objs.reduce((acc, obj) => {
return acc.concat(Object.keys(obj));
}, []).reduce((acc, key) => {
if (!acc.includes(key)) {
acc.push(key);
}
return acc;
}, []);
}
function pickKeys(obj, keys) {
const newObj = {};
for (const key of keys) {
newObj[key] = obj[key];
}
return newObj;
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
// src/validator.ts
function parseAndValidate(input) {

@@ -128,7 +95,39 @@ let errors = [];

// src/utils.ts
var uuidRegex = new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
"i"
);
function splitZip(l, r) {
return concatKeys(l, r).map((key) => {
return [key, l[key], r[key]];
});
}
function concatKeys(...objs) {
return objs.reduce((acc, obj) => {
return acc.concat(Object.keys(obj));
}, []).reduce((acc, key) => {
if (!acc.includes(key)) {
acc.push(key);
}
return acc;
}, []);
}
function pickKeys(obj, keys) {
const newObj = {};
for (const key of keys) {
newObj[key] = obj[key];
}
return newObj;
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
// src/deployError.ts
var DeployError = class extends Error {
var DeployError = class _DeployError extends Error {
name;
constructor(message, name) {
super(message);
Object.setPrototypeOf(this, DeployError.prototype);
Object.setPrototypeOf(this, _DeployError.prototype);
this.name = name;

@@ -202,6 +201,3 @@ }

if (!specTrigger && stateTrigger) {
return [
triggerKey,
{ ...pickKeys(stateTrigger, ["id"]), delete: true }
];
return [triggerKey, { id: stateTrigger.id, delete: true }];
}

@@ -226,8 +222,9 @@ return [

([edgeKey, stateEdge, specEdge]) => {
function convertToStateEdge(jobs2, triggers2, specEdge2) {
let edge = {
condition: specEdge2.condition || null,
source_job_id: specEdge2.source_job ? jobs2[specEdge2.source_job].id : null,
source_trigger_id: specEdge2.source_trigger ? triggers2[specEdge2.source_trigger].id : null,
target_job_id: specEdge2.target_job ? jobs2[specEdge2.target_job].id : null
function convertToStateEdge(jobs2, triggers2, specEdge2, id) {
const edge = {
id,
condition: specEdge2.condition ?? null,
source_job_id: (specEdge2.source_job && jobs2[specEdge2.source_job].id) ?? null,
source_trigger_id: (specEdge2.source_trigger && triggers2[specEdge2.source_trigger].id) ?? null,
target_job_id: (specEdge2.target_job && jobs2[specEdge2.target_job].id) ?? ""
};

@@ -239,17 +236,11 @@ return edge;

edgeKey,
{
...convertToStateEdge(jobs, triggers, specEdge),
id: crypto.randomUUID()
}
convertToStateEdge(jobs, triggers, specEdge, crypto.randomUUID())
];
}
if (!specEdge && stateEdge) {
return [edgeKey, { ...pickKeys(stateEdge, ["id"]), delete: true }];
return [edgeKey, { id: stateEdge.id, delete: true }];
}
return [
edgeKey,
{
...convertToStateEdge(jobs, triggers, specEdge),
id: stateEdge.id
}
convertToStateEdge(jobs, triggers, specEdge, stateEdge.id)
];

@@ -264,9 +255,8 @@ }

([workflowKey, stateWorkflow, specWorkflow]) => {
stateWorkflow = stateWorkflow || {};
const nextJobs = mergeJobs(
stateWorkflow.jobs || {},
stateWorkflow?.jobs || {},
specWorkflow?.jobs || {}
);
const nextTriggers = mergeTriggers(
stateWorkflow.triggers || {},
stateWorkflow?.triggers || {},
specWorkflow?.triggers || {}

@@ -276,6 +266,6 @@ );

deepClone({ jobs: nextJobs, triggers: nextTriggers }),
stateWorkflow.edges || {},
stateWorkflow?.edges || {},
specWorkflow?.edges || {}
);
if (specWorkflow && isEmpty(stateWorkflow)) {
if (specWorkflow && isEmpty(stateWorkflow || {})) {
return [

@@ -318,3 +308,4 @@ workflowKey,

([key, nextWorkflow, _state]) => {
nextWorkflow.jobs = Object.fromEntries(
const { id, name } = nextWorkflow;
const jobs = Object.fromEntries(
idKeyPairs(nextWorkflow.jobs, state.workflows[key].jobs).map(

@@ -324,3 +315,3 @@ ([key2, nextJob, _state2]) => [key2, nextJob]

);
nextWorkflow.triggers = Object.fromEntries(
const triggers = Object.fromEntries(
idKeyPairs(nextWorkflow.triggers, state.workflows[key].triggers).map(

@@ -330,3 +321,3 @@ ([key2, nextTrigger, _state2]) => [key2, nextTrigger]

);
nextWorkflow.edges = Object.fromEntries(
const edges = Object.fromEntries(
idKeyPairs(nextWorkflow.edges, state.workflows[key].edges).map(

@@ -336,3 +327,12 @@ ([key2, nextEdge, _state2]) => [key2, nextEdge]

);
return [key, nextWorkflow];
return [
key,
{
id,
name,
jobs,
triggers,
edges
}
];
}

@@ -364,11 +364,5 @@ )

...workflow,
jobs: Object.values(
workflow.jobs
),
triggers: Object.values(
workflow.triggers
),
edges: Object.values(
workflow.edges
)
jobs: Object.values(workflow.jobs),
triggers: Object.values(workflow.triggers),
edges: Object.values(workflow.edges)
};

@@ -595,4 +589,6 @@ });

getProject,
getSpec,
getState,
mergeSpecIntoState,
validateConfig
};
{
"name": "@openfn/deploy",
"version": "0.2.3",
"version": "0.2.5",
"description": "Deploy projects to Lightning instances",

@@ -30,4 +30,4 @@ "type": "module",

"tslib": "^2.4.0",
"tsup": "^6.2.3",
"typescript": "^4.6.4"
"tsup": "^7.2.0",
"typescript": "^5.1.6"
},

@@ -49,3 +49,3 @@ "files": [

"test:watch": "pnpm ava -w",
"_test:types": "pnpm tsc --noEmit --project tsconfig.json --excludeDirectories test",
"test:types": "pnpm tsc --project tsconfig.test.json",
"build": "tsup --config ../../tsup.config.js src/index.ts",

@@ -52,0 +52,0 @@ "build:watch": "pnpm build --watch",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc