@cyberskill/shared 1.7.0 → 1.8.0

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.cts CHANGED
@@ -581,7 +581,7 @@ declare class MongooseController<D extends Partial<C_Document>> {
581
581
 
582
582
  declare function useLoading(): I_LoadingContext;
583
583
 
584
- declare function useLocalStorage<T>(key: string, initialValue: T, serializer?: Serializer$1<T>): readonly [T, (value: T | ((val: T) => T)) => Promise<void>];
584
+ declare function useStorage<T>(key: string, initialValue: T, serializer?: Serializer$1<T>): readonly [T, (value: T | ((val: T) => T)) => Promise<void>];
585
585
 
586
586
  declare function ApolloProvider({ options, children }: {
587
587
  options: I_ApolloOptions;
@@ -593,7 +593,7 @@ declare function LoadingProvider({ children }: {
593
593
  }): react_jsx_runtime.JSX.Element;
594
594
 
595
595
  /**
596
- * Save the entire error list to local storage.
596
+ * Save the entire error list to storage.
597
597
  * @param errorList Array of I_ErrorEntry objects.
598
598
  */
599
599
  declare function saveErrorListToStorage(errorList: I_ErrorEntry[]): Promise<void>;
@@ -621,55 +621,6 @@ declare function logProcessStep(message: string, icon?: string): void;
621
621
  declare function parseCommandOutput(output: string): void;
622
622
  declare function executeCommand(command: string, description: string, parser?: typeof parseCommandOutput): Promise<void>;
623
623
 
624
- declare const localStorage: {
625
- /**
626
- * Get the value of a key.
627
- * @param key The key to retrieve.
628
- * @returns A promise that resolves to the value associated with the key, or `null` if the key doesn't exist.
629
- */
630
- get<T = unknown>(key: string): Promise<T | null>;
631
- /**
632
- * Set the value for a key.
633
- * @param key The key to set.
634
- * @param value The value to store. Can be any serializable type.
635
- * @returns A promise that resolves once the value is stored.
636
- */
637
- set<T = unknown>(key: string, value: T): Promise<void>;
638
- /**
639
- * Remove the value associated with a key.
640
- * @param key The key to remove.
641
- * @returns A promise that resolves once the key is removed.
642
- */
643
- remove(key: string): Promise<void>;
644
- /**
645
- * Clear all keys and values in the storage.
646
- * @returns A promise that resolves once the storage is cleared.
647
- */
648
- clear(): Promise<void>;
649
- /**
650
- * Get the name of the key at a specific index.
651
- * @param index The index of the key.
652
- * @returns A promise that resolves to the key name or `null` if the index is out of bounds.
653
- */
654
- key(index: number): Promise<string | null>;
655
- /**
656
- * Get all keys in the storage.
657
- * @returns A promise that resolves to an array of all keys.
658
- */
659
- keys(): Promise<string[]>;
660
- /**
661
- * Get the number of items in the storage.
662
- * @returns A promise that resolves to the number of keys stored.
663
- */
664
- length(): Promise<number>;
665
- /**
666
- * Iterates over all key-value pairs in the storage.
667
- * @param iteratee A callback function that receives the value, key, and iteration number.
668
- * @returns A promise that resolves once iteration is complete.
669
- */
670
- iterate<T = unknown>(iteratee: (value: T, key: string, iterationNumber: number) => void): Promise<void>;
671
- };
672
-
673
624
  declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
674
625
 
675
626
  /**
@@ -712,6 +663,7 @@ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean):
712
663
  * @param packageName Name of the package.
713
664
  */
714
665
  declare function updatePackage(packageName: string): Promise<void>;
666
+ declare function isCurrentProject(INIT_CWD: string, PACKAGE_NAME: string): boolean;
715
667
 
716
668
  interface Serializer<T> {
717
669
  serialize: (value: T) => string;
@@ -719,6 +671,53 @@ interface Serializer<T> {
719
671
  }
720
672
  declare const serializer: Serializer<any>;
721
673
 
674
+ declare const storage: {
675
+ /**
676
+ * Get the value of a key.
677
+ * @param key The key to retrieve.
678
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key doesn't exist.
679
+ */
680
+ get<T = unknown>(key: string): Promise<T | null>;
681
+ /**
682
+ * Set the value for a key.
683
+ * @param key The key to set.
684
+ * @param value The value to store.
685
+ * @returns A promise that resolves once the value is stored.
686
+ */
687
+ set<T = unknown>(key: string, value: T): Promise<void>;
688
+ /**
689
+ * Remove the value associated with a key.
690
+ * @param key The key to remove.
691
+ * @returns A promise that resolves once the key is removed.
692
+ */
693
+ remove(key: string): Promise<void>;
694
+ /**
695
+ * Get all keys in the storage.
696
+ * @returns A promise that resolves to an array of all keys.
697
+ */
698
+ keys(): Promise<string[]>;
699
+ /**
700
+ * Get all values in the storage.
701
+ * @returns A promise that resolves to an array of all values.
702
+ */
703
+ values<T = unknown>(): Promise<T[]>;
704
+ /**
705
+ * Get all entries in the storage as [key, value] tuples.
706
+ * @returns A promise that resolves to an array of entries.
707
+ */
708
+ entries<T = unknown>(): Promise<[string, T][]>;
709
+ /**
710
+ * Clear all keys and values in the storage.
711
+ * @returns A promise that resolves once the storage is cleared.
712
+ */
713
+ clear(): Promise<void>;
714
+ /**
715
+ * Get the number of items in the storage.
716
+ * @returns A promise that resolves to the number of keys stored.
717
+ */
718
+ length(): Promise<number>;
719
+ };
720
+
722
721
  declare const validate: {
723
722
  common: {
724
723
  /**
@@ -756,4 +755,4 @@ declare function isJson(str: string): boolean;
756
755
  declare function regexSearchMapper(str: string): string;
757
756
  declare const removeAccent: (str: string) => string;
758
757
 
759
- export { ApolloProvider, C_Collection, C_Db, C_Document, C_Model, DIRNAME, E_ErrorType, E_SpinnerMessage, type I_ApolloOptions, type I_Config, type I_DeleteOptionsExtended, type I_ErrorEntry, type I_EslintError, type I_ExtendedModel, type I_GenerateModelOptions, type I_GenerateSchemaOptions, type I_GenericDocument, type I_GraphqlCodegenConfig, type I_HookNextFunction, type I_Input_CreateMany, type I_Input_CreateOne, type I_Input_DeleteMany, type I_Input_DeleteOne, type I_Input_FindAll, type I_Input_FindOne, type I_Input_FindPaging, type I_Input_FindPagingAggregate, type I_Input_UpdateMany, type I_Input_UpdateOne, type I_LoadingContext, type I_LoadingProps, type I_MongooseModelMiddleware, type I_MongooseOptions, type I_Return, type I_ReturnFailure, type I_ReturnSuccess, type I_SlugifyOptions, type I_SpinnerOptions, type I_UpdateOptionsExtended, Loading, LoadingContext, LoadingProvider, MigrationController, MongooseController, RESPONSE_STATUS, type Serializer$1 as Serializer, type T_AggregatePaginateResult, type T_Children, type T_DeleteResult, type T_Filter, type T_FilterQuery, type T_GenerateSlugQueryResponse, type T_Input_MongooseSchema, type T_Input_Populate, type T_InsertManyOptions, type T_InsertManyResult, type T_InsertOneResult, type T_MiddlewareContext, type T_MongooseModelMiddlewareFunction, type T_MongoosePlugin, type T_MongooseShema, type T_OptionalUnlessRequiredId, type T_PaginateOptions, type T_PaginateOptionsWithPopulate, type T_PaginateResult, type T_PipelineStage, type T_PopulateOption, type T_PopulateOptions, type T_ProjectionType, type T_QueryOptions, type T_ThrowResponseArgs, type T_UpdateQuery, type T_UpdateResult, type T_WithId, clearExpiredErrorLists, deepMerge, displayResults, executeCommand, generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getLatestPackageVersion, getStoredErrorLists, isJson, isPackageOutdated, localStorage, logProcessStep, regexSearchMapper, removeAccent, runWithSpinner, saveErrorListToStorage, serializer, throwResponse, updatePackage, useLoading, useLocalStorage, validate };
758
+ export { ApolloProvider, C_Collection, C_Db, C_Document, C_Model, DIRNAME, E_ErrorType, E_SpinnerMessage, type I_ApolloOptions, type I_Config, type I_DeleteOptionsExtended, type I_ErrorEntry, type I_EslintError, type I_ExtendedModel, type I_GenerateModelOptions, type I_GenerateSchemaOptions, type I_GenericDocument, type I_GraphqlCodegenConfig, type I_HookNextFunction, type I_Input_CreateMany, type I_Input_CreateOne, type I_Input_DeleteMany, type I_Input_DeleteOne, type I_Input_FindAll, type I_Input_FindOne, type I_Input_FindPaging, type I_Input_FindPagingAggregate, type I_Input_UpdateMany, type I_Input_UpdateOne, type I_LoadingContext, type I_LoadingProps, type I_MongooseModelMiddleware, type I_MongooseOptions, type I_Return, type I_ReturnFailure, type I_ReturnSuccess, type I_SlugifyOptions, type I_SpinnerOptions, type I_UpdateOptionsExtended, Loading, LoadingContext, LoadingProvider, MigrationController, MongooseController, RESPONSE_STATUS, type Serializer$1 as Serializer, type T_AggregatePaginateResult, type T_Children, type T_DeleteResult, type T_Filter, type T_FilterQuery, type T_GenerateSlugQueryResponse, type T_Input_MongooseSchema, type T_Input_Populate, type T_InsertManyOptions, type T_InsertManyResult, type T_InsertOneResult, type T_MiddlewareContext, type T_MongooseModelMiddlewareFunction, type T_MongoosePlugin, type T_MongooseShema, type T_OptionalUnlessRequiredId, type T_PaginateOptions, type T_PaginateOptionsWithPopulate, type T_PaginateResult, type T_PipelineStage, type T_PopulateOption, type T_PopulateOptions, type T_ProjectionType, type T_QueryOptions, type T_ThrowResponseArgs, type T_UpdateQuery, type T_UpdateResult, type T_WithId, clearExpiredErrorLists, deepMerge, displayResults, executeCommand, generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getLatestPackageVersion, getStoredErrorLists, isCurrentProject, isJson, isPackageOutdated, logProcessStep, regexSearchMapper, removeAccent, runWithSpinner, saveErrorListToStorage, serializer, storage, throwResponse, updatePackage, useLoading, useStorage, validate };
package/dist/index.d.ts CHANGED
@@ -581,7 +581,7 @@ declare class MongooseController<D extends Partial<C_Document>> {
581
581
 
582
582
  declare function useLoading(): I_LoadingContext;
583
583
 
584
- declare function useLocalStorage<T>(key: string, initialValue: T, serializer?: Serializer$1<T>): readonly [T, (value: T | ((val: T) => T)) => Promise<void>];
584
+ declare function useStorage<T>(key: string, initialValue: T, serializer?: Serializer$1<T>): readonly [T, (value: T | ((val: T) => T)) => Promise<void>];
585
585
 
586
586
  declare function ApolloProvider({ options, children }: {
587
587
  options: I_ApolloOptions;
@@ -593,7 +593,7 @@ declare function LoadingProvider({ children }: {
593
593
  }): react_jsx_runtime.JSX.Element;
594
594
 
595
595
  /**
596
- * Save the entire error list to local storage.
596
+ * Save the entire error list to storage.
597
597
  * @param errorList Array of I_ErrorEntry objects.
598
598
  */
599
599
  declare function saveErrorListToStorage(errorList: I_ErrorEntry[]): Promise<void>;
@@ -621,55 +621,6 @@ declare function logProcessStep(message: string, icon?: string): void;
621
621
  declare function parseCommandOutput(output: string): void;
622
622
  declare function executeCommand(command: string, description: string, parser?: typeof parseCommandOutput): Promise<void>;
623
623
 
624
- declare const localStorage: {
625
- /**
626
- * Get the value of a key.
627
- * @param key The key to retrieve.
628
- * @returns A promise that resolves to the value associated with the key, or `null` if the key doesn't exist.
629
- */
630
- get<T = unknown>(key: string): Promise<T | null>;
631
- /**
632
- * Set the value for a key.
633
- * @param key The key to set.
634
- * @param value The value to store. Can be any serializable type.
635
- * @returns A promise that resolves once the value is stored.
636
- */
637
- set<T = unknown>(key: string, value: T): Promise<void>;
638
- /**
639
- * Remove the value associated with a key.
640
- * @param key The key to remove.
641
- * @returns A promise that resolves once the key is removed.
642
- */
643
- remove(key: string): Promise<void>;
644
- /**
645
- * Clear all keys and values in the storage.
646
- * @returns A promise that resolves once the storage is cleared.
647
- */
648
- clear(): Promise<void>;
649
- /**
650
- * Get the name of the key at a specific index.
651
- * @param index The index of the key.
652
- * @returns A promise that resolves to the key name or `null` if the index is out of bounds.
653
- */
654
- key(index: number): Promise<string | null>;
655
- /**
656
- * Get all keys in the storage.
657
- * @returns A promise that resolves to an array of all keys.
658
- */
659
- keys(): Promise<string[]>;
660
- /**
661
- * Get the number of items in the storage.
662
- * @returns A promise that resolves to the number of keys stored.
663
- */
664
- length(): Promise<number>;
665
- /**
666
- * Iterates over all key-value pairs in the storage.
667
- * @param iteratee A callback function that receives the value, key, and iteration number.
668
- * @returns A promise that resolves once iteration is complete.
669
- */
670
- iterate<T = unknown>(iteratee: (value: T, key: string, iterationNumber: number) => void): Promise<void>;
671
- };
672
-
673
624
  declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
674
625
 
675
626
  /**
@@ -712,6 +663,7 @@ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean):
712
663
  * @param packageName Name of the package.
713
664
  */
714
665
  declare function updatePackage(packageName: string): Promise<void>;
666
+ declare function isCurrentProject(INIT_CWD: string, PACKAGE_NAME: string): boolean;
715
667
 
716
668
  interface Serializer<T> {
717
669
  serialize: (value: T) => string;
@@ -719,6 +671,53 @@ interface Serializer<T> {
719
671
  }
720
672
  declare const serializer: Serializer<any>;
721
673
 
674
+ declare const storage: {
675
+ /**
676
+ * Get the value of a key.
677
+ * @param key The key to retrieve.
678
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key doesn't exist.
679
+ */
680
+ get<T = unknown>(key: string): Promise<T | null>;
681
+ /**
682
+ * Set the value for a key.
683
+ * @param key The key to set.
684
+ * @param value The value to store.
685
+ * @returns A promise that resolves once the value is stored.
686
+ */
687
+ set<T = unknown>(key: string, value: T): Promise<void>;
688
+ /**
689
+ * Remove the value associated with a key.
690
+ * @param key The key to remove.
691
+ * @returns A promise that resolves once the key is removed.
692
+ */
693
+ remove(key: string): Promise<void>;
694
+ /**
695
+ * Get all keys in the storage.
696
+ * @returns A promise that resolves to an array of all keys.
697
+ */
698
+ keys(): Promise<string[]>;
699
+ /**
700
+ * Get all values in the storage.
701
+ * @returns A promise that resolves to an array of all values.
702
+ */
703
+ values<T = unknown>(): Promise<T[]>;
704
+ /**
705
+ * Get all entries in the storage as [key, value] tuples.
706
+ * @returns A promise that resolves to an array of entries.
707
+ */
708
+ entries<T = unknown>(): Promise<[string, T][]>;
709
+ /**
710
+ * Clear all keys and values in the storage.
711
+ * @returns A promise that resolves once the storage is cleared.
712
+ */
713
+ clear(): Promise<void>;
714
+ /**
715
+ * Get the number of items in the storage.
716
+ * @returns A promise that resolves to the number of keys stored.
717
+ */
718
+ length(): Promise<number>;
719
+ };
720
+
722
721
  declare const validate: {
723
722
  common: {
724
723
  /**
@@ -756,4 +755,4 @@ declare function isJson(str: string): boolean;
756
755
  declare function regexSearchMapper(str: string): string;
757
756
  declare const removeAccent: (str: string) => string;
758
757
 
759
- export { ApolloProvider, C_Collection, C_Db, C_Document, C_Model, DIRNAME, E_ErrorType, E_SpinnerMessage, type I_ApolloOptions, type I_Config, type I_DeleteOptionsExtended, type I_ErrorEntry, type I_EslintError, type I_ExtendedModel, type I_GenerateModelOptions, type I_GenerateSchemaOptions, type I_GenericDocument, type I_GraphqlCodegenConfig, type I_HookNextFunction, type I_Input_CreateMany, type I_Input_CreateOne, type I_Input_DeleteMany, type I_Input_DeleteOne, type I_Input_FindAll, type I_Input_FindOne, type I_Input_FindPaging, type I_Input_FindPagingAggregate, type I_Input_UpdateMany, type I_Input_UpdateOne, type I_LoadingContext, type I_LoadingProps, type I_MongooseModelMiddleware, type I_MongooseOptions, type I_Return, type I_ReturnFailure, type I_ReturnSuccess, type I_SlugifyOptions, type I_SpinnerOptions, type I_UpdateOptionsExtended, Loading, LoadingContext, LoadingProvider, MigrationController, MongooseController, RESPONSE_STATUS, type Serializer$1 as Serializer, type T_AggregatePaginateResult, type T_Children, type T_DeleteResult, type T_Filter, type T_FilterQuery, type T_GenerateSlugQueryResponse, type T_Input_MongooseSchema, type T_Input_Populate, type T_InsertManyOptions, type T_InsertManyResult, type T_InsertOneResult, type T_MiddlewareContext, type T_MongooseModelMiddlewareFunction, type T_MongoosePlugin, type T_MongooseShema, type T_OptionalUnlessRequiredId, type T_PaginateOptions, type T_PaginateOptionsWithPopulate, type T_PaginateResult, type T_PipelineStage, type T_PopulateOption, type T_PopulateOptions, type T_ProjectionType, type T_QueryOptions, type T_ThrowResponseArgs, type T_UpdateQuery, type T_UpdateResult, type T_WithId, clearExpiredErrorLists, deepMerge, displayResults, executeCommand, generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getLatestPackageVersion, getStoredErrorLists, isJson, isPackageOutdated, localStorage, logProcessStep, regexSearchMapper, removeAccent, runWithSpinner, saveErrorListToStorage, serializer, throwResponse, updatePackage, useLoading, useLocalStorage, validate };
758
+ export { ApolloProvider, C_Collection, C_Db, C_Document, C_Model, DIRNAME, E_ErrorType, E_SpinnerMessage, type I_ApolloOptions, type I_Config, type I_DeleteOptionsExtended, type I_ErrorEntry, type I_EslintError, type I_ExtendedModel, type I_GenerateModelOptions, type I_GenerateSchemaOptions, type I_GenericDocument, type I_GraphqlCodegenConfig, type I_HookNextFunction, type I_Input_CreateMany, type I_Input_CreateOne, type I_Input_DeleteMany, type I_Input_DeleteOne, type I_Input_FindAll, type I_Input_FindOne, type I_Input_FindPaging, type I_Input_FindPagingAggregate, type I_Input_UpdateMany, type I_Input_UpdateOne, type I_LoadingContext, type I_LoadingProps, type I_MongooseModelMiddleware, type I_MongooseOptions, type I_Return, type I_ReturnFailure, type I_ReturnSuccess, type I_SlugifyOptions, type I_SpinnerOptions, type I_UpdateOptionsExtended, Loading, LoadingContext, LoadingProvider, MigrationController, MongooseController, RESPONSE_STATUS, type Serializer$1 as Serializer, type T_AggregatePaginateResult, type T_Children, type T_DeleteResult, type T_Filter, type T_FilterQuery, type T_GenerateSlugQueryResponse, type T_Input_MongooseSchema, type T_Input_Populate, type T_InsertManyOptions, type T_InsertManyResult, type T_InsertOneResult, type T_MiddlewareContext, type T_MongooseModelMiddlewareFunction, type T_MongoosePlugin, type T_MongooseShema, type T_OptionalUnlessRequiredId, type T_PaginateOptions, type T_PaginateOptionsWithPopulate, type T_PaginateResult, type T_PipelineStage, type T_PopulateOption, type T_PopulateOptions, type T_ProjectionType, type T_QueryOptions, type T_ThrowResponseArgs, type T_UpdateQuery, type T_UpdateResult, type T_WithId, clearExpiredErrorLists, deepMerge, displayResults, executeCommand, generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getLatestPackageVersion, getStoredErrorLists, isCurrentProject, isJson, isPackageOutdated, logProcessStep, regexSearchMapper, removeAccent, runWithSpinner, saveErrorListToStorage, serializer, storage, throwResponse, updatePackage, useLoading, useStorage, validate };