diff --git a/source-hubspot-native/acmeCo/companies.schema.yaml b/source-hubspot-native/acmeCo/companies.schema.yaml index f8936cf172..61be5883d8 100644 --- a/source-hubspot-native/acmeCo/companies.schema.yaml +++ b/source-hubspot-native/acmeCo/companies.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/contacts.schema.yaml b/source-hubspot-native/acmeCo/contacts.schema.yaml index e41b714f54..6225e89770 100644 --- a/source-hubspot-native/acmeCo/contacts.schema.yaml +++ b/source-hubspot-native/acmeCo/contacts.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/deals.schema.yaml b/source-hubspot-native/acmeCo/deals.schema.yaml index ec69db8df4..2859b68eb8 100644 --- a/source-hubspot-native/acmeCo/deals.schema.yaml +++ b/source-hubspot-native/acmeCo/deals.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/engagements.schema.yaml b/source-hubspot-native/acmeCo/engagements.schema.yaml index 0d3a844a77..9756e742dc 100644 --- a/source-hubspot-native/acmeCo/engagements.schema.yaml +++ b/source-hubspot-native/acmeCo/engagements.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/line_items.schema.yaml b/source-hubspot-native/acmeCo/line_items.schema.yaml index 4772ed86d4..992dfe837b 100644 --- a/source-hubspot-native/acmeCo/line_items.schema.yaml +++ b/source-hubspot-native/acmeCo/line_items.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/products.schema.yaml b/source-hubspot-native/acmeCo/products.schema.yaml index 9b63e47a68..f2688ba4de 100644 --- a/source-hubspot-native/acmeCo/products.schema.yaml +++ b/source-hubspot-native/acmeCo/products.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/acmeCo/tickets.schema.yaml b/source-hubspot-native/acmeCo/tickets.schema.yaml index 1d3aba6ca1..26b762bb57 100644 --- a/source-hubspot-native/acmeCo/tickets.schema.yaml +++ b/source-hubspot-native/acmeCo/tickets.schema.yaml @@ -3,13 +3,6 @@ $defs: History: additionalProperties: false properties: - _meta: - allOf: - - $ref: "#/$defs/Meta" - default: - op: u - row_id: -1 - description: Document metadata timestamp: format: date-time title: Timestamp @@ -93,13 +86,15 @@ properties: - type: "null" title: Properties propertiesWithHistory: - additionalProperties: - items: - $ref: "#/$defs/History" - type: array - default: {} + anyOf: + - additionalProperties: + items: + $ref: "#/$defs/History" + type: array + type: object + - type: "null" + default: ~ title: Propertieswithhistory - type: object associations: additionalProperties: false default: {} diff --git a/source-hubspot-native/source_hubspot_native/models.py b/source-hubspot-native/source_hubspot_native/models.py index 8ab6bf1dd0..6e4a2f3545 100644 --- a/source-hubspot-native/source_hubspot_native/models.py +++ b/source-hubspot-native/source_hubspot_native/models.py @@ -159,7 +159,7 @@ class History(BaseModel, extra="forbid"): archived: bool properties: dict[str, str | None] - propertiesWithHistory: SkipJsonSchema[dict[str, list[History]]] = {} + propertiesWithHistory: dict[str, list[History]] | None = None class InlineAssociations(BaseModel): class Entry(BaseModel): @@ -180,11 +180,11 @@ class Entry(BaseModel): def _post_init(self) -> Self: # Clear properties and history which don't have current values. self.properties = {k: v for k, v in self.properties.items() if v} - self.propertiesWithHistory = { - k: v for k, v in self.propertiesWithHistory.items() if len(v) - } - if len(self.propertiesWithHistory) == 0: - delattr(self, "propertiesWithHistory") + if self.propertiesWithHistory: + self.propertiesWithHistory = { + k: v for k, v in self.propertiesWithHistory.items() if len(v) + } + # If the model has attached inline associations, # hoist them to corresponding arrays. Then clear associations. diff --git a/source-hubspot-native/tests/snapshots/snapshots__discover__stdout.json b/source-hubspot-native/tests/snapshots/snapshots__discover__stdout.json index ae600999d2..cc49836614 100644 --- a/source-hubspot-native/tests/snapshots/snapshots__discover__stdout.json +++ b/source-hubspot-native/tests/snapshots/snapshots__discover__stdout.json @@ -6,6 +6,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -76,6 +137,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -121,6 +200,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -191,6 +331,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -228,6 +386,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -298,6 +517,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -351,6 +588,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -421,6 +719,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -458,6 +774,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -528,6 +905,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -581,6 +976,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -651,6 +1107,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {}, @@ -680,6 +1154,67 @@ }, "documentSchema": { "$defs": { + "History": { + "additionalProperties": false, + "properties": { + "timestamp": { + "format": "date-time", + "title": "Timestamp", + "type": "string" + }, + "value": { + "title": "Value", + "type": "string" + }, + "sourceType": { + "title": "Sourcetype", + "type": "string" + }, + "sourceId": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourceid" + }, + "sourceLabel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Sourcelabel" + }, + "updatedByUserId": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Updatedbyuserid" + } + }, + "required": [ + "timestamp", + "value", + "sourceType" + ], + "title": "History", + "type": "object" + }, "Meta": { "properties": { "op": { @@ -750,6 +1285,24 @@ }, "title": "Properties" }, + "propertiesWithHistory": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "$ref": "#/$defs/History" + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Propertieswithhistory" + }, "associations": { "additionalProperties": false, "default": {},