@etohq/admin-sdk 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Etohq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ export type { RouteConfig, WidgetConfig } from "./types";
2
+ export { defineRouteConfig, defineWidgetConfig } from "./utils";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export { defineRouteConfig, defineWidgetConfig } from "./utils";
@@ -0,0 +1,132 @@
1
+ import type { CustomFieldFormKeys, CustomFieldModel, CustomFieldModelContainerMap, CustomFieldModelFormTabsMap, InjectionZone, NestedRoutePosition } from "@etohq/admin-shared";
2
+ import type { ComponentType } from "react";
3
+ import { ZodFirstPartySchemaTypes } from "zod";
4
+ export interface WidgetConfig {
5
+ /**
6
+ * The injection zone or zones that the widget should be injected into.
7
+ */
8
+ zone: InjectionZone | InjectionZone[];
9
+ }
10
+ export interface RouteConfig {
11
+ /**
12
+ * An optional label to display in the sidebar. If not provided, the route will not be displayed in the sidebar.
13
+ */
14
+ label?: string;
15
+ /**
16
+ * An optional icon to display in the sidebar together with the label. If no label is provided, the icon will be ignored.
17
+ */
18
+ icon?: ComponentType;
19
+ /**
20
+ * The nested route to display under existing route in the sidebar.
21
+ */
22
+ nested?: NestedRoutePosition;
23
+ }
24
+ export type CustomFormField<TData = unknown, TValidation extends ZodFirstPartySchemaTypes = ZodFirstPartySchemaTypes> = {
25
+ /**
26
+ * The rules that the field should be validated against.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * rules: z.string().email() // The field must be a valid email
31
+ * ```
32
+ */
33
+ validation: TValidation;
34
+ /**
35
+ * The default value of the field.
36
+ */
37
+ defaultValue: ((data: TData) => any) | any;
38
+ /**
39
+ * The label of the field. If not provided, the label will be inferred from the field name.
40
+ */
41
+ label?: string;
42
+ /**
43
+ * The description of the field.
44
+ */
45
+ description?: string;
46
+ /**
47
+ * The placeholder of the field.
48
+ */
49
+ placeholder?: string;
50
+ /**
51
+ * Custom component to render the field. If not provided, the field will be rendered using the
52
+ * default component for the field type, which is determined by the field's validation schema.
53
+ */
54
+ component?: ComponentType;
55
+ };
56
+ export interface CustomFieldConfig<TModel extends CustomFieldModel> {
57
+ /**
58
+ * The name of the model that the custom models are linked to.
59
+ * This should be the name of one of the built-in models, such as `product` or `customer`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * model: "product"
64
+ * ```
65
+ */
66
+ model: TModel;
67
+ /**
68
+ * The name of the custom model(s) that the custom fields belong to.
69
+ * This is used to ensure that the custom fields are fetched when
70
+ * querying the entrypoint model.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * export default unstable_defineCustomFieldsConfig({
75
+ * model: "product",
76
+ * link: "brand"
77
+ * // ...
78
+ * })
79
+ * ```
80
+ * or
81
+ * ```ts
82
+ * export default unstable_defineCustomFieldsConfig({
83
+ * model: "product",
84
+ * link: ["brand", "seller"]
85
+ * // ...
86
+ * })
87
+ * ```
88
+ */
89
+ link: string | string[];
90
+ forms: Array<{
91
+ [K in CustomFieldFormKeys<TModel> & keyof CustomFieldModelFormTabsMap[TModel]]: {
92
+ /**
93
+ * The form to extend.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * export default unstable_defineCustomFieldsConfig({
98
+ * model: "product",
99
+ * link: "brand",
100
+ * forms: [
101
+ * {
102
+ * zone: "create",
103
+ * // ...
104
+ * }
105
+ * ],
106
+ * // ...
107
+ * })
108
+ * ```
109
+ */
110
+ zone: K;
111
+ fields: Record<string, CustomFormField<any, any>>;
112
+ } & (CustomFieldModelFormTabsMap[TModel][K] extends never ? {} : {
113
+ tab: CustomFieldModelFormTabsMap[TModel][K];
114
+ });
115
+ }[CustomFieldFormKeys<TModel> & keyof CustomFieldModelFormTabsMap[TModel]]>;
116
+ /**
117
+ * Optionally define how to display the custom fields, in an existing container on the entity details page.
118
+ * Alternatively, you can create a new widget to display the custom fields.
119
+ */
120
+ displays?: Array<{
121
+ /**
122
+ * The identifier of the container that the custom fields should be injected into.
123
+ */
124
+ zone: CustomFieldModelContainerMap[TModel];
125
+ /**
126
+ * The component that should be rendered to display the custom fields.
127
+ * This component will receive the entity data as a prop.
128
+ */
129
+ component: ComponentType;
130
+ }>;
131
+ }
132
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAA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AAC,GAAG;YAC5C;;;;;;;;;;;;;;;;;eAiBG;YACH,IAAI,EAAE,CAAC,CAAA;YACP,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;SAClD,GAAG,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,GACrD,EAAE,GACF;YAAE,GAAG,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE,CAAC;KACrD,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAAG,MAAM,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAC3E,CAAA;IACD;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf;;WAEG;QACH,IAAI,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAA;QAC1C;;;WAGG;QACH,SAAS,EAAE,aAAa,CAAA;KACzB,CAAC,CAAA;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,123 @@
1
+ import type { CustomFieldModelFormMap } from "@etohq/admin-shared";
2
+ import { z, ZodFirstPartySchemaTypes } from "zod";
3
+ import { CustomFieldConfig, CustomFormField, RouteConfig, WidgetConfig } from "./types";
4
+ /**
5
+ * Define a widget configuration.
6
+ *
7
+ * @param config The widget configuration.
8
+ * @returns The widget configuration.
9
+ */
10
+ export declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
11
+ /**
12
+ * Define a route configuration.
13
+ *
14
+ * @param config The route configuration.
15
+ * @returns The route configuration.
16
+ */
17
+ export declare function defineRouteConfig(config: RouteConfig): RouteConfig;
18
+ /**
19
+ * Define a custom fields configuration.
20
+ *
21
+ * @param config The custom fields configuration.
22
+ * @returns The custom fields configuration.
23
+ *
24
+ * @experimental This API is experimental and may change in the future.
25
+ */
26
+ export declare function unstable_defineCustomFieldsConfig<TModel extends keyof CustomFieldModelFormMap>(config: CustomFieldConfig<TModel>): CustomFieldConfig<TModel>;
27
+ /**
28
+ * Creates a type-safe form builder.
29
+ *
30
+ * @returns The form helper.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { unstable_createFormHelper, unstable_defineCustomFieldsConfig } from "@etohq/admin-sdk"
35
+ * import type { HttpTypes } from "@etohq/types"
36
+ * import type { Brand } from "../../types/brand"
37
+ *
38
+ * type ExtendedProduct = HttpTypes.Product & {
39
+ * brand: Brand | null
40
+ * }
41
+ *
42
+ * const form = unstable_createFormHelper<ExtendedProduct>()
43
+ *
44
+ * export default unstable_defineCustomFieldsConfig({
45
+ * entryPoint: "product",
46
+ * link: "brand",
47
+ * forms: [{
48
+ * form: "create",
49
+ * fields: {
50
+ * brand_id: form.define({
51
+ * rules: form.string().nullish(),
52
+ * defaultValue: "",
53
+ * }),
54
+ * }
55
+ * }]
56
+ * })
57
+ * ```
58
+ *
59
+ * @experimental This API is experimental and may change in the future.
60
+ */
61
+ export declare function unstable_createFormHelper<TData>(): {
62
+ /**
63
+ * Define a custom form field.
64
+ *
65
+ * @param field The field to define.
66
+ * @returns The field.
67
+ */
68
+ define: <T extends ZodFirstPartySchemaTypes>(field: Omit<CustomFormField<TData, T>, "validation"> & {
69
+ validation: T;
70
+ }) => CustomFormField<TData, T>;
71
+ string: () => z.ZodString;
72
+ number: () => z.ZodNumber;
73
+ boolean: () => z.ZodBoolean;
74
+ date: () => z.ZodDate;
75
+ array: <T extends z.ZodTypeAny>(schema: T, params?: z.RawCreateParams) => z.ZodArray<T, "many">;
76
+ object: <T extends z.ZodRawShape>(shape: T, params?: z.RawCreateParams) => z.ZodObject<T, "strip", z.ZodTypeAny, { [k_1 in keyof z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof z.baseObjectInputType<T>]: z.baseObjectInputType<T>[k_2]; }>;
77
+ null: () => z.ZodNull;
78
+ nullable: <T extends z.ZodTypeAny>(type: T, params?: z.RawCreateParams) => z.ZodNullable<T>;
79
+ undefined: () => z.ZodUndefined;
80
+ coerce: {
81
+ string: (params?: ({
82
+ errorMap?: z.ZodErrorMap | undefined;
83
+ invalid_type_error?: string | undefined;
84
+ required_error?: string | undefined;
85
+ description?: string | undefined;
86
+ } & {
87
+ coerce?: true | undefined;
88
+ }) | undefined) => z.ZodString;
89
+ number: (params?: ({
90
+ errorMap?: z.ZodErrorMap | undefined;
91
+ invalid_type_error?: string | undefined;
92
+ required_error?: string | undefined;
93
+ description?: string | undefined;
94
+ } & {
95
+ coerce?: boolean | undefined;
96
+ }) | undefined) => z.ZodNumber;
97
+ boolean: (params?: ({
98
+ errorMap?: z.ZodErrorMap | undefined;
99
+ invalid_type_error?: string | undefined;
100
+ required_error?: string | undefined;
101
+ description?: string | undefined;
102
+ } & {
103
+ coerce?: boolean | undefined;
104
+ }) | undefined) => z.ZodBoolean;
105
+ bigint: (params?: ({
106
+ errorMap?: z.ZodErrorMap | undefined;
107
+ invalid_type_error?: string | undefined;
108
+ required_error?: string | undefined;
109
+ description?: string | undefined;
110
+ } & {
111
+ coerce?: boolean | undefined;
112
+ }) | undefined) => z.ZodBigInt;
113
+ date: (params?: ({
114
+ errorMap?: z.ZodErrorMap | undefined;
115
+ invalid_type_error?: string | undefined;
116
+ required_error?: string | undefined;
117
+ description?: string | undefined;
118
+ } & {
119
+ coerce?: boolean | undefined;
120
+ }) | undefined) => z.ZodDate;
121
+ };
122
+ };
123
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/config/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,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
5
+ /**
6
+ * This property is required to allow the config to be exported,
7
+ * while still allowing HMR to work correctly.
8
+ *
9
+ * It tricks Fast Refresh into thinking that the config is a React component,
10
+ * which allows it to be updated without a full page reload.
11
+ */
12
+ $$typeof: Symbol.for("react.memo"),
13
+ };
14
+ }
15
+ /**
16
+ * Define a widget configuration.
17
+ *
18
+ * @param config The widget configuration.
19
+ * @returns The widget configuration.
20
+ */
21
+ export function defineWidgetConfig(config) {
22
+ return createConfigHelper(config);
23
+ }
24
+ /**
25
+ * Define a route configuration.
26
+ *
27
+ * @param config The route configuration.
28
+ * @returns The route configuration.
29
+ */
30
+ export function defineRouteConfig(config) {
31
+ return createConfigHelper(config);
32
+ }
33
+ /**
34
+ * Define a custom fields configuration.
35
+ *
36
+ * @param config The custom fields configuration.
37
+ * @returns The custom fields configuration.
38
+ *
39
+ * @experimental This API is experimental and may change in the future.
40
+ */
41
+ export function unstable_defineCustomFieldsConfig(config) {
42
+ return createConfigHelper(config);
43
+ }
44
+ /**
45
+ * Creates a type-safe form builder.
46
+ *
47
+ * @returns The form helper.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { unstable_createFormHelper, unstable_defineCustomFieldsConfig } from "@etohq/admin-sdk"
52
+ * import type { HttpTypes } from "@etohq/types"
53
+ * import type { Brand } from "../../types/brand"
54
+ *
55
+ * type ExtendedProduct = HttpTypes.Product & {
56
+ * brand: Brand | null
57
+ * }
58
+ *
59
+ * const form = unstable_createFormHelper<ExtendedProduct>()
60
+ *
61
+ * export default unstable_defineCustomFieldsConfig({
62
+ * entryPoint: "product",
63
+ * link: "brand",
64
+ * forms: [{
65
+ * form: "create",
66
+ * fields: {
67
+ * brand_id: form.define({
68
+ * rules: form.string().nullish(),
69
+ * defaultValue: "",
70
+ * }),
71
+ * }
72
+ * }]
73
+ * })
74
+ * ```
75
+ *
76
+ * @experimental This API is experimental and may change in the future.
77
+ */
78
+ export function unstable_createFormHelper() {
79
+ return {
80
+ /**
81
+ * Define a custom form field.
82
+ *
83
+ * @param field The field to define.
84
+ * @returns The field.
85
+ */
86
+ define: (field) => {
87
+ return field;
88
+ },
89
+ string: () => z.string(),
90
+ number: () => z.number(),
91
+ boolean: () => z.boolean(),
92
+ date: () => z.date(),
93
+ array: z.array,
94
+ object: z.object,
95
+ null: () => z.null(),
96
+ nullable: z.nullable,
97
+ undefined: () => z.undefined(),
98
+ coerce: z.coerce,
99
+ };
100
+ }
package/dist/index.d.ts CHANGED
@@ -1,40 +1,2 @@
1
- import { InjectionZone, NestedRoutePosition } from '@etohq/admin-shared';
2
- import { ComponentType } from 'react';
3
-
4
- interface WidgetConfig {
5
- /**
6
- * The injection zone or zones that the widget should be injected into.
7
- */
8
- zone: InjectionZone | InjectionZone[];
9
- }
10
- interface RouteConfig {
11
- /**
12
- * An optional label to display in the sidebar. If not provided, the route will not be displayed in the sidebar.
13
- */
14
- label?: string;
15
- /**
16
- * An optional icon to display in the sidebar together with the label. If no label is provided, the icon will be ignored.
17
- */
18
- icon?: ComponentType;
19
- /**
20
- * The nested route to display under existing route in the sidebar.
21
- */
22
- nested?: NestedRoutePosition;
23
- }
24
-
25
- /**
26
- * Define a widget configuration.
27
- *
28
- * @param config The widget configuration.
29
- * @returns The widget configuration.
30
- */
31
- declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
32
- /**
33
- * Define a route configuration.
34
- *
35
- * @param config The route configuration.
36
- * @returns The route configuration.
37
- */
38
- declare function defineRouteConfig(config: RouteConfig): RouteConfig;
39
-
40
- export { type RouteConfig, type WidgetConfig, defineRouteConfig, defineWidgetConfig };
1
+ export * from "./config";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -1,53 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- defineRouteConfig: () => defineRouteConfig,
24
- defineWidgetConfig: () => defineWidgetConfig
25
- });
26
- module.exports = __toCommonJS(src_exports);
27
-
28
- // src/config/utils.ts
29
- var import_zod = require("zod");
30
- function createConfigHelper(config) {
31
- return {
32
- ...config,
33
- /**
34
- * This property is required to allow the config to be exported,
35
- * while still allowing HMR to work correctly.
36
- *
37
- * It tricks Fast Refresh into thinking that the config is a React component,
38
- * which allows it to be updated without a full page reload.
39
- */
40
- $$typeof: Symbol.for("react.memo")
41
- };
42
- }
43
- function defineWidgetConfig(config) {
44
- return createConfigHelper(config);
45
- }
46
- function defineRouteConfig(config) {
47
- return createConfigHelper(config);
48
- }
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- defineRouteConfig,
52
- defineWidgetConfig
53
- });
1
+ export * from "./config";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@etohq/admin-sdk",
3
3
  "description": "SDK for building extension for the Eto admin dashboard.",
4
- "version": "1.3.0",
4
+ "version": "1.5.0",
5
5
  "author": "Kasper Kristensen <kasper@etohq.com>",
6
6
  "types": "dist/index.d.ts",
7
7
  "main": "dist/index.js",
@@ -15,20 +15,24 @@
15
15
  "dist",
16
16
  "package.json"
17
17
  ],
18
- "scripts": {
19
- "build": "tsup"
20
- },
21
18
  "devDependencies": {
22
- "@types/react": "^18.3.2",
23
- "tsup": "^8.0.2",
24
- "typescript": "^5.8.3",
19
+ "@types/react": "18.3.2",
20
+ "tsup": "8.0.2",
21
+ "typescript": "5.8.3",
25
22
  "zod": "3.22.4"
26
23
  },
27
24
  "dependencies": {
28
- "@etohq/admin-shared": "^1.3.0"
25
+ "rimraf": "5.0.2",
26
+ "tsc-alias": "1.8.6",
27
+ "@etohq/admin-shared": "1.5.0"
29
28
  },
30
29
  "peerDependencies": {
31
- "zod": "^3.22"
30
+ "zod": "3.22.4"
32
31
  },
33
- "packageManager": "yarn@3.2.1"
34
- }
32
+ "scripts": {
33
+ "watch": "tsc --build --watch",
34
+ "watch:test": "tsc --build tsconfig.spec.json --watch",
35
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
36
+ "build": "rimraf dist && tsc --build && npm run resolve:aliases"
37
+ }
38
+ }
package/dist/index.d.mts DELETED
@@ -1,40 +0,0 @@
1
- import { InjectionZone, NestedRoutePosition } from '@etohq/admin-shared';
2
- import { ComponentType } from 'react';
3
-
4
- interface WidgetConfig {
5
- /**
6
- * The injection zone or zones that the widget should be injected into.
7
- */
8
- zone: InjectionZone | InjectionZone[];
9
- }
10
- interface RouteConfig {
11
- /**
12
- * An optional label to display in the sidebar. If not provided, the route will not be displayed in the sidebar.
13
- */
14
- label?: string;
15
- /**
16
- * An optional icon to display in the sidebar together with the label. If no label is provided, the icon will be ignored.
17
- */
18
- icon?: ComponentType;
19
- /**
20
- * The nested route to display under existing route in the sidebar.
21
- */
22
- nested?: NestedRoutePosition;
23
- }
24
-
25
- /**
26
- * Define a widget configuration.
27
- *
28
- * @param config The widget configuration.
29
- * @returns The widget configuration.
30
- */
31
- declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
32
- /**
33
- * Define a route configuration.
34
- *
35
- * @param config The route configuration.
36
- * @returns The route configuration.
37
- */
38
- declare function defineRouteConfig(config: RouteConfig): RouteConfig;
39
-
40
- export { type RouteConfig, type WidgetConfig, defineRouteConfig, defineWidgetConfig };
package/dist/index.mjs DELETED
@@ -1,25 +0,0 @@
1
- // src/config/utils.ts
2
- import { z } from "zod";
3
- function createConfigHelper(config) {
4
- return {
5
- ...config,
6
- /**
7
- * This property is required to allow the config to be exported,
8
- * while still allowing HMR to work correctly.
9
- *
10
- * It tricks Fast Refresh into thinking that the config is a React component,
11
- * which allows it to be updated without a full page reload.
12
- */
13
- $$typeof: Symbol.for("react.memo")
14
- };
15
- }
16
- function defineWidgetConfig(config) {
17
- return createConfigHelper(config);
18
- }
19
- function defineRouteConfig(config) {
20
- return createConfigHelper(config);
21
- }
22
- export {
23
- defineRouteConfig,
24
- defineWidgetConfig
25
- };