@rebasepro/common 0.2.3 → 0.2.5

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.
@@ -0,0 +1,9 @@
1
+ import type { PostgresCollection } from "@rebasepro/types";
2
+ /**
3
+ * Default users collection.
4
+ *
5
+ * Prepended to the developer's collections array by the admin and server.
6
+ * Slug-based dedup (Map keyed by slug, last-write-wins) lets developers
7
+ * override by defining their own collection with `slug: "users"`.
8
+ */
9
+ export declare const defaultUsersCollection: PostgresCollection;
@@ -1 +1,2 @@
1
1
  export * from "./CollectionRegistry";
2
+ export * from "./default-collections";
package/dist/index.es.js CHANGED
@@ -1963,6 +1963,142 @@ class CollectionRegistry {
1963
1963
  };
1964
1964
  }
1965
1965
  }
1966
+ const defaultUsersCollection = {
1967
+ name: "Users",
1968
+ singularName: "User",
1969
+ slug: "users",
1970
+ table: "users",
1971
+ schema: "rebase",
1972
+ icon: "Users",
1973
+ group: "Settings",
1974
+ openEntityMode: "dialog",
1975
+ disableDefaultActions: ["copy"],
1976
+ sort: ["createdAt", "desc"],
1977
+ properties: {
1978
+ id: {
1979
+ name: "ID",
1980
+ type: "string",
1981
+ isId: "uuid",
1982
+ ui: {
1983
+ readOnly: true
1984
+ }
1985
+ },
1986
+ email: {
1987
+ name: "Email",
1988
+ type: "string",
1989
+ validation: {
1990
+ required: true,
1991
+ unique: true
1992
+ }
1993
+ },
1994
+ displayName: {
1995
+ name: "Name",
1996
+ type: "string",
1997
+ columnName: "display_name",
1998
+ validation: {
1999
+ required: true
2000
+ }
2001
+ },
2002
+ photoURL: {
2003
+ name: "Photo URL",
2004
+ type: "string",
2005
+ columnName: "photo_url",
2006
+ url: "image"
2007
+ },
2008
+ roles: {
2009
+ name: "Roles",
2010
+ type: "array",
2011
+ columnType: "text[]",
2012
+ of: {
2013
+ name: "Role",
2014
+ type: "string",
2015
+ enum: {
2016
+ admin: "Admin",
2017
+ editor: "Editor",
2018
+ viewer: "Viewer"
2019
+ }
2020
+ }
2021
+ },
2022
+ passwordHash: {
2023
+ name: "Password Hash",
2024
+ type: "string",
2025
+ columnName: "password_hash",
2026
+ ui: {
2027
+ hideFromCollection: true,
2028
+ disabled: {
2029
+ hidden: true
2030
+ }
2031
+ }
2032
+ },
2033
+ emailVerified: {
2034
+ name: "Email Verified",
2035
+ type: "boolean",
2036
+ columnName: "email_verified",
2037
+ defaultValue: false,
2038
+ ui: {
2039
+ hideFromCollection: true,
2040
+ disabled: {
2041
+ hidden: true
2042
+ }
2043
+ }
2044
+ },
2045
+ emailVerificationToken: {
2046
+ name: "Email Verification Token",
2047
+ type: "string",
2048
+ columnName: "email_verification_token",
2049
+ ui: {
2050
+ hideFromCollection: true,
2051
+ disabled: {
2052
+ hidden: true
2053
+ }
2054
+ }
2055
+ },
2056
+ emailVerificationSentAt: {
2057
+ name: "Email Verification Sent At",
2058
+ type: "date",
2059
+ columnName: "email_verification_sent_at",
2060
+ ui: {
2061
+ hideFromCollection: true,
2062
+ disabled: {
2063
+ hidden: true
2064
+ }
2065
+ }
2066
+ },
2067
+ metadata: {
2068
+ name: "Metadata",
2069
+ type: "map",
2070
+ defaultValue: {},
2071
+ ui: {
2072
+ hideFromCollection: true,
2073
+ disabled: {
2074
+ hidden: true
2075
+ }
2076
+ }
2077
+ },
2078
+ createdAt: {
2079
+ name: "Created At",
2080
+ type: "date",
2081
+ columnName: "created_at",
2082
+ ui: {
2083
+ readOnly: true
2084
+ }
2085
+ },
2086
+ updatedAt: {
2087
+ name: "Updated At",
2088
+ type: "date",
2089
+ columnName: "updated_at",
2090
+ autoValue: "on_update",
2091
+ ui: {
2092
+ hideFromCollection: true,
2093
+ disabled: {
2094
+ hidden: true
2095
+ }
2096
+ }
2097
+ }
2098
+ },
2099
+ listProperties: ["displayName", "email", "roles", "createdAt"],
2100
+ propertiesOrder: ["id", "email", "displayName", "roles", "createdAt"]
2101
+ };
1966
2102
  function mapOperator(op) {
1967
2103
  switch (op) {
1968
2104
  case "==":
@@ -2209,6 +2345,9 @@ function createDriverAccessor(driver, slug) {
2209
2345
  }
2210
2346
  });
2211
2347
  },
2348
+ deleteAll: driver.deleteAll ? async () => {
2349
+ return driver.deleteAll(slug);
2350
+ } : void 0,
2212
2351
  count: driver.countEntities ? async (params) => {
2213
2352
  return driver.countEntities({
2214
2353
  path: slug,
@@ -2317,8 +2456,10 @@ export {
2317
2456
  canDeleteEntity,
2318
2457
  canEditEntity,
2319
2458
  canReadCollection,
2459
+ checkOperation,
2320
2460
  createRelationRef,
2321
2461
  createRelationRefWithData,
2462
+ defaultUsersCollection,
2322
2463
  enumToObjectEntries,
2323
2464
  evaluateCondition,
2324
2465
  findRelation,