@nizza/core 0.4.5-alpha.0 → 0.4.5-alpha.10

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
  */
@@ -6,7 +6,7 @@ export declare class BroadcastChannelEventBus implements EventBus {
6
6
  private channel;
7
7
  private listeners;
8
8
  private eventQueue;
9
- constructor();
9
+ constructor(channelName: string);
10
10
  /**
11
11
  * Subscribe a listener function to a specific event with wildcards.
12
12
  *
@@ -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,5 @@
1
- import { TranslationFiles } from '../types';
2
- export declare function registerTranslations(translationFiles: TranslationFiles): void;
1
+ import { i18n } from 'i18next';
2
+ import { TranslationFiles, Translations } from '../types';
3
+ export declare function buildLanguageTranslations(langTranslations: Record<string, Record<string, string>>): Record<string, string>;
4
+ export declare function buildTranslations(translationFiles: TranslationFiles): Translations;
5
+ export declare function registerTranslationsOf(i18Instance: i18n, translationFiles: TranslationFiles): void;
@@ -1,2 +1,3 @@
1
1
  export * from './buildTranslations';
2
2
  export * from './init';
3
+ export * from './nizza';
@@ -1 +1,2 @@
1
- export declare const i18n: Promise<import("i18next").TFunction<"translation", undefined>>;
1
+ import { i18n } from 'i18next';
2
+ export declare function i18Init(i18Instance: i18n): void;
@@ -0,0 +1,2 @@
1
+ import { TranslationFiles } from '../types';
2
+ export declare const registerTranslations: (translationFiles: TranslationFiles) => void;
@@ -2,6 +2,7 @@ export * from './accounts';
2
2
  export * from './constants';
3
3
  export * from './domain';
4
4
  export * from './errors';
5
+ export * from './event-buses';
5
6
  export * from './i18n';
6
7
  export * from './jotai';
7
8
  export * from './mobx';
@@ -1,2 +1 @@
1
1
  export * from './StoreProvider';
2
- export * from './hooks';
@@ -1,11 +1,11 @@
1
1
  import { NizzaAccount } from '../accounts';
2
- import { NizzaConfiguration } from '../types';
2
+ import { NizzaConfig } from '../types';
3
3
  export declare class ConfigManager {
4
4
  private _config;
5
5
  private _account;
6
6
  constructor();
7
- configure(config: NizzaConfiguration): Promise<void>;
8
- get config(): NizzaConfiguration | null;
7
+ configure(config: NizzaConfig): Promise<void>;
8
+ get config(): NizzaConfig | null;
9
9
  get account(): NizzaAccount;
10
10
  get ok(): boolean;
11
11
  get accountName(): string;
@@ -1,22 +1,4 @@
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
- }
1
+ import { NizzaStore } from '../types';
22
2
  export declare const nizza: NizzaStore;
3
+ export declare const logger: import("loglevel").Logger;
4
+ export declare const coreLogger: import("loglevel").Logger;
@@ -0,0 +1,22 @@
1
+ import log from 'loglevel';
2
+ import { NizzaConfig, 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: NizzaConfig): Promise<this>;
14
+ get config(): NizzaConfig | 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';
@@ -928,6 +928,7 @@ export type GetAllChatMessageQuery = {
928
928
  isAdmin?: boolean | null;
929
929
  urlGif?: string | null;
930
930
  second?: number | null;
931
+ ip?: string | null;
931
932
  }> | null;
932
933
  } | {
933
934
  __typename: 'ErrorGeneral';
@@ -1016,6 +1017,30 @@ export type UpdateCustomizationMutation = {
1016
1017
  timestamp: string;
1017
1018
  };
1018
1019
  };
1020
+ export type GetTimeLineQueryVariables = Exact<{
1021
+ data: GetTimeLineInput;
1022
+ }>;
1023
+ export type GetTimeLineQuery = {
1024
+ __typename?: 'Query';
1025
+ getTimeLine: {
1026
+ __typename: 'ErrorGeneral';
1027
+ message: string;
1028
+ statusCode: string;
1029
+ timestamp: string;
1030
+ } | {
1031
+ __typename: 'TimeLineArray';
1032
+ data?: Array<{
1033
+ __typename?: 'TimeLine';
1034
+ time: string;
1035
+ likes: number;
1036
+ comments: number;
1037
+ viewers: number;
1038
+ orders: number;
1039
+ minute: number;
1040
+ hour: number;
1041
+ }> | null;
1042
+ };
1043
+ };
1019
1044
  export type AppendProductsToSnackVideoMutationVariables = Exact<{
1020
1045
  data: RelateToProductsSnackVideoInput;
1021
1046
  }>;
@@ -1258,6 +1283,9 @@ export declare const GetAllCustomizationDocument: DocumentNode<GetAllCustomizati
1258
1283
  export declare const UpdateCustomizationDocument: DocumentNode<UpdateCustomizationMutation, Exact<{
1259
1284
  data: CustomPlayerInput;
1260
1285
  }>>;
1286
+ export declare const GetTimeLineDocument: DocumentNode<GetTimeLineQuery, Exact<{
1287
+ data: GetTimeLineInput;
1288
+ }>>;
1261
1289
  export declare const AppendProductsToSnackVideoDocument: DocumentNode<AppendProductsToSnackVideoMutation, Exact<{
1262
1290
  data: RelateToProductsSnackVideoInput;
1263
1291
  }>>;
@@ -12,6 +12,7 @@ export interface ChatMessageBase {
12
12
  all?: boolean;
13
13
  urlGif?: string;
14
14
  language?: string;
15
+ ip?: string;
15
16
  }
16
17
  export interface ChatQuestion {
17
18
  data: string;
@@ -0,0 +1,41 @@
1
+ import { NizzaAccount } from '../../accounts';
2
+ import { BroadcastChannelEventBus } from '../../event-buses';
3
+ import { Logger } from '../../utils';
4
+ import { NizzaProductDataSource } from './productDataSource';
5
+ export interface GlobalStoreConfig {
6
+ account: string;
7
+ getProductDataSource?: () => Promise<any> | any;
8
+ }
9
+ export interface GlobalState {
10
+ config: GlobalStoreConfig | null;
11
+ ok: boolean;
12
+ account?: any;
13
+ accountName?: string;
14
+ productDataSource?: any;
15
+ }
16
+ export interface GlobalStore {
17
+ state: GlobalState;
18
+ instanceId: string;
19
+ log: Logger;
20
+ eventBus: BroadcastChannelEventBus;
21
+ readonly account?: any;
22
+ readonly productDataSource?: any;
23
+ configure: (config: GlobalStoreConfig) => Promise<void>;
24
+ setProductDataSource: (dataSource: any) => void;
25
+ }
26
+ export interface NizzaConfig extends GlobalStoreConfig {
27
+ account: string;
28
+ getProductDataSource?: () => Promise<NizzaProductDataSource> | NizzaProductDataSource;
29
+ }
30
+ export interface NizzaState extends GlobalState {
31
+ config: NizzaConfig | null;
32
+ account?: NizzaAccount;
33
+ productDataSource?: NizzaProductDataSource;
34
+ }
35
+ export interface NizzaStore extends GlobalStore {
36
+ state: NizzaState;
37
+ configure: (config: NizzaConfig) => Promise<void>;
38
+ setProductDataSource: (dataSource: NizzaProductDataSource) => void;
39
+ readonly account?: NizzaAccount;
40
+ readonly productDataSource?: NizzaProductDataSource;
41
+ }
@@ -2,6 +2,6 @@ export * from './chat';
2
2
  export * from './eventBus';
3
3
  export * from './main';
4
4
  export * from './nizzaEvent';
5
- export * from './nizzaGlobalObject';
5
+ export * from './globalStore';
6
6
  export * from './product';
7
7
  export * from './productDataSource';
@@ -1,3 +1,7 @@
1
1
  import { NizzaProduct } from './product';
2
- export type NizzaAddToCartHandler = <T extends NizzaProduct>(product: T) => Promise<void>;
2
+ export type NizzaAddToCartHandlerParams = {
3
+ product: NizzaProduct;
4
+ quantity: number;
5
+ };
6
+ export type NizzaAddToCartHandler = (params: NizzaAddToCartHandlerParams) => Promise<void>;
3
7
  export type NizzaSetUTMHandler = (utm: string) => Promise<void>;
@@ -23,6 +23,7 @@ export interface NizzaItem {
23
23
  itemId: string;
24
24
  name: string;
25
25
  images: NizzaImage[];
26
+ variationCode?: string;
26
27
  }
27
28
  export interface NizzaImage {
28
29
  imageUrl: string;
@@ -1,2 +1,7 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ /// <reference types="node" />
1
6
  export declare function downloadFile(filename: string, url: string, ext: string): void;
2
7
  export declare const jsDownload: (data: Blob, filename: string, mime?: string) => boolean | NodeJS.Timeout;
@@ -1,27 +1,7 @@
1
- import { Logger } from 'loglevel';
2
- export declare const logger: Logger;
3
- export declare const coreLogger: Logger;
4
- /**
5
- * Create a LogLevel instance for given context
6
- * @param {string} context - The context to create logger for
7
- * @returns {Logger} LogLevel logger instance
8
- */
9
- export declare function createLogger(context: string): Logger;
10
- /**
11
- * Register a logger instance in registry
12
- * @param {string} context - The context of the logger to register
13
- * @param {Logger} logger - The logger instance
14
- */
15
- export declare function registerLogger(context: string, logger: Logger): void;
16
- /**
17
- * Get a logger instance from registry by context
18
- * @param {string} context - The context to get the logger for
19
- * @returns {Logger} The registered LogLevel logger
20
- */
21
- export declare function getLogger(context: string): Logger;
22
- /**
23
- * Initialize a logger - create, register and return instance
24
- * @param {string} context - The context to initialize logger for
25
- * @returns {Logger} The initialized LogLevel logger instance
26
- */
27
- export declare function initializeLogger(context: string): Logger;
1
+ import { Logger as LogLevelLogger } from 'loglevel';
2
+ export declare class Logger {
3
+ private defaultLevel;
4
+ private namePrefix;
5
+ constructor(namePrefix?: string);
6
+ createLogger(context: string): LogLevelLogger;
7
+ }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.4.5-alpha.0",
3
+ "version": "0.4.5-alpha.10",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",
@@ -9,5 +9,6 @@
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
- "scripts": {}
12
+ "scripts": {},
13
+ "dependencies": {}
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.4.5-alpha.0",
3
+ "version": "0.4.5-alpha.10",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",
@@ -9,5 +9,6 @@
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
+ "dependencies": {},
12
13
  "scripts": {}
13
14
  }
@@ -1,5 +0,0 @@
1
- export interface NizzaConfiguration {
2
- account: string;
3
- }
4
- export interface NizzaCredentials {
5
- }