update package version and response return tyupe for delete domain api (#272)
This commit is contained in:
@@ -626,10 +626,10 @@
|
||||
{
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"nullable": false,
|
||||
"nullable": true,
|
||||
"example": 1
|
||||
},
|
||||
"required": true,
|
||||
"required": false,
|
||||
"name": "id",
|
||||
"in": "path"
|
||||
}
|
||||
@@ -643,152 +643,55 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"description": "The ID of the domain",
|
||||
"example": 1
|
||||
"type": "number"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the domain",
|
||||
"example": "example.com"
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"teamId": {
|
||||
"type": "number",
|
||||
"description": "The ID of the team",
|
||||
"example": 1
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"NOT_STARTED",
|
||||
"PENDING",
|
||||
"SUCCESS",
|
||||
"FAILED",
|
||||
"TEMPORARY_FAILURE"
|
||||
]
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"default": "us-east-1"
|
||||
},
|
||||
"clickTracking": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"openTracking": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"publicKey": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"dkimStatus": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"spfDetails": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"dmarcAdded": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"isVerifying": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"subdomain": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"verificationError": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"lastCheckedTime": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"dnsRecords": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"MX",
|
||||
"TXT"
|
||||
],
|
||||
"description": "DNS record type",
|
||||
"example": "TXT"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "DNS record name",
|
||||
"example": "mail"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"description": "DNS record value",
|
||||
"example": "v=spf1 include:amazonses.com ~all"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string",
|
||||
"description": "DNS record TTL",
|
||||
"example": "Auto"
|
||||
},
|
||||
"priority": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "DNS record priority",
|
||||
"example": "10"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"NOT_STARTED",
|
||||
"PENDING",
|
||||
"SUCCESS",
|
||||
"FAILED",
|
||||
"TEMPORARY_FAILURE"
|
||||
]
|
||||
},
|
||||
"recommended": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the record is recommended"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type",
|
||||
"name",
|
||||
"value",
|
||||
"ttl",
|
||||
"status"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"teamId",
|
||||
"status",
|
||||
"publicKey",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
"dnsRecords"
|
||||
"success",
|
||||
"message"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden - API key doesn't have access",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"error"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"error"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+7
-22
@@ -34,23 +34,15 @@
|
||||
},
|
||||
{
|
||||
"group": "Self Hosting",
|
||||
"pages": [
|
||||
"self-hosting/overview",
|
||||
"self-hosting/railway"
|
||||
]
|
||||
"pages": ["self-hosting/overview", "self-hosting/railway"]
|
||||
},
|
||||
{
|
||||
"group": "Guides",
|
||||
"pages": [
|
||||
"guides/use-with-react-email"
|
||||
]
|
||||
"pages": ["guides/use-with-react-email"]
|
||||
},
|
||||
{
|
||||
"group": "Community SDKs",
|
||||
"pages": [
|
||||
"community-sdk/python",
|
||||
"community-sdk/go"
|
||||
]
|
||||
"pages": ["community-sdk/python", "community-sdk/go"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -59,9 +51,7 @@
|
||||
"groups": [
|
||||
{
|
||||
"group": "API Reference",
|
||||
"pages": [
|
||||
"api-reference/introduction"
|
||||
]
|
||||
"pages": ["api-reference/introduction"]
|
||||
},
|
||||
{
|
||||
"group": "Emails",
|
||||
@@ -91,7 +81,8 @@
|
||||
"api-reference/domains/get-domain",
|
||||
"api-reference/domains/list-domains",
|
||||
"api-reference/domains/create-domain",
|
||||
"api-reference/domains/verify-domain"
|
||||
"api-reference/domains/verify-domain",
|
||||
"api-reference/domains/delete-domain"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -147,12 +138,6 @@
|
||||
}
|
||||
},
|
||||
"contextual": {
|
||||
"options": [
|
||||
"copy",
|
||||
"view",
|
||||
"chatgpt",
|
||||
"claude",
|
||||
"perplexity"
|
||||
]
|
||||
"options": ["copy", "view", "chatgpt", "claude", "perplexity"]
|
||||
}
|
||||
}
|
||||
@@ -5,83 +5,90 @@ import { UnsendApiError } from "../../api-error";
|
||||
import { deleteDomain as deleteDomainService } from "~/server/service/domain-service";
|
||||
|
||||
const route = createRoute({
|
||||
method: "delete",
|
||||
path: "/v1/domains/{id}",
|
||||
request: {
|
||||
params: z.object({
|
||||
id: z.coerce.number().openapi({
|
||||
param: {
|
||||
name: "id",
|
||||
in: "path",
|
||||
},
|
||||
example: 1,
|
||||
}),
|
||||
}),
|
||||
method: "delete",
|
||||
path: "/v1/domains/{id}",
|
||||
request: {
|
||||
params: z.object({
|
||||
id: z.coerce.number().openapi({
|
||||
param: {
|
||||
name: "id",
|
||||
in: "path",
|
||||
},
|
||||
example: 1,
|
||||
}),
|
||||
}),
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
id: z.number(),
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Domain deleted successfully",
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Domain deleted successfully",
|
||||
403: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
403: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
description: "Forbidden - API key doesn't have access",
|
||||
},
|
||||
description: "Forbidden - API key doesn't have access",
|
||||
},
|
||||
404: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
404: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Domain not found",
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
description: "Domain not found",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function deleteDomain(app: PublicAPIApp) {
|
||||
app.openapi(route, async (c) => {
|
||||
const team = c.var.team;
|
||||
const domainId = c.req.valid("param").id;
|
||||
app.openapi(route, async (c) => {
|
||||
const team = c.var.team;
|
||||
const domainId = c.req.valid("param").id;
|
||||
|
||||
// Enforce API key domain restriction
|
||||
if (team.apiKey.domainId && team.apiKey.domainId !== domainId) {
|
||||
throw new UnsendApiError({
|
||||
code: "FORBIDDEN",
|
||||
message: "API key doesn't have access to this domain",
|
||||
});
|
||||
}
|
||||
// Enforce API key domain restriction
|
||||
if (team.apiKey.domainId && team.apiKey.domainId !== domainId) {
|
||||
throw new UnsendApiError({
|
||||
code: "FORBIDDEN",
|
||||
message: "API key doesn't have access to this domain",
|
||||
});
|
||||
}
|
||||
|
||||
const domain = await db.domain.findFirst({
|
||||
where: {
|
||||
id: domainId,
|
||||
teamId: team.id
|
||||
},
|
||||
});
|
||||
|
||||
if (!domain) {
|
||||
throw new UnsendApiError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Domain not found",
|
||||
});
|
||||
}
|
||||
|
||||
const deletedDomain = await deleteDomainService(domainId);
|
||||
|
||||
return c.json(deletedDomain);
|
||||
const domain = await db.domain.findFirst({
|
||||
where: {
|
||||
id: domainId,
|
||||
teamId: team.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!domain) {
|
||||
throw new UnsendApiError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Domain not found",
|
||||
});
|
||||
}
|
||||
|
||||
const deletedDomain = await deleteDomainService(domainId);
|
||||
|
||||
return c.json({
|
||||
id: deletedDomain.id,
|
||||
success: true,
|
||||
message: "Domain deleted successfully",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default deleteDomain;
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "usesend"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
description = "Python SDK for the UseSend API"
|
||||
authors = ["UseSend"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -8,6 +8,7 @@ from .types import (
|
||||
Domain,
|
||||
DomainCreate,
|
||||
DomainCreateResponse,
|
||||
DomainDeleteResponse,
|
||||
DomainVerifyResponse,
|
||||
)
|
||||
|
||||
@@ -34,7 +35,7 @@ class Domains:
|
||||
data, err = self.usesend.get(f"/domains/{domain_id}")
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
def delete(self, domain_id: int) -> Tuple[Optional[Domain], Optional[APIError]]:
|
||||
def delete(self, domain_id: int) -> Tuple[Optional[DomainDeleteResponse], Optional[APIError]]:
|
||||
data, err = self.usesend.delete(f"/domains/{domain_id}")
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
|
||||
@@ -94,6 +94,11 @@ class DomainVerifyResponse(TypedDict):
|
||||
message: str
|
||||
|
||||
|
||||
class DomainDeleteResponse(TypedDict):
|
||||
id: int
|
||||
success: bool
|
||||
message: str
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Emails
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "usesend-js",
|
||||
"version": "1.5.4",
|
||||
"version": "1.5.5",
|
||||
"description": "",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
Vendored
+4
-69
@@ -369,7 +369,7 @@ export interface paths {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: number;
|
||||
id: number | null;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
@@ -382,78 +382,13 @@ export interface paths {
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
/**
|
||||
* @description The ID of the domain
|
||||
* @example 1
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* @description The name of the domain
|
||||
* @example example.com
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* @description The ID of the team
|
||||
* @example 1
|
||||
*/
|
||||
teamId: number;
|
||||
/** @enum {string} */
|
||||
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
||||
/** @default us-east-1 */
|
||||
region: string;
|
||||
/** @default false */
|
||||
clickTracking: boolean;
|
||||
/** @default false */
|
||||
openTracking: boolean;
|
||||
publicKey: string;
|
||||
dkimStatus?: string | null;
|
||||
spfDetails?: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
/** @default false */
|
||||
dmarcAdded: boolean;
|
||||
/** @default false */
|
||||
isVerifying: boolean;
|
||||
errorMessage?: string | null;
|
||||
subdomain?: string | null;
|
||||
verificationError?: string | null;
|
||||
lastCheckedTime?: string | null;
|
||||
dnsRecords: {
|
||||
/**
|
||||
* @description DNS record type
|
||||
* @example TXT
|
||||
* @enum {string}
|
||||
*/
|
||||
type: "MX" | "TXT";
|
||||
/**
|
||||
* @description DNS record name
|
||||
* @example mail
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* @description DNS record value
|
||||
* @example v=spf1 include:amazonses.com ~all
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* @description DNS record TTL
|
||||
* @example Auto
|
||||
*/
|
||||
ttl: string;
|
||||
/**
|
||||
* @description DNS record priority
|
||||
* @example 10
|
||||
*/
|
||||
priority?: string | null;
|
||||
/** @enum {string} */
|
||||
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
||||
/** @description Whether the record is recommended */
|
||||
recommended?: boolean;
|
||||
}[];
|
||||
success: boolean;
|
||||
message: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Forbidden - API key doesn't have access to this domain */
|
||||
/** @description Forbidden - API key doesn't have access */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
|
||||
Reference in New Issue
Block a user