@meeovi/layer-lists 1.0.2 → 1.0.3

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 (134) hide show
  1. package/README.md +111 -0
  2. package/app/composables/config.ts +1 -1
  3. package/app/composables/module.ts +75 -0
  4. package/app/composables/providers/directus.ts +112 -16
  5. package/app/composables/providers/memory.ts +39 -0
  6. package/app/composables/registry.ts +5 -0
  7. package/app/composables/types.ts +9 -0
  8. package/app/composables/utils/health.ts +16 -0
  9. package/dist/app/composables/config.d.ts +7 -0
  10. package/dist/app/composables/config.js +9 -0
  11. package/dist/app/composables/globals/useDirectusForm.d.ts +4 -0
  12. package/dist/app/composables/globals/useDirectusForm.js +10 -0
  13. package/dist/app/composables/module.d.ts +7 -0
  14. package/dist/app/composables/module.js +60 -0
  15. package/dist/app/composables/providers/atproto.d.ts +1 -0
  16. package/dist/app/composables/providers/atproto.js +133 -0
  17. package/dist/app/composables/providers/directus.d.ts +1 -0
  18. package/dist/app/composables/providers/directus.js +130 -0
  19. package/dist/app/composables/providers/memory.d.ts +1 -0
  20. package/dist/app/composables/providers/memory.js +110 -0
  21. package/dist/app/composables/registry.d.ts +4 -0
  22. package/dist/app/composables/registry.js +14 -0
  23. package/dist/app/composables/types.d.ts +38 -0
  24. package/dist/app/composables/types.js +1 -0
  25. package/dist/app/composables/useLists.d.ts +11 -0
  26. package/dist/app/composables/useLists.js +17 -0
  27. package/dist/app/composables/utils/health.d.ts +10 -0
  28. package/dist/app/composables/utils/health.js +15 -0
  29. package/dist/app/composables/utils/transforms.d.ts +13 -0
  30. package/dist/app/composables/utils/transforms.js +38 -0
  31. package/dist/app/composables/utils/validation.d.ts +3 -0
  32. package/dist/app/composables/utils/validation.js +16 -0
  33. package/dist/layers/lists/app/composables/config.d.ts +7 -0
  34. package/dist/layers/lists/app/composables/config.js +9 -0
  35. package/dist/layers/lists/app/composables/globals/useDirectusForm.d.ts +1 -0
  36. package/dist/layers/lists/app/composables/globals/useDirectusForm.js +1 -0
  37. package/dist/layers/lists/app/composables/module.d.ts +7 -0
  38. package/dist/layers/lists/app/composables/module.js +60 -0
  39. package/dist/layers/lists/app/composables/providers/atproto.d.ts +1 -0
  40. package/dist/layers/lists/app/composables/providers/atproto.js +133 -0
  41. package/dist/layers/lists/app/composables/providers/directus.d.ts +1 -0
  42. package/dist/layers/lists/app/composables/providers/directus.js +130 -0
  43. package/dist/layers/lists/app/composables/providers/memory.d.ts +1 -0
  44. package/dist/layers/lists/app/composables/providers/memory.js +110 -0
  45. package/dist/layers/lists/app/composables/registry.d.ts +4 -0
  46. package/dist/layers/lists/app/composables/registry.js +14 -0
  47. package/dist/layers/lists/app/composables/types.d.ts +38 -0
  48. package/dist/layers/lists/app/composables/types.js +1 -0
  49. package/dist/layers/lists/app/composables/useLists.d.ts +11 -0
  50. package/dist/layers/lists/app/composables/useLists.js +17 -0
  51. package/dist/layers/lists/app/composables/utils/health.d.ts +10 -0
  52. package/dist/layers/lists/app/composables/utils/health.js +15 -0
  53. package/dist/layers/lists/app/composables/utils/transforms.d.ts +13 -0
  54. package/dist/layers/lists/app/composables/utils/transforms.js +38 -0
  55. package/dist/layers/lists/app/composables/utils/validation.d.ts +3 -0
  56. package/dist/layers/lists/app/composables/utils/validation.js +16 -0
  57. package/dist/layers/lists/nuxt.config.d.ts +2 -0
  58. package/dist/layers/lists/nuxt.config.js +7 -0
  59. package/dist/layers/shared/app/composables/globals/useDirectusForm.d.ts +10 -0
  60. package/dist/layers/shared/app/composables/globals/useDirectusForm.js +66 -0
  61. package/dist/lists/app/composables/config.d.ts +7 -0
  62. package/dist/lists/app/composables/config.js +9 -0
  63. package/dist/lists/app/composables/globals/useDirectusForm.d.ts +1 -0
  64. package/dist/lists/app/composables/globals/useDirectusForm.js +1 -0
  65. package/dist/lists/app/composables/module.d.ts +7 -0
  66. package/dist/lists/app/composables/module.js +60 -0
  67. package/dist/lists/app/composables/providers/atproto.d.ts +1 -0
  68. package/dist/lists/app/composables/providers/atproto.js +133 -0
  69. package/dist/lists/app/composables/providers/directus.d.ts +1 -0
  70. package/dist/lists/app/composables/providers/directus.js +130 -0
  71. package/dist/lists/app/composables/providers/memory.d.ts +1 -0
  72. package/dist/lists/app/composables/providers/memory.js +110 -0
  73. package/dist/lists/app/composables/registry.d.ts +4 -0
  74. package/dist/lists/app/composables/registry.js +14 -0
  75. package/dist/lists/app/composables/types.d.ts +38 -0
  76. package/dist/lists/app/composables/types.js +1 -0
  77. package/dist/lists/app/composables/useLists.d.ts +11 -0
  78. package/dist/lists/app/composables/useLists.js +17 -0
  79. package/dist/lists/app/composables/utils/health.d.ts +10 -0
  80. package/dist/lists/app/composables/utils/health.js +15 -0
  81. package/dist/lists/app/composables/utils/transforms.d.ts +13 -0
  82. package/dist/lists/app/composables/utils/transforms.js +38 -0
  83. package/dist/lists/app/composables/utils/validation.d.ts +3 -0
  84. package/dist/lists/app/composables/utils/validation.js +16 -0
  85. package/dist/lists/nuxt.config.d.ts +2 -0
  86. package/dist/lists/nuxt.config.js +7 -0
  87. package/dist/nuxt.config.d.ts +2 -0
  88. package/dist/nuxt.config.js +7 -0
  89. package/dist/packages/core/index.d.ts +17 -0
  90. package/dist/packages/core/index.js +18 -0
  91. package/dist/packages/core/src/adapters/auth.d.ts +9 -0
  92. package/dist/packages/core/src/adapters/auth.js +1 -0
  93. package/dist/packages/core/src/adapters/cart.d.ts +22 -0
  94. package/dist/packages/core/src/adapters/cart.js +1 -0
  95. package/dist/packages/core/src/adapters/catalog.d.ts +17 -0
  96. package/dist/packages/core/src/adapters/catalog.js +1 -0
  97. package/dist/packages/core/src/adapters/common.d.ts +9 -0
  98. package/dist/packages/core/src/adapters/common.js +1 -0
  99. package/dist/packages/core/src/adapters/lists.d.ts +17 -0
  100. package/dist/packages/core/src/adapters/lists.js +1 -0
  101. package/dist/packages/core/src/adapters/search.d.ts +21 -0
  102. package/dist/packages/core/src/adapters/search.js +1 -0
  103. package/dist/packages/core/src/plugins/defineAdapter.d.ts +2 -0
  104. package/dist/packages/core/src/plugins/defineAdapter.js +3 -0
  105. package/dist/packages/core/src/plugins/defineModule.d.ts +2 -0
  106. package/dist/packages/core/src/plugins/defineModule.js +3 -0
  107. package/dist/packages/core/src/plugins/registry.d.ts +14 -0
  108. package/dist/packages/core/src/plugins/registry.js +46 -0
  109. package/dist/packages/core/src/runtime/app.d.ts +2 -0
  110. package/dist/packages/core/src/runtime/app.js +20 -0
  111. package/dist/packages/core/src/runtime/config.d.ts +7 -0
  112. package/dist/packages/core/src/runtime/config.js +9 -0
  113. package/dist/packages/core/src/runtime/context.d.ts +9 -0
  114. package/dist/packages/core/src/runtime/context.js +11 -0
  115. package/dist/packages/core/src/runtime/hooks.d.ts +5 -0
  116. package/dist/packages/core/src/runtime/hooks.js +18 -0
  117. package/dist/packages/core/src/runtime/lifecycle.d.ts +4 -0
  118. package/dist/packages/core/src/runtime/lifecycle.js +5 -0
  119. package/dist/packages/core/src/types/adapters.d.ts +14 -0
  120. package/dist/packages/core/src/types/adapters.js +1 -0
  121. package/dist/packages/core/src/types/app.d.ts +13 -0
  122. package/dist/packages/core/src/types/app.js +1 -0
  123. package/dist/packages/core/src/types/config.d.ts +8 -0
  124. package/dist/packages/core/src/types/config.js +1 -0
  125. package/dist/packages/core/src/types/events.d.ts +20 -0
  126. package/dist/packages/core/src/types/events.js +22 -0
  127. package/dist/packages/core/src/types/module.d.ts +15 -0
  128. package/dist/packages/core/src/types/module.js +1 -0
  129. package/dist/shared/app/composables/globals/useDirectusForm.d.ts +10 -0
  130. package/dist/shared/app/composables/globals/useDirectusForm.js +66 -0
  131. package/global.d.ts +1 -0
  132. package/package.json +4 -1
  133. package/shims.d.ts +7 -0
  134. package/tsconfig.json +21 -0
@@ -0,0 +1,13 @@
1
+ import type { List, ListItem } from '../types';
2
+ /**
3
+ * Normalize a raw provider list into Meeovi's List shape.
4
+ */
5
+ export declare function transformList(raw: any): List;
6
+ /**
7
+ * Normalize a raw provider item into Meeovi's ListItem shape.
8
+ */
9
+ export declare function transformItem(raw: any): ListItem;
10
+ /**
11
+ * Normalize arrays safely.
12
+ */
13
+ export declare function transformListArray(raw: any[]): List[];
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Normalize a raw provider list into Meeovi's List shape.
3
+ */
4
+ export function transformList(raw) {
5
+ return {
6
+ id: raw.id,
7
+ title: raw.title ?? raw.name ?? 'Untitled',
8
+ type: raw.type ?? 'list',
9
+ items: Array.isArray(raw.items)
10
+ ? raw.items.map(transformItem)
11
+ : [],
12
+ metadata: raw.metadata ?? {},
13
+ createdAt: raw.createdAt ?? raw.created_at ?? null,
14
+ updatedAt: raw.updatedAt ?? raw.updated_at ?? null
15
+ };
16
+ }
17
+ /**
18
+ * Normalize a raw provider item into Meeovi's ListItem shape.
19
+ */
20
+ export function transformItem(raw) {
21
+ return {
22
+ id: raw.id,
23
+ title: raw.title ?? raw.name ?? '',
24
+ description: raw.description ?? raw.body ?? '',
25
+ completed: raw.completed ?? raw.done ?? false,
26
+ position: raw.position ?? raw.order ?? 0,
27
+ parentId: raw.parentId ?? raw.parent_id ?? null,
28
+ metadata: raw.metadata ?? {},
29
+ createdAt: raw.createdAt ?? raw.created_at ?? null,
30
+ updatedAt: raw.updatedAt ?? raw.updated_at ?? null
31
+ };
32
+ }
33
+ /**
34
+ * Normalize arrays safely.
35
+ */
36
+ export function transformListArray(raw) {
37
+ return raw.map(transformList);
38
+ }
@@ -0,0 +1,3 @@
1
+ import type { List, ListItem } from '../types';
2
+ export declare function validateListInput(data: Partial<List>): void;
3
+ export declare function validateItemInput(data: Partial<ListItem>): void;
@@ -0,0 +1,16 @@
1
+ export function validateListInput(data) {
2
+ if (!data.title || typeof data.title !== 'string') {
3
+ throw new Error('List title is required and must be a string');
4
+ }
5
+ if (data.type && typeof data.type !== 'string') {
6
+ throw new Error('List type must be a string');
7
+ }
8
+ }
9
+ export function validateItemInput(data) {
10
+ if (!data.title || typeof data.title !== 'string') {
11
+ throw new Error('Item title is required and must be a string');
12
+ }
13
+ if (data.completed !== undefined && typeof data.completed !== 'boolean') {
14
+ throw new Error('Item completed must be a boolean');
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("c12").InputConfig<import("@nuxt/schema").NuxtConfig, import("c12").ConfigLayerMeta>;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { defineNuxtConfig } from 'nuxt/config';
2
+ export default defineNuxtConfig({
3
+ $meta: {
4
+ name: 'lists',
5
+ },
6
+ runtimeConfig: {}
7
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("c12").InputConfig<import("@nuxt/schema").NuxtConfig, import("c12").ConfigLayerMeta>;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { defineNuxtConfig } from 'nuxt/config';
2
+ export default defineNuxtConfig({
3
+ $meta: {
4
+ name: 'lists',
5
+ },
6
+ runtimeConfig: {}
7
+ });
@@ -0,0 +1,17 @@
1
+ export * from './src/runtime/app';
2
+ export * from './src/runtime/context';
3
+ export * from './src/runtime/config';
4
+ export * from './src/runtime/hooks';
5
+ export * from './src/plugins/defineModule';
6
+ export * from './src/plugins/defineAdapter';
7
+ export * from './src/plugins/registry';
8
+ export * from './src/adapters/common';
9
+ export * from './src/adapters/auth';
10
+ export * from './src/adapters/search';
11
+ export * from './src/adapters/catalog';
12
+ export * from './src/adapters/cart';
13
+ export * from './src/adapters/lists';
14
+ export * from './src/types/module';
15
+ export * from './src/types/app';
16
+ export * from './src/types/config';
17
+ export * from './src/types/events';
@@ -0,0 +1,18 @@
1
+ // src/index.ts
2
+ export * from './src/runtime/app';
3
+ export * from './src/runtime/context';
4
+ export * from './src/runtime/config';
5
+ export * from './src/runtime/hooks';
6
+ export * from './src/plugins/defineModule';
7
+ export * from './src/plugins/defineAdapter';
8
+ export * from './src/plugins/registry';
9
+ export * from './src/adapters/common';
10
+ export * from './src/adapters/auth';
11
+ export * from './src/adapters/search';
12
+ export * from './src/adapters/catalog';
13
+ export * from './src/adapters/cart';
14
+ export * from './src/adapters/lists';
15
+ export * from './src/types/module';
16
+ export * from './src/types/app';
17
+ export * from './src/types/config';
18
+ export * from './src/types/events';
@@ -0,0 +1,9 @@
1
+ import { BaseAdapterConfig } from './common';
2
+ export interface AuthAdapterConfig extends BaseAdapterConfig {
3
+ provider: 'custom' | 'auth0' | 'cognito' | string;
4
+ }
5
+ export interface AuthAdapter {
6
+ login(payload: unknown): Promise<unknown>;
7
+ logout(): Promise<void>;
8
+ getSession(): Promise<unknown | null>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { BaseAdapter, BaseAdapterConfig } from './common';
2
+ export interface CartAdapterConfig extends BaseAdapterConfig {
3
+ provider: string;
4
+ }
5
+ export interface CartItem {
6
+ id: string;
7
+ productId: string;
8
+ quantity: number;
9
+ [key: string]: unknown;
10
+ }
11
+ export interface Cart<TItem extends CartItem = CartItem> {
12
+ id: string;
13
+ items: TItem[];
14
+ [key: string]: unknown;
15
+ }
16
+ export interface CartAdapter<TItem extends CartItem = CartItem> extends BaseAdapter<CartAdapterConfig> {
17
+ type: 'cart';
18
+ getCart(id: string): Promise<Cart<TItem> | null>;
19
+ addItem(cartId: string, item: TItem): Promise<Cart<TItem>>;
20
+ removeItem(cartId: string, itemId: string): Promise<Cart<TItem>>;
21
+ clearCart(cartId: string): Promise<Cart<TItem>>;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { BaseAdapter, BaseAdapterConfig } from './common';
2
+ export interface CatalogAdapterConfig extends BaseAdapterConfig {
3
+ provider: string;
4
+ }
5
+ export interface CatalogProduct {
6
+ id: string;
7
+ slug: string;
8
+ name: string;
9
+ price: number;
10
+ [key: string]: unknown;
11
+ }
12
+ export interface CatalogAdapter<TProduct extends CatalogProduct = CatalogProduct> extends BaseAdapter<CatalogAdapterConfig> {
13
+ type: 'catalog';
14
+ getProductById(id: string): Promise<TProduct | null>;
15
+ getProductBySlug(slug: string): Promise<TProduct | null>;
16
+ listProducts(params?: Record<string, unknown>): Promise<TProduct[]>;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface BaseAdapterConfig {
2
+ enabled?: boolean;
3
+ timeoutMs?: number;
4
+ }
5
+ export interface BaseAdapter<TConfig extends BaseAdapterConfig = BaseAdapterConfig> {
6
+ id: string;
7
+ type: string;
8
+ config?: TConfig;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { BaseAdapter, BaseAdapterConfig } from './common';
2
+ export interface ListsAdapterConfig extends BaseAdapterConfig {
3
+ provider?: string;
4
+ }
5
+ export interface ListsAdapter extends BaseAdapter<ListsAdapterConfig> {
6
+ type: 'lists';
7
+ getList(id: string): Promise<any>;
8
+ listLists(params?: Record<string, any>): Promise<any[]>;
9
+ createList(data: Partial<any>): Promise<any>;
10
+ updateList(id: string, data: Partial<any>): Promise<any>;
11
+ deleteList(id: string): Promise<void>;
12
+ addItem(listId: string, item: Partial<any>): Promise<any>;
13
+ updateItem(listId: string, itemId: string, data: Partial<any>): Promise<any>;
14
+ deleteItem(listId: string, itemId: string): Promise<void>;
15
+ reorderItems?(listId: string, itemIds: string[]): Promise<void>;
16
+ }
17
+ export default ListsAdapter;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { BaseAdapter, BaseAdapterConfig } from './common';
2
+ export interface SearchAdapterConfig extends BaseAdapterConfig {
3
+ provider: string;
4
+ }
5
+ export interface SearchQuery {
6
+ term: string;
7
+ filters?: Record<string, unknown>;
8
+ page?: number;
9
+ pageSize?: number;
10
+ }
11
+ export interface SearchResult<TItem = unknown> {
12
+ items: TItem[];
13
+ total: number;
14
+ page: number;
15
+ pageSize: number;
16
+ }
17
+ export interface SearchAdapter<TItem = unknown> extends BaseAdapter<SearchAdapterConfig> {
18
+ type: 'search';
19
+ search(query: SearchQuery): Promise<SearchResult<TItem>>;
20
+ suggest?(term: string): Promise<string[]>;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BaseAdapter } from '../adapters/common';
2
+ export declare function defineAlternateAdapter<T extends BaseAdapter<any>>(adapter: T): T;
@@ -0,0 +1,3 @@
1
+ export function defineAlternateAdapter(adapter) {
2
+ return adapter;
3
+ }
@@ -0,0 +1,2 @@
1
+ import { AlternateModule } from '../types/module';
2
+ export declare function defineAlternateModule<T extends AlternateModule>(module: T): T;
@@ -0,0 +1,3 @@
1
+ export function defineAlternateModule(module) {
2
+ return module;
3
+ }
@@ -0,0 +1,14 @@
1
+ import { AlternateModule } from '../types/module';
2
+ import { AlternateContext } from '../runtime/context';
3
+ import { AlternateAdapterKey, AlternateAdapterMap, AlternateAdapterOf } from '../types/adapters';
4
+ import { AlternateEventBus } from '../types/events';
5
+ export declare class ModuleRegistry {
6
+ private modules;
7
+ private adapters;
8
+ private bus;
9
+ constructor(bus?: AlternateEventBus);
10
+ registerModule(module: AlternateModule, ctx: AlternateContext): void;
11
+ getAdapter<K extends AlternateAdapterKey>(key: K): AlternateAdapterOf<K> | undefined;
12
+ registerAdapter<K extends AlternateAdapterKey>(key: K, adapter: AlternateAdapterMap[K]): void;
13
+ runLifecycle(hook: keyof AlternateModule, ctx: AlternateContext): Promise<void>;
14
+ }
@@ -0,0 +1,46 @@
1
+ export class ModuleRegistry {
2
+ modules = new Map();
3
+ adapters = new Map();
4
+ bus = null;
5
+ constructor(bus) {
6
+ if (bus)
7
+ this.bus = bus;
8
+ }
9
+ registerModule(module, ctx) {
10
+ if (this.modules.has(module.id))
11
+ return;
12
+ this.modules.set(module.id, module);
13
+ if (module.adapters) {
14
+ for (const [key, adapter] of Object.entries(module.adapters)) {
15
+ const typedKey = key;
16
+ this.registerAdapter(typedKey, adapter);
17
+ }
18
+ }
19
+ module.setup?.(ctx);
20
+ }
21
+ getAdapter(key) {
22
+ return this.adapters.get(key);
23
+ }
24
+ // Register an adapter at runtime. Emits `adapter:registered` so modules
25
+ // depending on adapters can react when new adapters become available.
26
+ registerAdapter(key, adapter) {
27
+ this.adapters.set(key, adapter);
28
+ if (this.bus) {
29
+ try {
30
+ // notify listeners asynchronously
31
+ this.bus.emit('adapter:registered', { key }).catch(() => { });
32
+ }
33
+ catch (e) {
34
+ // ignore emit errors
35
+ }
36
+ }
37
+ }
38
+ async runLifecycle(hook, ctx) {
39
+ for (const module of this.modules.values()) {
40
+ const fn = module[hook];
41
+ if (typeof fn === 'function') {
42
+ await fn.call(module, ctx);
43
+ }
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,2 @@
1
+ import type { AlternateApp, AlternateAppOptions } from '../types/app';
2
+ export declare function createAlternateApp(options: AlternateAppOptions): AlternateApp;
@@ -0,0 +1,20 @@
1
+ import { AlternateContext } from './context';
2
+ import { ModuleRegistry } from '../plugins/registry';
3
+ import { createEventBus } from '../types/events';
4
+ import { setRuntimeContext } from './hooks';
5
+ import { runAppLifecycle } from './lifecycle';
6
+ export function createAlternateApp(options) {
7
+ const eventBus = createEventBus();
8
+ const registry = new ModuleRegistry(eventBus);
9
+ const context = new AlternateContext(options.config, registry);
10
+ setRuntimeContext(context, eventBus);
11
+ options.modules?.forEach((mod) => registry.registerModule(mod, context));
12
+ return {
13
+ context,
14
+ events: eventBus,
15
+ async start() {
16
+ await runAppLifecycle(registry, context, eventBus);
17
+ return context;
18
+ }
19
+ };
20
+ }
@@ -0,0 +1,7 @@
1
+ export declare function defineMeeoviConfig(): {
2
+ productProvider: string;
3
+ cartProvider: string;
4
+ contentProvider: string;
5
+ authUrl: string;
6
+ searchUrl: string;
7
+ };
@@ -0,0 +1,9 @@
1
+ export function defineMeeoviConfig() {
2
+ return {
3
+ productProvider: 'directus',
4
+ cartProvider: 'directus',
5
+ contentProvider: 'directus',
6
+ authUrl: '/api/auth',
7
+ searchUrl: '/api/search'
8
+ };
9
+ }
@@ -0,0 +1,9 @@
1
+ import { AlternateConfig } from '../types/config';
2
+ import { ModuleRegistry } from '../plugins/registry';
3
+ import { AlternateAdapterKey, AlternateAdapterOf } from '../types/adapters';
4
+ export declare class AlternateContext {
5
+ readonly config: AlternateConfig;
6
+ readonly modules: ModuleRegistry;
7
+ constructor(config: AlternateConfig, modules: ModuleRegistry);
8
+ getAdapter<K extends AlternateAdapterKey>(key: K): AlternateAdapterOf<K> | undefined;
9
+ }
@@ -0,0 +1,11 @@
1
+ export class AlternateContext {
2
+ config;
3
+ modules;
4
+ constructor(config, modules) {
5
+ this.config = config;
6
+ this.modules = modules;
7
+ }
8
+ getAdapter(key) {
9
+ return this.modules.getAdapter(key);
10
+ }
11
+ }
@@ -0,0 +1,5 @@
1
+ import { AlternateContext } from './context';
2
+ import { AlternateEventBus } from '../types/events';
3
+ export declare function setRuntimeContext(ctx: AlternateContext, bus: AlternateEventBus): void;
4
+ export declare function useAlternateContext(): AlternateContext;
5
+ export declare function useAlternateEventBus(): AlternateEventBus;
@@ -0,0 +1,18 @@
1
+ let currentContext = null;
2
+ let currentEventBus = null;
3
+ export function setRuntimeContext(ctx, bus) {
4
+ currentContext = ctx;
5
+ currentEventBus = bus;
6
+ }
7
+ export function useAlternateContext() {
8
+ if (!currentContext) {
9
+ throw new Error('[@meeovi/core] useAlternateContext() called before app initialization');
10
+ }
11
+ return currentContext;
12
+ }
13
+ export function useAlternateEventBus() {
14
+ if (!currentEventBus) {
15
+ throw new Error('[@meeovi/core] useAlternateEventBus() called before app initialization');
16
+ }
17
+ return currentEventBus;
18
+ }
@@ -0,0 +1,4 @@
1
+ import { AlternateContext } from './context';
2
+ import { ModuleRegistry } from '../plugins/registry';
3
+ import { AlternateEventBus } from '../types/events';
4
+ export declare function runAppLifecycle(registry: ModuleRegistry, ctx: AlternateContext, bus: AlternateEventBus): Promise<void>;
@@ -0,0 +1,5 @@
1
+ export async function runAppLifecycle(registry, ctx, bus) {
2
+ // Example lifecycle sequence
3
+ await registry.runLifecycle('onAppInit', ctx);
4
+ bus.emit('app:ready', { context: ctx });
5
+ }
@@ -0,0 +1,14 @@
1
+ import type { SearchAdapter } from '../adapters/search';
2
+ import type { ListsAdapter } from '../adapters/lists';
3
+ import type { CatalogAdapter } from '../adapters/catalog';
4
+ import type { CartAdapter } from '../adapters/cart';
5
+ import type { AuthAdapter } from '../adapters/auth';
6
+ export interface AlternateAdapterMap {
7
+ search: SearchAdapter;
8
+ lists: ListsAdapter;
9
+ catalog: CatalogAdapter;
10
+ cart: CartAdapter;
11
+ auth: AuthAdapter;
12
+ }
13
+ export type AlternateAdapterKey = keyof AlternateAdapterMap;
14
+ export type AlternateAdapterOf<K extends AlternateAdapterKey> = AlternateAdapterMap[K];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { AlternateConfig } from './config';
2
+ import { AlternateContext } from '../runtime/context';
3
+ import { AlternateEventBus } from './events';
4
+ import { AlternateModule } from './module';
5
+ export interface AlternateApp {
6
+ context: AlternateContext;
7
+ events: AlternateEventBus;
8
+ start(): Promise<AlternateContext>;
9
+ }
10
+ export interface AlternateAppOptions {
11
+ config: AlternateConfig;
12
+ modules?: AlternateModule[];
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface AlternateConfig {
2
+ env: 'development' | 'production' | 'test';
3
+ appName?: string;
4
+ logger?: {
5
+ level?: 'debug' | 'info' | 'warn' | 'error';
6
+ };
7
+ [key: string]: unknown;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { AlternateAdapterKey } from './adapters';
2
+ export interface AlternateEventMap {
3
+ 'app:ready': {
4
+ context: unknown;
5
+ };
6
+ 'app:error': {
7
+ error: unknown;
8
+ };
9
+ 'adapter:registered': {
10
+ key: AlternateAdapterKey;
11
+ };
12
+ }
13
+ export type AlternateEventKey = keyof AlternateEventMap;
14
+ export type AlternateEventHandler<K extends AlternateEventKey> = (payload: AlternateEventMap[K]) => void | Promise<void>;
15
+ export interface AlternateEventBus {
16
+ on<K extends AlternateEventKey>(event: K, handler: AlternateEventHandler<K>): void;
17
+ off<K extends AlternateEventKey>(event: K, handler: AlternateEventHandler<K>): void;
18
+ emit<K extends AlternateEventKey>(event: K, payload: AlternateEventMap[K]): Promise<void>;
19
+ }
20
+ export declare function createEventBus(): AlternateEventBus;
@@ -0,0 +1,22 @@
1
+ export function createEventBus() {
2
+ const handlers = new Map();
3
+ return {
4
+ on(event, handler) {
5
+ if (!handlers.has(event)) {
6
+ handlers.set(event, new Set());
7
+ }
8
+ handlers.get(event).add(handler);
9
+ },
10
+ off(event, handler) {
11
+ handlers.get(event)?.delete(handler);
12
+ },
13
+ async emit(event, payload) {
14
+ const set = handlers.get(event);
15
+ if (!set || set.size === 0)
16
+ return;
17
+ for (const handler of set) {
18
+ await handler(payload);
19
+ }
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,15 @@
1
+ import type { AlternateContext } from '../runtime/context';
2
+ import type { AlternateAdapterKey, AlternateAdapterOf } from './adapters';
3
+ export type AlternateModuleAdapters = Partial<{
4
+ [K in AlternateAdapterKey]: AlternateAdapterOf<K>;
5
+ }>;
6
+ export interface AlternateModuleLifecycle {
7
+ onAppInit?(ctx: AlternateContext): Promise<void> | void;
8
+ onBeforeRequest?(ctx: AlternateContext): Promise<void> | void;
9
+ onAfterRequest?(ctx: AlternateContext): Promise<void> | void;
10
+ }
11
+ export interface AlternateModule extends AlternateModuleLifecycle {
12
+ id: string;
13
+ adapters?: AlternateModuleAdapters;
14
+ setup?(ctx: AlternateContext): void | Promise<void>;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Ref } from 'vue';
2
+ export declare function useDirectusForm(collectionName: string, fieldsRef: Ref<any[]>, opts?: {
3
+ clearOnSuccess?: boolean;
4
+ closeDialogRef?: Ref<boolean>;
5
+ }): {
6
+ form: Ref<Record<string, any>, Record<string, any>>;
7
+ formError: Ref<string | null, string | null>;
8
+ formSuccess: Ref<string | null, string | null>;
9
+ submitForm: () => Promise<void>;
10
+ };