@afora/core 0.0.4 → 0.0.6
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/README.md +2 -0
- package/dist/core/application/exceptions.d.ts +9 -0
- package/dist/core/application/providers.d.ts +46 -0
- package/dist/core/application/types/application.interface.d.ts +70 -15
- package/dist/core/blueprint/types/slice.interface.d.ts +5 -2
- package/dist/core/entity/abstract-entity.d.ts +1 -1
- package/dist/core/entity/types/entity.interface.d.ts +13 -7
- package/dist/core/exception/exception.d.ts +10 -1
- package/dist/core/output/status.d.ts +2 -2
- package/dist/core/property/property.d.ts +4 -4
- package/dist/core/property/types/optional-property.type.d.ts +2 -2
- package/dist/core/property/types/property-type.interface.d.ts +17 -0
- package/dist/core/record/abstract-record.d.ts +4 -4
- package/dist/core/record/exceptions.d.ts +2 -0
- package/dist/core/record/name.d.ts +16 -0
- package/dist/core/record/record.d.ts +4 -3
- package/dist/core/record/types/plugin.interface.d.ts +11 -0
- package/dist/core/record/types/record.interface.d.ts +71 -10
- package/dist/core/repository/cursor.d.ts +13 -0
- package/dist/core/repository/exceptions.d.ts +10 -0
- package/dist/core/repository/query.d.ts +4 -4
- package/dist/core/repository/repository.d.ts +1 -1
- package/dist/core/repository/state.d.ts +3 -2
- package/dist/core/repository/types/query.interface.d.ts +37 -0
- package/dist/core/repository/types/repository.interface.d.ts +10 -6
- package/dist/core/use-case/steps/types/steps.interface.d.ts +1 -1
- package/dist/experimental.js +3 -2
- package/dist/{index-hn82hm31.js → index-3nd9bjnc.js} +69 -10
- package/dist/{index-ewm6r4nw.js → index-gbgc40xe.js} +452 -96
- package/dist/index.d.ts +9 -7
- package/dist/index.js +16 -2
- package/dist/std/properties/password.d.ts +5 -1
- package/dist/std/record-plugins.d.ts +5 -5
- package/dist/testing/index.js +91 -2
- package/dist/testing/provider-contract.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { applicationOf, isApplication } from "./core/application/application.js";
|
|
2
|
-
export { ApplicationAlreadyStarted, ApplicationConflict, ApplicationNotStarted, DuplicateApplicationDeclaration, InvalidApplicationDeclaration, InvalidApplicationEnvironment, UnregisteredApplicationReference, UnregisteredRepositoryDependency, UnregisteredUseCaseDependency, } from "./core/application/exceptions.js";
|
|
2
|
+
export { ApplicationAlreadyStarted, ApplicationConflict, ApplicationNotStarted, DuplicateApplicationDeclaration, InvalidApplicationDeclaration, InvalidApplicationEnvironment, ProviderNotBound, UnregisteredApplicationReference, UnregisteredRepositoryDependency, UnregisteredUseCaseDependency, } from "./core/application/exceptions.js";
|
|
3
|
+
export { isProviderSlot, isProviderStorage, type ProviderSlot, type ProviderStorage, providersOf, } from "./core/application/providers.js";
|
|
3
4
|
export { type Register, type RegisteredApplication, resetApplication, useApplication, } from "./core/application/registry.js";
|
|
4
5
|
export { isLogFactory, isProviderFactory, type LogFactory, logFrom, type ProviderFactory, providerFrom, } from "./core/application/start.js";
|
|
5
|
-
export type { AnyApplication, ApplicationCollections, ApplicationContext, ApplicationDescription, ApplicationSettings, ApplicationStartOptions, CommandDescription, ExceptionDescription, FieldDescription, FieldsDescription, IApplication, LogDescription, OutputDescription, PropertyDescription, PropertyLineageDescription, PropertyReference, RecordDescription, UseCaseDependencyDescription, UseCaseDescription, } from "./core/application/types/application.interface.js";
|
|
6
|
+
export type { AnyApplication, ApplicationCollections, ApplicationContext, ApplicationDescription, ApplicationRunArgs, ApplicationRunOptions, ApplicationSettings, ApplicationStartOptions, CommandDescription, ExceptionDescription, FieldDescription, FieldsDescription, IApplication, LogDescription, OutputDescription, PropertyDescription, PropertyLineageDescription, PropertyReference, ProviderReference, RecordDescription, UseCaseDependencyDescription, UseCaseDescription, } from "./core/application/types/application.interface.js";
|
|
6
7
|
export { blueprintBuilderOf } from "./core/blueprint/blueprint.js";
|
|
7
8
|
export { blueprintPluginOf } from "./core/blueprint/blueprint-plugin.js";
|
|
8
9
|
export { ReservedBlueprintKey, UndeclaredBlueprintProperty, } from "./core/blueprint/exceptions.js";
|
|
@@ -61,22 +62,23 @@ export type { IProperty } from "./core/property/types/property.interface.js";
|
|
|
61
62
|
export type { AnyPropertyConstructor, IPropertyCollection, } from "./core/property/types/property-collection.type.js";
|
|
62
63
|
export type { PropertyValue } from "./core/property/types/property-constructor.type.js";
|
|
63
64
|
export type { CallableProperty, NumberConstraints, PropertyMetadata, PropertyOptions, StringConstraints, } from "./core/property/types/property-options.interface.js";
|
|
64
|
-
export type { IPropertyType, UniqueMark, } from "./core/property/types/property-type.interface.js";
|
|
65
|
+
export type { IPropertyType, SensitiveMark, UniqueMark, } from "./core/property/types/property-type.interface.js";
|
|
65
66
|
export { AbstractRecord, RESERVED_RECORD_KEYS, } from "./core/record/abstract-record.js";
|
|
66
|
-
export { IncompatibleRecordPlugin, InvalidRecordPlugin, InvalidRecordValue, RecordPluginConflict, ReservedRecordKey, UndeclaredRecordProperty, UnknownRecordPlugin, } from "./core/record/exceptions.js";
|
|
67
|
+
export { IncompatibleRecordPlugin, InvalidRecordDeclaration, InvalidRecordPlugin, InvalidRecordValue, RecordPluginConflict, ReservedRecordKey, UndeclaredRecordProperty, UnknownRecordPlugin, } from "./core/record/exceptions.js";
|
|
67
68
|
export { MASK } from "./core/record/mask.js";
|
|
69
|
+
export { recordNameOf } from "./core/record/name.js";
|
|
68
70
|
export { hasPlugin, isRecordPlugin, pluginsOf, recordPluginOf, } from "./core/record/plugin.js";
|
|
69
71
|
export { recordPluginCatalogOf } from "./core/record/plugin-catalog.js";
|
|
70
72
|
export type { RecordBuilder } from "./core/record/record.js";
|
|
71
73
|
export { recordBuilderOf } from "./core/record/record.js";
|
|
72
74
|
export type { AnyRecordPlugin, IRecordPlugin, IRecordPluginCatalog, PluginUniqueKey, RecordPluginDescriptor, RecordPluginOptions, RecordPluginReference, RecordPluginRequirement, RecordPluginsOption, } from "./core/record/types/plugin.interface.js";
|
|
73
|
-
export type { DeclaredRecordInstance, IRecord, MarkedUniqueKey, RecordChange, RecordChanges, RecordConstructor, RecordEffect, RecordEffects, RecordKey, RecordOptions, RecordSettings, RecordValue, } from "./core/record/types/record.interface.js";
|
|
74
|
-
export { InvalidRepositoryData, InvalidRepositoryDeclaration, InvalidRepositoryEntity, InvalidRepositoryQuery, RepositoryEntityNotFound, RepositoryUniqueViolation, } from "./core/repository/exceptions.js";
|
|
75
|
+
export type { DeclaredRecordInstance, IRecord, MarkedUniqueKey, Masked, RecordChange, RecordChanges, RecordConstructor, RecordEffect, RecordEffects, RecordJson, RecordKey, RecordOptions, RecordSettings, RecordValue, } from "./core/record/types/record.interface.js";
|
|
76
|
+
export { InvalidRepositoryCursor, InvalidRepositoryData, InvalidRepositoryDeclaration, InvalidRepositoryEntity, InvalidRepositoryQuery, RepositoryEntityNotFound, RepositoryUniqueViolation, } from "./core/repository/exceptions.js";
|
|
75
77
|
export { inMemoryProvider } from "./core/repository/in-memory.js";
|
|
76
78
|
export { providerDescriptionOf, providerOf } from "./core/repository/provider.js";
|
|
77
79
|
export type { RepositorySettings } from "./core/repository/repository.js";
|
|
78
80
|
export { AbstractRepository, isRepository, RepositoryOf, repositoryOf, } from "./core/repository/repository.js";
|
|
79
|
-
export type { ProviderCapabilities, ProviderDescription, ProviderOption, ProviderOptions, ProviderSettings, RepositoryExists, RepositoryFindMany, RepositoryFindPage, RepositoryOrder, RepositoryPage, RepositoryQuery, RepositoryWhere, } from "./core/repository/types/query.interface.js";
|
|
81
|
+
export type { ProviderCapabilities, ProviderDescription, ProviderOption, ProviderOptions, ProviderQuery, ProviderSettings, RepositoryCursorPage, RepositoryCursorQuery, RepositoryExists, RepositoryFindCursor, RepositoryFindMany, RepositoryFindPage, RepositoryOrder, RepositoryPage, RepositoryQuery, RepositoryWhere, } from "./core/repository/types/query.interface.js";
|
|
80
82
|
export type { AnyRepository, AnyRepositoryEntity, EntityInstanceOf, EntityKeyOf, EntityNonUniqueKeyOf, EntityUniqueKeyOf, EntityValueOf, IRepositoryProvider, QueryValueOf, RepositoryAction, RepositoryContext, RepositoryCount, RepositoryCreate, RepositoryCreateInput, RepositoryData, RepositoryDelete, RepositoryFindBy, RepositoryFindManyBy, RepositoryUpdate, } from "./core/repository/types/repository.interface.js";
|
|
81
83
|
export type { SchemaClass } from "./core/schema/schema.js";
|
|
82
84
|
export { schemaOf } from "./core/schema/schema.js";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
UnregisteredRepositoryDependency2,
|
|
11
11
|
UnregisteredUseCaseDependency2,
|
|
12
12
|
ApplicationNotStarted2,
|
|
13
|
+
ProviderNotBound2,
|
|
13
14
|
ApplicationAlreadyStarted2,
|
|
14
15
|
InvalidApplicationEnvironment2,
|
|
15
16
|
useApplication2,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
EntityUniqueKeys2,
|
|
34
35
|
AbstractEntity2,
|
|
35
36
|
InvalidRepositoryQuery2,
|
|
37
|
+
InvalidRepositoryCursor2,
|
|
36
38
|
InvalidRepositoryDeclaration2,
|
|
37
39
|
InvalidRepositoryEntity2,
|
|
38
40
|
InvalidRepositoryData2,
|
|
@@ -76,6 +78,9 @@ import {
|
|
|
76
78
|
logFrom2,
|
|
77
79
|
isLogFactory2,
|
|
78
80
|
isProviderFactory2,
|
|
81
|
+
providersOf2,
|
|
82
|
+
isProviderSlot2,
|
|
83
|
+
isProviderStorage2,
|
|
79
84
|
isApplication2,
|
|
80
85
|
applicationOf2,
|
|
81
86
|
blueprintPluginOf2,
|
|
@@ -127,7 +132,7 @@ import {
|
|
|
127
132
|
entityOf2,
|
|
128
133
|
recordOf2,
|
|
129
134
|
StdStages2
|
|
130
|
-
} from "./index-
|
|
135
|
+
} from "./index-gbgc40xe.js";
|
|
131
136
|
import {
|
|
132
137
|
isProperty2,
|
|
133
138
|
schemaOf2,
|
|
@@ -138,6 +143,7 @@ import {
|
|
|
138
143
|
isRecordClass2,
|
|
139
144
|
isOptionalRecord2,
|
|
140
145
|
recordFieldOf2,
|
|
146
|
+
recordNameOf2,
|
|
141
147
|
listOf2,
|
|
142
148
|
isBlueprintList2,
|
|
143
149
|
ExceptionLayers2,
|
|
@@ -146,6 +152,7 @@ import {
|
|
|
146
152
|
exceptionOf2,
|
|
147
153
|
Meta2,
|
|
148
154
|
InvalidRecordValue2,
|
|
155
|
+
InvalidRecordDeclaration2,
|
|
149
156
|
UndeclaredRecordProperty2,
|
|
150
157
|
ReservedRecordKey2,
|
|
151
158
|
InvalidRecordPlugin2,
|
|
@@ -171,7 +178,7 @@ import {
|
|
|
171
178
|
propertyOf2,
|
|
172
179
|
optionalOf2,
|
|
173
180
|
blueprintBuilderOf2
|
|
174
|
-
} from "./index-
|
|
181
|
+
} from "./index-3nd9bjnc.js";
|
|
175
182
|
export {
|
|
176
183
|
AbstractDefineProperty2 as AbstractDefineProperty,
|
|
177
184
|
AbstractEntity2 as AbstractEntity,
|
|
@@ -213,8 +220,10 @@ export {
|
|
|
213
220
|
InvalidOpenAPIModel2 as InvalidOpenAPIModel,
|
|
214
221
|
InvalidOutputStage2 as InvalidOutputStage,
|
|
215
222
|
InvalidPropertyValue2 as InvalidPropertyValue,
|
|
223
|
+
InvalidRecordDeclaration2 as InvalidRecordDeclaration,
|
|
216
224
|
InvalidRecordPlugin2 as InvalidRecordPlugin,
|
|
217
225
|
InvalidRecordValue2 as InvalidRecordValue,
|
|
226
|
+
InvalidRepositoryCursor2 as InvalidRepositoryCursor,
|
|
218
227
|
InvalidRepositoryData2 as InvalidRepositoryData,
|
|
219
228
|
InvalidRepositoryDeclaration2 as InvalidRepositoryDeclaration,
|
|
220
229
|
InvalidRepositoryEntity2 as InvalidRepositoryEntity,
|
|
@@ -239,6 +248,7 @@ export {
|
|
|
239
248
|
Phone2 as Phone,
|
|
240
249
|
PropertyRequired2 as PropertyRequired,
|
|
241
250
|
PropertyStates2 as PropertyStates,
|
|
251
|
+
ProviderNotBound2 as ProviderNotBound,
|
|
242
252
|
Publishable2 as Publishable,
|
|
243
253
|
RESERVED_ENTITY_KEYS2 as RESERVED_ENTITY_KEYS,
|
|
244
254
|
RESERVED_RECORD_KEYS2 as RESERVED_RECORD_KEYS,
|
|
@@ -299,6 +309,8 @@ export {
|
|
|
299
309
|
isPasswordHash2 as isPasswordHash,
|
|
300
310
|
isProperty2 as isProperty,
|
|
301
311
|
isProviderFactory2 as isProviderFactory,
|
|
312
|
+
isProviderSlot2 as isProviderSlot,
|
|
313
|
+
isProviderStorage2 as isProviderStorage,
|
|
302
314
|
isRecordClass2 as isRecordClass,
|
|
303
315
|
isRecordPlugin2 as isRecordPlugin,
|
|
304
316
|
isRepository2 as isRepository,
|
|
@@ -323,8 +335,10 @@ export {
|
|
|
323
335
|
providerDescriptionOf2 as providerDescriptionOf,
|
|
324
336
|
providerFrom2 as providerFrom,
|
|
325
337
|
providerOf2 as providerOf,
|
|
338
|
+
providersOf2 as providersOf,
|
|
326
339
|
recordBuilderOf2 as recordBuilderOf,
|
|
327
340
|
recordFieldOf2 as recordFieldOf,
|
|
341
|
+
recordNameOf2 as recordNameOf,
|
|
328
342
|
recordOf2 as recordOf,
|
|
329
343
|
recordPluginCatalogOf2 as recordPluginCatalogOf,
|
|
330
344
|
recordPluginOf2 as recordPluginOf,
|
|
@@ -5,7 +5,11 @@ export declare const PASSWORD_SPECIAL_CHARACTERS = "!@#$%^&*()-_=+[]{}|\\;:'\",.
|
|
|
5
5
|
export declare function isPasswordHash(value: string): boolean;
|
|
6
6
|
/** The rules a plain password breaks; empty when it is strong enough. */
|
|
7
7
|
export declare function passwordIssues(value: string): string[];
|
|
8
|
-
declare const Password_base: import("../../index.js").PropertyClass<Type.TString, string
|
|
8
|
+
declare const Password_base: import("../../index.js").PropertyClass<Type.TString, string> & {
|
|
9
|
+
readonly type: {
|
|
10
|
+
readonly sensitive: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
9
13
|
/**
|
|
10
14
|
* A password stored as an Argon2 hash. The constructor only accepts a hash,
|
|
11
15
|
* e.g. one read from the database; `Password.hash` turns a plain password
|
|
@@ -6,7 +6,7 @@ declare const PublishableRecord_base: import("../index.js").RecordConstructor<im
|
|
|
6
6
|
safeParse(value: unknown): import("../index.js").ParseResult<string | undefined>;
|
|
7
7
|
readonly "~standard": import("../index.js").StandardSchemaV1.Props<string | undefined, string | undefined>;
|
|
8
8
|
}>;
|
|
9
|
-
}>, [], never, unknown>;
|
|
9
|
+
}>, [], never, unknown, never, never>;
|
|
10
10
|
/**
|
|
11
11
|
* A `publishedAt` absent while the record is a draft; `publish(at?)` sets it
|
|
12
12
|
* (to now by default), `unpublish()` clears it, `isPublished` tells.
|
|
@@ -30,7 +30,7 @@ declare const ArchivableRecord_base: import("../index.js").RecordConstructor<imp
|
|
|
30
30
|
safeParse(value: unknown): import("../index.js").ParseResult<string | undefined>;
|
|
31
31
|
readonly "~standard": import("../index.js").StandardSchemaV1.Props<string | undefined, string | undefined>;
|
|
32
32
|
}>;
|
|
33
|
-
}>, [], never, unknown>;
|
|
33
|
+
}>, [], never, unknown, never, never>;
|
|
34
34
|
/**
|
|
35
35
|
* An `archivedAt` absent while the record is active; `archive(at?)` sets it,
|
|
36
36
|
* `restore()` clears it, `isArchived` tells.
|
|
@@ -49,7 +49,7 @@ export declare class ArchivableRecord extends ArchivableRecord_base {
|
|
|
49
49
|
export declare const Archivable: import("../index.js").IRecordPlugin<typeof ArchivableRecord, "archivable">;
|
|
50
50
|
declare const TaggableRecord_base: import("../index.js").RecordConstructor<import("../core/property/types/property-options.interface.js").StoredFields<{
|
|
51
51
|
tags: import("../index.js").IBlueprintList<import("../index.js").PropertyClass<import("typebox").TString, string>, true>;
|
|
52
|
-
}>, [], never, unknown>;
|
|
52
|
+
}>, [], never, unknown, never, never>;
|
|
53
53
|
/**
|
|
54
54
|
* `tags`, a list of strings, each once; `tag`, `untag` and `hasTag` change and read it.
|
|
55
55
|
*
|
|
@@ -67,7 +67,7 @@ export declare class TaggableRecord extends TaggableRecord_base {
|
|
|
67
67
|
export declare const Taggable: import("../index.js").IRecordPlugin<typeof TaggableRecord, "taggable">;
|
|
68
68
|
declare const OwnableRecord_base: import("../index.js").RecordConstructor<import("../core/property/types/property-options.interface.js").StoredFields<{
|
|
69
69
|
ownerId: import("../index.js").CallableProperty<typeof import("../index.js").Id>;
|
|
70
|
-
}>, [], never, unknown>;
|
|
70
|
+
}>, [], never, unknown, never, never>;
|
|
71
71
|
/**
|
|
72
72
|
* An `ownerId`, the id of who owns the record, with `isOwnedBy` and `transferTo`.
|
|
73
73
|
*
|
|
@@ -84,7 +84,7 @@ export declare const Ownable: import("../index.js").IRecordPlugin<typeof Ownable
|
|
|
84
84
|
declare const AuthenticatableRecord_base: import("../index.js").RecordConstructor<import("../core/property/types/property-options.interface.js").StoredFields<{
|
|
85
85
|
email: import("../index.js").CallableProperty<import("../index.js").PropertyClass<import("typebox").TString, string>>;
|
|
86
86
|
password: import("../index.js").CallableProperty<typeof Password>;
|
|
87
|
-
}>, readonly ["password"], "email", unknown>;
|
|
87
|
+
}>, readonly ["password"], "email", unknown, never, never>;
|
|
88
88
|
/**
|
|
89
89
|
* An `email`, unique, and a `password` hash, sensitive, changed by
|
|
90
90
|
* `change.password` and checked by `verifyPassword`.
|
package/dist/testing/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import"../index-
|
|
1
|
+
import"../index-3nd9bjnc.js";
|
|
2
2
|
import {
|
|
3
3
|
RepositoryUniqueViolation2,
|
|
4
4
|
RepositoryEntityNotFound2,
|
|
5
5
|
blueprintOf2,
|
|
6
6
|
entityOf2
|
|
7
|
-
} from "../index-
|
|
7
|
+
} from "../index-gbgc40xe.js";
|
|
8
8
|
|
|
9
9
|
// src/testing/provider-contract.ts
|
|
10
10
|
function contextOf(name = "Accounts") {
|
|
@@ -371,6 +371,95 @@ function providerContract(runner, makeProvider, options = {}) {
|
|
|
371
371
|
expect(stored).toEqual(data);
|
|
372
372
|
});
|
|
373
373
|
});
|
|
374
|
+
describe("keyset", () => {
|
|
375
|
+
const keyset = (name, body) => it(name, async () => {
|
|
376
|
+
const enabled = options.keyset ?? (await makeProvider()).capabilities?.keyset;
|
|
377
|
+
if (enabled === true)
|
|
378
|
+
await body();
|
|
379
|
+
});
|
|
380
|
+
const seeded = async () => {
|
|
381
|
+
const f = await fixture();
|
|
382
|
+
const [a, b, c, d, e, g] = [
|
|
383
|
+
row({ n: 1, group: 1, name: "Gil" }),
|
|
384
|
+
row({ group: 1, name: "Érico" }),
|
|
385
|
+
row({ n: 2, group: 2, name: "Ana" }),
|
|
386
|
+
row({ n: 2, group: 1, name: "ana" }),
|
|
387
|
+
row({ group: 2, name: "Bia" }),
|
|
388
|
+
row({ n: 3, group: 2, name: "Zoe" })
|
|
389
|
+
];
|
|
390
|
+
await f.seed(a, b, c, d, e, g);
|
|
391
|
+
const find = (query) => f.provider.findMany(f.context, query).then(ids);
|
|
392
|
+
return { ...f, a, b, c, d, e, g, find };
|
|
393
|
+
};
|
|
394
|
+
const by = (key, direction = "asc") => [{ key, direction }, { key: "id" }];
|
|
395
|
+
keyset("gives the rows strictly after the position, ascending", async () => {
|
|
396
|
+
const { find, a, c, d, g } = await seeded();
|
|
397
|
+
const orderBy = by("n");
|
|
398
|
+
expect(await find({ orderBy, after: [1, a.id] })).toEqual([
|
|
399
|
+
c.id,
|
|
400
|
+
d.id,
|
|
401
|
+
g.id
|
|
402
|
+
]);
|
|
403
|
+
expect(await find({ orderBy, after: [2, c.id] })).toEqual([
|
|
404
|
+
d.id,
|
|
405
|
+
g.id
|
|
406
|
+
]);
|
|
407
|
+
expect(await find({ orderBy, after: [3, g.id] })).toEqual([]);
|
|
408
|
+
});
|
|
409
|
+
keyset("follows a descending order", async () => {
|
|
410
|
+
const { find, a, c, d, g } = await seeded();
|
|
411
|
+
const orderBy = by("n", "desc");
|
|
412
|
+
expect(await find({
|
|
413
|
+
orderBy,
|
|
414
|
+
after: [3, g.id],
|
|
415
|
+
where: { n: { in: [1, 2] } }
|
|
416
|
+
})).toEqual([c.id, d.id, a.id]);
|
|
417
|
+
expect(await find({
|
|
418
|
+
orderBy,
|
|
419
|
+
after: [2, d.id],
|
|
420
|
+
where: { n: { in: [1, 2] } }
|
|
421
|
+
})).toEqual([a.id]);
|
|
422
|
+
});
|
|
423
|
+
keyset("missing values are first ascending and last descending", async () => {
|
|
424
|
+
const { find, a, b, c, d, e, g } = await seeded();
|
|
425
|
+
expect(await find({ orderBy: by("n"), after: [undefined, b.id] })).toEqual([e.id, a.id, c.id, d.id, g.id]);
|
|
426
|
+
expect(await find({ orderBy: by("n"), after: [undefined, e.id] })).toEqual([a.id, c.id, d.id, g.id]);
|
|
427
|
+
expect(await find({ orderBy: by("n", "desc"), after: [1, a.id] })).toEqual([b.id, e.id]);
|
|
428
|
+
expect(await find({ orderBy: by("n", "desc"), after: [undefined, b.id] })).toEqual([e.id]);
|
|
429
|
+
expect(await find({ orderBy: by("n", "desc"), after: [undefined, e.id] })).toEqual([]);
|
|
430
|
+
});
|
|
431
|
+
keyset("compares strings by code point", async () => {
|
|
432
|
+
const { find, a, b, c, d, e, g } = await seeded();
|
|
433
|
+
expect(await find({ orderBy: by("name"), after: ["Bia", e.id] })).toEqual([a.id, g.id, d.id, b.id]);
|
|
434
|
+
expect(await find({ orderBy: by("name", "desc"), after: ["ana", d.id] })).toEqual([g.id, a.id, e.id, c.id]);
|
|
435
|
+
});
|
|
436
|
+
keyset("combines with where, withDeleted and limit; count ignores it", async () => {
|
|
437
|
+
const { provider, context, find, a, b, d } = await seeded();
|
|
438
|
+
const orderBy = [{ key: "id" }];
|
|
439
|
+
expect(await find({
|
|
440
|
+
orderBy,
|
|
441
|
+
after: [a.id],
|
|
442
|
+
where: { group: 1 },
|
|
443
|
+
limit: 1
|
|
444
|
+
})).toEqual([b.id]);
|
|
445
|
+
expect(await find({ orderBy, after: [b.id], where: { group: 1 } })).toEqual([d.id]);
|
|
446
|
+
await provider.update(context, {
|
|
447
|
+
...d,
|
|
448
|
+
deletedAt: "2024-01-01T00:00:00.000Z"
|
|
449
|
+
});
|
|
450
|
+
expect(await find({ orderBy, after: [b.id], where: { group: 1 } })).toEqual([]);
|
|
451
|
+
expect(await find({
|
|
452
|
+
orderBy,
|
|
453
|
+
after: [b.id],
|
|
454
|
+
where: { group: 1 },
|
|
455
|
+
withDeleted: true
|
|
456
|
+
})).toEqual([d.id]);
|
|
457
|
+
expect(await provider.count(context, {
|
|
458
|
+
orderBy,
|
|
459
|
+
after: [b.id]
|
|
460
|
+
})).toBe(5);
|
|
461
|
+
});
|
|
462
|
+
});
|
|
374
463
|
const withTransactions = async () => {
|
|
375
464
|
const enabled = options.transactions ?? (await makeProvider()).capabilities?.transactions;
|
|
376
465
|
return enabled === true;
|
|
@@ -13,6 +13,11 @@ export interface ProviderContractOptions {
|
|
|
13
13
|
* Run the transaction cases. Defaults to `provider.capabilities?.transactions`.
|
|
14
14
|
*/
|
|
15
15
|
readonly transactions?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Run the cases of `after`, which `findCursor` gives to `findMany`. Defaults
|
|
18
|
+
* to `provider.capabilities?.keyset`.
|
|
19
|
+
*/
|
|
20
|
+
readonly keyset?: boolean;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* Registers the behavior every `IRepositoryProvider` v2 must have. Pass the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@afora/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Domain modeling on TypeBox: entities with invariants, repositories, use cases, sensitive data masking and layered exceptions, usable by any Standard Schema consumer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"domain-driven-design",
|