Skip to content

Commit

Permalink
Added all other stripe definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert09 committed Mar 19, 2024
1 parent 85b83fb commit 1f56661
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 1 deletion.
6 changes: 6 additions & 0 deletions posthog/hogql/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class _SerializedFieldBase(TypedDict):
"lazy_table",
"virtual_table",
"field_traverser",
"expression",
]


Expand Down Expand Up @@ -346,6 +347,9 @@ def serialize_fields(field_input, context: HogQLContext) -> List[SerializedField
if field_key == "team_id":
pass
elif isinstance(field, DatabaseField):
if field.hidden:
continue

if isinstance(field, IntegerDatabaseField):
field_output.append({"key": field_key, "type": "integer"})
elif isinstance(field, FloatDatabaseField):
Expand All @@ -362,6 +366,8 @@ def serialize_fields(field_input, context: HogQLContext) -> List[SerializedField
field_output.append({"key": field_key, "type": "json"})
elif isinstance(field, StringArrayDatabaseField):
field_output.append({"key": field_key, "type": "array"})
elif isinstance(field, ExpressionField):
field_output.append({"key": field_key, "type": "expression"})
elif isinstance(field, LazyJoin):
is_view = isinstance(field.resolve_table(context), SavedQuery)
field_output.append(
Expand Down
246 changes: 245 additions & 1 deletion posthog/warehouse/models/external_table_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,249 @@
"next_invoice_sequence": IntegerDatabaseField(name="next_invoice_sequence"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
}
},
"stripe_invoice": {
"id": StringDatabaseField(name="id"),
"tax": IntegerDatabaseField(name="tax"),
"paid": BooleanDatabaseField(name="paid"),
"lines": StringJSONDatabaseField(name="lines"),
"total": IntegerDatabaseField(name="total"),
"charge": StringDatabaseField(name="charge"),
"issuer": StringJSONDatabaseField(name="issuer"),
"number": StringDatabaseField(name="number"),
"object": StringDatabaseField(name="object"),
"status": StringDatabaseField(name="status"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"currency": StringDatabaseField(name="currency"),
"customer_id": StringDatabaseField(name="customer"),
"discount": StringJSONDatabaseField(name="discount"),
"due_date": IntegerDatabaseField(name="due_date"),
"livemode": BooleanDatabaseField(name="livemode"),
"metadata": StringJSONDatabaseField(name="metadata"),
"subtotal": IntegerDatabaseField(name="subtotal"),
"attempted": BooleanDatabaseField(name="attempted"),
"discounts": StringJSONDatabaseField(name="discounts"),
"rendering": StringJSONDatabaseField(name="rendering"),
"amount_due": IntegerDatabaseField(name="amount_due"),
"__period_start": IntegerDatabaseField(name="period_start", hidden=True),
"period_start_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__period_start"])]), name="period_start_at"
),
"__period_end": IntegerDatabaseField(name="period_end", hidden=True),
"period_end_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__period_end"])]), name="period_end_at"
),
"amount_paid": IntegerDatabaseField(name="amount_paid"),
"description": StringDatabaseField(name="description"),
"invoice_pdf": StringDatabaseField(name="invoice_pdf"),
"account_name": StringDatabaseField(name="account_name"),
"auto_advance": BooleanDatabaseField(name="auto_advance"),
"__effective_at": IntegerDatabaseField(name="effective_at", hidden=True),
"effective_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__effective_at"])]), name="effective_at"
),
"subscription_id": StringDatabaseField(name="subscription"),
"attempt_count": IntegerDatabaseField(name="attempt_count"),
"automatic_tax": StringJSONDatabaseField(name="automatic_tax"),
"customer_name": StringDatabaseField(name="customer_name"),
"billing_reason": StringDatabaseField(name="billing_reason"),
"customer_email": StringDatabaseField(name="customer_email"),
"ending_balance": IntegerDatabaseField(name="ending_balance"),
"payment_intent": StringDatabaseField(name="payment_intent"),
"account_country": StringDatabaseField(name="account_country"),
"amount_shipping": IntegerDatabaseField(name="amount_shipping"),
"amount_remaining": IntegerDatabaseField(name="amount_remaining"),
"customer_address": StringJSONDatabaseField(name="customer_address"),
"customer_tax_ids": StringJSONDatabaseField(name="customer_tax_ids"),
"paid_out_of_band": BooleanDatabaseField(name="paid_out_of_band"),
"payment_settings": StringJSONDatabaseField(name="payment_settings"),
"starting_balance": IntegerDatabaseField(name="starting_balance"),
"collection_method": StringDatabaseField(name="collection_method"),
"default_tax_rates": StringJSONDatabaseField(name="default_tax_rates"),
"total_tax_amounts": StringJSONDatabaseField(name="total_tax_amounts"),
"hosted_invoice_url": StringDatabaseField(name="hosted_invoice_url"),
"status_transitions": StringJSONDatabaseField(name="status_transitions"),
"customer_tax_exempt": StringDatabaseField(name="customer_tax_exempt"),
"total_excluding_tax": IntegerDatabaseField(name="total_excluding_tax"),
"subscription_details": StringJSONDatabaseField(name="subscription_details"),
"__webhooks_delivered_at": IntegerDatabaseField(name="webhooks_delivered_at", hidden=True),
"webhooks_delivered_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__webhooks_delivered_at"])]),
name="webhooks_delivered_at",
),
"subtotal_excluding_tax": IntegerDatabaseField(name="subtotal_excluding_tax"),
"total_discount_amounts": StringJSONDatabaseField(name="total_discount_amounts"),
"pre_payment_credit_notes_amount": IntegerDatabaseField(name="pre_payment_credit_notes_amount"),
"post_payment_credit_notes_amount": IntegerDatabaseField(name="post_payment_credit_notes_amount"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
},
"stripe_charge": {
"id": StringDatabaseField(name="id"),
"paid": BooleanDatabaseField(name="paid"),
"amount": IntegerDatabaseField(name="amount"),
"object": StringDatabaseField(name="object"),
"source": StringJSONDatabaseField(name="source"),
"status": StringDatabaseField(name="status"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"invoice_id": StringDatabaseField(name="invoice"),
"outcome": StringJSONDatabaseField(name="outcome"),
"captured": BooleanDatabaseField(name="captured"),
"currency": StringDatabaseField(name="currency"),
"customer_id": StringDatabaseField(name="customer"),
"disputed": BooleanDatabaseField(name="disputed"),
"livemode": BooleanDatabaseField(name="livemode"),
"metadata": StringJSONDatabaseField(name="metadata"),
"refunded": BooleanDatabaseField(name="refunded"),
"description": StringDatabaseField(name="description"),
"receipt_url": StringDatabaseField(name="receipt_url"),
"failure_code": StringDatabaseField(name="failure_code"),
"fraud_details": StringJSONDatabaseField(name="fraud_details"),
"radar_options": StringJSONDatabaseField(name="radar_options"),
"receipt_email": StringDatabaseField(name="receipt_email"),
"payment_intent_id": StringDatabaseField(name="payment_intent"),
"payment_method_id": StringDatabaseField(name="payment_method"),
"amount_captured": IntegerDatabaseField(name="amount_captured"),
"amount_refunded": IntegerDatabaseField(name="amount_refunded"),
"billing_details": StringJSONDatabaseField(name="billing_details"),
"failure_message": StringDatabaseField(name="failure_message"),
"balance_transaction_id": StringDatabaseField(name="balance_transaction"),
"statement_descriptor": StringDatabaseField(name="statement_descriptor"),
"payment_method_details": StringJSONDatabaseField(name="payment_method_details"),
"calculated_statement_descriptor": StringDatabaseField(name="calculated_statement_descriptor"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
},
"stripe_price": {
"id": StringDatabaseField(name="id"),
"type": StringDatabaseField(name="type"),
"active": BooleanDatabaseField(name="active"),
"object": StringDatabaseField(name="object"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"product_id": StringDatabaseField(name="product"),
"currency": StringDatabaseField(name="currency"),
"livemode": BooleanDatabaseField(name="livemode"),
"metadata": StringJSONDatabaseField(name="metadata"),
"nickname": StringDatabaseField(name="nickname"),
"recurring": StringJSONDatabaseField(name="recurring"),
"tiers_mode": StringDatabaseField(name="tiers_mode"),
"unit_amount": IntegerDatabaseField(name="unit_amount"),
"tax_behavior": StringDatabaseField(name="tax_behavior"),
"billing_scheme": StringDatabaseField(name="billing_scheme"),
"unit_amount_decimal": StringDatabaseField(name="unit_amount_decimal"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
},
"stripe_product": {
"id": StringDatabaseField(name="id"),
"name": StringDatabaseField(name="name"),
"type": StringDatabaseField(name="type"),
"active": BooleanDatabaseField(name="active"),
"images": StringJSONDatabaseField(name="images"),
"object": StringDatabaseField(name="object"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"__updated": IntegerDatabaseField(name="updated", hidden=True),
"updated_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__updated"])]), name="updated_at"
),
"features": StringJSONDatabaseField(name="features"),
"livemode": BooleanDatabaseField(name="livemode"),
"metadata": StringJSONDatabaseField(name="metadata"),
"tax_code": StringDatabaseField(name="tax_code"),
"attributes": StringJSONDatabaseField(name="attributes"),
"description": StringDatabaseField(name="description"),
"default_price_id": StringDatabaseField(name="default_price"),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
},
"stripe_subscription": {
"id": StringDatabaseField(name="id"),
"plan": StringJSONDatabaseField(name="plan"),
"items": StringJSONDatabaseField(name="items"),
"object": StringDatabaseField(name="object"),
"status": StringDatabaseField(name="status"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"currency": StringDatabaseField(name="currency"),
"customer_id": StringDatabaseField(name="customer"),
"__ended_at": IntegerDatabaseField(name="ended_at", hidden=True),
"ended_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__ended_at"])]), name="ended_at"
),
"livemode": BooleanDatabaseField(name="livemode"),
"metadata": StringJSONDatabaseField(name="metadata"),
"quantity": IntegerDatabaseField(name="quantity"),
"__start_date": IntegerDatabaseField(name="start_date", hidden=True),
"start_date": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__start_date"])]), name="start_date"
),
"__canceled_at": IntegerDatabaseField(name="canceled_at", hidden=True),
"canceled_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__canceled_at"])]), name="canceled_at"
),
"automatic_tax": StringJSONDatabaseField(name="automatic_tax"),
"latest_invoice_id": StringDatabaseField(name="latest_invoice"),
"trial_settings": StringJSONDatabaseField(name="trial_settings"),
"invoice_settings": StringJSONDatabaseField(name="invoice_settings"),
"payment_settings": StringJSONDatabaseField(name="payment_settings"),
"collection_method": StringDatabaseField(name="collection_method"),
"default_tax_rates": StringJSONDatabaseField(name="default_tax_rates"),
"__current_period_start": IntegerDatabaseField(name="current_period_start", hidden=True),
"current_period_start": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__current_period_start"])]),
name="current_period_start",
),
"__current_period_end": IntegerDatabaseField(name="current_period_end", hidden=True),
"current_period_end": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__current_period_end"])]),
name="current_period_end",
),
"__billing_cycle_anchor": IntegerDatabaseField(name="billing_cycle_anchor", hidden=True),
"billing_cycle_anchor": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__billing_cycle_anchor"])]),
name="billing_cycle_anchor",
),
"cancel_at_period_end": BooleanDatabaseField(name="cancel_at_period_end"),
"cancellation_details": StringJSONDatabaseField(name="cancellation_details"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
},
"stripe_balancetransaction": {
"id": StringDatabaseField(name="id"),
"fee": IntegerDatabaseField(name="fee"),
"net": IntegerDatabaseField(name="net"),
"type": StringDatabaseField(name="type"),
"amount": IntegerDatabaseField(name="amount"),
"object": StringDatabaseField(name="object"),
"source_id": StringDatabaseField(name="source"),
"status": StringDatabaseField(name="status"),
"__created": IntegerDatabaseField(name="created", hidden=True),
"created_at": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__created"])]), name="created_at"
),
"currency": StringDatabaseField(name="currency"),
"description": StringDatabaseField(name="description"),
"fee_details": StringJSONDatabaseField(name="fee_details"),
"__available_on": IntegerDatabaseField(name="available_on", hidden=True),
"available_on": ast.ExpressionField(
expr=ast.Call(name="fromUnixTimestamp", args=[ast.Field(chain=["__available_on"])]), name="available_on"
),
"reporting_category": StringDatabaseField(name="reporting_category"),
"__dlt_id": StringDatabaseField(name="_dlt_id", hidden=True),
"__dlt_load_id": StringDatabaseField(name="_dlt_load_id", hidden=True),
},
}

0 comments on commit 1f56661

Please sign in to comment.