@nymphjs/nymph 1.0.0-beta.11 → 1.0.0-beta.111
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 +540 -0
- package/README.md +23 -21
- package/dist/Entity.d.ts +293 -10
- package/dist/Entity.js +560 -148
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +52 -13
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +256 -23
- package/dist/Entity.types.js +1 -2
- package/dist/Nymph.d.ts +586 -12
- package/dist/Nymph.js +844 -179
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +81 -8
- 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 +201 -40
- package/dist/driver/NymphDriver.js +685 -239
- 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 +909 -93
- 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/HttpError.d.ts +5 -0
- package/dist/errors/HttpError.js +11 -0
- package/dist/errors/HttpError.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.d.ts +2 -1
- package/dist/errors/QueryFailedError.js +5 -6
- 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 +11 -8
- package/dist/errors/index.js +11 -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.d.ts +1 -1
- package/dist/nymphJoiProps.js +10 -15
- package/dist/nymphJoiProps.js.map +1 -1
- package/dist/testArtifacts.d.ts +19 -6
- package/dist/testArtifacts.js +32 -37
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +27 -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 +24 -20
- package/src/Entity.test.ts +50 -7
- package/src/Entity.ts +489 -150
- package/src/Entity.types.ts +72 -74
- package/src/Nymph.ts +985 -322
- package/src/Nymph.types.ts +150 -27
- 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 +859 -412
- package/src/driver/index.ts +2 -2
- package/src/driver/testArtifacts.ts +1090 -186
- package/src/errors/EntityUniqueConstraintError.ts +6 -0
- package/src/errors/HttpError.ts +12 -0
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/QueryFailedError.ts +3 -1
- package/src/errors/index.ts +14 -8
- package/src/index.ts +11 -11
- package/src/nymphJoiProps.ts +2 -2
- package/src/testArtifacts.ts +20 -20
- package/src/testMocks.ts +76 -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];
|
|
@@ -22,6 +22,14 @@ export type SerializedEntityData = {
|
|
|
22
22
|
[k: string]: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
export type EntityObject = {
|
|
26
|
+
guid: string | null;
|
|
27
|
+
cdate: number | null;
|
|
28
|
+
mdate: number | null;
|
|
29
|
+
tags: string[];
|
|
30
|
+
[k: string]: any;
|
|
31
|
+
};
|
|
32
|
+
|
|
25
33
|
export type EntityJson = {
|
|
26
34
|
class: string;
|
|
27
35
|
guid: string | null;
|
|
@@ -137,6 +145,17 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
137
145
|
* Array of the entity's tags.
|
|
138
146
|
*/
|
|
139
147
|
tags: string[];
|
|
148
|
+
/**
|
|
149
|
+
* Get a GUID for the entity.
|
|
150
|
+
*
|
|
151
|
+
* If the entity has already been saved, this will just return the GUID.
|
|
152
|
+
*
|
|
153
|
+
* If the entity has not yet been saved, this will return a new GUID that gets
|
|
154
|
+
* held by the entity. The `guid` property will remain null, but this method
|
|
155
|
+
* will then always return the same GUID. When the entity is eventually saved
|
|
156
|
+
* into the database, this GUID will be used.
|
|
157
|
+
*/
|
|
158
|
+
$getGuaranteedGUID(): string;
|
|
140
159
|
/**
|
|
141
160
|
* Add one or more tags.
|
|
142
161
|
*
|
|
@@ -162,9 +181,10 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
162
181
|
* This should only be used by Nymph to save the data into storage.
|
|
163
182
|
*
|
|
164
183
|
* @param includeSData Whether to include the serialized data as well.
|
|
184
|
+
* @param referenceOnlyExisting Whether to only turn existing entities into references.
|
|
165
185
|
* @returns The entity's data object.
|
|
166
186
|
*/
|
|
167
|
-
$getData(includeSData?: boolean): EntityData;
|
|
187
|
+
$getData(includeSData?: boolean, referenceOnlyExisting?: boolean): EntityData;
|
|
168
188
|
/**
|
|
169
189
|
* Used to retrieve the serialized data object.
|
|
170
190
|
*
|
|
@@ -178,12 +198,30 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
178
198
|
* @returns The entity's serialized data object.
|
|
179
199
|
*/
|
|
180
200
|
$getSData(): SerializedEntityData;
|
|
201
|
+
/**
|
|
202
|
+
* Get an array of strings that **must** be unique across the current etype.
|
|
203
|
+
*
|
|
204
|
+
* When you try to save another entity with any of the same unique strings,
|
|
205
|
+
* Nymph will throw an error.
|
|
206
|
+
*
|
|
207
|
+
* The default implementation of this method returns an empty array, meaning
|
|
208
|
+
* there are no uniqueness constraints applied to its etype.
|
|
209
|
+
*
|
|
210
|
+
* @returns Resolves to an array of entity's unique constraint strings.
|
|
211
|
+
*/
|
|
212
|
+
$getUniques(): Promise<string[]>;
|
|
181
213
|
/**
|
|
182
214
|
* Get the original values of the AC properties.
|
|
183
215
|
*
|
|
184
216
|
* @returns An object of AC properties.
|
|
185
217
|
*/
|
|
186
218
|
$getOriginalAcValues(): ACProperties;
|
|
219
|
+
/**
|
|
220
|
+
* Get the current values of the AC properties.
|
|
221
|
+
*
|
|
222
|
+
* @returns An object of AC properties.
|
|
223
|
+
*/
|
|
224
|
+
$getCurrentAcValues(): ACProperties;
|
|
187
225
|
/**
|
|
188
226
|
* Get an object that holds the same data as the entity.
|
|
189
227
|
*
|
|
@@ -239,15 +277,25 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
239
277
|
/**
|
|
240
278
|
* Used to set the data.
|
|
241
279
|
*
|
|
242
|
-
* This should only be used by Nymph to push the data from storage
|
|
280
|
+
* This should only be used by Nymph to push the data from storage or the
|
|
281
|
+
* client.
|
|
243
282
|
*
|
|
244
283
|
* `sdata` is used by Nymph to avoid unserializing data that hasn't been
|
|
245
284
|
* requested yet.
|
|
246
285
|
*
|
|
286
|
+
* If `source` is set to "server", the data is coming from the DB or the
|
|
287
|
+
* cache. If not, assume the data is coming from the client and can't be
|
|
288
|
+
* trusted.
|
|
289
|
+
*
|
|
247
290
|
* @param data The data object.
|
|
248
291
|
* @param sdata The serialized data object.
|
|
292
|
+
* @param source If this is set to "server", the data is coming from the DB.
|
|
249
293
|
*/
|
|
250
|
-
$putData(
|
|
294
|
+
$putData(
|
|
295
|
+
data: EntityData,
|
|
296
|
+
sdata?: SerializedEntityData,
|
|
297
|
+
source?: 'server',
|
|
298
|
+
): void;
|
|
251
299
|
/**
|
|
252
300
|
* Remove one or more tags.
|
|
253
301
|
*
|
|
@@ -257,12 +305,14 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
257
305
|
/**
|
|
258
306
|
* Return a Nymph Entity Reference for this entity.
|
|
259
307
|
*
|
|
260
|
-
* If the entity hasn't been saved yet (and has no GUID), it will
|
|
261
|
-
*
|
|
308
|
+
* If the entity hasn't been saved yet (and has no GUID), it will use the
|
|
309
|
+
* guaranteed GUID from `$getGuaranteedGUID`, unless `existingOnly` is true,
|
|
310
|
+
* then it will return the entity.
|
|
262
311
|
*
|
|
263
|
-
* @
|
|
312
|
+
* @param existingOnly Whether to only turn existing entities into references.
|
|
313
|
+
* @returns A Nymph Entity Reference array.
|
|
264
314
|
*/
|
|
265
|
-
$toReference(): EntityReference | EntityInterface;
|
|
315
|
+
$toReference(existingOnly?: boolean): EntityReference | EntityInterface;
|
|
266
316
|
/**
|
|
267
317
|
* Set whether to use "skipAc" when accessing entity references.
|
|
268
318
|
*
|
|
@@ -271,61 +321,9 @@ export interface EntityInterface extends DataObjectInterface {
|
|
|
271
321
|
$useSkipAc(useSkipAc: boolean): void;
|
|
272
322
|
}
|
|
273
323
|
|
|
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;
|
|
324
|
+
export type EntityConstructor<
|
|
325
|
+
D extends EntityData = EntityData,
|
|
326
|
+
E extends Entity<D> = Entity<D>,
|
|
327
|
+
> = (new (...args: any[]) => E) & {
|
|
328
|
+
[k in keyof typeof Entity]: (typeof Entity)[k];
|
|
331
329
|
};
|