@nymphjs/nymph 1.0.0-beta.8 → 1.0.0-beta.81

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 (65) hide show
  1. package/CHANGELOG.md +382 -0
  2. package/README.md +9 -19
  3. package/dist/Entity.d.ts +269 -7
  4. package/dist/Entity.js +491 -105
  5. package/dist/Entity.js.map +1 -1
  6. package/dist/Entity.test.js +25 -3
  7. package/dist/Entity.test.js.map +1 -1
  8. package/dist/Entity.types.d.ts +225 -19
  9. package/dist/Nymph.d.ts +430 -11
  10. package/dist/Nymph.js +686 -168
  11. package/dist/Nymph.js.map +1 -1
  12. package/dist/Nymph.types.d.ts +65 -7
  13. package/dist/Nymph.types.js +2 -1
  14. package/dist/Nymph.types.js.map +1 -1
  15. package/dist/conf/d.d.ts +30 -0
  16. package/dist/conf/defaults.js +27 -0
  17. package/dist/conf/defaults.js.map +1 -1
  18. package/dist/driver/NymphDriver.d.ts +136 -38
  19. package/dist/driver/NymphDriver.js +264 -131
  20. package/dist/driver/NymphDriver.js.map +1 -1
  21. package/dist/driver/testArtifacts.d.ts +1 -1
  22. package/dist/driver/testArtifacts.js +499 -51
  23. package/dist/driver/testArtifacts.js.map +1 -1
  24. package/dist/errors/EntityInvalidDataError.d.ts +6 -0
  25. package/dist/errors/EntityInvalidDataError.js +7 -1
  26. package/dist/errors/EntityInvalidDataError.js.map +1 -1
  27. package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
  28. package/dist/errors/EntityUniqueConstraintError.js +11 -0
  29. package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
  30. package/dist/errors/InvalidStateError.d.ts +3 -0
  31. package/dist/errors/InvalidStateError.js +11 -0
  32. package/dist/errors/InvalidStateError.js.map +1 -0
  33. package/dist/errors/QueryFailedError.js +1 -0
  34. package/dist/errors/QueryFailedError.js.map +1 -1
  35. package/dist/errors/index.d.ts +2 -0
  36. package/dist/errors/index.js +2 -0
  37. package/dist/errors/index.js.map +1 -1
  38. package/dist/testArtifacts.d.ts +17 -5
  39. package/dist/testArtifacts.js +31 -27
  40. package/dist/testArtifacts.js.map +1 -1
  41. package/dist/testMocks.d.ts +13 -10
  42. package/dist/testMocks.js +32 -13
  43. package/dist/testMocks.js.map +1 -1
  44. package/dist/utils.d.ts +1 -1
  45. package/dist/utils.js +21 -5
  46. package/dist/utils.js.map +1 -1
  47. package/package.json +16 -14
  48. package/src/Entity.test.ts +22 -5
  49. package/src/Entity.ts +423 -134
  50. package/src/Entity.types.ts +32 -66
  51. package/src/Nymph.ts +609 -176
  52. package/src/Nymph.types.ts +131 -26
  53. package/src/conf/d.ts +12 -0
  54. package/src/conf/defaults.ts +31 -0
  55. package/src/driver/NymphDriver.ts +289 -311
  56. package/src/driver/testArtifacts.ts +572 -181
  57. package/src/errors/EntityUniqueConstraintError.ts +6 -0
  58. package/src/errors/InvalidStateError.ts +6 -0
  59. package/src/errors/index.ts +4 -0
  60. package/src/nymphJoiProps.ts +2 -2
  61. package/src/testArtifacts.ts +18 -19
  62. package/src/testMocks.ts +55 -30
  63. package/src/utils.ts +22 -8
  64. package/tsconfig.json +3 -3
  65. package/typedoc.json +4 -0
@@ -1,15 +1,15 @@
1
1
  import type Nymph from './Nymph';
2
- import type { Options } from './Nymph.types';
2
+ import type Entity from './Entity';
3
3
 
4
4
  export type ACProperties = {
5
- user: any;
6
- group: any;
7
- acUser: any;
8
- acGroup: any;
9
- acOther: any;
10
- acRead: any;
11
- acWrite: any;
12
- acFull: any;
5
+ user: string | null;
6
+ group: string | null;
7
+ acUser: number | null;
8
+ acGroup: number | null;
9
+ acOther: number | null;
10
+ acRead: (string | null)[] | null;
11
+ acWrite: (string | null)[] | null;
12
+ acFull: (string | null)[] | null;
13
13
  };
14
14
 
15
15
  export type EntityReference = ['nymph_entity_reference', string, string];
@@ -178,12 +178,30 @@ export interface EntityInterface extends DataObjectInterface {
178
178
  * @returns The entity's serialized data object.
179
179
  */
180
180
  $getSData(): SerializedEntityData;
181
+ /**
182
+ * Get an array of strings that **must** be unique across the current etype.
183
+ *
184
+ * When you try to save another entity with any of the same unique strings,
185
+ * Nymph will throw an error.
186
+ *
187
+ * The default implementation of this method returns an empty array, meaning
188
+ * there are no uniqueness constraints applied to its etype.
189
+ *
190
+ * @returns Resolves to an array of entity's unique constraint strings.
191
+ */
192
+ $getUniques(): Promise<string[]>;
181
193
  /**
182
194
  * Get the original values of the AC properties.
183
195
  *
184
196
  * @returns An object of AC properties.
185
197
  */
186
198
  $getOriginalAcValues(): ACProperties;
199
+ /**
200
+ * Get the current values of the AC properties.
201
+ *
202
+ * @returns An object of AC properties.
203
+ */
204
+ $getCurrentAcValues(): ACProperties;
187
205
  /**
188
206
  * Get an object that holds the same data as the entity.
189
207
  *
@@ -271,61 +289,9 @@ export interface EntityInterface extends DataObjectInterface {
271
289
  $useSkipAc(useSkipAc: boolean): void;
272
290
  }
273
291
 
274
- export type EntityConstructor = (new (...args: any[]) => EntityInterface) & {
275
- /**
276
- * The instance of Nymph to use for queries.
277
- */
278
- nymph: Nymph;
279
- /**
280
- * A unique name for this type of entity used to separate its data from other
281
- * types of entities in the database.
282
- */
283
- ETYPE: string;
284
- /**
285
- * The lookup name for this entity.
286
- *
287
- * This is used for reference arrays (and sleeping references) and client
288
- * requests.
289
- */
290
- class: string;
291
- /**
292
- * Properties that will not be searchable from the frontend. If the frontend
293
- * includes any of these properties in any of their clauses, they will be
294
- * filtered out before the search is executed.
295
- */
296
- searchRestrictedData: string[];
297
- /**
298
- * The names of static methods allowed to be called by the frontend with
299
- * serverCallStatic.
300
- */
301
- clientEnabledStaticMethods: string[];
302
- /**
303
- * Create a new entity instance.
304
- *
305
- * @param guid An optional GUID to retrieve.
306
- */
307
- factory(guid?: string): Promise<EntityInterface>;
308
- /**
309
- * Create a new entity instance.
310
- *
311
- * @param guid An optional GUID to retrieve.
312
- */
313
- factorySync(guid?: string): EntityInterface;
314
- /**
315
- * Create a new sleeping reference instance.
316
- *
317
- * Sleeping references won't retrieve their data from the database until it
318
- * is actually used.
319
- *
320
- * @param reference The Nymph Entity Reference to use to wake.
321
- * @returns The new instance.
322
- */
323
- factoryReference(reference: EntityReference): EntityInterface;
324
- /**
325
- * Alter the options for a query for this entity.
326
- *
327
- * @param options The current options.
328
- * @returns The altered options.
329
- */
330
- alterOptions?<T extends Options>(options: T): T;
292
+ export type EntityConstructor<
293
+ D extends EntityData = EntityData,
294
+ E extends Entity<D> = Entity<D>,
295
+ > = (new (...args: any[]) => E) & {
296
+ [k in keyof typeof Entity]: (typeof Entity)[k];
331
297
  };