@aventara/client 1.0.0-rc.1 → 1.0.0-rc.11
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 +247 -0
- package/README.md +147 -11
- package/dist/cli/command.parser.d.ts +4 -3
- package/dist/cli/command.parser.js +3 -3
- package/dist/cli/generation-failure.renderer.d.ts +2 -1
- package/dist/cli/generation-success.renderer.d.ts +2 -1
- package/dist/cli/step.reporter.d.ts +2 -1
- package/dist/cli/terminal.prompter.d.ts +2 -1
- package/dist/config/client-config.interface.d.ts +17 -0
- package/dist/config/config.loader.d.ts +8 -3
- package/dist/config/config.loader.js +20 -2
- package/dist/config/config.resolver.d.ts +10 -3
- package/dist/config/config.resolver.js +28 -0
- package/dist/config/env.cascade.d.ts +2 -6
- package/dist/config/env.cascade.js +3 -3
- package/dist/config/module-style.resolver.d.ts +3 -6
- package/dist/config/module-style.resolver.js +2 -2
- package/dist/config/tsconfig.locator.d.ts +2 -1
- package/dist/config/tsconfig.locator.js +14 -2
- package/dist/contract/contract.acceptance.d.ts +0 -1
- package/dist/contract/contract.acceptance.js +1 -1
- package/dist/contract/contract.fetcher.d.ts +2 -1
- package/dist/contract/contract.loader.d.ts +3 -2
- package/dist/emit/access.emitter.d.ts +12 -0
- package/dist/emit/access.emitter.js +263 -0
- package/dist/emit/banner.emitter.d.ts +6 -1
- package/dist/emit/banner.emitter.js +12 -8
- package/dist/emit/cached-read.emitter.d.ts +3 -0
- package/dist/emit/cached-read.emitter.js +158 -0
- package/dist/emit/client-surface.emitter.js +130 -13
- package/dist/emit/client-tree.emitter.d.ts +9 -2
- package/dist/emit/client-tree.emitter.js +51 -15
- package/dist/emit/derivation.emitter.d.ts +3 -3
- package/dist/emit/derivation.emitter.js +6 -3
- package/dist/emit/descriptor.emitter.d.ts +2 -0
- package/dist/emit/descriptor.emitter.js +28 -1
- package/dist/emit/emitted-tree.interface.d.ts +1 -1
- package/dist/emit/field-check.emitter.d.ts +2 -1
- package/dist/emit/field-check.emitter.js +2 -13
- package/dist/emit/module-specifier.scanner.d.ts +2 -1
- package/dist/emit/name.deriver.d.ts +2 -3
- package/dist/emit/name.deriver.js +6 -1
- package/dist/emit/named-type.emitter.js +12 -2
- package/dist/emit/operation-set.emitter.d.ts +3 -0
- package/dist/emit/operation-set.emitter.js +604 -0
- package/dist/emit/runtime.emitter.d.ts +5 -4
- package/dist/emit/runtime.emitter.js +484 -42
- package/dist/emit/scalar.codec.js +223 -6
- package/dist/emit/transaction.emitter.js +7 -3
- package/dist/generate.d.ts +3 -2
- package/dist/generate.js +1 -1
- package/dist/hydration/hydration-tag.format.d.ts +11 -0
- package/dist/hydration/hydration-tag.format.js +6 -0
- package/dist/init/client-init.planner.d.ts +3 -2
- package/dist/init/client-init.questions.d.ts +1 -12
- package/dist/init/client-init.questions.js +2 -2
- package/dist/internal.d.ts +25 -0
- package/dist/internal.js +11 -0
- package/dist/output/output.validator.d.ts +3 -4
- package/dist/output/output.validator.js +2 -2
- package/dist/output/output.writer.d.ts +3 -2
- package/package.json +9 -5
|
@@ -141,6 +141,7 @@ function rulesTableSource(contract) {
|
|
|
141
141
|
function fieldValidatorsSource(contract, from) {
|
|
142
142
|
return `import type { AvFieldCheck } from ${from("../derivation/contracts/field-check")};
|
|
143
143
|
import type { JsonSchema } from ${from("../derivation/contracts/json-shape")};
|
|
144
|
+
import { RECORD_SITES, writeKeysOf } from ${from("./codec")};
|
|
144
145
|
import { DECODE_TABLE } from ${from("./descriptor")};
|
|
145
146
|
import { type AvCause, type AvValidationIssue, frameworkErrorOf } from ${from("./errors")};
|
|
146
147
|
import {
|
|
@@ -456,21 +457,9 @@ function shapedValueIssues(schema: JsonSchema, list: boolean, value: unknown, pa
|
|
|
456
457
|
|
|
457
458
|
// ---- field validators, judged as the server judges them after its field pipes ----
|
|
458
459
|
|
|
459
|
-
/** Where each relation directive holds the records its target writes. */
|
|
460
|
-
const RECORD_SITES: { readonly [directive: string]: readonly (string | undefined)[] } = {
|
|
461
|
-
$create: [undefined],
|
|
462
|
-
$connect: [],
|
|
463
|
-
$connectOrCreate: ["create"],
|
|
464
|
-
$disconnect: [],
|
|
465
|
-
$set: [],
|
|
466
|
-
$update: ["data"],
|
|
467
|
-
$delete: [],
|
|
468
|
-
$upsert: ["create", "update"],
|
|
469
|
-
};
|
|
470
|
-
|
|
471
460
|
/** The top-level data records of a create, update or upsert. */
|
|
472
461
|
function writeRecordPaths(family: string, args: unknown): Path[] {
|
|
473
|
-
const keys = family
|
|
462
|
+
const keys = writeKeysOf(family);
|
|
474
463
|
const records: Path[] = [];
|
|
475
464
|
if (!isPlainRecord(args)) {
|
|
476
465
|
return records;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface ScannedModule {
|
|
2
2
|
/**
|
|
3
3
|
* Every module specifier: a `from` clause's, a side-effect `import`'s, and an
|
|
4
4
|
* `import()` type query's.
|
|
@@ -8,3 +8,4 @@ export interface ScannedModule {
|
|
|
8
8
|
readonly references: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare function scanModuleSpecifiers(text: string): ScannedModule;
|
|
11
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { AvContractClient, AvOperationFamily } from "@aventara/core";
|
|
|
3
3
|
* Name derivation and the rename ladder for the emitted tree.
|
|
4
4
|
*/
|
|
5
5
|
export declare const RESERVED_EMITTED_NAMES: readonly string[];
|
|
6
|
-
|
|
6
|
+
interface ResourceNamedType {
|
|
7
7
|
readonly suffix: string;
|
|
8
8
|
readonly family: AvOperationFamily;
|
|
9
9
|
readonly variant: string;
|
|
@@ -37,8 +37,6 @@ export interface EmittedNames {
|
|
|
37
37
|
readonly properties: readonly EmittedProperty[];
|
|
38
38
|
readonly warnings: readonly string[];
|
|
39
39
|
}
|
|
40
|
-
/** Whether `text` is an IdentifierName — the rule above, for every emitter. */
|
|
41
|
-
export declare function isIdentifierName(text: string): boolean;
|
|
42
40
|
/**
|
|
43
41
|
* The emitted names of a Contract's enums and Resources, renamed where a name
|
|
44
42
|
* cannot be declared as-is.
|
|
@@ -52,3 +50,4 @@ export declare class AvGeneratedNameError extends Error {
|
|
|
52
50
|
constructor(problems: readonly string[]);
|
|
53
51
|
}
|
|
54
52
|
export declare function ownPropertyKey(value: string): string;
|
|
53
|
+
export {};
|
|
@@ -2,6 +2,8 @@ import { isOperationVariantAvailable } from "@aventara/core/internal";
|
|
|
2
2
|
import { FRAMEWORK_ERROR_CLASS_NAMES } from "./runtime.emitter.js";
|
|
3
3
|
export const RESERVED_EMITTED_NAMES = [
|
|
4
4
|
...new Set([
|
|
5
|
+
"AvAccessError",
|
|
6
|
+
"AvAccessMe",
|
|
5
7
|
"AvClient",
|
|
6
8
|
"AvClientOptions",
|
|
7
9
|
"AvCallOptions",
|
|
@@ -18,6 +20,7 @@ export const RESERVED_EMITTED_NAMES = [
|
|
|
18
20
|
"AvValidationCode",
|
|
19
21
|
"AvValidationIssue",
|
|
20
22
|
"avClient",
|
|
23
|
+
"avLazy",
|
|
21
24
|
...FRAMEWORK_ERROR_CLASS_NAMES,
|
|
22
25
|
]),
|
|
23
26
|
].sort();
|
|
@@ -46,11 +49,13 @@ export function namedTypesOf(operations) {
|
|
|
46
49
|
return RESOURCE_NAMED_TYPES.filter((named) => isOperationVariantAvailable(families[named.family]?.[named.variant]));
|
|
47
50
|
}
|
|
48
51
|
export const CLIENT_MEMBER_NAMES = [
|
|
52
|
+
"$access",
|
|
49
53
|
"__defineGetter__",
|
|
50
54
|
"__defineSetter__",
|
|
51
55
|
"__lookupGetter__",
|
|
52
56
|
"__lookupSetter__",
|
|
53
57
|
"__proto__",
|
|
58
|
+
"all",
|
|
54
59
|
"constructor",
|
|
55
60
|
"hasOwnProperty",
|
|
56
61
|
"isPrototypeOf",
|
|
@@ -63,7 +68,7 @@ export const CLIENT_MEMBER_NAMES = [
|
|
|
63
68
|
"valueOf",
|
|
64
69
|
];
|
|
65
70
|
const IDENTIFIER = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u;
|
|
66
|
-
|
|
71
|
+
function isIdentifierName(text) {
|
|
67
72
|
return IDENTIFIER.test(text);
|
|
68
73
|
}
|
|
69
74
|
const RESERVED_WORDS = new Set([
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsonSchemaType } from "./json-shape.emitter.js";
|
|
1
2
|
import { importSpecifier, } from "./module-style.interface.js";
|
|
2
3
|
import { namedTypesOf } from "./name.deriver.js";
|
|
3
4
|
export function emitNamedTypesModule(contract, names, style) {
|
|
@@ -12,12 +13,21 @@ export function emitNamedTypesModule(contract, names, style) {
|
|
|
12
13
|
`export type ${identifier}${named.suffix} = ResourceArgument<${resource}, ${JSON.stringify(named.family)}, ${JSON.stringify(named.variant)}, ${JSON.stringify(named.argument)}>;\n`;
|
|
13
14
|
});
|
|
14
15
|
});
|
|
16
|
+
const me = contract.access?.verbs?.me?.result;
|
|
17
|
+
const identity = me === undefined
|
|
18
|
+
? []
|
|
19
|
+
: [
|
|
20
|
+
"/** What `avClient.$access.me()` resolves when someone is signed in: the token identity. */\n" +
|
|
21
|
+
`export type AvAccessMe = ${jsonSchemaType(me)};\n`,
|
|
22
|
+
];
|
|
15
23
|
const uses = (helper) => declarations.some((declaration) => declaration.includes(` = ${helper}<`));
|
|
16
24
|
const imported = ["ResourceArgument", "ResourceRecord"].filter(uses);
|
|
17
25
|
return {
|
|
18
26
|
path: "types.d.ts",
|
|
19
27
|
source: declarations.length === 0
|
|
20
|
-
?
|
|
21
|
-
|
|
28
|
+
? identity.length === 0
|
|
29
|
+
? "export {};\n"
|
|
30
|
+
: identity.join("")
|
|
31
|
+
: `import type { ${imported.join(", ")} } from ${JSON.stringify(importSpecifier("./client", style))};\n\n${declarations.join("")}${identity.join("")}`,
|
|
22
32
|
};
|
|
23
33
|
}
|