rads-db 3.0.82 → 3.0.84

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/index.cjs CHANGED
@@ -879,9 +879,9 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
879
879
  await afterPut(docArgsToSave, ctx, computedContext);
880
880
  return { _logs, cursor, correctCount, incorrectCount, incorrectDocs };
881
881
  }
882
- function construct(key2) {
882
+ function construct(key2, defaultValues) {
883
883
  const type = schema[key2];
884
- const result2 = {};
884
+ let result2 = {};
885
885
  if (!type.fields)
886
886
  return {};
887
887
  if (type.fields.id && type.decorators.entity)
@@ -892,12 +892,14 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
892
892
  if (field.defaultValueClass)
893
893
  result2[fieldName] = construct(field.defaultValueClass);
894
894
  }
895
+ if (defaultValues)
896
+ result2 = merge(result2, defaultValues);
895
897
  return result2;
896
898
  }
897
899
  const result = {
898
900
  // No deleteMany / deleteAll on purpose - it's a dangerous operation, let them use driver instead
899
- construct() {
900
- return construct(key);
901
+ construct(defaultValues) {
902
+ return construct(key, defaultValues);
901
903
  },
902
904
  getMany,
903
905
  putMany,
package/dist/index.d.ts CHANGED
@@ -110,7 +110,7 @@ type DeepKeys<T> = T extends object ? {
110
110
  }[(string | number) & keyof T] : never;
111
111
  interface EntityMethods<E, EN extends keyof EntityMeta> {
112
112
  /** Returns object with with random UUID as `id` and prefilled default values */
113
- construct(): E;
113
+ construct(defaultValues?: DeepPartial<E>): E;
114
114
  /** Used to access underlying mechanism of storage directly.
115
115
  * Warning: bypasses all rads features - schema won't be validated, default values won't be filled, etc. */
116
116
  driver: Driver;
@@ -153,6 +153,10 @@ interface UiFieldDecoratorArgs {
153
153
  hint?: string;
154
154
  /** If true, field is hidden from the rads-ui */
155
155
  isHidden?: boolean;
156
+ /** If true, field is readonly in the rads-ui */
157
+ isReadonly?: boolean;
158
+ /** If true, field can be edited only during creation */
159
+ isImmutable?: boolean;
156
160
  /** TODO: Preferred component to display or edit this value */
157
161
  component?: string;
158
162
  }
package/dist/index.mjs CHANGED
@@ -872,9 +872,9 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
872
872
  await afterPut(docArgsToSave, ctx, computedContext);
873
873
  return { _logs, cursor, correctCount, incorrectCount, incorrectDocs };
874
874
  }
875
- function construct(key2) {
875
+ function construct(key2, defaultValues) {
876
876
  const type = schema[key2];
877
- const result2 = {};
877
+ let result2 = {};
878
878
  if (!type.fields)
879
879
  return {};
880
880
  if (type.fields.id && type.decorators.entity)
@@ -885,12 +885,14 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
885
885
  if (field.defaultValueClass)
886
886
  result2[fieldName] = construct(field.defaultValueClass);
887
887
  }
888
+ if (defaultValues)
889
+ result2 = merge(result2, defaultValues);
888
890
  return result2;
889
891
  }
890
892
  const result = {
891
893
  // No deleteMany / deleteAll on purpose - it's a dangerous operation, let them use driver instead
892
- construct() {
893
- return construct(key);
894
+ construct(defaultValues) {
895
+ return construct(key, defaultValues);
894
896
  },
895
897
  getMany,
896
898
  putMany,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.0.82",
3
+ "version": "3.0.84",
4
4
  "packageManager": "pnpm@8.6.1",
5
5
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
6
6
  "author": "",