@rebasepro/common 0.2.1 → 0.2.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.
- package/dist/data/query_builder.d.ts +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +385 -240
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +384 -239
- package/dist/index.umd.js.map +1 -1
- package/package.json +7 -4
- package/src/collections/CollectionRegistry.ts +12 -1
- package/src/data/buildRebaseData.ts +25 -5
- package/src/data/query_builder.ts +117 -0
- package/src/index.ts +2 -0
- package/src/util/relations.ts +15 -15
- package/src/util/resolutions.ts +5 -2
- package/src/collections/CollectionRegistry.d.ts +0 -56
- package/src/collections/index.d.ts +0 -1
- package/src/data/buildRebaseData.d.ts +0 -14
- package/src/index.d.ts +0 -3
- package/src/util/builders.d.ts +0 -57
- package/src/util/callbacks.d.ts +0 -6
- package/src/util/collections.d.ts +0 -11
- package/src/util/common.d.ts +0 -2
- package/src/util/conditions.d.ts +0 -26
- package/src/util/entities.d.ts +0 -58
- package/src/util/enums.d.ts +0 -3
- package/src/util/index.d.ts +0 -16
- package/src/util/navigation_from_path.d.ts +0 -34
- package/src/util/navigation_utils.d.ts +0 -20
- package/src/util/parent_references_from_path.d.ts +0 -6
- package/src/util/paths.d.ts +0 -14
- package/src/util/permissions.d.ts +0 -5
- package/src/util/references.d.ts +0 -2
- package/src/util/relations.d.ts +0 -22
- package/src/util/resolutions.d.ts +0 -72
- package/src/util/storage.d.ts +0 -24
package/src/util/paths.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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[];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AuthController, Entity, EntityCollection, User } from "@rebasepro/types";
|
|
2
|
-
export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>): boolean;
|
|
3
|
-
export declare function canEditEntity<M extends Record<string, unknown>, 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, unknown>, 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, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
package/src/util/references.d.ts
DELETED
package/src/util/relations.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
13
|
-
/**
|
|
14
|
-
* Look up a relation by key with forgiving normalization.
|
|
15
|
-
*
|
|
16
|
-
* `resolveCollectionRelations` stores each relation under a single canonical
|
|
17
|
-
* key (no aliases). This helper tries the given key as-is, then falls back to
|
|
18
|
-
* slug form (underscores → hyphens) and snake_case form (hyphens → underscores)
|
|
19
|
-
* so that callers that receive a key from external input (URL path segments,
|
|
20
|
-
* user-provided config, etc.) can still find the right entry.
|
|
21
|
-
*/
|
|
22
|
-
export declare function findRelation(resolvedRelations: Record<string, Relation>, key: string): Relation | undefined;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ArrayProperty, AuthController, EntityCollection, EnumValueConfig, EnumValues, NumberProperty, Properties, Property, Relation, RelationProperty, StringProperty } from "@rebasepro/types";
|
|
2
|
-
type PropertyConfig = {
|
|
3
|
-
property: unknown;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Resolve property builders, enums and arrays.
|
|
8
|
-
*/
|
|
9
|
-
export type ResolvePropertyProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
10
|
-
property: Property;
|
|
11
|
-
propertyKey?: string;
|
|
12
|
-
values?: Partial<M>;
|
|
13
|
-
previousValues?: Partial<M>;
|
|
14
|
-
path?: string;
|
|
15
|
-
entityId?: string | number;
|
|
16
|
-
index?: number;
|
|
17
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
18
|
-
ignoreMissingFields?: boolean;
|
|
19
|
-
authController: AuthController;
|
|
20
|
-
};
|
|
21
|
-
export declare function resolveProperty<M extends Record<string, unknown> = Record<string, unknown>>(props: ResolvePropertyProps<M>): Property | null;
|
|
22
|
-
export declare function resolveRelationProperty(property: RelationProperty, relations: Relation[], propertyKey?: string): RelationProperty;
|
|
23
|
-
/**
|
|
24
|
-
* Resolve enum aliases for a string or number property
|
|
25
|
-
* @param property
|
|
26
|
-
*/
|
|
27
|
-
export declare function resolvePropertyEnum(property: StringProperty | NumberProperty): StringProperty | NumberProperty;
|
|
28
|
-
/**
|
|
29
|
-
* Resolve enums and arrays for properties
|
|
30
|
-
* @param properties
|
|
31
|
-
* @param value
|
|
32
|
-
*/
|
|
33
|
-
export declare function resolveProperties<M extends Record<string, unknown>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
|
|
34
|
-
propertyKey?: string;
|
|
35
|
-
properties: Properties;
|
|
36
|
-
values?: Partial<M>;
|
|
37
|
-
previousValues?: Partial<M>;
|
|
38
|
-
path?: string;
|
|
39
|
-
entityId?: string | number;
|
|
40
|
-
index?: number;
|
|
41
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
42
|
-
ignoreMissingFields?: boolean;
|
|
43
|
-
authController: AuthController;
|
|
44
|
-
}): Properties;
|
|
45
|
-
export declare function resolveArrayProperties<M>({ propertyKey, property, ignoreMissingFields, ...props }: {
|
|
46
|
-
propertyKey?: string;
|
|
47
|
-
property: ArrayProperty;
|
|
48
|
-
values?: Partial<M>;
|
|
49
|
-
previousValues?: Partial<M>;
|
|
50
|
-
path?: string;
|
|
51
|
-
entityId?: string | number;
|
|
52
|
-
index?: number;
|
|
53
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
54
|
-
ignoreMissingFields?: boolean;
|
|
55
|
-
authController: AuthController;
|
|
56
|
-
}): Property[];
|
|
57
|
-
export declare function getArrayResolvedProperties({ propertyKey, propertyValue, property, ...props }: {
|
|
58
|
-
propertyValue: unknown;
|
|
59
|
-
propertyKey?: string;
|
|
60
|
-
property: ArrayProperty;
|
|
61
|
-
ignoreMissingFields: boolean;
|
|
62
|
-
values?: object;
|
|
63
|
-
previousValues?: object;
|
|
64
|
-
path?: string;
|
|
65
|
-
entityId?: string | number;
|
|
66
|
-
index?: number;
|
|
67
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
68
|
-
authController: AuthController;
|
|
69
|
-
}): Property[];
|
|
70
|
-
export declare function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined;
|
|
71
|
-
export declare function getSubcollections<M extends Record<string, unknown> = Record<string, unknown>>(collection: EntityCollection<M>): EntityCollection<Record<string, unknown>>[];
|
|
72
|
-
export {};
|
package/src/util/storage.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ArrayProperty, EntityValues, StorageConfig, StringProperty, UploadedFileContext } from "@rebasepro/types";
|
|
2
|
-
interface ResolveFilenameStringParams<M extends Record<string, unknown>> {
|
|
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 Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
|
|
13
|
-
interface ResolveStoragePathStringParams<M extends Record<string, unknown>> {
|
|
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 Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveStoragePathStringParams<M>): string;
|
|
24
|
-
export {};
|