-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUMM-2266 Reorganise rum-models-generator
package for Session Replay code generation
#940
RUMM-2266 Reorganise rum-models-generator
package for Session Replay code generation
#940
Conversation
to prepare it for Session Replay generation track
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-2020 Datadog, Inc. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Type-safe Swift schema. | ||
public protocol SwiftType {} | ||
|
||
/// Swift primitive type. | ||
public protocol SwiftPrimitiveType: SwiftType {} | ||
/// An allowed value of Swift primitive type. | ||
public protocol SwiftPrimitiveValue {} | ||
/// An allowed default value of Swift property. | ||
public protocol SwiftPropertyDefaultValue {} | ||
/// An allowed value of Swift with no obj-c interoperability. | ||
public protocol SwiftPrimitiveNoObjcInteropType: SwiftPrimitiveType {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only changes in this file are internal
→ public
access modifiers for all pieces of Swift schema. This is to make it visible for external module which performs code decoration.
// CLI wrapper | ||
.target( | ||
name: "rum-models-generator", | ||
dependencies: [ | ||
"RUMModelsGeneratorCore", | ||
"CodeGeneration", | ||
"CodeDecoration", | ||
.product(name: "ArgumentParser", package: "swift-argument-parser") | ||
]), | ||
] | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is no longer rum-
models generator, we may want to rename the package. I don't do this, because it has consequences on other files in the repo (all places where we call it from). I didn't want to spend time on it right now, but it's IMO something we might want consider in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's fine keep it for now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 👏 👏
// CLI wrapper | ||
.target( | ||
name: "rum-models-generator", | ||
dependencies: [ | ||
"RUMModelsGeneratorCore", | ||
"CodeGeneration", | ||
"CodeDecoration", | ||
.product(name: "ArgumentParser", package: "swift-argument-parser") | ||
]), | ||
] | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's fine keep it for now 👍
What and why?
📦 This PR reorganises
rum-models-generator
package so it can be later easily extended with Session Replay code generation pipeline. This is to clean up the package code and keep both generation tracks separate.It doesn't yet generate Session Replay models - this requires abstracting some configuration (e.g. the access control in generated code) and will be added in next PR.
How?
The package is now composed of 3 targets:
CodeGeneration
, which provides generation pipeline:CodeDecoration
, providing 2 distinct implementations ofcodeDecorator
:RUMCodeDecorator: CodeDecorator
- applies RUM conventions to generated codeSRCodeDecorator: CodeDecorator
- will apply SR conventions to generated coderum-models-generator
- small CLI wrapper🎁 With this change, the
CodeGeneration
module becomes fully RUM- and SR-agnostic. It can be understood as general-purpose generator of Swift and Objc-interop code from JSON Schema.Conventions required by RUM and SR products are only implemented in
CodeDecoration
module, by conformance toCodeGeneration.CodeDecorator
interface:Review checklist
Custom CI job configuration (optional)