-
Notifications
You must be signed in to change notification settings - Fork 329
feat: adding changes feed api #1859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,10 @@ public enum Type { | |
| EXTENDED | ||
| } | ||
|
|
||
| public enum State { | ||
| ACTIVE, INACTIVE, DELETED | ||
| } | ||
|
|
||
| @Id | ||
| @GeneratedValue(generator = "extensionVersionSeq") | ||
| @SequenceGenerator(name = "extensionVersionSeq", sequenceName = "extension_version_seq") | ||
|
|
@@ -77,6 +81,11 @@ public enum Type { | |
|
|
||
| private boolean active; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private State state = State.ACTIVE; | ||
|
|
||
| private LocalDateTime lastUpdated = TimeUtil.getCurrentUTC(); | ||
|
|
||
| private boolean potentiallyMalicious; | ||
|
|
||
| private String displayName; | ||
|
|
@@ -319,6 +328,24 @@ public boolean isActive() { | |
|
|
||
| public void setActive(boolean active) { | ||
| this.active = active; | ||
| setState(active ? State.ACTIVE : State.INACTIVE); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: If for whatever reason the Version gets marked as
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I think I would break it down to more methods, to be more idiomatic, although the final picture here will be dropping the active boolean flag and only using the state.. maybe doing so now could be an option since the flyway migration will set the state looking at the active boolean flag. |
||
| } | ||
|
|
||
| public State getState() { | ||
| return state; | ||
| } | ||
|
|
||
| public void setState(State state) { | ||
| this.state = state; | ||
| this.lastUpdated = TimeUtil.getCurrentUTC(); | ||
| } | ||
|
|
||
| public LocalDateTime getLastUpdated() { | ||
| return lastUpdated; | ||
| } | ||
|
|
||
| public void setLastUpdated(LocalDateTime lastUpdated) { | ||
| this.lastUpdated = lastUpdated; | ||
| } | ||
|
|
||
| public boolean isPotentiallyMalicious() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2026 Eclipse Foundation and others | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ********************************************************************************/ | ||
| package org.eclipse.openvsx.json; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(name = "ChangeEntry", description = "A single registry change entry") | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class ChangeEntryJson { | ||
|
|
||
| @Schema(description = "Namespace of the extension") | ||
| private String namespace; | ||
|
|
||
| @Schema(description = "Name of the extension") | ||
| private String name; | ||
|
|
||
| @Schema(description = "Version string") | ||
| private String version; | ||
|
|
||
| @Schema(description = "Target platform (e.g. universal, linux-x64)") | ||
| private String targetPlatform; | ||
|
|
||
| @Schema(description = "Current state of this extension version (active, inactive, deleted)") | ||
| private String state; | ||
|
|
||
| @Schema(description = "Timestamp of the version publication (ISO-8601 UTC)") | ||
| private String timestamp; | ||
|
|
||
| @Schema(description = "Timestamp of the last state change (ISO-8601 UTC)") | ||
| private String lastUpdated; | ||
|
|
||
| @Schema(description = "Full extension metadata") | ||
| private ExtensionJson extension; | ||
|
|
||
| public String getNamespace() { | ||
| return namespace; | ||
| } | ||
|
|
||
| public void setNamespace(String namespace) { | ||
| this.namespace = namespace; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getVersion() { | ||
| return version; | ||
| } | ||
|
|
||
| public void setVersion(String version) { | ||
| this.version = version; | ||
| } | ||
|
|
||
| public String getTargetPlatform() { | ||
| return targetPlatform; | ||
| } | ||
|
|
||
| public void setTargetPlatform(String targetPlatform) { | ||
| this.targetPlatform = targetPlatform; | ||
| } | ||
|
|
||
| public String getState() { | ||
| return state; | ||
| } | ||
|
|
||
| public void setState(String state) { | ||
| this.state = state; | ||
| } | ||
|
|
||
| public String getTimestamp() { | ||
| return timestamp; | ||
| } | ||
|
|
||
| public void setTimestamp(String timestamp) { | ||
| this.timestamp = timestamp; | ||
| } | ||
|
|
||
| public String getLastUpdated() { | ||
| return lastUpdated; | ||
| } | ||
|
|
||
| public void setLastUpdated(String lastUpdated) { | ||
| this.lastUpdated = lastUpdated; | ||
| } | ||
|
|
||
| public ExtensionJson getExtension() { | ||
| return extension; | ||
| } | ||
|
|
||
| public void setExtension(ExtensionJson extension) { | ||
| this.extension = extension; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2026 Eclipse Foundation and others | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ********************************************************************************/ | ||
| package org.eclipse.openvsx.json; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Schema(name = "ChangesResult", description = "Paginated list of registry changes") | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class ChangesResultJson extends ResultJson { | ||
|
|
||
| public static ChangesResultJson error(String message) { | ||
| var result = new ChangesResultJson(); | ||
| result.setError(message); | ||
| return result; | ||
| } | ||
|
|
||
| @Schema(description = "Number of skipped entries according to the changes request") | ||
| @NotNull | ||
| @Min(0) | ||
| private int offset; | ||
|
|
||
| @Schema(description = "Total number of changes matching the request") | ||
| @NotNull | ||
| @Min(0) | ||
| private int totalSize; | ||
|
|
||
| @Schema(description = "List of change entries, limited to the size specified in the request") | ||
| @NotNull | ||
| private List<ChangeEntryJson> changes; | ||
|
|
||
| public int getOffset() { | ||
| return offset; | ||
| } | ||
|
|
||
| public void setOffset(int offset) { | ||
| this.offset = offset; | ||
| } | ||
|
|
||
| public int getTotalSize() { | ||
| return totalSize; | ||
| } | ||
|
|
||
| public void setTotalSize(int totalSize) { | ||
| this.totalSize = totalSize; | ||
| } | ||
|
|
||
| public List<ChangeEntryJson> getChanges() { | ||
| return changes; | ||
| } | ||
|
|
||
| public void setChanges(List<ChangeEntryJson> changes) { | ||
| this.changes = changes; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is there a reason that we're modifying the enums on return? As these aren't aribitrary, we should probably just preserve the data as is and let the client do what they want with that data rather than make the assumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so initially I wanted to match our convention, given that in other cases such as for the user role enum we return lowercased values, but thinking about it a bit more I'm realizing we do that there because these values weren't enums before.. so yeah I think returning uppercased enum values here its fine
wdyt @netomi ?