@nymphjs/nymph 1.0.0-beta.13 → 1.0.0-beta.131

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 (123) hide show
  1. package/CHANGELOG.md +650 -0
  2. package/README.md +34 -24
  3. package/dist/Entity.d.ts +306 -15
  4. package/dist/Entity.js +688 -226
  5. package/dist/Entity.js.map +1 -1
  6. package/dist/Entity.test.js +75 -29
  7. package/dist/Entity.test.js.map +1 -1
  8. package/dist/Entity.types.d.ts +275 -28
  9. package/dist/Entity.types.js +1 -2
  10. package/dist/Nymph.d.ts +575 -11
  11. package/dist/Nymph.js +825 -288
  12. package/dist/Nymph.js.map +1 -1
  13. package/dist/Nymph.types.d.ts +117 -7
  14. package/dist/Nymph.types.js +47 -5
  15. package/dist/Nymph.types.js.map +1 -1
  16. package/dist/conf/defaults.d.ts +1 -1
  17. package/dist/conf/defaults.js +26 -3
  18. package/dist/conf/defaults.js.map +1 -1
  19. package/dist/conf/index.d.ts +50 -2
  20. package/dist/conf/index.js +2 -8
  21. package/dist/conf/index.js.map +1 -1
  22. package/dist/decorators/index.d.ts +1 -0
  23. package/dist/decorators/index.js +2 -0
  24. package/dist/decorators/index.js.map +1 -0
  25. package/dist/decorators/transactional.d.ts +12 -0
  26. package/dist/decorators/transactional.js +45 -0
  27. package/dist/decorators/transactional.js.map +1 -0
  28. package/dist/driver/NymphDriver.d.ts +209 -41
  29. package/dist/driver/NymphDriver.js +737 -242
  30. package/dist/driver/NymphDriver.js.map +1 -1
  31. package/dist/driver/index.d.ts +1 -2
  32. package/dist/driver/index.js +2 -23
  33. package/dist/driver/index.js.map +1 -1
  34. package/dist/driver/testArtifacts.d.ts +4 -4
  35. package/dist/driver/testArtifacts.js +2016 -1086
  36. package/dist/driver/testArtifacts.js.map +1 -1
  37. package/dist/errors/ClassNotAvailableError.js +1 -5
  38. package/dist/errors/ClassNotAvailableError.js.map +1 -1
  39. package/dist/errors/EntityConflictError.js +1 -5
  40. package/dist/errors/EntityConflictError.js.map +1 -1
  41. package/dist/errors/EntityInvalidDataError.d.ts +6 -0
  42. package/dist/errors/EntityInvalidDataError.js +8 -6
  43. package/dist/errors/EntityInvalidDataError.js.map +1 -1
  44. package/dist/errors/EntityIsSleepingReferenceError.js +1 -5
  45. package/dist/errors/EntityIsSleepingReferenceError.js.map +1 -1
  46. package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
  47. package/dist/errors/EntityUniqueConstraintError.js +7 -0
  48. package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
  49. package/dist/errors/HttpError.d.ts +5 -0
  50. package/dist/errors/HttpError.js +11 -0
  51. package/dist/errors/HttpError.js.map +1 -0
  52. package/dist/errors/InvalidParametersError.js +1 -5
  53. package/dist/errors/InvalidParametersError.js.map +1 -1
  54. package/dist/errors/InvalidStateError.d.ts +3 -0
  55. package/dist/errors/InvalidStateError.js +7 -0
  56. package/dist/errors/InvalidStateError.js.map +1 -0
  57. package/dist/errors/MethodFailedError.d.ts +3 -0
  58. package/dist/errors/MethodFailedError.js +7 -0
  59. package/dist/errors/MethodFailedError.js.map +1 -0
  60. package/dist/errors/NotConfiguredError.js +1 -5
  61. package/dist/errors/NotConfiguredError.js.map +1 -1
  62. package/dist/errors/QueryFailedError.d.ts +2 -1
  63. package/dist/errors/QueryFailedError.js +5 -6
  64. package/dist/errors/QueryFailedError.js.map +1 -1
  65. package/dist/errors/UnableToConnectError.js +1 -5
  66. package/dist/errors/UnableToConnectError.js.map +1 -1
  67. package/dist/errors/index.d.ts +12 -8
  68. package/dist/errors/index.js +12 -24
  69. package/dist/errors/index.js.map +1 -1
  70. package/dist/helpers/index.d.ts +1 -0
  71. package/dist/helpers/index.js +2 -0
  72. package/dist/helpers/index.js.map +1 -0
  73. package/dist/helpers/transaction.d.ts +15 -0
  74. package/dist/helpers/transaction.js +47 -0
  75. package/dist/helpers/transaction.js.map +1 -0
  76. package/dist/index.d.ts +13 -11
  77. package/dist/index.js +16 -34
  78. package/dist/index.js.map +1 -1
  79. package/dist/nymphJoiProps.d.ts +1 -1
  80. package/dist/nymphJoiProps.js +10 -15
  81. package/dist/nymphJoiProps.js.map +1 -1
  82. package/dist/testArtifacts.d.ts +21 -6
  83. package/dist/testArtifacts.js +124 -50
  84. package/dist/testArtifacts.js.map +1 -1
  85. package/dist/testMocks.d.ts +27 -12
  86. package/dist/testMocks.js +44 -33
  87. package/dist/testMocks.js.map +1 -1
  88. package/dist/utils.d.ts +5 -5
  89. package/dist/utils.js +106 -68
  90. package/dist/utils.js.map +1 -1
  91. package/jest.config.js +31 -5
  92. package/package.json +43 -24
  93. package/src/Entity.test.ts +73 -23
  94. package/src/Entity.ts +646 -252
  95. package/src/Entity.types.ts +102 -90
  96. package/src/Nymph.ts +930 -517
  97. package/src/Nymph.types.ts +145 -39
  98. package/src/conf/defaults.ts +34 -1
  99. package/src/conf/index.ts +50 -2
  100. package/src/decorators/index.ts +1 -0
  101. package/src/decorators/transactional.ts +63 -0
  102. package/src/driver/NymphDriver.ts +987 -417
  103. package/src/driver/index.ts +1 -3
  104. package/src/driver/testArtifacts.ts +2699 -1628
  105. package/src/errors/EntityUniqueConstraintError.ts +6 -0
  106. package/src/errors/HttpError.ts +12 -0
  107. package/src/errors/InvalidStateError.ts +6 -0
  108. package/src/errors/MethodFailedError.ts +6 -0
  109. package/src/errors/QueryFailedError.ts +3 -1
  110. package/src/errors/index.ts +16 -8
  111. package/src/helpers/index.ts +1 -0
  112. package/src/helpers/transaction.ts +65 -0
  113. package/src/index.ts +13 -11
  114. package/src/nymphJoiProps.ts +2 -2
  115. package/src/testArtifacts.ts +69 -20
  116. package/src/testMocks.ts +107 -41
  117. package/src/utils.ts +102 -67
  118. package/tsconfig.json +6 -3
  119. package/typedoc.json +4 -0
  120. package/dist/conf/d.d.ts +0 -6
  121. package/dist/conf/d.js +0 -3
  122. package/dist/conf/d.js.map +0 -1
  123. package/src/conf/d.ts +0 -24
package/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Nymph
2
2
 
3
- Powerful object data storage and querying.
3
+ Application Data and Access Framework for Node.js and the browser.
4
4
 
5
- The Nymph core provides the base level classes and utilities to query the database, save data to it, and define different data types.
5
+ https://nymph.io/
6
+
7
+ Nymph.js includes an object relational mapper with nested, atomic transactions, a powerful query language, a user and group manager with granular access controls, a REST server, a publish/subscribe server for real time collaboration, and a client for Node.js and the browser. It allows rapid prototyping and production ready speed and features.
8
+
9
+ Nymph can use SQLite3, MySQL, or PostgreSQL as its database backend. You can use SQLite in development, and MySQL or Postgres in production. You can even use Nymph with SQLite in an Electron app.
10
+
11
+ Nymph is the framework that powers the [Port87](https://port87.com) email service. It also powers [Nephele](https://forge.sciactive.com/sciactive/nephele)'s deduplication adapter. Nymph was started in 2009 as part of a framework called [Pines](https://sourceforge.net/projects/pines/). In 2012, it was spun off into its own project, and in 2021, it was migrated to Node.js. As part of Pines, it powered TECHsmart's entire ERP system for over a decade.
12
+
13
+ The Nymph core package provides the base level classes and utilities to query the database, save data to it, and define different data types.
6
14
 
7
15
  ## Installation
8
16
 
@@ -12,7 +20,7 @@ npm install --save @nymphjs/nymph
12
20
 
13
21
  ## Drivers
14
22
 
15
- To use Nymph, you need a database driver. Nymph.js provides a [MySQL driver](../driver-mysql/README.md), a [PostgreSQL driver](../driver-postgresql/README.md), and a [SQLite3 driver](../driver-sqlite3/README.md). They all provide the exact same functionality.
23
+ To use Nymph, you need a database driver. Nymph.js provides a [MySQL driver](../driver-mysql/README.md), a [PostgreSQL driver](../driver-postgresql/README.md), and a [SQLite3 driver](../driver-sqlite3/README.md). They all provide the exact same functionality (with the exception of alphanumerical sort order, which is dependent on database collation).
16
24
 
17
25
  ## Usage
18
26
 
@@ -46,7 +54,7 @@ async function run() {
46
54
 
47
55
  const otherPendingTodos = await nymph.getEntities(
48
56
  { class: Todo },
49
- { type: '&', '!guid': myEntity.guid, equal: ['done', false] }
57
+ { type: '&', '!guid': myEntity.guid, equal: ['done', false] },
50
58
  );
51
59
 
52
60
  const total = otherPendingTodos.length;
@@ -54,7 +62,7 @@ async function run() {
54
62
  console.log(
55
63
  `Besides the one I just created, there ${
56
64
  single ? 'is' : 'are'
57
- } ${total} pending todo${single ? '' : 's'} in the database.`
65
+ } ${total} pending todo${single ? '' : 's'} in the database.`,
58
66
  );
59
67
  }
60
68
  ```
@@ -72,23 +80,13 @@ export default class Todo extends Entity<TodoData> {
72
80
  static ETYPE = 'todo'; // This is used for the table name(s) in the DB.
73
81
  static class = 'Todo'; // This is used to map references to their class.
74
82
 
75
- static async factory(guid?: string): Promise<Todo & TodoData> {
76
- return (await super.factory(guid)) as Todo & TodoData;
77
- }
78
-
79
- static factorySync(guid?: string): Todo & TodoData {
80
- return super.factorySync(guid) as Todo & TodoData;
81
- }
82
-
83
- constructor(guid?: string) {
84
- super(guid);
83
+ constructor() {
84
+ super();
85
85
 
86
- if (this.guid == null) {
87
- // Within the methods of an entity, you will use `this.$data` to access
88
- // its data. Outside, you don't need the $data part.
89
- this.$data.text = '';
90
- this.$data.done = false;
91
- }
86
+ // Within the methods of an entity, you will use `this.$data` to access
87
+ // its data. Outside, you don't need the $data part.
88
+ this.$data.text = '';
89
+ this.$data.done = false;
92
90
  }
93
91
 
94
92
  async $getOtherTodos() {
@@ -97,7 +95,7 @@ export default class Todo extends Entity<TodoData> {
97
95
  // instance of Nymph, so it could be a transactional instance.
98
96
  const otherTodos = await this.$nymph.getEntities(
99
97
  { class: Todo },
100
- { type: '!&', guid: this.guid }
98
+ { type: '!&', guid: this.guid },
101
99
  );
102
100
  return otherTodos;
103
101
  }
@@ -106,11 +104,23 @@ export default class Todo extends Entity<TodoData> {
106
104
 
107
105
  ## Options
108
106
 
109
- See the [config declaration file](src/conf/d.ts).
107
+ See the [config declaration file](src/conf/index.ts).
108
+
109
+ # Live Migrations
110
+
111
+ Sometimes database changes can be live migrated. In these cases, running `needsMigration()` will tell you about them, and the docblock for that method will give you more information. You should always run this method after updating to a new version of Nymph to see what needs to be migrated, if anything.
112
+
113
+ If a migration is needed, you should export the DB in the version you were using before, in case anything goes wrong during the migration.
114
+
115
+ The next step is to use the `liveMigration(migrationType)` method with the correct migration type.
116
+
117
+ If required (explained in the docblock), you might then need to run a specific import on all of your entities. This is very important, and you might not be able to use new features or upgrade further without performing this step.
118
+
119
+ Note that you can always export the DB in the version you were previously using, completely clear the DB (drop all of the tables), then import the DB in the new version.
110
120
 
111
121
  # License
112
122
 
113
- Copyright 2021 SciActive Inc
123
+ Copyright 2021-2026 SciActive Inc
114
124
 
115
125
  Licensed under the Apache License, Version 2.0 (the "License");
116
126
  you may not use this file except in compliance with the License.
package/dist/Entity.d.ts CHANGED
@@ -1,57 +1,348 @@
1
- import type Nymph from './Nymph';
2
- import { ACProperties, EntityData, EntityInterface, EntityJson, EntityPatch, EntityReference, SerializedEntityData } from './Entity.types';
1
+ import type Nymph from './Nymph.js';
2
+ import type { Options } from './Nymph.types.js';
3
+ import type { ACProperties, EntityConstructor, EntityData, EntityInterface, EntityJson, EntityObject, EntityPatch, EntityReference, SerializedEntityData } from './Entity.types.js';
4
+ export type EntityDataType<T> = T extends Entity<infer DataType> ? DataType : never;
5
+ export type EntityInstanceType<T extends EntityConstructor> = T extends new () => infer E ? E & EntityDataType<E> : never;
6
+ export type EntityObjectType<T extends EntityConstructor> = T extends new () => infer E ? EntityObject & EntityDataType<E> : never;
7
+ /**
8
+ * Database abstraction object.
9
+ *
10
+ * Provides a way to access, manipulate, and store data in Nymph.
11
+ *
12
+ * The GUID is not set until the entity is saved. GUIDs must be unique forever,
13
+ * even after deletion. It's the job of the Nymph DB driver to make sure no two
14
+ * entities ever have the same GUID. This is generally done by using a large
15
+ * randomly generated ID.
16
+ *
17
+ * Each entity class has an etype that determines which table(s) in the database
18
+ * it belongs to. If two entity classes have the same etype, their data will be
19
+ * stored in the same table(s). This isn't a good idea, however, because
20
+ * references to an entity store a class name, not an etype.
21
+ *
22
+ * Tags are used to classify entities. Where an etype is used to separate data
23
+ * by tables, tags can be used to separate entities within a table. You can
24
+ * define specific tags to be protected, meaning they cannot be added/removed
25
+ * from the client. It can be useful to allow user defined tags, such as for
26
+ * blog posts.
27
+ *
28
+ * Simply calling $delete() will not unset the entity. It will still take up
29
+ * memory. Likewise, simply calling unset will not delete the entity from the
30
+ * DB.
31
+ *
32
+ * Some notes about $equals() and $is(), the replacements for "==":
33
+ *
34
+ * The == operator will likely not give you the result you want, since two
35
+ * instances of the same entity will fail that check, even though they represent
36
+ * the same data in the database.
37
+ *
38
+ * $equals() performs a more strict comparison of the entity to another. Use
39
+ * $equals() instead of the == operator when you want to check both the entities
40
+ * they represent, and the data inside them. In order to return true for
41
+ * $equals(), the entity and object must meet the following criteria:
42
+ *
43
+ * - They must be entities.
44
+ * - They must have equal GUIDs, or both must have no GUID.
45
+ * - Their data and tags must be equal.
46
+ *
47
+ * $is() performs a less strict comparison of the entity to another. Use $is()
48
+ * instead of the == operator when the entity's data may have been changed, but
49
+ * you only care if they represent the same entity. In order to return true, the
50
+ * entity and object must meet the following criteria:
51
+ *
52
+ * - They must be entities.
53
+ * - They must have equal GUIDs, or both must have no GUID.
54
+ * - If they have no GUIDs, their data and tags must be equal.
55
+ *
56
+ * Some notes about saving entities in other entity's properties:
57
+ *
58
+ * Entities use references in the DB to store an entity in their properties. The
59
+ * reference is stored as an array with the values:
60
+ *
61
+ * - 0 => The string 'nymph_entity_reference'
62
+ * - 1 => The referenced entity's GUID.
63
+ * - 2 => The referenced entity's class name.
64
+ *
65
+ * Since the referenced entity's class name (meaning the `class` static
66
+ * property, not the name of the class itself) is stored in the reference on the
67
+ * parent entity, if you change the class name in an update, you need to
68
+ * reassign all referenced entities of that class and resave.
69
+ *
70
+ * When an entity is loaded, it does not request its referenced entities from
71
+ * Nymph. Instead, it creates instances without data called sleeping references.
72
+ * When you first access an entity's data, if it is a sleeping reference, it
73
+ * will fill its data from the DB. You can call clearCache() to turn all the
74
+ * entities back into sleeping references.
75
+ */
3
76
  export default class Entity<T extends EntityData = EntityData> implements EntityInterface {
77
+ /**
78
+ * The instance of Nymph to use for queries.
79
+ */
4
80
  static nymph: Nymph;
81
+ /**
82
+ * A unique name for this type of entity used to separate its data from other
83
+ * types of entities in the database.
84
+ */
5
85
  static ETYPE: string;
86
+ /**
87
+ * The lookup name for this entity.
88
+ *
89
+ * This is used for reference arrays (and sleeping references) and client
90
+ * requests.
91
+ */
6
92
  static class: string;
7
93
  $nymph: Nymph;
8
94
  guid: string | null;
9
95
  cdate: number | null;
10
96
  mdate: number | null;
11
97
  tags: string[];
98
+ /**
99
+ * The data proxy handler.
100
+ */
12
101
  protected $dataHandler: Object;
102
+ /**
103
+ * The actual data store.
104
+ */
13
105
  protected $dataStore: T;
106
+ /**
107
+ * The actual sdata store.
108
+ */
14
109
  protected $sdata: SerializedEntityData;
110
+ /**
111
+ * The data proxy object.
112
+ */
15
113
  protected $data: T;
114
+ /**
115
+ * Whether this instance is a sleeping reference.
116
+ */
16
117
  protected $isASleepingReference: boolean;
118
+ /**
119
+ * The reference to use to wake.
120
+ */
17
121
  protected $sleepingReference: EntityReference | null;
122
+ /**
123
+ * A promise that resolved when the entity's data is wake.
124
+ */
125
+ protected $wakePromise: Promise<Entity<T>> | null;
126
+ /**
127
+ * Properties that will not be serialized into JSON with toJSON(). This
128
+ * can be considered a denylist, because these properties will not be set
129
+ * with incoming JSON.
130
+ *
131
+ * Clients CAN still determine what is in these properties, unless they are
132
+ * also listed in searchRestrictedData.
133
+ */
18
134
  protected $privateData: string[];
135
+ /**
136
+ * Whether this entity should publish changes to PubSub servers.
137
+ */
138
+ static pubSubEnabled: boolean;
139
+ /**
140
+ * Whether this entity should be accessible on the frontend through the REST
141
+ * server.
142
+ *
143
+ * If this is false, any request from the client that attempts to use this
144
+ * entity will fail.
145
+ */
146
+ static restEnabled: boolean;
147
+ /**
148
+ * Properties that will not be searchable from the frontend. If the frontend
149
+ * includes any of these properties in any of their clauses, they will be
150
+ * filtered out before the search is executed.
151
+ */
19
152
  static searchRestrictedData: string[];
153
+ /**
154
+ * Properties that can only be modified by server side code. They will still
155
+ * be visible on the frontend, unlike $privateData, but any changes to them
156
+ * that come from the frontend will be ignored.
157
+ *
158
+ * In addition to what's listed here, all of the access control properties
159
+ * will be included when Tilmeld is being used. These are:
160
+ *
161
+ * - acUser
162
+ * - acGroup
163
+ * - acOther
164
+ * - acRead
165
+ * - acWrite
166
+ * - acFull
167
+ * - user
168
+ * - group
169
+ *
170
+ * You should modify these through client enabled methods or the $save method
171
+ * instead, for safety.
172
+ */
20
173
  protected $protectedData: string[];
174
+ /**
175
+ * If this is defined, then it lists the only properties that will be
176
+ * accepted from incoming JSON. Any other properties will be ignored.
177
+ *
178
+ * If you use an allowlist, you don't need to use protectedData, since you
179
+ * can simply leave those entries out of allowlistData.
180
+ */
21
181
  protected $allowlistData?: string[];
182
+ /**
183
+ * Tags that can only be added/removed by server side code. They will still be
184
+ * visible on the frontend, but any changes to them that come from the
185
+ * frontend will be ignored.
186
+ */
22
187
  protected $protectedTags: string[];
188
+ /**
189
+ * If this is defined, then it lists the only tags that will be accepted from
190
+ * incoming JSON. Any other tags will be ignored.
191
+ */
23
192
  protected $allowlistTags?: string[];
193
+ /**
194
+ * The names of methods allowed to be called by the frontend with serverCall.
195
+ */
24
196
  protected $clientEnabledMethods: string[];
197
+ /**
198
+ * The names of static methods allowed to be called by the frontend with
199
+ * serverCallStatic.
200
+ */
25
201
  static clientEnabledStaticMethods: string[];
202
+ /**
203
+ * Whether to use "skipAc" when accessing entity references.
204
+ */
26
205
  private $skipAc;
206
+ /**
207
+ * The AC properties' values when the entity was loaded.
208
+ */
27
209
  private $originalAcValues;
28
- constructor(guid?: string);
29
- static factory(guid?: string): Promise<EntityInterface | Entity<EntityData>>;
30
- static factorySync(guid?: string): Entity<EntityData>;
31
- static factoryReference(reference: EntityReference): Entity<EntityData>;
32
- toJSON(): EntityReference | EntityJson | null;
210
+ /**
211
+ * This is used to hold a generated GUID for a new entity.
212
+ */
213
+ private $guaranteedGUID;
214
+ /**
215
+ * Alter the options for a query for this entity.
216
+ *
217
+ * @param options The current options.
218
+ * @returns The altered options.
219
+ */
220
+ static alterOptions?<T extends Options>(options: T): T;
221
+ /**
222
+ * Initialize an entity.
223
+ */
224
+ constructor(..._rest: any[]);
225
+ private $existingProxy?;
226
+ protected $proxy(): this & T;
227
+ /**
228
+ * Create or retrieve a new entity instance.
229
+ *
230
+ * Note that this will always return an entity, even if the GUID is not found.
231
+ *
232
+ * @param guid An optional GUID to retrieve.
233
+ */
234
+ static factory<E extends Entity>(this: {
235
+ new (): E;
236
+ }, guid?: string): Promise<E & EntityDataType<E>>;
237
+ /**
238
+ * Create a new entity instance.
239
+ */
240
+ static factorySync<E extends Entity>(this: {
241
+ new (): E;
242
+ }): E & EntityDataType<E>;
243
+ /**
244
+ * Create a new sleeping reference instance.
245
+ *
246
+ * Sleeping references won't retrieve their data from the database until they
247
+ * are readied with `$wake()` or a parent's `$wakeAll()`.
248
+ *
249
+ * @param reference The Nymph Entity Reference to use to wake.
250
+ * @returns The new instance.
251
+ */
252
+ static factoryReference<E extends Entity>(this: {
253
+ new (): E;
254
+ }, reference: EntityReference): E & EntityDataType<E>;
255
+ /**
256
+ * Get an array of strings that **must** be unique across the current etype.
257
+ *
258
+ * When you try to save another entity with any of the same unique strings,
259
+ * Nymph will throw an error.
260
+ *
261
+ * The default implementation of this static method instantiates the entity,
262
+ * assigns all of the given data, then calls `$getUniques` and returns its
263
+ * output. This can have a performance impact if a lot of extra processing
264
+ * happens during any of these steps. You can override this method to
265
+ * calculate the unique strings faster, but you must return the same strings
266
+ * that would be returned by `$getUniques`.
267
+ *
268
+ * @returns Resolves to an array of entity's unique constraint strings.
269
+ */
270
+ static getUniques({ guid, cdate, mdate, tags, data, sdata, }: {
271
+ guid?: string;
272
+ cdate?: number;
273
+ mdate?: number;
274
+ tags: string[];
275
+ data: EntityData;
276
+ sdata?: SerializedEntityData;
277
+ }): Promise<string[]>;
278
+ /**
279
+ * Get a string for full text search for one of an entity's properties.
280
+ *
281
+ * The result will be tokenized and stored as the full text search index for
282
+ * use with "search" clauses.
283
+ *
284
+ * Return null to not include any tokens in the full text search storage.
285
+ *
286
+ * You shouldn't use any other entity data to transform the text, as it won't
287
+ * always be available. This function is meant for things like stripping HTML
288
+ * tags.
289
+ *
290
+ * @returns By default, returns the value if it is a string.
291
+ */
292
+ static getFTSText(_name: string, value: any): string | null;
293
+ toJSON(): EntityJson | EntityReference | null;
294
+ $setNymph(nymph: Nymph): void;
295
+ $getGuaranteedGUID(): string;
33
296
  $addTag(...tags: string[]): void;
34
297
  $arraySearch(array: any[], strict?: boolean): number;
35
298
  $clearCache(): void;
36
299
  $getClientEnabledMethods(): string[];
37
- $delete(): Promise<boolean>;
300
+ $delete(): Promise<void>;
38
301
  $equals(object: any): boolean;
39
- $getData(includeSData?: boolean): any;
302
+ $getData(includeSData?: boolean): T;
40
303
  $getSData(): SerializedEntityData;
304
+ $getUniques(): Promise<string[]>;
41
305
  $getOriginalAcValues(): ACProperties;
42
- $getValidatable(): any;
306
+ $getCurrentAcValues(): ACProperties;
307
+ $getAcUid(): any;
308
+ $getAcGid(): any;
309
+ $getAcReadIds(): (string | null)[] | null;
310
+ $getAcWriteIds(): (string | null)[] | null;
311
+ $getAcFullIds(): (string | null)[] | null;
312
+ $getValidatable(): {
313
+ guid: string | null;
314
+ cdate: number | null;
315
+ mdate: number | null;
316
+ tags: string[];
317
+ } & T;
43
318
  $getTags(): string[];
44
319
  $hasTag(...tags: string[]): boolean;
45
320
  $inArray(array: any[], strict?: boolean): boolean;
46
321
  $is(object: any): boolean;
47
322
  $jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
48
323
  $jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
49
- $putData(data: EntityData, sdata?: SerializedEntityData): void;
324
+ $putData(data: EntityData, sdata?: SerializedEntityData, _source?: 'server'): void;
325
+ /**
326
+ * Set up a sleeping reference.
327
+ * @param array $reference The reference to use to wake.
328
+ */
50
329
  protected $referenceSleep(reference: EntityReference): void;
51
- protected $referenceWake(): boolean;
52
- $refresh(): Promise<boolean | 0>;
330
+ /**
331
+ * Check if this is a sleeping reference and throw an error if so.
332
+ */
333
+ protected $check(): void;
334
+ /**
335
+ * Check if this is a sleeping reference.
336
+ */
337
+ $asleep(): boolean;
338
+ /**
339
+ * Wake from a sleeping reference.
340
+ */
341
+ $wake(): Promise<Entity<T>>;
342
+ $wakeAll(level?: number): Promise<Entity<T>>;
343
+ $refresh(): Promise<boolean>;
53
344
  $removeTag(...tags: string[]): void;
54
- $save(): Promise<boolean>;
55
- $toReference(): EntityReference | this;
345
+ $save(): Promise<void>;
346
+ $toReference(existingOnly?: boolean): EntityReference | (this & T);
56
347
  $useSkipAc(skipAc: boolean): void;
57
348
  }