@yongdall/web 0.1.3 → 0.2.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/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as dot_request1 from "dot-request";
2
2
  import DotRequest, { default as DotRequest$1 } from "dot-request";
3
- import { ArrayStore, AsyncValidator, AsyncValidator as AsyncValidator$1, ObjectStore, Schema, Schema as Schema$1, Store, Store as Store$1, StoreLayout, StoreLayout as StoreLayout$1, Validator, Validator as Validator$1, renderStore } from "@neeloong/form";
3
+ import { ArrayStore, ObjectStore, Schema, Schema as Schema$1, Store, Store as Store$1, StoreLayout, StoreLayout as StoreLayout$1, renderStore } from "@neeloong/form";
4
4
  import { BootConfiguration, Hook, Indicator, Plugin, Search } from "@yongdall/common";
5
- import { Field, MaybePromise, Permission } from "@yongdall/types";
5
+ import { Field, MaybePromise, Permission, Permissions } from "@yongdall/types";
6
6
  import { Signal as Signal$1 } from "signal-polyfill";
7
7
  export * from "@yongdall/common";
8
8
 
@@ -504,21 +504,21 @@ declare class Page {
504
504
  * @param {AbortSignal} [signal]
505
505
  * @returns
506
506
  */
507
- createHeader(signal?: AbortSignal): PageHeader | null;
507
+ createHeader(signal?: AbortSignal): PageHeader;
508
508
  /**
509
509
  *
510
510
  * @param {AbortSignal} [signal]
511
511
  * @returns
512
512
  */
513
- createFooter(signal?: AbortSignal): PageFooter | null;
513
+ createFooter(signal?: AbortSignal): PageFooter;
514
514
  /**
515
515
  *
516
516
  * @param {'start' | 'end' | 'before' | 'after'} position
517
517
  * @param {boolean} [inserted]
518
518
  * @param {AbortSignal} [signal]
519
- * @returns {PageSection?}
519
+ * @returns {PageSection}
520
520
  */
521
- createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection | null;
521
+ createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection;
522
522
  get signal(): AbortSignal;
523
523
  set siderOpen(open: boolean);
524
524
  get siderOpen(): boolean;
@@ -526,9 +526,9 @@ declare class Page {
526
526
  *
527
527
  * @param {boolean} [inserted]
528
528
  * @param {AbortSignal} [signal]
529
- * @returns {PageSider?}
529
+ * @returns {PageSider}
530
530
  */
531
- createSider(inserted?: boolean, signal?: AbortSignal): PageSider | null;
531
+ createSider(inserted?: boolean, signal?: AbortSignal): PageSider;
532
532
  #private;
533
533
  }
534
534
  //#endregion
@@ -540,25 +540,25 @@ type PageConfiguration = {
540
540
  organization?: string | undefined;
541
541
  workspace?: string | undefined;
542
542
  page?: string | undefined;
543
- widget: string;
544
- title: string;
545
- titlePattern: string;
546
- config: Record<string, any>;
547
- fields: {
543
+ widget?: string | null | undefined;
544
+ title?: string | undefined;
545
+ titlePattern?: string | undefined;
546
+ config?: Record<string, any> | undefined;
547
+ fields?: {
548
548
  field?: string;
549
549
  label?: string;
550
550
  width?: number;
551
551
  pattern?: string;
552
- }[];
553
- sides: {
552
+ }[] | undefined;
553
+ sides?: {
554
554
  widget: string;
555
555
  options: string;
556
- }[];
557
- menuButtons: Menu.Button[];
558
- menus: (Menu | null)[];
559
- forms: Record<string, {
556
+ }[] | undefined;
557
+ menuButtons?: Menu.Button[] | undefined;
558
+ menus?: (Menu | null)[] | undefined;
559
+ forms?: Record<string, {
560
560
  layoutId?: string;
561
- } | null>;
561
+ } | null> | undefined;
562
562
  where?: Search.AndList | undefined;
563
563
  orWhere?: Search.OrList | undefined;
564
564
  defaultQuery?: string | undefined;
@@ -670,9 +670,9 @@ declare namespace PageIdent {
670
670
  * @returns
671
671
  */
672
672
  declare function modelService(model: string): {
673
- then<TResult1 = ModelConfiguration, TResult2 = never>(onfulfilled?: ((value: ModelConfiguration) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
674
- catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<ModelConfiguration | TResult2>;
675
- finally(onfinally?: (() => void) | null | undefined): Promise<ModelConfiguration>;
673
+ then<TResult1 = ModelConfiguration | null, TResult2 = never>(onfulfilled?: ((value: ModelConfiguration | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
674
+ catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<ModelConfiguration | TResult2 | null>;
675
+ finally(onfinally?: (() => void) | null | undefined): Promise<ModelConfiguration | null>;
676
676
  /**
677
677
  * @param {Search.Param} [options]
678
678
  * @returns {Promise<{documents: any[]; total: number}>}
@@ -685,7 +685,8 @@ declare function modelService(model: string): {
685
685
  limit,
686
686
  page,
687
687
  offset,
688
- select
688
+ select,
689
+ total
689
690
  }?: Search.Param): Promise<{
690
691
  documents: any[];
691
692
  total: number;
@@ -749,22 +750,10 @@ declare function modelService(model: string): {
749
750
  get: () => Promise<any>;
750
751
  };
751
752
  };
752
- loadModel: (force?: boolean) => Promise<ModelConfiguration>;
753
- loadScript: (force?: boolean) => Promise<ModelScriptConfiguration>;
753
+ loadModel: (force?: boolean) => Promise<ModelConfiguration | null>;
754
+ loadScript: (force?: boolean) => Promise<ModelScriptConfiguration | null>;
754
755
  getModel: () => ModelConfiguration | null;
755
756
  getScript: () => ModelScriptConfiguration | null;
756
- page: (page: string, workspace?: string | null) => {
757
- load: (force?: boolean) => Promise<PageConfiguration>;
758
- /**
759
- * @template [TResult1=PageConfiguration]
760
- * @template [TResult2=never]
761
- * @param {((value: PageConfiguration) => TResult1 | PromiseLike<TResult1>)?} [onfulfilled]
762
- * @param {((reason: any) => TResult2 | PromiseLike<TResult2>)?} [onrejected]
763
- * @returns {Promise<TResult1 | TResult2>};
764
- */
765
- then<TResult1 = PageConfiguration, TResult2 = never>(onfulfilled?: ((value: PageConfiguration) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
766
- configuration(): Promise<false | Record<string, any>>;
767
- };
768
757
  };
769
758
  type ModelConfiguration = {
770
759
  id?: string | undefined;
@@ -799,6 +788,10 @@ type ModelConfiguration = {
799
788
  options?: Record<string, unknown> | null | undefined;
800
789
  /**
801
790
  * 关联前端脚本
791
+ */
792
+ scripts?: (string | [string, object])[] | null | undefined;
793
+ /**
794
+ * 关联默认页面
802
795
  * // TODO: 查询配置
803
796
  * // TODO: 前端按钮配置
804
797
  * // TODO: 是否可销毁、可创建、更新、保存、upsert
@@ -807,7 +800,7 @@ type ModelConfiguration = {
807
800
  * // TODO: 操作事件
808
801
  * // TODO: 是否分页
809
802
  */
810
- scripts?: (string | [string, object])[] | null | undefined;
803
+ pages?: Record<string, string | object | null> | null | undefined;
811
804
  };
812
805
  type FieldScriptConfiguration = Omit<Field, "scripts" | "type"> & {
813
806
  script?: Omit<FieldScript, "subFields">;
@@ -868,13 +861,13 @@ type FieldScript = {
868
861
  step?: ((store: Store$1) => string) | null | undefined;
869
862
  max?: ((store: Store$1) => string) | null | undefined;
870
863
  min?: ((store: Store$1) => string) | null | undefined;
871
- validator?: Validator$1 | Validator$1[] | null | undefined;
864
+ validator?: Schema$1.Validator | Schema$1.Validator[] | null | undefined;
872
865
  validators?: {
873
- input?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
874
- change?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
875
- click?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
876
- focus?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
877
- blur?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
866
+ input?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
867
+ change?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
868
+ click?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
869
+ focus?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
870
+ blur?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
878
871
  } | undefined;
879
872
  };
880
873
  //#endregion
@@ -1034,12 +1027,18 @@ type User = {
1034
1027
  plugins?: Record<string, Record<string, any>> | undefined;
1035
1028
  };
1036
1029
  declare namespace User {
1030
+ const multi: boolean;
1031
+ const single: boolean;
1037
1032
  const session: User | null;
1038
1033
  const target: User | null;
1039
1034
  const current: User | null;
1040
- const permissions: Set<string> | null;
1041
- const organizationPermissions: Record<string, Set<string>> | null;
1042
- const allOrganizationPermissions: Set<string> | null;
1035
+ /** @param {string} permission */
1036
+ function hasPermission(permission: string): boolean;
1037
+ /** @param {string} permission @param {string} [organization] */
1038
+ function hasOrganizationPermission(permission: string, organization?: string): boolean;
1039
+ const permissions: Permissions;
1040
+ const organizationPermissions: Record<string, Permissions>;
1041
+ const allOrganizationPermissions: Permissions;
1043
1042
  const waitLogin: boolean;
1044
1043
  /**
1045
1044
  * @template {Record<string, any>} T
@@ -1161,10 +1160,6 @@ interface FieldStyle {
1161
1160
  /** 是否为设计模式 */
1162
1161
  design?: boolean;
1163
1162
  }
1164
- interface RendererFieldStyle extends FieldStyle {
1165
- /** 是否为编辑模式 */
1166
- editable?: boolean;
1167
- }
1168
1163
  interface FieldShowHandle {
1169
1164
  readonly root: HTMLElement;
1170
1165
  destroy(): void;
@@ -1218,10 +1213,19 @@ interface FormFieldHook {
1218
1213
  filters: Record<string, FieldFilterComponent | [FieldFilterComponent, string?]>;
1219
1214
  }
1220
1215
  declare namespace FromRenderer {
1221
- interface Options extends StoreLayout$1 {}
1216
+ interface Options {
1217
+ model?: ModelScriptConfiguration | null;
1218
+ layout?: StoreLayout$1<any> | null;
1219
+ editable?: boolean;
1220
+ signal?: AbortSignal;
1221
+ /** 是否启用链接 */
1222
+ enableLink?: boolean;
1223
+ /** 是否为设计模式 */
1224
+ design?: boolean;
1225
+ }
1222
1226
  }
1223
1227
  interface FromRenderer {
1224
- render(model: ModelScriptConfiguration, store: Store$1<any, any>, root: HTMLElement, style: RendererFieldStyle, options?: FromRenderer.Options | null): () => void;
1228
+ render(store: Store$1<any, any>, root: HTMLElement, options?: FromRenderer.Options): void;
1225
1229
  }
1226
1230
  interface UserHook {
1227
1231
  permissions(userPlugin: Record<string, any>, user: User): Set<string> | null;
@@ -1324,36 +1328,39 @@ declare class PageContext extends GeneralContext {
1324
1328
  /**
1325
1329
  *
1326
1330
  * @param {AbortSignal} [signal]
1327
- * @returns {PageHeader?}
1331
+ * @returns {PageHeader}
1328
1332
  */
1329
- createHeader(signal?: AbortSignal): PageHeader | null;
1333
+ createHeader(signal?: AbortSignal): PageHeader;
1330
1334
  /**
1331
1335
  *
1332
1336
  * @param {AbortSignal} [signal]
1333
- * @returns {PageFooter?}
1337
+ * @returns {PageFooter}
1334
1338
  */
1335
- createFooter(signal?: AbortSignal): PageFooter | null;
1339
+ createFooter(signal?: AbortSignal): PageFooter;
1336
1340
  /**
1337
1341
  *
1338
1342
  * @param {boolean} [inserted]
1339
1343
  * @param {AbortSignal} [signal]
1340
1344
  * @returns
1341
1345
  */
1342
- createSider(inserted?: boolean, signal?: AbortSignal): PageSider | null;
1346
+ createSider(inserted?: boolean, signal?: AbortSignal): PageSider;
1343
1347
  /**
1344
1348
  *
1345
1349
  * @param {'start' | 'end' | 'before' | 'after'} position
1346
1350
  * @param {boolean} [inserted]
1347
1351
  * @param {AbortSignal} [signal]
1348
- * @returns {PageSection?}
1352
+ * @returns {PageSection}
1349
1353
  */
1350
- createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection | null;
1354
+ createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection;
1351
1355
  /**
1352
1356
  *
1353
- * @param {PageConfiguration['sides']} sides
1357
+ * @param {{widget: string; options: string}[]} sides
1354
1358
  * @param {PageSectionParam} param
1355
1359
  */
1356
- renderSides(sides: PageConfiguration["sides"], param: PageSectionParam): void;
1360
+ renderSides(sides: {
1361
+ widget: string;
1362
+ options: string;
1363
+ }[], param: PageSectionParam): void;
1357
1364
  /**
1358
1365
  * @param {string} url
1359
1366
  * @param {string | PageIdent} [page]
@@ -1525,25 +1532,29 @@ declare function toSchema(fields: Record<string, FieldScriptConfiguration>, comp
1525
1532
  //#region packages/web/form/renderForm.d.mts
1526
1533
  /**
1527
1534
  *
1528
- * @param {ModelConfiguration} model
1529
- * @param {Store} store
1535
+ * @param {Store<any, any>} store
1530
1536
  * @param {HTMLElement} root
1531
- * @param {RendererFieldStyle} style
1532
- * @param {FromRenderer.Options?} [options]
1533
- * @param {string?} [type]
1537
+ * @param {FromRenderer.Options & {type?: string}} [options]
1538
+ * @returns {void}
1534
1539
  */
1535
- declare function _default$1(model: ModelConfiguration, store: Store$1, root: HTMLElement, style: RendererFieldStyle, options?: FromRenderer.Options | null, type?: string | null): () => void;
1540
+ declare function _default$1(store: Store$1<any, any>, root: HTMLElement, options?: FromRenderer.Options & {
1541
+ type?: string;
1542
+ }): void;
1536
1543
  //#endregion
1537
- //#region packages/web/form/renderGridForm.d.mts
1544
+ //#region packages/web/form/renderStoreForm.d.mts
1538
1545
  /**
1539
1546
  *
1540
- * @param {ModelConfiguration} model
1541
- * @param {Store} store
1547
+ * @param {Store<any, any>} store
1542
1548
  * @param {HTMLElement} root
1543
- * @param {RendererFieldStyle} style
1544
- * @param {StoreLayout?} [options]
1549
+ * @param {FromRenderer.Options} [options]
1545
1550
  */
1546
- declare function _default$2(model: ModelConfiguration, store: Store$1, root: HTMLElement, style: RendererFieldStyle, options?: StoreLayout$1 | null): () => void;
1551
+ declare function _default$2(store: Store$1<any, any>, root: HTMLElement, {
1552
+ enableLink,
1553
+ design,
1554
+ layout,
1555
+ editable,
1556
+ signal
1557
+ }?: FromRenderer.Options): void;
1547
1558
  //#endregion
1548
1559
  //#region packages/web/form/createStore.d.mts
1549
1560
  /**
@@ -1601,10 +1612,11 @@ declare function showFilterDialog(modelDefine: ModelScriptConfiguration, value?:
1601
1612
  *
1602
1613
  * @param {Store} store
1603
1614
  * @param {FieldStyle} style
1615
+ * @param {any} [renderer]
1604
1616
  * @param {StoreLayout.Options?} [options]
1605
- * @returns {[HTMLElement, () => void]?}
1617
+ * @returns {HTMLElement?}
1606
1618
  */
1607
- declare function createStoreField(store: Store$1, style: FieldStyle, options?: StoreLayout$1.Options | null): [HTMLElement, () => void] | null;
1619
+ declare function createStoreField(store: Store$1, style: FieldStyle, renderer?: any, options?: StoreLayout$1.Options | null): HTMLElement | null;
1608
1620
  //#endregion
1609
1621
  //#region packages/web/utils/toUrl.d.mts
1610
1622
  /**
@@ -1662,22 +1674,22 @@ declare function formLayoutsService(layout: string): {
1662
1674
  then<TResult1 = {
1663
1675
  layout: any;
1664
1676
  type?: string;
1665
- }, TResult2 = never>(onfulfilled?: ((value: {
1677
+ } | null, TResult2 = never>(onfulfilled?: ((value: {
1666
1678
  layout: any;
1667
1679
  type?: string;
1668
- }) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1680
+ } | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1669
1681
  catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<{
1670
1682
  layout: any;
1671
1683
  type?: string;
1672
- } | TResult2>;
1684
+ } | TResult2 | null>;
1673
1685
  finally(onfinally?: (() => void) | null | undefined): Promise<{
1674
1686
  layout: any;
1675
1687
  type?: string;
1676
- }>;
1688
+ } | null>;
1677
1689
  load: (force?: boolean) => Promise<{
1678
1690
  layout: any;
1679
1691
  type?: string;
1680
- }>;
1692
+ } | null>;
1681
1693
  get: () => {
1682
1694
  layout: any;
1683
1695
  type?: string;
@@ -2121,7 +2133,6 @@ declare let loadTheme: () => MaybePromise<Partial<Omit<Theme, "styleFiles"> & Re
2121
2133
  //#region packages/web/configuration.d.mts
2122
2134
  /** @type {Record<string, Plugin>} */
2123
2135
  declare const plugins: Record<string, Plugin>;
2124
- declare const single: boolean | undefined;
2125
2136
  declare const userMenus: any[];
2126
2137
  declare const webRoot: URL;
2127
2138
  /** @import { Plugin, BootConfiguration } from '@yongdall/common' */
@@ -2188,4 +2199,4 @@ declare function updateHooks(hooks: Record<string, Hook.Define<Hooks>>): void;
2188
2199
  /** @type {Hook<Hooks>} */
2189
2200
  declare const allHooks: Hook<Hooks>;
2190
2201
  //#endregion
2191
- export { ArrayStore, type AsyncValidator, Authenticator, Command, ConfiguratorComponent, ConfiguratorContext, type ContinuationDefine, DotRequest, FieldComponent, FieldComponentEvent, FieldComponents, FieldContext, FieldDefine, FieldFilterComponent, FieldFilterContext, FieldFilterStyle, type FieldScript, type FieldScriptConfiguration, FieldShowHandle, FieldStyle, FormFieldHook, FromRenderer, GeneralContext, type HomeContext, Hooks, IconDefine, Ident_d_exports as Ident, List, type Match, Menu, type ModelConfiguration, ModelIndicator, type ModelScript, type ModelScriptConfiguration, ObjectStore, Option, Page, type PageContext, type PageError, PageFooter, type PageHandle, PageHeader, type PageIdent, type PageManager, type PageRenderer, PageSection, PageSectionParam, PageSider, Pagination, RendererFieldStyle, ResponseError, type Schema, Signal$1 as Signal, State, Store, type StoreLayout, SubmodelsLayoutEvent, Theme, User, UserHook, type Validator, VerifyContext, VerifyError, type WorkspaceDefine, addManager, allHooks, buildPlugin, configuration, createComputed, createFilters, createIcon, createQuickFilters, createShowField, createState, createStore, createStoreField, effect, enumerationsService, execScript, filterPermission, findConfigurator, formLayoutsService, getAuthorizations, getField, getFieldFilter, getFieldFilterOperators, getPages, getPrimaryFields, hasField, hasFieldFilter, importStyle, importWidget, isPluginId, loadMenu, loadOptions, modelService, neverAbortedSignal, pathRoots, _default as permissionsService, plugins, _default$1 as renderForm, _default$2 as renderGridForm, renderStore, request, root$1 as root, selectFile, setIcon, showFilterDialog, single, start, testPermission, testPermissionConstraints, toFileLink, toFileURL, toId, toSchema, toUrl, updateHooks, userMenus, waitAbortSignal, watch, webRoot };
2202
+ export { ArrayStore, Authenticator, Command, ConfiguratorComponent, ConfiguratorContext, type ContinuationDefine, DotRequest, FieldComponent, FieldComponentEvent, FieldComponents, FieldContext, FieldDefine, FieldFilterComponent, FieldFilterContext, FieldFilterStyle, type FieldScript, type FieldScriptConfiguration, FieldShowHandle, FieldStyle, FormFieldHook, FromRenderer, GeneralContext, type HomeContext, Hooks, IconDefine, Ident_d_exports as Ident, List, type Match, Menu, type ModelConfiguration, ModelIndicator, type ModelScript, type ModelScriptConfiguration, ObjectStore, Option, Page, type PageContext, type PageError, PageFooter, type PageHandle, PageHeader, type PageIdent, type PageManager, type PageRenderer, PageSection, PageSectionParam, PageSider, Pagination, ResponseError, type Schema, Signal$1 as Signal, State, Store, type StoreLayout, SubmodelsLayoutEvent, Theme, User, UserHook, VerifyContext, VerifyError, type WorkspaceDefine, addManager, allHooks, buildPlugin, configuration, createComputed, createFilters, createIcon, createQuickFilters, createShowField, createState, createStore, createStoreField, effect, enumerationsService, execScript, filterPermission, findConfigurator, formLayoutsService, getAuthorizations, getField, getFieldFilter, getFieldFilterOperators, getPages, getPrimaryFields, hasField, hasFieldFilter, importStyle, importWidget, isPluginId, loadMenu, loadOptions, modelService, neverAbortedSignal, pathRoots, _default as permissionsService, plugins, _default$1 as renderForm, renderStore, _default$2 as renderStoreForm, request, root$1 as root, selectFile, setIcon, showFilterDialog, start, testPermission, testPermissionConstraints, toFileLink, toFileURL, toId, toSchema, toUrl, updateHooks, userMenus, waitAbortSignal, watch, webRoot };