bt-core-app 1.4.2 → 1.4.4
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/dist/index.d.ts +1273 -41
- package/package.json +9 -2
- package/dist/composables/actions-tracker.d.ts +0 -19
- package/dist/composables/actions.d.ts +0 -79
- package/dist/composables/api.d.ts +0 -86
- package/dist/composables/auth.d.ts +0 -70
- package/dist/composables/cosmetics.d.ts +0 -38
- package/dist/composables/csv.d.ts +0 -20
- package/dist/composables/dates.d.ts +0 -15
- package/dist/composables/demo.d.ts +0 -9
- package/dist/composables/dialogs.d.ts +0 -75
- package/dist/composables/document-meta.d.ts +0 -11
- package/dist/composables/draggable.d.ts +0 -56
- package/dist/composables/filters.d.ts +0 -11
- package/dist/composables/forage.d.ts +0 -7
- package/dist/composables/helpers.d.ts +0 -100
- package/dist/composables/id.d.ts +0 -1
- package/dist/composables/list.d.ts +0 -211
- package/dist/composables/navigation.d.ts +0 -89
- package/dist/composables/presets.d.ts +0 -8
- package/dist/composables/pwa.d.ts +0 -14
- package/dist/composables/resizable.d.ts +0 -35
- package/dist/composables/rules.d.ts +0 -7
- package/dist/composables/stores.d.ts +0 -111
- package/dist/composables/track.d.ts +0 -12
- package/dist/composables/urls.d.ts +0 -22
- package/dist/core.d.ts +0 -19
- package/dist/types.d.ts +0 -13
- package/dist/useApi.d.ts +0 -0
- package/src/assets/vue.svg +0 -1
- package/src/components/BT-Btn.vue +0 -41
- package/src/components/BT-Col.vue +0 -36
- package/src/components/BT-Field-Checkbox.vue +0 -70
- package/src/components/BT-Field-Date.vue +0 -108
- package/src/components/BT-Field-Entity.vue +0 -48
- package/src/components/BT-Field-Select.vue +0 -67
- package/src/components/BT-Field-String.vue +0 -78
- package/src/components/BT-Field-Switch.vue +0 -68
- package/src/components/BT-Field-Tags.vue +0 -66
- package/src/components/BT-Field-Textarea.vue +0 -67
- package/src/components/BT-Field-Trigger.vue +0 -315
- package/src/components/BT-Header-Option.vue +0 -39
- package/src/components/BT-Json.vue +0 -67
- package/src/components/BT-Nav-Menu-Item.vue +0 -60
- package/src/components/BT-Nav-Sidebar.vue +0 -78
- package/src/components/BT-Select-List-Box.vue +0 -258
- package/src/components/BT-Select.vue +0 -46
- package/src/components/BT-Snack.vue +0 -31
- package/src/components/BT-Span.vue +0 -21
- package/src/components/Dialog-Confirm.vue +0 -47
- package/src/components/Dialog-Select-Date.vue +0 -89
- package/src/components/Dialog-Select.vue +0 -140
- package/src/components/Dialog-Text.vue +0 -59
- package/src/composables/actions-tracker.ts +0 -99
- package/src/composables/actions.ts +0 -354
- package/src/composables/api.ts +0 -479
- package/src/composables/auth.ts +0 -452
- package/src/composables/cosmetics.ts +0 -177
- package/src/composables/csv.ts +0 -198
- package/src/composables/dates.ts +0 -86
- package/src/composables/demo.ts +0 -33
- package/src/composables/dialogs.ts +0 -114
- package/src/composables/document-meta.ts +0 -44
- package/src/composables/draggable.ts +0 -189
- package/src/composables/filters.ts +0 -264
- package/src/composables/forage.ts +0 -49
- package/src/composables/helpers.ts +0 -647
- package/src/composables/id.ts +0 -20
- package/src/composables/list.ts +0 -604
- package/src/composables/navigation.ts +0 -222
- package/src/composables/presets.ts +0 -28
- package/src/composables/pwa.ts +0 -97
- package/src/composables/resizable.ts +0 -382
- package/src/composables/rules.ts +0 -40
- package/src/composables/stores.ts +0 -818
- package/src/composables/track.ts +0 -55
- package/src/composables/urls.ts +0 -66
- package/src/core.ts +0 -113
- package/src/index.ts +0 -48
- package/src/types.ts +0 -17
- package/src/useApi.ts +0 -68
- package/src/vite-env.d.ts +0 -1
- package/test/api.test.ts +0 -84
- package/test/auth.test.ts +0 -74
- package/test/forage.test.ts +0 -31
- package/test/helpers.test.ts +0 -231
- package/test/navigation.test.ts +0 -99
- package/test/stores-last-update.test.ts +0 -138
- package/test/stores-session.test.ts +0 -118
- package/test/track.test.ts +0 -29
- package/test/urls.test.ts +0 -42
- package/test/utils.ts +0 -15
- package/tsconfig.json +0 -28
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -45
package/src/composables/track.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type MaybeRefOrGetter, type Ref, ref, toRef, toValue, watch } from "vue";
|
|
2
|
-
import { copyDeep } from '../composables/helpers';
|
|
3
|
-
|
|
4
|
-
export interface UseTrackerOptions {
|
|
5
|
-
propsToIgnore?: string[]
|
|
6
|
-
propsToTrack?: string[],
|
|
7
|
-
useTracker?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useTracker(data: MaybeRefOrGetter<any>, options?: UseTrackerOptions) { //propsToIgnore, propsToTrack) {
|
|
11
|
-
const isChanged = ref(false);
|
|
12
|
-
const asyncItem: Ref<any> = toRef(data);
|
|
13
|
-
let originalJSON = createJSON(toValue(data));
|
|
14
|
-
|
|
15
|
-
if (options?.useTracker !== false) {
|
|
16
|
-
watch(asyncItem, (v) => {
|
|
17
|
-
isChanged.value = createJSON(v) != originalJSON;
|
|
18
|
-
}, { deep: true })
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function createJSON(dataItem: any) {
|
|
22
|
-
const copy = copyDeep(dataItem);
|
|
23
|
-
|
|
24
|
-
if (options != null) {
|
|
25
|
-
if (options.propsToIgnore != null) {
|
|
26
|
-
//delete from copy
|
|
27
|
-
options.propsToIgnore.forEach(k => {
|
|
28
|
-
delete copy[k];
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
else if (options.propsToTrack != null) {
|
|
32
|
-
//only keep these
|
|
33
|
-
const dataProps = Object.keys(dataItem)
|
|
34
|
-
dataProps.forEach(k => {
|
|
35
|
-
if (!options!.propsToTrack!.some(x => x == k)) {
|
|
36
|
-
delete copy[k]
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return JSON.stringify(copy);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function restart() {
|
|
46
|
-
originalJSON = createJSON(toValue(asyncItem));
|
|
47
|
-
isChanged.value = false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
asyncItem,
|
|
52
|
-
isChanged,
|
|
53
|
-
restartTracker: restart
|
|
54
|
-
}
|
|
55
|
-
}
|
package/src/composables/urls.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export type Environment = 'production' | 'staging' | 'development'
|
|
2
|
-
|
|
3
|
-
export interface CreateUrlOptions {
|
|
4
|
-
production: UrlSet
|
|
5
|
-
staging: UrlSet
|
|
6
|
-
development: UrlSet
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface UrlSet {
|
|
10
|
-
auth?: string
|
|
11
|
-
data?: string
|
|
12
|
-
localDbName?: string
|
|
13
|
-
other?: any
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let current: CreateUrlOptions
|
|
17
|
-
|
|
18
|
-
export function useDbName(): string {
|
|
19
|
-
const env = import.meta.env.NODE_ENV as Environment
|
|
20
|
-
|
|
21
|
-
if (current == null)
|
|
22
|
-
return env as string
|
|
23
|
-
|
|
24
|
-
const urlSet = current[env] ?? current['development']
|
|
25
|
-
return urlSet.localDbName ?? env as string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useAuthUrl(): string {
|
|
29
|
-
const env = import.meta.env.NODE_ENV as Environment
|
|
30
|
-
|
|
31
|
-
if (current == null)
|
|
32
|
-
return ''
|
|
33
|
-
|
|
34
|
-
const urlSet = current[env] ?? current['development']
|
|
35
|
-
return urlSet.auth ?? ''
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param microservice
|
|
41
|
-
* @returns
|
|
42
|
-
*/
|
|
43
|
-
export function useDataUrl(microservice?: string): string {
|
|
44
|
-
const env = import.meta.env.NODE_ENV as Environment
|
|
45
|
-
|
|
46
|
-
if (current == null)
|
|
47
|
-
return ''
|
|
48
|
-
|
|
49
|
-
const urlSet = current[env] ?? current['development']
|
|
50
|
-
|
|
51
|
-
if (microservice == null)
|
|
52
|
-
return urlSet.data ?? ''
|
|
53
|
-
|
|
54
|
-
let other = urlSet.other[microservice]
|
|
55
|
-
|
|
56
|
-
return other ?? urlSet.data ?? ''
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function useUrls(): CreateUrlOptions {
|
|
60
|
-
return current
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function createUrl(options: CreateUrlOptions) {
|
|
64
|
-
current = options
|
|
65
|
-
return current
|
|
66
|
-
}
|
package/src/core.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { App } from 'vue'
|
|
2
|
-
import { createApi } from './composables/api'
|
|
3
|
-
import { CreateAuthOptions, createAuth, type AuthSubscription } from './composables/auth'
|
|
4
|
-
import { BaseCosmeticTheme, createCosmetics, UseCosmeticsOptions } from './composables/cosmetics'
|
|
5
|
-
import { createDates } from './composables/dates'
|
|
6
|
-
import { createDemo } from './composables/demo'
|
|
7
|
-
import { createFilters } from './composables/filters'
|
|
8
|
-
import { createNavigation, type NavigationItem } from './composables/navigation'
|
|
9
|
-
import { createPresets } from './composables/presets'
|
|
10
|
-
import { createPWA } from './composables/pwa'
|
|
11
|
-
import { createStoreBuilder } from './composables/stores'
|
|
12
|
-
import { CreateUrlOptions, createUrl } from './composables/urls'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// import BTBtn from './components/BT-Btn.vue'
|
|
16
|
-
// import BTCol from './components/BT-Col.vue'
|
|
17
|
-
// import BTFieldCheckbox from './components/BT-Field-Checkbox.vue'
|
|
18
|
-
// import BTFieldDate from './components/BT-Field-Date.vue'
|
|
19
|
-
// import BTFieldEntity from './components/BT-Field-Entity.vue'
|
|
20
|
-
// import BTFieldSelect from './components/BT-Field-Select.vue'
|
|
21
|
-
// import BTFieldString from './components/BT-Field-String.vue'
|
|
22
|
-
// import BTFieldSwitch from './components/BT-Field-Switch.vue'
|
|
23
|
-
// import BTFieldTags from './components/BT-Field-Tags.vue'
|
|
24
|
-
// import BTFieldTextarea from './components/BT-Field-Textarea.vue'
|
|
25
|
-
// import BTFieldTrigger from './components/BT-Field-Trigger.vue'
|
|
26
|
-
// import BTHeaderOption from './components/BT-Header-Option.vue'
|
|
27
|
-
// import BTJson from './components/BT-Json.vue'
|
|
28
|
-
// import BTSelectListBox from './components/BT-Select-List-Box.vue'
|
|
29
|
-
// import BTSelect from './components/BT-Select.vue'
|
|
30
|
-
// import BTSnack from './components/BT-Snack.vue'
|
|
31
|
-
// import BTSpan from './components/BT-Span.vue'
|
|
32
|
-
|
|
33
|
-
export interface CoreApp {
|
|
34
|
-
install(app: App) : void
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CreateCoreOptions extends UseCosmeticsOptions<BaseCosmeticTheme> {
|
|
38
|
-
auth: CreateAuthOptions
|
|
39
|
-
defaultCacheExpiryHours?: number
|
|
40
|
-
// getAuthQuery: (redirectPath?: string, state?: string) => string
|
|
41
|
-
navItems?: NavigationItem[]
|
|
42
|
-
presets: any
|
|
43
|
-
// setCredentials?: (state: RemovableRef<any>, payload: any) => void
|
|
44
|
-
/**suboptions */
|
|
45
|
-
subscriptionOptions?: AuthSubscription[]
|
|
46
|
-
urls: CreateUrlOptions
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function createCore(options: CreateCoreOptions): CoreApp {
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
install() { //app: App) {
|
|
53
|
-
|
|
54
|
-
//register components
|
|
55
|
-
// app.component('bt-btn', BTBtn)
|
|
56
|
-
// app.component('bt-col', BTCol)
|
|
57
|
-
// app.component('bt-field-checkbox', BTFieldCheckbox)
|
|
58
|
-
// app.component('bt-field-date', BTFieldDate)
|
|
59
|
-
// app.component('bt-field-entity', BTFieldEntity)
|
|
60
|
-
// app.component('bt-field-select', BTFieldSelect)
|
|
61
|
-
// app.component('bt-field-string', BTFieldString)
|
|
62
|
-
// app.component('bt-field-switch', BTFieldSwitch)
|
|
63
|
-
// app.component('bt-field-tags', BTFieldTags)
|
|
64
|
-
// app.component('bt-field-text-area', BTFieldTextarea)
|
|
65
|
-
// app.component('bt-field-trigger', BTFieldTrigger)
|
|
66
|
-
// app.component('bt-header-option', BTHeaderOption)
|
|
67
|
-
// app.component('bt-json', BTJson)
|
|
68
|
-
// app.component('bt-select-list-box', BTSelectListBox)
|
|
69
|
-
// app.component('bt-select', BTSelect)
|
|
70
|
-
// app.component('bt-snack', BTSnack)
|
|
71
|
-
// app.component('bt-span', BTSpan)
|
|
72
|
-
|
|
73
|
-
//define globals
|
|
74
|
-
// app.config.globalProperties.$btcore = core
|
|
75
|
-
|
|
76
|
-
createCosmetics(options)
|
|
77
|
-
|
|
78
|
-
const demo = createDemo()
|
|
79
|
-
|
|
80
|
-
const navigation = createNavigation(options)
|
|
81
|
-
|
|
82
|
-
createPresets(options)
|
|
83
|
-
|
|
84
|
-
options.auth.demo ??= demo
|
|
85
|
-
options.auth.getAuthItem = navigation.findItem
|
|
86
|
-
|
|
87
|
-
const auth = createAuth(options.auth)
|
|
88
|
-
|
|
89
|
-
const api = createApi({
|
|
90
|
-
auth: auth,
|
|
91
|
-
findPath: navigation.findPath,
|
|
92
|
-
useBearerToken: true
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
const dates = createDates({
|
|
96
|
-
getTimeZone: auth.getTimeZone
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
createFilters({
|
|
100
|
-
dates: dates
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
createPWA()
|
|
104
|
-
|
|
105
|
-
createStoreBuilder({
|
|
106
|
-
api,
|
|
107
|
-
auth
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
createUrl(options.urls)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export { useActionsTracker } from './composables/actions-tracker'
|
|
2
|
-
export type { BTActions, GetOptions, DeleteOptions, RestoreOptions, SaveOptions, ApiActionOptions, UseActionsOptions } from './composables/actions'
|
|
3
|
-
export { useActions } from './composables/actions'
|
|
4
|
-
export type { BTApi, UseApiOptions, PathOptions, QueryParams } from './composables/api'
|
|
5
|
-
export { createApi, useApi } from './composables/api'
|
|
6
|
-
export type { BTAuth, AuthItem, AuthSubscription, BaseAuthCredentials, CreateAuthOptions } from './composables/auth'
|
|
7
|
-
export { createAuth, useAuth } from './composables/auth'
|
|
8
|
-
export type { BTCosmetics, BaseCosmeticTheme, UseCosmeticsOptions } from './composables/cosmetics'
|
|
9
|
-
export { createCosmetics, useCosmetics } from './composables/cosmetics'
|
|
10
|
-
export * from './composables/csv'
|
|
11
|
-
export type { BTDates, CreateDatesOptions } from './composables/dates'
|
|
12
|
-
export { createDates, useDates } from './composables/dates'
|
|
13
|
-
export type { BTDemo } from './composables/demo'
|
|
14
|
-
export { createDemo, useDemo } from './composables/demo'
|
|
15
|
-
// export * from './composables/dialogs'
|
|
16
|
-
export type { BTDocumentMeta, UseDocumentMetaOptions } from './composables/document-meta'
|
|
17
|
-
export { useDocumentMeta } from './composables/document-meta'
|
|
18
|
-
export * from './composables/draggable'
|
|
19
|
-
export type { BTFilters, UseFiltersOptions } from './composables/filters'
|
|
20
|
-
export { createFilters, useFilters } from './composables/filters'
|
|
21
|
-
export { useLocalDb, useLocalCache } from './composables/forage'
|
|
22
|
-
export * from './composables/helpers'
|
|
23
|
-
export { useId } from './composables/id'
|
|
24
|
-
export type { TableColumn, CustomFilterParam, ListEvents, ListProps, GroupedHeaderOption, UseListOptions } from './composables/list'
|
|
25
|
-
export { useList } from './composables/list'
|
|
26
|
-
export type { BTNavigation, ExternalParty, ExternalNavigation, NavigationItem, UseNavigationOptions } from './composables/navigation'
|
|
27
|
-
export { createNavigation, useNavigation } from './composables/navigation'
|
|
28
|
-
export type { BTPresets, CreatePresetsOptions } from './composables/presets'
|
|
29
|
-
export { createPresets, usePresets } from './composables/presets'
|
|
30
|
-
export type { BTPWA, SWEvent } from './composables/pwa'
|
|
31
|
-
export { createPWA, usePWA } from './composables/pwa'
|
|
32
|
-
export * from './composables/resizable'
|
|
33
|
-
export type { UseRulesOptions } from './composables/rules'
|
|
34
|
-
export { useRules } from './composables/rules'
|
|
35
|
-
export type { BTStoreDefinition, BTStore, StoreMode, StorageMode, LocalMeta, LocallyStoredItem, StoreGetAllReturn, StoreGetReturn, UseStoreOptions, CreateStoreBuilderOptions, CreateStoreOptions } from './composables/stores'
|
|
36
|
-
export { createStoreBuilder, createStoreDefinition, useStore, useStoreDefinition, createWholeLastUpdateStoreDefinition, createSessionStoreDefinition } from './composables/stores'
|
|
37
|
-
export type { UseTrackerOptions } from './composables/track'
|
|
38
|
-
export { useTracker } from './composables/track'
|
|
39
|
-
export { createUrl, useUrls, useAuthUrl, useDbName, useDataUrl } from './composables/urls'
|
|
40
|
-
export * from './types'
|
|
41
|
-
export type { CoreApp, CreateCoreOptions } from './core'
|
|
42
|
-
export { createCore } from './core'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// import BTNavMenuItem from './components/BT-Nav-Menu-Item.vue'
|
|
46
|
-
// import BTNavSidebar from './components/BT-Nav-Sidebar.vue'
|
|
47
|
-
|
|
48
|
-
// export { BTNavMenuItem, BTNavSidebar }
|
package/src/types.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Inline: merges toolbars | much more compact | hides navigation
|
|
3
|
-
Page: shows navigation and page settings
|
|
4
|
-
Blade: shows blade minimize, maximize, close, and pins as a column
|
|
5
|
-
Free-moving: show blade as draggable and resizable with minimize, maximize, and close and pinning
|
|
6
|
-
*/
|
|
7
|
-
export type BladeVariant = 'page' | 'blade' | 'freestyle' | 'inline' | 'pane'
|
|
8
|
-
|
|
9
|
-
export type BladeDensity = 'default' | 'comfortable' | 'compact'
|
|
10
|
-
|
|
11
|
-
export type BladeMode = 'new' | 'view' | 'edit'
|
|
12
|
-
|
|
13
|
-
export type FieldVariant = 'underlined' | 'outlined' | 'filled' | 'solo' | 'solo-inverted' | 'solo-filled' | 'plain'
|
|
14
|
-
|
|
15
|
-
export interface BaseModel {
|
|
16
|
-
id?: string
|
|
17
|
-
}
|
package/src/useApi.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// import { inject } from 'vue'
|
|
2
|
-
// // import { BTActions } from './composables/actions'
|
|
3
|
-
// import { BTAuth } from './composables/auth'
|
|
4
|
-
// import { BTApi } from './composables/api'
|
|
5
|
-
// import { BTCosmetics } from './composables/cosmetics'
|
|
6
|
-
// import { BTDates } from './composables/dates'
|
|
7
|
-
// import { BTDemo } from './composables/demo'
|
|
8
|
-
// import { BTFilters } from './composables/filters'
|
|
9
|
-
// import { BTNavigation } from './composables/navigation'
|
|
10
|
-
// import { BTPresets } from './composables/presets'
|
|
11
|
-
// import { BTPWA } from './composables/pwa'
|
|
12
|
-
// import { BTStore, CreateStoreOptions } from './composables/stores'
|
|
13
|
-
|
|
14
|
-
// // /**returns a new instance */
|
|
15
|
-
// // export function useActions(): BTActions {
|
|
16
|
-
// // return inject('bt-actions')!
|
|
17
|
-
// // }
|
|
18
|
-
|
|
19
|
-
// /**returns a singleton */
|
|
20
|
-
// export function useApi(): BTApi {
|
|
21
|
-
// return inject('bt-api')!
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
// /**returns a singleton */
|
|
25
|
-
// export function useAuth(): BTAuth {
|
|
26
|
-
// return inject('bt-auth')!
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
// /**returns a singleton */
|
|
30
|
-
// export function useCosmetics(): BTCosmetics {
|
|
31
|
-
// return inject('bt-cosmetics')!
|
|
32
|
-
// }
|
|
33
|
-
|
|
34
|
-
// /**returns a singleton */
|
|
35
|
-
// export function useDates(): BTDates {
|
|
36
|
-
// return inject('bt-dates')!
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
|
-
// /**returns a singleton */
|
|
40
|
-
// export function useDemo(): BTDemo {
|
|
41
|
-
// return inject('bt-demo')!
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
// /**returns a singleton */
|
|
45
|
-
// export function useFilters(): BTFilters {
|
|
46
|
-
// return inject('bt-filters')!
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
|
-
// /**returns a singleton */
|
|
50
|
-
// export function useNavigation(): BTNavigation {
|
|
51
|
-
// return inject('bt-navigation')!
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// /**returns a singleton */
|
|
55
|
-
// export function usePresets(preset?: string): any {
|
|
56
|
-
// const p = inject('bt-presets')! as BTPresets
|
|
57
|
-
// return p.usePresets(preset)
|
|
58
|
-
// }
|
|
59
|
-
|
|
60
|
-
// /**returns a singleton */
|
|
61
|
-
// export function usePWA(): BTPWA {
|
|
62
|
-
// return inject('bt-pwa')!
|
|
63
|
-
// }
|
|
64
|
-
|
|
65
|
-
// /**returns a new instance */
|
|
66
|
-
// export function useStore(): (opt: CreateStoreOptions) => BTStore {
|
|
67
|
-
// return inject('bt-store')!
|
|
68
|
-
// }
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/test/api.test.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, afterAll, afterEach, beforeAll } from 'vitest'
|
|
2
|
-
import { createApi } from '../src/composables/api'
|
|
3
|
-
import { setupServer } from 'msw/node'
|
|
4
|
-
import { http, HttpResponse } from 'msw'
|
|
5
|
-
|
|
6
|
-
const handlers = [
|
|
7
|
-
http.get('https://test-api/get/1', () => {
|
|
8
|
-
return HttpResponse.json({
|
|
9
|
-
data: { test: 'a' },
|
|
10
|
-
count: 0,
|
|
11
|
-
filters: ['test']
|
|
12
|
-
})
|
|
13
|
-
}),
|
|
14
|
-
http.get('https://test-api/get/2', () => {
|
|
15
|
-
return new HttpResponse('not found', {
|
|
16
|
-
status: 304
|
|
17
|
-
})
|
|
18
|
-
}),
|
|
19
|
-
http.get('https://test-api/getAll', () => {
|
|
20
|
-
return HttpResponse.json({
|
|
21
|
-
data: [{ test: 'a' }, { test: 'b' }],
|
|
22
|
-
count: 2,
|
|
23
|
-
filters: ['test', 'test two']
|
|
24
|
-
})
|
|
25
|
-
}),
|
|
26
|
-
http.post('https://test-api/post', () => {
|
|
27
|
-
return HttpResponse.json({ data: { test: 'b' } })
|
|
28
|
-
}),
|
|
29
|
-
http.patch('https://test-api/patch', () => {
|
|
30
|
-
return HttpResponse.json({ data: { test: 'c' } })
|
|
31
|
-
})
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
const server = setupServer(...handlers)
|
|
35
|
-
|
|
36
|
-
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
|
|
37
|
-
|
|
38
|
-
afterAll(() => server.close())
|
|
39
|
-
|
|
40
|
-
afterEach(() => server.resetHandlers())
|
|
41
|
-
|
|
42
|
-
describe('default api', () => {
|
|
43
|
-
const api = createApi({
|
|
44
|
-
findPath: () => 'https://test-api/',
|
|
45
|
-
defaultThrowError: false
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('get', async () => {
|
|
49
|
-
const res = await api.get<any>({ additionalUrl: 'get', id: '1', nav: 'test' })
|
|
50
|
-
expect(res).not.toBeNull()
|
|
51
|
-
expect(res.data.test).toEqual('a')
|
|
52
|
-
expect(res.filters[0]).toEqual('test')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('get fails', async () => {
|
|
56
|
-
const res = await api.get<any>({ additionalUrl: 'get', id: '2', nav: 'test' })
|
|
57
|
-
expect(res.status).toEqual(304)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
test('getAll', async () => {
|
|
61
|
-
const res = await api.get<any>({ additionalUrl: 'getAll', nav: 'test' })
|
|
62
|
-
expect(res).not.toBeNull()
|
|
63
|
-
expect(res.data.length).toEqual(2)
|
|
64
|
-
expect(res.count).toEqual(2)
|
|
65
|
-
expect(res.filters[0]).toEqual('test')
|
|
66
|
-
expect(res.filters[1]).toEqual('test two')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('post', async () => {
|
|
70
|
-
const res = await api.post<any>({ additionalUrl: 'post', nav: 'test', data: { data: 'a' }})
|
|
71
|
-
expect(res).not.toBeNull()
|
|
72
|
-
expect(res).toEqual({ data: { test: 'b' } })
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('patch', async () => {
|
|
76
|
-
const res = await api.patch<any>({ additionalUrl: 'patch', nav: 'test', data: { data: 'a' }})
|
|
77
|
-
expect(res).not.toBeNull()
|
|
78
|
-
expect(res).toEqual({ data: { test: 'c' } })
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
// describe('default api fails', () => {
|
|
83
|
-
|
|
84
|
-
// })
|
package/test/auth.test.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, afterAll, afterEach, beforeAll } from 'vitest'
|
|
2
|
-
import { createAuth, useAuth } from '../src/composables/auth'
|
|
3
|
-
import { setupServer } from 'msw/node'
|
|
4
|
-
import { http, HttpResponse } from 'msw'
|
|
5
|
-
|
|
6
|
-
const handlers = [
|
|
7
|
-
http.get('https://test-api/get/1', () => {
|
|
8
|
-
return HttpResponse.json({
|
|
9
|
-
data: { test: 'a' },
|
|
10
|
-
count: 0,
|
|
11
|
-
filters: ['test']
|
|
12
|
-
})
|
|
13
|
-
}),
|
|
14
|
-
http.get('https://test-api/get/2', () => {
|
|
15
|
-
return new HttpResponse('not found', {
|
|
16
|
-
status: 304
|
|
17
|
-
})
|
|
18
|
-
}),
|
|
19
|
-
http.get('https://test-api/getAll', () => {
|
|
20
|
-
return HttpResponse.json({
|
|
21
|
-
data: [{ test: 'a' }, { test: 'b' }],
|
|
22
|
-
count: 2,
|
|
23
|
-
filters: ['test', 'test two']
|
|
24
|
-
})
|
|
25
|
-
}),
|
|
26
|
-
http.post('https://test-api/post', () => {
|
|
27
|
-
return HttpResponse.json({ data: { test: 'b' } })
|
|
28
|
-
}),
|
|
29
|
-
http.patch('https://test-api/patch', () => {
|
|
30
|
-
return HttpResponse.json({ data: { test: 'c' } })
|
|
31
|
-
})
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
const server = setupServer(...handlers)
|
|
35
|
-
|
|
36
|
-
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
|
|
37
|
-
|
|
38
|
-
afterAll(() => server.close())
|
|
39
|
-
|
|
40
|
-
afterEach(() => server.resetHandlers())
|
|
41
|
-
|
|
42
|
-
describe('default auth', () => {
|
|
43
|
-
const auth = createAuth({
|
|
44
|
-
defaultTimeZone: 'Aus',
|
|
45
|
-
getAuthItem: () => { return {}}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('creates successfully', () => {
|
|
49
|
-
const state = auth.authState
|
|
50
|
-
const creds = auth.credentials.value
|
|
51
|
-
|
|
52
|
-
expect(state).not.toBeNull()
|
|
53
|
-
expect(auth.credentials).not.toBeNull()
|
|
54
|
-
expect(creds.timeZone).toEqual('Aus')
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('use successfully', () => {
|
|
58
|
-
const a = useAuth()
|
|
59
|
-
|
|
60
|
-
expect(a.authState).toEqual(auth.authState)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('login', () => {
|
|
64
|
-
auth.login()
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
// describe('auth', () => {
|
|
69
|
-
// const auth = createAuth({})
|
|
70
|
-
|
|
71
|
-
// test('get auth url', () => {
|
|
72
|
-
// expect(auth.getAuthorizeUrl('redirect')).toEqual('a')
|
|
73
|
-
// })
|
|
74
|
-
// })
|
package/test/forage.test.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { withSetup } from './utils'
|
|
3
|
-
import { useLocalDb } from '../src/composables/forage'
|
|
4
|
-
|
|
5
|
-
describe('foraging', () => {
|
|
6
|
-
const [db] = withSetup(() => useLocalDb())
|
|
7
|
-
|
|
8
|
-
test('local db exists', () => {
|
|
9
|
-
expect(db).not.toBeNull()
|
|
10
|
-
expect(db._config.name).toEqual('test')
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
// describe('local cache', () => {
|
|
16
|
-
// const [cache] = withSetup(() => useLocalCache())
|
|
17
|
-
|
|
18
|
-
// test('save', async () => {
|
|
19
|
-
// expect(cache).not.toBeNull()
|
|
20
|
-
|
|
21
|
-
// await cache.saveAsync({ test: 'a' }, 'test-key')
|
|
22
|
-
|
|
23
|
-
// const res = await cache.getAsync('test-key')
|
|
24
|
-
|
|
25
|
-
// expect(res.test).toEqual('a')
|
|
26
|
-
|
|
27
|
-
// await cache.clearAsync()
|
|
28
|
-
|
|
29
|
-
// const none = await cache.getAsync('test-key')
|
|
30
|
-
// })
|
|
31
|
-
// })
|