Changed endpoint name, GET->POST, request/response signature, and perform batch queries against db
Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
@@ -38,7 +38,6 @@
|
||||
"test": "backstage-cli package test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/errors": "workspace:^",
|
||||
"@backstage/types": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -4,39 +4,14 @@
|
||||
|
||||
```ts
|
||||
import type { JsonValue } from '@backstage/types';
|
||||
import type { SerializedError } from '@backstage/errors';
|
||||
|
||||
// @public (undocumented)
|
||||
export function isMultiUserSettingError(
|
||||
setting: MultiUserSetting,
|
||||
): setting is MultiUserSettingError;
|
||||
|
||||
// @public
|
||||
export type MultiUserSetting = MultiUserSettingError | MultiUserSettingSuccess;
|
||||
|
||||
// @public
|
||||
export type MultiUserSettingError = {
|
||||
bucket: string;
|
||||
key: string;
|
||||
error: SerializedError;
|
||||
export type MultiGetResponse = {
|
||||
items: ({
|
||||
value: JsonValue;
|
||||
} | null)[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export type MultiUserSettingSuccess = {
|
||||
bucket: string;
|
||||
key: string;
|
||||
value: JsonValue;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export function parseDataLoaderKey(bucketAndKey: string): {
|
||||
bucket: string;
|
||||
key: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export function stringifyDataLoaderKey(bucket: string, key: string): string;
|
||||
|
||||
// @public (undocumented)
|
||||
export type UserSettingsSignal = {
|
||||
type: 'key-changed' | 'key-deleted';
|
||||
|
||||
@@ -15,6 +15,3 @@
|
||||
*/
|
||||
|
||||
export * from './types';
|
||||
export { isMultiUserSettingError } from './types';
|
||||
|
||||
export { stringifyDataLoaderKey, parseDataLoaderKey } from './keys';
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/** @public */
|
||||
export function stringifyDataLoaderKey(bucket: string, key: string) {
|
||||
return `${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function parseDataLoaderKey(bucketAndKey: string) {
|
||||
const [bucket, key] = bucketAndKey.split('/');
|
||||
return { bucket: decodeURIComponent(bucket), key: decodeURIComponent(key) };
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { SerializedError } from '@backstage/errors';
|
||||
import type { JsonValue } from '@backstage/types';
|
||||
|
||||
/** @public */
|
||||
@@ -24,37 +23,8 @@ export type UserSettingsSignal = {
|
||||
};
|
||||
|
||||
/**
|
||||
* A failed fetch of a user setting in a bucket
|
||||
* Response type from /multiget
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type MultiUserSettingError = {
|
||||
bucket: string;
|
||||
key: string;
|
||||
error: SerializedError;
|
||||
};
|
||||
|
||||
/**
|
||||
* A successful value of a user setting in a bucket
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type MultiUserSettingSuccess = {
|
||||
bucket: string;
|
||||
key: string;
|
||||
value: JsonValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* A single setting in a bucket, or an error, used result from the /multi endpoint
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type MultiUserSetting = MultiUserSettingError | MultiUserSettingSuccess;
|
||||
|
||||
/** @public */
|
||||
export function isMultiUserSettingError(
|
||||
setting: MultiUserSetting,
|
||||
): setting is MultiUserSettingError {
|
||||
return 'error' in setting;
|
||||
}
|
||||
export type MultiGetResponse = { items: ({ value: JsonValue } | null)[] };
|
||||
|
||||
Reference in New Issue
Block a user