@rebasepro/common 0.0.1-canary.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/collections/CollectionRegistry.d.ts +48 -0
  4. package/dist/collections/index.d.ts +1 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.es.js +2380 -0
  7. package/dist/index.es.js.map +1 -0
  8. package/dist/index.umd.js +2379 -0
  9. package/dist/index.umd.js.map +1 -0
  10. package/dist/util/arrays.d.ts +1 -0
  11. package/dist/util/builders.d.ts +64 -0
  12. package/dist/util/callbacks.d.ts +6 -0
  13. package/dist/util/collections.d.ts +11 -0
  14. package/dist/util/common.d.ts +2 -0
  15. package/dist/util/conditions.d.ts +26 -0
  16. package/dist/util/dates.d.ts +1 -0
  17. package/dist/util/entities.d.ts +28 -0
  18. package/dist/util/entity_actions.d.ts +2 -0
  19. package/dist/util/enums.d.ts +3 -0
  20. package/dist/util/fields.d.ts +2 -0
  21. package/dist/util/flatten_object.d.ts +5 -0
  22. package/dist/util/hash.d.ts +1 -0
  23. package/dist/util/index.d.ts +26 -0
  24. package/dist/util/names.d.ts +22 -0
  25. package/dist/util/navigation_from_path.d.ts +29 -0
  26. package/dist/util/navigation_utils.d.ts +31 -0
  27. package/dist/util/objects.d.ts +26 -0
  28. package/dist/util/os.d.ts +2 -0
  29. package/dist/util/parent_references_from_path.d.ts +6 -0
  30. package/dist/util/paths.d.ts +14 -0
  31. package/dist/util/permissions.d.ts +5 -0
  32. package/dist/util/permissions.test.d.ts +1 -0
  33. package/dist/util/plurals.d.ts +16 -0
  34. package/dist/util/references.d.ts +2 -0
  35. package/dist/util/regexp.d.ts +7 -0
  36. package/dist/util/relations.d.ts +12 -0
  37. package/dist/util/resolutions.d.ts +74 -0
  38. package/dist/util/storage.d.ts +24 -0
  39. package/dist/util/strings.d.ts +7 -0
  40. package/package.json +118 -0
  41. package/src/collections/CollectionRegistry.ts +319 -0
  42. package/src/collections/index.ts +1 -0
  43. package/src/index.ts +2 -0
  44. package/src/util/arrays.ts +3 -0
  45. package/src/util/builders.ts +138 -0
  46. package/src/util/callbacks.ts +115 -0
  47. package/src/util/collections.ts +126 -0
  48. package/src/util/common.ts +2 -0
  49. package/src/util/conditions.ts +348 -0
  50. package/src/util/dates.ts +1 -0
  51. package/src/util/entities.ts +212 -0
  52. package/src/util/entity_actions.ts +28 -0
  53. package/src/util/enums.ts +26 -0
  54. package/src/util/fields.ts +28 -0
  55. package/src/util/flatten_object.ts +45 -0
  56. package/src/util/hash.ts +11 -0
  57. package/src/util/index.ts +26 -0
  58. package/src/util/names.ts +30 -0
  59. package/src/util/navigation_from_path.ts +121 -0
  60. package/src/util/navigation_utils.ts +222 -0
  61. package/src/util/objects.ts +376 -0
  62. package/src/util/os.ts +13 -0
  63. package/src/util/parent_references_from_path.ts +57 -0
  64. package/src/util/paths.ts +27 -0
  65. package/src/util/permissions.test.ts +716 -0
  66. package/src/util/permissions.ts +235 -0
  67. package/src/util/plurals.ts +188 -0
  68. package/src/util/references.ts +34 -0
  69. package/src/util/regexp.ts +32 -0
  70. package/src/util/relations.ts +211 -0
  71. package/src/util/resolutions.ts +383 -0
  72. package/src/util/storage.ts +144 -0
  73. package/src/util/strings.ts +84 -0
@@ -0,0 +1,11 @@
1
+ import { DefaultSelectedViewBuilder, DefaultSelectedViewParams, EntityCollection, Properties } from "@rebasepro/types";
2
+ export declare function sortProperties<M extends Record<string, any>>(properties: Properties, propertiesOrder?: string[]): Properties;
3
+ export declare function resolveDefaultSelectedView(defaultSelectedView: string | DefaultSelectedViewBuilder | undefined, params: DefaultSelectedViewParams): string | undefined;
4
+ export declare function getLocalChangesBackup(collection: EntityCollection): "manual_apply" | "auto_apply";
5
+ /**
6
+ * Returns the primary keys for an entity collection by inspecting the properties
7
+ * and finding any properties with `isId`.
8
+ * Fallbacks to `["id"]` if no properties are marked as `isId: true`.
9
+ * @param collection
10
+ */
11
+ export declare function getPrimaryKeys<M extends Record<string, any>>(collection: EntityCollection<M>): Extract<keyof M, string>[];
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_ONE_OF_TYPE = "type";
2
+ export declare const DEFAULT_ONE_OF_VALUE = "value";
@@ -0,0 +1,26 @@
1
+ import { AuthController, ConditionContext, JsonLogicRule, Property } from "@rebasepro/types";
2
+ /**
3
+ * Register custom JSON Logic operations for Rebase.
4
+ * Call this once at app initialization.
5
+ */
6
+ export declare function registerConditionOperations(): void;
7
+ /**
8
+ * Evaluate a JSON Logic rule against the given context.
9
+ */
10
+ export declare function evaluateCondition(rule: JsonLogicRule, context: ConditionContext): unknown;
11
+ /**
12
+ * Build a ConditionContext from the current property resolution context.
13
+ */
14
+ export declare function buildConditionContext(params: {
15
+ propertyKey?: string;
16
+ values?: Record<string, unknown>;
17
+ previousValues?: Record<string, unknown>;
18
+ path: string;
19
+ entityId?: string;
20
+ index?: number;
21
+ authController: AuthController;
22
+ }): ConditionContext;
23
+ /**
24
+ * Apply PropertyConditions to a resolved property, evaluating all JSON Logic rules.
25
+ */
26
+ export declare function applyPropertyConditions(property: Property, context: ConditionContext): Property;
@@ -0,0 +1 @@
1
+ export declare const defaultDateFormat = "MMMM dd, yyyy, HH:mm:ss";
@@ -0,0 +1,28 @@
1
+ import { DataType, Entity, EntityReference, EntityRelation, EntityStatus, EntityValues, Properties, Property } from "@rebasepro/types";
2
+ export declare function isReadOnly(property: Property): boolean;
3
+ export declare function isHidden(property: Property): boolean;
4
+ export declare function isPropertyBuilder(property?: Property): boolean;
5
+ export declare function getDefaultValuesFor<M extends Record<string, any>>(properties: Properties): Partial<EntityValues<M>>;
6
+ export declare function getDefaultValueFor(property?: Property): {} | null | undefined;
7
+ export declare function getDefaultValueFortype(type: DataType): {} | null;
8
+ /**
9
+ * Update the automatic values in an entity before save
10
+ * @group Datasource
11
+ */
12
+ export declare function updateDateAutoValues<M extends Record<string, any>>({ inputValues, properties, status, timestampNowValue }: {
13
+ inputValues: Partial<EntityValues<M>>;
14
+ properties: Properties;
15
+ status: EntityStatus;
16
+ timestampNowValue: unknown;
17
+ }): EntityValues<M>;
18
+ /**
19
+ * Add missing required fields, expected in the collection, to the values of an entity
20
+ * @param values
21
+ * @param properties
22
+ * @group Datasource
23
+ */
24
+ export declare function sanitizeData<M extends Record<string, any>>(values: EntityValues<M>, properties: Properties): Record<string, unknown>;
25
+ export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference;
26
+ export declare function getRelationFrom<M extends Record<string, any>>(entity: Entity<M>): EntityRelation;
27
+ export declare function traverseValuesProperties<M extends Record<string, any>>(inputValues: Partial<EntityValues<M>>, properties: Properties, operation: (value: unknown, property: Property) => unknown): EntityValues<M> | undefined;
28
+ export declare function traverseValueProperty(inputValue: unknown, property: Property, operation: (value: unknown, property: Property) => unknown): unknown;
@@ -0,0 +1,2 @@
1
+ import { EntityAction } from "@rebasepro/types";
2
+ export declare function mergeEntityActions(currentActions: EntityAction[], newActions: EntityAction[]): EntityAction[];
@@ -0,0 +1,3 @@
1
+ import { EnumValueConfig, EnumValues } from "@rebasepro/types";
2
+ export declare function enumToObjectEntries(enumValues: EnumValues): EnumValueConfig[];
3
+ export declare function getLabelOrConfigFrom(enumValues: EnumValueConfig[], key?: string | number): EnumValueConfig | undefined;
@@ -0,0 +1,2 @@
1
+ import { DefaultFieldConfig } from "@rebasepro/types";
2
+ export declare function isDefaultFieldConfigId(id: string): id is DefaultFieldConfig;
@@ -0,0 +1,5 @@
1
+ export declare function flattenObject(obj: Record<string, unknown>, parentKey?: string): {
2
+ [key: string]: unknown;
3
+ };
4
+ export type ArrayValuesCount = Record<string, number>;
5
+ export declare function getArrayValuesCount(array: Record<string, unknown>[]): ArrayValuesCount;
@@ -0,0 +1 @@
1
+ export declare function hashString(str: string): number;
@@ -0,0 +1,26 @@
1
+ export * from "./collections";
2
+ export * from "./common";
3
+ export * from "./entities";
4
+ export * from "./strings";
5
+ export * from "./dates";
6
+ export * from "./enums";
7
+ export * from "./objects";
8
+ export * from "./paths";
9
+ export * from "./regexp";
10
+ export * from "./navigation_utils";
11
+ export * from "./entity_actions";
12
+ export * from "./fields";
13
+ export * from "./resolutions";
14
+ export * from "./permissions";
15
+ export * from "./plurals";
16
+ export * from "./references";
17
+ export * from "./flatten_object";
18
+ export * from "./navigation_from_path";
19
+ export * from "./parent_references_from_path";
20
+ export * from "./builders";
21
+ export * from "./storage";
22
+ export * from "./arrays";
23
+ export * from "./callbacks";
24
+ export * from "./hash";
25
+ export * from "./relations";
26
+ export * from "./conditions";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generates a foreign key column name from a given string, typically a collection slug or name.
3
+ * It converts the name to snake_case, attempts to singularize it by removing a trailing 's'
4
+ * (a common convention for collection names), and appends '_id'.
5
+ *
6
+ * @param name The base name to convert to a foreign key.
7
+ * @returns A foreign key name in the format 'singular_name_id'.
8
+ *
9
+ * @example
10
+ * // returns "user_id"
11
+ * generateForeignKeyName("users")
12
+ *
13
+ * @example
14
+ * // returns "post_id"
15
+ * generateForeignKeyName("posts")
16
+ *
17
+ * @example
18
+ * // returns "product_id"
19
+ * generateForeignKeyName("Product")
20
+ *
21
+ */
22
+ export declare function generateForeignKeyName(name: string): string;
@@ -0,0 +1,29 @@
1
+ import { EntityCollection, EntityCustomView } from "@rebasepro/types";
2
+ export type NavigationViewInternal<M extends Record<string, any> = any> = NavigationViewEntityInternal<M> | NavigationViewCollectionInternal<M> | NavigationViewEntityCustomInternal<M>;
3
+ export interface NavigationViewEntityInternal<M extends Record<string, any>> {
4
+ type: "entity";
5
+ entityId: string | number;
6
+ slug: string;
7
+ path: string;
8
+ parentCollection: EntityCollection<M>;
9
+ }
10
+ export interface NavigationViewCollectionInternal<M extends Record<string, any>> {
11
+ type: "collection";
12
+ id: string;
13
+ slug: string;
14
+ path: string;
15
+ collection: EntityCollection<M>;
16
+ }
17
+ export interface NavigationViewEntityCustomInternal<M extends Record<string, any>> {
18
+ type: "custom_view";
19
+ slug: string;
20
+ path: string;
21
+ entityId: string | number;
22
+ view: EntityCustomView<M>;
23
+ }
24
+ export declare function getNavigationEntriesFromPath(props: {
25
+ path: string;
26
+ collections: EntityCollection[] | undefined;
27
+ currentFullPath?: string;
28
+ contextEntityViews?: EntityCustomView[];
29
+ }): NavigationViewInternal[];
@@ -0,0 +1,31 @@
1
+ import { EntityCollection, CMSUrlController, SideEntityController } from "@rebasepro/types";
2
+ export declare function removeInitialAndTrailingSlashes(s: string): string;
3
+ export declare function removeInitialSlash(s: string): string;
4
+ export declare function removeTrailingSlash(s: string): string;
5
+ export declare function addInitialSlash(s: string): string;
6
+ export declare function getLastSegment(path: string): string;
7
+ export declare function resolveCollectionPathIds(path: string, allCollections: EntityCollection[]): string;
8
+ /**
9
+ * Find the corresponding view at any depth for a given path.
10
+ * Note that path or segments of the paths can be collection aliases.
11
+ * @param slugOrPath
12
+ * @param collections
13
+ */
14
+ export declare function getCollectionBySlugWithin(slugOrPath: string, collections: EntityCollection[]): EntityCollection | undefined;
15
+ /**
16
+ * Get the subcollection combinations from a path:
17
+ * "sites/es/locales" => ["sites/es/locales", "sites"]
18
+ * @param subpaths
19
+ */
20
+ export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
21
+ export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, selectedTab, sideEntityController, onClose, navigation }: {
22
+ openEntityMode: "side_panel" | "full_screen";
23
+ collection?: EntityCollection;
24
+ entityId?: string | number;
25
+ selectedTab?: string;
26
+ copy?: boolean;
27
+ path: string;
28
+ sideEntityController: SideEntityController;
29
+ onClose?: () => void;
30
+ navigation: CMSUrlController;
31
+ }): void;
@@ -0,0 +1,26 @@
1
+ /** @private is the value an empty array? */
2
+ export declare const isEmptyArray: (value?: unknown) => boolean;
3
+ /** @private is the given object a Function? */
4
+ export declare const isFunction: (obj: unknown) => obj is Function;
5
+ /** @private is the given object an integer? */
6
+ export declare const isInteger: (obj: unknown) => boolean;
7
+ /** @private is the given object a NaN? */
8
+ export declare const isNaN: (obj: unknown) => boolean;
9
+ /**
10
+ * Deeply get a value from an object via its path.
11
+ */
12
+ export declare function getIn(obj: Record<string, unknown> | unknown[] | unknown, key: string | string[], def?: unknown, p?: number): unknown;
13
+ export declare function setIn<T>(obj: T, path: string, value: unknown): T;
14
+ export declare function clone<T>(value: T): T;
15
+ export declare const pick: <T extends Record<string, unknown>>(obj: T, ...args: (keyof T)[]) => Partial<T>;
16
+ export declare function isObject(item: unknown): item is Record<string, unknown>;
17
+ export declare function isPlainObject(obj: unknown): obj is Record<string, unknown>;
18
+ export declare function mergeDeep<T extends Record<string, any>, U extends Record<string, any>>(target: T, source: U, ignoreUndefined?: boolean): T & U;
19
+ export declare function getValueInPath(o: object | undefined, path: string): unknown;
20
+ export declare function removeInPath(o: object, path: string): object | undefined;
21
+ export declare function removeFunctions(o: unknown): unknown;
22
+ export declare function getHashValue<T>(v: T): string | null;
23
+ export declare function removeUndefined(value: unknown, removeEmptyStrings?: boolean): unknown;
24
+ export declare function removeNulls(value: unknown): unknown;
25
+ export declare function isEmptyObject(obj: object): boolean;
26
+ export declare function removePropsIfExisting(source: Record<string, unknown> | unknown[], comparison: Record<string, unknown> | unknown[]): Record<string, unknown> | unknown[];
@@ -0,0 +1,2 @@
1
+ export declare function getOS(): string;
2
+ export declare function getAltSymbol(): "⌥" | "Alt";
@@ -0,0 +1,6 @@
1
+ import { EntityCollection, EntityReference } from "@rebasepro/types";
2
+ export declare function getParentReferencesFromPath(props: {
3
+ path: string;
4
+ collections: EntityCollection[] | undefined;
5
+ currentFullPath?: string;
6
+ }): EntityReference[];
@@ -0,0 +1,14 @@
1
+ export declare const COLLECTION_PATH_SEPARATOR = "::";
2
+ /**
3
+ * Remove the entity ids from a given path
4
+ * `products/B44RG6APH/locales` => `products::locales`
5
+ * @param path
6
+ */
7
+ export declare function stripCollectionPath(path: string): string;
8
+ export declare function segmentsToStrippedPath(paths: string[]): string;
9
+ /**
10
+ * Extract the collection path routes
11
+ * `products/B44RG6APH/locales` => [`products`, `locales`]
12
+ * @param path
13
+ */
14
+ export declare function fullPathToCollectionSegments(path: string): string[];
@@ -0,0 +1,5 @@
1
+ import { AuthController, Entity, EntityCollection, User } from "@rebasepro/types";
2
+ export declare function canReadCollection<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>): boolean;
3
+ export declare function canEditEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
4
+ export declare function canCreateEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
5
+ export declare function canDeleteEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Returns the plural of an English word.
3
+ *
4
+ * @param {string} word
5
+ * @param {number} [amount]
6
+ * @returns {string}
7
+ */
8
+ export declare function plural(word: string, amount?: number): string;
9
+ /**
10
+ * Returns the singular of an English word.
11
+ *
12
+ * @param {string} word
13
+ * @param {number} [amount]
14
+ * @returns {string}
15
+ */
16
+ export declare function singular(word: string, amount?: number): string;
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@rebasepro/types";
2
+ export declare function getEntityImagePreviewPropertyKey<M extends object>(collection: EntityCollection<M>): string | undefined;
@@ -0,0 +1,7 @@
1
+ export declare function serializeRegExp(input: RegExp): string;
2
+ /**
3
+ * Get a RegExp out of a serialized string
4
+ * @param input
5
+ */
6
+ export declare function hydrateRegExp(input?: string): RegExp | undefined;
7
+ export declare function isValidRegExp(input: string): boolean;
@@ -0,0 +1,12 @@
1
+ import { EntityCollection, Property, Relation } from "@rebasepro/types";
2
+ export declare function sanitizeRelation(relation: Partial<Relation>, sourceCollection: EntityCollection): Relation;
3
+ export declare function resolveCollectionRelations(collection: EntityCollection): Record<string, Relation>;
4
+ export declare function resolvePropertyRelation({ propertyKey, property, sourceCollection }: {
5
+ propertyKey: string;
6
+ property: Property;
7
+ sourceCollection: EntityCollection;
8
+ }): Relation | undefined;
9
+ export declare function getTableName(collection: EntityCollection): string;
10
+ export declare function getTableVarName(tableName: string): string;
11
+ export declare function getEnumVarName(tableName: string, propName: string): string;
12
+ export declare function getColumnName(fullColumn: string): string;
@@ -0,0 +1,74 @@
1
+ import { ArrayProperty, AuthController, CustomizationController, EntityAction, EntityCollection, EntityCustomView, EnumValueConfig, EnumValues, NumberProperty, Properties, Property, PropertyConfig, Relation, RelationProperty, StringProperty } from "@rebasepro/types";
2
+ /**
3
+ * Resolve property builders, enums and arrays.
4
+ */
5
+ export type ResolvePropertyProps<M extends Record<string, any> = any> = {
6
+ property: Property;
7
+ propertyKey?: string;
8
+ values?: Partial<M>;
9
+ previousValues?: Partial<M>;
10
+ path?: string;
11
+ entityId?: string | number;
12
+ index?: number;
13
+ propertyConfigs?: Record<string, PropertyConfig>;
14
+ ignoreMissingFields?: boolean;
15
+ authController: AuthController;
16
+ };
17
+ export declare function resolveProperty<M extends Record<string, any> = any>(props: ResolvePropertyProps<M>): Property | null;
18
+ export declare function resolveRelationProperty(property: RelationProperty, relations: Relation[]): RelationProperty;
19
+ /**
20
+ * Resolve enum aliases for a string or number property
21
+ * @param property
22
+ */
23
+ export declare function resolvePropertyEnum(property: StringProperty | NumberProperty): StringProperty | NumberProperty;
24
+ /**
25
+ * Resolve enums and arrays for properties
26
+ * @param properties
27
+ * @param value
28
+ */
29
+ export declare function resolveProperties<M extends Record<string, any>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
30
+ propertyKey?: string;
31
+ properties: Properties;
32
+ values?: Partial<M>;
33
+ previousValues?: Partial<M>;
34
+ path?: string;
35
+ entityId?: string | number;
36
+ index?: number;
37
+ propertyConfigs?: Record<string, PropertyConfig>;
38
+ ignoreMissingFields?: boolean;
39
+ authController: AuthController;
40
+ }): Properties;
41
+ export declare function resolveArrayProperties<M>({ propertyKey, property, ignoreMissingFields, ...props }: {
42
+ propertyKey?: string;
43
+ property: ArrayProperty;
44
+ values?: Partial<M>;
45
+ previousValues?: Partial<M>;
46
+ path?: string;
47
+ entityId?: string | number;
48
+ index?: number;
49
+ propertyConfigs?: Record<string, PropertyConfig>;
50
+ ignoreMissingFields?: boolean;
51
+ authController: AuthController;
52
+ }): Property[];
53
+ export declare function getArrayResolvedProperties({ propertyKey, propertyValue, property, ...props }: {
54
+ propertyValue: unknown;
55
+ propertyKey?: string;
56
+ property: ArrayProperty;
57
+ ignoreMissingFields: boolean;
58
+ values?: object;
59
+ previousValues?: object;
60
+ path?: string;
61
+ entityId?: string | number;
62
+ index?: number;
63
+ propertyConfigs?: Record<string, PropertyConfig>;
64
+ authController: AuthController;
65
+ }): Property[];
66
+ export declare function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined;
67
+ export declare function resolveEntityView(entityView: string | EntityCustomView<any>, contextEntityViews?: EntityCustomView<any>[]): EntityCustomView<any> | undefined;
68
+ export declare function resolveEntityAction<M extends Record<string, any>>(entityAction: string | EntityAction<M>, contextEntityActions?: EntityAction<M>[]): EntityAction<M> | undefined;
69
+ export declare function resolvedSelectedEntityView<M extends Record<string, any>>(customViews: (string | EntityCustomView<M>)[] | undefined, customizationController: CustomizationController, selectedTab?: string, canEdit?: boolean): {
70
+ resolvedEntityViews: EntityCustomView<M>[];
71
+ selectedEntityView: EntityCustomView<M> | undefined;
72
+ selectedSecondaryForm: EntityCustomView<M> | undefined;
73
+ };
74
+ export declare function getSubcollections<M extends Record<string, any> = any>(collection: EntityCollection<M>): EntityCollection<any, any>[];
@@ -0,0 +1,24 @@
1
+ import { ArrayProperty, EntityValues, StorageConfig, StringProperty, UploadedFileContext } from "@rebasepro/types";
2
+ interface ResolveFilenameStringParams<M extends object> {
3
+ input: string | ((context: UploadedFileContext) => (Promise<string> | string));
4
+ storage: StorageConfig;
5
+ values: EntityValues<M>;
6
+ entityId?: string | number;
7
+ path?: string;
8
+ property: StringProperty | ArrayProperty;
9
+ file: File;
10
+ propertyKey: string;
11
+ }
12
+ export declare function resolveStorageFilenameString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
13
+ interface ResolveStoragePathStringParams<M extends object> {
14
+ input: string | ((context: UploadedFileContext) => string);
15
+ storage: StorageConfig;
16
+ values: EntityValues<M>;
17
+ entityId?: string | number;
18
+ path?: string;
19
+ property: StringProperty | ArrayProperty;
20
+ file: File;
21
+ propertyKey: string;
22
+ }
23
+ export declare function resolveStoragePathString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveStoragePathStringParams<M>): string;
24
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const toKebabCase: (str: string) => string;
2
+ export declare const toSnakeCase: (str: string) => string;
3
+ export declare function randomString(strLength?: number): string;
4
+ export declare function randomColor(): string;
5
+ export declare function slugify(text?: string, separator?: string, lowercase?: boolean): string;
6
+ export declare function unslugify(slug?: string): string;
7
+ export declare function prettifyIdentifier(input: string): string;
package/package.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@rebasepro/common",
3
+ "type": "module",
4
+ "version": "0.0.1-canary.0",
5
+ "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
+ "funding": {
7
+ "url": "https://github.com/sponsors/rebaseco"
8
+ },
9
+ "author": "Rebase",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/rebaseco/rebase.git",
14
+ "directory": "packages/common"
15
+ },
16
+ "main": "./dist/index.umd.js",
17
+ "module": "./dist/index.es.js",
18
+ "types": "./dist/index.d.ts",
19
+ "source": "src/index.ts",
20
+ "engines": {
21
+ "node": ">=14"
22
+ },
23
+ "keywords": [
24
+ "firebase",
25
+ "cms",
26
+ "admin",
27
+ "admin panel",
28
+ "firebase panel",
29
+ "firestore",
30
+ "headless",
31
+ "headless cms",
32
+ "content manager"
33
+ ],
34
+ "scripts": {
35
+ "watch": "vite build --watch",
36
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
37
+ "prepublishOnly": "run-s build",
38
+ "test:lint": "eslint \"src/**\" --quiet",
39
+ "test": "jest --passWithNoTests",
40
+ "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
41
+ "generateIcons": "ts-node --esm src/icons/generateIcons.ts"
42
+ },
43
+ "exports": {
44
+ ".": {
45
+ "development": "./src/index.ts",
46
+ "import": "./dist/index.es.js",
47
+ "require": "./dist/index.umd.js",
48
+ "types": "./dist/index.d.ts"
49
+ },
50
+ "./package.json": "./package.json"
51
+ },
52
+ "dependencies": {
53
+ "@rebasepro/types": "0.0.1-canary.0",
54
+ "fast-equals": "5.3.0"
55
+ },
56
+ "peerDependencies": {
57
+ "react": ">=19.0.0",
58
+ "react-dom": ">=19.0.0",
59
+ "react-router": "^6.28.0",
60
+ "react-router-dom": "^6.28.0"
61
+ },
62
+ "devDependencies": {
63
+ "@jest/globals": "^29.7.0",
64
+ "@testing-library/react": "^16.3.0",
65
+ "@testing-library/user-event": "^14.6.1",
66
+ "@types/jest": "^29.5.14",
67
+ "@types/node": "^20.17.14",
68
+ "@types/object-hash": "^3.0.6",
69
+ "@types/react": "^19.0.8",
70
+ "@types/react-dom": "^19.0.3",
71
+ "@types/react-measure": "^2.0.12",
72
+ "@vitejs/plugin-react": "^4.3.4",
73
+ "babel-plugin-react-compiler": "beta",
74
+ "cross-env": "^7.0.3",
75
+ "eslint-plugin-react-compiler": "beta",
76
+ "jest": "^29.7.0",
77
+ "npm-run-all": "^4.1.5",
78
+ "react-router": "^7.13.1",
79
+ "react-router-dom": "^7.13.1",
80
+ "ts-jest": "^29.3.1",
81
+ "ts-node": "^10.9.2",
82
+ "tsd": "^0.31.2",
83
+ "typescript": "^5.8.3",
84
+ "vite": "^5.4.17"
85
+ },
86
+ "files": [
87
+ "dist",
88
+ "src"
89
+ ],
90
+ "gitHead": "646afae9c387c3ce02c699d98cd8c7272bdd1929",
91
+ "publishConfig": {
92
+ "access": "public"
93
+ },
94
+ "eslintConfig": {
95
+ "extends": [
96
+ "react-app",
97
+ "react-app/jest"
98
+ ]
99
+ },
100
+ "jest": {
101
+ "transform": {
102
+ "^.+\\.tsx?$": "ts-jest"
103
+ },
104
+ "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
105
+ "moduleFileExtensions": [
106
+ "ts",
107
+ "tsx",
108
+ "js",
109
+ "jsx",
110
+ "json",
111
+ "node"
112
+ ],
113
+ "testEnvironment": "node",
114
+ "moduleNameMapper": {
115
+ "\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
116
+ }
117
+ }
118
+ }