@rebasepro/sdk-generator 0.0.1-canary.09e5ec5

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 (86) hide show
  1. package/LICENSE +6 -0
  2. package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
  3. package/dist/common/src/collections/index.d.ts +1 -0
  4. package/dist/common/src/data/buildRebaseData.d.ts +14 -0
  5. package/dist/common/src/index.d.ts +3 -0
  6. package/dist/common/src/util/builders.d.ts +57 -0
  7. package/dist/common/src/util/callbacks.d.ts +6 -0
  8. package/dist/common/src/util/collections.d.ts +11 -0
  9. package/dist/common/src/util/common.d.ts +2 -0
  10. package/dist/common/src/util/conditions.d.ts +26 -0
  11. package/dist/common/src/util/entities.d.ts +58 -0
  12. package/dist/common/src/util/enums.d.ts +3 -0
  13. package/dist/common/src/util/index.d.ts +16 -0
  14. package/dist/common/src/util/navigation_from_path.d.ts +34 -0
  15. package/dist/common/src/util/navigation_utils.d.ts +20 -0
  16. package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
  17. package/dist/common/src/util/paths.d.ts +14 -0
  18. package/dist/common/src/util/permissions.d.ts +5 -0
  19. package/dist/common/src/util/references.d.ts +2 -0
  20. package/dist/common/src/util/relations.d.ts +22 -0
  21. package/dist/common/src/util/resolutions.d.ts +72 -0
  22. package/dist/common/src/util/storage.d.ts +24 -0
  23. package/dist/index.cjs +232 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.es.js +229 -0
  26. package/dist/index.es.js.map +1 -0
  27. package/dist/sdk-generator/src/generate-types.d.ts +2 -0
  28. package/dist/sdk-generator/src/index.d.ts +19 -0
  29. package/dist/sdk-generator/src/utils.d.ts +22 -0
  30. package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
  31. package/dist/types/src/controllers/auth.d.ts +119 -0
  32. package/dist/types/src/controllers/client.d.ts +170 -0
  33. package/dist/types/src/controllers/collection_registry.d.ts +45 -0
  34. package/dist/types/src/controllers/customization_controller.d.ts +60 -0
  35. package/dist/types/src/controllers/data.d.ts +168 -0
  36. package/dist/types/src/controllers/data_driver.d.ts +160 -0
  37. package/dist/types/src/controllers/database_admin.d.ts +11 -0
  38. package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
  39. package/dist/types/src/controllers/effective_role.d.ts +4 -0
  40. package/dist/types/src/controllers/email.d.ts +34 -0
  41. package/dist/types/src/controllers/index.d.ts +18 -0
  42. package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
  43. package/dist/types/src/controllers/navigation.d.ts +213 -0
  44. package/dist/types/src/controllers/registry.d.ts +54 -0
  45. package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
  46. package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
  47. package/dist/types/src/controllers/snackbar.d.ts +24 -0
  48. package/dist/types/src/controllers/storage.d.ts +171 -0
  49. package/dist/types/src/index.d.ts +4 -0
  50. package/dist/types/src/rebase_context.d.ts +105 -0
  51. package/dist/types/src/types/backend.d.ts +536 -0
  52. package/dist/types/src/types/builders.d.ts +15 -0
  53. package/dist/types/src/types/chips.d.ts +5 -0
  54. package/dist/types/src/types/collections.d.ts +856 -0
  55. package/dist/types/src/types/cron.d.ts +102 -0
  56. package/dist/types/src/types/data_source.d.ts +64 -0
  57. package/dist/types/src/types/entities.d.ts +145 -0
  58. package/dist/types/src/types/entity_actions.d.ts +98 -0
  59. package/dist/types/src/types/entity_callbacks.d.ts +173 -0
  60. package/dist/types/src/types/entity_link_builder.d.ts +7 -0
  61. package/dist/types/src/types/entity_overrides.d.ts +10 -0
  62. package/dist/types/src/types/entity_views.d.ts +61 -0
  63. package/dist/types/src/types/export_import.d.ts +21 -0
  64. package/dist/types/src/types/index.d.ts +23 -0
  65. package/dist/types/src/types/locales.d.ts +4 -0
  66. package/dist/types/src/types/modify_collections.d.ts +5 -0
  67. package/dist/types/src/types/plugins.d.ts +279 -0
  68. package/dist/types/src/types/properties.d.ts +1176 -0
  69. package/dist/types/src/types/property_config.d.ts +70 -0
  70. package/dist/types/src/types/relations.d.ts +336 -0
  71. package/dist/types/src/types/slots.d.ts +252 -0
  72. package/dist/types/src/types/translations.d.ts +870 -0
  73. package/dist/types/src/types/user_management_delegate.d.ts +121 -0
  74. package/dist/types/src/types/websockets.d.ts +78 -0
  75. package/dist/types/src/users/index.d.ts +2 -0
  76. package/dist/types/src/users/roles.d.ts +22 -0
  77. package/dist/types/src/users/user.d.ts +46 -0
  78. package/jest.config.cjs +13 -0
  79. package/package.json +51 -0
  80. package/src/generate-types.ts +199 -0
  81. package/src/index.ts +71 -0
  82. package/src/json-logic-js.d.ts +8 -0
  83. package/src/utils.ts +42 -0
  84. package/test/sdk-generator.test.ts +88 -0
  85. package/tsconfig.json +26 -0
  86. package/vite.config.ts +49 -0
@@ -0,0 +1,90 @@
1
+ import type { Entity } from "../types/entities";
2
+ import type { EntityCollection } from "../types/collections";
3
+ /**
4
+ * Props used to open a side dialog
5
+ * @group Hooks and utilities
6
+ */
7
+ export interface EntitySidePanelProps<M extends Record<string, unknown> = Record<string, unknown>> {
8
+ /**
9
+ * Absolute path of the entity
10
+ */
11
+ path: string;
12
+ /**
13
+ * ID of the entity, if not set, it means we are creating a new entity
14
+ */
15
+ entityId?: string | number;
16
+ /**
17
+ * Set this flag to true if you want to make a copy of an existing entity
18
+ */
19
+ copy?: boolean;
20
+ /**
21
+ * Open the entity with a selected sub-collection view. If the panel for this
22
+ * entity was already open, it is replaced.
23
+ */
24
+ selectedTab?: string;
25
+ /**
26
+ * Use this prop to override the width of the form view.
27
+ * e.g. "600px"
28
+ */
29
+ width?: number | string;
30
+ /**
31
+ * Collection representing the entities of this view.
32
+ * If you leave it blank it will be induced by your navigation
33
+ */
34
+ collection?: EntityCollection<M>;
35
+ /**
36
+ * Should update the URL when opening the dialog.
37
+ * Consider that if the collection that you provide is not defined in the base
38
+ * config of your `Rebase` component, you will not be able to recreate
39
+ * the state if copying the URL to a different window.
40
+ */
41
+ updateUrl?: boolean;
42
+ /**
43
+ * Callback when the entity is updated
44
+ * @param params
45
+ */
46
+ onUpdate?: (params: {
47
+ entity: Entity<M>;
48
+ }) => void;
49
+ /**
50
+ * Callback when the dialog is closed
51
+ */
52
+ onClose?: () => void;
53
+ /**
54
+ * Should this panel close when saving
55
+ */
56
+ closeOnSave?: boolean;
57
+ /**
58
+ * Override some form properties
59
+ */
60
+ formProps?: Record<string, unknown>;
61
+ /**
62
+ * Allow the user to open the entity fullscreen
63
+ */
64
+ allowFullScreen?: boolean;
65
+ }
66
+ /**
67
+ * Controller to open the side dialog displaying entity forms
68
+ * @group Hooks and utilities
69
+ */
70
+ export interface SideEntityController {
71
+ /**
72
+ * Close the last panel
73
+ */
74
+ close: () => void;
75
+ /**
76
+ * Open a new entity sideDialog. By default, the collection and configuration
77
+ * of the view is fetched from the collections you have specified in the
78
+ * navigation.
79
+ * At least you need to pass the path of the entity you would like
80
+ * to edit. You can set an entityId if you would like to edit and existing one
81
+ * (or a new one with that id).
82
+ * @param props
83
+ */
84
+ open: <M extends Record<string, unknown> = Record<string, unknown>>(props: EntitySidePanelProps<M>) => void;
85
+ /**
86
+ * Replace the last open entity panel with the given one.
87
+ * @param props
88
+ */
89
+ replace: <M extends Record<string, unknown> = Record<string, unknown>>(props: EntitySidePanelProps<M>) => void;
90
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Possible snackbar types
3
+ * @group Hooks and utilities
4
+ */
5
+ export type SnackbarMessageType = "success" | "info" | "warning" | "error";
6
+ /**
7
+ * Controller to display snackbars
8
+ * @group Hooks and utilities
9
+ */
10
+ export interface SnackbarController {
11
+ /**
12
+ * Close the currently open snackbar
13
+ */
14
+ close: () => void;
15
+ /**
16
+ * Display a new snackbar. You need to specify the type and message.
17
+ * You can optionally specify a title
18
+ */
19
+ open: (props: {
20
+ type: SnackbarMessageType;
21
+ message: React.ReactNode;
22
+ autoHideDuration?: number;
23
+ }) => void;
24
+ }
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @group Models
3
+ */
4
+ export interface UploadFileProps {
5
+ file: File;
6
+ key: string;
7
+ metadata?: Record<string, unknown>;
8
+ bucket?: string;
9
+ }
10
+ /**
11
+ * @group Models
12
+ */
13
+ export interface UploadFileResult {
14
+ /**
15
+ * Storage key including the file name where the file was uploaded.
16
+ */
17
+ key: string;
18
+ /**
19
+ * Bucket where the file was uploaded
20
+ */
21
+ bucket: string;
22
+ /**
23
+ * Fully qualified storage URL for the uploaded file.
24
+ *
25
+ * For example: `s3://my-bucket/path/to/file.png`.
26
+ *
27
+ * This is optional for backwards compatibility.
28
+ */
29
+ storageUrl?: string;
30
+ }
31
+ /**
32
+ * @group Models
33
+ */
34
+ export interface DownloadConfig {
35
+ /**
36
+ * Temporal url that can be used to download the file
37
+ */
38
+ url: string | null;
39
+ metadata?: DownloadMetadata;
40
+ fileNotFound?: boolean;
41
+ }
42
+ /**
43
+ * The full set of object metadata, including read-only properties.
44
+ * @public
45
+ */
46
+ export declare interface DownloadMetadata {
47
+ /**
48
+ * The bucket this object is contained in.
49
+ */
50
+ bucket: string;
51
+ /**
52
+ * The full path of this object.
53
+ */
54
+ fullPath: string;
55
+ /**
56
+ * The short name of this object, which is the last component of the full path.
57
+ * For example, if path is 'full/path/image.png', name is 'image.png'.
58
+ */
59
+ name: string;
60
+ /**
61
+ * The size of this object, in bytes.
62
+ */
63
+ size: number;
64
+ /**
65
+ * Type of the uploaded file
66
+ * e.g. "image/jpeg"
67
+ */
68
+ contentType: string;
69
+ customMetadata: Record<string, unknown>;
70
+ }
71
+ /**
72
+ * @group Models
73
+ */
74
+ export interface StorageSource {
75
+ /**
76
+ * Upload an object, specifying a key
77
+ * @param file
78
+ * @param key
79
+ * @param metadata
80
+ * @param bucket
81
+ */
82
+ putObject: ({ file, key, metadata, bucket }: UploadFileProps) => Promise<UploadFileResult>;
83
+ /**
84
+ * Convert a storage key or URL into a download configuration (signed URL equivalent)
85
+ * @param keyOrUrl
86
+ * @param bucket
87
+ */
88
+ getSignedUrl: (keyOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
89
+ /**
90
+ * Get an object from a storage key.
91
+ * It returns null if the object does not exist.
92
+ * @param key
93
+ * @param bucket
94
+ */
95
+ getObject: (key: string, bucket?: string) => Promise<File | null>;
96
+ /**
97
+ * Delete an object.
98
+ * @param key
99
+ * @param bucket
100
+ */
101
+ deleteObject: (key: string, bucket?: string) => Promise<void>;
102
+ /**
103
+ * List the contents of a prefix.
104
+ * @param prefix
105
+ * @param options
106
+ */
107
+ listObjects: (prefix: string, options?: {
108
+ bucket?: string;
109
+ maxResults?: number;
110
+ pageToken?: string;
111
+ }) => Promise<StorageListResult>;
112
+ }
113
+ /**
114
+ * Result returned by list().
115
+ * @public
116
+ */
117
+ export declare interface StorageListResult {
118
+ /**
119
+ * References to prefixes (sub-folders). You can call list() on them to
120
+ * get its contents.
121
+ *
122
+ * Folders are implicit based on '/' in the object paths.
123
+ * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
124
+ * will return '/a/b' as a prefix.
125
+ */
126
+ prefixes: StorageReference[];
127
+ /**
128
+ * Objects in this directory.
129
+ * You can call getMetadata() and getDownloadUrl() on them.
130
+ */
131
+ items: StorageReference[];
132
+ /**
133
+ * If set, there might be more results for this list. Use this token to resume the list.
134
+ */
135
+ nextPageToken?: string;
136
+ }
137
+ /**
138
+ * Represents a reference to an S3-compatible storage object. Developers can
139
+ * upload, download, and delete objects, as well as get/set object metadata.
140
+ * @public
141
+ */
142
+ export declare interface StorageReference {
143
+ /**
144
+ * Returns a s3:// URL for this object in the form
145
+ * `s3://<bucket>/<path>/<to>/<object>`
146
+ * @returns The s3:// URL.
147
+ */
148
+ toString(): string;
149
+ /**
150
+ * A reference to the root of this object's bucket.
151
+ */
152
+ root: StorageReference;
153
+ /**
154
+ * The name of the bucket containing this reference's object.
155
+ */
156
+ bucket: string;
157
+ /**
158
+ * The full path of this object.
159
+ */
160
+ fullPath: string;
161
+ /**
162
+ * The short name of this object, which is the last component of the full path.
163
+ * For example, if path is 'full/path/image.png', name is 'image.png'.
164
+ */
165
+ name: string;
166
+ /**
167
+ * A reference pointing to the parent location of this reference, or null if
168
+ * this reference is the root.
169
+ */
170
+ parent: StorageReference | null;
171
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./rebase_context";
2
+ export * from "./types";
3
+ export * from "./controllers";
4
+ export * from "./users";
@@ -0,0 +1,105 @@
1
+ import type { AnalyticsController } from "./controllers/analytics_controller";
2
+ import type { AuthController } from "./controllers/auth";
3
+ import type { StorageSource } from "./controllers/storage";
4
+ import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
5
+ import type { DatabaseAdmin } from "./types/backend";
6
+ import type { RebaseData } from "./controllers/data";
7
+ import type { User } from "./users";
8
+ import type { UserManagementDelegate } from "./types/user_management_delegate";
9
+ /**
10
+ * Context that is provided to entity callbacks (hooks).
11
+ * It contains only the dependencies that are available in both the frontend and the backend.
12
+ * @group Hooks and utilities
13
+ */
14
+ export type RebaseCallContext<USER extends User = User> = {
15
+ /**
16
+ * Unified data access — `context.data.products.create(...)`.
17
+ * Access any collection as a dynamic property.
18
+ */
19
+ data: RebaseData;
20
+ /**
21
+ * Used storage implementation
22
+ */
23
+ storageSource: StorageSource;
24
+ /**
25
+ * Set by the backend when callbacks are executed on the server.
26
+ */
27
+ user?: USER;
28
+ };
29
+ /**
30
+ * Context that includes the internal controllers and contexts used by the app.
31
+ * Some controllers and context included in this context can be accessed
32
+ * directly from their respective hooks.
33
+ * @group Hooks and utilities
34
+ * @see useRebaseContext
35
+ */
36
+ export type RebaseContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = RebaseCallContext<USER> & {
37
+ authController: AuthControllerType;
38
+ /**
39
+ * Controller mapping strings to collections
40
+ */
41
+ collectionRegistryController?: import("./controllers/collection_registry").CollectionRegistryController;
42
+ /**
43
+ * Controller for navigation state
44
+ */
45
+ navigationStateController?: import("./controllers/navigation").NavigationStateController;
46
+ /**
47
+ * Controller for side dialogs (side sheets)
48
+ */
49
+ sideDialogsController?: import("./controllers/side_dialogs_controller").SideDialogsController;
50
+ /**
51
+ * Controller to open the side dialog displaying entity forms
52
+ */
53
+ sideEntityController?: import("./controllers/side_entity_controller").SideEntityController;
54
+ /**
55
+ * Controller resolving URLs in the CMS
56
+ */
57
+ urlController?: import("./controllers/navigation").UrlController;
58
+ /**
59
+ * Controller to handle simple confirmation and alert dialogs
60
+ */
61
+ dialogsController?: import("./controllers/dialogs_controller").DialogsController;
62
+ /**
63
+ * Controller for CMS customization
64
+ */
65
+ customizationController?: import("./controllers/customization_controller").CustomizationController;
66
+ /**
67
+ * Controller for effective role
68
+ */
69
+ effectiveRoleController?: {
70
+ effectiveRole: string | null;
71
+ setEffectiveRole: (role: string | null) => void;
72
+ };
73
+ /**
74
+ * Use this controller to access data stored in the browser for the user
75
+ */
76
+ userConfigPersistence?: UserConfigurationPersistence;
77
+ /**
78
+ * Callback to send analytics events
79
+ */
80
+ analyticsController?: AnalyticsController;
81
+ /**
82
+ * This section is used to manage users in the CMS.
83
+ * It is used to show user information in various places of the CMS,
84
+ * for example, to show who created or modified an entity,
85
+ * or to assign ownership of an entity.
86
+ *
87
+ * In the base CMS, this information is not used for access control.
88
+ * You can pass your own implementation of this section, to populate
89
+ * the dropdown of users when assigning ownership of an entity,
90
+ * or to show more information about the user.
91
+ *
92
+ * If you are using the Rebase user management plugin, this
93
+ * section will be implemented automatically.
94
+ */
95
+ userManagement?: UserManagementDelegate<USER>;
96
+ /**
97
+ * Administrative database operations (SQL, schema discovery).
98
+ * Only available in developer/admin contexts.
99
+ */
100
+ databaseAdmin?: DatabaseAdmin;
101
+ /**
102
+ * Controller for snackbars
103
+ */
104
+ snackbarController?: import("./controllers/snackbar").SnackbarController;
105
+ };