sdk-aws-lambda 0.2.0 → 0.3.0

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 (69) hide show
  1. package/dist/contract/cli/asGenArgs.d.ts +21 -0
  2. package/dist/contract/cli/asGenArgs.js +69 -0
  3. package/dist/contract/cli/asGenArgs.js.map +1 -0
  4. package/dist/contract/cli/gen.d.ts +23 -0
  5. package/dist/contract/cli/gen.js +72 -0
  6. package/dist/contract/cli/gen.js.map +1 -0
  7. package/dist/domain.objects/DomainObjectCaptured.d.ts +51 -0
  8. package/dist/domain.objects/DomainObjectCaptured.js +8 -0
  9. package/dist/domain.objects/DomainObjectCaptured.js.map +1 -0
  10. package/dist/domain.objects/GeneratedFile.d.ts +18 -0
  11. package/dist/domain.objects/GeneratedFile.js +8 -0
  12. package/dist/domain.objects/GeneratedFile.js.map +1 -0
  13. package/dist/domain.objects/LambdaCredentialsAbsentError.d.ts +11 -0
  14. package/dist/domain.objects/LambdaCredentialsAbsentError.js +16 -0
  15. package/dist/domain.objects/LambdaCredentialsAbsentError.js.map +1 -0
  16. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.d.ts +12 -0
  17. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.js +17 -0
  18. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.js.map +1 -0
  19. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.d.ts +14 -0
  20. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.js +19 -0
  21. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.js.map +1 -0
  22. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.d.ts +16 -0
  23. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.js +36 -0
  24. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.js.map +1 -0
  25. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.d.ts +10 -0
  26. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.js +18 -0
  27. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.js.map +1 -0
  28. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.d.ts +14 -0
  29. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js +44 -0
  30. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js.map +1 -0
  31. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.d.ts +11 -0
  32. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.js +42 -0
  33. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.js.map +1 -0
  34. package/dist/domain.operations/genServiceSdk/gen.file/banner.d.ts +9 -0
  35. package/dist/domain.operations/genServiceSdk/gen.file/banner.js +16 -0
  36. package/dist/domain.operations/genServiceSdk/gen.file/banner.js.map +1 -0
  37. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.d.ts +20 -0
  38. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.js +44 -0
  39. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.js.map +1 -0
  40. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.d.ts +13 -0
  41. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.js +49 -0
  42. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.js.map +1 -0
  43. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +16 -0
  44. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +39 -0
  45. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -0
  46. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.d.ts +35 -0
  47. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js +189 -0
  48. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js.map +1 -0
  49. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.d.ts +15 -0
  50. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js +37 -0
  51. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js.map +1 -0
  52. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.d.ts +26 -0
  53. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.js +106 -0
  54. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.js.map +1 -0
  55. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.d.ts +15 -0
  56. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js +51 -0
  57. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js.map +1 -0
  58. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.d.ts +14 -0
  59. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js +68 -0
  60. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js.map +1 -0
  61. package/dist/domain.operations/genServiceSdk/genServiceSdk.d.ts +20 -0
  62. package/dist/domain.operations/genServiceSdk/genServiceSdk.js +88 -0
  63. package/dist/domain.operations/genServiceSdk/genServiceSdk.js.map +1 -0
  64. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +49 -4
  65. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -1
  66. package/dist/index.d.ts +5 -0
  67. package/dist/index.js +12 -1
  68. package/dist/index.js.map +1 -1
  69. package/package.json +11 -8
@@ -0,0 +1,21 @@
1
+ import { type EnvironmentAccessTier } from 'sdk-environment';
2
+ /**
3
+ * .what = parse + validate the `gen` cli args into a typed, safe shape
4
+ * .why = the cli boundary must fail loud on bad input (per rule.require.failfast)
5
+ * before the orchestrator runs; a malformed invocation should never reach
6
+ * the spine
7
+ *
8
+ * .args
9
+ * --for <service> a svc-{noun} service name (required)
10
+ * --into <dir> the target directory (required)
11
+ * --env <access> the env access tier: test | prep | prod (required)
12
+ *
13
+ * .throws ConstraintError — a required arg is absent or invalid (with usage hint)
14
+ */
15
+ export declare const asGenArgs: (input: {
16
+ argv: string[];
17
+ }) => {
18
+ service: string;
19
+ into: string;
20
+ access: EnvironmentAccessTier;
21
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asGenArgs = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const sdk_environment_1 = require("sdk-environment");
6
+ /**
7
+ * .what = parse + validate the `gen` cli args into a typed, safe shape
8
+ * .why = the cli boundary must fail loud on bad input (per rule.require.failfast)
9
+ * before the orchestrator runs; a malformed invocation should never reach
10
+ * the spine
11
+ *
12
+ * .args
13
+ * --for <service> a svc-{noun} service name (required)
14
+ * --into <dir> the target directory (required)
15
+ * --env <access> the env access tier: test | prep | prod (required)
16
+ *
17
+ * .throws ConstraintError — a required arg is absent or invalid (with usage hint)
18
+ */
19
+ const asGenArgs = (input) => {
20
+ // parse `--flag value` pairs from argv
21
+ const flags = asFlagMap(input.argv);
22
+ // --for: required, must be svc-<noun> shaped. distinguish the two faults so the
23
+ // user sees which mistake they made — absent flag vs a malformed value
24
+ const service = flags['for'];
25
+ if (!service)
26
+ return throwUsage(`--for is required; must be a svc-<noun> service name`);
27
+ if (!/^svc-[a-z0-9]+$/.test(service))
28
+ return throwUsage(`invalid --for value '${service}'; must be a svc-<noun> service name`);
29
+ // --into: required, non-empty
30
+ const into = flags['into'];
31
+ if (!into)
32
+ return throwUsage(`--into <dir> is required`);
33
+ // --env: required, must be a valid access tier
34
+ const env = flags['env'];
35
+ if (!env)
36
+ return throwUsage(`--env <test|prep|prod> is required`);
37
+ if (!(0, sdk_environment_1.isEnvironmentAccessTier)(env))
38
+ return throwUsage(`--env must be one of: test | prep | prod`);
39
+ return { service, into, access: env };
40
+ };
41
+ exports.asGenArgs = asGenArgs;
42
+ /**
43
+ * .what = collect `--flag value` pairs from an argv array into a map
44
+ * .why = a tiny hand-parse; a full arg framework is unwarranted for 3 flags
45
+ */
46
+ const asFlagMap = (argv) => {
47
+ const flags = {};
48
+ for (let i = 0; i < argv.length; i += 1) {
49
+ const token = argv[i];
50
+ if (token?.startsWith('--')) {
51
+ const key = token.slice(2);
52
+ const value = argv[i + 1];
53
+ if (value !== undefined && !value.startsWith('--')) {
54
+ flags[key] = value;
55
+ i += 1;
56
+ }
57
+ }
58
+ }
59
+ return flags;
60
+ };
61
+ /**
62
+ * .what = throw a ConstraintError with the standard usage hint
63
+ */
64
+ const throwUsage = (reason) => {
65
+ throw new helpful_errors_1.ConstraintError(reason, {
66
+ usage: 'sdk-aws-lambda gen --for svc-<noun> --into <dir> --env <test|prep|prod>',
67
+ });
68
+ };
69
+ //# sourceMappingURL=asGenArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asGenArgs.js","sourceRoot":"","sources":["../../../src/contract/cli/asGenArgs.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AACjD,qDAGyB;AAEzB;;;;;;;;;;;;GAYG;AACI,MAAM,SAAS,GAAG,CAAC,KAEzB,EAAoE,EAAE;IACrE,uCAAuC;IACvC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEpC,gFAAgF;IAChF,uEAAuE;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,OAAO;QACV,OAAO,UAAU,CAAC,sDAAsD,CAAC,CAAC;IAC5E,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,OAAO,UAAU,CACf,wBAAwB,OAAO,sCAAsC,CACtE,CAAC;IAEJ,8BAA8B;IAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI;QAAE,OAAO,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAEzD,+CAA+C;IAC/C,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,IAAI,CAAC,GAAG;QAAE,OAAO,UAAU,CAAC,oCAAoC,CAAC,CAAC;IAClE,IAAI,CAAC,IAAA,yCAAuB,EAAC,GAAG,CAAC;QAC/B,OAAO,UAAU,CAAC,0CAA0C,CAAC,CAAC;IAEhE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACxC,CAAC,CAAC;AA3BW,QAAA,SAAS,aA2BpB;AAEF;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,IAAc,EAA0B,EAAE;IAC3D,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnD,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACnB,CAAC,IAAI,CAAC,CAAC;YACT,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,MAAc,EAAS,EAAE;IAC3C,MAAM,IAAI,gCAAe,CAAC,MAAM,EAAE;QAChC,KAAK,EACH,yEAAyE;KAC5E,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { type ContextLogTrail } from 'sdk-logs';
3
+ import type { ContextAwsLambdaCaller } from '../../domain.objects/ContextAwsLambdaCaller';
4
+ /**
5
+ * .what = the `sdk-aws-lambda gen` cli entrypoint
6
+ * .why = generates a per-service sdk into a target dir from live introspection;
7
+ * validates args, routes --env into ambient context, and maps errors to
8
+ * semantic exit codes (0 ok / 1 malfunction / 2 constraint)
9
+ *
10
+ * .context = the caller may inject `log` (observability) + `aws` (sdk seam for
11
+ * tests); both default when absent so the bin can call `gen({ argv })`.
12
+ * `env.access` is NOT injected here — it is parsed from `--env` (the cli
13
+ * is the composition root that maps the flag into ambient access).
14
+ */
15
+ export declare const gen: (input: {
16
+ argv: string[];
17
+ }, context?: {
18
+ log?: ContextLogTrail['log'];
19
+ aws?: ContextAwsLambdaCaller['aws'];
20
+ }) => Promise<{
21
+ exit: number;
22
+ message: string | null;
23
+ }>;
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.gen = void 0;
5
+ const helpful_errors_1 = require("helpful-errors");
6
+ const sdk_logs_1 = require("sdk-logs");
7
+ const genServiceSdk_1 = require("../../domain.operations/genServiceSdk/genServiceSdk");
8
+ const asGenArgs_1 = require("./asGenArgs");
9
+ /**
10
+ * .what = the `sdk-aws-lambda gen` cli entrypoint
11
+ * .why = generates a per-service sdk into a target dir from live introspection;
12
+ * validates args, routes --env into ambient context, and maps errors to
13
+ * semantic exit codes (0 ok / 1 malfunction / 2 constraint)
14
+ *
15
+ * .context = the caller may inject `log` (observability) + `aws` (sdk seam for
16
+ * tests); both default when absent so the bin can call `gen({ argv })`.
17
+ * `env.access` is NOT injected here — it is parsed from `--env` (the cli
18
+ * is the composition root that maps the flag into ambient access).
19
+ */
20
+ const gen = async (input, context) => {
21
+ const log = context?.log ?? (0, sdk_logs_1.genContextLogTrail)({ trail: null, env: null }).log;
22
+ try {
23
+ // validate args at the boundary (throws ConstraintError → exit 2)
24
+ const args = (0, asGenArgs_1.asGenArgs)({ argv: input.argv });
25
+ // route the --env flag into ambient context.env.access, then generate
26
+ await (0, genServiceSdk_1.genServiceSdk)({ which: { service: args.service }, into: args.into }, { log, env: { access: args.access }, aws: context?.aws });
27
+ return { exit: 0, message: null };
28
+ }
29
+ catch (error) {
30
+ // caller-must-fix errors → exit 2; server/unexpected → exit 1. surface the
31
+ // message on the result (not only via log) so callers + tests can assert +
32
+ // snapshot exactly what the user sees
33
+ const exit = getExitForError({ error });
34
+ const message = error instanceof Error ? error.message : String(error);
35
+ log.error('gen failed', { exit, error: message });
36
+ return { exit, message };
37
+ }
38
+ };
39
+ exports.gen = gen;
40
+ /**
41
+ * .what = decide whether a thrown error is a caller-must-fix constraint
42
+ * .why = every codegen error class (LambdaCredentialsAbsentError,
43
+ * LambdaIntrospectionBlockedError, LambdaServiceNotFoundError,
44
+ * LambdaFunctionNotFoundError, LambdaIntrospectionNotSupportedError,
45
+ * LambdaDomainObjectNotCapturableError) extends ConstraintError, so a single
46
+ * `instanceof ConstraintError` covers them all — no per-class chain to keep in
47
+ * sync (a new Lambda*Error extends ConstraintError is caught automatically)
48
+ */
49
+ const isConstraintError = (error) => error instanceof helpful_errors_1.ConstraintError;
50
+ /**
51
+ * .what = map a thrown error to its semantic exit code
52
+ * .why = constraint errors (caller must fix) exit 2; malfunctions exit 1
53
+ */
54
+ const getExitForError = (input) => {
55
+ if (isConstraintError(input.error))
56
+ return 2;
57
+ if (input.error instanceof helpful_errors_1.MalfunctionError)
58
+ return 1;
59
+ return 1;
60
+ };
61
+ // when invoked as a bin, run + set the process exit code
62
+ /* istanbul ignore next */
63
+ if (require.main === module) {
64
+ (0, exports.gen)({ argv: process.argv.slice(2) })
65
+ .then(({ exit }) => {
66
+ process.exitCode = exit;
67
+ })
68
+ .catch(() => {
69
+ process.exitCode = 1;
70
+ });
71
+ }
72
+ //# sourceMappingURL=gen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gen.js","sourceRoot":"","sources":["../../../src/contract/cli/gen.ts"],"names":[],"mappings":";;;;AAEA,mDAAmE;AACnE,uCAAoE;AAGpE,uFAAoF;AACpF,2CAAwC;AAExC;;;;;;;;;;GAUG;AACI,MAAM,GAAG,GAAG,KAAK,EACtB,KAEC,EACD,OAGC,EACkD,EAAE;IACrD,MAAM,GAAG,GACP,OAAO,EAAE,GAAG,IAAI,IAAA,6BAAkB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC;IAErE,IAAI,CAAC;QACH,kEAAkE;QAClE,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAE7C,sEAAsE;QACtE,MAAM,IAAA,6BAAa,EACjB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EACrD,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CACzD,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2EAA2E;QAC3E,2EAA2E;QAC3E,sCAAsC;QACtC,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAhCW,QAAA,GAAG,OAgCd;AAEF;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAW,EAAE,CACpD,KAAK,YAAY,gCAAe,CAAC;AAEnC;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAyB,EAAU,EAAE;IAC5D,IAAI,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,KAAK,YAAY,iCAAgB;QAAE,OAAO,CAAC,CAAC;IACtD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,yDAAyD;AACzD,0BAA0B;AAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAA,WAAG,EAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SACjC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QACjB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE;QACV,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { DomainLiteral, type DomainObjectKind } from 'domain-objects';
2
+ import type { JSONSchema } from 'zod/v4/core/json-schema';
3
+ /**
4
+ * .what = a domain-object captured from an introspected `x-domain-object` pragma,
5
+ * normalized for emit (the raw domain-objects `DomainObjectPragma` fields +
6
+ * the json-schema `shape`, with the key-fields defaulted)
7
+ * .why = parse the wire pragma once at the boundary into a structured value; all
8
+ * downstream ops speak in this instead of a re-read of the raw json
9
+ *
10
+ * .kind = which base class the upstream dobj extended (from the pragma's stamped
11
+ * `kind`); governs which base class asResourceClassSource emits
12
+ */
13
+ export interface DomainObjectCaptured {
14
+ /**
15
+ * .what = the upstream domain-object's unqualified class name (e.g. 'Job')
16
+ * .why = the codegen prefixes this with the service (e.g. 'SvcJobsJob')
17
+ */
18
+ name: string;
19
+ /**
20
+ * .what = which base class the upstream dobj extended (entity/literal/event/object)
21
+ * .why = the codegen emits the base class this maps to
22
+ */
23
+ kind: DomainObjectKind;
24
+ /**
25
+ * .what = the primary key parts (artificial/serialized key), if any
26
+ */
27
+ primary: string[];
28
+ /**
29
+ * .what = the unique key parts (natural key), if any
30
+ */
31
+ unique: string[];
32
+ /**
33
+ * .what = the colloquial alias, if declared upstream
34
+ */
35
+ alias: null | string | {
36
+ singular?: string;
37
+ plural?: string;
38
+ };
39
+ /**
40
+ * .what = map of nested-property name → nested dobj type name(s), unprefixed
41
+ * .why = the codegen prefixes each nested type name with the service; a value
42
+ * is an array when the nested position is polymorphic (choice of dobjs)
43
+ */
44
+ nested: Record<string, string | string[]>;
45
+ /**
46
+ * .what = the json-schema shape of the dobj (for TS type emit)
47
+ */
48
+ shape: JSONSchema;
49
+ }
50
+ export declare class DomainObjectCaptured extends DomainLiteral<DomainObjectCaptured> implements DomainObjectCaptured {
51
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DomainObjectCaptured = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class DomainObjectCaptured extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.DomainObjectCaptured = DomainObjectCaptured;
8
+ //# sourceMappingURL=DomainObjectCaptured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainObjectCaptured.js","sourceRoot":"","sources":["../../src/domain.objects/DomainObjectCaptured.ts"],"names":[],"mappings":";;;AAAA,mDAAsE;AAsDtE,MAAa,oBACX,SAAQ,8BAAmC;CACT;AAFpC,oDAEoC"}
@@ -0,0 +1,18 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = one file the codegen will emit (path + content)
4
+ * .why = the emit boundary speaks in a named domain literal, not raw tuples;
5
+ * the batch communicator writes a list of these atomically
6
+ */
7
+ export interface GeneratedFile {
8
+ /**
9
+ * .what = the absolute-or-relative path the file will be written to
10
+ */
11
+ path: string;
12
+ /**
13
+ * .what = the full text content of the file (already formatted)
14
+ */
15
+ content: string;
16
+ }
17
+ export declare class GeneratedFile extends DomainLiteral<GeneratedFile> implements GeneratedFile {
18
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeneratedFile = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class GeneratedFile extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.GeneratedFile = GeneratedFile;
8
+ //# sourceMappingURL=GeneratedFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneratedFile.js","sourceRoot":"","sources":["../../src/domain.objects/GeneratedFile.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAmB/C,MAAa,aACX,SAAQ,8BAA4B;CACT;AAF7B,sCAE6B"}
@@ -0,0 +1,11 @@
1
+ import { ConstraintError } from 'helpful-errors';
2
+ /**
3
+ * .what = error when the aws sdk cannot load credentials for introspection
4
+ * .why = a clear, caller-must-fix error (with an unlock hint) instead of a raw
5
+ * aws CredentialsProviderError; introspection needs live prep creds
6
+ *
7
+ * .note = bare subclass per helpful-errors convention; pass message + metadata
8
+ * at the throw site via `new LambdaCredentialsAbsentError(message, { ... })`
9
+ */
10
+ export declare class LambdaCredentialsAbsentError extends ConstraintError {
11
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LambdaCredentialsAbsentError = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = error when the aws sdk cannot load credentials for introspection
7
+ * .why = a clear, caller-must-fix error (with an unlock hint) instead of a raw
8
+ * aws CredentialsProviderError; introspection needs live prep creds
9
+ *
10
+ * .note = bare subclass per helpful-errors convention; pass message + metadata
11
+ * at the throw site via `new LambdaCredentialsAbsentError(message, { ... })`
12
+ */
13
+ class LambdaCredentialsAbsentError extends helpful_errors_1.ConstraintError {
14
+ }
15
+ exports.LambdaCredentialsAbsentError = LambdaCredentialsAbsentError;
16
+ //# sourceMappingURL=LambdaCredentialsAbsentError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaCredentialsAbsentError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaCredentialsAbsentError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;;GAOG;AACH,MAAa,4BAA6B,SAAQ,gCAAe;CAAG;AAApE,oEAAoE"}
@@ -0,0 +1,12 @@
1
+ import { ConstraintError } from 'helpful-errors';
2
+ /**
3
+ * .what = error when a contract-surfaced domain-object cannot be captured
4
+ * .why = a dobj referenced by an endpoint that declares no `static schema` has no
5
+ * shape to reconstruct; fail loud and name the dobj (uc.9) rather than
6
+ * silently drop it
7
+ *
8
+ * .note = bare subclass per helpful-errors convention; pass message + metadata
9
+ * at the throw site via `new LambdaDomainObjectNotCapturableError(message, { ... })`
10
+ */
11
+ export declare class LambdaDomainObjectNotCapturableError extends ConstraintError {
12
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LambdaDomainObjectNotCapturableError = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = error when a contract-surfaced domain-object cannot be captured
7
+ * .why = a dobj referenced by an endpoint that declares no `static schema` has no
8
+ * shape to reconstruct; fail loud and name the dobj (uc.9) rather than
9
+ * silently drop it
10
+ *
11
+ * .note = bare subclass per helpful-errors convention; pass message + metadata
12
+ * at the throw site via `new LambdaDomainObjectNotCapturableError(message, { ... })`
13
+ */
14
+ class LambdaDomainObjectNotCapturableError extends helpful_errors_1.ConstraintError {
15
+ }
16
+ exports.LambdaDomainObjectNotCapturableError = LambdaDomainObjectNotCapturableError;
17
+ //# sourceMappingURL=LambdaDomainObjectNotCapturableError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaDomainObjectNotCapturableError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaDomainObjectNotCapturableError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;;;GAQG;AACH,MAAa,oCAAqC,SAAQ,gCAAe;CAAG;AAA5E,oFAA4E"}
@@ -0,0 +1,14 @@
1
+ import { ConstraintError } from 'helpful-errors';
2
+ /**
3
+ * .what = error when a domain-object REFERENCE names a dobj that is not captured in
4
+ * full anywhere in the service's contracts, so the generated `typeof
5
+ * Svc<Prefix><Name>` cannot bind
6
+ * .why = a ref emits `RefByPrimary<typeof SvcSurfSeaturtle>`; that resource must
7
+ * exist. if no endpoint surfaces the referenced dobj whole, the generated sdk
8
+ * would not compile — fail loud (caller must surface the dobj on an endpoint)
9
+ *
10
+ * .note = bare subclass per helpful-errors convention; pass message + metadata at
11
+ * the throw site via `new LambdaDomainObjectRefUnbindableError(message, { ... })`
12
+ */
13
+ export declare class LambdaDomainObjectRefUnbindableError extends ConstraintError {
14
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LambdaDomainObjectRefUnbindableError = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = error when a domain-object REFERENCE names a dobj that is not captured in
7
+ * full anywhere in the service's contracts, so the generated `typeof
8
+ * Svc<Prefix><Name>` cannot bind
9
+ * .why = a ref emits `RefByPrimary<typeof SvcSurfSeaturtle>`; that resource must
10
+ * exist. if no endpoint surfaces the referenced dobj whole, the generated sdk
11
+ * would not compile — fail loud (caller must surface the dobj on an endpoint)
12
+ *
13
+ * .note = bare subclass per helpful-errors convention; pass message + metadata at
14
+ * the throw site via `new LambdaDomainObjectRefUnbindableError(message, { ... })`
15
+ */
16
+ class LambdaDomainObjectRefUnbindableError extends helpful_errors_1.ConstraintError {
17
+ }
18
+ exports.LambdaDomainObjectRefUnbindableError = LambdaDomainObjectRefUnbindableError;
19
+ //# sourceMappingURL=LambdaDomainObjectRefUnbindableError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaDomainObjectRefUnbindableError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaDomainObjectRefUnbindableError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;;;;;GAUG;AACH,MAAa,oCAAqC,SAAQ,gCAAe;CAAG;AAA5E,oFAA4E"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * .what = derive the codegen symbols (object name + dobj prefix) for a service
3
+ * .why = the generated sdk names one object `svcJobs` and prefixes captured
4
+ * domain-objects `SvcJobsJob`; both derive from the `svc-{noun}` name
5
+ *
6
+ * .model = matches the extant `asLambdaEndpoint` slug parser: a service is
7
+ * exactly `svc-{noun}` (2 dash-segments). so `svc-jobs` → noun `jobs`.
8
+ *
9
+ * .throws UnexpectedCodePathError — input is not a valid `svc-{noun}` service
10
+ */
11
+ export declare const asServiceSymbols: (input: {
12
+ service: string;
13
+ }) => {
14
+ object: string;
15
+ prefix: string;
16
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asServiceSymbols = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = derive the codegen symbols (object name + dobj prefix) for a service
7
+ * .why = the generated sdk names one object `svcJobs` and prefixes captured
8
+ * domain-objects `SvcJobsJob`; both derive from the `svc-{noun}` name
9
+ *
10
+ * .model = matches the extant `asLambdaEndpoint` slug parser: a service is
11
+ * exactly `svc-{noun}` (2 dash-segments). so `svc-jobs` → noun `jobs`.
12
+ *
13
+ * .throws UnexpectedCodePathError — input is not a valid `svc-{noun}` service
14
+ */
15
+ const asServiceSymbols = (input) => {
16
+ // split the service into its dash-segments
17
+ const parts = input.service.split('-');
18
+ // require the svc-{noun} shape: exactly 2 non-empty segments, first is 'svc'
19
+ const isValid = parts.length === 2 && parts[0] === 'svc' && (parts[1]?.length ?? 0) > 0;
20
+ if (!isValid)
21
+ throw new helpful_errors_1.UnexpectedCodePathError(`service does not match expected 'svc-{noun}' shape`, { service: input.service });
22
+ // noun is the second segment (e.g. 'jobs')
23
+ const noun = parts[1];
24
+ // object = camelCase svc+noun (e.g. 'svcJobs')
25
+ const object = `svc${capitalize(noun)}`;
26
+ // prefix = PascalCase Svc+Noun (e.g. 'SvcJobs')
27
+ const prefix = `Svc${capitalize(noun)}`;
28
+ return { object, prefix };
29
+ };
30
+ exports.asServiceSymbols = asServiceSymbols;
31
+ /**
32
+ * .what = uppercase the first character of a word
33
+ * .why = build camelCase/PascalCase symbols from the service noun
34
+ */
35
+ const capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
36
+ //# sourceMappingURL=asServiceSymbols.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asServiceSymbols.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAEzD;;;;;;;;;GASG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAEhC,EAAsC,EAAE;IACvC,2CAA2C;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,6EAA6E;IAC7E,MAAM,OAAO,GACX,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1E,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,wCAAuB,CAC/B,oDAAoD,EACpD,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAC3B,CAAC;IAEJ,2CAA2C;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;IAEhC,+CAA+C;IAC/C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAExC,gDAAgD;IAChD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAExC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC,CAAC;AAzBW,QAAA,gBAAgB,oBAyB3B;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * .what = assemble the `<svc>.ts` barrel file text
3
+ * .why = the single public entrypoint: re-exports the mechanisms object + all
4
+ * resource declarations, so consumers import from one path (uc.1)
5
+ */
6
+ export declare const asBarrelFileSource: (input: {
7
+ object: string;
8
+ mechanismsModule: string;
9
+ resourcesModule: string;
10
+ }) => string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asBarrelFileSource = void 0;
4
+ const banner_1 = require("./banner");
5
+ /**
6
+ * .what = assemble the `<svc>.ts` barrel file text
7
+ * .why = the single public entrypoint: re-exports the mechanisms object + all
8
+ * resource declarations, so consumers import from one path (uc.1)
9
+ */
10
+ const asBarrelFileSource = (input) => [
11
+ banner_1.banner,
12
+ '',
13
+ `export { ${input.object} } from '${input.mechanismsModule}';`,
14
+ `export * from '${input.resourcesModule}';`,
15
+ '',
16
+ ].join('\n');
17
+ exports.asBarrelFileSource = asBarrelFileSource;
18
+ //# sourceMappingURL=asBarrelFileSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asBarrelFileSource.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAElC;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAIlC,EAAU,EAAE,CACX;IACE,eAAM;IACN,EAAE;IACF,YAAY,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,gBAAgB,IAAI;IAC9D,kBAAkB,KAAK,CAAC,eAAe,IAAI;IAC3C,EAAE;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAXF,QAAA,kBAAkB,sBAWhB"}
@@ -0,0 +1,14 @@
1
+ import type { LambdaEndpointSchema } from '../../../domain.objects/LambdaEndpointSchema';
2
+ /**
3
+ * .what = assemble the full `<svc>.mechanisms.ts` file text
4
+ * .why = exposes the `<object>` const of typed `(event, context)` fns, one per
5
+ * endpoint (uc.1); imports askLambdaEndpoint + the resource types
6
+ */
7
+ export declare const asMechanismsFileSource: (input: {
8
+ service: string;
9
+ object: string;
10
+ resourcesModule: string;
11
+ resourceNames: string[];
12
+ contracts: Record<string, LambdaEndpointSchema>;
13
+ dobjRefs: Record<string, string>;
14
+ }) => string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asMechanismsFileSource = void 0;
4
+ const asMechanismFnSource_1 = require("../gen.mechanism/asMechanismFnSource");
5
+ const banner_1 = require("./banner");
6
+ /**
7
+ * .what = assemble the full `<svc>.mechanisms.ts` file text
8
+ * .why = exposes the `<object>` const of typed `(event, context)` fns, one per
9
+ * endpoint (uc.1); imports askLambdaEndpoint + the resource types
10
+ */
11
+ const asMechanismsFileSource = (input) => {
12
+ // one fn per endpoint, keyed by bare function name (sorted for stable output)
13
+ const fns = Object.keys(input.contracts)
14
+ .sort()
15
+ .map((fnName) => (0, asMechanismFnSource_1.asMechanismFnSource)({
16
+ service: input.service,
17
+ function: fnName,
18
+ schema: input.contracts[fnName],
19
+ dobjRefs: input.dobjRefs,
20
+ }));
21
+ const fnsText = fns.join('\n');
22
+ // import only the resource types the fn signatures actually name — a nested-only
23
+ // dobj (referenced inside another resource, never in a fn signature) must NOT be
24
+ // imported here, else the generated file has an unused import (consumer lint fails)
25
+ const usedResourceNames = input.resourceNames.filter((name) => new RegExp(`\\b${name}\\b`).test(fnsText));
26
+ // the import lines: askLambdaEndpoint always; resource types only if any used
27
+ const imports = [
28
+ `import { askLambdaEndpoint, type ContextAwsLambdaCaller } from 'sdk-aws-lambda';`,
29
+ ];
30
+ if (usedResourceNames.length > 0)
31
+ imports.push(`import type { ${usedResourceNames.join(', ')} } from '${input.resourcesModule}';`);
32
+ return [
33
+ banner_1.banner,
34
+ '',
35
+ imports.join('\n'),
36
+ '',
37
+ `export const ${input.object} = {`,
38
+ fnsText,
39
+ `};`,
40
+ '',
41
+ ].join('\n');
42
+ };
43
+ exports.asMechanismsFileSource = asMechanismsFileSource;
44
+ //# sourceMappingURL=asMechanismsFileSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asMechanismsFileSource.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.ts"],"names":[],"mappings":";;;AACA,8EAA2E;AAC3E,qCAAkC;AAElC;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CAAC,KAOtC,EAAU,EAAE;IACX,8EAA8E;IAC9E,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;SACrC,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACd,IAAA,yCAAmB,EAAC;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAyB;QACvD,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CACH,CAAC;IACJ,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,iFAAiF;IACjF,iFAAiF;IACjF,oFAAoF;IACpF,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAC5D,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAC1C,CAAC;IAEF,8EAA8E;IAC9E,MAAM,OAAO,GAAG;QACd,kFAAkF;KACnF,CAAC;IACF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;QAC9B,OAAO,CAAC,IAAI,CACV,iBAAiB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,eAAe,IAAI,CACnF,CAAC;IAEJ,OAAO;QACL,eAAM;QACN,EAAE;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB,EAAE;QACF,gBAAgB,KAAK,CAAC,MAAM,MAAM;QAClC,OAAO;QACP,IAAI;QACJ,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AA/CW,QAAA,sBAAsB,0BA+CjC"}
@@ -0,0 +1,11 @@
1
+ import type { DomainObjectCaptured } from '../../../domain.objects/DomainObjectCaptured';
2
+ /**
3
+ * .what = assemble the full `<svc>.resources.ts` file text
4
+ * .why = declares every captured dobj as a prefixed interface + class (uc.2);
5
+ * imports the domain-objects base classes; carries the do-not-edit banner
6
+ */
7
+ export declare const asResourcesFileSource: (input: {
8
+ dobjs: DomainObjectCaptured[];
9
+ prefix: string;
10
+ dobjRefs: Record<string, string>;
11
+ }) => string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asResourcesFileSource = void 0;
4
+ const getTypescriptFromJsonSchema_1 = require("../gen.mechanism/getTypescriptFromJsonSchema");
5
+ const asResourceClassSource_1 = require("../gen.resource/asResourceClassSource");
6
+ const banner_1 = require("./banner");
7
+ /**
8
+ * .what = assemble the full `<svc>.resources.ts` file text
9
+ * .why = declares every captured dobj as a prefixed interface + class (uc.2);
10
+ * imports the domain-objects base classes; carries the do-not-edit banner
11
+ */
12
+ const asResourcesFileSource = (input) => {
13
+ // one interface + class block per captured dobj (sorted for stable output)
14
+ const blocks = input.dobjs.map((dobj) => (0, asResourceClassSource_1.asResourceClassSource)({
15
+ dobj,
16
+ prefix: input.prefix,
17
+ dobjRefs: input.dobjRefs,
18
+ }));
19
+ // import only the base classes actually used — one per distinct kind present
20
+ // (entity→DomainEntity, literal→DomainLiteral, etc); an unused import here would
21
+ // trip the consumer's lint (rule.forbid.snapshot-visual-blemishes)
22
+ const baseClasses = [
23
+ ...new Set(input.dobjs.map((dobj) => asResourceClassSource_1.BASE_CLASS_BY_KIND[dobj.kind])),
24
+ ];
25
+ // import the ref generics (Ref / RefByPrimary / RefByUnique) any dobj shape
26
+ // references — collected across every captured dobj so the import carries exactly
27
+ // the generics emitted (no unused import)
28
+ const refGenerics = [
29
+ ...new Set(input.dobjs.flatMap((dobj) => (0, getTypescriptFromJsonSchema_1.getRefGenericsUsed)({ schema: dobj.shape, dobjRefs: input.dobjRefs }))),
30
+ ].sort();
31
+ // one domain-objects import for base classes + ref generics, alphabetized
32
+ const imported = [...baseClasses, ...refGenerics].sort();
33
+ // the import line, omitted entirely when the import list is empty
34
+ const importLine = imported.length > 0
35
+ ? `import { ${imported.join(', ')} } from 'domain-objects';`
36
+ : null;
37
+ return [banner_1.banner, '', importLine, '', blocks.join('\n\n'), '']
38
+ .filter((line) => line !== null)
39
+ .join('\n');
40
+ };
41
+ exports.asResourcesFileSource = asResourcesFileSource;
42
+ //# sourceMappingURL=asResourcesFileSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asResourcesFileSource.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.ts"],"names":[],"mappings":";;;AACA,8FAAkF;AAClF,iFAG+C;AAC/C,qCAAkC;AAElC;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,KAIrC,EAAU,EAAE;IACX,2EAA2E;IAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtC,IAAA,6CAAqB,EAAC;QACpB,IAAI;QACJ,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CACH,CAAC;IAEF,6EAA6E;IAC7E,iFAAiF;IACjF,mEAAmE;IACnE,MAAM,WAAW,GAAG;QAClB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,0CAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;KACrE,CAAC;IAEF,4EAA4E;IAC5E,kFAAkF;IAClF,0CAA0C;IAC1C,MAAM,WAAW,GAAG;QAClB,GAAG,IAAI,GAAG,CACR,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC3B,IAAA,gDAAkB,EAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CACrE,CACF;KACF,CAAC,IAAI,EAAE,CAAC;IAET,0EAA0E;IAC1E,MAAM,QAAQ,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IAEzD,kEAAkE;IAClE,MAAM,UAAU,GACd,QAAQ,CAAC,MAAM,GAAG,CAAC;QACjB,CAAC,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B;QAC5D,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO,CAAC,eAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;SACzD,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC;SAC/C,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AA5CW,QAAA,qBAAqB,yBA4ChC"}