3782 lines
116 KiB
JSON
3782 lines
116 KiB
JSON
[
|
|
{
|
|
"description": "Merger Execution",
|
|
"database": {
|
|
"puncs": [],
|
|
"enums": [
|
|
{
|
|
"id": "11111111-1111-1111-1111-111111111111",
|
|
"type": "relation_type",
|
|
"enum": "relation_type",
|
|
"values": [
|
|
"foreign_key",
|
|
"polymorphic",
|
|
"graph"
|
|
]
|
|
}
|
|
],
|
|
"relations": [
|
|
{
|
|
"id": "22222222-2222-2222-2222-222222222222",
|
|
"type": "relation",
|
|
"constraint": "fk_order_customer_person",
|
|
"source_type": "order",
|
|
"source_columns": [
|
|
"customer_id"
|
|
],
|
|
"destination_type": "person",
|
|
"destination_columns": [
|
|
"id"
|
|
],
|
|
"prefix": "customer"
|
|
},
|
|
{
|
|
"id": "33333333-3333-3333-3333-333333333333",
|
|
"type": "relation",
|
|
"constraint": "fk_order_line_order",
|
|
"source_type": "order_line",
|
|
"source_columns": [
|
|
"order_id"
|
|
],
|
|
"destination_type": "order",
|
|
"destination_columns": [
|
|
"id"
|
|
]
|
|
},
|
|
{
|
|
"id": "44444444-4444-4444-4444-444444444444",
|
|
"type": "relation",
|
|
"constraint": "fk_relationship_source_entity",
|
|
"source_type": "relationship",
|
|
"source_columns": [
|
|
"source_id",
|
|
"source_type"
|
|
],
|
|
"destination_type": "entity",
|
|
"destination_columns": [
|
|
"id",
|
|
"type"
|
|
],
|
|
"prefix": "source"
|
|
},
|
|
{
|
|
"id": "55555555-5555-5555-5555-555555555555",
|
|
"type": "relation",
|
|
"constraint": "fk_relationship_target_entity",
|
|
"source_type": "relationship",
|
|
"source_columns": [
|
|
"target_id",
|
|
"target_type"
|
|
],
|
|
"destination_type": "entity",
|
|
"destination_columns": [
|
|
"id",
|
|
"type"
|
|
],
|
|
"prefix": "target"
|
|
},
|
|
{
|
|
"id": "66666666-6666-6666-6666-666666666666",
|
|
"type": "relation",
|
|
"constraint": "fk_entity_organization",
|
|
"source_type": "entity",
|
|
"source_columns": [
|
|
"organization_id"
|
|
],
|
|
"destination_type": "organization",
|
|
"destination_columns": [
|
|
"id"
|
|
],
|
|
"prefix": null
|
|
},
|
|
{
|
|
"id": "66666666-6666-6666-6666-666666666666",
|
|
"type": "relation",
|
|
"constraint": "fk_entity_organization",
|
|
"source_type": "entity",
|
|
"source_columns": [
|
|
"organization_id"
|
|
],
|
|
"destination_type": "organization",
|
|
"destination_columns": [
|
|
"id"
|
|
],
|
|
"prefix": null
|
|
},
|
|
{
|
|
"id": "33333333-3333-3333-3333-333333333334",
|
|
"type": "relation",
|
|
"constraint": "fk_invoice_line_invoice",
|
|
"source_type": "invoice_line",
|
|
"source_columns": [
|
|
"invoice_id"
|
|
],
|
|
"destination_type": "invoice",
|
|
"destination_columns": [
|
|
"id"
|
|
]
|
|
}
|
|
],
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"schemas": {
|
|
"entity": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"archived": {
|
|
"type": "boolean"
|
|
},
|
|
"created_by": {
|
|
"type": "string"
|
|
},
|
|
"modified_by": {
|
|
"type": "string"
|
|
},
|
|
"created_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"modified_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"organization_id": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"type",
|
|
"created_by",
|
|
"created_at",
|
|
"modified_by",
|
|
"modified_at"
|
|
]
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
]
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false,
|
|
"variations": [
|
|
"entity",
|
|
"organization",
|
|
"user",
|
|
"person",
|
|
"order",
|
|
"order_line",
|
|
"relationship",
|
|
"contact",
|
|
"phone_number",
|
|
"email_address",
|
|
"attachment",
|
|
"invoice",
|
|
"invoice_line"
|
|
]
|
|
},
|
|
{
|
|
"name": "organization",
|
|
"schemas": {
|
|
"organization": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"organization",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"organization": [
|
|
"id",
|
|
"type",
|
|
"name"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
]
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "user",
|
|
"schemas": {
|
|
"user": {
|
|
"type": "organization",
|
|
"properties": {}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"user",
|
|
"organization",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"user": [
|
|
"id",
|
|
"type"
|
|
],
|
|
"organization": [
|
|
"id",
|
|
"type",
|
|
"name"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
]
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"person": {
|
|
"type": "user",
|
|
"properties": {
|
|
"first_name": {
|
|
"type": "string"
|
|
},
|
|
"last_name": {
|
|
"type": "string"
|
|
},
|
|
"date_of_birth": {
|
|
"type": "string"
|
|
},
|
|
"pronouns": {
|
|
"type": "string"
|
|
},
|
|
"contact_id": {
|
|
"type": "string"
|
|
},
|
|
"contacts": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"oneOf": [
|
|
{
|
|
"type": "phone_number"
|
|
},
|
|
{
|
|
"type": "email_address"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"email_addresses": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"type": "email_address"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"organization_id": {
|
|
"type": "string",
|
|
"const": "ffffffff-ffff-ffff-ffff-ffffffffffff"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"person",
|
|
"user",
|
|
"organization",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"first_name",
|
|
"last_name",
|
|
"date_of_birth",
|
|
"pronouns",
|
|
"contact_id",
|
|
"name",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
],
|
|
"grouped_fields": {
|
|
"person": [
|
|
"id",
|
|
"type",
|
|
"first_name",
|
|
"last_name",
|
|
"date_of_birth",
|
|
"pronouns",
|
|
"contact_id"
|
|
],
|
|
"user": [
|
|
"id",
|
|
"type"
|
|
],
|
|
"organization": [
|
|
"id",
|
|
"type",
|
|
"name"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
]
|
|
},
|
|
"lookup_fields": [
|
|
"first_name",
|
|
"last_name",
|
|
"date_of_birth",
|
|
"pronouns"
|
|
],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "order",
|
|
"schemas": {
|
|
"order": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"total": {
|
|
"type": "number"
|
|
},
|
|
"customer_id": {
|
|
"type": "string"
|
|
},
|
|
"customer": {
|
|
"type": "person"
|
|
},
|
|
"lines": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "order_line"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"order",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"total",
|
|
"customer_id",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
],
|
|
"grouped_fields": {
|
|
"order": [
|
|
"id",
|
|
"type",
|
|
"total",
|
|
"customer_id"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
]
|
|
},
|
|
"lookup_fields": [
|
|
"id"
|
|
],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "order_line",
|
|
"schemas": {
|
|
"order_line": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"order_id": {
|
|
"type": "string"
|
|
},
|
|
"product": {
|
|
"type": "string"
|
|
},
|
|
"price": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"order_line",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"order_id",
|
|
"product",
|
|
"price",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
],
|
|
"grouped_fields": {
|
|
"order_line": [
|
|
"id",
|
|
"type",
|
|
"order_id",
|
|
"product",
|
|
"price"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived",
|
|
"organization_id"
|
|
]
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "relationship",
|
|
"relationship": true,
|
|
"hierarchy": [
|
|
"relationship",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type",
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"relationship": [
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"source_id": "uuid",
|
|
"source_type": "text",
|
|
"target_id": "uuid",
|
|
"target_type": "text",
|
|
"name": "text",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"schemas": {
|
|
"relationship": {
|
|
"type": "entity",
|
|
"properties": {}
|
|
}
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true
|
|
},
|
|
{
|
|
"name": "contact",
|
|
"relationship": true,
|
|
"hierarchy": [
|
|
"contact",
|
|
"relationship",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"is_primary",
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type",
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"relationship": [
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type"
|
|
],
|
|
"contact": [
|
|
"is_primary"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"source_id": "uuid",
|
|
"source_type": "text",
|
|
"target_id": "uuid",
|
|
"target_type": "text",
|
|
"is_primary": "boolean",
|
|
"name": "text",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"schemas": {
|
|
"contact": {
|
|
"type": "relationship",
|
|
"properties": {
|
|
"is_primary": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true
|
|
},
|
|
{
|
|
"name": "phone_number",
|
|
"hierarchy": [
|
|
"phone_number",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"number",
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"phone_number": [
|
|
"number"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"number": "text",
|
|
"name": "text",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"schemas": {
|
|
"phone_number": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"number": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "email_address",
|
|
"hierarchy": [
|
|
"email_address",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"address",
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"email_address": [
|
|
"address"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"address": "text",
|
|
"name": "text",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"schemas": {
|
|
"email_address": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"address": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "attachment",
|
|
"schemas": {
|
|
"type_metadata": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"other_metadata": {
|
|
"type": "object",
|
|
"properties": {
|
|
"other": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"attachment": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"flags": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"type_metadata": {
|
|
"type": "type_metadata"
|
|
},
|
|
"other_metadata": {
|
|
"type": "other_metadata"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"attachment",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"flags",
|
|
"type_metadata",
|
|
"other_metadata",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"attachment": [
|
|
"id",
|
|
"type",
|
|
"flags",
|
|
"type_metadata",
|
|
"other_metadata"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"flags": "_text",
|
|
"type_metadata": "jsonb",
|
|
"other_metadata": "jsonb",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid",
|
|
"archived": "boolean"
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "account",
|
|
"hierarchy": [
|
|
"account",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"kind",
|
|
"routing_number",
|
|
"card_number"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"name",
|
|
"archived",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by"
|
|
],
|
|
"account": [
|
|
"id",
|
|
"type",
|
|
"kind",
|
|
"routing_number",
|
|
"card_number"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"name": "text",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid",
|
|
"kind": "text",
|
|
"routing_number": "text",
|
|
"card_number": "text"
|
|
},
|
|
"schemas": {
|
|
"account": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"cases": [
|
|
{
|
|
"when": {
|
|
"properties": {
|
|
"kind": {
|
|
"const": "checking"
|
|
}
|
|
}
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"routing_number": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"when": {
|
|
"properties": {
|
|
"kind": {
|
|
"const": "credit"
|
|
}
|
|
}
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"card_number": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"notify": true,
|
|
"relationship": false
|
|
},
|
|
{
|
|
"name": "invoice",
|
|
"schemas": {
|
|
"invoice": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"total": {
|
|
"type": "number"
|
|
},
|
|
"lines": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "invoice_line"
|
|
}
|
|
},
|
|
"metadata_line": {
|
|
"type": "invoice_line"
|
|
},
|
|
"metadata_lines": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "invoice_line"
|
|
}
|
|
},
|
|
"metadata_nested_line": {
|
|
"type": "object",
|
|
"properties": {
|
|
"line": {
|
|
"type": "invoice_line"
|
|
}
|
|
}
|
|
},
|
|
"metadata_nested_lines": {
|
|
"type": "object",
|
|
"properties": {
|
|
"lines": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "invoice_line"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"invoice",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"total",
|
|
"metadata_line",
|
|
"metadata_lines",
|
|
"metadata_nested_line",
|
|
"metadata_nested_lines",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"invoice": [
|
|
"id",
|
|
"type",
|
|
"total",
|
|
"metadata_line",
|
|
"metadata_lines",
|
|
"metadata_nested_line",
|
|
"metadata_nested_lines"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
]
|
|
},
|
|
"lookup_fields": [
|
|
"id"
|
|
],
|
|
"historical": true,
|
|
"relationship": false,
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"total": "numeric",
|
|
"metadata_line": "jsonb",
|
|
"metadata_lines": "jsonb",
|
|
"metadata_nested_line": "jsonb",
|
|
"metadata_nested_lines": "jsonb",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"variations": [
|
|
"invoice"
|
|
]
|
|
},
|
|
{
|
|
"name": "invoice_line",
|
|
"schemas": {
|
|
"invoice_line": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"invoice_id": {
|
|
"type": "string"
|
|
},
|
|
"price": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hierarchy": [
|
|
"invoice_line",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"invoice_id",
|
|
"price",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"invoice_line": [
|
|
"id",
|
|
"type",
|
|
"invoice_id",
|
|
"price"
|
|
],
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"created_at",
|
|
"created_by",
|
|
"modified_at",
|
|
"modified_by",
|
|
"archived"
|
|
]
|
|
},
|
|
"lookup_fields": [],
|
|
"historical": true,
|
|
"relationship": false,
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"invoice_id": "uuid",
|
|
"price": "numeric",
|
|
"created_at": "timestamptz",
|
|
"created_by": "uuid",
|
|
"modified_at": "timestamptz",
|
|
"modified_by": "uuid"
|
|
},
|
|
"variations": [
|
|
"invoice_line"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Insert person without id (no lookup)",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "person",
|
|
"first_name": "IncompleteFirst",
|
|
"last_name": "IncompleteLast"
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "33333333-3333-3333-3333-333333333333",
|
|
"type": "person",
|
|
"first_name": "IncompleteFirst",
|
|
"last_name": "IncompleteLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "old-contact"
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"organization\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"user\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"person\" (",
|
|
" \"first_name\",",
|
|
" \"id\",",
|
|
" \"last_name\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'IncompleteFirst',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'IncompleteLast',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"first_name\": \"IncompleteFirst\",",
|
|
" \"last_name\": \"IncompleteLast\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"first_name\": \"IncompleteFirst\",",
|
|
" \"last_name\": \"IncompleteLast\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"IncompleteFirst\",",
|
|
" \"last_name\": \"IncompleteLast\",",
|
|
" \"type\": \"person\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Update existing person without id (lookup)",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "abc-contact"
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "22222222-2222-2222-2222-222222222222",
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "old-contact"
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" (\"first_name\" = 'LookupFirst'",
|
|
" AND \"last_name\" = 'LookupLast'",
|
|
" AND \"date_of_birth\" = '{{timestamp}}'",
|
|
" AND \"pronouns\" = 'they/them'))"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"person\" SET",
|
|
" contact_id = 'abc-contact'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"entity\" SET",
|
|
" modified_at = '{{timestamp}}',",
|
|
" modified_by = '00000000-0000-0000-0000-000000000000'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{",
|
|
" \"contact_id\": \"old-contact\"",
|
|
" }',",
|
|
" '{",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '{{uuid:mocks.0.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'update',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"id\": \"{{uuid:mocks.0.id}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"first_name\": \"LookupFirst\",",
|
|
" \"last_name\": \"LookupLast\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"they/them\",",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"type\": \"person\"",
|
|
" },",
|
|
" \"old\": {",
|
|
" \"contact_id\": \"old-contact\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Update existing person with id (lookup)",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "33333333-3333-3333-3333-333333333333",
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "abc-contact"
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "22222222-2222-2222-2222-222222222222",
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "old-contact"
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:data.id}}'",
|
|
" OR (\"first_name\" = 'LookupFirst'",
|
|
" AND \"last_name\" = 'LookupLast'",
|
|
" AND \"date_of_birth\" = '{{timestamp}}'",
|
|
" AND \"pronouns\" = 'they/them'))"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"person\" SET",
|
|
" contact_id = 'abc-contact'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"entity\" SET",
|
|
" modified_at = '{{timestamp}}',",
|
|
" modified_by = '00000000-0000-0000-0000-000000000000'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{",
|
|
" \"contact_id\": \"old-contact\"",
|
|
" }',",
|
|
" '{",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '{{uuid:mocks.0.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'update',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"id\": \"{{uuid:mocks.0.id}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"first_name\": \"LookupFirst\",",
|
|
" \"last_name\": \"LookupLast\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"they/them\",",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"contact_id\": \"abc-contact\",",
|
|
" \"type\": \"person\"",
|
|
" },",
|
|
" \"old\": {",
|
|
" \"contact_id\": \"old-contact\"",
|
|
" },",
|
|
" \"replaces\": \"{{uuid:data.id}}\"",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Replace existing person with id and no changes (lookup)",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "33333333-3333-3333-3333-333333333333",
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them"
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "22222222-2222-2222-2222-222222222222",
|
|
"type": "person",
|
|
"first_name": "LookupFirst",
|
|
"last_name": "LookupLast",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": "they/them",
|
|
"contact_id": "old-contact"
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:data.id}}'",
|
|
" OR (\"first_name\" = 'LookupFirst'",
|
|
" AND \"last_name\" = 'LookupLast'",
|
|
" AND \"date_of_birth\" = '{{timestamp}}'",
|
|
" AND \"pronouns\" = 'they/them'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"id\": \"{{uuid:mocks.0.id}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"first_name\": \"LookupFirst\",",
|
|
" \"last_name\": \"LookupLast\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"they/them\",",
|
|
" \"contact_id\": \"old-contact\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"type\": \"person\"",
|
|
" },",
|
|
" \"replaces\": \"{{uuid:data.id}}\"",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Update existing person with id (no lookup)",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "11111111-1111-1111-1111-111111111111",
|
|
"type": "person",
|
|
"first_name": "NewFirst",
|
|
"last_name": "NewLast"
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "11111111-1111-1111-1111-111111111111",
|
|
"type": "person",
|
|
"first_name": "OldFirst",
|
|
"last_name": "OldLast"
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:mocks.0.id}}')"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"person\" SET",
|
|
" first_name = 'NewFirst',",
|
|
" last_name = 'NewLast'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"entity\" SET",
|
|
" modified_at = '{{timestamp}}',",
|
|
" modified_by = '00000000-0000-0000-0000-000000000000'",
|
|
"WHERE",
|
|
" id = '{{uuid:mocks.0.id}}'"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{",
|
|
" \"first_name\": \"OldFirst\",",
|
|
" \"last_name\": \"OldLast\"",
|
|
" }',",
|
|
" '{",
|
|
" \"first_name\": \"NewFirst\",",
|
|
" \"last_name\": \"NewLast\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '{{uuid:mocks.0.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'update',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"id\": \"{{uuid:mocks.0.id}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"first_name\": \"NewFirst\",",
|
|
" \"last_name\": \"NewLast\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"NewFirst\",",
|
|
" \"last_name\": \"NewLast\",",
|
|
" \"type\": \"person\"",
|
|
" },",
|
|
" \"old\": {",
|
|
" \"first_name\": \"OldFirst\",",
|
|
" \"last_name\": \"OldLast\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Empty strings null out fields",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "123",
|
|
"type": "person",
|
|
"first_name": "John",
|
|
"last_name": "Doe",
|
|
"date_of_birth": "1990-01-01T00:00:00Z",
|
|
"pronouns": ""
|
|
},
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" t1.id = '123')"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '123',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"organization\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '123',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"user\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '123',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"person\" (",
|
|
" \"date_of_birth\",",
|
|
" \"first_name\",",
|
|
" \"id\",",
|
|
" \"last_name\",",
|
|
" \"pronouns\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" 'John',",
|
|
" '123',",
|
|
" 'Doe',",
|
|
" NULL,",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"first_name\": \"John\",",
|
|
" \"last_name\": \"Doe\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '123',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"first_name\": \"John\",",
|
|
" \"last_name\": \"Doe\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"\",",
|
|
" \"id\": \"123\",",
|
|
" \"type\": \"person\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"John\",",
|
|
" \"last_name\": \"Doe\",",
|
|
" \"date_of_birth\": \"{{timestamp}}\",",
|
|
" \"pronouns\": \"\",",
|
|
" \"type\": \"person\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Insert order with nested customer person",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "order",
|
|
"total": 100.0,
|
|
"customer": {
|
|
"type": "person",
|
|
"first_name": "Bob",
|
|
"last_name": "Smith",
|
|
"date_of_birth": "2000-01-01"
|
|
}
|
|
},
|
|
"schema_id": "order",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"organization_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"organization\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"user\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"person\" (",
|
|
" \"date_of_birth\",",
|
|
" \"first_name\",",
|
|
" \"id\",",
|
|
" \"last_name\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '2000-01-01',",
|
|
" 'Bob',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'Smith',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"first_name\": \"Bob\",",
|
|
" \"last_name\": \"Smith\",",
|
|
" \"date_of_birth\": \"2000-01-01\",",
|
|
" \"type\": \"person\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_2}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order\" (",
|
|
" \"customer_id\",",
|
|
" \"id\",",
|
|
" \"total\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_3}}',",
|
|
" 100,",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"total\": 100.0,",
|
|
" \"type\": \"order\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" }',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{uuid:generated_4}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"total\": 100.0,",
|
|
" \"id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"total\": 100.0,",
|
|
" \"type\": \"order\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"first_name\": \"Bob\",",
|
|
" \"last_name\": \"Smith\",",
|
|
" \"date_of_birth\": \"2000-01-01\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"Bob\",",
|
|
" \"last_name\": \"Smith\",",
|
|
" \"date_of_birth\": \"2000-01-01\",",
|
|
" \"type\": \"person\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Insert order with nested order lines",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "abc",
|
|
"type": "order",
|
|
"total": 99.0,
|
|
"lines": [
|
|
{
|
|
"type": "order_line",
|
|
"product": "Widget",
|
|
"price": 99.0
|
|
}
|
|
]
|
|
},
|
|
"schema_id": "order",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
|
|
"FROM agreego.\"order\" t1",
|
|
"JOIN agreego.\"entity\" t2 ON ",
|
|
"WHERE",
|
|
" t1.id = 'abc'",
|
|
" OR (\"id\" = 'abc'))"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'abc',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order\" (",
|
|
" \"id\",",
|
|
" \"total\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'abc',",
|
|
" 99,",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order_line\" (",
|
|
" \"id\",",
|
|
" \"order_id\",",
|
|
" \"price\",",
|
|
" \"product\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'abc',",
|
|
" 99,",
|
|
" 'Widget',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"total\": 99.0,",
|
|
" \"type\": \"order\"",
|
|
" }',",
|
|
" 'abc',",
|
|
" '{{uuid:generated_2}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"total\": 99.0,",
|
|
" \"id\": \"abc\",",
|
|
" \"type\": \"order\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"total\": 99.0,",
|
|
" \"type\": \"order\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Insert person with contacts and phone numbers (M:M)",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "person",
|
|
"first_name": "Relation",
|
|
"last_name": "Test",
|
|
"contacts": [
|
|
{
|
|
"type": "contact",
|
|
"is_primary": true,
|
|
"target": {
|
|
"type": "phone_number",
|
|
"number": "555-0001"
|
|
}
|
|
},
|
|
{
|
|
"type": "contact",
|
|
"is_primary": false,
|
|
"target": {
|
|
"type": "email_address",
|
|
"address": "test@example.com"
|
|
}
|
|
}
|
|
],
|
|
"email_addresses": [
|
|
{
|
|
"type": "contact",
|
|
"is_primary": false,
|
|
"target": {
|
|
"type": "email_address",
|
|
"address": "test2@example.com"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"organization\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"user\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"person\" (",
|
|
" \"first_name\",",
|
|
" \"id\",",
|
|
" \"last_name\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'Relation',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'Test',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_1}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'phone_number'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"phone_number\" (",
|
|
" \"number\"",
|
|
")",
|
|
"VALUES (",
|
|
" '555-0001'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"number\": \"555-0001\",",
|
|
" \"type\": \"phone_number\"",
|
|
" }',",
|
|
" '{{uuid:generated_1}}',",
|
|
" '{{uuid:generated_2}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'contact'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"relationship\" (",
|
|
" \"source_id\",",
|
|
" \"source_type\",",
|
|
" \"target_id\",",
|
|
" \"target_type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'phone_number'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"contact\" (",
|
|
" \"is_primary\"",
|
|
")",
|
|
"VALUES (",
|
|
" true",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"is_primary\": true,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_1}}\",",
|
|
" \"target_type\": \"phone_number\",",
|
|
" \"type\": \"contact\"",
|
|
" }',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{uuid:generated_4}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_5}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'email_address'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"email_address\" (",
|
|
" \"address\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'test@example.com'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"address\": \"test@example.com\",",
|
|
" \"type\": \"email_address\"",
|
|
" }',",
|
|
" '{{uuid:generated_5}}',",
|
|
" '{{uuid:generated_6}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_7}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'contact'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"relationship\" (",
|
|
" \"source_id\",",
|
|
" \"source_type\",",
|
|
" \"target_id\",",
|
|
" \"target_type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person',",
|
|
" '{{uuid:generated_5}}',",
|
|
" 'email_address'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"contact\" (",
|
|
" \"is_primary\"",
|
|
")",
|
|
"VALUES (",
|
|
" false",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_5}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"type\": \"contact\"",
|
|
" }',",
|
|
" '{{uuid:generated_7}}',",
|
|
" '{{uuid:generated_8}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_9}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'email_address'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"email_address\" (",
|
|
" \"address\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'test2@example.com'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"address\": \"test2@example.com\",",
|
|
" \"type\": \"email_address\"",
|
|
" }',",
|
|
" '{{uuid:generated_9}}',",
|
|
" '{{uuid:generated_10}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_11}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'contact'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"relationship\" (",
|
|
" \"source_id\",",
|
|
" \"source_type\",",
|
|
" \"target_id\",",
|
|
" \"target_type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person',",
|
|
" '{{uuid:generated_9}}',",
|
|
" 'email_address'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"contact\" (",
|
|
" \"is_primary\"",
|
|
")",
|
|
"VALUES (",
|
|
" false",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_9}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"type\": \"contact\"",
|
|
" }',",
|
|
" '{{uuid:generated_11}}',",
|
|
" '{{uuid:generated_12}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"first_name\": \"Relation\",",
|
|
" \"last_name\": \"Test\",",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_13}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"first_name\": \"Relation\",",
|
|
" \"last_name\": \"Test\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"Relation\",",
|
|
" \"last_name\": \"Test\",",
|
|
" \"type\": \"person\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"is_primary\": true,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_1}}\",",
|
|
" \"target_type\": \"phone_number\",",
|
|
" \"id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"contact\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"is_primary\": true,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_1}}\",",
|
|
" \"target_type\": \"phone_number\",",
|
|
" \"type\": \"contact\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"number\": \"555-0001\",",
|
|
" \"id\": \"{{uuid:generated_1}}\",",
|
|
" \"type\": \"phone_number\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"number\": \"555-0001\",",
|
|
" \"type\": \"phone_number\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_5}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"id\": \"{{uuid:generated_7}}\",",
|
|
" \"type\": \"contact\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_5}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"type\": \"contact\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"address\": \"test@example.com\",",
|
|
" \"id\": \"{{uuid:generated_5}}\",",
|
|
" \"type\": \"email_address\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"address\": \"test@example.com\",",
|
|
" \"type\": \"email_address\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_9}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"id\": \"{{uuid:generated_11}}\",",
|
|
" \"type\": \"contact\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"is_primary\": false,",
|
|
" \"source_id\": \"{{uuid:generated_0}}\",",
|
|
" \"source_type\": \"person\",",
|
|
" \"target_id\": \"{{uuid:generated_9}}\",",
|
|
" \"target_type\": \"email_address\",",
|
|
" \"type\": \"contact\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"address\": \"test2@example.com\",",
|
|
" \"id\": \"{{uuid:generated_9}}\",",
|
|
" \"type\": \"email_address\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"address\": \"test2@example.com\",",
|
|
" \"type\": \"email_address\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Archive a person",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "abc-archived",
|
|
"type": "person",
|
|
"archived": true
|
|
},
|
|
"mocks": [
|
|
{
|
|
"id": "abc-archived",
|
|
"type": "person",
|
|
"first_name": "ArchivedFirst",
|
|
"last_name": "ArchivedLast",
|
|
"archived": false
|
|
}
|
|
],
|
|
"schema_id": "person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*)",
|
|
"FROM agreego.\"person\" t1",
|
|
"JOIN agreego.\"user\" t2 ON ",
|
|
"JOIN agreego.\"organization\" t3 ON ",
|
|
"JOIN agreego.\"entity\" t4 ON ",
|
|
"WHERE",
|
|
" t1.id = 'abc-archived')"
|
|
],
|
|
[
|
|
"UPDATE agreego.\"entity\" SET",
|
|
" archived = true,",
|
|
" modified_at = '{{timestamp}}',",
|
|
" modified_by = '00000000-0000-0000-0000-000000000000'",
|
|
"WHERE",
|
|
" id = 'abc-archived'"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{",
|
|
" \"archived\": false",
|
|
" }',",
|
|
" '{",
|
|
" \"archived\": true,",
|
|
" \"type\": \"person\"",
|
|
" }',",
|
|
" 'abc-archived',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'delete',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"id\": \"abc-archived\",",
|
|
" \"type\": \"person\",",
|
|
" \"first_name\": \"ArchivedFirst\",",
|
|
" \"last_name\": \"ArchivedLast\",",
|
|
" \"archived\": true,",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"archived\": true,",
|
|
" \"type\": \"person\"",
|
|
" },",
|
|
" \"old\": {",
|
|
" \"archived\": false",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Attachment with text[] and jsonb metadata structures",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "attachment",
|
|
"flags": [
|
|
"urgent",
|
|
"reviewed"
|
|
],
|
|
"other_metadata": {
|
|
"other": "hello"
|
|
},
|
|
"type_metadata": {
|
|
"type": "type_metadata"
|
|
}
|
|
},
|
|
"schema_id": "attachment",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'attachment'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"attachment\" (",
|
|
" \"flags\",",
|
|
" \"id\",",
|
|
" \"other_metadata\",",
|
|
" \"type\",",
|
|
" \"type_metadata\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{\"urgent\",\"reviewed\"}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{",
|
|
" \"other\": \"hello\"",
|
|
" }',",
|
|
" 'attachment',",
|
|
" '{",
|
|
" \"type\": \"type_metadata\"",
|
|
" }'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"flags\": [",
|
|
" \"urgent\",",
|
|
" \"reviewed\"",
|
|
" ],",
|
|
" \"other_metadata\": {",
|
|
" \"other\": \"hello\"",
|
|
" },",
|
|
" \"type_metadata\": {",
|
|
" \"type\": \"type_metadata\"",
|
|
" },",
|
|
" \"type\": \"attachment\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"flags\": [",
|
|
" \"urgent\",",
|
|
" \"reviewed\"",
|
|
" ],",
|
|
" \"other_metadata\": {",
|
|
" \"other\": \"hello\"",
|
|
" },",
|
|
" \"type_metadata\": {",
|
|
" \"type\": \"type_metadata\"",
|
|
" },",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"attachment\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"flags\": [",
|
|
" \"urgent\",",
|
|
" \"reviewed\"",
|
|
" ],",
|
|
" \"other_metadata\": {",
|
|
" \"other\": \"hello\"",
|
|
" },",
|
|
" \"type_metadata\": {",
|
|
" \"type\": \"type_metadata\"",
|
|
" },",
|
|
" \"type\": \"attachment\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Anchor order and insert new line (no line id)",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "abc",
|
|
"type": "order",
|
|
"lines": [
|
|
{
|
|
"type": "order_line",
|
|
"product": "Widget",
|
|
"price": 99.0
|
|
}
|
|
]
|
|
},
|
|
"schema_id": "order",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order_line\" (",
|
|
" \"id\",",
|
|
" \"order_id\",",
|
|
" \"price\",",
|
|
" \"product\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'abc',",
|
|
" 99,",
|
|
" 'Widget',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Anchor order and insert new line (with line id)",
|
|
"action": "merge",
|
|
"data": {
|
|
"id": "abc",
|
|
"type": "order",
|
|
"lines": [
|
|
{
|
|
"id": "11111111-2222-3333-4444-555555555555",
|
|
"type": "order_line",
|
|
"product": "Widget",
|
|
"price": 99.0
|
|
}
|
|
]
|
|
},
|
|
"schema_id": "order",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
|
|
"FROM agreego.\"order_line\" t1",
|
|
"JOIN agreego.\"entity\" t2 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:data.lines.0.id}}')"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:data.lines.0.id}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order_line\" (",
|
|
" \"id\",",
|
|
" \"order_id\",",
|
|
" \"price\",",
|
|
" \"product\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:data.lines.0.id}}',",
|
|
" 'abc',",
|
|
" 99,",
|
|
" 'Widget',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }',",
|
|
" '{{uuid:data.lines.0.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"id\": \"{{uuid:data.lines.0.id}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"product\": \"Widget\",",
|
|
" \"price\": 99.0,",
|
|
" \"order_id\": \"abc\",",
|
|
" \"type\": \"order_line\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Insert invoice with JSONB metadata",
|
|
"action": "merge",
|
|
"schema_id": "invoice",
|
|
"data": {
|
|
"id": "11111111-2222-3333-4444-555555555555",
|
|
"type": "invoice",
|
|
"number": "INV-1001",
|
|
"total": 200.0,
|
|
"metadata_line": {
|
|
"price": 50
|
|
},
|
|
"metadata_lines": [
|
|
{
|
|
"price": 25
|
|
}
|
|
],
|
|
"metadata_nested_line": {
|
|
"line": {
|
|
"price": 75
|
|
}
|
|
},
|
|
"metadata_nested_lines": {
|
|
"lines": [
|
|
{
|
|
"price": 100
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
|
|
"FROM agreego.\"invoice\" t1",
|
|
"JOIN agreego.\"entity\" t2 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:data.id}}'",
|
|
" OR (\"id\" = '{{uuid:data.id}}'))"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:data.id}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'invoice'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"invoice\" (",
|
|
" \"id\",",
|
|
" \"metadata_line\",",
|
|
" \"metadata_lines\",",
|
|
" \"metadata_nested_line\",",
|
|
" \"metadata_nested_lines\",",
|
|
" \"total\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:data.id}}',",
|
|
" '{",
|
|
" \"price\": 50",
|
|
" }',",
|
|
" '[{\"price\":25}]',",
|
|
" '{",
|
|
" \"line\": {",
|
|
" \"price\": 75",
|
|
" }",
|
|
" }',",
|
|
" '{",
|
|
" \"lines\": [",
|
|
" {",
|
|
" \"price\": 100",
|
|
" }",
|
|
" ]",
|
|
" }',",
|
|
" 200,",
|
|
" 'invoice'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"total\": 200.0,",
|
|
" \"metadata_line\": {",
|
|
" \"price\": 50",
|
|
" },",
|
|
" \"metadata_lines\": [",
|
|
" {",
|
|
" \"price\": 25",
|
|
" }",
|
|
" ],",
|
|
" \"metadata_nested_line\": {",
|
|
" \"line\": {",
|
|
" \"price\": 75",
|
|
" }",
|
|
" },",
|
|
" \"metadata_nested_lines\": {",
|
|
" \"lines\": [",
|
|
" {",
|
|
" \"price\": 100",
|
|
" }",
|
|
" ]",
|
|
" },",
|
|
" \"type\": \"invoice\"",
|
|
" }',",
|
|
" '{{uuid:data.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Insert account with checking kind and routing number",
|
|
"action": "merge",
|
|
"schema_id": "account",
|
|
"data": {
|
|
"id": "11111111-2222-3333-4444-555555555555",
|
|
"type": "account",
|
|
"kind": "checking",
|
|
"routing_number": "123456789"
|
|
},
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"(SELECT to_jsonb(t1.*) || to_jsonb(t2.*)",
|
|
"FROM agreego.\"account\" t1",
|
|
"JOIN agreego.\"entity\" t2 ON ",
|
|
"WHERE",
|
|
" t1.id = '{{uuid:data.id}}')"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:data.id}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'account'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"account\" (",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"routing_number\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:data.id}}',",
|
|
" 'checking',",
|
|
" '123456789',",
|
|
" 'account'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"kind\": \"checking\",",
|
|
" \"routing_number\": \"123456789\",",
|
|
" \"type\": \"account\"",
|
|
" }',",
|
|
" '{{uuid:data.id}}',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"kind\": \"checking\",",
|
|
" \"routing_number\": \"123456789\",",
|
|
" \"id\": \"{{uuid:data.id}}\",",
|
|
" \"type\": \"account\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"kind\": \"checking\",",
|
|
" \"routing_number\": \"123456789\",",
|
|
" \"type\": \"account\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Test organization_id syntactic sugar permutations",
|
|
"action": "merge",
|
|
"data": {
|
|
"type": "order",
|
|
"organization_id": "parent-org-id",
|
|
"customer": {
|
|
"type": "person",
|
|
"first_name": "Const",
|
|
"last_name": "Person"
|
|
},
|
|
"lines": [
|
|
{
|
|
"type": "order_line"
|
|
},
|
|
{
|
|
"type": "order_line",
|
|
"organization_id": "explicit-org-id"
|
|
}
|
|
]
|
|
},
|
|
"schema_id": "order",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"organization_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_1}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"organization\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"user\" (",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"person\" (",
|
|
" \"first_name\",",
|
|
" \"id\",",
|
|
" \"last_name\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" 'Const',",
|
|
" '{{uuid:generated_0}}',",
|
|
" 'Person',",
|
|
" 'person'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"first_name\": \"Const\",",
|
|
" \"last_name\": \"Person\",",
|
|
" \"type\": \"person\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" }',",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_2}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"organization_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'parent-org-id',",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order\" (",
|
|
" \"customer_id\",",
|
|
" \"id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_0}}',",
|
|
" '{{uuid:generated_3}}',",
|
|
" 'order'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"organization_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_4}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'parent-org-id',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order_line\" (",
|
|
" \"id\",",
|
|
" \"order_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_4}}',",
|
|
" '{{uuid:generated_3}}',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"organization_id\": \"parent-org-id\"",
|
|
" }',",
|
|
" '{{uuid:generated_4}}',",
|
|
" '{{uuid:generated_5}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"entity\" (",
|
|
" \"created_at\",",
|
|
" \"created_by\",",
|
|
" \"id\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\",",
|
|
" \"organization_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" '{{uuid:generated_6}}',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000',",
|
|
" 'explicit-org-id',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.\"order_line\" (",
|
|
" \"id\",",
|
|
" \"order_id\",",
|
|
" \"type\"",
|
|
")",
|
|
"VALUES (",
|
|
" '{{uuid:generated_6}}',",
|
|
" '{{uuid:generated_3}}',",
|
|
" 'order_line'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"organization_id\": \"explicit-org-id\",",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order_line\"",
|
|
" }',",
|
|
" '{{uuid:generated_6}}',",
|
|
" '{{uuid:generated_7}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"INSERT INTO agreego.change (",
|
|
" \"old\",",
|
|
" \"new\",",
|
|
" \"entity_id\",",
|
|
" \"id\",",
|
|
" \"kind\",",
|
|
" \"modified_at\",",
|
|
" \"modified_by\"",
|
|
")",
|
|
"VALUES (",
|
|
" NULL,",
|
|
" '{",
|
|
" \"organization_id\": \"parent-org-id\",",
|
|
" \"type\": \"order\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" }',",
|
|
" '{{uuid:generated_3}}',",
|
|
" '{{uuid:generated_8}}',",
|
|
" 'create',",
|
|
" '{{timestamp}}',",
|
|
" '00000000-0000-0000-0000-000000000000'",
|
|
")"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"organization_id\": \"parent-org-id\",",
|
|
" \"id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"organization_id\": \"parent-org-id\",",
|
|
" \"type\": \"order\",",
|
|
" \"customer_id\": \"{{uuid:generated_0}}\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"first_name\": \"Const\",",
|
|
" \"last_name\": \"Person\",",
|
|
" \"id\": \"{{uuid:generated_0}}\",",
|
|
" \"type\": \"person\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"first_name\": \"Const\",",
|
|
" \"last_name\": \"Person\",",
|
|
" \"type\": \"person\",",
|
|
" \"organization_id\": \"{{uuid:generated_1}}\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"id\": \"{{uuid:generated_4}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\",",
|
|
" \"organization_id\": \"parent-org-id\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"organization_id\": \"parent-org-id\"",
|
|
" }",
|
|
"}'))"
|
|
],
|
|
[
|
|
"(SELECT pg_notify('entity', '{",
|
|
" \"complete\": {",
|
|
" \"organization_id\": \"explicit-org-id\",",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"id\": \"{{uuid:generated_6}}\",",
|
|
" \"type\": \"order_line\",",
|
|
" \"created_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"created_at\": \"{{timestamp}}\",",
|
|
" \"modified_by\": \"00000000-0000-0000-0000-000000000000\",",
|
|
" \"modified_at\": \"{{timestamp}}\"",
|
|
" },",
|
|
" \"new\": {",
|
|
" \"organization_id\": \"explicit-org-id\",",
|
|
" \"order_id\": \"{{uuid:generated_3}}\",",
|
|
" \"type\": \"order_line\"",
|
|
" }",
|
|
"}'))"
|
|
]
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |