mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-04 06:19:46 +00:00
feat: Remove the vault
This commit is contained in:
@@ -5,47 +5,45 @@ import { Utils, utils } from "../util/utils"
|
||||
|
||||
export class CreatedAction<
|
||||
Store,
|
||||
Vault,
|
||||
ConfigType extends
|
||||
| Record<string, any>
|
||||
| Config<any, Store, Vault>
|
||||
| Config<any, never, never>,
|
||||
| Config<any, Store>
|
||||
| Config<any, never>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
> {
|
||||
private constructor(
|
||||
public readonly myMetaData: Omit<ActionMetadata, "input">,
|
||||
readonly fn: (options: {
|
||||
effects: Effects
|
||||
utils: Utils<Store, Vault>
|
||||
utils: Utils<Store>
|
||||
input: Type
|
||||
}) => Promise<ActionResult>,
|
||||
readonly input: Config<Type, Store, Vault>,
|
||||
readonly input: Config<Type, Store>,
|
||||
) {}
|
||||
public validator = this.input.validator
|
||||
|
||||
static of<
|
||||
Store,
|
||||
Vault,
|
||||
ConfigType extends
|
||||
| Record<string, any>
|
||||
| Config<any, any, any>
|
||||
| Config<any, never, never>,
|
||||
| Config<any, any>
|
||||
| Config<any, never>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
>(
|
||||
metaData: Omit<ActionMetadata, "input"> & {
|
||||
input: Config<Type, Store, Vault> | Config<Type, never, never>
|
||||
input: Config<Type, Store> | Config<Type, never>
|
||||
},
|
||||
fn: (options: {
|
||||
effects: Effects
|
||||
utils: Utils<Store, Vault>
|
||||
utils: Utils<Store>
|
||||
input: Type
|
||||
}) => Promise<ActionResult>,
|
||||
) {
|
||||
const { input, ...rest } = metaData
|
||||
return new CreatedAction<Store, Vault, ConfigType, Type>(
|
||||
return new CreatedAction<Store, ConfigType, Type>(
|
||||
rest,
|
||||
fn,
|
||||
input as Config<Type, Store, Vault>,
|
||||
input as Config<Type, Store>,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -67,7 +65,7 @@ export class CreatedAction<
|
||||
|
||||
async ActionMetadata(options: {
|
||||
effects: Effects
|
||||
utils: Utils<Store, Vault>
|
||||
utils: Utils<Store>
|
||||
}): Promise<ActionMetadata> {
|
||||
return {
|
||||
...this.myMetaData,
|
||||
|
||||
@@ -3,11 +3,11 @@ import { createUtils } from "../util"
|
||||
import { once } from "../util/once"
|
||||
import { CreatedAction } from "./createAction"
|
||||
|
||||
export function setupActions<Store, Vault>(
|
||||
...createdActions: CreatedAction<Store, Vault, any>[]
|
||||
export function setupActions<Store>(
|
||||
...createdActions: CreatedAction<Store, any>[]
|
||||
) {
|
||||
const myActions = once(() => {
|
||||
const actions: Record<string, CreatedAction<Store, Vault, any>> = {}
|
||||
const actions: Record<string, CreatedAction<Store, any>> = {}
|
||||
for (const action of createdActions) {
|
||||
actions[action.myMetaData.id] = action
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export function setupActions<Store, Vault>(
|
||||
return myActions()
|
||||
},
|
||||
async actionsMetadata({ effects }: { effects: Effects }) {
|
||||
const utils = createUtils<Store, Vault>(effects)
|
||||
const utils = createUtils<Store>(effects)
|
||||
return Promise.all(
|
||||
createdActions.map((x) => x.ActionMetadata({ effects, utils })),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user