pre updating version control

This commit is contained in:
taDuc
2026-04-17 20:55:33 +07:00
parent 6f7e819aca
commit 5397bf9808
5 changed files with 806 additions and 166 deletions

View File

@@ -69,6 +69,64 @@ const openApiSpec = {
status: { type: "number" },
},
},
EntityBatchCreateChange: {
type: "object",
properties: {
action: { type: "string", enum: ["create"] },
entity: { $ref: "#/components/schemas/EntityCreateInput" },
},
required: ["action"],
},
EntityBatchUpdateChange: {
type: "object",
properties: {
action: { type: "string", enum: ["update"] },
id: { type: "string" },
entity: { $ref: "#/components/schemas/EntityUpdateInput" },
name: { type: "string" },
slug: { type: "string", nullable: true },
description: { type: "string", nullable: true },
type_id: { type: "string" },
status: { type: "number" },
},
required: ["action", "id"],
},
EntityBatchDeleteChange: {
type: "object",
properties: {
action: { type: "string", enum: ["delete"] },
id: { type: "string" },
},
required: ["action", "id"],
},
EntityBatchPayload: {
type: "object",
properties: {
changes: {
type: "array",
items: {
oneOf: [
{ $ref: "#/components/schemas/EntityBatchCreateChange" },
{ $ref: "#/components/schemas/EntityBatchUpdateChange" },
{ $ref: "#/components/schemas/EntityBatchDeleteChange" },
],
},
},
},
required: ["changes"],
},
EntityBatchResponse: {
type: "object",
properties: {
success: { type: "boolean" },
applied: { type: "number" },
created_entity_ids: {
type: "array",
items: { type: "string" },
},
},
required: ["success", "applied", "created_entity_ids"],
},
GeoJSONGeometry: {
type: "object",
properties: {
@@ -221,6 +279,51 @@ const openApiSpec = {
},
required: ["success", "applied"],
},
CombinedBatchPayload: {
type: "object",
properties: {
entity_changes: {
type: "array",
items: {
oneOf: [
{ $ref: "#/components/schemas/EntityBatchCreateChange" },
{ $ref: "#/components/schemas/EntityBatchUpdateChange" },
{ $ref: "#/components/schemas/EntityBatchDeleteChange" },
],
},
},
geometry_changes: {
type: "array",
items: {
oneOf: [
{ $ref: "#/components/schemas/BatchCreateChange" },
{ $ref: "#/components/schemas/BatchUpdateChange" },
{ $ref: "#/components/schemas/BatchDeleteChange" },
],
},
},
},
},
CombinedBatchResponse: {
type: "object",
properties: {
success: { type: "boolean" },
applied: { type: "number" },
entity_applied: { type: "number" },
geometry_applied: { type: "number" },
created_entity_ids: {
type: "array",
items: { type: "string" },
},
},
required: [
"success",
"applied",
"entity_applied",
"geometry_applied",
"created_entity_ids",
],
},
MetadataResponse: {
type: "object",
additionalProperties: {
@@ -442,6 +545,46 @@ const openApiSpec = {
},
},
},
"/entities/batch": {
post: {
tags: ["Entities"],
summary: "Apply batch create/update/delete entities",
requestBody: {
required: true,
content: {
"application/json": {
schema: { $ref: "#/components/schemas/EntityBatchPayload" },
},
},
},
responses: {
200: {
description: "Batch applied",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/EntityBatchResponse" },
},
},
},
400: {
description: "Invalid payload",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/ErrorResponse" },
},
},
},
409: {
description: "Unique conflict or cannot delete due to orphaned geometries",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/ErrorResponse" },
},
},
},
},
},
},
"/entities/{id}": {
get: {
tags: ["Entities"],
@@ -721,6 +864,46 @@ const openApiSpec = {
},
},
},
"/geometries/batch/combined": {
post: {
tags: ["Geometries", "Entities"],
summary: "Apply entity batch and geometry batch in one transaction",
requestBody: {
required: true,
content: {
"application/json": {
schema: { $ref: "#/components/schemas/CombinedBatchPayload" },
},
},
},
responses: {
200: {
description: "Combined batch applied",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/CombinedBatchResponse" },
},
},
},
400: {
description: "Invalid payload",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/ErrorResponse" },
},
},
},
409: {
description: "Conflict in entity changes (unique or orphan guard)",
content: {
"application/json": {
schema: { $ref: "#/components/schemas/ErrorResponse" },
},
},
},
},
},
},
},
};