chore: move to having a root extension with apis and app inputs
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Fredrik Adelöw <freben@users.noreply.github.com> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -28,7 +28,7 @@ const factoryDataRef = createExtensionDataRef<AnyApiFactory>().with({
|
||||
*/
|
||||
export const ApiBlueprint = createExtensionBlueprint({
|
||||
kind: 'api',
|
||||
attachTo: { id: 'app', input: 'apis' },
|
||||
attachTo: { id: 'root', input: 'apis' },
|
||||
output: [factoryDataRef],
|
||||
dataRefs: {
|
||||
factory: factoryDataRef,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppNode } from '../apis';
|
||||
import { ApiHolder, AppNode } from '../apis';
|
||||
import { PortableSchema } from '../schema';
|
||||
import { Expand } from '../types';
|
||||
import {
|
||||
@@ -133,6 +133,7 @@ export type CreateExtensionOptions<
|
||||
};
|
||||
factory(context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: {
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
};
|
||||
@@ -203,6 +204,7 @@ export interface ExtensionDefinition<
|
||||
}) => ExtensionDataContainer<UOutput>,
|
||||
context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: TConfig & {
|
||||
[key in keyof TExtensionConfigSchema]: z.infer<
|
||||
ReturnType<TExtensionConfigSchema[key]>
|
||||
@@ -273,6 +275,7 @@ export type InternalExtensionDefinition<
|
||||
};
|
||||
factory(context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: TConfig;
|
||||
inputs: {
|
||||
[inputName in string]: unknown;
|
||||
@@ -292,6 +295,7 @@ export type InternalExtensionDefinition<
|
||||
readonly output: Array<AnyExtensionDataRef>;
|
||||
factory(context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: TConfig;
|
||||
inputs: ResolvedExtensionInputs<{
|
||||
[inputName in string]: ExtensionInput<
|
||||
@@ -437,10 +441,11 @@ export function createExtension<
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
factory: ({ node, config, inputs }) => {
|
||||
factory: ({ node, apis, config, inputs }) => {
|
||||
if (!overrideOptions.factory) {
|
||||
return newOptions.factory({
|
||||
node,
|
||||
apis,
|
||||
config: config as any,
|
||||
inputs: inputs as any,
|
||||
});
|
||||
@@ -450,6 +455,7 @@ export function createExtension<
|
||||
return createExtensionDataContainer<UOutput>(
|
||||
newOptions.factory({
|
||||
node,
|
||||
apis,
|
||||
config: (innerContext?.config ?? config) as any,
|
||||
inputs: resolveInputOverrides(
|
||||
newOptions.inputs,
|
||||
@@ -462,6 +468,7 @@ export function createExtension<
|
||||
},
|
||||
{
|
||||
node,
|
||||
apis,
|
||||
config: config as any,
|
||||
inputs: inputs as any,
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppNode } from '../apis';
|
||||
import { ApiHolder, AppNode } from '../apis';
|
||||
import { Expand } from '../types';
|
||||
import {
|
||||
ExtensionDefinition,
|
||||
@@ -70,6 +70,7 @@ export type CreateExtensionBlueprintOptions<
|
||||
params: TParams,
|
||||
context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: {
|
||||
[key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;
|
||||
};
|
||||
@@ -172,6 +173,7 @@ export interface ExtensionBlueprint<
|
||||
) => ExtensionDataContainer<UOutput>,
|
||||
context: {
|
||||
node: AppNode;
|
||||
apis: ApiHolder;
|
||||
config: TConfig & {
|
||||
[key in keyof TExtensionConfigSchema]: z.infer<
|
||||
ReturnType<TExtensionConfigSchema[key]>
|
||||
@@ -300,11 +302,12 @@ export function createExtensionBlueprint<
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
factory: ({ node, config, inputs }) => {
|
||||
factory: ({ node, config, inputs, apis }) => {
|
||||
return args.factory(
|
||||
(innerParams, innerContext) => {
|
||||
return createExtensionDataContainer<UOutput>(
|
||||
options.factory(innerParams, {
|
||||
apis,
|
||||
node,
|
||||
config: (innerContext?.config ?? config) as any,
|
||||
inputs: resolveInputOverrides(
|
||||
@@ -317,6 +320,7 @@ export function createExtensionBlueprint<
|
||||
);
|
||||
},
|
||||
{
|
||||
apis,
|
||||
node,
|
||||
config: config as any,
|
||||
inputs: inputs as any,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppNode } from '../apis';
|
||||
import { ApiHolder, AppNode } from '../apis';
|
||||
import {
|
||||
ExtensionDefinition,
|
||||
ResolvedExtensionInputs,
|
||||
@@ -57,6 +57,7 @@ export type InternalExtension<TConfig, TConfigInput> = Extension<
|
||||
[name in string]: AnyExtensionDataRef;
|
||||
};
|
||||
factory(context: {
|
||||
apis: ApiHolder;
|
||||
node: AppNode;
|
||||
config: TConfig;
|
||||
inputs: {
|
||||
@@ -76,6 +77,7 @@ export type InternalExtension<TConfig, TConfigInput> = Extension<
|
||||
};
|
||||
readonly output: Array<AnyExtensionDataRef>;
|
||||
factory(options: {
|
||||
apis: ApiHolder;
|
||||
node: AppNode;
|
||||
config: TConfig;
|
||||
inputs: ResolvedExtensionInputs<{
|
||||
|
||||
Reference in New Issue
Block a user