@aventara/client 1.0.0-rc.0 → 1.0.0-rc.10
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 +651 -0
- package/README.md +195 -141
- package/dist/cli/command.parser.d.ts +7 -6
- package/dist/cli/command.parser.js +13 -13
- package/dist/cli/generation-failure.renderer.d.ts +2 -1
- package/dist/cli/generation-failure.renderer.js +24 -24
- 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 +24 -7
- package/dist/config/config.loader.d.ts +12 -7
- package/dist/config/config.loader.js +26 -8
- package/dist/config/config.resolver.d.ts +16 -9
- package/dist/config/config.resolver.js +40 -12
- package/dist/config/env.cascade.d.ts +4 -8
- package/dist/config/env.cascade.js +7 -7
- package/dist/config/module-style.resolver.d.ts +4 -7
- package/dist/config/module-style.resolver.js +4 -4
- package/dist/config/tsconfig.locator.d.ts +3 -2
- package/dist/config/tsconfig.locator.js +16 -4
- package/dist/contract/contract.acceptance.d.ts +4 -5
- package/dist/contract/contract.acceptance.js +5 -5
- package/dist/contract/contract.fetcher.d.ts +5 -4
- package/dist/contract/contract.fetcher.js +6 -6
- package/dist/contract/contract.loader.d.ts +9 -8
- package/dist/contract/contract.loader.js +2 -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/client-surface.emitter.d.ts +2 -2
- package/dist/emit/client-surface.emitter.js +136 -41
- package/dist/emit/client-tree.emitter.d.ts +11 -4
- package/dist/emit/client-tree.emitter.js +51 -17
- package/dist/emit/contract-carrier.emitter.d.ts +3 -3
- package/dist/emit/derivation.emitter.d.ts +3 -3
- package/dist/emit/derivation.emitter.js +7 -3
- package/dist/emit/descriptor.emitter.d.ts +2 -2
- package/dist/emit/descriptor.emitter.js +1 -1
- package/dist/emit/emitted-tree.interface.d.ts +1 -1
- package/dist/emit/enum.emitter.d.ts +2 -2
- package/dist/emit/field-check.emitter.d.ts +22 -0
- package/dist/emit/field-check.emitter.js +592 -0
- package/dist/emit/json-shape.emitter.d.ts +2 -2
- package/dist/emit/module-specifier.scanner.d.ts +2 -1
- package/dist/emit/name.deriver.d.ts +8 -9
- package/dist/emit/name.deriver.js +18 -15
- package/dist/emit/named-type.emitter.d.ts +2 -2
- package/dist/emit/named-type.emitter.js +12 -2
- package/dist/emit/runtime.emitter.d.ts +6 -5
- package/dist/emit/runtime.emitter.js +215 -116
- package/dist/emit/scalar.codec.d.ts +1 -1
- package/dist/emit/scalar.codec.js +246 -29
- package/dist/emit/transaction.emitter.js +30 -14
- package/dist/generate.d.ts +5 -4
- package/dist/generate.js +3 -3
- package/dist/hydration/hydration-tag.format.d.ts +11 -0
- package/dist/hydration/hydration-tag.format.js +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/init/client-init.errors.d.ts +4 -4
- package/dist/init/client-init.errors.js +4 -4
- package/dist/init/client-init.orchestrator.js +7 -7
- package/dist/init/client-init.planner.d.ts +3 -2
- package/dist/init/client-init.questions.d.ts +5 -16
- package/dist/init/client-init.questions.js +12 -12
- package/dist/init/client-project.inspector.d.ts +2 -2
- package/dist/init/client-project.inspector.js +3 -3
- 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 +8 -7
- package/dist/output/output.writer.js +12 -12
- package/package.json +9 -5
|
@@ -2,21 +2,23 @@ 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
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
9
|
+
"AvCallOptions",
|
|
10
|
+
"AvCause",
|
|
11
|
+
"AvDecimal",
|
|
12
|
+
"AvFetch",
|
|
13
|
+
"AvError",
|
|
14
|
+
"AvNotFoundError",
|
|
15
|
+
"AvOperation",
|
|
16
|
+
"AvOperationCode",
|
|
15
17
|
"ResourceArgument",
|
|
16
18
|
"ResourceRecord",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
19
|
+
"AvTransportError",
|
|
20
|
+
"AvValidationCode",
|
|
21
|
+
"AvValidationIssue",
|
|
20
22
|
"avClient",
|
|
21
23
|
...FRAMEWORK_ERROR_CLASS_NAMES,
|
|
22
24
|
]),
|
|
@@ -46,6 +48,7 @@ export function namedTypesOf(operations) {
|
|
|
46
48
|
return RESOURCE_NAMED_TYPES.filter((named) => isOperationVariantAvailable(families[named.family]?.[named.variant]));
|
|
47
49
|
}
|
|
48
50
|
export const CLIENT_MEMBER_NAMES = [
|
|
51
|
+
"$access",
|
|
49
52
|
"__defineGetter__",
|
|
50
53
|
"__defineSetter__",
|
|
51
54
|
"__lookupGetter__",
|
|
@@ -63,7 +66,7 @@ export const CLIENT_MEMBER_NAMES = [
|
|
|
63
66
|
"valueOf",
|
|
64
67
|
];
|
|
65
68
|
const IDENTIFIER = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u;
|
|
66
|
-
|
|
69
|
+
function isIdentifierName(text) {
|
|
67
70
|
return IDENTIFIER.test(text);
|
|
68
71
|
}
|
|
69
72
|
const RESERVED_WORDS = new Set([
|
|
@@ -214,7 +217,7 @@ export function deriveEmittedNames(contract) {
|
|
|
214
217
|
const enums = enumNames.map((name) => resolve("enum", name));
|
|
215
218
|
const properties = resourceProperties(resourceNames, warnings, refusals);
|
|
216
219
|
if (refusals.length > 0) {
|
|
217
|
-
throw new
|
|
220
|
+
throw new AvGeneratedNameError(byName(refusals));
|
|
218
221
|
}
|
|
219
222
|
return { enums, resources, properties, warnings: byName(warnings) };
|
|
220
223
|
}
|
|
@@ -262,8 +265,8 @@ function byName(lines) {
|
|
|
262
265
|
function compareCodeUnits(left, right) {
|
|
263
266
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
264
267
|
}
|
|
265
|
-
export class
|
|
266
|
-
name = "
|
|
268
|
+
export class AvGeneratedNameError extends Error {
|
|
269
|
+
name = "AvGeneratedNameError";
|
|
267
270
|
constructor(problems) {
|
|
268
271
|
super(`the ClientContract's names cannot all be emitted: ${problems.join("; ")}. ` +
|
|
269
272
|
`Rename ${problems.length === 1 ? "it" : "them"} on the server, then generate again.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvContractClient } from "@aventara/core";
|
|
2
2
|
import type { EmittedModule } from "./emitted-tree.interface.js";
|
|
3
3
|
import { type ClientModuleStyle } from "./module-style.interface.js";
|
|
4
4
|
import { type EmittedNames } from "./name.deriver.js";
|
|
5
|
-
export declare function emitNamedTypesModule(contract:
|
|
5
|
+
export declare function emitNamedTypesModule(contract: AvContractClient, names: EmittedNames, style: ClientModuleStyle): EmittedModule;
|
|
@@ -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
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AvContractClient } from "@aventara/core";
|
|
2
|
+
import type { EmittedEntrypoint } from "../config/client-config.interface.js";
|
|
3
|
+
import { type RegenerateCommand } from "./banner.emitter.js";
|
|
3
4
|
import type { EmittedModule } from "./emitted-tree.interface.js";
|
|
4
5
|
import { type ClientModuleStyle } from "./module-style.interface.js";
|
|
5
6
|
export declare function emitDecimalModule(): EmittedModule;
|
|
6
|
-
export declare function emitMetadataModule(protocol:
|
|
7
|
+
export declare function emitMetadataModule(protocol: AvContractClient["protocol"], entrypoint: EmittedEntrypoint): EmittedModule;
|
|
7
8
|
export declare const FRAMEWORK_ERROR_CLASS_NAMES: readonly string[];
|
|
8
9
|
export declare function errorsModuleExports(): readonly string[];
|
|
9
|
-
export declare function emitErrorsModule(): EmittedModule;
|
|
10
|
-
export declare function emitTransportModule(style: ClientModuleStyle): EmittedModule;
|
|
10
|
+
export declare function emitErrorsModule(regenerate?: RegenerateCommand): EmittedModule;
|
|
11
|
+
export declare function emitTransportModule(style: ClientModuleStyle, access?: boolean): EmittedModule;
|