@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Rebase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ <p align="center">
2
+ <img src="https://rebase.pro/img/dark_mode.webp" alt="Intro video" style="max-width: 100%;"/>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://rebase.pro">
7
+ <img src="https://rebase.pro/img/logo_small.png" width="240px" alt="Rebase logo" />
8
+ </a>
9
+ </p>
10
+
11
+ <h1 align="center">Rebase</h1>
12
+ <h3 align="center">Awesome Firebase/MongoDB-based headless CMS</h3>
13
+ <p align="center"><a href="https://demo.rebase.pro">Live demo</a></p>
14
+
15
+ <br />
16
+
17
+
18
+ [![NPM](https://img.shields.io/npm/v/rebase.svg)](https://www.npmjs.com/package/rebase) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
19
+
20
+ Designed by developers for developers, Rebase is a headless CMS and admin panel
21
+ that seamlessly integrates with **Firebase and Firestore** by default, but is
22
+ also
23
+ compatible with any backend.
24
+
25
+ Effortlessly generate **CRUD views** based on your configuration. Rebase is
26
+ simple
27
+ to set up for standard cases and easy to extend and customize for more specific
28
+ needs.
29
+
30
+ Built to produce collection and form views that naturally align with the
31
+ collection/document model, Rebase covers a wide range of basic and advanced use
32
+ cases. With extensibility in mind, it's easy to create your own views or modify
33
+ existing ones.
34
+
35
+ Rebase does **not impose any data structure** restrictions, ensuring a smooth,
36
+ out-of-the-box experience for any project.
37
+
38
+ ### Core technologies
39
+
40
+ Rebase is based on this great technologies:
41
+
42
+ - Typescript
43
+ - Tailwind CSS
44
+ - Firebase SDK 10
45
+ - React + React Router 6
46
+
47
+ ### Quickstart
48
+
49
+ The easiest way to get going is to check our quickstart guide! You will just
50
+ need to follow some quick steps:
51
+
52
+ https://rebase.pro/docs
53
+
54
+ ### Demo
55
+
56
+ Check the demo with all the core functionalities.
57
+
58
+ https://demo.rebase.pro
59
+
60
+ > You can modify the data, but it gets periodically restored.
61
+
62
+ ### Changelog
63
+
64
+ https://rebase.pro/docs/changelog
65
+
66
+ ## Features
67
+
68
+ Rebase has been meticulously crafted to make it incredibly easy for developers
69
+ to build a CMS/admin tool while offering an excellent data editing experience
70
+ and a user-friendly interface for marketers and content managers.
71
+
72
+ ### 🏓 Exceptional Spreadsheet View
73
+
74
+ We've developed a highly efficient windowed **spreadsheet view** for
75
+ collections, allowing inline editing for most common fields, as well as popup
76
+ views for other cases and your custom field implementations.
77
+
78
+ Featuring **real-time** support, Rebase is perfect for apps that require
79
+ constant updates. It also supports **text search** (through an external provider
80
+ like Algolia, if using Firestore), **filtering and sorting**, and **exporting**
81
+ data.
82
+
83
+ ### ✨ Robust Forms
84
+
85
+ ![fields](https://rebase.pro/img/form_editing.webp)
86
+
87
+ When editing an entity, Rebase offers a nested system of side dialogs for
88
+ navigating through **subcollections** and accessing custom views (such as custom
89
+ forms or blog previews). This functionality can also be accessed
90
+ programmatically using the `useSideEntityController` hook.
91
+
92
+ Rebase includes **over 20 built-in fields** with numerous customization and
93
+ validation options. The components have been carefully designed for an
94
+ outstanding user experience, including advanced features like **references** to
95
+ other collections, **markdown**, and **array reordering**.
96
+
97
+ For unsupported use cases, create your own **custom field** as a React
98
+ component.
99
+
100
+ Rebase also supports **conditional fields** in forms, allowing you to define
101
+ rules for active fields based on your logic.
102
+
103
+ ### 👮 Authentication, Permissions, and Role System
104
+
105
+ Define which navigation views users can see and the operations (create, edit,
106
+ delete) they can perform based on your role system. You can even configure this
107
+ on a per-entity or collection level.
108
+
109
+ By default, Rebase supports all Firebase authorization mechanisms, but you can
110
+ implement your own.
111
+
112
+ ### 🏹 Relational Support
113
+
114
+ Define references to entities in other collections and benefit from the
115
+ integrated reference fields and shortcuts.
116
+
117
+ You can also define subcollections at the entity level for nesting data in a
118
+ collection/document/collection model.
119
+
120
+ ### 🆒 Real-Time Data
121
+
122
+ Every view in the CMS supports real-time data, making it suitable for displaying
123
+ constantly updated information.
124
+
125
+ Forms also support this feature, with any modified value in the database being
126
+ updated in any open form view as long as it hasn't been touched by the user.
127
+ This enables advanced cases where a Cloud Function is triggered after saving an
128
+ entity, modifying some values, and requiring real-time updates.
129
+
130
+ ### 🗂️ File Storage
131
+
132
+ Rebase supports uploading files to Firebase Storage out of the box and provides
133
+ specific fields for handling single and multiple file uploads, as well as
134
+ reordering.
135
+
136
+ You can replace the Firebase Storage implementation with your own.
137
+
138
+ ## Included example
139
+
140
+ You can access the code for the demo project under
141
+ [`example`](https://github.com/Rebaseco/rebase/tree/master/example). It includes
142
+ every feature provided by this CMS.
143
+
144
+ Keep in mind you need to update the dependencies in that project if you want to
145
+ use it as it is, without linking it to the library source code. More details in
146
+ its README
147
+
148
+ ## Contact and support
149
+
150
+ If you need general support, you can open a GitHub issue.
151
+
152
+ Do you need consulting setting up your Firestore-based CMS in no time? We are
153
+ happy to help!
154
+ `hello@rebase.pro`
155
+
156
+ ## Development
157
+
158
+ If you would like to make changes to the source, feel free to submit a PR!
159
+
160
+ When developing, the core library can be found under `lib`.
161
+ There is an example project in the folder `example`.
162
+
163
+ In order to run the project, you need to create a file
164
+ called `firebase_config.ts`
165
+ in `example/src`.
166
+
167
+ That file needs to export a valid Firebase config, that you can get
168
+ from your Firebase console when creating a webapp for your project.
169
+
170
+ Then simply run `yarn` and `yarn dev`
171
+
172
+ ## License
173
+
174
+ MIT © [Rebase](https://github.com/Rebaseco)
@@ -0,0 +1,48 @@
1
+ import { EntityCollection } from "@rebasepro/types";
2
+ export declare class CollectionRegistry {
3
+ private collectionsByDbPath;
4
+ private collectionsBySlug;
5
+ private rootCollections;
6
+ private rawCollectionsByDbPath;
7
+ private rawCollectionsBySlug;
8
+ private rawRootCollections;
9
+ private lastRawInputSnapshot;
10
+ constructor(collections?: EntityCollection[]);
11
+ reset(): void;
12
+ /**
13
+ * Registers a collection and its subcollections recursively.
14
+ * Returns true if the collections have changed, false otherwise.
15
+ *
16
+ * Idempotent: compares the raw input (before normalization) against a stored
17
+ * snapshot. Only re-normalizes and re-registers when the raw input actually changed.
18
+ * @param collections
19
+ */
20
+ registerMultiple(collections: EntityCollection[]): boolean;
21
+ register(collection: EntityCollection, rawCollection?: EntityCollection): void;
22
+ private _registerRecursively;
23
+ normalizeCollection(collection: EntityCollection): EntityCollection;
24
+ private normalizeProperties;
25
+ private normalizeProperty;
26
+ get(path: string): EntityCollection | undefined;
27
+ /**
28
+ * Gets the pristine, un-normalized collection exactly as it was provided.
29
+ * Useful for the AST editor so it doesn't accidentally serialize injected metadata back to disk.
30
+ */
31
+ getRaw(path: string): EntityCollection | undefined;
32
+ /**
33
+ * Get collection by resolving multi-segment paths through relations
34
+ * e.g., "authors/70/posts" resolves to the posts collection
35
+ */
36
+ getCollectionByPath(collectionPath: string): EntityCollection | undefined;
37
+ getCollections(): EntityCollection[];
38
+ getRawCollections(): EntityCollection[];
39
+ /**
40
+ * Resolves a multi-segment path like "products/123/locales" and returns
41
+ * information about the collections and entity IDs along the path
42
+ */
43
+ resolvePathToCollections(path: string): {
44
+ collections: EntityCollection[];
45
+ entityIds: (string | number)[];
46
+ finalCollection: EntityCollection;
47
+ };
48
+ }
@@ -0,0 +1 @@
1
+ export * from "./CollectionRegistry";
@@ -0,0 +1,2 @@
1
+ export * from "./util";
2
+ export * from "./collections";