@mythpe/quasar-ui-qui 0.0.25 → 0.0.26-dev

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.
Files changed (71) hide show
  1. package/index.d.ts +17 -0
  2. package/package.json +14 -8
  3. package/src/boot/register.ts +14 -0
  4. package/src/components/form/MAvatarViewer.vue +324 -0
  5. package/src/components/form/MAxios.vue +141 -0
  6. package/src/components/form/MBtn.vue +271 -93
  7. package/src/components/form/MCheckbox.vue +126 -0
  8. package/src/components/form/MColor.vue +122 -0
  9. package/src/components/form/MDate.vue +47 -0
  10. package/src/components/form/MEditor.vue +285 -0
  11. package/src/components/form/MEmail.vue +40 -0
  12. package/src/components/form/MField.vue +145 -0
  13. package/src/components/form/MFile.vue +212 -0
  14. package/src/components/form/MForm.vue +86 -0
  15. package/src/components/form/MHidden.vue +86 -0
  16. package/src/components/form/MHiddenInput.vue +55 -0
  17. package/src/components/form/MInput.vue +178 -0
  18. package/src/components/form/MInputFieldControl.vue +27 -0
  19. package/src/components/form/MInputLabel.vue +35 -0
  20. package/src/components/form/MMobile.vue +40 -0
  21. package/src/components/form/MPassword.vue +73 -0
  22. package/src/components/form/MPicker.vue +313 -0
  23. package/src/components/form/MRadio.vue +178 -0
  24. package/src/components/form/MSelect.vue +349 -0
  25. package/src/components/form/MTime.vue +45 -0
  26. package/src/components/form/index.ts +55 -0
  27. package/src/components/grid/MBlock.vue +39 -18
  28. package/src/components/grid/MCol.vue +11 -15
  29. package/src/components/grid/MColumn.vue +8 -0
  30. package/src/components/grid/MContainer.vue +22 -13
  31. package/src/components/grid/MHelpRow.vue +9 -12
  32. package/src/components/grid/MRow.vue +31 -10
  33. package/src/components/grid/index.ts +16 -0
  34. package/src/components/index.ts +12 -0
  35. package/src/components/transition/MFadeTransition.vue +27 -0
  36. package/src/components/transition/MFadeXTransition.vue +26 -0
  37. package/src/components/transition/MTransition.vue +41 -0
  38. package/src/components/transition/index.ts +13 -0
  39. package/src/components/typography/MTypingString.vue +8 -0
  40. package/src/components/typography/index.ts +11 -0
  41. package/src/composable/index.ts +12 -0
  42. package/src/composable/useBindInput.ts +209 -0
  43. package/src/composable/useError.ts +11 -0
  44. package/src/composable/useMyth.ts +302 -0
  45. package/src/composable/useValue.ts +12 -0
  46. package/src/index.common.js +19 -1
  47. package/src/index.esm.js +18 -3
  48. package/src/index.js +19 -0
  49. package/src/index.sass +8 -26
  50. package/src/index.ts +18 -4
  51. package/src/index.umd.js +17 -2
  52. package/src/style/m-container.sass +13 -0
  53. package/src/style/main.sass +42 -0
  54. package/src/types/api-helpers.d.ts +123 -0
  55. package/src/types/components.d.ts +769 -27
  56. package/src/types/dt.d.ts +144 -0
  57. package/src/types/index.d.ts +155 -1
  58. package/src/types/lodash.d.ts +26 -0
  59. package/src/types/quasar-helpers.d.ts +7 -0
  60. package/src/types/theme.d.ts +12 -0
  61. package/src/utils/Helpers.ts +293 -0
  62. package/src/utils/Str.ts +211 -0
  63. package/src/utils/index.ts +13 -0
  64. package/src/utils/myth.ts +95 -0
  65. package/src/utils/vee-rules.ts +32 -0
  66. package/src/utils/vue-plugin.ts +129 -0
  67. package/tsconfig.json +9 -13
  68. package/src/myth.ts +0 -30
  69. package/src/types/myth.ts +0 -42
  70. package/src/vue-plugin.ts +0 -41
  71. package/types.d.ts +0 -1
@@ -0,0 +1,302 @@
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
8
+
9
+ import lodash from 'lodash'
10
+ import { useI18n } from 'vue-i18n'
11
+ import type { RouteLocationNormalizedLoaded } from 'vue-router'
12
+ import { copyToClipboard, Dialog, extend, QDialogOptions, QNotifyCreateOptions, useQuasar } from 'quasar'
13
+ import { Helpers, myth, Str, veeRules } from '../utils'
14
+ import type { MDtColumn, MDtHeadersParameter, ParseHeaderOptions, Vue3MAlertMessage, Vue3MAlertMessageOptions, Vue3MConfirmMessage } from '../types'
15
+ import { computed } from 'vue'
16
+
17
+ export const useMyth = () => {
18
+ const { t, te } = useI18n({ useScope: 'global' })
19
+ const { props: pluginOptions } = myth
20
+ const q = useQuasar()
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
+ // @ts-ignore
23
+ const __ = (key: any, ...rest: unknown[]) => !key ? '' : te(`attributes.${key}`) ? t(`attributes.${key}`, ...rest) : te(key) ? t(key, ...rest) : key
24
+ const getPageTitle = (route: RouteLocationNormalizedLoaded, number?: number | string): string => {
25
+ number = number || 2
26
+ number = parseInt(number.toString())
27
+ const defaultValue = ''
28
+ // Not is route
29
+ // No page title
30
+ if (!route) {
31
+ return defaultValue
32
+ }
33
+
34
+ const routePath = route?.path?.toString() || null
35
+ const routeName = route?.name?.toString() || null
36
+
37
+ // Not is route
38
+ // No page title
39
+ if (!routePath || !routeName) {
40
+ return defaultValue
41
+ }
42
+
43
+ let lastRouteName = routeName.split('.').pop() || ''
44
+ if (lastRouteName === 'index') {
45
+ const s = routeName.split('.')
46
+ lastRouteName = s[s.length - 2] ?? lastRouteName
47
+ }
48
+ const pluralize = Str.pascalCase(lodash.pluralize(lastRouteName))
49
+ const singular = Str.pascalCase(lodash.singularize(lastRouteName))
50
+ const keys = lodash.filter(lodash.uniq([
51
+ `${lastRouteName}Page.title`,
52
+ `${lodash.camelCase(lastRouteName)}Page.title`,
53
+ `choice.${pluralize}`,
54
+ `choice.${singular}`,
55
+ `replace.${lastRouteName}_details`,
56
+ `replace.${lastRouteName}`,
57
+ pluralize,
58
+ lodash.snakeCase(pluralize),
59
+ singular,
60
+ lodash.snakeCase(singular)
61
+ ]))
62
+
63
+ let str: string | null = null
64
+ let k: string | any
65
+
66
+ if (te((k = `routes.${routeName}`)) && lodash.isString((str = t(k)))) {
67
+ return str
68
+ }
69
+
70
+ if (te((k = `routes.${routePath}`)) && lodash.isString((str = t(k)))) {
71
+ return str
72
+ }
73
+
74
+ for (const f in keys) {
75
+ if (!(k = keys[f])) {
76
+ continue
77
+ }
78
+ if (te && te(k) && lodash.isString(t(k))) {
79
+ if (lodash.startsWith(k, 'choice.')) {
80
+ const s = k.split('.')
81
+ const n = routeName.split('.')
82
+ if (s.length === 2 && n.length > 1) {
83
+ const model = n[n.length - 2]
84
+ const pluralizeModel = lodash.pluralize(lodash.pascalCase(model))
85
+ const _modelChoiceKey = `choice.${pluralizeModel}`
86
+ if (te(_modelChoiceKey)) {
87
+ const l = t(_modelChoiceKey, number as any)
88
+ const rep = lodash.singularize(n[n.length - 1]).toLocaleLowerCase()
89
+ const e = `replace.${rep}`
90
+ str = te(e) ? t(e, { name: l }) : null
91
+ } else {
92
+ const pop: string = k.split('.').pop() || ''
93
+ str = te(k) ? t(k, number as any, { [pop]: number }) : null
94
+ }
95
+ } else {
96
+ const pop: string = k.split('.').pop() || ''
97
+ str = te(k) ? t(k, number as any, { [pop]: number }) : null
98
+ }
99
+ } else {
100
+ const parents: string[] = routeName.split('.')
101
+ if (parents.length > 1) {
102
+ const e = `choice.${Str.pascalCase(lodash.pluralize(parents[parents.length - 2]))}`
103
+ str = te(e) ? t(k, { name: t(e, '1') }) : null
104
+ } else {
105
+ str = te(k) ? t(k, { name: '' }) : null
106
+ }
107
+ }
108
+ return str || defaultValue
109
+ }
110
+ }
111
+ return defaultValue
112
+ }
113
+ /**
114
+ * Custom transformer
115
+ * @param headers
116
+ * @param options
117
+ */
118
+ const parseHeaders = (headers: MDtHeadersParameter, options: ParseHeaderOptions = {}): MDtColumn[] => {
119
+ const defaultOptions: Partial<ParseHeaderOptions> = {
120
+ controlKey: 'control',
121
+ // controlStyle: 'max-width: 150px',
122
+ align: 'center'
123
+ // sortable: !0
124
+ }
125
+ const opts = extend<ParseHeaderOptions>(!0, defaultOptions, options)
126
+ let control: string | undefined = defaultOptions.controlKey
127
+ let controlStyle: string | undefined = defaultOptions.controlStyle
128
+ if (opts.controlKey) {
129
+ control = opts.controlKey
130
+ delete opts.controlKey
131
+ }
132
+ if (opts.controlStyle) {
133
+ controlStyle = opts.controlStyle
134
+ delete opts.controlStyle
135
+ }
136
+
137
+ const result: MDtColumn[] = []
138
+
139
+ headers.forEach((elm: string | MDtColumn | undefined) => {
140
+ if (typeof elm !== 'string' && !elm?.name) return elm
141
+ // Todo: will do this
142
+ let item: MDtColumn = typeof elm === 'string' ? {
143
+ name: elm as string,
144
+ label: elm as string,
145
+ field: elm as string
146
+ } : { ...elm }
147
+ item.name = item.name ?? ''
148
+ item.label = (item.label === undefined || item.label === null) ? item.name : item.label
149
+ item.field = (item.field === undefined || item.field === null) ? item.name : item.field
150
+ item = {
151
+ ...item,
152
+ name: Str.strBefore(Str.strBefore(item.name), 'ToString'),
153
+ label: (item.label !== undefined && item.label !== null) ? Str.strBefore(Str.strBefore(item.label), 'ToString') : item.label
154
+ }
155
+ const name = item.name
156
+ let k
157
+ if (te) {
158
+ if (te((k = `attributes.${item.label}`))) {
159
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
160
+ // @ts-ignore
161
+ item.label = t(k)
162
+ } else if (te((k = `attributes.${lodash.snakeCase(item.label)}`))) {
163
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
164
+ // @ts-ignore
165
+ item.label = t(k)
166
+ } else if (te((k = `attributes.${lodash.camelCase(item.label)}`))) {
167
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
168
+ // @ts-ignore
169
+ item.label = t(k)
170
+ } else if (te((k = `attributes.${Str.pascalCase(item.label)}`))) {
171
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
172
+ // @ts-ignore
173
+ item.label = t(k)
174
+ } else if (te((k = `choice.${lodash.pluralize(Str.pascalCase(item.label))}`))) {
175
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
176
+ // @ts-ignore
177
+ item.label = t(k, 2)
178
+ } else if (te((k = item.label))) {
179
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
180
+ // @ts-ignore
181
+ item.label = t(k)
182
+ }
183
+ }
184
+
185
+ if (name === control) {
186
+ if (controlStyle && !item.style) {
187
+ item.style = controlStyle + (item.style ? ` ${item.style}` : '')
188
+ }
189
+ item.headerClasses = (item.headerClasses ? item.headerClasses : '') + ' m--control-header'
190
+ item.headerClasses = item.headerClasses.trim()
191
+ item.sortable = !1
192
+ if (!item.align) {
193
+ item.align = 'right'
194
+ }
195
+ opts.classes = opts.classes || ''
196
+ if (typeof opts.classes === 'function') {
197
+ opts.classes = opts.classes()
198
+ }
199
+ opts.classes += ' m--control-cell'
200
+ opts.classes = opts.classes.trim()
201
+ }
202
+
203
+ item = { ...opts, ...item }
204
+
205
+ if (item.sortable === undefined && (options.noSort ?? []).length > 0 && options.noSort?.includes(item.name)) {
206
+ item.sortable = !1
207
+ } else if (item.sortable === undefined) {
208
+ item.sortable = !0
209
+ }
210
+ result.push(item)
211
+ })
212
+ return lodash.uniqBy(result, (e: MDtColumn) => e.name)
213
+ }
214
+ /**
215
+ * Copy text
216
+ * @param text
217
+ */
218
+ const copyText = async (text: string | any) => copyToClipboard(text)
219
+
220
+ const quasarNotifyOptions = (opts: QNotifyCreateOptions | string): QNotifyCreateOptions => {
221
+ return {
222
+ badgeColor: 'primary',
223
+ progress: !0,
224
+ ...pluginOptions.value.notify as any,
225
+ message: typeof opts === 'string' ? opts : opts.message,
226
+ ...(typeof opts !== 'string' ? opts : {})
227
+ }
228
+ }
229
+ const alertMessage = (opts: Vue3MAlertMessageOptions): Vue3MAlertMessage => {
230
+ return q.notify(quasarNotifyOptions(opts))
231
+ }
232
+ const alertSuccess = (message: string) => {
233
+ return alertMessage({ type: 'positive', message })
234
+ }
235
+ const alertError = (message: string) => {
236
+ return alertMessage({ type: 'negative', message })
237
+ }
238
+ const confirmMessage = (message?: string, title?: string, opts?: QDialogOptions): Vue3MConfirmMessage => {
239
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
240
+ // @ts-ignore
241
+ title = title || t('messages.are_you_sure') || ''
242
+ message = message || ''
243
+ opts = opts || {}
244
+ const buttonsProps = {
245
+ ...(pluginOptions.value.btn || {})
246
+ // ...(options.value.confirmDialogOptions?.buttons || {})
247
+ }
248
+ // const okProps = options.value.confirmDialogOptions?.okProps || {}
249
+ const okProps: any = {}
250
+ // const cancelProps = options.value.confirmDialogOptions?.cancelProps || {}
251
+ const cancelProps: any = {}
252
+ // const dialogProps = options.value.confirmDialog || {} as any
253
+ const dialogProps: any = {}
254
+ dialogProps.transitionShow = dialogProps.transitionShow || 'jump-down'
255
+ dialogProps.transitionHide = dialogProps.transitionHide || 'jump-up'
256
+ dialogProps.class = ('m--confirm ') + (dialogProps.class || '')
257
+ return Dialog.create({
258
+ title,
259
+ message,
260
+ focus: 'none',
261
+ cancel: {
262
+ color: cancelProps.color || 'positive',
263
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
264
+ // @ts-ignore
265
+ label: t(cancelProps?.label || 'no'),
266
+ ...buttonsProps as any,
267
+ flat: !0,
268
+ unelevated: !0,
269
+ ...cancelProps as any
270
+ },
271
+ ok: {
272
+ color: okProps.color || 'negative',
273
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
274
+ // @ts-ignore
275
+ label: t(okProps?.label || 'yes'),
276
+ ...buttonsProps as any,
277
+ flat: !0,
278
+ unelevated: !0,
279
+ ...okProps as any
280
+ },
281
+ persistent: !0,
282
+ ...dialogProps as any,
283
+ ...opts as any
284
+ })
285
+ }
286
+ const api = computed(() => myth.api.value)
287
+ return {
288
+ api,
289
+ __,
290
+ getPageTitle,
291
+ parseHeaders,
292
+ copyText,
293
+ quasarNotifyOptions,
294
+ alertMessage,
295
+ alertSuccess,
296
+ alertError,
297
+ confirmMessage,
298
+ ...Helpers,
299
+ ...Str,
300
+ veeRules
301
+ }
302
+ }
@@ -0,0 +1,12 @@
1
+ import { computed, MaybeRefOrGetter } from 'vue'
2
+ import { useFieldValue, useSetFieldValue } from 'vee-validate'
3
+
4
+ export const useValue = <T = any> (name: MaybeRefOrGetter<string>) => {
5
+ const [value, setValue] = [useFieldValue<T>(name), useSetFieldValue<T>(name)]
6
+ const field = computed<T>({
7
+ get: () => value.value,
8
+ set: (v: T) => setValue(v)
9
+ })
10
+
11
+ return { field, value, setValue }
12
+ }
@@ -1 +1,19 @@
1
- export * from './vue-plugin'
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
8
+
9
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.esm.js CHANGED
@@ -1,4 +1,19 @@
1
- import * as VuePlugin from './vue-plugin'
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
2
8
 
3
- export * from './vue-plugin'
4
- export default VuePlugin
9
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
8
+
9
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.sass CHANGED
@@ -1,27 +1,9 @@
1
- @import 'quasar/src/css/variables.sass'
2
- $m--container-padding: $space-base !default
3
- $m--container-fluid-width: 1440px !default
4
- $m--row-margin-top: $m--container-padding !default
5
-
6
- .flex-break
7
- flex: 1 0 100% !important
8
-
9
- .row
10
- .flex-break
11
- height: 0 !important
12
-
13
- .column
14
- .flex-break
15
- width: 0 !important
1
+ // MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
2
+ // Email: mythpe@gmail.com
3
+ // Mobile: +966590470092
4
+ // Website: https://www.4myth.com
5
+ // Github: https://github.com/mythpe
16
6
 
17
- .m--container
18
- &__dense
19
- padding: 0 !important
20
-
21
- &__fluid
22
- max-width: $m--container-fluid-width
23
- margin-left: auto
24
- margin-right: auto
25
-
26
- .m--row + .m--row
27
- margin-top: $m--row-margin-top
7
+ @import 'quasar/src/css/variables.sass'
8
+ @import './style/main.sass'
9
+ @import './style/m-container'
package/src/index.ts CHANGED
@@ -1,5 +1,19 @@
1
- export * from './vue-plugin'
2
- export * from './types'
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
3
8
 
4
- import * as VuePlugin from './vue-plugin'
5
- export default VuePlugin
9
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.umd.js CHANGED
@@ -1,2 +1,17 @@
1
- import * as VuePlugin from './vue-plugin'
2
- export default VuePlugin
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
8
+
9
+ import * as components from './components'
10
+ import * as composable from './composable'
11
+ import * as utils from './utils'
12
+
13
+ export default {
14
+ ...components,
15
+ ...composable,
16
+ ...utils
17
+ }
@@ -0,0 +1,13 @@
1
+ @use "quasar/src/css/variables" as q
2
+
3
+ $m--container-padding: q.$space-base !default
4
+ $m--container-fluid-width: 1440px !default
5
+
6
+ .m--container
7
+ &__dense
8
+ padding: 0
9
+
10
+ &__fluid
11
+ max-width: $m--container-fluid-width
12
+ margin-left: auto
13
+ margin-right: auto
@@ -0,0 +1,42 @@
1
+ // Flex.
2
+ .flex-break
3
+ flex: 1 0 100% !important
4
+ padding: 0 !important
5
+ margin: 0 !important
6
+
7
+ .row
8
+ .flex-break
9
+ height: 0 !important
10
+
11
+ .column
12
+ .flex-break
13
+ width: 0 !important
14
+
15
+ $m--row-margin-top: 1rem !default
16
+
17
+ .m--row + .m--row
18
+ margin-top: $m--row-margin-top
19
+
20
+
21
+ // Directions.
22
+ .ltr
23
+ direction: ltr #{"/* rtl:ignore */"}
24
+
25
+ .rtl
26
+ direction: rtl #{"/* rtl:ignore */"}
27
+
28
+ // Colors.
29
+ $text-light-color: #111111 !default
30
+ $text-dark-color: #ffffff !default
31
+
32
+ .body--light
33
+ color: $text-light-color
34
+
35
+ .text-color
36
+ color: $text-light-color
37
+
38
+ .body--dark
39
+ color: $text-dark-color
40
+
41
+ .text-color
42
+ color: $text-dark-color
@@ -0,0 +1,123 @@
1
+ /*
2
+ * MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ * Email: mythpe@gmail.com
4
+ * Mobile: +966590470092
5
+ * Website: https://www.4myth.com
6
+ * Github: https://github.com/mythpe
7
+ */
8
+
9
+ import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
10
+ import { ApiServiceParams } from './dt'
11
+
12
+ // Axios
13
+ type Generic = Record<any, any>;
14
+
15
+ export type ApiMetaInterface = {
16
+ // server current page
17
+ current_page: number | null;
18
+ // server last page
19
+ last_page: number | null;
20
+ // server total items
21
+ total: number | null;
22
+ [K: any]: any;
23
+ };
24
+ export type ApiErrorInterface = Record<string, string[]>;
25
+ export type ApiErrorsInterface = ApiErrorInterface[];
26
+
27
+ export type ApiModel<T extends Generic = Generic> = {
28
+ id: string | number;
29
+ value: string | number;
30
+ label?: string;
31
+ [K: keyof T]: any;
32
+ [s: string]: any;
33
+ };
34
+
35
+ type ResponseAsMain = Generic & {
36
+ success: boolean;
37
+ errors: ApiErrorsInterface;
38
+ message: string;
39
+ }
40
+
41
+ type ResponseAsModel<T extends Generic = Generic> = ResponseAsMain & {
42
+ data: ApiModel<T>
43
+ }
44
+ type ResponseAsList<T extends Generic = Generic> = ResponseAsMain & {
45
+ data: ResponseAsModel<T>[];
46
+ links: {
47
+ first: string;
48
+ last: string;
49
+ prev: string | null;
50
+ next: string | null;
51
+ }
52
+ meta: ApiMetaInterface;
53
+ }
54
+ type ResponseDataType = ResponseAsList | ResponseAsModel | Generic;
55
+ export type ApiFulfilledResponse = AxiosResponse<ResponseDataType>
56
+ export type ApiErrorResponse = AxiosError<ResponseDataType>;
57
+
58
+ export type ApiInterface = ApiFulfilledResponse & {
59
+ _data: ResponseDataType;
60
+ _message: ResponseAsMain['message'];
61
+ _meta: ResponseAsList['meta'];
62
+ _success: ResponseAsMain['success'];
63
+ _errors: ResponseAsMain['errors'];
64
+ }
65
+
66
+ // Axios
67
+
68
+ export type DownloadFromResponse = {
69
+ status: boolean;
70
+ response: AxiosResponse;
71
+ }
72
+
73
+ export type DownloadFromResponseCode = 'no_response' | 'no_file_name' | 'no_file_url' | 'unknown' | string
74
+ export type DownloadFromResponseError = {
75
+ code: DownloadFromResponseCode
76
+ status: boolean;
77
+ }
78
+
79
+ export type UrlType = string | number | any;
80
+ export type ParamsType = Record<string, any> | FormData | object
81
+ export type ConfigType = AxiosRequestConfig<ApiInterface> & Partial<{
82
+ params: Partial<ApiServiceParams> & Generic
83
+ }>
84
+
85
+ export type HelpersStubSchema = {
86
+ index (config?: ConfigType): Promise<ApiInterface>;
87
+
88
+ staticIndex (config?: ConfigType): Promise<ApiInterface>;
89
+
90
+ export (data?: ParamsType, config?: AxiosRequestConfig): Promise<ApiInterface>;
91
+
92
+ store (data?: ParamsType, config?: AxiosRequestConfig): Promise<ApiInterface>;
93
+
94
+ show (id: UrlType, config?: AxiosRequestConfig): Promise<ApiInterface>;
95
+
96
+ staticShow (id: UrlType, config?: AxiosRequestConfig): Promise<ApiInterface>;
97
+
98
+ update (id: UrlType, data?: ParamsType, config?: AxiosRequestConfig): Promise<ApiInterface>;
99
+
100
+ destroy (id: UrlType, config?: AxiosRequestConfig): Promise<ApiInterface>;
101
+
102
+ destroyAll (ids?: UrlType[], config?: AxiosRequestConfig): Promise<ApiInterface>;
103
+
104
+ getUploadAttachmentsUrl (id: UrlType): string;
105
+
106
+ uploadAttachments (id: UrlType, data: Generic, config?: AxiosRequestConfig): Promise<ApiInterface>;
107
+
108
+ deleteAttachment (id: UrlType, fileId: string | number, config?: AxiosRequestConfig): Promise<ApiInterface>;
109
+
110
+ updateAttachment (id: UrlType, fileId: string | number, data: Record<string, any>, config?: AxiosRequestConfig): Promise<ApiInterface>;
111
+
112
+ } | (HelpersStubSchema & Record<string, HelpersStubSchema | ((...args: any) => Promise<ApiInterface>)>)
113
+
114
+ export type StubSchemaContext = HelpersStubSchema
115
+ & Record<string, ((...args: any) => Promise<ApiInterface>)>
116
+ & Record<string, Record<string, ((...args: any) => Promise<ApiInterface>)>>
117
+ & Record<string, Record<string, Record<string, ((...args: any) => Promise<ApiInterface>)>>>
118
+
119
+ export type StubSchema = StubSchemaContext
120
+ & ((...args: any) => Promise<ApiInterface>)
121
+ & string
122
+ & Record<string, StubSchemaContext>
123
+ export type MythApiServicesSchema = { [key: string | symbol | number]: StubSchema }