@othree.io/chisel-sdk 4.0.0 → 5.0.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 (84) hide show
  1. package/README.md +207 -1
  2. package/lib/cjs/aws/index.d.ts.map +1 -0
  3. package/lib/cjs/aws/index.js.map +1 -0
  4. package/lib/cjs/aws/read.d.ts +44 -0
  5. package/lib/cjs/aws/read.d.ts.map +1 -0
  6. package/lib/{aws → cjs/aws}/read.js +65 -48
  7. package/lib/cjs/aws/read.js.map +1 -0
  8. package/lib/cjs/aws/write.d.ts +23 -0
  9. package/lib/cjs/aws/write.d.ts.map +1 -0
  10. package/lib/{aws → cjs/aws}/write.js +56 -34
  11. package/lib/cjs/aws/write.js.map +1 -0
  12. package/lib/cjs/iac/index.d.ts +28 -0
  13. package/lib/cjs/iac/index.d.ts.map +1 -0
  14. package/lib/{iac → cjs/iac}/index.js +23 -8
  15. package/lib/cjs/iac/index.js.map +1 -0
  16. package/lib/cjs/iac/read.d.ts +50 -0
  17. package/lib/cjs/iac/read.d.ts.map +1 -0
  18. package/lib/{iac → cjs/iac}/read.js +58 -32
  19. package/lib/cjs/iac/read.js.map +1 -0
  20. package/lib/cjs/iac/shared.d.ts +14 -0
  21. package/lib/cjs/iac/shared.d.ts.map +1 -0
  22. package/lib/{iac → cjs/iac}/shared.js +12 -8
  23. package/lib/cjs/iac/shared.js.map +1 -0
  24. package/lib/cjs/iac/types.d.ts +28 -0
  25. package/lib/cjs/iac/types.d.ts.map +1 -0
  26. package/lib/cjs/iac/types.js +26 -0
  27. package/lib/cjs/iac/types.js.map +1 -0
  28. package/lib/cjs/iac/write.d.ts +32 -0
  29. package/lib/cjs/iac/write.d.ts.map +1 -0
  30. package/lib/{iac → cjs/iac}/write.js +40 -17
  31. package/lib/cjs/iac/write.js.map +1 -0
  32. package/lib/cjs/index.d.ts.map +1 -0
  33. package/lib/cjs/index.js.map +1 -0
  34. package/lib/esm/aws/index.js +3 -0
  35. package/lib/esm/aws/index.js.map +1 -0
  36. package/lib/esm/aws/read.js +119 -0
  37. package/lib/esm/aws/read.js.map +1 -0
  38. package/lib/esm/aws/write.js +99 -0
  39. package/lib/esm/aws/write.js.map +1 -0
  40. package/lib/esm/iac/index.js +66 -0
  41. package/lib/esm/iac/index.js.map +1 -0
  42. package/lib/esm/iac/read.js +168 -0
  43. package/lib/esm/iac/read.js.map +1 -0
  44. package/lib/esm/iac/shared.js +32 -0
  45. package/lib/esm/iac/shared.js.map +1 -0
  46. package/lib/esm/iac/types.js +23 -0
  47. package/lib/esm/iac/types.js.map +1 -0
  48. package/lib/esm/iac/write.js +92 -0
  49. package/lib/esm/iac/write.js.map +1 -0
  50. package/lib/esm/index.js +3 -0
  51. package/lib/esm/index.js.map +1 -0
  52. package/package.json +50 -21
  53. package/.gitlab-ci.yml +0 -29
  54. package/lib/aws/index.d.ts.map +0 -1
  55. package/lib/aws/index.js.map +0 -1
  56. package/lib/aws/read.d.ts +0 -35
  57. package/lib/aws/read.d.ts.map +0 -1
  58. package/lib/aws/read.js.map +0 -1
  59. package/lib/aws/write.d.ts +0 -24
  60. package/lib/aws/write.d.ts.map +0 -1
  61. package/lib/aws/write.js.map +0 -1
  62. package/lib/iac/index.d.ts +0 -24
  63. package/lib/iac/index.d.ts.map +0 -1
  64. package/lib/iac/index.js.map +0 -1
  65. package/lib/iac/read.d.ts +0 -48
  66. package/lib/iac/read.d.ts.map +0 -1
  67. package/lib/iac/read.js.map +0 -1
  68. package/lib/iac/shared.d.ts +0 -12
  69. package/lib/iac/shared.d.ts.map +0 -1
  70. package/lib/iac/shared.js.map +0 -1
  71. package/lib/iac/types.d.ts +0 -13
  72. package/lib/iac/types.d.ts.map +0 -1
  73. package/lib/iac/types.js +0 -14
  74. package/lib/iac/types.js.map +0 -1
  75. package/lib/iac/write.d.ts +0 -29
  76. package/lib/iac/write.d.ts.map +0 -1
  77. package/lib/iac/write.js.map +0 -1
  78. package/lib/index.d.ts.map +0 -1
  79. package/lib/index.js.map +0 -1
  80. package/release.config.js +0 -4
  81. /package/lib/{aws → cjs/aws}/index.d.ts +0 -0
  82. /package/lib/{aws → cjs/aws}/index.js +0 -0
  83. /package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  84. /package/lib/{index.js → cjs/index.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/aws/write.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8C;AAC9C,8CAA0G;AAC1G,8CAAwC;AACxC,gDAAyE;AACzE,kDAA4C;AAC5C,gDAAwC;AACxC,sDAK8B;AAC9B,gDAA8D;AAC9D,6BAAqB;AACrB,+BAAkC;AAClC,2DAA4C;AAC5C,8DAAuD;AACvD,oDAA6C;AAgB7C,MAAM,sBAAsB,GAA+C,OAAC,CAAC,MAAM,CAAC;IAChF,WAAW,EAAE,wBAAc;IAC3B,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,wBAAc,CAAC;CACxC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,CAA2C,KAAmD,EAAsH,EAAE;IAC3O,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC,CAAC;QACjE,WAAW,EAAE,IAAA,mBAAQ,EAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QACtE,YAAY,EAAE,IAAA,mBAAQ,EAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;KAC9F,CAAC,CAAC,GAAG,EAAE,CAAA;IAER,OAAO;QACH,cAAc,EAAE,KAAK,CAAC,cA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,oBAAW,CAAC,iBAAiB,CAAuB;QACjI,aAAa;QACb,KAAK,EAAL,SAAK;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE,KAAK,CAAC,WAAW;KAC5B,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAA;IAExB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAA;IAEjF,MAAM,YAAY,GAAgC,QAAQ,CAAC,cAAK,CAAC,MAAM,CAAgB;QACnF,SAAS;QACT,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,iBAAiB;QACjB,YAAY;QACZ,KAAK,EAAL,eAAK;KACR,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAA;IAE1B,MAAM,aAAa,GAAG,QAAQ,CAAC,qBAAQ,CAAC,mBAAmB,CAAgB;QACvE,MAAM,EAAE,YAAY;KACvB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAA;IAE1B,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,aAAa,EAAE,eAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3C,QAAQ,EAAE,eAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;KAC7C,CAAC,CAAA;AACN,CAAC,CAAA;AArEY,QAAA,WAAW,eAqEvB","sourcesContent":["import {handlers} from '@othree.io/chisel-aws'\nimport {actor, ChiselEvent, CommandResult, eventSource, EventSourceConfiguration} from '@othree.io/chisel'\nimport {lambda} from '@othree.io/awsome'\nimport {logIOAsync, createDefaultWinstonLogger} from '@othree.io/journal'\nimport {Optional} from '@othree.io/optional'\nimport {match} from '@othree.io/cerillo'\nimport {\n awsActor,\n awsEventSource,\n ChiselDynamoConfiguration,\n ChiselShardedSnsConfiguration,\n} from '@othree.io/chisel-aws'\nimport {zodValidate, NonEmptyString} from '@othree.io/auditor'\nimport {z} from 'zod'\nimport { v7 as newId } from 'uuid'\nimport * as AWSXRay from 'aws-xray-sdk-core'\nimport {DynamoDBClient} from '@aws-sdk/client-dynamodb'\nimport {SNSClient} from '@aws-sdk/client-sns'\n\ntype GetStateQuery = Readonly<{\n contextId: string\n}>\n\nexport type LambdaActor<AggregateRoot> = Readonly<{\n handleCommand: (event: handlers.LambdaCommand) => Promise<lambda.InvocationResult<CommandResult<AggregateRoot>>>\n getState: (event: lambda.Query<GetStateQuery>) => Promise<lambda.InvocationResult<AggregateRoot>>\n}>\n\ntype ChiselActorEnvironmentVariables = Readonly<{\n eventsTable: string\n eventsTopics: Array<string>\n}>\n\nconst ChiselActorConstraints: z.ZodType<ChiselActorEnvironmentVariables> = z.object({\n eventsTable: NonEmptyString,\n eventsTopics: z.array(NonEmptyString),\n})\n\nconst getConfiguration = <AggregateRoot, Event extends ChiselEvent>(input: CreateLambdaActorInput<AggregateRoot, Event>): ChiselDynamoConfiguration & ChiselShardedSnsConfiguration<AggregateRoot> & EventSourceConfiguration<AggregateRoot> => {\n const envVars = zodValidate({ constraints: ChiselActorConstraints })({\n eventsTable: Optional(process.env.EVENTS_TABLE).map(String).orElse(''),\n eventsTopics: Optional(process.env.EVENTS_TOPICS).map(_ => String(_).split(',')).orElse([]),\n }).get()\n\n return {\n BoundedContext: input.boundedContext,\n IsFifo: true,\n SnapshotFrequency: 100,\n TableName: envVars.eventsTable,\n TopicsArn: envVars.eventsTopics,\n SnapshotEventType: '$SNAPSHOT$',\n GetMessageGroupId: (event: ChiselEvent, _state: AggregateRoot) => event.contextId,\n IncludeState: true,\n SnapshotSerializer: {\n serialize: (state: AggregateRoot) => JSON.stringify(state),\n deserialize: (state: string) => JSON.parse(state) as AggregateRoot\n }\n }\n}\n\ntype CreateLambdaActorInput<AggregateRoot, Event extends ChiselEvent> = Readonly<{\n boundedContext: string\n now: () => number\n getInitialState: (contextId: Optional<string>) => Promise<Optional<AggregateRoot>>\n handleCommand: actor.HandleCommand<AggregateRoot>\n reduceEvent: eventSource.Reduce<AggregateRoot, Event>\n getConfiguration?: () => ChiselDynamoConfiguration & ChiselShardedSnsConfiguration<AggregateRoot> & EventSourceConfiguration<AggregateRoot>\n}>\n\nconst getStateHandler = <AggregateRoot>(loadState: eventSource.LoadState<AggregateRoot>) =>\n async (event: lambda.Query<GetStateQuery>): Promise<AggregateRoot> => {\n return loadState(Optional(event.query.contextId))\n .then(_ => _.map(state => state.state).get() as AggregateRoot)\n }\n\nexport const createActor = <AggregateRoot, Event extends ChiselEvent>(input: CreateLambdaActorInput<AggregateRoot, Event>): LambdaActor<AggregateRoot> => {\n const logLevel = Optional(process.env.LOG_LEVEL)\n .orElse('info')\n\n const logger = createDefaultWinstonLogger(console)(input.boundedContext, logLevel)\n\n const logDebug = logIOAsync({\n now: input.now,\n log: logger.debug.bind(logger),\n logError: logger.error.bind(logger),\n })\n\n const configuration: EventSourceConfiguration<AggregateRoot> & ChiselDynamoConfiguration & ChiselShardedSnsConfiguration<AggregateRoot> = Optional(input.getConfiguration)\n .map(_ => _())\n .orElse(getConfiguration(input))\n\n const dynamoDbClient = AWSXRay.captureAWSv3Client(new DynamoDBClient({}))\n const snsClient = AWSXRay.captureAWSv3Client(new SNSClient({}))\n\n const getEvents = logDebug(awsEventSource.getEvents({\n dynamoDb: dynamoDbClient,\n configuration,\n }))('getEvents')\n\n const persistEvent: eventSource.PersistEvent = logDebug(awsEventSource.persist({\n dynamoDb: dynamoDbClient,\n configuration,\n }))('persistEvent')\n\n const publishEvent: actor.PublishEvent<AggregateRoot> = logDebug(awsActor.publishShardedEvent<AggregateRoot>({\n hashCode: awsActor.hashCode,\n snsClient,\n configuration,\n }))('publishEvent')\n\n const loadState: eventSource.LoadState<AggregateRoot> = logDebug(eventSource.loadState<AggregateRoot, Event>({\n configuration,\n getEvents: getEvents,\n getInitialState: input.getInitialState,\n reduce: input.reduceEvent,\n match,\n }))('loadState')\n\n const calculateNewState: eventSource.CalculateNewState<AggregateRoot> = logDebug(eventSource.calculateNewState<AggregateRoot, Event>({\n configuration,\n newId,\n now: input.now,\n persistEvent: persistEvent,\n reduce: input.reduceEvent,\n }))('calculateNewState')\n\n const getStateHandlerFn = logDebug(getStateHandler(loadState))('getStateHandler')\n\n const actorHandler: actor.Handle<AggregateRoot> = logDebug(actor.handle<AggregateRoot>({\n loadState,\n handleCommand: input.handleCommand,\n calculateNewState,\n publishEvent,\n match,\n }))('chiselHandleCommand')\n\n const handleCommand = logDebug(handlers.handleLambdaCommand<AggregateRoot>({\n handle: actorHandler,\n }))('handleLambdaCommand')\n\n return Object.freeze({\n handleCommand: lambda.unwrap(handleCommand),\n getState: lambda.unwrap(getStateHandlerFn),\n })\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { App } from 'aws-cdk-lib';
2
+ import { stack } from '@othree.io/cdk';
3
+ import { ChiselServiceContext } from './types';
4
+ import { TopicsStackOutput } from './shared';
5
+ import { WritePersistenceStackOutput, WriteServicesStackOutput, WriteSideInput } from './write';
6
+ import { QueueSubscribersStackOutput, ReadPersistenceStackOutput, ReadServicesStackOutput, ReadSideInput } from './read';
7
+ export type StacksInput = Readonly<{
8
+ boundedContext: string;
9
+ version: string;
10
+ projectMetadata: stack.ProjectMetadata;
11
+ context: ChiselServiceContext;
12
+ writeSide: WriteSideInput;
13
+ readSide?: ReadSideInput;
14
+ }>;
15
+ export type ChiselStacks = Readonly<{
16
+ topics: TopicsStackOutput;
17
+ writeSide: Readonly<{
18
+ persistence: WritePersistenceStackOutput;
19
+ services: WriteServicesStackOutput;
20
+ }>;
21
+ readSide?: Readonly<{
22
+ subscribers: QueueSubscribersStackOutput;
23
+ persistence: ReadPersistenceStackOutput;
24
+ servicesStack: ReadServicesStackOutput;
25
+ }>;
26
+ }>;
27
+ export declare const createChiselStacks: (app: App, input: StacksInput) => ChiselStacks;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/iac/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAEpC,OAAO,EAAC,oBAAoB,EAAkC,MAAM,SAAS,CAAA;AAE7E,OAAO,EAAoB,iBAAiB,EAAC,MAAM,UAAU,CAAA;AAC7D,OAAO,EAEH,2BAA2B,EAC3B,wBAAwB,EACxB,cAAc,EACjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAGH,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,aAAa,EAChB,MAAM,QAAQ,CAAA;AAGf,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,KAAK,CAAC,eAAe,CAAA;IACtC,OAAO,EAAE,oBAAoB,CAAA;IAC7B,SAAS,EAAE,cAAc,CAAA;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAA;CAC3B,CAAC,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAA;IACzB,SAAS,EAAE,QAAQ,CAAC;QAChB,WAAW,EAAE,2BAA2B,CAAA;QACxC,QAAQ,EAAE,wBAAwB,CAAA;KACrC,CAAC,CAAA;IACF,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAChB,WAAW,EAAE,2BAA2B,CAAA;QACxC,WAAW,EAAE,0BAA0B,CAAA;QACvC,aAAa,EAAE,uBAAuB,CAAA;KACzC,CAAC,CAAA;CACL,CAAC,CAAA;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,GAAG,EAAE,OAAO,WAAW,KAAG,YAgEjE,CAAA"}
@@ -1,32 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createChiselStacks = void 0;
4
- const context_1 = require("@othree.io/cdk/lib/context");
5
- const auditor_1 = require("@othree.io/auditor");
6
4
  const optional_1 = require("@othree.io/optional");
7
5
  const types_1 = require("./types");
6
+ const auditor_1 = require("@othree.io/auditor");
8
7
  const shared_1 = require("./shared");
9
8
  const write_1 = require("./write");
10
9
  const read_1 = require("./read");
11
10
  const createChiselStacks = (app, input) => {
12
- const context = ((0, context_1.loadCdkContext)(auditor_1.zod.zodValidate)(app, types_1.ChiselServiceContextConstraints)).get();
11
+ const context = (0, auditor_1.zodValidate)({ constraints: types_1.ChiselServiceContextConstraints })(input.context).get();
13
12
  const topicsStack = (0, shared_1.createTopicsStack)(app, context, {
14
13
  boundedContext: input.boundedContext,
15
14
  version: input.version,
15
+ projectMetadata: input.projectMetadata,
16
+ });
17
+ const writePersistenceStack = (0, write_1.createWritePersistenceStack)(app, context, {
18
+ boundedContext: input.boundedContext,
19
+ version: input.version,
20
+ writeSide: input.writeSide,
21
+ projectMetadata: input.projectMetadata,
22
+ });
23
+ const writeServicesStack = (0, write_1.createWriteServicesStack)(app, context, {
24
+ boundedContext: input.boundedContext,
25
+ version: input.version,
26
+ writeSide: input.writeSide,
27
+ eventsTable: writePersistenceStack.eventsTable,
28
+ topics: topicsStack.topics,
29
+ projectMetadata: input.projectMetadata,
16
30
  });
17
- const writePersistenceStack = (0, write_1.createWritePersistenceStack)(app, context, input);
18
- const writeServicesStack = (0, write_1.createWriteServicesStack)(app, context, Object.assign(Object.assign({}, input), { eventsTable: writePersistenceStack.eventsTable, topics: topicsStack.topics }));
19
31
  const readSideStacks = (0, optional_1.Optional)(input.readSide).map(readSide => {
20
32
  const subscribersStack = (0, read_1.createTopicSubscribersStack)(app, context, {
21
33
  boundedContext: input.boundedContext,
22
34
  version: input.version,
23
35
  readSide: readSide,
24
- topics: topicsStack.topics
36
+ topics: topicsStack.topics,
37
+ projectMetadata: input.projectMetadata,
25
38
  });
26
39
  const persistenceStack = (0, read_1.createReadPersistenceStack)(app, context, {
27
40
  boundedContext: input.boundedContext,
28
41
  version: input.version,
29
- readSide: readSide
42
+ readSide: readSide,
43
+ projectMetadata: input.projectMetadata,
30
44
  });
31
45
  const servicesStack = (0, read_1.createReadServicesStack)(app, context, {
32
46
  boundedContext: input.boundedContext,
@@ -34,7 +48,8 @@ const createChiselStacks = (app, input) => {
34
48
  readSide: readSide,
35
49
  dlq: subscribersStack.dlq,
36
50
  eventQueues: subscribersStack.eventQueues,
37
- projectionTable: persistenceStack.projectionTable
51
+ projectionTable: persistenceStack.projectionTable,
52
+ projectMetadata: input.projectMetadata,
38
53
  });
39
54
  return Object.freeze({
40
55
  subscribers: subscribersStack,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/iac/index.ts"],"names":[],"mappings":";;;AAEA,kDAA4C;AAC5C,mCAA6E;AAC7E,gDAA8C;AAC9C,qCAA6D;AAC7D,mCAKgB;AAChB,iCAOe;AAyBR,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAE,KAAkB,EAAgB,EAAE;IAC7E,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,uCAA+B,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAA;IAElG,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,GAAG,EAAE,OAAO,EAAE;QAChD,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,eAAe,EAAE,KAAK,CAAC,eAAe;KACzC,CAAC,CAAA;IACF,MAAM,qBAAqB,GAAG,IAAA,mCAA2B,EAAC,GAAG,EAAE,OAAO,EAAE;QACpE,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;KACzC,CAAC,CAAA;IACF,MAAM,kBAAkB,GAAG,IAAA,gCAAwB,EAAC,GAAG,EAAE,OAAO,EAAE;QAC9D,cAAc,EAA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,EAAE,gBAAgB;YAC7B,aAAa,EAAE,aAAa;SAC/B,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,qBAAqB;YAClC,QAAQ,EAAE,kBAAkB;SAC/B,CAAC;QACF,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,SAAU,CAAC;KAC9C,CAAC,CAAA;AACN,CAAC,CAAA;AAhEY,QAAA,kBAAkB,sBAgE9B","sourcesContent":["import {App} from 'aws-cdk-lib'\nimport {stack} from '@othree.io/cdk'\nimport {Optional} from '@othree.io/optional'\nimport {ChiselServiceContext, ChiselServiceContextConstraints} from './types'\nimport {zodValidate} from '@othree.io/auditor'\nimport {createTopicsStack, TopicsStackOutput} from './shared'\nimport {\n createWritePersistenceStack, createWriteServicesStack,\n WritePersistenceStackOutput,\n WriteServicesStackOutput,\n WriteSideInput\n} from './write'\nimport {\n createReadPersistenceStack, createReadServicesStack,\n createTopicSubscribersStack,\n QueueSubscribersStackOutput,\n ReadPersistenceStackOutput,\n ReadServicesStackOutput,\n ReadSideInput\n} from './read'\n\n\nexport type StacksInput = Readonly<{\n boundedContext: string\n version: string\n projectMetadata: stack.ProjectMetadata\n context: ChiselServiceContext\n writeSide: WriteSideInput\n readSide?: ReadSideInput\n}>\n\nexport type ChiselStacks = Readonly<{\n topics: TopicsStackOutput\n writeSide: Readonly<{\n persistence: WritePersistenceStackOutput\n services: WriteServicesStackOutput\n }>\n readSide?: Readonly<{\n subscribers: QueueSubscribersStackOutput\n persistence: ReadPersistenceStackOutput\n servicesStack: ReadServicesStackOutput\n }>\n}>\n\nexport const createChiselStacks = (app: App, input: StacksInput): ChiselStacks => {\n const context = zodValidate({ constraints: ChiselServiceContextConstraints })(input.context).get()\n\n const topicsStack = createTopicsStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n projectMetadata: input.projectMetadata,\n })\n const writePersistenceStack = createWritePersistenceStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n writeSide: input.writeSide,\n projectMetadata: input.projectMetadata,\n })\n const writeServicesStack = createWriteServicesStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n writeSide: input.writeSide,\n eventsTable: writePersistenceStack.eventsTable,\n topics: topicsStack.topics,\n projectMetadata: input.projectMetadata,\n })\n\n const readSideStacks = Optional(input.readSide).map(readSide => {\n const subscribersStack = createTopicSubscribersStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n readSide: readSide,\n topics: topicsStack.topics,\n projectMetadata: input.projectMetadata,\n })\n\n const persistenceStack = createReadPersistenceStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n readSide: readSide,\n projectMetadata: input.projectMetadata,\n })\n\n const servicesStack = createReadServicesStack(app, context, {\n boundedContext: input.boundedContext,\n version: input.version,\n readSide: readSide,\n dlq: subscribersStack.dlq,\n eventQueues: subscribersStack.eventQueues,\n projectionTable: persistenceStack.projectionTable,\n projectMetadata: input.projectMetadata,\n })\n\n return Object.freeze({\n subscribers: subscribersStack,\n persistence: persistenceStack,\n servicesStack: servicesStack\n })\n })\n\n return Object.freeze({\n topics: topicsStack,\n writeSide: Object.freeze({\n persistence: writePersistenceStack,\n services: writeServicesStack,\n }),\n readSide: readSideStacks.orElse(undefined!)\n })\n}\n"]}
@@ -0,0 +1,50 @@
1
+ import { App, Stack } from 'aws-cdk-lib';
2
+ import { ChiselServiceContext } from './types';
3
+ import { stack } from '@othree.io/cdk';
4
+ export type GSIKeyType = 'string' | 'number' | 'binary';
5
+ export type GSIKey = Readonly<{
6
+ name: string;
7
+ type: GSIKeyType;
8
+ }>;
9
+ export type GSIInput = Readonly<{
10
+ indexName: string;
11
+ primaryKey: GSIKey;
12
+ sortKey: GSIKey;
13
+ }>;
14
+ export type ReadSideInput = Readonly<{
15
+ codePath: string;
16
+ tablePk?: string;
17
+ globalSecondaryIndexes?: Array<GSIInput>;
18
+ deleteOnEvents: Array<string>;
19
+ }>;
20
+ export type ReadSide = Readonly<{
21
+ boundedContext: string;
22
+ version: string;
23
+ readSide: ReadSideInput;
24
+ projectMetadata: stack.ProjectMetadata;
25
+ }>;
26
+ export type QueueSubscribersInput = ReadSide & Readonly<{
27
+ topics: Array<string>;
28
+ }>;
29
+ export type QueueSubscribersStackOutput = Readonly<{
30
+ stack: Stack;
31
+ eventQueues: Array<string>;
32
+ dlq: string;
33
+ }>;
34
+ export declare const createTopicSubscribersStack: (app: App, context: ChiselServiceContext, input: QueueSubscribersInput) => QueueSubscribersStackOutput;
35
+ export type ReadPersistenceInput = ReadSide;
36
+ export type ReadPersistenceStackOutput = Readonly<{
37
+ stack: Stack;
38
+ projectionTable: string;
39
+ }>;
40
+ export declare const createReadPersistenceStack: (app: App, context: ChiselServiceContext, input: ReadPersistenceInput) => ReadPersistenceStackOutput;
41
+ export type ReadServicesInput = ReadSide & Readonly<{
42
+ projectionTable: string;
43
+ eventQueues: Array<string>;
44
+ dlq: string;
45
+ }>;
46
+ export type ReadServicesStackOutput = Readonly<{
47
+ stack: Stack;
48
+ }>;
49
+ export declare const createReadServicesStack: (app: App, context: ChiselServiceContext, input: ReadServicesInput) => ReadServicesStackOutput;
50
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/iac/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAY,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAiC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAQpE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IA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I,KAAK,GAAG,EAAE,SAAS,oBAAoB,EAAE,OAAO,oBAAoB,KAAG,0BAsCjH,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAChD,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,GAAG,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,KAAK,EAAE,KAAK,CAAA;CACf,CAAC,CAAA;AAEF,eAAO,MAAM,uBAAuB,GAAI,KAAK,GAAG,EAAE,SAAS,oBAAoB,EAAE,OAAO,iBAAiB,KAAG,uBA8D3G,CAAA"}
@@ -3,22 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createReadServicesStack = exports.createReadPersistenceStack = exports.createTopicSubscribersStack = void 0;
4
4
  const aws_cdk_lib_1 = require("aws-cdk-lib");
5
5
  const cdk_1 = require("@othree.io/cdk");
6
- const core_1 = require("@othree.io/cdk/lib/core");
7
6
  const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
8
7
  const aws_sns_1 = require("aws-cdk-lib/aws-sns");
9
8
  const aws_dynamodb_1 = require("aws-cdk-lib/aws-dynamodb");
10
- const optional_1 = require("@othree.io/optional");
11
9
  const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
10
+ const optional_1 = require("@othree.io/optional");
12
11
  const aws_lambda_event_sources_1 = require("aws-cdk-lib/aws-lambda-event-sources");
12
+ const defaultLambdaConfiguration = {
13
+ runtime: aws_lambda_1.Runtime.NODEJS_20_X,
14
+ tracing: aws_lambda_1.Tracing.ACTIVE,
15
+ timeout: aws_cdk_lib_1.Duration.seconds(30),
16
+ memorySize: 256,
17
+ architecture: aws_lambda_1.Architecture.ARM_64,
18
+ };
13
19
  const createTopicSubscribersStack = (app, context, input) => {
14
- const withId = cdk_1.core.id(input.version)({
15
- prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
16
- suffix: context.project.env,
20
+ const withId = cdk_1.core.id({
21
+ version: input.version,
22
+ input: {
23
+ prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
24
+ suffix: context.project.env,
25
+ },
17
26
  });
18
- const topicSubscribersStack = cdk_1.stack.withStack(cdk_1.stack.withDefaultConfiguration(cdk_1.stack.loadProjectMetadata(app), 'TopicSubscribersStack'))(app)({
27
+ const defaultConfiguration = cdk_1.stack.withDefaultConfiguration(input.projectMetadata, 'TopicSubscribersStack');
28
+ const topicSubscribersStack = cdk_1.stack.withStack({ defaultConfiguration, app })({
19
29
  id: withId(`${input.boundedContext}-TopicSubscribers`),
20
30
  });
21
- const newQueue = cdk_1.sqs.withQueue(cdk_1.sqs.withDefaultConfiguration((0, core_1.appContext)(app)))(topicSubscribersStack);
31
+ const account = cdk_1.core.getStackAccountFromEnv();
32
+ const newQueue = cdk_1.sqs.withQueue({
33
+ defaultConfiguration: { visibilityTimeout: aws_cdk_lib_1.Duration.seconds(30) },
34
+ stack: topicSubscribersStack,
35
+ });
22
36
  const redriveDLQ = newQueue({
23
37
  id: `${withId(`${input.boundedContext}-Projection-RedriveDLQ`)}.fifo`,
24
38
  });
@@ -26,7 +40,7 @@ const createTopicSubscribersStack = (app, context, input) => {
26
40
  const dlq = newQueue({
27
41
  id: dlqName
28
42
  });
29
- const dlqArn = cdk_1.sqs.queueArnFromName(cdk_1.core.getStackAccountFromEnv())(dlqName);
43
+ const dlqArn = cdk_1.sqs.queueArnFromName({ account })(dlqName);
30
44
  const eventQueues = input.topics.map((topic, idx) => {
31
45
  const queueName = `${withId(`${input.boundedContext}-Projection-EventsQueue-${idx + 1}`)}.fifo`;
32
46
  const queue = newQueue({
@@ -41,14 +55,16 @@ const createTopicSubscribersStack = (app, context, input) => {
41
55
  maxReceiveCount: 4,
42
56
  },
43
57
  });
44
- cdk_1.sns.withSqsSubscription()(cdk_1.sns.withChiselFilterPolicy({
45
- bcs: [input.boundedContext],
46
- }))({
58
+ cdk_1.sns.withSqsSubscription({
59
+ filterPolicy: cdk_1.sns.withChiselFilterPolicy({
60
+ bcs: [input.boundedContext],
61
+ }),
62
+ })({
47
63
  queue: queue,
48
64
  dlq: redriveDLQ,
49
65
  topic: aws_sns_1.Topic.fromTopicArn(topicSubscribersStack, `Subscriber-Topic${idx}`, topic),
50
66
  });
51
- const queueArn = cdk_1.sqs.queueArnFromName(cdk_1.core.getStackAccountFromEnv())(queueName);
67
+ const queueArn = cdk_1.sqs.queueArnFromName({ account })(queueName);
52
68
  return queueArn;
53
69
  });
54
70
  return {
@@ -67,27 +83,33 @@ const mapGSIKeyTypeToAttributeType = (type) => {
67
83
  return typeMap[type];
68
84
  };
69
85
  const createReadPersistenceStack = (app, context, input) => {
70
- var _a;
71
- const withId = cdk_1.core.id(input.version)({
72
- prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
73
- suffix: context.project.env,
86
+ const withId = cdk_1.core.id({
87
+ version: input.version,
88
+ input: {
89
+ prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
90
+ suffix: context.project.env,
91
+ },
74
92
  });
75
- const readPersistenceStack = cdk_1.stack.withStack(cdk_1.stack.withDefaultConfiguration(cdk_1.stack.loadProjectMetadata(app), 'ProjectionPersistenceStack'))(app)({
93
+ const defaultConfiguration = cdk_1.stack.withDefaultConfiguration(input.projectMetadata, 'ProjectionPersistenceStack');
94
+ const readPersistenceStack = cdk_1.stack.withStack({ defaultConfiguration, app })({
76
95
  id: withId(`${input.boundedContext}-ProjectionPersistence`),
77
96
  });
78
97
  const tableName = withId(`${input.boundedContext}-Projection`);
79
- const projectionTable = cdk_1.dynamo.withTable(cdk_1.dynamo.withDefaultConfiguration((0, core_1.appContext)(app)))(readPersistenceStack)({
98
+ const projectionTable = cdk_1.dynamo.withTable({
99
+ defaultConfiguration: { billingMode: aws_dynamodb_1.BillingMode.PAY_PER_REQUEST },
100
+ stack: readPersistenceStack,
101
+ })({
80
102
  id: tableName,
81
103
  partitionKey: { type: aws_dynamodb_1.AttributeType.STRING, name: (0, optional_1.Optional)(input.readSide.tablePk).orElse('id') }
82
104
  });
83
- (_a = input.readSide.globalSecondaryIndexes) === null || _a === void 0 ? void 0 : _a.forEach(gsi => {
105
+ (0, optional_1.Optional)(input.readSide.globalSecondaryIndexes).map(_ => _.forEach(gsi => {
84
106
  projectionTable.addGlobalSecondaryIndex({
85
107
  indexName: gsi.indexName,
86
108
  partitionKey: { type: mapGSIKeyTypeToAttributeType(gsi.primaryKey.type), name: gsi.primaryKey.name },
87
109
  sortKey: { type: mapGSIKeyTypeToAttributeType(gsi.sortKey.type), name: gsi.sortKey.name },
88
110
  });
89
- });
90
- const account = (0, core_1.getStackAccountFromEnv)();
111
+ }));
112
+ const account = cdk_1.core.getStackAccountFromEnv();
91
113
  return Object.freeze({
92
114
  stack: readPersistenceStack,
93
115
  projectionTable: `arn:aws:dynamodb:${account.region}:${account.accountId}:table/${tableName}`,
@@ -95,16 +117,18 @@ const createReadPersistenceStack = (app, context, input) => {
95
117
  };
96
118
  exports.createReadPersistenceStack = createReadPersistenceStack;
97
119
  const createReadServicesStack = (app, context, input) => {
98
- const withId = cdk_1.core.id(input.version)({
99
- prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
100
- suffix: context.project.env,
120
+ const withId = cdk_1.core.id({
121
+ version: input.version,
122
+ input: {
123
+ prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
124
+ suffix: context.project.env,
125
+ },
101
126
  });
102
- const readServicesStack = cdk_1.stack.withStack(cdk_1.stack.withDefaultConfiguration(cdk_1.stack.loadProjectMetadata(app), 'ReadServicesStack'))(app)({
127
+ const defaultConfiguration = cdk_1.stack.withDefaultConfiguration(input.projectMetadata, 'ReadServicesStack');
128
+ const readServicesStack = cdk_1.stack.withStack({ defaultConfiguration, app })({
103
129
  id: withId(`${input.boundedContext}-ReadServices`),
104
130
  });
105
- const withScalingConfiguration = cdk_1.lambda.withScalingConfiguration(app);
106
- const withLambdaConfiguration = cdk_1.lambda.withLambdaConfiguration(app)(cdk_1.lambda.withDefaultConfiguration);
107
- const createLambda = cdk_1.lambda.withLambda(readServicesStack)(withScalingConfiguration)(withLambdaConfiguration);
131
+ const createLambda = cdk_1.lambda.withLambda({ stack: readServicesStack, aliasName: 'live' });
108
132
  const projectionTable = aws_dynamodb_1.Table.fromTableArn(readServicesStack, 'ProjectionTable', input.projectionTable);
109
133
  const dlq = aws_sqs_1.Queue.fromQueueArn(readServicesStack, 'ProjectionDLQ', input.dlq);
110
134
  const environment = {
@@ -115,8 +139,9 @@ const createReadServicesStack = (app, context, input) => {
115
139
  };
116
140
  const updateProjectionHandler = createLambda({
117
141
  functionName: withId(`${input.boundedContext}-Projection-SQS-UpdateProjection`),
118
- code: aws_lambda_1.Code.fromAsset('../codebase/read/dist'),
119
- environment: Object.assign({}, environment),
142
+ codePath: '../codebase/read/dist',
143
+ lambdaConfiguration: defaultLambdaConfiguration,
144
+ environment,
120
145
  handler: 'entrypoint.sqs.updateProjection',
121
146
  });
122
147
  projectionTable.grantReadWriteData(updateProjectionHandler);
@@ -135,8 +160,9 @@ const createReadServicesStack = (app, context, input) => {
135
160
  dlq.grantSendMessages(updateProjectionHandler);
136
161
  const getById = createLambda({
137
162
  functionName: withId(`${input.boundedContext}-Projection-Service-GetById`),
138
- code: aws_lambda_1.Code.fromAsset('../codebase/read/dist'),
139
- environment: Object.assign({}, environment),
163
+ codePath: '../codebase/read/dist',
164
+ lambdaConfiguration: defaultLambdaConfiguration,
165
+ environment,
140
166
  handler: 'entrypoint.services.getById',
141
167
  });
142
168
  projectionTable.grantReadWriteData(getById);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/iac/read.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,wCAAoE;AACpE,iDAA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AA,gBAAK,GAAU,CAAC,CAAC,CAAC,CAAC,CAAC;iBACrC,MAAM,CAAC,CAAC,CAAC;YACd,uBAAuB,EAAE,IAAI;SAChC,CAAC,CAAC,CAAA;IACP,CAAC,CAAC,CAAA;IACF,GAAG,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CAAA;IAE9C,MAAM,OAAO,GAAG,YAAY,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,cAAc,6BAA6B,CAAC;QAC1E,QAAQ,EAAE,uBAAuB;QACjC,mBAAmB,EAAE,0BAA0B;QAC/C,WAAW;QACX,OAAO,EAAE,6BAA6B;KACzC,CAAC,CAAA;IACF,eAAe,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAE3C,OAAO;QACH,KAAK,EAAE,iBAAiB;KAC3B,CAAA;AACL,CAAC,CAAA;AA9DY,QAAA,uBAAuB,2BA8DnC","sourcesContent":["import {App, Duration, Stack} from 'aws-cdk-lib'\nimport {ChiselServiceContext} from './types'\nimport {core, dynamo, lambda, sns, sqs, stack} from '@othree.io/cdk'\nimport {DeduplicationScope, Queue} from 'aws-cdk-lib/aws-sqs'\nimport {Topic} from 'aws-cdk-lib/aws-sns'\nimport {AttributeType, BillingMode, Table} from 'aws-cdk-lib/aws-dynamodb'\nimport {Architecture, Runtime, Tracing} from 'aws-cdk-lib/aws-lambda'\nimport {Empty, Optional} from '@othree.io/optional'\nimport {SqsEventSource} from 'aws-cdk-lib/aws-lambda-event-sources'\n\nexport type GSIKeyType = 'string' | 'number' | 'binary'\n\nexport type GSIKey = Readonly<{\n name: string\n type: GSIKeyType\n}>\n\nexport type GSIInput = Readonly<{\n indexName: string\n primaryKey: GSIKey\n sortKey: GSIKey\n}>\n\nexport type ReadSideInput = Readonly<{\n codePath: string\n tablePk?: string\n globalSecondaryIndexes?: Array<GSIInput>\n deleteOnEvents: Array<string>\n}>\n\nexport type ReadSide = Readonly<{\n boundedContext: string\n version: string\n readSide: ReadSideInput\n projectMetadata: stack.ProjectMetadata\n}>\n\nexport type QueueSubscribersInput = ReadSide & Readonly<{\n topics: Array<string>\n}>\n\nexport type QueueSubscribersStackOutput = Readonly<{\n stack: Stack\n eventQueues: Array<string>\n dlq: string\n}>\n\nconst defaultLambdaConfiguration: lambda.LambdaConfiguration = {\n runtime: Runtime.NODEJS_20_X,\n tracing: Tracing.ACTIVE,\n timeout: Duration.seconds(30),\n memorySize: 256,\n architecture: Architecture.ARM_64,\n}\n\nexport const createTopicSubscribersStack = (app: App, context: ChiselServiceContext, input: QueueSubscribersInput): QueueSubscribersStackOutput => {\n const withId = core.id({\n version: input.version,\n input: {\n prefix: Optional(context.project.naming).map(_ => _.prefix).orElse(undefined!),\n suffix: context.project.env,\n },\n })\n\n const defaultConfiguration = stack.withDefaultConfiguration(input.projectMetadata, 'TopicSubscribersStack')\n\n const topicSubscribersStack = stack.withStack({ defaultConfiguration, app })({\n id: withId(`${input.boundedContext}-TopicSubscribers`),\n })\n\n const account = core.getStackAccountFromEnv()\n\n const newQueue = sqs.withQueue({\n defaultConfiguration: { visibilityTimeout: Duration.seconds(30) },\n stack: topicSubscribersStack,\n })\n\n const redriveDLQ = newQueue({\n id: `${withId(`${input.boundedContext}-Projection-RedriveDLQ`)}.fifo`,\n })\n\n const dlqName = withId(`${input.boundedContext}-Projection-EventsDLQ`)\n const dlq = newQueue({\n id: dlqName\n })\n const dlqArn = sqs.queueArnFromName({ account })(dlqName)\n\n const eventQueues = input.topics.map((topic, idx) => {\n const queueName = `${withId(`${input.boundedContext}-Projection-EventsQueue-${idx + 1}`)}.fifo`\n const queue = newQueue({\n id: queueName,\n }, {\n fifo: true,\n contentBasedDeduplication: true,\n visibilityTimeout: Duration.seconds(30),\n deduplicationScope: DeduplicationScope.MESSAGE_GROUP,\n deadLetterQueue: {\n queue: redriveDLQ,\n maxReceiveCount: 4,\n },\n })\n\n sns.withSqsSubscription({\n filterPolicy: sns.withChiselFilterPolicy({\n bcs: [input.boundedContext],\n }),\n })({\n queue: queue,\n dlq: redriveDLQ,\n topic: Topic.fromTopicArn(topicSubscribersStack, `Subscriber-Topic${idx}`, topic),\n })\n\n const queueArn = sqs.queueArnFromName({ account })(queueName)\n\n return queueArn\n })\n\n return {\n stack: topicSubscribersStack,\n eventQueues: eventQueues,\n dlq: dlqArn\n }\n}\n\nexport type ReadPersistenceInput = ReadSide\n\nexport type ReadPersistenceStackOutput = Readonly<{\n stack: Stack\n projectionTable: string\n}>\n\nconst mapGSIKeyTypeToAttributeType = (type: GSIKeyType): AttributeType => {\n const typeMap: Record<GSIKeyType, AttributeType> = {\n 'string': AttributeType.STRING,\n 'number': AttributeType.NUMBER,\n 'binary': AttributeType.BINARY\n }\n return typeMap[type]\n}\n\nexport const createReadPersistenceStack = (app: App, context: ChiselServiceContext, input: ReadPersistenceInput): ReadPersistenceStackOutput => {\n const withId = core.id({\n version: input.version,\n input: {\n prefix: Optional(context.project.naming).map(_ => _.prefix).orElse(undefined!),\n suffix: context.project.env,\n },\n })\n\n const defaultConfiguration = stack.withDefaultConfiguration(input.projectMetadata, 'ProjectionPersistenceStack')\n\n const readPersistenceStack = stack.withStack({ defaultConfiguration, app })({\n id: withId(`${input.boundedContext}-ProjectionPersistence`),\n })\n\n const tableName = withId(`${input.boundedContext}-Projection`)\n const projectionTable = dynamo.withTable({\n defaultConfiguration: { billingMode: BillingMode.PAY_PER_REQUEST },\n stack: readPersistenceStack,\n })({\n id: tableName,\n partitionKey: {type: AttributeType.STRING, name: Optional(input.readSide.tablePk).orElse('id')}\n })\n\n Optional(input.readSide.globalSecondaryIndexes).map(_ => _.forEach(gsi => {\n (projectionTable as Table).addGlobalSecondaryIndex({\n indexName: gsi.indexName,\n partitionKey: {type: mapGSIKeyTypeToAttributeType(gsi.primaryKey.type), name: gsi.primaryKey.name},\n sortKey: {type: mapGSIKeyTypeToAttributeType(gsi.sortKey.type), name: gsi.sortKey.name},\n })\n }))\n\n const account = core.getStackAccountFromEnv()\n\n return Object.freeze({\n stack: readPersistenceStack,\n projectionTable: `arn:aws:dynamodb:${account.region}:${account.accountId}:table/${tableName}`,\n })\n}\n\nexport type ReadServicesInput = ReadSide & Readonly<{\n projectionTable: string\n eventQueues: Array<string>\n dlq: string\n}>\n\nexport type ReadServicesStackOutput = Readonly<{\n stack: Stack\n}>\n\nexport const createReadServicesStack = (app: App, context: ChiselServiceContext, input: ReadServicesInput): ReadServicesStackOutput => {\n const withId = core.id({\n version: input.version,\n input: {\n prefix: Optional(context.project.naming).map(_ => _.prefix).orElse(undefined!),\n suffix: context.project.env,\n },\n })\n\n const defaultConfiguration = stack.withDefaultConfiguration(input.projectMetadata, 'ReadServicesStack')\n\n const readServicesStack = stack.withStack({ defaultConfiguration, app })({\n id: withId(`${input.boundedContext}-ReadServices`),\n })\n\n const createLambda = lambda.withLambda({ stack: readServicesStack, aliasName: 'live' })\n\n const projectionTable = Table.fromTableArn(readServicesStack, 'ProjectionTable', input.projectionTable)\n const dlq = Queue.fromQueueArn(readServicesStack, 'ProjectionDLQ', input.dlq)\n\n const environment = {\n PROJECTION_TABLE: projectionTable.tableName,\n PROJECTION_DLQ: input.dlq,\n PROJECTION_PK: Optional(input.readSide.tablePk).orElse('id'),\n DELETE_ON_EVENTS: input.readSide.deleteOnEvents.join(',')\n }\n\n const updateProjectionHandler = createLambda({\n functionName: withId(`${input.boundedContext}-Projection-SQS-UpdateProjection`),\n codePath: '../codebase/read/dist',\n lambdaConfiguration: defaultLambdaConfiguration,\n environment,\n handler: 'entrypoint.sqs.updateProjection',\n })\n projectionTable.grantReadWriteData(updateProjectionHandler)\n input.eventQueues.forEach((queueArn, idx) => {\n const queue = Queue.fromQueueArn(readServicesStack, `QueueSource${idx}`, queueArn)\n\n updateProjectionHandler.addEventSource(new SqsEventSource(queue, {\n batchSize: 10,\n maxConcurrency: Optional(context.lambda.functions.find(_ => _.name === updateProjectionHandler.functionName))\n .map(_ => Optional(_.reservedConcurrentExecutions))\n .map(_ => Math.floor(_ / input.eventQueues.length))\n .map(_ => _ < 2 ? Empty<number>() : _)\n .orElse(2),\n reportBatchItemFailures: true,\n }))\n })\n dlq.grantSendMessages(updateProjectionHandler)\n\n const getById = createLambda({\n functionName: withId(`${input.boundedContext}-Projection-Service-GetById`),\n codePath: '../codebase/read/dist',\n lambdaConfiguration: defaultLambdaConfiguration,\n environment,\n handler: 'entrypoint.services.getById',\n })\n projectionTable.grantReadWriteData(getById)\n\n return {\n stack: readServicesStack\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { App, Stack } from 'aws-cdk-lib';
2
+ import { ChiselServiceContext } from './types';
3
+ import { stack } from '@othree.io/cdk';
4
+ export type TopicsStackInput = Readonly<{
5
+ boundedContext: string;
6
+ version: string;
7
+ projectMetadata: stack.ProjectMetadata;
8
+ }>;
9
+ export type TopicsStackOutput = Readonly<{
10
+ stack: Stack;
11
+ topics: Array<string>;
12
+ }>;
13
+ export declare const createTopicsStack: (app: App, context: ChiselServiceContext, input: TopicsStackInput) => TopicsStackOutput;
14
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/iac/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAY,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAG/C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,KAAK,CAAC,eAAe,CAAA;CACzC,CAAC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACxB,CAAC,CAAA;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,GAAG,EAAE,SAAS,oBAAoB,EAAE,OAAO,gBAAgB,KAAG,iBAmCpG,CAAA"}
@@ -2,26 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTopicsStack = void 0;
4
4
  const cdk_1 = require("@othree.io/cdk");
5
- const core_1 = require("@othree.io/cdk/lib/core");
6
5
  const optional_1 = require("@othree.io/optional");
7
6
  const createTopicsStack = (app, context, input) => {
8
- const withId = cdk_1.core.id(input.version)({
9
- prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
10
- suffix: context.project.env,
7
+ const withId = cdk_1.core.id({
8
+ version: input.version,
9
+ input: {
10
+ prefix: (0, optional_1.Optional)(context.project.naming).map(_ => _.prefix).orElse(undefined),
11
+ suffix: context.project.env,
12
+ },
11
13
  });
12
- const eventsStack = cdk_1.stack.withStack(cdk_1.stack.withDefaultConfiguration(cdk_1.stack.loadProjectMetadata(app), 'EventBusStack'))(app)({
14
+ const defaultConfiguration = cdk_1.stack.withDefaultConfiguration(input.projectMetadata, 'EventBusStack');
15
+ const eventsStack = cdk_1.stack.withStack({ defaultConfiguration, app })({
13
16
  id: withId(`${input.boundedContext}-EventBus`),
14
17
  });
15
- const range = [...Array(context.chisel.numberOfShards).keys()];
18
+ const account = cdk_1.core.getStackAccountFromEnv();
19
+ const range = Array.from(Array(context.chisel.numberOfShards).keys());
16
20
  const topics = range.map(idx => {
17
21
  const topicName = `${withId(`${input.boundedContext}-Topic-${idx + 1}`)}.fifo`;
18
- cdk_1.sns.withTopic()(eventsStack)({
22
+ cdk_1.sns.withTopic({ stack: eventsStack })({
19
23
  id: topicName,
20
24
  }, {
21
25
  fifo: true,
22
26
  contentBasedDeduplication: true,
23
27
  });
24
- return cdk_1.sns.topicArnFromName((0, core_1.getStackAccountFromEnv)())(topicName);
28
+ return cdk_1.sns.topicArnFromName({ account })(topicName);
25
29
  });
26
30
  return Object.freeze({
27
31
  stack: eventsSt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EAAE,WAAW,EAAE,CAAC,CAAC;YAClC,EAAE,EAAE,SAAS;SAChB,EAAE;YACC,IAAI,EAAE,IAAI;YACV,yBAAyB,EAAE,IAAI;SAClC,CAAC,CAAA;QAEF,OAAO,SAAG,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,MAAM;KACjB,CAAC,CAAA;AACN,CAAC,CAAA;AAnCY,QAAA,iBAAiB,qBAmC7B","sourcesContent":["import {App, Stack} from 'aws-cdk-lib'\nimport {ChiselServiceContext} from './types'\nimport {core, sns, stack} from '@othree.io/cdk'\nimport {Optional} from '@othree.io/optional'\n\nexport type TopicsStackInput = Readonly<{\n boundedContext: string\n version: string\n projectMetadata: stack.ProjectMetadata\n}>\n\nexport type TopicsStackOutput = Readonly<{\n stack: Stack\n topics: Array<string>\n}>\n\nexport const createTopicsStack = (app: App, context: ChiselServiceContext, input: TopicsStackInput): TopicsStackOutput => {\n const withId = core.id({\n version: input.version,\n input: {\n prefix: Optional(context.project.naming).map(_ => _.prefix).orElse(undefined!),\n suffix: context.project.env,\n },\n })\n\n const defaultConfiguration = stack.withDefaultConfiguration(input.projectMetadata, 'EventBusStack')\n\n const eventsStack = stack.withStack({ defaultConfiguration, app })({\n id: withId(`${input.boundedContext}-EventBus`),\n })\n\n const account = core.getStackAccountFromEnv()\n const range = Array.from(Array(context.chisel.numberOfShards).keys())\n\n const topics = range.map(idx => {\n const topicName = `${withId(`${input.boundedContext}-Topic-${idx + 1}`)}.fifo`\n\n sns.withTopic({ stack: eventsStack })({\n id: topicName,\n }, {\n fifo: true,\n contentBasedDeduplication: true,\n })\n\n return sns.topicArnFromName({ account })(topicName)\n })\n\n return Object.freeze({\n stack: eventsStack,\n topics: topics,\n })\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { ZodType } from 'zod';
2
+ export type NamingContext = Readonly<{
3
+ prefix?: string;
4
+ }>;
5
+ export type ProjectContext = Readonly<{
6
+ naming?: NamingContext;
7
+ env: string;
8
+ }>;
9
+ export declare const ProjectContextConstraints: ZodType<ProjectContext>;
10
+ export type LambdaFunctionContext = Readonly<{
11
+ name: string;
12
+ reservedConcurrentExecutions?: number;
13
+ }>;
14
+ export type LambdaContext = Readonly<{
15
+ functions: Array<LambdaFunctionContext>;
16
+ }>;
17
+ export declare const LambdaContextConstraints: ZodType<LambdaContext>;
18
+ export type ChiselContext = Readonly<{
19
+ numberOfShards: number;
20
+ }>;
21
+ export declare const ChiselConstraints: ZodType<ChiselContext>;
22
+ export type ChiselServiceContext = Readonly<{
23
+ project: ProjectContext;
24
+ lambda: LambdaContext;
25
+ chisel: ChiselContext;
26
+ }>;
27
+ export declare const ChiselServiceContextConstraints: ZodType<ChiselServiceContext>;
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/iac/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAI,OAAO,EAAC,MAAM,KAAK,CAAA;AAG9B,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAClC,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAAC,cAAc,CAK5D,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,4BAA4B,CAAC,EAAE,MAAM,CAAA;CACxC,CAAC,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAA;CAC1C,CAAC,CAAA;AAEF,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,aAAa,CAK1D,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,cAAc,EAAE,MAAM,CAAA;CACzB,CAAC,CAAA;AAEF,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,aAAa,CAEnD,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IACxC,OAAO,EAAE,cAAc,CAAA;IACvB,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,aAAa,CAAA;CACxB,CAAC,CAAA;AAEF,eAAO,MAAM,+BAA+B,EAAE,OAAO,CAAC,oBAAoB,CAIxE,CAAA"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChiselServiceContextConstraints = exports.ChiselConstraints = exports.LambdaContextConstraints = exports.ProjectContextConstraints = void 0;
4
+ const zod_1 = require("zod");
5
+ const auditor_1 = require("@othree.io/auditor");
6
+ exports.ProjectContextConstraints = zod_1.z.object({
7
+ naming: zod_1.z.object({
8
+ prefix: zod_1.z.string().optional(),
9
+ }).optional(),
10
+ env: auditor_1.NonEmptyString,
11
+ });
12
+ exports.LambdaContextConstraints = zod_1.z.object({
13
+ functions: zod_1.z.array(zod_1.z.object({
14
+ name: auditor_1.NonEmptyString,
15
+ reservedConcurrentExecutions: zod_1.z.number().int().min(1).optional(),
16
+ })),
17
+ });
18
+ exports.ChiselConstraints = zod_1.z.object({
19
+ numberOfShards: zod_1.z.number().int().min(1),
20
+ });
21
+ exports.ChiselServiceContextConstraints = zod_1.z.object({
22
+ project: exports.ProjectContextConstraints,
23
+ lambda: exports.LambdaContextConstraints,
24
+ chisel: exports.ChiselConstraints,
25
+ });
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/iac/types.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,gDAAiD;AAWpC,QAAA,yBAAyB,GAA4B,OAAC,CAAC,MAAM,CAAC;IACvE,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;QACb,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC,CAAC,QAAQ,EAAE;IACb,GAAG,EAAE,wBAAc;CACtB,CAAC,CAAA;AAWW,QAAA,wBAAwB,GAA2B,OAAC,CAAC,MAAM,CAAC;IACrE,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,wBAAc;QACpB,4BAA4B,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KACnE,CAAC,CAAC;CACN,CAAC,CAAA;AAMW,QAAA,iBAAiB,GAA2B,OAAC,CAAC,MAAM,CAAC;IAC9D,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1C,CAAC,CAAA;AAQW,QAAA,+BAA+B,GAAkC,OAAC,CAAC,MAAM,CAAC;IACnF,OAAO,EAAE,iCAAyB;IAClC,MAAM,EAAE,gCAAwB;IAChC,MAAM,EAAE,yBAAiB;CAC5B,CAAC,CAAA","sourcesContent":["import {z, ZodType} from 'zod'\nimport {NonEmptyString} from '@othree.io/auditor'\n\nexport type NamingContext = Readonly<{\n prefix?: string\n}>\n\nexport type ProjectContext = Readonly<{\n naming?: NamingContext\n env: string\n}>\n\nexport const ProjectContextConstraints: ZodType<ProjectContext> = z.object({\n naming: z.object({\n prefix: z.string().optional(),\n }).optional(),\n env: NonEmptyString,\n})\n\nexport type LambdaFunctionContext = Readonly<{\n name: string\n reservedConcurrentExecutions?: number\n}>\n\nexport type LambdaContext = Readonly<{\n functions: Array<LambdaFunctionContext>\n}>\n\nexport const LambdaContextConstraints: ZodType<LambdaContext> = z.object({\n functions: z.array(z.object({\n name: NonEmptyString,\n reservedConcurrentExecutions: z.number().int().min(1).optional(),\n })),\n})\n\nexport type ChiselContext = Readonly<{\n numberOfShards: number\n}>\n\nexport const ChiselConstraints: ZodType<ChiselContext> = z.object({\n numberOfShards: z.number().int().min(1),\n})\n\nexport type ChiselServiceContext = Readonly<{\n project: ProjectContext\n lambda: LambdaContext\n chisel: ChiselContext\n}>\n\nexport const ChiselServiceContextConstraints: ZodType<ChiselServiceContext> = z.object({\n project: ProjectContextConstraints,\n lambda: LambdaContextConstraints,\n chisel: ChiselConstraints,\n})\n"]}
@@ -0,0 +1,32 @@
1
+ import { App, Stack } from 'aws-cdk-lib';
2
+ import { stack } from '@othree.io/cdk';
3
+ import { ChiselServiceContext } from './types';
4
+ export type WriteSideInput = Readonly<{
5
+ codePath: string;
6
+ }>;
7
+ export type WritePersistenceStackInput = Readonly<{
8
+ boundedContext: string;
9
+ version: string;
10
+ writeSide: WriteSideInput;
11
+ projectMetadata: stack.ProjectMetadata;
12
+ }>;
13
+ export type WritePersistenceStackOutput = Readonly<{
14
+ stack: Stack;
15
+ eventsTable: string;
16
+ }>;
17
+ export declare const createWritePersistenceStack: (app: App, context: ChiselServiceContext, input: WritePersistenceStackInput) => WritePersistenceStackOutput;
18
+ export type WriteServicesInput = Readonly<{
19
+ boundedContext: string;
20
+ version: string;
21
+ writeSide: WriteSideInput;
22
+ topics: Array<string>;
23
+ eventsTable: string;
24
+ projectMetadata: stack.ProjectMetadata;
25
+ }>;
26
+ export type WriteServicesStackOutput = Readonly<{
27
+ stack: Stack;
28
+ handleCommandArn: string;
29
+ getStateArn: string;
30
+ }>;
31
+ export declare const createWriteServicesStack: (app: App, context: ChiselServiceContext, input: WriteServicesInput) => WriteServicesStackOutput;
32
+ //# sourceMappingURL=write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/iac/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