Skip to content

Commit

Permalink
CLI Deploy: Don't send empty collections (#862)
Browse files Browse the repository at this point in the history
* do not send empty collections

* add changeset

* version: [email protected]

---------

Co-authored-by: Joe Clark <[email protected]>
  • Loading branch information
midigofrank and josephjclark authored Jan 29, 2025
1 parent 084fe7e commit 3633241
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/cli

## 1.10.4

### Patch Changes

- 295ceed: CLI Deploy: Don't send empty collections
- Updated dependencies [295ceed]
- @openfn/deploy@0.10.0

## 1.10.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "1.10.3",
"version": "1.10.4",
"description": "CLI devtools for the openfn toolchain.",
"engines": {
"node": ">=18",
Expand Down
6 changes: 6 additions & 0 deletions packages/deploy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/deploy

## 0.10.0

### Minor Changes

- 295ceed: CLI Deploy: Don't send empty collections

## 0.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/deploy",
"version": "0.9.0",
"version": "0.10.0",
"description": "Deploy projects to Lightning instances",
"type": "module",
"exports": {
Expand Down
8 changes: 5 additions & 3 deletions packages/deploy/src/stateTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export function mergeProjectPayloadIntoState(
);

const nextCollections = Object.fromEntries(
idKeyPairs(project.collections || {}, state.collections || {}).map(
idKeyPairs(project.collections || [], state.collections || {}).map(
([key, nextCollection, _state]) => {
return [key, nextCollection];
}
Expand Down Expand Up @@ -557,10 +557,12 @@ export function toProjectPayload(state: ProjectState): ProjectPayload {
state.collections
);

const { collections: _, ...stateWithoutCollections } = state;

return {
...state,
collections,
...stateWithoutCollections,
project_credentials,
workflows,
...(collections.length > 0 && { collections }),
};
}
2 changes: 1 addition & 1 deletion packages/deploy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface ProjectPayload {
id: string;
name: string;
description: string;
collections: Concrete<CollectionState>[];
collections?: Concrete<CollectionState>[];
project_credentials: Concrete<CredentialState>[];
workflows: {
id: string;
Expand Down
14 changes: 13 additions & 1 deletion packages/deploy/test/stateTransform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getStateFromProjectPayload,
mergeProjectPayloadIntoState,
mergeSpecIntoState,
toProjectPayload,
} from '../src/stateTransform';
import { ProjectPayload } from '../src/types';
import {
Expand Down Expand Up @@ -616,10 +617,21 @@ test('getStateFromProjectPayload with minimal project', (t) => {
});

test('getStateFromProjectPayload with full lightning project', (t) => {
const project = lightningProjectPayload;
const expectedState = lightningProjectState;

const project = lightningProjectPayload;

const state = getStateFromProjectPayload(project);

t.deepEqual(state, expectedState);
});

test('toProjectPayload drops empty collections key', (t) => {
const { collections: _, ...projectState } = lightningProjectState;
projectState.collections = {};
const { collections: _c, ...expectedPayload } = lightningProjectPayload;

const payload = toProjectPayload(projectState);

t.deepEqual(payload, expectedPayload);
});

0 comments on commit 3633241

Please sign in to comment.