ts / src / registrations.ts
1,224 words
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/**
 * Register, renew, transfer, trade and manage .ro domains. Registrations
 * charge credits up front (refunded on failure); see GET /credits/prices
 * for current amounts. Mutations are subject to the client's domain gate
 * when configured.
 */
import type { Client } from './client.js';
import { checkGate } from './gate.js';
import * as http from './http.js';
import type { Body, Query } from './types.js';

type Id = { id: string };

/** GET /domains/registrations — List your domains (cursor-paginated). */
export const list = (client: Client, query?: Query<'/domains/registrations', 'get'>) =>
  http.get(client, '/domains/registrations', { query });

/** Every registration, following cursor pagination. */
export const listAll = (client: Client, query?: Query<'/domains/registrations', 'get'>) =>
  http.paginate(client, '/domains/registrations', 'registrations', { query });

/** POST /domains/registrations — Register a .ro domain (202; charges credits). */
export const register = async (client: Client, body: Body<'/domains/registrations', 'post'>) => {
  await checkGate(client, 'POST /domains/registrations', { domain: body.domain });
  return http.post(client, '/domains/registrations', { body });
};

/** GET /domains/registrations/{id} — Get a domain. */
export const get = (client: Client, id: string) =>
  http.get(client, '/domains/registrations/{id}', { params: { id } });

/** POST /domains/registrations/{id}/renew — Renew a domain (202; charges credits). */
export const renew = async (client: Client, id: string, body?: Body<'/domains/registrations/{id}/renew', 'post'>) => {
  await checkGate(client, 'POST /domains/registrations/{id}/renew', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/renew', { params: { id }, body });
};

/** PUT /domains/registrations/{id}/auto-renew — Toggle auto-renew. */
export const setAutoRenew = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/auto-renew', 'put'>,
) => {
  await checkGate(client, 'PUT /domains/registrations/{id}/auto-renew', { registrationId: id });
  return http.put(client, '/domains/registrations/{id}/auto-renew', { params: { id }, body });
};

/** PUT /domains/registrations/{id}/sensitive — Toggle the sensitive-domain protection. */
export const setSensitive = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/sensitive', 'put'>,
) => {
  await checkGate(client, 'PUT /domains/registrations/{id}/sensitive', { registrationId: id });
  return http.put(client, '/domains/registrations/{id}/sensitive', { params: { id }, body });
};

/** PUT /domains/registrations/{id}/nameservers — Replace nameservers (202). */
export const setNameservers = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/nameservers', 'put'>,
) => {
  await checkGate(client, 'PUT /domains/registrations/{id}/nameservers', { registrationId: id });
  return http.put(client, '/domains/registrations/{id}/nameservers', { params: { id }, body });
};

/** GET /domains/registrations/{id}/hosts — List the domain's hosts (glue records). */
export const listHosts = (client: Client, id: string, query?: Query<'/domains/registrations/{id}/hosts', 'get'>) =>
  http.get(client, '/domains/registrations/{id}/hosts', { params: { id }, query });

/** POST /domains/registrations/{id}/hosts — Create a host (glue record, 202). */
export const createHost = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/hosts', 'post'>,
) => {
  await checkGate(client, 'POST /domains/registrations/{id}/hosts', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/hosts', { params: { id }, body });
};

/** PUT /domains/registrations/{id}/hosts/{host} — Replace a host's IPs (202). */
export const setHostIps = async (
  client: Client,
  id: string,
  host: string,
  body: Body<'/domains/registrations/{id}/hosts/{host}', 'put'>,
) => {
  await checkGate(client, 'PUT /domains/registrations/{id}/hosts/{host}', { registrationId: id });
  return http.put(client, '/domains/registrations/{id}/hosts/{host}', { params: { id, host }, body });
};

/** DELETE /domains/registrations/{id}/hosts/{host} — Delete a host (glue record, 202). */
export const deleteHost = async (
  client: Client,
  id: string,
  host: string,
  body?: Body<'/domains/registrations/{id}/hosts/{host}', 'delete'>,
) => {
  await checkGate(client, 'DELETE /domains/registrations/{id}/hosts/{host}', { registrationId: id });
  return http.del(client, '/domains/registrations/{id}/hosts/{host}', { params: { id, host }, body });
};

/** GET /domains/registrations/{id}/dsdata — List the domain's DS records. */
export const listDsData = (client: Client, id: string, query?: Query<'/domains/registrations/{id}/dsdata', 'get'>) =>
  http.get(client, '/domains/registrations/{id}/dsdata', { params: { id }, query });

/** POST /domains/registrations/{id}/dsdata — Publish a DS record (202). */
export const publishDsData = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/dsdata', 'post'>,
) => {
  await checkGate(client, 'POST /domains/registrations/{id}/dsdata', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/dsdata', { params: { id }, body });
};

/** DELETE /domains/registrations/{id}/dsdata — Withdraw a DS record (202; carries a JSON body). */
export const withdrawDsData = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/dsdata', 'delete'>,
) => {
  await checkGate(client, 'DELETE /domains/registrations/{id}/dsdata', { registrationId: id });
  return http.del(client, '/domains/registrations/{id}/dsdata', { params: { id }, body });
};

/** POST /domains/registrations/{id}/transfer-out — Start moving a domain away. */
export const transferOut = async (
  client: Client,
  id: string,
  body?: Body<'/domains/registrations/{id}/transfer-out', 'post'>,
) => {
  await checkGate(client, 'POST /domains/registrations/{id}/transfer-out', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/transfer-out', { params: { id }, body });
};

/** PUT /domains/registrations/{id}/registrant — Update the registrant's contact details (202). */
export const updateRegistrant = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/registrant', 'put'>,
) => {
  await checkGate(client, 'PUT /domains/registrations/{id}/registrant', { registrationId: id });
  return http.put(client, '/domains/registrations/{id}/registrant', { params: { id }, body });
};

/** POST /domains/registrations/{id}/registrant-email/start — Start registrant-email ownership verification. */
export const startRegistrantEmailVerification = async (client: Client, id: string) => {
  await checkGate(client, 'POST /domains/registrations/{id}/registrant-email/start', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/registrant-email/start', { params: { id } });
};

/** POST /domains/registrations/{id}/registrant-email/confirm — Confirm the registrant-email code. */
export const confirmRegistrantEmail = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/registrant-email/confirm', 'post'>,
) => {
  await checkGate(client, 'POST /domains/registrations/{id}/registrant-email/confirm', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/registrant-email/confirm', { params: { id }, body });
};

/** POST /domains/registrations/{id}/registrant-email/adopt — Adopt the registrant contact email (202). */
export const adoptRegistrantEmail = async (
  client: Client,
  id: string,
  body: Body<'/domains/registrations/{id}/registrant-email/adopt', 'post'>,
) => {
  await checkGate(client, 'POST /domains/registrations/{id}/registrant-email/adopt', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/registrant-email/adopt', { params: { id }, body });
};

/** GET /domains/registrations/{id}/trade — Quote a registrant change (trade). */
export const quoteTrade = (client: Client, id: string) =>
  http.get(client, '/domains/registrations/{id}/trade', { params: { id } });

/** POST /domains/registrations/{id}/trade — Change a domain's registrant (trade, 202; charges credits). */
export const trade = async (client: Client, id: string, body: Body<'/domains/registrations/{id}/trade', 'post'>) => {
  await checkGate(client, 'POST /domains/registrations/{id}/trade', { registrationId: id });
  return http.post(client, '/domains/registrations/{id}/trade', { params: { id }, body });
};

/** POST /domains/transfers-in — Transfer a .ro domain to ird (202). */
export const transferIn = async (client: Client, body: Body<'/domains/transfers-in', 'post'>) => {
  await checkGate(client, 'POST /domains/transfers-in', { domain: body.domain });
  return http.post(client, '/domains/transfers-in', { body });
};

/** POST /domains/trades-in — Trade a .ro domain into ird (become the holder, 202; charges credits). */
export const tradeIn = async (client: Client, body: Body<'/domains/trades-in', 'post'>) => {
  await checkGate(client, 'POST /domains/trades-in', { domain: body.domain });
  return http.post(client, '/domains/trades-in', { body });
};

/** POST /domains/adoptions — Adopt an ird-sponsored domain you already own. */
export const adopt = async (client: Client, body: Body<'/domains/adoptions', 'post'>) => {
  await checkGate(client, 'POST /domains/adoptions', { domain: body.domain });
  return http.post(client, '/domains/adoptions', { body });
};

/** GET /domains/actions — List your registry actions (cursor-paginated). */
export const listActions = (client: Client, query?: Query<'/domains/actions', 'get'>) =>
  http.get(client, '/domains/actions', { query });

/** Every registry action, following cursor pagination. */
export const listAllActions = (client: Client, query?: Query<'/domains/actions', 'get'>) =>
  http.paginate(client, '/domains/actions', 'actions', { query });

/** GET /domains/actions/{id} — Poll a registry action. */
export const getAction = (client: Client, id: string) =>
  http.get(client, '/domains/actions/{id}', { params: { id } satisfies Id });

/**
 * POST /domains/actions/{id}/cancel — Cancel a queued action. Subject to the
 * client's domain gate on the action's registration (resolved via
 * `getAction` when a gate is set).
 */
export const cancelAction = async (
  client: Client,
  id: string,
  body?: Body<'/domains/actions/{id}/cancel', 'post'>,
) => {
  if (client.gate) {
    const { action } = await getAction(client, id);
    await checkGate(client, 'POST /domains/actions/{id}/cancel', { registrationId: action?.registration_id });
  }
  return http.post(client, '/domains/actions/{id}/cancel', { params: { id }, body });
};

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/ts.git