@moonbase.sh/api 0.1.113 → 0.1.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +40 -25
- package/dist/index.d.cts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +39 -25
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
ActivationMethod: () => ActivationMethod,
|
|
34
34
|
ActivationRequestStatus: () => ActivationRequestStatus,
|
|
35
35
|
ActivationStatus: () => ActivationStatus,
|
|
36
|
+
ConflictError: () => ConflictError,
|
|
36
37
|
LicenseStatus: () => LicenseStatus,
|
|
37
38
|
MoonbaseClient: () => MoonbaseClient,
|
|
38
39
|
MoonbaseError: () => MoonbaseError,
|
|
@@ -290,32 +291,41 @@ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
|
290
291
|
var import_zod7 = require("zod");
|
|
291
292
|
|
|
292
293
|
// src/utils/errors.ts
|
|
293
|
-
var
|
|
294
|
-
constructor() {
|
|
294
|
+
var MoonbaseError = class extends Error {
|
|
295
|
+
constructor(problemDetails) {
|
|
296
|
+
var _a, _b;
|
|
295
297
|
super();
|
|
298
|
+
this.problemDetails = problemDetails;
|
|
299
|
+
this.name = "MoonbaseError";
|
|
300
|
+
this.message = (_b = (_a = problemDetails == null ? void 0 : problemDetails.detail) != null ? _a : problemDetails == null ? void 0 : problemDetails.title) != null ? _b : "An unknown error occurred";
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
var NotAuthorizedError = class extends MoonbaseError {
|
|
304
|
+
constructor(problemDetails) {
|
|
305
|
+
super(problemDetails);
|
|
306
|
+
this.problemDetails = problemDetails;
|
|
296
307
|
this.name = "NotAuthorizedError";
|
|
297
308
|
}
|
|
298
309
|
};
|
|
299
|
-
var NotAuthenticatedError = class extends
|
|
300
|
-
constructor() {
|
|
301
|
-
super();
|
|
310
|
+
var NotAuthenticatedError = class extends MoonbaseError {
|
|
311
|
+
constructor(problemDetails) {
|
|
312
|
+
super(problemDetails);
|
|
313
|
+
this.problemDetails = problemDetails;
|
|
302
314
|
this.name = "NotAuthenticatedError";
|
|
303
315
|
}
|
|
304
316
|
};
|
|
305
|
-
var NotFoundError = class extends
|
|
306
|
-
constructor() {
|
|
307
|
-
super();
|
|
317
|
+
var NotFoundError = class extends MoonbaseError {
|
|
318
|
+
constructor(problemDetails) {
|
|
319
|
+
super(problemDetails);
|
|
320
|
+
this.problemDetails = problemDetails;
|
|
308
321
|
this.name = "NotFoundError";
|
|
309
322
|
}
|
|
310
323
|
};
|
|
311
|
-
var
|
|
312
|
-
constructor(
|
|
313
|
-
super();
|
|
314
|
-
this.
|
|
315
|
-
this.
|
|
316
|
-
this.status = status;
|
|
317
|
-
this.name = "MoonbaseError";
|
|
318
|
-
this.message = detail != null ? detail : title;
|
|
324
|
+
var ConflictError = class extends MoonbaseError {
|
|
325
|
+
constructor(problemDetails) {
|
|
326
|
+
super(problemDetails);
|
|
327
|
+
this.problemDetails = problemDetails;
|
|
328
|
+
this.name = "ConflictError";
|
|
319
329
|
}
|
|
320
330
|
};
|
|
321
331
|
|
|
@@ -324,23 +334,27 @@ var problemDetailsSchema = import_zod7.z.object({
|
|
|
324
334
|
type: import_zod7.z.string(),
|
|
325
335
|
title: import_zod7.z.string(),
|
|
326
336
|
detail: import_zod7.z.string().optional(),
|
|
337
|
+
instance: import_zod7.z.string().optional(),
|
|
327
338
|
status: import_zod7.z.number()
|
|
328
339
|
});
|
|
329
340
|
async function handleResponseProblem(response) {
|
|
330
|
-
if (response.status === 404)
|
|
331
|
-
throw new NotFoundError();
|
|
332
|
-
if (response.status === 401)
|
|
333
|
-
throw new NotAuthenticatedError();
|
|
334
|
-
if (response.status === 403)
|
|
335
|
-
throw new NotAuthorizedError();
|
|
336
341
|
let problemDetails;
|
|
337
342
|
try {
|
|
338
343
|
const json = await response.json();
|
|
339
|
-
|
|
344
|
+
if (json)
|
|
345
|
+
problemDetails = problemDetailsSchema.parse(json);
|
|
340
346
|
} catch (e) {
|
|
341
347
|
throw new Error("An unknown problem occurred");
|
|
342
348
|
}
|
|
343
|
-
|
|
349
|
+
if (response.status === 404)
|
|
350
|
+
throw new NotFoundError(problemDetails);
|
|
351
|
+
if (response.status === 401)
|
|
352
|
+
throw new NotAuthenticatedError(problemDetails);
|
|
353
|
+
if (response.status === 403)
|
|
354
|
+
throw new NotAuthorizedError(problemDetails);
|
|
355
|
+
if (response.status === 404)
|
|
356
|
+
throw new ConflictError(problemDetails);
|
|
357
|
+
throw new MoonbaseError(problemDetails);
|
|
344
358
|
}
|
|
345
359
|
|
|
346
360
|
// src/utils/api.ts
|
|
@@ -437,7 +451,7 @@ var TrialEndpoints = class {
|
|
|
437
451
|
}
|
|
438
452
|
async import(trial) {
|
|
439
453
|
const request = importTrialRequestSchema.parse(trial);
|
|
440
|
-
const response = await this.api.fetch(`/api/
|
|
454
|
+
const response = await this.api.fetch(`/api/trials/import`, "POST", request);
|
|
441
455
|
return trialSchema.parse(response.data);
|
|
442
456
|
}
|
|
443
457
|
};
|
|
@@ -460,6 +474,7 @@ var MoonbaseClient = class {
|
|
|
460
474
|
ActivationMethod,
|
|
461
475
|
ActivationRequestStatus,
|
|
462
476
|
ActivationStatus,
|
|
477
|
+
ConflictError,
|
|
463
478
|
LicenseStatus,
|
|
464
479
|
MoonbaseClient,
|
|
465
480
|
MoonbaseError,
|
package/dist/index.d.cts
CHANGED
|
@@ -956,20 +956,46 @@ declare class TrialEndpoints {
|
|
|
956
956
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
-
declare
|
|
960
|
-
|
|
959
|
+
declare const problemDetailsSchema: z.ZodObject<{
|
|
960
|
+
type: z.ZodString;
|
|
961
|
+
title: z.ZodString;
|
|
962
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
963
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
964
|
+
status: z.ZodNumber;
|
|
965
|
+
}, "strip", z.ZodTypeAny, {
|
|
966
|
+
type: string;
|
|
967
|
+
title: string;
|
|
968
|
+
status: number;
|
|
969
|
+
detail?: string | undefined;
|
|
970
|
+
instance?: string | undefined;
|
|
971
|
+
}, {
|
|
972
|
+
type: string;
|
|
973
|
+
title: string;
|
|
974
|
+
status: number;
|
|
975
|
+
detail?: string | undefined;
|
|
976
|
+
instance?: string | undefined;
|
|
977
|
+
}>;
|
|
978
|
+
type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
979
|
+
|
|
980
|
+
declare class MoonbaseError extends Error {
|
|
981
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
982
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
961
983
|
}
|
|
962
|
-
declare class
|
|
963
|
-
|
|
984
|
+
declare class NotAuthorizedError extends MoonbaseError {
|
|
985
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
986
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
964
987
|
}
|
|
965
|
-
declare class
|
|
966
|
-
|
|
988
|
+
declare class NotAuthenticatedError extends MoonbaseError {
|
|
989
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
990
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
967
991
|
}
|
|
968
|
-
declare class
|
|
969
|
-
readonly
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
992
|
+
declare class NotFoundError extends MoonbaseError {
|
|
993
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
994
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
995
|
+
}
|
|
996
|
+
declare class ConflictError extends MoonbaseError {
|
|
997
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
998
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
973
999
|
}
|
|
974
1000
|
|
|
975
1001
|
interface MoonbaseConfiguration {
|
|
@@ -986,4 +1012,4 @@ declare class MoonbaseClient {
|
|
|
986
1012
|
trials: TrialEndpoints;
|
|
987
1013
|
}
|
|
988
1014
|
|
|
989
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
1015
|
+
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, ConflictError, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -956,20 +956,46 @@ declare class TrialEndpoints {
|
|
|
956
956
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
-
declare
|
|
960
|
-
|
|
959
|
+
declare const problemDetailsSchema: z.ZodObject<{
|
|
960
|
+
type: z.ZodString;
|
|
961
|
+
title: z.ZodString;
|
|
962
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
963
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
964
|
+
status: z.ZodNumber;
|
|
965
|
+
}, "strip", z.ZodTypeAny, {
|
|
966
|
+
type: string;
|
|
967
|
+
title: string;
|
|
968
|
+
status: number;
|
|
969
|
+
detail?: string | undefined;
|
|
970
|
+
instance?: string | undefined;
|
|
971
|
+
}, {
|
|
972
|
+
type: string;
|
|
973
|
+
title: string;
|
|
974
|
+
status: number;
|
|
975
|
+
detail?: string | undefined;
|
|
976
|
+
instance?: string | undefined;
|
|
977
|
+
}>;
|
|
978
|
+
type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
979
|
+
|
|
980
|
+
declare class MoonbaseError extends Error {
|
|
981
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
982
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
961
983
|
}
|
|
962
|
-
declare class
|
|
963
|
-
|
|
984
|
+
declare class NotAuthorizedError extends MoonbaseError {
|
|
985
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
986
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
964
987
|
}
|
|
965
|
-
declare class
|
|
966
|
-
|
|
988
|
+
declare class NotAuthenticatedError extends MoonbaseError {
|
|
989
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
990
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
967
991
|
}
|
|
968
|
-
declare class
|
|
969
|
-
readonly
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
992
|
+
declare class NotFoundError extends MoonbaseError {
|
|
993
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
994
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
995
|
+
}
|
|
996
|
+
declare class ConflictError extends MoonbaseError {
|
|
997
|
+
readonly problemDetails: ProblemDetails | undefined;
|
|
998
|
+
constructor(problemDetails: ProblemDetails | undefined);
|
|
973
999
|
}
|
|
974
1000
|
|
|
975
1001
|
interface MoonbaseConfiguration {
|
|
@@ -986,4 +1012,4 @@ declare class MoonbaseClient {
|
|
|
986
1012
|
trials: TrialEndpoints;
|
|
987
1013
|
}
|
|
988
1014
|
|
|
989
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
1015
|
+
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, ConflictError, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
package/dist/index.js
CHANGED
|
@@ -244,32 +244,41 @@ import fetch from "cross-fetch";
|
|
|
244
244
|
import { z as z7 } from "zod";
|
|
245
245
|
|
|
246
246
|
// src/utils/errors.ts
|
|
247
|
-
var
|
|
248
|
-
constructor() {
|
|
247
|
+
var MoonbaseError = class extends Error {
|
|
248
|
+
constructor(problemDetails) {
|
|
249
|
+
var _a, _b;
|
|
249
250
|
super();
|
|
251
|
+
this.problemDetails = problemDetails;
|
|
252
|
+
this.name = "MoonbaseError";
|
|
253
|
+
this.message = (_b = (_a = problemDetails == null ? void 0 : problemDetails.detail) != null ? _a : problemDetails == null ? void 0 : problemDetails.title) != null ? _b : "An unknown error occurred";
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var NotAuthorizedError = class extends MoonbaseError {
|
|
257
|
+
constructor(problemDetails) {
|
|
258
|
+
super(problemDetails);
|
|
259
|
+
this.problemDetails = problemDetails;
|
|
250
260
|
this.name = "NotAuthorizedError";
|
|
251
261
|
}
|
|
252
262
|
};
|
|
253
|
-
var NotAuthenticatedError = class extends
|
|
254
|
-
constructor() {
|
|
255
|
-
super();
|
|
263
|
+
var NotAuthenticatedError = class extends MoonbaseError {
|
|
264
|
+
constructor(problemDetails) {
|
|
265
|
+
super(problemDetails);
|
|
266
|
+
this.problemDetails = problemDetails;
|
|
256
267
|
this.name = "NotAuthenticatedError";
|
|
257
268
|
}
|
|
258
269
|
};
|
|
259
|
-
var NotFoundError = class extends
|
|
260
|
-
constructor() {
|
|
261
|
-
super();
|
|
270
|
+
var NotFoundError = class extends MoonbaseError {
|
|
271
|
+
constructor(problemDetails) {
|
|
272
|
+
super(problemDetails);
|
|
273
|
+
this.problemDetails = problemDetails;
|
|
262
274
|
this.name = "NotFoundError";
|
|
263
275
|
}
|
|
264
276
|
};
|
|
265
|
-
var
|
|
266
|
-
constructor(
|
|
267
|
-
super();
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
270
|
-
this.status = status;
|
|
271
|
-
this.name = "MoonbaseError";
|
|
272
|
-
this.message = detail != null ? detail : title;
|
|
277
|
+
var ConflictError = class extends MoonbaseError {
|
|
278
|
+
constructor(problemDetails) {
|
|
279
|
+
super(problemDetails);
|
|
280
|
+
this.problemDetails = problemDetails;
|
|
281
|
+
this.name = "ConflictError";
|
|
273
282
|
}
|
|
274
283
|
};
|
|
275
284
|
|
|
@@ -278,23 +287,27 @@ var problemDetailsSchema = z7.object({
|
|
|
278
287
|
type: z7.string(),
|
|
279
288
|
title: z7.string(),
|
|
280
289
|
detail: z7.string().optional(),
|
|
290
|
+
instance: z7.string().optional(),
|
|
281
291
|
status: z7.number()
|
|
282
292
|
});
|
|
283
293
|
async function handleResponseProblem(response) {
|
|
284
|
-
if (response.status === 404)
|
|
285
|
-
throw new NotFoundError();
|
|
286
|
-
if (response.status === 401)
|
|
287
|
-
throw new NotAuthenticatedError();
|
|
288
|
-
if (response.status === 403)
|
|
289
|
-
throw new NotAuthorizedError();
|
|
290
294
|
let problemDetails;
|
|
291
295
|
try {
|
|
292
296
|
const json = await response.json();
|
|
293
|
-
|
|
297
|
+
if (json)
|
|
298
|
+
problemDetails = problemDetailsSchema.parse(json);
|
|
294
299
|
} catch (e) {
|
|
295
300
|
throw new Error("An unknown problem occurred");
|
|
296
301
|
}
|
|
297
|
-
|
|
302
|
+
if (response.status === 404)
|
|
303
|
+
throw new NotFoundError(problemDetails);
|
|
304
|
+
if (response.status === 401)
|
|
305
|
+
throw new NotAuthenticatedError(problemDetails);
|
|
306
|
+
if (response.status === 403)
|
|
307
|
+
throw new NotAuthorizedError(problemDetails);
|
|
308
|
+
if (response.status === 404)
|
|
309
|
+
throw new ConflictError(problemDetails);
|
|
310
|
+
throw new MoonbaseError(problemDetails);
|
|
298
311
|
}
|
|
299
312
|
|
|
300
313
|
// src/utils/api.ts
|
|
@@ -391,7 +404,7 @@ var TrialEndpoints = class {
|
|
|
391
404
|
}
|
|
392
405
|
async import(trial) {
|
|
393
406
|
const request = importTrialRequestSchema.parse(trial);
|
|
394
|
-
const response = await this.api.fetch(`/api/
|
|
407
|
+
const response = await this.api.fetch(`/api/trials/import`, "POST", request);
|
|
395
408
|
return trialSchema.parse(response.data);
|
|
396
409
|
}
|
|
397
410
|
};
|
|
@@ -413,6 +426,7 @@ export {
|
|
|
413
426
|
ActivationMethod,
|
|
414
427
|
ActivationRequestStatus,
|
|
415
428
|
ActivationStatus,
|
|
429
|
+
ConflictError,
|
|
416
430
|
LicenseStatus,
|
|
417
431
|
MoonbaseClient,
|
|
418
432
|
MoonbaseError,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.115",
|
|
5
5
|
"description": "Package to let you integrate backends with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|