@nizza/core 0.4.5-alpha.1 → 0.4.5-alpha.2

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.
@@ -1,4 +1,4 @@
1
- import { Attributes, EventBus, EventBusListener, EventBusSubscription } from '../../types';
1
+ import { Attributes, EventBus, EventBusListener, EventBusSubscription } from '../types';
2
2
  /**
3
3
  * Implementation of EventBus using BroadcastChannel for cross-window communication.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { EventBus, EventBusListener, EventBusSubscription } from '../../types';
1
+ import { EventBus, EventBusListener, EventBusSubscription } from '../types';
2
2
  export declare class EventEmitter2EventBus implements EventBus {
3
3
  private emitter;
4
4
  constructor();
@@ -1,2 +1 @@
1
1
  export * from './StoreProvider';
2
- export * from './hooks';
@@ -1,22 +1,16 @@
1
1
  import log from 'loglevel';
2
- import { NizzaConfiguration, NizzaProductDataSource } from '../types';
3
- import { BroadcastChannelEventBus } from './event-buses';
4
- export declare class NizzaStore {
5
- private static _instance;
6
- private _productDataSource;
7
- private _configManager;
8
- private _eventBus;
9
- readonly instanceId: string;
10
- readonly log: log.RootLogger;
11
- private constructor();
12
- static instance(): NizzaStore;
13
- configure(config: NizzaConfiguration): Promise<this>;
14
- get config(): NizzaConfiguration | null;
15
- get account(): import("..").NizzaAccount;
16
- get ok(): boolean;
17
- get accountName(): string;
18
- get productDataSource(): NizzaProductDataSource | null;
19
- get eventBus(): BroadcastChannelEventBus;
20
- setProductDataSource(dataSource: NizzaProductDataSource): void;
21
- }
2
+ import { BroadcastChannelEventBus } from '../event-buses';
3
+ import { NizzaConfiguration, NizzaProductDataSource, NizzaState } from '../types';
4
+ export type NizzaStore = ReturnType<typeof createNizza>;
5
+ declare const createNizza: () => {
6
+ log: log.RootLogger;
7
+ state: NizzaState;
8
+ configure: (config: NizzaConfiguration) => Promise<void>;
9
+ setProductDataSource: (dataSource: NizzaProductDataSource) => void;
10
+ instanceId: string;
11
+ eventBus: BroadcastChannelEventBus;
12
+ readonly account: import("../accounts").NizzaAccount | undefined;
13
+ readonly productDataSource: NizzaProductDataSource | undefined;
14
+ };
22
15
  export declare const nizza: NizzaStore;
16
+ export {};
@@ -0,0 +1,22 @@
1
+ import log from 'loglevel';
2
+ import { NizzaConfiguration, NizzaProductDataSource } from '../types';
3
+ import { BroadcastChannelEventBus } from '../event-buses';
4
+ export declare class NizzaStore {
5
+ private static _instance;
6
+ private _productDataSource;
7
+ private _configManager;
8
+ private _eventBus;
9
+ readonly instanceId: string;
10
+ readonly log: log.RootLogger;
11
+ private constructor();
12
+ static instance(): NizzaStore;
13
+ configure(config: NizzaConfiguration): Promise<this>;
14
+ get config(): NizzaConfiguration | null;
15
+ get account(): import("..").NizzaAccount;
16
+ get ok(): boolean;
17
+ get accountName(): string;
18
+ get productDataSource(): NizzaProductDataSource | null;
19
+ get eventBus(): BroadcastChannelEventBus;
20
+ setProductDataSource(dataSource: NizzaProductDataSource): void;
21
+ }
22
+ export declare const nizza: NizzaStore;
@@ -1 +1,10 @@
1
- export declare function validateRequiredProps(): void;
1
+ /**
2
+ * Validates that required properties are defined in a given state object.
3
+ * It supports deep property paths (e.g., 'config.account').
4
+ *
5
+ * @param {Record<string, any>} state - The state object to be validated.
6
+ * @param {string[]} requiredProps - An array of strings representing the property paths to be validated.
7
+ * @throws {InvalidNizzaGlobalObjectError} Throws an error if a required property is missing or invalid.
8
+ * @throws {Error} Throws an error if the input arguments are not valid.
9
+ */
10
+ export declare function validateRequiredProps<T extends Record<string, any>>(state: T, requiredProps: string[]): void;
@@ -1,4 +1,2 @@
1
- export * from './ConfigManager';
2
1
  export * from './NizzaStore';
3
- export * from './event-buses';
4
2
  export * from './helpers';
@@ -1,5 +1,15 @@
1
+ import { NizzaAccount } from '../../accounts';
2
+ import { NizzaProductDataSource } from './productDataSource';
3
+ export type NizzaState = {
4
+ config: NizzaConfiguration | null;
5
+ ok: boolean;
6
+ account?: NizzaAccount;
7
+ accountName?: string;
8
+ productDataSource?: NizzaProductDataSource;
9
+ };
1
10
  export interface NizzaConfiguration {
2
11
  account: string;
12
+ getProductDataSource?: () => Promise<NizzaProductDataSource> | NizzaProductDataSource;
3
13
  }
4
14
  export interface NizzaCredentials {
5
15
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.4.5-alpha.1",
3
+ "version": "0.4.5-alpha.2",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.4.5-alpha.1",
3
+ "version": "0.4.5-alpha.2",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",