|
|
|
|
@ -18,6 +18,7 @@ class LeStorageGenerator: |
|
|
|
|
model_name = model_data["name"] |
|
|
|
|
is_sync = model_data.get("synchronizable", False) |
|
|
|
|
is_observable = model_data.get("observable", False) |
|
|
|
|
store_parent = model_data.get("storeParent", False) |
|
|
|
|
properties = model_data["properties"] |
|
|
|
|
did_set_properties = [] |
|
|
|
|
|
|
|
|
|
@ -45,7 +46,7 @@ class LeStorageGenerator: |
|
|
|
|
lines.append("") |
|
|
|
|
|
|
|
|
|
# Add SyncedStorable protocol requirements |
|
|
|
|
lines.extend(self._generate_protocol_requirements(resource_name, token_exempted, copy_server_response)) |
|
|
|
|
lines.extend(self._generate_protocol_requirements(resource_name, token_exempted, copy_server_response, store_parent)) |
|
|
|
|
lines.append("") |
|
|
|
|
|
|
|
|
|
# Properties |
|
|
|
|
@ -423,16 +424,19 @@ class LeStorageGenerator: |
|
|
|
|
lines.append(" }") |
|
|
|
|
return lines |
|
|
|
|
|
|
|
|
|
def _generate_protocol_requirements(self, resource_name: str, token_exempted: List[str], copy_server_response: str) -> List[str]: |
|
|
|
|
def _generate_protocol_requirements(self, resource_name: str, token_exempted: List[str], copy_server_response: str, store_parent: bool) -> List[str]: |
|
|
|
|
"""Generate the static functions required by SyncedStorable protocol.""" |
|
|
|
|
# Convert HTTP methods to proper format |
|
|
|
|
formatted_methods = [f".{method.lower()}" for method in token_exempted] |
|
|
|
|
methods_str = ", ".join(formatted_methods) if formatted_methods else "" |
|
|
|
|
|
|
|
|
|
store_parent_swift = "true" if store_parent else "false" |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
f" public static func resourceName() -> String {{ return \"{resource_name}\" }}", |
|
|
|
|
f" public static func tokenExemptedMethods() -> [HTTPMethod] {{ return [{methods_str}] }}", |
|
|
|
|
f" public static var copyServerResponse: Bool = {copy_server_response}", |
|
|
|
|
f" public static func storeParent() -> Bool {{ return {store_parent_swift} }}", |
|
|
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|