@nymphjs/nymph 1.0.0-beta.9 → 1.0.0-beta.91
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/CHANGELOG.md +436 -0
- package/README.md +10 -20
- package/dist/Entity.d.ts +277 -10
- package/dist/Entity.js +543 -148
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +53 -13
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +249 -23
- package/dist/Entity.types.js +1 -2
- package/dist/Nymph.d.ts +431 -12
- package/dist/Nymph.js +692 -180
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +65 -7
- package/dist/Nymph.types.js +3 -5
- package/dist/Nymph.types.js.map +1 -1
- package/dist/conf/d.d.ts +43 -0
- package/dist/conf/d.js +1 -2
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +26 -3
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +2 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +137 -39
- package/dist/driver/NymphDriver.js +344 -194
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/index.d.ts +2 -2
- package/dist/driver/index.js +3 -23
- package/dist/driver/index.js.map +1 -1
- package/dist/driver/testArtifacts.d.ts +2 -2
- package/dist/driver/testArtifacts.js +557 -92
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/ClassNotAvailableError.js +1 -5
- package/dist/errors/ClassNotAvailableError.js.map +1 -1
- package/dist/errors/EntityConflictError.js +1 -5
- package/dist/errors/EntityConflictError.js.map +1 -1
- package/dist/errors/EntityInvalidDataError.d.ts +6 -0
- package/dist/errors/EntityInvalidDataError.js +8 -6
- package/dist/errors/EntityInvalidDataError.js.map +1 -1
- package/dist/errors/EntityIsSleepingReferenceError.js +1 -5
- package/dist/errors/EntityIsSleepingReferenceError.js.map +1 -1
- package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
- package/dist/errors/EntityUniqueConstraintError.js +7 -0
- package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
- package/dist/errors/InvalidParametersError.js +1 -5
- package/dist/errors/InvalidParametersError.js.map +1 -1
- package/dist/errors/InvalidStateError.d.ts +3 -0
- package/dist/errors/InvalidStateError.js +7 -0
- package/dist/errors/InvalidStateError.js.map +1 -0
- package/dist/errors/NotConfiguredError.js +1 -5
- package/dist/errors/NotConfiguredError.js.map +1 -1
- package/dist/errors/QueryFailedError.js +2 -5
- package/dist/errors/QueryFailedError.js.map +1 -1
- package/dist/errors/UnableToConnectError.js +1 -5
- package/dist/errors/UnableToConnectError.js.map +1 -1
- package/dist/errors/index.d.ts +10 -8
- package/dist/errors/index.js +10 -24
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +14 -34
- package/dist/index.js.map +1 -1
- package/dist/nymphJoiProps.js +10 -15
- package/dist/nymphJoiProps.js.map +1 -1
- package/dist/testArtifacts.d.ts +18 -6
- package/dist/testArtifacts.js +32 -37
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +15 -12
- package/dist/testMocks.js +40 -29
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +40 -29
- package/dist/utils.js.map +1 -1
- package/jest.config.js +11 -2
- package/package.json +22 -19
- package/src/Entity.test.ts +52 -7
- package/src/Entity.ts +458 -147
- package/src/Entity.types.ts +64 -74
- package/src/Nymph.ts +754 -321
- package/src/Nymph.types.ts +131 -26
- package/src/conf/d.ts +25 -0
- package/src/conf/defaults.ts +34 -1
- package/src/conf/index.ts +2 -2
- package/src/driver/NymphDriver.ts +362 -359
- package/src/driver/index.ts +2 -2
- package/src/driver/testArtifacts.ts +609 -185
- package/src/errors/EntityUniqueConstraintError.ts +6 -0
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/index.ts +12 -8
- package/src/index.ts +11 -11
- package/src/nymphJoiProps.ts +2 -2
- package/src/testArtifacts.ts +19 -20
- package/src/testMocks.ts +60 -35
- package/src/type/locutus.d.ts +3 -0
- package/src/utils.ts +39 -18
- package/tsconfig.json +5 -3
- package/typedoc.json +4 -0
package/src/Entity.types.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type Nymph from './Nymph';
|
|
2
|
-
import type
|
|
1
|
+
import type Nymph from './Nymph.js';
|
|
2
|
+
import type Entity from './Entity.js';
|
|
3
3
|
|
|
4
4
|
export type ACProperties = {
|
|
5
|
-
user:
|
|
6
|
-
group:
|
|
7
|
-
acUser:
|
|
8
|
-
acGroup:
|
|
9
|
-
acOther:
|
|
10
|
-
acRead:
|
|
11
|
-
acWrite:
|
|
12
|
-
acFull:
|
|
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];
|
|
@@ -137,6 +137,17 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
137
137
|
* Array of the entity's tags.
|
|
138
138
|
*/
|
|
139
139
|
tags: string[];
|
|
140
|
+
/**
|
|
141
|
+
* Get a GUID for the entity.
|
|
142
|
+
*
|
|
143
|
+
* If the entity has already been saved, this will just return the GUID.
|
|
144
|
+
*
|
|
145
|
+
* If the entity has not yet been saved, this will return a new GUID that gets
|
|
146
|
+
* held by the entity. The `guid` property will remain null, but this method
|
|
147
|
+
* will then always return the same GUID. When the entity is eventually saved
|
|
148
|
+
* into the database, this GUID will be used.
|
|
149
|
+
*/
|
|
150
|
+
$getGuaranteedGUID(): string;
|
|
140
151
|
/**
|
|
141
152
|
* Add one or more tags.
|
|
142
153
|
*
|
|
@@ -162,9 +173,10 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
162
173
|
* This should only be used by Nymph to save the data into storage.
|
|
163
174
|
*
|
|
164
175
|
* @param includeSData Whether to include the serialized data as well.
|
|
176
|
+
* @param referenceOnlyExisting Whether to only turn existing entities into references.
|
|
165
177
|
* @returns The entity's data object.
|
|
166
178
|
*/
|
|
167
|
-
$getData(includeSData?: boolean): EntityData;
|
|
179
|
+
$getData(includeSData?: boolean, referenceOnlyExisting?: boolean): EntityData;
|
|
168
180
|
/**
|
|
169
181
|
* Used to retrieve the serialized data object.
|
|
170
182
|
*
|
|
@@ -178,12 +190,30 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
178
190
|
* @returns The entity's serialized data object.
|
|
179
191
|
*/
|
|
180
192
|
$getSData(): SerializedEntityData;
|
|
193
|
+
/**
|
|
194
|
+
* Get an array of strings that **must** be unique across the current etype.
|
|
195
|
+
*
|
|
196
|
+
* When you try to save another entity with any of the same unique strings,
|
|
197
|
+
* Nymph will throw an error.
|
|
198
|
+
*
|
|
199
|
+
* The default implementation of this method returns an empty array, meaning
|
|
200
|
+
* there are no uniqueness constraints applied to its etype.
|
|
201
|
+
*
|
|
202
|
+
* @returns Resolves to an array of entity's unique constraint strings.
|
|
203
|
+
*/
|
|
204
|
+
$getUniques(): Promise<string[]>;
|
|
181
205
|
/**
|
|
182
206
|
* Get the original values of the AC properties.
|
|
183
207
|
*
|
|
184
208
|
* @returns An object of AC properties.
|
|
185
209
|
*/
|
|
186
210
|
$getOriginalAcValues(): ACProperties;
|
|
211
|
+
/**
|
|
212
|
+
* Get the current values of the AC properties.
|
|
213
|
+
*
|
|
214
|
+
* @returns An object of AC properties.
|
|
215
|
+
*/
|
|
216
|
+
$getCurrentAcValues(): ACProperties;
|
|
187
217
|
/**
|
|
188
218
|
* Get an object that holds the same data as the entity.
|
|
189
219
|
*
|
|
@@ -239,15 +269,25 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
239
269
|
/**
|
|
240
270
|
* Used to set the data.
|
|
241
271
|
*
|
|
242
|
-
* This should only be used by Nymph to push the data from storage
|
|
272
|
+
* This should only be used by Nymph to push the data from storage or the
|
|
273
|
+
* client.
|
|
243
274
|
*
|
|
244
275
|
* `sdata` is used by Nymph to avoid unserializing data that hasn't been
|
|
245
276
|
* requested yet.
|
|
246
277
|
*
|
|
278
|
+
* If `source` is set to "server", the data is coming from the DB or the
|
|
279
|
+
* cache. If not, assume the data is coming from the client and can't be
|
|
280
|
+
* trusted.
|
|
281
|
+
*
|
|
247
282
|
* @param data The data object.
|
|
248
283
|
* @param sdata The serialized data object.
|
|
284
|
+
* @param source If this is set to "server", the data is coming from the DB.
|
|
249
285
|
*/
|
|
250
|
-
$putData(
|
|
286
|
+
$putData(
|
|
287
|
+
data: EntityData,
|
|
288
|
+
sdata?: SerializedEntityData,
|
|
289
|
+
source?: 'server',
|
|
290
|
+
): void;
|
|
251
291
|
/**
|
|
252
292
|
* Remove one or more tags.
|
|
253
293
|
*
|
|
@@ -257,12 +297,14 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
257
297
|
/**
|
|
258
298
|
* Return a Nymph Entity Reference for this entity.
|
|
259
299
|
*
|
|
260
|
-
* If the entity hasn't been saved yet (and has no GUID), it will
|
|
261
|
-
*
|
|
300
|
+
* If the entity hasn't been saved yet (and has no GUID), it will use the
|
|
301
|
+
* guaranteed GUID from `$getGuaranteedGUID`, unless `existingOnly` is true,
|
|
302
|
+
* then it will return the entity.
|
|
262
303
|
*
|
|
263
|
-
* @
|
|
304
|
+
* @param existingOnly Whether to only turn existing entities into references.
|
|
305
|
+
* @returns A Nymph Entity Reference array.
|
|
264
306
|
*/
|
|
265
|
-
$toReference(): EntityReference | EntityInterface;
|
|
307
|
+
$toReference(existingOnly?: boolean): EntityReference | EntityInterface;
|
|
266
308
|
/**
|
|
267
309
|
* Set whether to use "skipAc" when accessing entity references.
|
|
268
310
|
*
|
|
@@ -271,61 +313,9 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
271
313
|
$useSkipAc(useSkipAc: boolean): void;
|
|
272
314
|
}
|
|
273
315
|
|
|
274
|
-
export type EntityConstructor
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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;
|
|
316
|
+
export type EntityConstructor<
|
|
317
|
+
D extends EntityData = EntityData,
|
|
318
|
+
E extends Entity<D> = Entity<D>,
|
|
319
|
+
> = (new (...args: any[]) => E) & {
|
|
320
|
+
[k in keyof typeof Entity]: (typeof Entity)[k];
|
|
331
321
|
};
|