@aventara/testing 1.0.0-rc.3 → 1.0.0-rc.4

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @aventara/testing
2
2
 
3
+ ## 1.0.0-rc.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e3d03a7]
8
+ - Updated dependencies [d10639a]
9
+ - Updated dependencies [f67e68c]
10
+ - Updated dependencies [708556c]
11
+ - Updated dependencies [3a0dfca]
12
+ - Updated dependencies [99169d2]
13
+ - Updated dependencies [0fd2608]
14
+ - Updated dependencies [154e440]
15
+ - Updated dependencies [2fcffdb]
16
+ - @aventara/core@1.0.0-rc.4
17
+
3
18
  ## 1.0.0-rc.3
4
19
 
5
20
  ### Patch Changes
@@ -1,5 +1,6 @@
1
- import type { AvContext, AvFramework } from "@aventara/core";
1
+ import type { AvAdapterModel, AvContext, AvFramework, AvPrebuiltContracts } from "@aventara/core";
2
2
  import { AvDecimal } from "@aventara/core";
3
+ import type { AvAdapterOperation } from "@aventara/core/internal";
3
4
  /**
4
5
  * The corpus's adapter model:
5
6
  *
@@ -421,13 +422,100 @@ export declare const CORPUS_SAMPLE: {
421
422
  readonly blob: Uint8Array<ArrayBuffer>;
422
423
  };
423
424
  /**
424
- * A fresh corpus Framework, and the count of operations its Adapter has been
425
- * handed so far — a row's `adapterCalls` is read from it. `contractHash`
426
- * selects which corpus ClientContract it serves: the `transactions: "none"`
427
- * one when it is {@link CORPUS_NONE_CLIENT_CONTRACT_HASH}, the main one
425
+ * The corpus Framework's configuration, over a fresh corpus Adapter, and the
426
+ * count of operations that Adapter has been handed so far. `contractHash`
427
+ * selects which corpus ClientContract it compiles to: the `transactions:
428
+ * "none"` one when it is {@link CORPUS_NONE_CLIENT_CONTRACT_HASH}, the main one
428
429
  * otherwise (a stale or absent hash included).
429
430
  */
430
- export declare function createCorpusFramework(contractHash?: string): Promise<{
431
+ export declare function corpusConfiguration(contractHash?: string): {
432
+ config: {
433
+ api: string;
434
+ adapter: import("@aventara/core").AvAdapter<AvAdapterModel> & {
435
+ readonly operations: readonly AvAdapterOperation<AvAdapterModel>[];
436
+ readonly transactions: readonly import("../adapters/fake-adapter.js").AvFakeTransactionTrace<AvAdapterModel>[];
437
+ } & {
438
+ transaction?: <T>(work: (executor: import("@aventara/core/internal").AvAdapterTransactionExecutor<AvAdapterModel>) => Promise<T>) => Promise<T>;
439
+ referentialActions: {
440
+ readonly books: readonly [{
441
+ readonly field: "author";
442
+ readonly target: "authors";
443
+ readonly references: readonly ["authorId"];
444
+ readonly onDelete: "cascade";
445
+ }];
446
+ };
447
+ };
448
+ resources: {
449
+ readonly books: {
450
+ readonly fields: {
451
+ readonly label: {
452
+ readonly definition: {
453
+ readonly type: {
454
+ readonly scalar: "string";
455
+ };
456
+ readonly nullable: false;
457
+ readonly list: false;
458
+ readonly lifecycle: readonly ["VIRTUAL"];
459
+ };
460
+ readonly pipelines: {
461
+ readonly compute: {
462
+ readonly read: {
463
+ readonly dependsOn: readonly ["id"];
464
+ readonly compute: ({ record, }: {
465
+ readonly record: Readonly<Record<string, unknown>>;
466
+ }) => string;
467
+ };
468
+ };
469
+ };
470
+ };
471
+ };
472
+ };
473
+ };
474
+ application: {
475
+ readonly exposed: true;
476
+ readonly exemptions: {
477
+ readonly resources: {
478
+ readonly books: {
479
+ readonly fields: {
480
+ readonly label: true;
481
+ };
482
+ };
483
+ };
484
+ };
485
+ };
486
+ client: {
487
+ readonly pipelines: {
488
+ readonly guards: readonly [typeof corpusGuard];
489
+ readonly pipes: readonly [typeof corpusPipe];
490
+ };
491
+ readonly exposed: true;
492
+ readonly exemptions: {
493
+ readonly resources: {
494
+ readonly authors: {
495
+ readonly fields: {
496
+ readonly secret: true;
497
+ };
498
+ };
499
+ readonly secrets: {
500
+ readonly operations: {
501
+ readonly find: readonly ["many"];
502
+ };
503
+ };
504
+ readonly hiddenRes: true;
505
+ };
506
+ };
507
+ };
508
+ };
509
+ adapterCalls: () => number;
510
+ };
511
+ /**
512
+ * A fresh corpus Framework, and the count of operations its Adapter has been
513
+ * handed so far — a row's `adapterCalls` is read from it. `contractHash` selects
514
+ * which corpus ClientContract it serves ({@link corpusConfiguration}). With
515
+ * `prebuilt`, its Contracts are loaded from that file when it matches, as a
516
+ * serverless deployment's would be.
517
+ */
518
+ export declare function createCorpusFramework(contractHash?: string, prebuilt?: AvPrebuiltContracts): Promise<{
431
519
  readonly framework: AvFramework;
432
520
  readonly adapterCalls: () => number;
433
521
  }>;
@@ -238,7 +238,7 @@ function failingCommit(transaction) {
238
238
  return result;
239
239
  };
240
240
  }
241
- export async function createCorpusFramework(contractHash) {
241
+ export function corpusConfiguration(contractHash) {
242
242
  const fake = createFakeAdapter({
243
243
  model: contractHash === CORPUS_NONE_CLIENT_CONTRACT_HASH
244
244
  ? { ...CORPUS_MODEL, transactions: "none" }
@@ -251,12 +251,22 @@ export async function createCorpusFramework(contractHash) {
251
251
  ? {}
252
252
  : { transaction: failingCommit(fake.transaction) }),
253
253
  });
254
+ return {
255
+ config: {
256
+ api: CORPUS_ENTRYPOINT,
257
+ adapter,
258
+ resources: CORPUS_RESOURCES,
259
+ application: CORPUS_APPLICATION_CONFIG,
260
+ client: CORPUS_CLIENT_CONFIG,
261
+ },
262
+ adapterCalls: () => adapter.operations.length,
263
+ };
264
+ }
265
+ export async function createCorpusFramework(contractHash, prebuilt) {
266
+ const { config, adapterCalls } = corpusConfiguration(contractHash);
254
267
  const framework = await createFramework({
255
- api: CORPUS_ENTRYPOINT,
256
- adapter,
257
- resources: CORPUS_RESOURCES,
258
- application: CORPUS_APPLICATION_CONFIG,
259
- client: CORPUS_CLIENT_CONFIG,
268
+ ...config,
269
+ ...(prebuilt === undefined ? {} : { prebuilt }),
260
270
  });
261
- return { framework, adapterCalls: () => adapter.operations.length };
271
+ return { framework, adapterCalls };
262
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aventara/testing",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Conformance and extension testing utilities for Aventara.",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "CHANGELOG.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@aventara/core": "1.0.0-rc.3"
27
+ "@aventara/core": "1.0.0-rc.4"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"