mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 03:23:09 +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';
|
import { PutBucket, Key, Bucket, DelBucket, Value, PutEntry, DelEntry, SettingsUpdate } from './types';
|
||||||
|
|
||||||
export const action = <T extends SettingsUpdate>(data: T): Poke<T> => ({
|
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 = (
|
export const putBucket = (
|
||||||
|
desk: string,
|
||||||
key: Key,
|
key: Key,
|
||||||
bucket: Bucket
|
bucket: Bucket
|
||||||
): Poke<PutBucket> => action({
|
): Poke<PutBucket> => action({
|
||||||
'put-bucket': {
|
'put-bucket': {
|
||||||
|
desk,
|
||||||
'bucket-key': key,
|
'bucket-key': key,
|
||||||
'bucket': bucket
|
'bucket': bucket
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const delBucket = (
|
export const delBucket = (
|
||||||
|
desk: string,
|
||||||
key: Key
|
key: Key
|
||||||
): Poke<DelBucket> => action({
|
): Poke<DelBucket> => action({
|
||||||
'del-bucket': {
|
'del-bucket': {
|
||||||
|
desk,
|
||||||
'bucket-key': key
|
'bucket-key': key
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const putEntry = (
|
export const putEntry = (
|
||||||
|
desk: string,
|
||||||
bucket: Key,
|
bucket: Key,
|
||||||
key: Key,
|
key: Key,
|
||||||
value: Value
|
value: Value
|
||||||
): Poke<PutEntry> => action({
|
): Poke<PutEntry> => action({
|
||||||
'put-entry': {
|
'put-entry': {
|
||||||
|
desk,
|
||||||
'bucket-key': bucket,
|
'bucket-key': bucket,
|
||||||
'entry-key': key,
|
'entry-key': key,
|
||||||
value: value
|
value: value
|
||||||
@ -38,10 +44,12 @@ export const putEntry = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const delEntry = (
|
export const delEntry = (
|
||||||
|
desk: string,
|
||||||
bucket: Key,
|
bucket: Key,
|
||||||
key: Key
|
key: Key
|
||||||
): Poke<DelEntry> => action({
|
): Poke<DelEntry> => action({
|
||||||
'del-entry': {
|
'del-entry': {
|
||||||
|
desk,
|
||||||
'bucket-key': bucket,
|
'bucket-key': bucket,
|
||||||
'entry-key': key
|
'entry-key': key
|
||||||
}
|
}
|
||||||
@ -50,17 +58,16 @@ export const delEntry = (
|
|||||||
export const getAll: Scry = {
|
export const getAll: Scry = {
|
||||||
app: 'settings-store',
|
app: 'settings-store',
|
||||||
path: '/all'
|
path: '/all'
|
||||||
}
|
};
|
||||||
|
|
||||||
export const getBucket = (bucket: string) => ({
|
export const getBucket = (desk: string, bucket: string) => ({
|
||||||
app: 'settings-store',
|
app: 'settings-store',
|
||||||
path: `/bucket/${bucket}`
|
path: `/bucket/${bucket}`
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getEntry = (bucket: string, entry: string) => ({
|
export const getEntry = (desk: string, bucket: string, entry: string) => ({
|
||||||
app: 'settings-store',
|
app: 'settings-store',
|
||||||
path: `/entry/${bucket}/${entry}`
|
path: `/entry/${desk}/${bucket}/${entry}`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
@ -4,43 +4,46 @@ export type Bucket = Map<string, Value>;
|
|||||||
export type Settings = Map<string, Bucket>;
|
export type Settings = Map<string, Bucket>;
|
||||||
|
|
||||||
export interface PutBucket {
|
export interface PutBucket {
|
||||||
"put-bucket": {
|
'put-bucket': {
|
||||||
"bucket-key": Key;
|
desk: string;
|
||||||
"bucket": Bucket;
|
'bucket-key': Key;
|
||||||
|
'bucket': Bucket;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DelBucket {
|
export interface DelBucket {
|
||||||
"del-bucket": {
|
'del-bucket': {
|
||||||
"bucket-key": Key;
|
desk: string;
|
||||||
|
'bucket-key': Key;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PutEntry {
|
export interface PutEntry {
|
||||||
"put-entry": {
|
'put-entry': {
|
||||||
"bucket-key": Key;
|
'bucket-key': Key;
|
||||||
"entry-key": Key;
|
'entry-key': Key;
|
||||||
"value"?: Value;
|
'value'?: Value;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DelEntry {
|
export interface DelEntry {
|
||||||
"del-entry": {
|
'del-entry': {
|
||||||
"bucket-key": Key;
|
desk: string;
|
||||||
"entry-key": Key;
|
'bucket-key': Key;
|
||||||
|
'entry-key': Key;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AllData {
|
export interface AllData {
|
||||||
"all": Settings;
|
'all': Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BucketData {
|
export interface BucketData {
|
||||||
"bucket": Bucket;
|
'bucket': Bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntryData {
|
export interface EntryData {
|
||||||
"entry": Value;
|
'entry': Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SettingsUpdate =
|
export type SettingsUpdate =
|
||||||
|
Loading…
Reference in New Issue
Block a user