web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

commit 467799730a7f63e42c3eef18cee798e464747c66
parent 89ffc1473203b4e86e29c1e28c58067b951aa59a
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Wed, 15 Jan 2025 15:52:48 +0000

apps-lib: use simplified model types

Diffstat:
Mapps-lib/src/lib/index.ts | 2+-
Mapps-lib/src/lib/types/feature.ts | 3++-
Mapps-lib/src/lib/types/model.ts | 129++++++++++---------------------------------------------------------------------
Mapps-lib/src/lib/types/view.ts | 42+++++++++++++++++-------------------------
Mapps-lib/src/lib/view/farm-land-view.svelte | 5++---
Mapps-lib/src/lib/view/farm-land.svelte | 5++---
Mapps-lib/src/lib/view/search.svelte | 16++--------------
Mapps-lib/src/lib/view/settings-profile-edit.svelte | 12++----------
Mapps-lib/src/lib/view/settings-profile.svelte | 5++---
9 files changed, 46 insertions(+), 173 deletions(-)

diff --git a/apps-lib/src/lib/index.ts b/apps-lib/src/lib/index.ts @@ -71,7 +71,6 @@ export * from "./types/component" export * from "./types/el" export * from "./types/feature" export * from "./types/interface" -export * from "./types/model" export * from "./types/util" export * from "./types/view" export * from "./util/app" @@ -96,3 +95,4 @@ export { default as SettingsNostr } from "./view/settings-nostr.svelte" export { default as SettingsProfileEdit } from "./view/settings-profile-edit.svelte" export { default as SettingsProfile } from "./view/settings-profile.svelte" export { default as Settings } from "./view/settings.svelte" + diff --git a/apps-lib/src/lib/types/feature.ts b/apps-lib/src/lib/types/feature.ts @@ -1,4 +1,5 @@ -import { type CallbackPromiseGeneric, type ModelLocationGcs, type ModelNostrProfile, type ModelNostrRelay } from "$lib"; +import type { CallbackPromiseGeneric } from "./app"; +import type { ModelLocationGcs, ModelNostrProfile, ModelNostrRelay } from "./model"; export type ISearchResultDisplayCallbacks = { lc_handle_result_location_gcs: CallbackPromiseGeneric<ModelLocationGcs>; diff --git a/apps-lib/src/lib/types/model.ts b/apps-lib/src/lib/types/model.ts @@ -1,12 +1,17 @@ -export type ModelTableBasis = { +export type ModelNostrProfile = { id: string; - created_at: string; - updated_at: string; -}; + name?: string; + display_name?: string; + about?: string; + picture?: string; +} -export type ModelLocationGcs = ModelTableBasis & ModelLocationGcsFields; +export type ModelNostrRelay = { + id: string; +} -export type ModelLocationGcsFields = { +export type ModelLocationGcs = { + id: string; lat: number; lng: number; geohash: string; @@ -22,110 +27,8 @@ export type ModelLocationGcsFields = { gc_admin1_name?: string; gc_country_id?: string; gc_country_name?: string; -}; -export type ModelLocationGcsFieldsKey = "lat" | "lng" | "geohash" | "kind" | "label" | "area" | "elevation" | "soil" | "climate" | "gc_id" | "gc_name" | "gc_admin1_id" | "gc_admin1_name" | "gc_country_id" | "gc_country_name"; - -export type ModelLocationGcsFormFields = Record<ModelLocationGcsFieldsKey, string>; - -export type ModelLocationGcsEditFields = Partial<ModelLocationGcsFormFields>; - -export type ModelTradeProduct = ModelTableBasis & ModelTradeProductFields; - -export type ModelTradeProductFields = { - key: string; - category: string; - title: string; - summary: string; - process: string; - lot: string; - profile: string; - year: number; - qty_amt: number; - qty_unit: string; - qty_label?: string; - qty_avail?: number; - price_amt: number; - price_currency: string; - price_qty_amt: number; - price_qty_unit: string; - notes?: string; -}; -export type ModelTradeProductFieldsKey = "key" | "category" | "title" | "summary" | "process" | "lot" | "profile" | "year" | "qty_amt" | "qty_unit" | "qty_label" | "qty_avail" | "price_amt" | "price_currency" | "price_qty_amt" | "price_qty_unit" | "notes"; - -export type ModelTradeProductFormFields = Record<ModelTradeProductFieldsKey, string>; - -export type ModelTradeProductEditFields = Partial<ModelTradeProductFormFields>; - -export type ModelNostrProfile = ModelTableBasis & ModelNostrProfileFields; - -export type ModelNostrProfileFields = { - public_key: string; - name?: string; - display_name?: string; - about?: string; - website?: string; - picture?: string; - banner?: string; - nip05?: string; - lud06?: string; - lud16?: string; -}; -export type ModelNostrProfileFieldsKey = "public_key" | "name" | "display_name" | "about" | "website" | "picture" | "banner" | "nip05" | "lud06" | "lud16"; - -export type ModelNostrProfileFormFields = Record<ModelNostrProfileFieldsKey, string>; - -export type ModelNostrProfileEditFields = Partial<ModelNostrProfileFormFields>; - -export type ModelNostrRelay = ModelTableBasis & ModelNostrRelayFields; - -export type ModelNostrRelayFields = { - url: string; - relay_id?: string; - name?: string; - description?: string; - pubkey?: string; - contact?: string; - supported_nips?: string; - software?: string; - version?: string; - data?: string; -}; -export type ModelNostrRelayFieldsKey = "url" | "relay_id" | "name" | "description" | "pubkey" | "contact" | "supported_nips" | "software" | "version" | "data"; - -export type ModelNostrRelayFormFields = Record<ModelNostrRelayFieldsKey, string>; - -export type ModelNostrRelayEditFields = Partial<ModelNostrRelayFormFields>; - -export type ModelMediaImage = ModelTableBasis & ModelMediaImageFields; +} -export type ModelMediaImageFields = { - file_path: string; - mime_type: string; - res_base: string; - res_path: string; - label?: string; - description?: string; -}; -export type ModelMediaImageFieldsKey = "file_path" | "mime_type" | "res_base" | "res_path" | "label" | "description"; - -export type ModelMediaImageFormFields = Record<ModelMediaImageFieldsKey, string>; - -export type ModelMediaImageEditFields = Partial<ModelMediaImageFormFields>; - -export type ModelLogError = ModelTableBasis & ModelLogErrorFields; - -export type ModelLogErrorFields = { - error: string; - message: string; - stack_trace?: string; - cause?: string; - app_system: string; - app_version: string; - nostr_pubkey: string; - data?: string; -}; -export type ModelLogErrorFieldsKey = "error" | "message" | "stack_trace" | "cause" | "app_system" | "app_version" | "nostr_pubkey" | "data"; - -export type ModelLogErrorFormFields = Record<ModelLogErrorFieldsKey, string>; - -export type ModelLogErrorEditFields = Partial<ModelLogErrorFormFields>; -\ No newline at end of file +export type ModelTradeProduct = { + id: string; +} +\ No newline at end of file diff --git a/apps-lib/src/lib/types/view.ts b/apps-lib/src/lib/types/view.ts @@ -1,4 +1,5 @@ import { type CallbackPromise, type CallbackPromiseFull, type CallbackPromiseReturn, type IBasisOpt } from ".."; +import type { ModelLocationGcs, ModelNostrProfile, ModelNostrRelay, ModelTradeProduct } from "./model"; export type ViewBasis<T extends object> = { kv_init_prevent?: boolean; @@ -13,36 +14,28 @@ export type ViewBasisLoadData<TView extends object, TLoadData extends object> = lc_handle_back?: CallbackPromise; }; -export type IFarmLoadData< - TLocationGcs extends object, -> = IBasisOpt<{ - location_gcs: TLocationGcs[]; +export type IFarmLoadData = IBasisOpt<{ + location_gcs: ModelLocationGcs[]; }>; -export type IFarmViewLoadData< - TLocationGcs extends object, -> = IBasisOpt<{ - location_gcs: TLocationGcs; +export type IFarmViewLoadData = IBasisOpt<{ + location_gcs: ModelLocationGcs; }>; -export type ISearchLoadData< - TLocationGcs extends object, - TNostrProfile extends object, - TNostrRelay extends object, - TTradeProduct extends object, -> = IBasisOpt<{ - location_gcs: TLocationGcs[]; - nostr_profile: TNostrProfile[]; - nostr_relay: TNostrRelay[]; - trade_product: TTradeProduct[]; +export type ISearchLoadData = IBasisOpt<{ + location_gcs: ModelLocationGcs[]; + nostr_profile: ModelNostrProfile[]; + nostr_relay: ModelNostrRelay[]; + trade_product: ModelTradeProduct[]; }>; -export type ISettingsNostrProfileLoadData<TNostrProfile extends object> = IBasisOpt<{ - nostr_profile: TNostrProfile; +export type ISettingsNostrProfileLoadData = IBasisOpt<{ + nostr_profile: ModelNostrProfile; }>; -export type ISettingsNostrProfileEditLoadData<TNostrProfile extends object, TNostrProfileFieldKey extends string> = IBasisOpt<{ - nostr_profile: TNostrProfile; - field_key: TNostrProfileFieldKey; +export type ISettingsNostrProfileEditLoadData = IBasisOpt<{ + nostr_profile: ModelNostrProfile; + field_key: string; field_val?: string; -}>; -\ No newline at end of file +}>; + diff --git a/apps-lib/src/lib/view/farm-land-view.svelte b/apps-lib/src/lib/view/farm-land-view.svelte @@ -1,4 +1,4 @@ -<script lang="ts" generics="TLocationGcs extends ModelLocationGcs"> +<script lang="ts"> import { app_notify, GlyphButtonSimple, @@ -9,11 +9,10 @@ PageToolbar, qp_id, type IFarmViewLoadData, - type ModelLocationGcs, type ViewBasisLoadData, } from "$lib"; import { onDestroy, onMount } from "svelte"; - type LoadData = IFarmViewLoadData<TLocationGcs>; + type LoadData = IFarmViewLoadData; export let basis: ViewBasisLoadData<{}, LoadData>; let load_data: LoadData = undefined; diff --git a/apps-lib/src/lib/view/farm-land.svelte b/apps-lib/src/lib/view/farm-land.svelte @@ -1,4 +1,4 @@ -<script lang="ts" generics="TLocationGcs extends ModelLocationGcs"> +<script lang="ts"> import { Fade, FloatTabs, @@ -12,11 +12,10 @@ PageToolbar, type CallbackPromise, type IFarmLoadData, - type ModelLocationGcs, type ViewBasisLoadData, } from "$lib"; import { onDestroy, onMount } from "svelte"; - type LoadData = IFarmLoadData<TLocationGcs>; + type LoadData = IFarmLoadData; export let basis: ViewBasisLoadData< { diff --git a/apps-lib/src/lib/view/search.svelte b/apps-lib/src/lib/view/search.svelte @@ -1,7 +1,4 @@ -<script - lang="ts" - generics="TLocationGcs extends ModelLocationGcs, TNostrProfile extends ModelNostrProfile, TNostrRelay extends ModelNostrRelay, TTradeProduct extends ModelTradeProduct" -> +<script lang="ts"> import { cfg_app, debounce_input, @@ -17,21 +14,12 @@ SearchService, type ISearchLoadData, type ISearchResultDisplayCallbacks, - type ModelLocationGcs, - type ModelNostrProfile, - type ModelNostrRelay, - type ModelTradeProduct, type SearchServiceResult, type ViewBasisLoadData, } from "$lib"; import { onDestroy, onMount } from "svelte"; - type LoadData = ISearchLoadData< - TLocationGcs, - TNostrProfile, - TNostrRelay, - TTradeProduct - >; + type LoadData = ISearchLoadData; export let basis: ViewBasisLoadData< ISearchResultDisplayCallbacks & {}, diff --git a/apps-lib/src/lib/view/settings-profile-edit.svelte b/apps-lib/src/lib/view/settings-profile-edit.svelte @@ -1,7 +1,4 @@ -<script - lang="ts" - generics="TModelNostrProfile extends ModelNostrProfile, TModelNostrProfileFieldsKey extends ModelNostrProfileFieldsKey" -> +<script lang="ts"> import { app_notify, fmt_id, @@ -15,16 +12,11 @@ TextArea, type CallbackPromise, type ISettingsNostrProfileEditLoadData, - type ModelNostrProfile, - type ModelNostrProfileFieldsKey, type ViewBasisLoadData, } from "$lib"; import { onDestroy, onMount } from "svelte"; - type LoadData = ISettingsNostrProfileEditLoadData< - TModelNostrProfile, - TModelNostrProfileFieldsKey - >; + type LoadData = ISettingsNostrProfileEditLoadData; export let basis: ViewBasisLoadData< { diff --git a/apps-lib/src/lib/view/settings-profile.svelte b/apps-lib/src/lib/view/settings-profile.svelte @@ -1,4 +1,4 @@ -<script lang="ts" generics="TModelNostrProfile extends ModelNostrProfile"> +<script lang="ts"> import { ascii, FloatPageButton, @@ -13,14 +13,13 @@ type CallbackPromiseFull, type CallbackPromiseReturn, type ISettingsNostrProfileLoadData, - type ModelNostrProfile, type ViewBasisLoadData, } from "$lib"; import { onDestroy, onMount } from "svelte"; export let bv_photo_path_opt = ``; - type LoadData = ISettingsNostrProfileLoadData<TModelNostrProfile>; + type LoadData = ISettingsNostrProfileLoadData; export let basis: ViewBasisLoadData< {