mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 11:40:11 +03:00
@urbit/api: update settings for desk namespacing
This commit is contained in:
parent
f31c119ba0
commit
061416dccd
@ -1,4 +1,4 @@
|
||||
import { Poke, Scry } from "../lib";
|
||||
import { Poke, Scry } from '../lib';
|
||||
import { PutBucket, Key, Bucket, DelBucket, Value, PutEntry, DelEntry, SettingsUpdate } from './types';
|
||||
|
||||
export const action = <T extends SettingsUpdate>(data: T): Poke<T> => ({
|
||||
@ -8,29 +8,35 @@ export const action = <T extends SettingsUpdate>(data: T): Poke<T> => ({
|
||||
});
|
||||
|
||||
export const putBucket = (
|
||||
desk: string,
|
||||
key: Key,
|
||||
bucket: Bucket
|
||||
): Poke<PutBucket> => action({
|
||||
'put-bucket': {
|
||||
desk,
|
||||
'bucket-key': key,
|
||||
'bucket': bucket
|
||||
}
|
||||
});
|
||||
|
||||
export const delBucket = (
|
||||
desk: string,
|
||||
key: Key
|
||||
): Poke<DelBucket> => action({
|
||||
'del-bucket': {
|
||||
desk,
|
||||
'bucket-key': key
|
||||
}
|
||||
});
|
||||
|
||||
export const putEntry = (
|
||||
desk: string,
|
||||
bucket: Key,
|
||||
key: Key,
|
||||
value: Value
|
||||
): Poke<PutEntry> => action({
|
||||
'put-entry': {
|
||||
desk,
|
||||
'bucket-key': bucket,
|
||||
'entry-key': key,
|
||||
value: value
|
||||
@ -38,10 +44,12 @@ export const putEntry = (
|
||||
});
|
||||
|
||||
export const delEntry = (
|
||||
desk: string,
|
||||
bucket: Key,
|
||||
key: Key
|
||||
): Poke<DelEntry> => action({
|
||||
'del-entry': {
|
||||
desk,
|
||||
'bucket-key': bucket,
|
||||
'entry-key': key
|
||||
}
|
||||
@ -50,17 +58,16 @@ export const delEntry = (
|
||||
export const getAll: Scry = {
|
||||
app: 'settings-store',
|
||||
path: '/all'
|
||||
}
|
||||
};
|
||||
|
||||
export const getBucket = (bucket: string) => ({
|
||||
export const getBucket = (desk: string, bucket: string) => ({
|
||||
app: 'settings-store',
|
||||
path: `/bucket/${bucket}`
|
||||
});
|
||||
|
||||
export const getEntry = (bucket: string, entry: string) => ({
|
||||
export const getEntry = (desk: string, bucket: string, entry: string) => ({
|
||||
app: 'settings-store',
|
||||
path: `/entry/${bucket}/${entry}`
|
||||
path: `/entry/${desk}/${bucket}/${entry}`
|
||||
});
|
||||
|
||||
|
||||
export * from './types';
|
||||
|
@ -4,43 +4,46 @@ export type Bucket = Map<string, Value>;
|
||||
export type Settings = Map<string, Bucket>;
|
||||
|
||||
export interface PutBucket {
|
||||
"put-bucket": {
|
||||
"bucket-key": Key;
|
||||
"bucket": Bucket;
|
||||
'put-bucket': {
|
||||
desk: string;
|
||||
'bucket-key': Key;
|
||||
'bucket': Bucket;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DelBucket {
|
||||
"del-bucket": {
|
||||
"bucket-key": Key;
|
||||
'del-bucket': {
|
||||
desk: string;
|
||||
'bucket-key': Key;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PutEntry {
|
||||
"put-entry": {
|
||||
"bucket-key": Key;
|
||||
"entry-key": Key;
|
||||
"value"?: Value;
|
||||
'put-entry': {
|
||||
'bucket-key': Key;
|
||||
'entry-key': Key;
|
||||
'value'?: Value;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DelEntry {
|
||||
"del-entry": {
|
||||
"bucket-key": Key;
|
||||
"entry-key": Key;
|
||||
'del-entry': {
|
||||
desk: string;
|
||||
'bucket-key': Key;
|
||||
'entry-key': Key;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AllData {
|
||||
"all": Settings;
|
||||
'all': Settings;
|
||||
}
|
||||
|
||||
export interface BucketData {
|
||||
"bucket": Bucket;
|
||||
'bucket': Bucket;
|
||||
}
|
||||
|
||||
export interface EntryData {
|
||||
"entry": Value;
|
||||
'entry': Value;
|
||||
}
|
||||
|
||||
export type SettingsUpdate =
|
||||
|
Loading…
Reference in New Issue
Block a user