@moonbase.sh/api 0.1.112 → 0.1.114

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 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,
@@ -63,6 +64,7 @@ var communicationPreferencesSchema = import_zod.z.object({
63
64
  });
64
65
  var customerSchema = import_zod.z.object({
65
66
  id: import_zod.z.string(),
67
+ externalId: import_zod.z.string().optional(),
66
68
  name: import_zod.z.string(),
67
69
  businessName: import_zod.z.string().nullable(),
68
70
  taxId: import_zod.z.string().nullable(),
@@ -79,6 +81,7 @@ var customerSchema = import_zod.z.object({
79
81
  var importCustomerRequestSchema = import_zod.z.object({
80
82
  name: import_zod.z.string(),
81
83
  email: import_zod.z.string(),
84
+ externalId: import_zod.z.string().optional(),
82
85
  password: import_zod.z.string().optional(),
83
86
  address: addressSchema.optional()
84
87
  });
@@ -174,6 +177,7 @@ var TrialStatus = /* @__PURE__ */ ((TrialStatus2) => {
174
177
  // src/trials/schemas.ts
175
178
  var trialSchema = import_zod4.z.object({
176
179
  id: import_zod4.z.string(),
180
+ externalId: import_zod4.z.string().optional(),
177
181
  productId: import_zod4.z.string(),
178
182
  deviceName: import_zod4.z.string(),
179
183
  deviceSignature: import_zod4.z.string(),
@@ -184,6 +188,7 @@ var trialSchema = import_zod4.z.object({
184
188
  });
185
189
  var importTrialRequestSchema = import_zod4.z.object({
186
190
  productId: import_zod4.z.string(),
191
+ externalId: import_zod4.z.string().optional(),
187
192
  deviceName: import_zod4.z.string(),
188
193
  deviceSignature: import_zod4.z.string(),
189
194
  expiresAt: import_zod4.z.date(),
@@ -286,32 +291,41 @@ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
286
291
  var import_zod7 = require("zod");
287
292
 
288
293
  // src/utils/errors.ts
289
- var NotAuthorizedError = class extends Error {
290
- constructor() {
294
+ var MoonbaseError = class extends Error {
295
+ constructor(problemDetails) {
296
+ var _a, _b;
291
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;
292
307
  this.name = "NotAuthorizedError";
293
308
  }
294
309
  };
295
- var NotAuthenticatedError = class extends Error {
296
- constructor() {
297
- super();
310
+ var NotAuthenticatedError = class extends MoonbaseError {
311
+ constructor(problemDetails) {
312
+ super(problemDetails);
313
+ this.problemDetails = problemDetails;
298
314
  this.name = "NotAuthenticatedError";
299
315
  }
300
316
  };
301
- var NotFoundError = class extends Error {
302
- constructor() {
303
- super();
317
+ var NotFoundError = class extends MoonbaseError {
318
+ constructor(problemDetails) {
319
+ super(problemDetails);
320
+ this.problemDetails = problemDetails;
304
321
  this.name = "NotFoundError";
305
322
  }
306
323
  };
307
- var MoonbaseError = class extends Error {
308
- constructor(title, detail, status) {
309
- super();
310
- this.title = title;
311
- this.detail = detail;
312
- this.status = status;
313
- this.name = "MoonbaseError";
314
- 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";
315
329
  }
316
330
  };
317
331
 
@@ -320,23 +334,27 @@ var problemDetailsSchema = import_zod7.z.object({
320
334
  type: import_zod7.z.string(),
321
335
  title: import_zod7.z.string(),
322
336
  detail: import_zod7.z.string().optional(),
337
+ instance: import_zod7.z.string().optional(),
323
338
  status: import_zod7.z.number()
324
339
  });
325
340
  async function handleResponseProblem(response) {
326
- if (response.status === 404)
327
- throw new NotFoundError();
328
- if (response.status === 401)
329
- throw new NotAuthenticatedError();
330
- if (response.status === 403)
331
- throw new NotAuthorizedError();
332
341
  let problemDetails;
333
342
  try {
334
343
  const json = await response.json();
335
- problemDetails = problemDetailsSchema.parse(json);
344
+ if (json)
345
+ problemDetails = problemDetailsSchema.parse(json);
336
346
  } catch (e) {
337
347
  throw new Error("An unknown problem occurred");
338
348
  }
339
- throw new MoonbaseError(problemDetails.title, problemDetails.detail, problemDetails.status);
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);
340
358
  }
341
359
 
342
360
  // src/utils/api.ts
@@ -456,6 +474,7 @@ var MoonbaseClient = class {
456
474
  ActivationMethod,
457
475
  ActivationRequestStatus,
458
476
  ActivationStatus,
477
+ ConflictError,
459
478
  LicenseStatus,
460
479
  MoonbaseClient,
461
480
  MoonbaseError,
package/dist/index.d.cts CHANGED
@@ -121,6 +121,7 @@ declare const activationRequestSchema: z.ZodObject<{
121
121
  }>>;
122
122
  trial: z.ZodOptional<z.ZodObject<{
123
123
  id: z.ZodString;
124
+ externalId: z.ZodOptional<z.ZodString>;
124
125
  productId: z.ZodString;
125
126
  deviceName: z.ZodString;
126
127
  deviceSignature: z.ZodString;
@@ -136,6 +137,7 @@ declare const activationRequestSchema: z.ZodObject<{
136
137
  deviceName: string;
137
138
  deviceSignature: string;
138
139
  expiresAt: Date;
140
+ externalId?: string | undefined;
139
141
  ownerId?: string | undefined;
140
142
  }, {
141
143
  status: TrialStatus;
@@ -145,10 +147,12 @@ declare const activationRequestSchema: z.ZodObject<{
145
147
  deviceName: string;
146
148
  deviceSignature: string;
147
149
  expiresAt: Date;
150
+ externalId?: string | undefined;
148
151
  ownerId?: string | undefined;
149
152
  }>>;
150
153
  customer: z.ZodOptional<z.ZodObject<{
151
154
  id: z.ZodString;
155
+ externalId: z.ZodOptional<z.ZodString>;
152
156
  name: z.ZodString;
153
157
  businessName: z.ZodNullable<z.ZodString>;
154
158
  taxId: z.ZodNullable<z.ZodString>;
@@ -211,6 +215,7 @@ declare const activationRequestSchema: z.ZodObject<{
211
215
  communicationPreferences: {
212
216
  newsletterOptIn: boolean;
213
217
  };
218
+ externalId?: string | undefined;
214
219
  }, {
215
220
  id: string;
216
221
  name: string;
@@ -234,6 +239,7 @@ declare const activationRequestSchema: z.ZodObject<{
234
239
  communicationPreferences: {
235
240
  newsletterOptIn: boolean;
236
241
  };
242
+ externalId?: string | undefined;
237
243
  }>>;
238
244
  }, "strip", z.ZodTypeAny, {
239
245
  status: ActivationRequestStatus;
@@ -277,6 +283,7 @@ declare const activationRequestSchema: z.ZodObject<{
277
283
  deviceName: string;
278
284
  deviceSignature: string;
279
285
  expiresAt: Date;
286
+ externalId?: string | undefined;
280
287
  ownerId?: string | undefined;
281
288
  } | undefined;
282
289
  customer?: {
@@ -302,6 +309,7 @@ declare const activationRequestSchema: z.ZodObject<{
302
309
  communicationPreferences: {
303
310
  newsletterOptIn: boolean;
304
311
  };
312
+ externalId?: string | undefined;
305
313
  } | undefined;
306
314
  }, {
307
315
  status: ActivationRequestStatus;
@@ -345,6 +353,7 @@ declare const activationRequestSchema: z.ZodObject<{
345
353
  deviceName: string;
346
354
  deviceSignature: string;
347
355
  expiresAt: Date;
356
+ externalId?: string | undefined;
348
357
  ownerId?: string | undefined;
349
358
  } | undefined;
350
359
  customer?: {
@@ -370,6 +379,7 @@ declare const activationRequestSchema: z.ZodObject<{
370
379
  communicationPreferences: {
371
380
  newsletterOptIn: boolean;
372
381
  };
382
+ externalId?: string | undefined;
373
383
  } | undefined;
374
384
  }>;
375
385
 
@@ -392,6 +402,7 @@ declare class ActivationRequestEndpoints {
392
402
 
393
403
  declare const customerSchema: z.ZodObject<{
394
404
  id: z.ZodString;
405
+ externalId: z.ZodOptional<z.ZodString>;
395
406
  name: z.ZodString;
396
407
  businessName: z.ZodNullable<z.ZodString>;
397
408
  taxId: z.ZodNullable<z.ZodString>;
@@ -454,6 +465,7 @@ declare const customerSchema: z.ZodObject<{
454
465
  communicationPreferences: {
455
466
  newsletterOptIn: boolean;
456
467
  };
468
+ externalId?: string | undefined;
457
469
  }, {
458
470
  id: string;
459
471
  name: string;
@@ -477,10 +489,12 @@ declare const customerSchema: z.ZodObject<{
477
489
  communicationPreferences: {
478
490
  newsletterOptIn: boolean;
479
491
  };
492
+ externalId?: string | undefined;
480
493
  }>;
481
494
  declare const importCustomerRequestSchema: z.ZodObject<{
482
495
  name: z.ZodString;
483
496
  email: z.ZodString;
497
+ externalId: z.ZodOptional<z.ZodString>;
484
498
  password: z.ZodOptional<z.ZodString>;
485
499
  address: z.ZodOptional<z.ZodObject<{
486
500
  countryCode: z.ZodString;
@@ -507,6 +521,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
507
521
  }, "strip", z.ZodTypeAny, {
508
522
  name: string;
509
523
  email: string;
524
+ externalId?: string | undefined;
510
525
  password?: string | undefined;
511
526
  address?: {
512
527
  countryCode: string;
@@ -519,6 +534,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
519
534
  }, {
520
535
  name: string;
521
536
  email: string;
537
+ externalId?: string | undefined;
522
538
  password?: string | undefined;
523
539
  address?: {
524
540
  countryCode: string;
@@ -865,6 +881,7 @@ declare class ProductEndpoints {
865
881
 
866
882
  declare const trialSchema: z.ZodObject<{
867
883
  id: z.ZodString;
884
+ externalId: z.ZodOptional<z.ZodString>;
868
885
  productId: z.ZodString;
869
886
  deviceName: z.ZodString;
870
887
  deviceSignature: z.ZodString;
@@ -880,6 +897,7 @@ declare const trialSchema: z.ZodObject<{
880
897
  deviceName: string;
881
898
  deviceSignature: string;
882
899
  expiresAt: Date;
900
+ externalId?: string | undefined;
883
901
  ownerId?: string | undefined;
884
902
  }, {
885
903
  status: TrialStatus;
@@ -889,10 +907,12 @@ declare const trialSchema: z.ZodObject<{
889
907
  deviceName: string;
890
908
  deviceSignature: string;
891
909
  expiresAt: Date;
910
+ externalId?: string | undefined;
892
911
  ownerId?: string | undefined;
893
912
  }>;
894
913
  declare const importTrialRequestSchema: z.ZodObject<{
895
914
  productId: z.ZodString;
915
+ externalId: z.ZodOptional<z.ZodString>;
896
916
  deviceName: z.ZodString;
897
917
  deviceSignature: z.ZodString;
898
918
  expiresAt: z.ZodDate;
@@ -904,6 +924,7 @@ declare const importTrialRequestSchema: z.ZodObject<{
904
924
  deviceName: string;
905
925
  deviceSignature: string;
906
926
  expiresAt: Date;
927
+ externalId?: string | undefined;
907
928
  customerId?: string | undefined;
908
929
  lastValidation?: Date | undefined;
909
930
  createdAt?: Date | undefined;
@@ -912,6 +933,7 @@ declare const importTrialRequestSchema: z.ZodObject<{
912
933
  deviceName: string;
913
934
  deviceSignature: string;
914
935
  expiresAt: Date;
936
+ externalId?: string | undefined;
915
937
  customerId?: string | undefined;
916
938
  lastValidation?: Date | undefined;
917
939
  createdAt?: Date | undefined;
@@ -934,20 +956,46 @@ declare class TrialEndpoints {
934
956
  import(trial: ImportTrialRequest): Promise<Trial>;
935
957
  }
936
958
 
937
- declare class NotAuthorizedError extends Error {
938
- constructor();
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);
939
983
  }
940
- declare class NotAuthenticatedError extends Error {
941
- constructor();
984
+ declare class NotAuthorizedError extends MoonbaseError {
985
+ readonly problemDetails: ProblemDetails | undefined;
986
+ constructor(problemDetails: ProblemDetails | undefined);
942
987
  }
943
- declare class NotFoundError extends Error {
944
- constructor();
988
+ declare class NotAuthenticatedError extends MoonbaseError {
989
+ readonly problemDetails: ProblemDetails | undefined;
990
+ constructor(problemDetails: ProblemDetails | undefined);
945
991
  }
946
- declare class MoonbaseError extends Error {
947
- readonly title: string;
948
- readonly detail: string | undefined;
949
- readonly status: number;
950
- constructor(title: string, detail: string | undefined, status: number);
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);
951
999
  }
952
1000
 
953
1001
  interface MoonbaseConfiguration {
@@ -964,4 +1012,4 @@ declare class MoonbaseClient {
964
1012
  trials: TrialEndpoints;
965
1013
  }
966
1014
 
967
- 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
@@ -121,6 +121,7 @@ declare const activationRequestSchema: z.ZodObject<{
121
121
  }>>;
122
122
  trial: z.ZodOptional<z.ZodObject<{
123
123
  id: z.ZodString;
124
+ externalId: z.ZodOptional<z.ZodString>;
124
125
  productId: z.ZodString;
125
126
  deviceName: z.ZodString;
126
127
  deviceSignature: z.ZodString;
@@ -136,6 +137,7 @@ declare const activationRequestSchema: z.ZodObject<{
136
137
  deviceName: string;
137
138
  deviceSignature: string;
138
139
  expiresAt: Date;
140
+ externalId?: string | undefined;
139
141
  ownerId?: string | undefined;
140
142
  }, {
141
143
  status: TrialStatus;
@@ -145,10 +147,12 @@ declare const activationRequestSchema: z.ZodObject<{
145
147
  deviceName: string;
146
148
  deviceSignature: string;
147
149
  expiresAt: Date;
150
+ externalId?: string | undefined;
148
151
  ownerId?: string | undefined;
149
152
  }>>;
150
153
  customer: z.ZodOptional<z.ZodObject<{
151
154
  id: z.ZodString;
155
+ externalId: z.ZodOptional<z.ZodString>;
152
156
  name: z.ZodString;
153
157
  businessName: z.ZodNullable<z.ZodString>;
154
158
  taxId: z.ZodNullable<z.ZodString>;
@@ -211,6 +215,7 @@ declare const activationRequestSchema: z.ZodObject<{
211
215
  communicationPreferences: {
212
216
  newsletterOptIn: boolean;
213
217
  };
218
+ externalId?: string | undefined;
214
219
  }, {
215
220
  id: string;
216
221
  name: string;
@@ -234,6 +239,7 @@ declare const activationRequestSchema: z.ZodObject<{
234
239
  communicationPreferences: {
235
240
  newsletterOptIn: boolean;
236
241
  };
242
+ externalId?: string | undefined;
237
243
  }>>;
238
244
  }, "strip", z.ZodTypeAny, {
239
245
  status: ActivationRequestStatus;
@@ -277,6 +283,7 @@ declare const activationRequestSchema: z.ZodObject<{
277
283
  deviceName: string;
278
284
  deviceSignature: string;
279
285
  expiresAt: Date;
286
+ externalId?: string | undefined;
280
287
  ownerId?: string | undefined;
281
288
  } | undefined;
282
289
  customer?: {
@@ -302,6 +309,7 @@ declare const activationRequestSchema: z.ZodObject<{
302
309
  communicationPreferences: {
303
310
  newsletterOptIn: boolean;
304
311
  };
312
+ externalId?: string | undefined;
305
313
  } | undefined;
306
314
  }, {
307
315
  status: ActivationRequestStatus;
@@ -345,6 +353,7 @@ declare const activationRequestSchema: z.ZodObject<{
345
353
  deviceName: string;
346
354
  deviceSignature: string;
347
355
  expiresAt: Date;
356
+ externalId?: string | undefined;
348
357
  ownerId?: string | undefined;
349
358
  } | undefined;
350
359
  customer?: {
@@ -370,6 +379,7 @@ declare const activationRequestSchema: z.ZodObject<{
370
379
  communicationPreferences: {
371
380
  newsletterOptIn: boolean;
372
381
  };
382
+ externalId?: string | undefined;
373
383
  } | undefined;
374
384
  }>;
375
385
 
@@ -392,6 +402,7 @@ declare class ActivationRequestEndpoints {
392
402
 
393
403
  declare const customerSchema: z.ZodObject<{
394
404
  id: z.ZodString;
405
+ externalId: z.ZodOptional<z.ZodString>;
395
406
  name: z.ZodString;
396
407
  businessName: z.ZodNullable<z.ZodString>;
397
408
  taxId: z.ZodNullable<z.ZodString>;
@@ -454,6 +465,7 @@ declare const customerSchema: z.ZodObject<{
454
465
  communicationPreferences: {
455
466
  newsletterOptIn: boolean;
456
467
  };
468
+ externalId?: string | undefined;
457
469
  }, {
458
470
  id: string;
459
471
  name: string;
@@ -477,10 +489,12 @@ declare const customerSchema: z.ZodObject<{
477
489
  communicationPreferences: {
478
490
  newsletterOptIn: boolean;
479
491
  };
492
+ externalId?: string | undefined;
480
493
  }>;
481
494
  declare const importCustomerRequestSchema: z.ZodObject<{
482
495
  name: z.ZodString;
483
496
  email: z.ZodString;
497
+ externalId: z.ZodOptional<z.ZodString>;
484
498
  password: z.ZodOptional<z.ZodString>;
485
499
  address: z.ZodOptional<z.ZodObject<{
486
500
  countryCode: z.ZodString;
@@ -507,6 +521,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
507
521
  }, "strip", z.ZodTypeAny, {
508
522
  name: string;
509
523
  email: string;
524
+ externalId?: string | undefined;
510
525
  password?: string | undefined;
511
526
  address?: {
512
527
  countryCode: string;
@@ -519,6 +534,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
519
534
  }, {
520
535
  name: string;
521
536
  email: string;
537
+ externalId?: string | undefined;
522
538
  password?: string | undefined;
523
539
  address?: {
524
540
  countryCode: string;
@@ -865,6 +881,7 @@ declare class ProductEndpoints {
865
881
 
866
882
  declare const trialSchema: z.ZodObject<{
867
883
  id: z.ZodString;
884
+ externalId: z.ZodOptional<z.ZodString>;
868
885
  productId: z.ZodString;
869
886
  deviceName: z.ZodString;
870
887
  deviceSignature: z.ZodString;
@@ -880,6 +897,7 @@ declare const trialSchema: z.ZodObject<{
880
897
  deviceName: string;
881
898
  deviceSignature: string;
882
899
  expiresAt: Date;
900
+ externalId?: string | undefined;
883
901
  ownerId?: string | undefined;
884
902
  }, {
885
903
  status: TrialStatus;
@@ -889,10 +907,12 @@ declare const trialSchema: z.ZodObject<{
889
907
  deviceName: string;
890
908
  deviceSignature: string;
891
909
  expiresAt: Date;
910
+ externalId?: string | undefined;
892
911
  ownerId?: string | undefined;
893
912
  }>;
894
913
  declare const importTrialRequestSchema: z.ZodObject<{
895
914
  productId: z.ZodString;
915
+ externalId: z.ZodOptional<z.ZodString>;
896
916
  deviceName: z.ZodString;
897
917
  deviceSignature: z.ZodString;
898
918
  expiresAt: z.ZodDate;
@@ -904,6 +924,7 @@ declare const importTrialRequestSchema: z.ZodObject<{
904
924
  deviceName: string;
905
925
  deviceSignature: string;
906
926
  expiresAt: Date;
927
+ externalId?: string | undefined;
907
928
  customerId?: string | undefined;
908
929
  lastValidation?: Date | undefined;
909
930
  createdAt?: Date | undefined;
@@ -912,6 +933,7 @@ declare const importTrialRequestSchema: z.ZodObject<{
912
933
  deviceName: string;
913
934
  deviceSignature: string;
914
935
  expiresAt: Date;
936
+ externalId?: string | undefined;
915
937
  customerId?: string | undefined;
916
938
  lastValidation?: Date | undefined;
917
939
  createdAt?: Date | undefined;
@@ -934,20 +956,46 @@ declare class TrialEndpoints {
934
956
  import(trial: ImportTrialRequest): Promise<Trial>;
935
957
  }
936
958
 
937
- declare class NotAuthorizedError extends Error {
938
- constructor();
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);
939
983
  }
940
- declare class NotAuthenticatedError extends Error {
941
- constructor();
984
+ declare class NotAuthorizedError extends MoonbaseError {
985
+ readonly problemDetails: ProblemDetails | undefined;
986
+ constructor(problemDetails: ProblemDetails | undefined);
942
987
  }
943
- declare class NotFoundError extends Error {
944
- constructor();
988
+ declare class NotAuthenticatedError extends MoonbaseError {
989
+ readonly problemDetails: ProblemDetails | undefined;
990
+ constructor(problemDetails: ProblemDetails | undefined);
945
991
  }
946
- declare class MoonbaseError extends Error {
947
- readonly title: string;
948
- readonly detail: string | undefined;
949
- readonly status: number;
950
- constructor(title: string, detail: string | undefined, status: number);
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);
951
999
  }
952
1000
 
953
1001
  interface MoonbaseConfiguration {
@@ -964,4 +1012,4 @@ declare class MoonbaseClient {
964
1012
  trials: TrialEndpoints;
965
1013
  }
966
1014
 
967
- 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
@@ -17,6 +17,7 @@ var communicationPreferencesSchema = z.object({
17
17
  });
18
18
  var customerSchema = z.object({
19
19
  id: z.string(),
20
+ externalId: z.string().optional(),
20
21
  name: z.string(),
21
22
  businessName: z.string().nullable(),
22
23
  taxId: z.string().nullable(),
@@ -33,6 +34,7 @@ var customerSchema = z.object({
33
34
  var importCustomerRequestSchema = z.object({
34
35
  name: z.string(),
35
36
  email: z.string(),
37
+ externalId: z.string().optional(),
36
38
  password: z.string().optional(),
37
39
  address: addressSchema.optional()
38
40
  });
@@ -128,6 +130,7 @@ var TrialStatus = /* @__PURE__ */ ((TrialStatus2) => {
128
130
  // src/trials/schemas.ts
129
131
  var trialSchema = z4.object({
130
132
  id: z4.string(),
133
+ externalId: z4.string().optional(),
131
134
  productId: z4.string(),
132
135
  deviceName: z4.string(),
133
136
  deviceSignature: z4.string(),
@@ -138,6 +141,7 @@ var trialSchema = z4.object({
138
141
  });
139
142
  var importTrialRequestSchema = z4.object({
140
143
  productId: z4.string(),
144
+ externalId: z4.string().optional(),
141
145
  deviceName: z4.string(),
142
146
  deviceSignature: z4.string(),
143
147
  expiresAt: z4.date(),
@@ -240,32 +244,41 @@ import fetch from "cross-fetch";
240
244
  import { z as z7 } from "zod";
241
245
 
242
246
  // src/utils/errors.ts
243
- var NotAuthorizedError = class extends Error {
244
- constructor() {
247
+ var MoonbaseError = class extends Error {
248
+ constructor(problemDetails) {
249
+ var _a, _b;
245
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;
246
260
  this.name = "NotAuthorizedError";
247
261
  }
248
262
  };
249
- var NotAuthenticatedError = class extends Error {
250
- constructor() {
251
- super();
263
+ var NotAuthenticatedError = class extends MoonbaseError {
264
+ constructor(problemDetails) {
265
+ super(problemDetails);
266
+ this.problemDetails = problemDetails;
252
267
  this.name = "NotAuthenticatedError";
253
268
  }
254
269
  };
255
- var NotFoundError = class extends Error {
256
- constructor() {
257
- super();
270
+ var NotFoundError = class extends MoonbaseError {
271
+ constructor(problemDetails) {
272
+ super(problemDetails);
273
+ this.problemDetails = problemDetails;
258
274
  this.name = "NotFoundError";
259
275
  }
260
276
  };
261
- var MoonbaseError = class extends Error {
262
- constructor(title, detail, status) {
263
- super();
264
- this.title = title;
265
- this.detail = detail;
266
- this.status = status;
267
- this.name = "MoonbaseError";
268
- 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";
269
282
  }
270
283
  };
271
284
 
@@ -274,23 +287,27 @@ var problemDetailsSchema = z7.object({
274
287
  type: z7.string(),
275
288
  title: z7.string(),
276
289
  detail: z7.string().optional(),
290
+ instance: z7.string().optional(),
277
291
  status: z7.number()
278
292
  });
279
293
  async function handleResponseProblem(response) {
280
- if (response.status === 404)
281
- throw new NotFoundError();
282
- if (response.status === 401)
283
- throw new NotAuthenticatedError();
284
- if (response.status === 403)
285
- throw new NotAuthorizedError();
286
294
  let problemDetails;
287
295
  try {
288
296
  const json = await response.json();
289
- problemDetails = problemDetailsSchema.parse(json);
297
+ if (json)
298
+ problemDetails = problemDetailsSchema.parse(json);
290
299
  } catch (e) {
291
300
  throw new Error("An unknown problem occurred");
292
301
  }
293
- throw new MoonbaseError(problemDetails.title, problemDetails.detail, problemDetails.status);
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);
294
311
  }
295
312
 
296
313
  // src/utils/api.ts
@@ -409,6 +426,7 @@ export {
409
426
  ActivationMethod,
410
427
  ActivationRequestStatus,
411
428
  ActivationStatus,
429
+ ConflictError,
412
430
  LicenseStatus,
413
431
  MoonbaseClient,
414
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.112",
4
+ "version": "0.1.114",
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",