zova-module-a-openapi 5.0.0 → 5.1.1

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/src/monkey.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { IModule } from '@cabloy/module-info';
2
+ import type { Ref } from 'vue';
3
+ import type { BeanBase, BeanContainer, IMonkeyBeanInit, IMonkeyModule } from 'zova';
4
+
5
+ import { ref, watch } from 'vue';
6
+ import { BeanSimple } from 'zova';
7
+
8
+ import type { ModelSdk } from './model/sdk.js';
9
+
10
+ export class Monkey extends BeanSimple implements IMonkeyModule, IMonkeyBeanInit {
11
+ private _moduleSelf: IModule;
12
+ private _modelSdk: Ref<ModelSdk | undefined> = ref();
13
+
14
+ constructor(moduleSelf: IModule) {
15
+ super();
16
+ this._moduleSelf = moduleSelf;
17
+ }
18
+
19
+ async moduleLoading(_module: IModule) {}
20
+ async moduleLoaded(module: IModule) {
21
+ // self
22
+ if (this._moduleSelf === module) {
23
+ await this._loadSdk();
24
+ this.ctx.util.instanceScope(() => {
25
+ return watch(
26
+ () => {
27
+ return this.app.meta.locale.current;
28
+ },
29
+ async () => {
30
+ await this._loadSdk();
31
+ },
32
+ );
33
+ });
34
+ }
35
+ }
36
+
37
+ async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
38
+ const self = this;
39
+ // $sdk
40
+ bean.defineProperty(beanInstance, '$sdk', {
41
+ enumerable: false,
42
+ configurable: true,
43
+ get() {
44
+ return self._modelSdk;
45
+ },
46
+ });
47
+ }
48
+
49
+ private async _loadSdk() {
50
+ this._modelSdk.value = await this.app.bean._getBeanSelector('a-openapi.model.sdk', true, this.app.meta.locale.current);
51
+ }
52
+ }
@@ -0,0 +1,26 @@
1
+ import type { BeanBase, ZovaApplication, ZovaContext } from 'zova';
2
+ import type { ZovaJsx } from 'zova-jsx';
3
+ import type { IActionRecord } from 'zova-module-a-action';
4
+
5
+ export interface IJsxRenderContextBase {
6
+ app: ZovaApplication;
7
+ ctx: ZovaContext;
8
+ $scene?: keyof IJsxRenderSceneRecord;
9
+ $host: BeanBase;
10
+ $celScope?: unknown;
11
+ $jsx: ZovaJsx;
12
+ }
13
+
14
+ export interface IJsxRenderSceneRecord {
15
+ pageWrapper: never;
16
+ page: never;
17
+ pageEntryWrapper: never;
18
+ pageEntry: never;
19
+ // table: never;
20
+ tableColumn: never;
21
+ tableCell: never;
22
+ // form: never;
23
+ formField: never;
24
+ }
25
+
26
+ export type TypeActionProvider = keyof IActionRecord;
@@ -0,0 +1,18 @@
1
+ export interface IResourceActionTableOptions {}
2
+ export interface IResourceActionRowOptions {}
3
+
4
+ export interface TypeResourceActionTableRecord {
5
+ create: IResourceActionTableOptions;
6
+ operationsTable: IResourceActionTableOptions;
7
+ }
8
+
9
+ export interface TypeResourceActionRowRecord {
10
+ view: IResourceActionRowOptions;
11
+ update: IResourceActionRowOptions;
12
+ delete: IResourceActionRowOptions;
13
+ operationsRow: IResourceActionRowOptions;
14
+ }
15
+
16
+ export type TypeResourceActionRowRecordRender = {
17
+ [key in keyof TypeResourceActionRowRecord as `action${Capitalize<key>}`]: TypeResourceActionRowRecord[key];
18
+ };
@@ -0,0 +1,16 @@
1
+ export interface ICaptchaSceneRecord {
2
+ 'captcha-simple:simple': never;
3
+ }
4
+
5
+ export interface ICaptchaProviderRecord {}
6
+
7
+ export interface ICaptchaOptions {
8
+ scene?: keyof ICaptchaSceneRecord;
9
+ }
10
+
11
+ export interface ICaptchaData {
12
+ id: string;
13
+ provider: keyof ICaptchaProviderRecord | string;
14
+ token?: unknown;
15
+ payload?: unknown;
16
+ }
@@ -0,0 +1,4 @@
1
+ export const OrderCoreBase = 100;
2
+ export const OrderBusinessBase = 1000;
3
+ export const OrderUnknownBase = 10000;
4
+ export const OrderMaxBase = 100000;
@@ -0,0 +1,25 @@
1
+ export type TypeDateFormatPreset =
2
+ | 'DATE_SHORT'
3
+ | 'DATE_MED'
4
+ | 'DATE_MED_WITH_WEEKDAY'
5
+ | 'DATE_FULL'
6
+ | 'DATE_HUGE'
7
+ | 'TIME_SIMPLE'
8
+ | 'TIME_WITH_SECONDS'
9
+ | 'TIME_WITH_SHORT_OFFSET'
10
+ | 'TIME_WITH_LONG_OFFSET'
11
+ | 'TIME_24_SIMPLE'
12
+ | 'TIME_24_WITH_SECONDS'
13
+ | 'TIME_24_WITH_SHORT_OFFSET'
14
+ | 'TIME_24_WITH_LONG_OFFSET'
15
+ | 'DATETIME_SHORT'
16
+ | 'DATETIME_MED'
17
+ | 'DATETIME_MED_WITH_WEEKDAY'
18
+ | 'DATETIME_FULL'
19
+ | 'DATETIME_HUGE'
20
+ | 'DATETIME_SHORT_WITH_SECONDS'
21
+ | 'DATETIME_MED_WITH_SECONDS'
22
+ | 'DATETIME_FULL_WITH_SECONDS'
23
+ | 'DATETIME_HUGE_WITH_SECONDS';
24
+
25
+ export type TypeDateFormat = { preset: TypeDateFormatPreset } | string;
@@ -0,0 +1,16 @@
1
+ export * from './action.js';
2
+ export * from './actions.js';
3
+ export * from './captcha.js';
4
+ export * from './database.js';
5
+ export * from './date.js';
6
+ export * from './jsx.js';
7
+ export * from './permissions.js';
8
+ export * from './resourceMeta.js';
9
+ export * from './resourcePicker.js';
10
+ export * from './rest.js';
11
+ export * from './schema.js';
12
+ export * from './sdk.js';
13
+ export * from './select.js';
14
+ export * from './table.js';
15
+ export * from './textarea.js';
16
+ export * from './toggle.js';
@@ -0,0 +1,10 @@
1
+ import type { IActionsRecord } from 'zova-module-a-action';
2
+
3
+ import type { TypeActionProvider } from './action.js';
4
+ import 'zova-jsx';
5
+
6
+ declare module 'zova-jsx' {
7
+ export interface ZovaJsx {
8
+ normalizeAction(type: keyof IActionsRecord): TypeActionProvider;
9
+ }
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { TableIdentity } from 'table-identity';
2
+
3
+ export interface IOpenapiActionRecord {
4
+ create: boolean;
5
+ view: boolean;
6
+ update: boolean;
7
+ delete: boolean;
8
+ }
9
+
10
+ export type IOpenapiPermissionModeActionActions = {
11
+ [K in keyof IOpenapiActionRecord]?: IOpenapiActionRecord[K];
12
+ };
13
+
14
+ export interface IOpenapiPermissions {
15
+ roleIds?: TableIdentity[];
16
+ roleNames?: string[];
17
+ actions?: IOpenapiPermissionModeActionActions;
18
+ }
@@ -0,0 +1,37 @@
1
+ import type { TypeComponentRecordSelectorKeysStrict } from 'zova';
2
+ import type { IActionsRecord } from 'zova-module-a-action';
3
+
4
+ import type { IOpenapiPermissions } from './permissions.js';
5
+
6
+ export type TypeOpenApiRestResourceScene = 'table' | 'row';
7
+
8
+ export type TypeOpenapiPermissions = IOpenapiPermissions | boolean;
9
+
10
+ export interface IOpenapiOptionsResourceMeta {
11
+ /**
12
+ * false: disallow
13
+ * true: public
14
+ * undefined: by api
15
+ * IOpenapiPermissions: specific
16
+ */
17
+ permissions?: TypeOpenapiPermissions;
18
+ provider?: IOpenapiOptionsResourceMetaProvider;
19
+ form?: IOpenapiOptionsResourceMetaForm;
20
+ table?: IOpenapiOptionsResourceMetaTable;
21
+ }
22
+
23
+ export interface IOpenapiOptionsResourceMetaForm {}
24
+
25
+ export interface IOpenapiOptionsResourceMetaTable {}
26
+
27
+ export interface IOpenapiOptionsResourceMetaProvider {
28
+ components?: IOpenapiOptionsResourceMetaProviderComponents;
29
+ actions?: IActionsRecord;
30
+ }
31
+
32
+ export interface IOpenapiOptionsResourceMetaProviderComponents {
33
+ restPage?: TypeComponentRecordSelectorKeysStrict<'restPage'>;
34
+ restPageEntry?: TypeComponentRecordSelectorKeysStrict<'restPageEntry'>;
35
+ table?: TypeComponentRecordSelectorKeysStrict<'table'>;
36
+ form?: TypeComponentRecordSelectorKeysStrict<'form'>;
37
+ }
@@ -0,0 +1,10 @@
1
+ import type { ISelectOptions } from './select.js';
2
+ import type { ITableQuery } from './table.js';
3
+
4
+ export interface IResourcePickerOptions {
5
+ resource?: string;
6
+ actionPath?: string;
7
+ query?: ITableQuery;
8
+ selectOptions?: ISelectOptions;
9
+ relation?: string;
10
+ }
@@ -0,0 +1,107 @@
1
+ import type { CurrencyOptions } from '@zhennann/currency';
2
+ import type { ComponentPublicInstance } from 'vue';
3
+ import type { Constructable, IComponentRecord, TypeBeanRecordGeneralSelector } from 'zova';
4
+ import type { TypeRenderComponentJsx } from 'zova-jsx';
5
+
6
+ import type { TypeResourceActionRowRecordRender } from './actions.js';
7
+ import type { ICaptchaOptions } from './captcha.js';
8
+ import type { TypeDateFormat } from './date.js';
9
+ import type { IResourcePickerOptions } from './resourcePicker.js';
10
+ import type { ISelectOptions } from './select.js';
11
+ import type { ITextareaOptions } from './textarea.js';
12
+ import type { IToggleOptions } from './toggle.js';
13
+ import 'openapi3-ts/oas30';
14
+ import 'openapi3-ts/oas31';
15
+
16
+ export interface ISchemaObjectExtensionFieldRest {
17
+ render?: TypeFormFieldRenderComponentNormal | TypeTableCellRenderComponentNormal;
18
+ captcha?: ICaptchaOptions;
19
+ currency?: CurrencyOptions;
20
+ dateFormat?: TypeDateFormat;
21
+ toggle?: IToggleOptions;
22
+ select?: ISelectOptions;
23
+ textarea?: ITextareaOptions;
24
+ resourcePicker?: IResourcePickerOptions;
25
+ customKey?: string;
26
+ visible?: boolean;
27
+ displayValue?: any;
28
+ order?: number;
29
+ table?: Omit<ISchemaObjectExtensionFieldRest, TypeSchemaScene>;
30
+ form?: Omit<ISchemaObjectExtensionFieldRest, TypeSchemaScene>;
31
+ filter?: Omit<ISchemaObjectExtensionFieldRest, TypeSchemaScene>;
32
+ }
33
+
34
+ export interface ISchemaObjectExtensionFieldFilterCapabilities {
35
+ where?: boolean;
36
+ // filter?: boolean;
37
+ order?: boolean;
38
+ // group?: boolean;
39
+ }
40
+
41
+ export interface ISchemaObjectExtensionFieldFilter {
42
+ capabilities?: ISchemaObjectExtensionFieldFilterCapabilities;
43
+ }
44
+
45
+ export interface ISchemaObjectExtensionField {
46
+ key?: string;
47
+ rest?: ISchemaObjectExtensionFieldRest;
48
+ filter?: ISchemaObjectExtensionFieldFilter;
49
+ }
50
+
51
+ declare module 'openapi3-ts/oas30' {
52
+ export interface SchemaObject extends ISchemaObjectExtensionField {}
53
+ }
54
+
55
+ declare module 'openapi3-ts/oas31' {
56
+ export interface SchemaObject extends ISchemaObjectExtensionField {}
57
+ }
58
+
59
+ export type TypeSchemaScene = 'table' | 'form' | 'filter';
60
+ export type TypeFormSchemaScene = 'form' | 'filter';
61
+
62
+ export const renderFormFieldTopPropsSystem = ['order', 'table', 'form', 'filter'];
63
+ export const renderTableColumnTopPropsSystem = ['order', 'table', 'form', 'filter', 'displayValue'];
64
+
65
+ export type TypeRenderComponentPreset =
66
+ | keyof TypeResourceActionRowRecordRender
67
+ | 'text'
68
+ | 'captcha'
69
+ | 'currency'
70
+ | 'date'
71
+ | 'dateRange'
72
+ | 'textarea'
73
+ | 'select'
74
+ | 'checkbox'
75
+ | 'radio'
76
+ | 'switch'
77
+ | 'image'
78
+ | 'file'
79
+ | 'color'
80
+ | 'password'
81
+ | 'email'
82
+ | 'url';
83
+
84
+ // form
85
+ export type TypeFormFieldRenderComponentNormal = Constructable<ComponentPublicInstance> | keyof IComponentRecord | TypeRenderComponentPreset;
86
+ export type TypeFormFieldRenderComponent = TypeFormFieldRenderComponentNormal | TypeRenderComponentJsx;
87
+ export type TypeFormFieldRenderComponentProvider =
88
+ | Constructable
89
+ | Constructable<ComponentPublicInstance>
90
+ | keyof IComponentRecord
91
+ | 'input'
92
+ | 'textarea'
93
+ | 'select';
94
+
95
+ // table
96
+ export type TypeTableCellRenderComponentNormal =
97
+ | Constructable<ComponentPublicInstance>
98
+ | keyof IComponentRecord
99
+ | keyof TypeBeanRecordGeneralSelector<'tableCell'>
100
+ | TypeRenderComponentPreset;
101
+ export type TypeTableCellRenderComponent = TypeTableCellRenderComponentNormal | TypeRenderComponentJsx;
102
+ export type TypeTableCellRenderComponentProvider =
103
+ | Constructable<ComponentPublicInstance>
104
+ | keyof IComponentRecord
105
+ | keyof TypeBeanRecordGeneralSelector<'tableCell'>
106
+ | 'text';
107
+ export type TypeTableRenderComponentProvider = Constructable<ComponentPublicInstance> | keyof IComponentRecord | TypeRenderComponentJsx;
@@ -0,0 +1,24 @@
1
+ import type { DefaultError, UseQueryReturnType } from '@tanstack/vue-query';
2
+ import type { OpenAPIObject, SchemaObject } from 'openapi3-ts/oas31';
3
+ import type { UnwrapNestedRefs } from 'vue';
4
+
5
+ import type { IOpenapiSdkItem } from './sdk.js';
6
+
7
+ export interface IOpenapiSchema {
8
+ doc: OpenAPIObject;
9
+ meta?: IOpenapiSchemaMeta;
10
+ }
11
+
12
+ export interface IOpenapiSchemaMeta {}
13
+
14
+ export type TypeOpenapiSchemasSdk = UnwrapNestedRefs<UseQueryReturnType<IOpenapiSdkItem, DefaultError>>;
15
+
16
+ export interface IOpenapiSchemas {
17
+ sdk: TypeOpenapiSchemasSdk;
18
+ query?: SchemaObject;
19
+ filter?: SchemaObject;
20
+ requestBody?: SchemaObject;
21
+ responseBody?: SchemaObject;
22
+ paged?: SchemaObject;
23
+ row?: SchemaObject;
24
+ }
@@ -0,0 +1,26 @@
1
+ import type { OperationObject } from 'openapi3-ts/oas31';
2
+
3
+ import type { ModelSdk } from '../model/sdk.js';
4
+ import type { IOpenapiOptionsResourceMeta } from './resourceMeta.js';
5
+ import type { IOpenapiSchemaMeta } from './schema.js';
6
+
7
+ export const SymbolOpenapiSchemaName = '__schemaName__';
8
+
9
+ export interface IOpenapiSdkBootstrap {
10
+ apiPath: string;
11
+ resourceMeta: IOpenapiOptionsResourceMeta;
12
+ }
13
+
14
+ export interface IOpenapiSdkItem {
15
+ schemas: string[];
16
+ operationObject: OperationObject;
17
+ meta?: IOpenapiSchemaMeta;
18
+ }
19
+
20
+ export type TypeRequestMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
21
+
22
+ declare module 'zova' {
23
+ export interface BeanBase {
24
+ $sdk: ModelSdk;
25
+ }
26
+ }
@@ -0,0 +1,16 @@
1
+ export interface ISelectChipsOptions {
2
+ column?: boolean;
3
+ filter?: boolean;
4
+ selectedClass?: string;
5
+ }
6
+
7
+ export interface ISelectOptions {
8
+ mode?: 'default' | 'chips';
9
+ chipsOptions?: ISelectChipsOptions;
10
+ multiple?: boolean;
11
+ chips?: boolean;
12
+ items?: any[];
13
+ itemTitle?: string;
14
+ itemValue?: string;
15
+ itemProps?: string;
16
+ }
@@ -0,0 +1,27 @@
1
+ export interface ITablePaged {
2
+ pageNo: number;
3
+ pageSize?: number;
4
+ }
5
+
6
+ export interface ITableQuery {
7
+ columns?: string[] | undefined;
8
+ where?:
9
+ | {
10
+ [key: string]: unknown;
11
+ }
12
+ | undefined;
13
+ orders?: string | string[][] | undefined;
14
+ pageNo?: number;
15
+ pageSize?: number;
16
+ }
17
+
18
+ export interface ITableRes<Entity = any> extends ITableResPaged {
19
+ list: Entity[];
20
+ }
21
+
22
+ export interface ITableResPaged {
23
+ total: string;
24
+ pageCount: number;
25
+ pageSize: number;
26
+ pageNo: number;
27
+ }
@@ -0,0 +1,10 @@
1
+ export interface ITextareaOptions {
2
+ autoGrow?: boolean;
3
+ maxRows?: number;
4
+ maxHeight?: number;
5
+ noResize?: boolean;
6
+ rows?: number;
7
+ color?: string;
8
+ bgColor?: string;
9
+ counter?: string | number | true;
10
+ }
@@ -0,0 +1,3 @@
1
+ export interface IToggleOptions {
2
+ color?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
3
+ }
package/README.md DELETED
@@ -1 +0,0 @@
1
- # @cabloy/set