Skip to content

Commit

Permalink
feat: Add a new method to fetch the config as json (#137)
Browse files Browse the repository at this point in the history
* Add a new method to fetch the config as json

* Update changelog

* Revert version changes

* Update getConfigFieldInfo method implementation

* Add non null to not null fields

* Update getConfigFieldsInfo method signature in Storage interface

* Add @nullable annotation to ConfigFieldInfo class
  • Loading branch information
prateek3255 authored Feb 28, 2024
1 parent 1933948 commit 8d0605c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Add a new method `getConfigFieldsJson` to fetch the plugin config as json

## [4.0.5] - 2023-12-05

- Adds `InvalidConfigException` to throws list of `canBeUsed` function
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/ConfigFieldInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
*
* You may not use this file except in compliance with the License. You may
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package io.supertokens.pluginInterface;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class ConfigFieldInfo {
@Nonnull
public String name;
@Nonnull
public String description;
public boolean isDifferentAcrossTenants;
@Nonnull
public String type;
@Nullable
public String[] options;

public ConfigFieldInfo(@Nonnull String name, @Nonnull String description, boolean isDifferentAcrossTenants, @Nonnull String type) {
this(name, description, isDifferentAcrossTenants, type, null);
}

public ConfigFieldInfo(@Nonnull String name, @Nonnull String description, boolean isDifferentAcrossTenants, @Nonnull String type, @Nullable String[] options) {
this.name = name;
this.description = description;
this.isDifferentAcrossTenants = isDifferentAcrossTenants;
this.type = type;
this.options = options;
}
}
3 changes: 3 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

import java.util.ArrayList;
import java.util.Set;

public interface Storage {
Expand Down Expand Up @@ -89,6 +90,8 @@ boolean isUserIdBeingUsedInNonAuthRecipe(AppIdentifier appIdentifier, String cla

Set<String> getValidFieldsInConfig();

ArrayList<ConfigFieldInfo> getConfigFieldsInfo();

void setLogLevels(Set<LOG_LEVEL> logLevels);

String[] getAllTablesInTheDatabase() throws StorageQueryException;
Expand Down

0 comments on commit 8d0605c

Please sign in to comment.