@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +651 -0
  2. package/README.md +195 -141
  3. package/dist/cli/command.parser.d.ts +7 -6
  4. package/dist/cli/command.parser.js +13 -13
  5. package/dist/cli/generation-failure.renderer.d.ts +2 -1
  6. package/dist/cli/generation-failure.renderer.js +24 -24
  7. package/dist/cli/generation-success.renderer.d.ts +2 -1
  8. package/dist/cli/step.reporter.d.ts +2 -1
  9. package/dist/cli/terminal.prompter.d.ts +2 -1
  10. package/dist/config/client-config.interface.d.ts +24 -7
  11. package/dist/config/config.loader.d.ts +12 -7
  12. package/dist/config/config.loader.js +26 -8
  13. package/dist/config/config.resolver.d.ts +16 -9
  14. package/dist/config/config.resolver.js +40 -12
  15. package/dist/config/env.cascade.d.ts +4 -8
  16. package/dist/config/env.cascade.js +7 -7
  17. package/dist/config/module-style.resolver.d.ts +4 -7
  18. package/dist/config/module-style.resolver.js +4 -4
  19. package/dist/config/tsconfig.locator.d.ts +3 -2
  20. package/dist/config/tsconfig.locator.js +16 -4
  21. package/dist/contract/contract.acceptance.d.ts +4 -5
  22. package/dist/contract/contract.acceptance.js +5 -5
  23. package/dist/contract/contract.fetcher.d.ts +5 -4
  24. package/dist/contract/contract.fetcher.js +6 -6
  25. package/dist/contract/contract.loader.d.ts +9 -8
  26. package/dist/contract/contract.loader.js +2 -2
  27. package/dist/emit/access.emitter.d.ts +12 -0
  28. package/dist/emit/access.emitter.js +263 -0
  29. package/dist/emit/banner.emitter.d.ts +6 -1
  30. package/dist/emit/banner.emitter.js +12 -8
  31. package/dist/emit/client-surface.emitter.d.ts +2 -2
  32. package/dist/emit/client-surface.emitter.js +136 -41
  33. package/dist/emit/client-tree.emitter.d.ts +11 -4
  34. package/dist/emit/client-tree.emitter.js +51 -17
  35. package/dist/emit/contract-carrier.emitter.d.ts +3 -3
  36. package/dist/emit/derivation.emitter.d.ts +3 -3
  37. package/dist/emit/derivation.emitter.js +7 -3
  38. package/dist/emit/descriptor.emitter.d.ts +2 -2
  39. package/dist/emit/descriptor.emitter.js +1 -1
  40. package/dist/emit/emitted-tree.interface.d.ts +1 -1
  41. package/dist/emit/enum.emitter.d.ts +2 -2
  42. package/dist/emit/field-check.emitter.d.ts +22 -0
  43. package/dist/emit/field-check.emitter.js +592 -0
  44. package/dist/emit/json-shape.emitter.d.ts +2 -2
  45. package/dist/emit/module-specifier.scanner.d.ts +2 -1
  46. package/dist/emit/name.deriver.d.ts +8 -9
  47. package/dist/emit/name.deriver.js +18 -15
  48. package/dist/emit/named-type.emitter.d.ts +2 -2
  49. package/dist/emit/named-type.emitter.js +12 -2
  50. package/dist/emit/runtime.emitter.d.ts +6 -5
  51. package/dist/emit/runtime.emitter.js +215 -116
  52. package/dist/emit/scalar.codec.d.ts +1 -1
  53. package/dist/emit/scalar.codec.js +246 -29
  54. package/dist/emit/transaction.emitter.js +30 -14
  55. package/dist/generate.d.ts +5 -4
  56. package/dist/generate.js +3 -3
  57. package/dist/hydration/hydration-tag.format.d.ts +11 -0
  58. package/dist/hydration/hydration-tag.format.js +6 -0
  59. package/dist/index.d.ts +1 -1
  60. package/dist/init/client-init.errors.d.ts +4 -4
  61. package/dist/init/client-init.errors.js +4 -4
  62. package/dist/init/client-init.orchestrator.js +7 -7
  63. package/dist/init/client-init.planner.d.ts +3 -2
  64. package/dist/init/client-init.questions.d.ts +5 -16
  65. package/dist/init/client-init.questions.js +12 -12
  66. package/dist/init/client-project.inspector.d.ts +2 -2
  67. package/dist/init/client-project.inspector.js +3 -3
  68. package/dist/internal.d.ts +25 -0
  69. package/dist/internal.js +11 -0
  70. package/dist/output/output.validator.d.ts +3 -4
  71. package/dist/output/output.validator.js +2 -2
  72. package/dist/output/output.writer.d.ts +8 -7
  73. package/dist/output/output.writer.js +12 -12
  74. 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
- "CallOptions",
8
- "Cause",
9
- "Decimal",
10
- "Fetch",
11
- "FrameworkError",
12
- "NotFoundError",
13
- "Operation",
14
- "OperationCode",
9
+ "AvCallOptions",
10
+ "AvCause",
11
+ "AvDecimal",
12
+ "AvFetch",
13
+ "AvError",
14
+ "AvNotFoundError",
15
+ "AvOperation",
16
+ "AvOperationCode",
15
17
  "ResourceArgument",
16
18
  "ResourceRecord",
17
- "TransportError",
18
- "ValidationCode",
19
- "ValidationIssue",
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
- export function isIdentifierName(text) {
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 GeneratedNameError(byName(refusals));
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 GeneratedNameError extends Error {
266
- name = "GeneratedNameError";
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 { ClientContract } from "@aventara/core";
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: ClientContract, names: EmittedNames, style: ClientModuleStyle): EmittedModule;
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
- ? "export {};\n"
21
- : `import type { ${imported.join(", ")} } from ${JSON.stringify(importSpecifier("./client", style))};\n\n${declarations.join("")}`,
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 { ClientContract } from "@aventara/core";
2
- import type { ClientEntrypoint } from "../config/client-config.interface.js";
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: ClientContract["protocol"], entrypoint: ClientEntrypoint): EmittedModule;
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;