@moonbase.sh/api 0.1.110 → 0.1.112
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 +75 -10
- package/dist/index.d.cts +251 -91
- package/dist/index.d.ts +251 -91
- package/dist/index.js +75 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -76,6 +76,12 @@ var customerSchema = import_zod.z.object({
|
|
|
76
76
|
address: addressSchema.nullable(),
|
|
77
77
|
communicationPreferences: communicationPreferencesSchema
|
|
78
78
|
});
|
|
79
|
+
var importCustomerRequestSchema = import_zod.z.object({
|
|
80
|
+
name: import_zod.z.string(),
|
|
81
|
+
email: import_zod.z.string(),
|
|
82
|
+
password: import_zod.z.string().optional(),
|
|
83
|
+
address: addressSchema.optional()
|
|
84
|
+
});
|
|
79
85
|
|
|
80
86
|
// src/licenses/schemas.ts
|
|
81
87
|
var import_zod2 = require("zod");
|
|
@@ -100,6 +106,7 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
100
106
|
// src/licenses/schemas.ts
|
|
101
107
|
var licenseSchema = import_zod2.z.object({
|
|
102
108
|
id: import_zod2.z.string(),
|
|
109
|
+
externalId: import_zod2.z.string().optional(),
|
|
103
110
|
productId: import_zod2.z.string(),
|
|
104
111
|
ownerId: import_zod2.z.string(),
|
|
105
112
|
status: import_zod2.z.nativeEnum(LicenseStatus),
|
|
@@ -116,6 +123,20 @@ var licenseActivationSchema = import_zod2.z.object({
|
|
|
116
123
|
lastValidatedAt: import_zod2.z.coerce.date(),
|
|
117
124
|
license: licenseSchema
|
|
118
125
|
});
|
|
126
|
+
var importLicenseRequestSchema = import_zod2.z.object({
|
|
127
|
+
customerId: import_zod2.z.string(),
|
|
128
|
+
productId: import_zod2.z.string(),
|
|
129
|
+
externalId: import_zod2.z.string().optional(),
|
|
130
|
+
createdAt: import_zod2.z.date().optional(),
|
|
131
|
+
maxNumberOfActivations: import_zod2.z.number().optional(),
|
|
132
|
+
offlineActivationsAllowed: import_zod2.z.boolean().optional(),
|
|
133
|
+
activations: import_zod2.z.object({
|
|
134
|
+
activationMethod: import_zod2.z.nativeEnum(ActivationMethod),
|
|
135
|
+
deviceName: import_zod2.z.string(),
|
|
136
|
+
deviceSignature: import_zod2.z.string(),
|
|
137
|
+
lastValidation: import_zod2.z.date().optional()
|
|
138
|
+
}).array().optional()
|
|
139
|
+
});
|
|
119
140
|
|
|
120
141
|
// src/products/schemas.ts
|
|
121
142
|
var import_zod3 = require("zod");
|
|
@@ -161,6 +182,15 @@ var trialSchema = import_zod4.z.object({
|
|
|
161
182
|
lastValidatedAt: import_zod4.z.coerce.date(),
|
|
162
183
|
ownerId: import_zod4.z.string().optional()
|
|
163
184
|
});
|
|
185
|
+
var importTrialRequestSchema = import_zod4.z.object({
|
|
186
|
+
productId: import_zod4.z.string(),
|
|
187
|
+
deviceName: import_zod4.z.string(),
|
|
188
|
+
deviceSignature: import_zod4.z.string(),
|
|
189
|
+
expiresAt: import_zod4.z.date(),
|
|
190
|
+
customerId: import_zod4.z.string().optional(),
|
|
191
|
+
lastValidation: import_zod4.z.date().optional(),
|
|
192
|
+
createdAt: import_zod4.z.date().optional()
|
|
193
|
+
});
|
|
164
194
|
|
|
165
195
|
// src/activationRequests/models.ts
|
|
166
196
|
var ActivationRequestStatus = /* @__PURE__ */ ((ActivationRequestStatus2) => {
|
|
@@ -206,16 +236,10 @@ var CustomerEndpoints = class {
|
|
|
206
236
|
const response = await this.api.fetch(`/api/customers/${idOrEmail}`);
|
|
207
237
|
return customerSchema.parse(response.data);
|
|
208
238
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
constructor(api) {
|
|
214
|
-
this.api = api;
|
|
215
|
-
}
|
|
216
|
-
async validate(licenseId, activationId) {
|
|
217
|
-
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/validate`, "POST");
|
|
218
|
-
return licenseActivationSchema.parse(response.data);
|
|
239
|
+
async import(customer) {
|
|
240
|
+
const request = importCustomerRequestSchema.parse(customer);
|
|
241
|
+
const response = await this.api.fetch(`/api/customers/import`, "POST", request);
|
|
242
|
+
return customerSchema.parse(response.data);
|
|
219
243
|
}
|
|
220
244
|
};
|
|
221
245
|
|
|
@@ -347,6 +371,42 @@ var MoonbaseApi = class {
|
|
|
347
371
|
}
|
|
348
372
|
};
|
|
349
373
|
|
|
374
|
+
// src/licenses/endpoints.ts
|
|
375
|
+
var LicenseEndpoints = class {
|
|
376
|
+
constructor(api) {
|
|
377
|
+
this.api = api;
|
|
378
|
+
}
|
|
379
|
+
async query(opts) {
|
|
380
|
+
const response = await this.api.fetch(`/api/licenses?${objectToQuery(opts)}`);
|
|
381
|
+
return paged(licenseSchema).parse(response.data);
|
|
382
|
+
}
|
|
383
|
+
async get(licenseId) {
|
|
384
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}`);
|
|
385
|
+
return licenseSchema.parse(response.data);
|
|
386
|
+
}
|
|
387
|
+
async import(license) {
|
|
388
|
+
const request = importLicenseRequestSchema.parse(license);
|
|
389
|
+
const response = await this.api.fetch(`/api/licenses/import`, "POST", request);
|
|
390
|
+
return licenseSchema.parse(response.data);
|
|
391
|
+
}
|
|
392
|
+
async revoke(licenseId) {
|
|
393
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/revoke`, "POST");
|
|
394
|
+
return licenseSchema.parse(response.data);
|
|
395
|
+
}
|
|
396
|
+
async queryActivations(licenseId, opts) {
|
|
397
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations?${objectToQuery(opts)}`);
|
|
398
|
+
return paged(licenseActivationSchema).parse(response.data);
|
|
399
|
+
}
|
|
400
|
+
async validateActivation(licenseId, activationId) {
|
|
401
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/validate`, "POST");
|
|
402
|
+
return licenseActivationSchema.parse(response.data);
|
|
403
|
+
}
|
|
404
|
+
async revokeActivation(licenseId, activationId) {
|
|
405
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
|
|
406
|
+
return licenseActivationSchema.parse(response.data);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
350
410
|
// src/products/endpoints.ts
|
|
351
411
|
var ProductEndpoints = class {
|
|
352
412
|
constructor(api) {
|
|
@@ -371,6 +431,11 @@ var TrialEndpoints = class {
|
|
|
371
431
|
const response = await this.api.fetch(`/api/trials/${productId}/request`, "POST", target);
|
|
372
432
|
return trialSchema.parse(response.data);
|
|
373
433
|
}
|
|
434
|
+
async import(trial) {
|
|
435
|
+
const request = importTrialRequestSchema.parse(trial);
|
|
436
|
+
const response = await this.api.fetch(`/api/customers/import`, "POST", request);
|
|
437
|
+
return trialSchema.parse(response.data);
|
|
438
|
+
}
|
|
374
439
|
};
|
|
375
440
|
|
|
376
441
|
// src/index.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -58,6 +58,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
58
58
|
lastValidatedAt: z.ZodDate;
|
|
59
59
|
license: z.ZodObject<{
|
|
60
60
|
id: z.ZodString;
|
|
61
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
61
62
|
productId: z.ZodString;
|
|
62
63
|
ownerId: z.ZodString;
|
|
63
64
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -72,6 +73,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
72
73
|
activeNumberOfActivations: number;
|
|
73
74
|
maxNumberOfActivations: number;
|
|
74
75
|
offlineActivationsAllowed: boolean;
|
|
76
|
+
externalId?: string | undefined;
|
|
75
77
|
}, {
|
|
76
78
|
status: LicenseStatus;
|
|
77
79
|
id: string;
|
|
@@ -80,6 +82,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
80
82
|
activeNumberOfActivations: number;
|
|
81
83
|
maxNumberOfActivations: number;
|
|
82
84
|
offlineActivationsAllowed: boolean;
|
|
85
|
+
externalId?: string | undefined;
|
|
83
86
|
}>;
|
|
84
87
|
}, "strip", z.ZodTypeAny, {
|
|
85
88
|
status: ActivationStatus;
|
|
@@ -96,6 +99,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
96
99
|
activeNumberOfActivations: number;
|
|
97
100
|
maxNumberOfActivations: number;
|
|
98
101
|
offlineActivationsAllowed: boolean;
|
|
102
|
+
externalId?: string | undefined;
|
|
99
103
|
};
|
|
100
104
|
}, {
|
|
101
105
|
status: ActivationStatus;
|
|
@@ -112,6 +116,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
112
116
|
activeNumberOfActivations: number;
|
|
113
117
|
maxNumberOfActivations: number;
|
|
114
118
|
offlineActivationsAllowed: boolean;
|
|
119
|
+
externalId?: string | undefined;
|
|
115
120
|
};
|
|
116
121
|
}>>;
|
|
117
122
|
trial: z.ZodOptional<z.ZodObject<{
|
|
@@ -261,6 +266,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
261
266
|
activeNumberOfActivations: number;
|
|
262
267
|
maxNumberOfActivations: number;
|
|
263
268
|
offlineActivationsAllowed: boolean;
|
|
269
|
+
externalId?: string | undefined;
|
|
264
270
|
};
|
|
265
271
|
} | undefined;
|
|
266
272
|
trial?: {
|
|
@@ -328,6 +334,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
328
334
|
activeNumberOfActivations: number;
|
|
329
335
|
maxNumberOfActivations: number;
|
|
330
336
|
offlineActivationsAllowed: boolean;
|
|
337
|
+
externalId?: string | undefined;
|
|
331
338
|
};
|
|
332
339
|
} | undefined;
|
|
333
340
|
trial?: {
|
|
@@ -471,17 +478,160 @@ declare const customerSchema: z.ZodObject<{
|
|
|
471
478
|
newsletterOptIn: boolean;
|
|
472
479
|
};
|
|
473
480
|
}>;
|
|
481
|
+
declare const importCustomerRequestSchema: z.ZodObject<{
|
|
482
|
+
name: z.ZodString;
|
|
483
|
+
email: z.ZodString;
|
|
484
|
+
password: z.ZodOptional<z.ZodString>;
|
|
485
|
+
address: z.ZodOptional<z.ZodObject<{
|
|
486
|
+
countryCode: z.ZodString;
|
|
487
|
+
streetAddress1: z.ZodString;
|
|
488
|
+
streetAddress2: z.ZodNullable<z.ZodString>;
|
|
489
|
+
locality: z.ZodNullable<z.ZodString>;
|
|
490
|
+
region: z.ZodNullable<z.ZodString>;
|
|
491
|
+
postCode: z.ZodString;
|
|
492
|
+
}, "strip", z.ZodTypeAny, {
|
|
493
|
+
countryCode: string;
|
|
494
|
+
streetAddress1: string;
|
|
495
|
+
streetAddress2: string | null;
|
|
496
|
+
locality: string | null;
|
|
497
|
+
region: string | null;
|
|
498
|
+
postCode: string;
|
|
499
|
+
}, {
|
|
500
|
+
countryCode: string;
|
|
501
|
+
streetAddress1: string;
|
|
502
|
+
streetAddress2: string | null;
|
|
503
|
+
locality: string | null;
|
|
504
|
+
region: string | null;
|
|
505
|
+
postCode: string;
|
|
506
|
+
}>>;
|
|
507
|
+
}, "strip", z.ZodTypeAny, {
|
|
508
|
+
name: string;
|
|
509
|
+
email: string;
|
|
510
|
+
password?: string | undefined;
|
|
511
|
+
address?: {
|
|
512
|
+
countryCode: string;
|
|
513
|
+
streetAddress1: string;
|
|
514
|
+
streetAddress2: string | null;
|
|
515
|
+
locality: string | null;
|
|
516
|
+
region: string | null;
|
|
517
|
+
postCode: string;
|
|
518
|
+
} | undefined;
|
|
519
|
+
}, {
|
|
520
|
+
name: string;
|
|
521
|
+
email: string;
|
|
522
|
+
password?: string | undefined;
|
|
523
|
+
address?: {
|
|
524
|
+
countryCode: string;
|
|
525
|
+
streetAddress1: string;
|
|
526
|
+
streetAddress2: string | null;
|
|
527
|
+
locality: string | null;
|
|
528
|
+
region: string | null;
|
|
529
|
+
postCode: string;
|
|
530
|
+
} | undefined;
|
|
531
|
+
}>;
|
|
474
532
|
|
|
475
533
|
type Customer = z.infer<typeof customerSchema>;
|
|
534
|
+
type ImportCustomerRequest = z.infer<typeof importCustomerRequestSchema>;
|
|
476
535
|
|
|
477
536
|
declare class CustomerEndpoints {
|
|
478
537
|
private api;
|
|
479
538
|
constructor(api: MoonbaseApi);
|
|
480
539
|
get(idOrEmail: string): Promise<Customer>;
|
|
540
|
+
import(customer: ImportCustomerRequest): Promise<Customer>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare const pricingVariationSchema: z.ZodObject<{
|
|
544
|
+
id: z.ZodString;
|
|
545
|
+
name: z.ZodString;
|
|
546
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
547
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
548
|
+
hasDiscount: z.ZodBoolean;
|
|
549
|
+
discount: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
550
|
+
type: z.ZodLiteral<"PercentageOffDiscount">;
|
|
551
|
+
name: z.ZodString;
|
|
552
|
+
description: z.ZodOptional<z.ZodString>;
|
|
553
|
+
percentage: z.ZodNumber;
|
|
554
|
+
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
555
|
+
}, "strip", z.ZodTypeAny, {
|
|
556
|
+
type: "PercentageOffDiscount";
|
|
557
|
+
name: string;
|
|
558
|
+
percentage: number;
|
|
559
|
+
total: Record<string, number>;
|
|
560
|
+
description?: string | undefined;
|
|
561
|
+
}, {
|
|
562
|
+
type: "PercentageOffDiscount";
|
|
563
|
+
name: string;
|
|
564
|
+
percentage: number;
|
|
565
|
+
total: Record<string, number>;
|
|
566
|
+
description?: string | undefined;
|
|
567
|
+
}>, z.ZodObject<{
|
|
568
|
+
type: z.ZodLiteral<"FlatAmountOffDiscount">;
|
|
569
|
+
name: z.ZodString;
|
|
570
|
+
description: z.ZodOptional<z.ZodString>;
|
|
571
|
+
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
572
|
+
}, "strip", z.ZodTypeAny, {
|
|
573
|
+
type: "FlatAmountOffDiscount";
|
|
574
|
+
name: string;
|
|
575
|
+
total: Record<string, number>;
|
|
576
|
+
description?: string | undefined;
|
|
577
|
+
}, {
|
|
578
|
+
type: "FlatAmountOffDiscount";
|
|
579
|
+
name: string;
|
|
580
|
+
total: Record<string, number>;
|
|
581
|
+
description?: string | undefined;
|
|
582
|
+
}>]>>;
|
|
583
|
+
}, "strip", z.ZodTypeAny, {
|
|
584
|
+
id: string;
|
|
585
|
+
name: string;
|
|
586
|
+
originalPrice: Record<string, number>;
|
|
587
|
+
price: Record<string, number>;
|
|
588
|
+
hasDiscount: boolean;
|
|
589
|
+
discount?: {
|
|
590
|
+
type: "PercentageOffDiscount";
|
|
591
|
+
name: string;
|
|
592
|
+
percentage: number;
|
|
593
|
+
total: Record<string, number>;
|
|
594
|
+
description?: string | undefined;
|
|
595
|
+
} | {
|
|
596
|
+
type: "FlatAmountOffDiscount";
|
|
597
|
+
name: string;
|
|
598
|
+
total: Record<string, number>;
|
|
599
|
+
description?: string | undefined;
|
|
600
|
+
} | undefined;
|
|
601
|
+
}, {
|
|
602
|
+
id: string;
|
|
603
|
+
name: string;
|
|
604
|
+
originalPrice: Record<string, number>;
|
|
605
|
+
price: Record<string, number>;
|
|
606
|
+
hasDiscount: boolean;
|
|
607
|
+
discount?: {
|
|
608
|
+
type: "PercentageOffDiscount";
|
|
609
|
+
name: string;
|
|
610
|
+
percentage: number;
|
|
611
|
+
total: Record<string, number>;
|
|
612
|
+
description?: string | undefined;
|
|
613
|
+
} | {
|
|
614
|
+
type: "FlatAmountOffDiscount";
|
|
615
|
+
name: string;
|
|
616
|
+
total: Record<string, number>;
|
|
617
|
+
description?: string | undefined;
|
|
618
|
+
} | undefined;
|
|
619
|
+
}>;
|
|
620
|
+
|
|
621
|
+
type PricingVariation = z.infer<typeof pricingVariationSchema>;
|
|
622
|
+
interface Page<T> {
|
|
623
|
+
items: Array<T>;
|
|
624
|
+
hasMore: boolean;
|
|
625
|
+
next: string | null;
|
|
626
|
+
}
|
|
627
|
+
interface Quantifiable<T> {
|
|
628
|
+
value: T;
|
|
629
|
+
quantity: number;
|
|
481
630
|
}
|
|
482
631
|
|
|
483
632
|
declare const licenseSchema: z.ZodObject<{
|
|
484
633
|
id: z.ZodString;
|
|
634
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
485
635
|
productId: z.ZodString;
|
|
486
636
|
ownerId: z.ZodString;
|
|
487
637
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -496,6 +646,7 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
496
646
|
activeNumberOfActivations: number;
|
|
497
647
|
maxNumberOfActivations: number;
|
|
498
648
|
offlineActivationsAllowed: boolean;
|
|
649
|
+
externalId?: string | undefined;
|
|
499
650
|
}, {
|
|
500
651
|
status: LicenseStatus;
|
|
501
652
|
id: string;
|
|
@@ -504,6 +655,7 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
504
655
|
activeNumberOfActivations: number;
|
|
505
656
|
maxNumberOfActivations: number;
|
|
506
657
|
offlineActivationsAllowed: boolean;
|
|
658
|
+
externalId?: string | undefined;
|
|
507
659
|
}>;
|
|
508
660
|
declare const licenseActivationSchema: z.ZodObject<{
|
|
509
661
|
id: z.ZodString;
|
|
@@ -514,6 +666,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
514
666
|
lastValidatedAt: z.ZodDate;
|
|
515
667
|
license: z.ZodObject<{
|
|
516
668
|
id: z.ZodString;
|
|
669
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
517
670
|
productId: z.ZodString;
|
|
518
671
|
ownerId: z.ZodString;
|
|
519
672
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -528,6 +681,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
528
681
|
activeNumberOfActivations: number;
|
|
529
682
|
maxNumberOfActivations: number;
|
|
530
683
|
offlineActivationsAllowed: boolean;
|
|
684
|
+
externalId?: string | undefined;
|
|
531
685
|
}, {
|
|
532
686
|
status: LicenseStatus;
|
|
533
687
|
id: string;
|
|
@@ -536,6 +690,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
536
690
|
activeNumberOfActivations: number;
|
|
537
691
|
maxNumberOfActivations: number;
|
|
538
692
|
offlineActivationsAllowed: boolean;
|
|
693
|
+
externalId?: string | undefined;
|
|
539
694
|
}>;
|
|
540
695
|
}, "strip", z.ZodTypeAny, {
|
|
541
696
|
status: ActivationStatus;
|
|
@@ -552,6 +707,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
552
707
|
activeNumberOfActivations: number;
|
|
553
708
|
maxNumberOfActivations: number;
|
|
554
709
|
offlineActivationsAllowed: boolean;
|
|
710
|
+
externalId?: string | undefined;
|
|
555
711
|
};
|
|
556
712
|
}, {
|
|
557
713
|
status: ActivationStatus;
|
|
@@ -568,8 +724,59 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
568
724
|
activeNumberOfActivations: number;
|
|
569
725
|
maxNumberOfActivations: number;
|
|
570
726
|
offlineActivationsAllowed: boolean;
|
|
727
|
+
externalId?: string | undefined;
|
|
571
728
|
};
|
|
572
729
|
}>;
|
|
730
|
+
declare const importLicenseRequestSchema: z.ZodObject<{
|
|
731
|
+
customerId: z.ZodString;
|
|
732
|
+
productId: z.ZodString;
|
|
733
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
734
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
735
|
+
maxNumberOfActivations: z.ZodOptional<z.ZodNumber>;
|
|
736
|
+
offlineActivationsAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
737
|
+
activations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
738
|
+
activationMethod: z.ZodNativeEnum<typeof ActivationMethod>;
|
|
739
|
+
deviceName: z.ZodString;
|
|
740
|
+
deviceSignature: z.ZodString;
|
|
741
|
+
lastValidation: z.ZodOptional<z.ZodDate>;
|
|
742
|
+
}, "strip", z.ZodTypeAny, {
|
|
743
|
+
activationMethod: ActivationMethod;
|
|
744
|
+
deviceName: string;
|
|
745
|
+
deviceSignature: string;
|
|
746
|
+
lastValidation?: Date | undefined;
|
|
747
|
+
}, {
|
|
748
|
+
activationMethod: ActivationMethod;
|
|
749
|
+
deviceName: string;
|
|
750
|
+
deviceSignature: string;
|
|
751
|
+
lastValidation?: Date | undefined;
|
|
752
|
+
}>, "many">>;
|
|
753
|
+
}, "strip", z.ZodTypeAny, {
|
|
754
|
+
productId: string;
|
|
755
|
+
customerId: string;
|
|
756
|
+
externalId?: string | undefined;
|
|
757
|
+
createdAt?: Date | undefined;
|
|
758
|
+
maxNumberOfActivations?: number | undefined;
|
|
759
|
+
offlineActivationsAllowed?: boolean | undefined;
|
|
760
|
+
activations?: {
|
|
761
|
+
activationMethod: ActivationMethod;
|
|
762
|
+
deviceName: string;
|
|
763
|
+
deviceSignature: string;
|
|
764
|
+
lastValidation?: Date | undefined;
|
|
765
|
+
}[] | undefined;
|
|
766
|
+
}, {
|
|
767
|
+
productId: string;
|
|
768
|
+
customerId: string;
|
|
769
|
+
externalId?: string | undefined;
|
|
770
|
+
createdAt?: Date | undefined;
|
|
771
|
+
maxNumberOfActivations?: number | undefined;
|
|
772
|
+
offlineActivationsAllowed?: boolean | undefined;
|
|
773
|
+
activations?: {
|
|
774
|
+
activationMethod: ActivationMethod;
|
|
775
|
+
deviceName: string;
|
|
776
|
+
deviceSignature: string;
|
|
777
|
+
lastValidation?: Date | undefined;
|
|
778
|
+
}[] | undefined;
|
|
779
|
+
}>;
|
|
573
780
|
|
|
574
781
|
declare enum LicenseStatus {
|
|
575
782
|
Active = "Active",
|
|
@@ -585,100 +792,26 @@ declare enum ActivationMethod {
|
|
|
585
792
|
}
|
|
586
793
|
type License = z.infer<typeof licenseSchema>;
|
|
587
794
|
type LicenseActivation = z.infer<typeof licenseActivationSchema>;
|
|
795
|
+
type ImportLicenseRequest = z.infer<typeof importLicenseRequestSchema>;
|
|
588
796
|
|
|
589
797
|
declare class LicenseEndpoints {
|
|
590
798
|
private api;
|
|
591
799
|
constructor(api: MoonbaseApi);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}, "strip", z.ZodTypeAny, {
|
|
608
|
-
type: "PercentageOffDiscount";
|
|
609
|
-
name: string;
|
|
610
|
-
percentage: number;
|
|
611
|
-
total: Record<string, number>;
|
|
612
|
-
description?: string | undefined;
|
|
613
|
-
}, {
|
|
614
|
-
type: "PercentageOffDiscount";
|
|
615
|
-
name: string;
|
|
616
|
-
percentage: number;
|
|
617
|
-
total: Record<string, number>;
|
|
618
|
-
description?: string | undefined;
|
|
619
|
-
}>, z.ZodObject<{
|
|
620
|
-
type: z.ZodLiteral<"FlatAmountOffDiscount">;
|
|
621
|
-
name: z.ZodString;
|
|
622
|
-
description: z.ZodOptional<z.ZodString>;
|
|
623
|
-
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
624
|
-
}, "strip", z.ZodTypeAny, {
|
|
625
|
-
type: "FlatAmountOffDiscount";
|
|
626
|
-
name: string;
|
|
627
|
-
total: Record<string, number>;
|
|
628
|
-
description?: string | undefined;
|
|
629
|
-
}, {
|
|
630
|
-
type: "FlatAmountOffDiscount";
|
|
631
|
-
name: string;
|
|
632
|
-
total: Record<string, number>;
|
|
633
|
-
description?: string | undefined;
|
|
634
|
-
}>]>>;
|
|
635
|
-
}, "strip", z.ZodTypeAny, {
|
|
636
|
-
id: string;
|
|
637
|
-
name: string;
|
|
638
|
-
originalPrice: Record<string, number>;
|
|
639
|
-
price: Record<string, number>;
|
|
640
|
-
hasDiscount: boolean;
|
|
641
|
-
discount?: {
|
|
642
|
-
type: "PercentageOffDiscount";
|
|
643
|
-
name: string;
|
|
644
|
-
percentage: number;
|
|
645
|
-
total: Record<string, number>;
|
|
646
|
-
description?: string | undefined;
|
|
647
|
-
} | {
|
|
648
|
-
type: "FlatAmountOffDiscount";
|
|
649
|
-
name: string;
|
|
650
|
-
total: Record<string, number>;
|
|
651
|
-
description?: string | undefined;
|
|
652
|
-
} | undefined;
|
|
653
|
-
}, {
|
|
654
|
-
id: string;
|
|
655
|
-
name: string;
|
|
656
|
-
originalPrice: Record<string, number>;
|
|
657
|
-
price: Record<string, number>;
|
|
658
|
-
hasDiscount: boolean;
|
|
659
|
-
discount?: {
|
|
660
|
-
type: "PercentageOffDiscount";
|
|
661
|
-
name: string;
|
|
662
|
-
percentage: number;
|
|
663
|
-
total: Record<string, number>;
|
|
664
|
-
description?: string | undefined;
|
|
665
|
-
} | {
|
|
666
|
-
type: "FlatAmountOffDiscount";
|
|
667
|
-
name: string;
|
|
668
|
-
total: Record<string, number>;
|
|
669
|
-
description?: string | undefined;
|
|
670
|
-
} | undefined;
|
|
671
|
-
}>;
|
|
672
|
-
|
|
673
|
-
type PricingVariation = z.infer<typeof pricingVariationSchema>;
|
|
674
|
-
interface Page<T> {
|
|
675
|
-
items: Array<T>;
|
|
676
|
-
hasMore: boolean;
|
|
677
|
-
next: string | null;
|
|
678
|
-
}
|
|
679
|
-
interface Quantifiable<T> {
|
|
680
|
-
value: T;
|
|
681
|
-
quantity: number;
|
|
800
|
+
query(opts?: {
|
|
801
|
+
paginationToken?: string;
|
|
802
|
+
productFilter?: string;
|
|
803
|
+
pageSize?: number;
|
|
804
|
+
}): Promise<Page<License>>;
|
|
805
|
+
get(licenseId: string): Promise<License>;
|
|
806
|
+
import(license: ImportLicenseRequest): Promise<License>;
|
|
807
|
+
revoke(licenseId: string): Promise<License>;
|
|
808
|
+
queryActivations(licenseId: string, opts?: {
|
|
809
|
+
paginationToken?: string;
|
|
810
|
+
productFilter?: string;
|
|
811
|
+
pageSize?: number;
|
|
812
|
+
}): Promise<Page<LicenseActivation>>;
|
|
813
|
+
validateActivation(licenseId: string, activationId: string): Promise<LicenseActivation>;
|
|
814
|
+
revokeActivation(licenseId: string, activationId: string): Promise<LicenseActivation>;
|
|
682
815
|
}
|
|
683
816
|
|
|
684
817
|
declare const productSchema: z.ZodObject<{
|
|
@@ -758,12 +891,38 @@ declare const trialSchema: z.ZodObject<{
|
|
|
758
891
|
expiresAt: Date;
|
|
759
892
|
ownerId?: string | undefined;
|
|
760
893
|
}>;
|
|
894
|
+
declare const importTrialRequestSchema: z.ZodObject<{
|
|
895
|
+
productId: z.ZodString;
|
|
896
|
+
deviceName: z.ZodString;
|
|
897
|
+
deviceSignature: z.ZodString;
|
|
898
|
+
expiresAt: z.ZodDate;
|
|
899
|
+
customerId: z.ZodOptional<z.ZodString>;
|
|
900
|
+
lastValidation: z.ZodOptional<z.ZodDate>;
|
|
901
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
902
|
+
}, "strip", z.ZodTypeAny, {
|
|
903
|
+
productId: string;
|
|
904
|
+
deviceName: string;
|
|
905
|
+
deviceSignature: string;
|
|
906
|
+
expiresAt: Date;
|
|
907
|
+
customerId?: string | undefined;
|
|
908
|
+
lastValidation?: Date | undefined;
|
|
909
|
+
createdAt?: Date | undefined;
|
|
910
|
+
}, {
|
|
911
|
+
productId: string;
|
|
912
|
+
deviceName: string;
|
|
913
|
+
deviceSignature: string;
|
|
914
|
+
expiresAt: Date;
|
|
915
|
+
customerId?: string | undefined;
|
|
916
|
+
lastValidation?: Date | undefined;
|
|
917
|
+
createdAt?: Date | undefined;
|
|
918
|
+
}>;
|
|
761
919
|
|
|
762
920
|
declare enum TrialStatus {
|
|
763
921
|
Active = "Active",
|
|
764
922
|
Expired = "Expired"
|
|
765
923
|
}
|
|
766
924
|
type Trial = z.infer<typeof trialSchema>;
|
|
925
|
+
type ImportTrialRequest = z.infer<typeof importTrialRequestSchema>;
|
|
767
926
|
|
|
768
927
|
declare class TrialEndpoints {
|
|
769
928
|
private api;
|
|
@@ -772,6 +931,7 @@ declare class TrialEndpoints {
|
|
|
772
931
|
deviceName: string;
|
|
773
932
|
deviceSignature: string;
|
|
774
933
|
}): Promise<Trial>;
|
|
934
|
+
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
775
935
|
}
|
|
776
936
|
|
|
777
937
|
declare class NotAuthorizedError extends Error {
|
|
@@ -804,4 +964,4 @@ declare class MoonbaseClient {
|
|
|
804
964
|
trials: TrialEndpoints;
|
|
805
965
|
}
|
|
806
966
|
|
|
807
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Customer, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
58
58
|
lastValidatedAt: z.ZodDate;
|
|
59
59
|
license: z.ZodObject<{
|
|
60
60
|
id: z.ZodString;
|
|
61
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
61
62
|
productId: z.ZodString;
|
|
62
63
|
ownerId: z.ZodString;
|
|
63
64
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -72,6 +73,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
72
73
|
activeNumberOfActivations: number;
|
|
73
74
|
maxNumberOfActivations: number;
|
|
74
75
|
offlineActivationsAllowed: boolean;
|
|
76
|
+
externalId?: string | undefined;
|
|
75
77
|
}, {
|
|
76
78
|
status: LicenseStatus;
|
|
77
79
|
id: string;
|
|
@@ -80,6 +82,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
80
82
|
activeNumberOfActivations: number;
|
|
81
83
|
maxNumberOfActivations: number;
|
|
82
84
|
offlineActivationsAllowed: boolean;
|
|
85
|
+
externalId?: string | undefined;
|
|
83
86
|
}>;
|
|
84
87
|
}, "strip", z.ZodTypeAny, {
|
|
85
88
|
status: ActivationStatus;
|
|
@@ -96,6 +99,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
96
99
|
activeNumberOfActivations: number;
|
|
97
100
|
maxNumberOfActivations: number;
|
|
98
101
|
offlineActivationsAllowed: boolean;
|
|
102
|
+
externalId?: string | undefined;
|
|
99
103
|
};
|
|
100
104
|
}, {
|
|
101
105
|
status: ActivationStatus;
|
|
@@ -112,6 +116,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
112
116
|
activeNumberOfActivations: number;
|
|
113
117
|
maxNumberOfActivations: number;
|
|
114
118
|
offlineActivationsAllowed: boolean;
|
|
119
|
+
externalId?: string | undefined;
|
|
115
120
|
};
|
|
116
121
|
}>>;
|
|
117
122
|
trial: z.ZodOptional<z.ZodObject<{
|
|
@@ -261,6 +266,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
261
266
|
activeNumberOfActivations: number;
|
|
262
267
|
maxNumberOfActivations: number;
|
|
263
268
|
offlineActivationsAllowed: boolean;
|
|
269
|
+
externalId?: string | undefined;
|
|
264
270
|
};
|
|
265
271
|
} | undefined;
|
|
266
272
|
trial?: {
|
|
@@ -328,6 +334,7 @@ declare const activationRequestSchema: z.ZodObject<{
|
|
|
328
334
|
activeNumberOfActivations: number;
|
|
329
335
|
maxNumberOfActivations: number;
|
|
330
336
|
offlineActivationsAllowed: boolean;
|
|
337
|
+
externalId?: string | undefined;
|
|
331
338
|
};
|
|
332
339
|
} | undefined;
|
|
333
340
|
trial?: {
|
|
@@ -471,17 +478,160 @@ declare const customerSchema: z.ZodObject<{
|
|
|
471
478
|
newsletterOptIn: boolean;
|
|
472
479
|
};
|
|
473
480
|
}>;
|
|
481
|
+
declare const importCustomerRequestSchema: z.ZodObject<{
|
|
482
|
+
name: z.ZodString;
|
|
483
|
+
email: z.ZodString;
|
|
484
|
+
password: z.ZodOptional<z.ZodString>;
|
|
485
|
+
address: z.ZodOptional<z.ZodObject<{
|
|
486
|
+
countryCode: z.ZodString;
|
|
487
|
+
streetAddress1: z.ZodString;
|
|
488
|
+
streetAddress2: z.ZodNullable<z.ZodString>;
|
|
489
|
+
locality: z.ZodNullable<z.ZodString>;
|
|
490
|
+
region: z.ZodNullable<z.ZodString>;
|
|
491
|
+
postCode: z.ZodString;
|
|
492
|
+
}, "strip", z.ZodTypeAny, {
|
|
493
|
+
countryCode: string;
|
|
494
|
+
streetAddress1: string;
|
|
495
|
+
streetAddress2: string | null;
|
|
496
|
+
locality: string | null;
|
|
497
|
+
region: string | null;
|
|
498
|
+
postCode: string;
|
|
499
|
+
}, {
|
|
500
|
+
countryCode: string;
|
|
501
|
+
streetAddress1: string;
|
|
502
|
+
streetAddress2: string | null;
|
|
503
|
+
locality: string | null;
|
|
504
|
+
region: string | null;
|
|
505
|
+
postCode: string;
|
|
506
|
+
}>>;
|
|
507
|
+
}, "strip", z.ZodTypeAny, {
|
|
508
|
+
name: string;
|
|
509
|
+
email: string;
|
|
510
|
+
password?: string | undefined;
|
|
511
|
+
address?: {
|
|
512
|
+
countryCode: string;
|
|
513
|
+
streetAddress1: string;
|
|
514
|
+
streetAddress2: string | null;
|
|
515
|
+
locality: string | null;
|
|
516
|
+
region: string | null;
|
|
517
|
+
postCode: string;
|
|
518
|
+
} | undefined;
|
|
519
|
+
}, {
|
|
520
|
+
name: string;
|
|
521
|
+
email: string;
|
|
522
|
+
password?: string | undefined;
|
|
523
|
+
address?: {
|
|
524
|
+
countryCode: string;
|
|
525
|
+
streetAddress1: string;
|
|
526
|
+
streetAddress2: string | null;
|
|
527
|
+
locality: string | null;
|
|
528
|
+
region: string | null;
|
|
529
|
+
postCode: string;
|
|
530
|
+
} | undefined;
|
|
531
|
+
}>;
|
|
474
532
|
|
|
475
533
|
type Customer = z.infer<typeof customerSchema>;
|
|
534
|
+
type ImportCustomerRequest = z.infer<typeof importCustomerRequestSchema>;
|
|
476
535
|
|
|
477
536
|
declare class CustomerEndpoints {
|
|
478
537
|
private api;
|
|
479
538
|
constructor(api: MoonbaseApi);
|
|
480
539
|
get(idOrEmail: string): Promise<Customer>;
|
|
540
|
+
import(customer: ImportCustomerRequest): Promise<Customer>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare const pricingVariationSchema: z.ZodObject<{
|
|
544
|
+
id: z.ZodString;
|
|
545
|
+
name: z.ZodString;
|
|
546
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
547
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
548
|
+
hasDiscount: z.ZodBoolean;
|
|
549
|
+
discount: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
550
|
+
type: z.ZodLiteral<"PercentageOffDiscount">;
|
|
551
|
+
name: z.ZodString;
|
|
552
|
+
description: z.ZodOptional<z.ZodString>;
|
|
553
|
+
percentage: z.ZodNumber;
|
|
554
|
+
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
555
|
+
}, "strip", z.ZodTypeAny, {
|
|
556
|
+
type: "PercentageOffDiscount";
|
|
557
|
+
name: string;
|
|
558
|
+
percentage: number;
|
|
559
|
+
total: Record<string, number>;
|
|
560
|
+
description?: string | undefined;
|
|
561
|
+
}, {
|
|
562
|
+
type: "PercentageOffDiscount";
|
|
563
|
+
name: string;
|
|
564
|
+
percentage: number;
|
|
565
|
+
total: Record<string, number>;
|
|
566
|
+
description?: string | undefined;
|
|
567
|
+
}>, z.ZodObject<{
|
|
568
|
+
type: z.ZodLiteral<"FlatAmountOffDiscount">;
|
|
569
|
+
name: z.ZodString;
|
|
570
|
+
description: z.ZodOptional<z.ZodString>;
|
|
571
|
+
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
572
|
+
}, "strip", z.ZodTypeAny, {
|
|
573
|
+
type: "FlatAmountOffDiscount";
|
|
574
|
+
name: string;
|
|
575
|
+
total: Record<string, number>;
|
|
576
|
+
description?: string | undefined;
|
|
577
|
+
}, {
|
|
578
|
+
type: "FlatAmountOffDiscount";
|
|
579
|
+
name: string;
|
|
580
|
+
total: Record<string, number>;
|
|
581
|
+
description?: string | undefined;
|
|
582
|
+
}>]>>;
|
|
583
|
+
}, "strip", z.ZodTypeAny, {
|
|
584
|
+
id: string;
|
|
585
|
+
name: string;
|
|
586
|
+
originalPrice: Record<string, number>;
|
|
587
|
+
price: Record<string, number>;
|
|
588
|
+
hasDiscount: boolean;
|
|
589
|
+
discount?: {
|
|
590
|
+
type: "PercentageOffDiscount";
|
|
591
|
+
name: string;
|
|
592
|
+
percentage: number;
|
|
593
|
+
total: Record<string, number>;
|
|
594
|
+
description?: string | undefined;
|
|
595
|
+
} | {
|
|
596
|
+
type: "FlatAmountOffDiscount";
|
|
597
|
+
name: string;
|
|
598
|
+
total: Record<string, number>;
|
|
599
|
+
description?: string | undefined;
|
|
600
|
+
} | undefined;
|
|
601
|
+
}, {
|
|
602
|
+
id: string;
|
|
603
|
+
name: string;
|
|
604
|
+
originalPrice: Record<string, number>;
|
|
605
|
+
price: Record<string, number>;
|
|
606
|
+
hasDiscount: boolean;
|
|
607
|
+
discount?: {
|
|
608
|
+
type: "PercentageOffDiscount";
|
|
609
|
+
name: string;
|
|
610
|
+
percentage: number;
|
|
611
|
+
total: Record<string, number>;
|
|
612
|
+
description?: string | undefined;
|
|
613
|
+
} | {
|
|
614
|
+
type: "FlatAmountOffDiscount";
|
|
615
|
+
name: string;
|
|
616
|
+
total: Record<string, number>;
|
|
617
|
+
description?: string | undefined;
|
|
618
|
+
} | undefined;
|
|
619
|
+
}>;
|
|
620
|
+
|
|
621
|
+
type PricingVariation = z.infer<typeof pricingVariationSchema>;
|
|
622
|
+
interface Page<T> {
|
|
623
|
+
items: Array<T>;
|
|
624
|
+
hasMore: boolean;
|
|
625
|
+
next: string | null;
|
|
626
|
+
}
|
|
627
|
+
interface Quantifiable<T> {
|
|
628
|
+
value: T;
|
|
629
|
+
quantity: number;
|
|
481
630
|
}
|
|
482
631
|
|
|
483
632
|
declare const licenseSchema: z.ZodObject<{
|
|
484
633
|
id: z.ZodString;
|
|
634
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
485
635
|
productId: z.ZodString;
|
|
486
636
|
ownerId: z.ZodString;
|
|
487
637
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -496,6 +646,7 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
496
646
|
activeNumberOfActivations: number;
|
|
497
647
|
maxNumberOfActivations: number;
|
|
498
648
|
offlineActivationsAllowed: boolean;
|
|
649
|
+
externalId?: string | undefined;
|
|
499
650
|
}, {
|
|
500
651
|
status: LicenseStatus;
|
|
501
652
|
id: string;
|
|
@@ -504,6 +655,7 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
504
655
|
activeNumberOfActivations: number;
|
|
505
656
|
maxNumberOfActivations: number;
|
|
506
657
|
offlineActivationsAllowed: boolean;
|
|
658
|
+
externalId?: string | undefined;
|
|
507
659
|
}>;
|
|
508
660
|
declare const licenseActivationSchema: z.ZodObject<{
|
|
509
661
|
id: z.ZodString;
|
|
@@ -514,6 +666,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
514
666
|
lastValidatedAt: z.ZodDate;
|
|
515
667
|
license: z.ZodObject<{
|
|
516
668
|
id: z.ZodString;
|
|
669
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
517
670
|
productId: z.ZodString;
|
|
518
671
|
ownerId: z.ZodString;
|
|
519
672
|
status: z.ZodNativeEnum<typeof LicenseStatus>;
|
|
@@ -528,6 +681,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
528
681
|
activeNumberOfActivations: number;
|
|
529
682
|
maxNumberOfActivations: number;
|
|
530
683
|
offlineActivationsAllowed: boolean;
|
|
684
|
+
externalId?: string | undefined;
|
|
531
685
|
}, {
|
|
532
686
|
status: LicenseStatus;
|
|
533
687
|
id: string;
|
|
@@ -536,6 +690,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
536
690
|
activeNumberOfActivations: number;
|
|
537
691
|
maxNumberOfActivations: number;
|
|
538
692
|
offlineActivationsAllowed: boolean;
|
|
693
|
+
externalId?: string | undefined;
|
|
539
694
|
}>;
|
|
540
695
|
}, "strip", z.ZodTypeAny, {
|
|
541
696
|
status: ActivationStatus;
|
|
@@ -552,6 +707,7 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
552
707
|
activeNumberOfActivations: number;
|
|
553
708
|
maxNumberOfActivations: number;
|
|
554
709
|
offlineActivationsAllowed: boolean;
|
|
710
|
+
externalId?: string | undefined;
|
|
555
711
|
};
|
|
556
712
|
}, {
|
|
557
713
|
status: ActivationStatus;
|
|
@@ -568,8 +724,59 @@ declare const licenseActivationSchema: z.ZodObject<{
|
|
|
568
724
|
activeNumberOfActivations: number;
|
|
569
725
|
maxNumberOfActivations: number;
|
|
570
726
|
offlineActivationsAllowed: boolean;
|
|
727
|
+
externalId?: string | undefined;
|
|
571
728
|
};
|
|
572
729
|
}>;
|
|
730
|
+
declare const importLicenseRequestSchema: z.ZodObject<{
|
|
731
|
+
customerId: z.ZodString;
|
|
732
|
+
productId: z.ZodString;
|
|
733
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
734
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
735
|
+
maxNumberOfActivations: z.ZodOptional<z.ZodNumber>;
|
|
736
|
+
offlineActivationsAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
737
|
+
activations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
738
|
+
activationMethod: z.ZodNativeEnum<typeof ActivationMethod>;
|
|
739
|
+
deviceName: z.ZodString;
|
|
740
|
+
deviceSignature: z.ZodString;
|
|
741
|
+
lastValidation: z.ZodOptional<z.ZodDate>;
|
|
742
|
+
}, "strip", z.ZodTypeAny, {
|
|
743
|
+
activationMethod: ActivationMethod;
|
|
744
|
+
deviceName: string;
|
|
745
|
+
deviceSignature: string;
|
|
746
|
+
lastValidation?: Date | undefined;
|
|
747
|
+
}, {
|
|
748
|
+
activationMethod: ActivationMethod;
|
|
749
|
+
deviceName: string;
|
|
750
|
+
deviceSignature: string;
|
|
751
|
+
lastValidation?: Date | undefined;
|
|
752
|
+
}>, "many">>;
|
|
753
|
+
}, "strip", z.ZodTypeAny, {
|
|
754
|
+
productId: string;
|
|
755
|
+
customerId: string;
|
|
756
|
+
externalId?: string | undefined;
|
|
757
|
+
createdAt?: Date | undefined;
|
|
758
|
+
maxNumberOfActivations?: number | undefined;
|
|
759
|
+
offlineActivationsAllowed?: boolean | undefined;
|
|
760
|
+
activations?: {
|
|
761
|
+
activationMethod: ActivationMethod;
|
|
762
|
+
deviceName: string;
|
|
763
|
+
deviceSignature: string;
|
|
764
|
+
lastValidation?: Date | undefined;
|
|
765
|
+
}[] | undefined;
|
|
766
|
+
}, {
|
|
767
|
+
productId: string;
|
|
768
|
+
customerId: string;
|
|
769
|
+
externalId?: string | undefined;
|
|
770
|
+
createdAt?: Date | undefined;
|
|
771
|
+
maxNumberOfActivations?: number | undefined;
|
|
772
|
+
offlineActivationsAllowed?: boolean | undefined;
|
|
773
|
+
activations?: {
|
|
774
|
+
activationMethod: ActivationMethod;
|
|
775
|
+
deviceName: string;
|
|
776
|
+
deviceSignature: string;
|
|
777
|
+
lastValidation?: Date | undefined;
|
|
778
|
+
}[] | undefined;
|
|
779
|
+
}>;
|
|
573
780
|
|
|
574
781
|
declare enum LicenseStatus {
|
|
575
782
|
Active = "Active",
|
|
@@ -585,100 +792,26 @@ declare enum ActivationMethod {
|
|
|
585
792
|
}
|
|
586
793
|
type License = z.infer<typeof licenseSchema>;
|
|
587
794
|
type LicenseActivation = z.infer<typeof licenseActivationSchema>;
|
|
795
|
+
type ImportLicenseRequest = z.infer<typeof importLicenseRequestSchema>;
|
|
588
796
|
|
|
589
797
|
declare class LicenseEndpoints {
|
|
590
798
|
private api;
|
|
591
799
|
constructor(api: MoonbaseApi);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}, "strip", z.ZodTypeAny, {
|
|
608
|
-
type: "PercentageOffDiscount";
|
|
609
|
-
name: string;
|
|
610
|
-
percentage: number;
|
|
611
|
-
total: Record<string, number>;
|
|
612
|
-
description?: string | undefined;
|
|
613
|
-
}, {
|
|
614
|
-
type: "PercentageOffDiscount";
|
|
615
|
-
name: string;
|
|
616
|
-
percentage: number;
|
|
617
|
-
total: Record<string, number>;
|
|
618
|
-
description?: string | undefined;
|
|
619
|
-
}>, z.ZodObject<{
|
|
620
|
-
type: z.ZodLiteral<"FlatAmountOffDiscount">;
|
|
621
|
-
name: z.ZodString;
|
|
622
|
-
description: z.ZodOptional<z.ZodString>;
|
|
623
|
-
total: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
624
|
-
}, "strip", z.ZodTypeAny, {
|
|
625
|
-
type: "FlatAmountOffDiscount";
|
|
626
|
-
name: string;
|
|
627
|
-
total: Record<string, number>;
|
|
628
|
-
description?: string | undefined;
|
|
629
|
-
}, {
|
|
630
|
-
type: "FlatAmountOffDiscount";
|
|
631
|
-
name: string;
|
|
632
|
-
total: Record<string, number>;
|
|
633
|
-
description?: string | undefined;
|
|
634
|
-
}>]>>;
|
|
635
|
-
}, "strip", z.ZodTypeAny, {
|
|
636
|
-
id: string;
|
|
637
|
-
name: string;
|
|
638
|
-
originalPrice: Record<string, number>;
|
|
639
|
-
price: Record<string, number>;
|
|
640
|
-
hasDiscount: boolean;
|
|
641
|
-
discount?: {
|
|
642
|
-
type: "PercentageOffDiscount";
|
|
643
|
-
name: string;
|
|
644
|
-
percentage: number;
|
|
645
|
-
total: Record<string, number>;
|
|
646
|
-
description?: string | undefined;
|
|
647
|
-
} | {
|
|
648
|
-
type: "FlatAmountOffDiscount";
|
|
649
|
-
name: string;
|
|
650
|
-
total: Record<string, number>;
|
|
651
|
-
description?: string | undefined;
|
|
652
|
-
} | undefined;
|
|
653
|
-
}, {
|
|
654
|
-
id: string;
|
|
655
|
-
name: string;
|
|
656
|
-
originalPrice: Record<string, number>;
|
|
657
|
-
price: Record<string, number>;
|
|
658
|
-
hasDiscount: boolean;
|
|
659
|
-
discount?: {
|
|
660
|
-
type: "PercentageOffDiscount";
|
|
661
|
-
name: string;
|
|
662
|
-
percentage: number;
|
|
663
|
-
total: Record<string, number>;
|
|
664
|
-
description?: string | undefined;
|
|
665
|
-
} | {
|
|
666
|
-
type: "FlatAmountOffDiscount";
|
|
667
|
-
name: string;
|
|
668
|
-
total: Record<string, number>;
|
|
669
|
-
description?: string | undefined;
|
|
670
|
-
} | undefined;
|
|
671
|
-
}>;
|
|
672
|
-
|
|
673
|
-
type PricingVariation = z.infer<typeof pricingVariationSchema>;
|
|
674
|
-
interface Page<T> {
|
|
675
|
-
items: Array<T>;
|
|
676
|
-
hasMore: boolean;
|
|
677
|
-
next: string | null;
|
|
678
|
-
}
|
|
679
|
-
interface Quantifiable<T> {
|
|
680
|
-
value: T;
|
|
681
|
-
quantity: number;
|
|
800
|
+
query(opts?: {
|
|
801
|
+
paginationToken?: string;
|
|
802
|
+
productFilter?: string;
|
|
803
|
+
pageSize?: number;
|
|
804
|
+
}): Promise<Page<License>>;
|
|
805
|
+
get(licenseId: string): Promise<License>;
|
|
806
|
+
import(license: ImportLicenseRequest): Promise<License>;
|
|
807
|
+
revoke(licenseId: string): Promise<License>;
|
|
808
|
+
queryActivations(licenseId: string, opts?: {
|
|
809
|
+
paginationToken?: string;
|
|
810
|
+
productFilter?: string;
|
|
811
|
+
pageSize?: number;
|
|
812
|
+
}): Promise<Page<LicenseActivation>>;
|
|
813
|
+
validateActivation(licenseId: string, activationId: string): Promise<LicenseActivation>;
|
|
814
|
+
revokeActivation(licenseId: string, activationId: string): Promise<LicenseActivation>;
|
|
682
815
|
}
|
|
683
816
|
|
|
684
817
|
declare const productSchema: z.ZodObject<{
|
|
@@ -758,12 +891,38 @@ declare const trialSchema: z.ZodObject<{
|
|
|
758
891
|
expiresAt: Date;
|
|
759
892
|
ownerId?: string | undefined;
|
|
760
893
|
}>;
|
|
894
|
+
declare const importTrialRequestSchema: z.ZodObject<{
|
|
895
|
+
productId: z.ZodString;
|
|
896
|
+
deviceName: z.ZodString;
|
|
897
|
+
deviceSignature: z.ZodString;
|
|
898
|
+
expiresAt: z.ZodDate;
|
|
899
|
+
customerId: z.ZodOptional<z.ZodString>;
|
|
900
|
+
lastValidation: z.ZodOptional<z.ZodDate>;
|
|
901
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
902
|
+
}, "strip", z.ZodTypeAny, {
|
|
903
|
+
productId: string;
|
|
904
|
+
deviceName: string;
|
|
905
|
+
deviceSignature: string;
|
|
906
|
+
expiresAt: Date;
|
|
907
|
+
customerId?: string | undefined;
|
|
908
|
+
lastValidation?: Date | undefined;
|
|
909
|
+
createdAt?: Date | undefined;
|
|
910
|
+
}, {
|
|
911
|
+
productId: string;
|
|
912
|
+
deviceName: string;
|
|
913
|
+
deviceSignature: string;
|
|
914
|
+
expiresAt: Date;
|
|
915
|
+
customerId?: string | undefined;
|
|
916
|
+
lastValidation?: Date | undefined;
|
|
917
|
+
createdAt?: Date | undefined;
|
|
918
|
+
}>;
|
|
761
919
|
|
|
762
920
|
declare enum TrialStatus {
|
|
763
921
|
Active = "Active",
|
|
764
922
|
Expired = "Expired"
|
|
765
923
|
}
|
|
766
924
|
type Trial = z.infer<typeof trialSchema>;
|
|
925
|
+
type ImportTrialRequest = z.infer<typeof importTrialRequestSchema>;
|
|
767
926
|
|
|
768
927
|
declare class TrialEndpoints {
|
|
769
928
|
private api;
|
|
@@ -772,6 +931,7 @@ declare class TrialEndpoints {
|
|
|
772
931
|
deviceName: string;
|
|
773
932
|
deviceSignature: string;
|
|
774
933
|
}): Promise<Trial>;
|
|
934
|
+
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
775
935
|
}
|
|
776
936
|
|
|
777
937
|
declare class NotAuthorizedError extends Error {
|
|
@@ -804,4 +964,4 @@ declare class MoonbaseClient {
|
|
|
804
964
|
trials: TrialEndpoints;
|
|
805
965
|
}
|
|
806
966
|
|
|
807
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Customer, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,12 @@ var customerSchema = z.object({
|
|
|
30
30
|
address: addressSchema.nullable(),
|
|
31
31
|
communicationPreferences: communicationPreferencesSchema
|
|
32
32
|
});
|
|
33
|
+
var importCustomerRequestSchema = z.object({
|
|
34
|
+
name: z.string(),
|
|
35
|
+
email: z.string(),
|
|
36
|
+
password: z.string().optional(),
|
|
37
|
+
address: addressSchema.optional()
|
|
38
|
+
});
|
|
33
39
|
|
|
34
40
|
// src/licenses/schemas.ts
|
|
35
41
|
import { z as z2 } from "zod";
|
|
@@ -54,6 +60,7 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
54
60
|
// src/licenses/schemas.ts
|
|
55
61
|
var licenseSchema = z2.object({
|
|
56
62
|
id: z2.string(),
|
|
63
|
+
externalId: z2.string().optional(),
|
|
57
64
|
productId: z2.string(),
|
|
58
65
|
ownerId: z2.string(),
|
|
59
66
|
status: z2.nativeEnum(LicenseStatus),
|
|
@@ -70,6 +77,20 @@ var licenseActivationSchema = z2.object({
|
|
|
70
77
|
lastValidatedAt: z2.coerce.date(),
|
|
71
78
|
license: licenseSchema
|
|
72
79
|
});
|
|
80
|
+
var importLicenseRequestSchema = z2.object({
|
|
81
|
+
customerId: z2.string(),
|
|
82
|
+
productId: z2.string(),
|
|
83
|
+
externalId: z2.string().optional(),
|
|
84
|
+
createdAt: z2.date().optional(),
|
|
85
|
+
maxNumberOfActivations: z2.number().optional(),
|
|
86
|
+
offlineActivationsAllowed: z2.boolean().optional(),
|
|
87
|
+
activations: z2.object({
|
|
88
|
+
activationMethod: z2.nativeEnum(ActivationMethod),
|
|
89
|
+
deviceName: z2.string(),
|
|
90
|
+
deviceSignature: z2.string(),
|
|
91
|
+
lastValidation: z2.date().optional()
|
|
92
|
+
}).array().optional()
|
|
93
|
+
});
|
|
73
94
|
|
|
74
95
|
// src/products/schemas.ts
|
|
75
96
|
import { z as z3 } from "zod";
|
|
@@ -115,6 +136,15 @@ var trialSchema = z4.object({
|
|
|
115
136
|
lastValidatedAt: z4.coerce.date(),
|
|
116
137
|
ownerId: z4.string().optional()
|
|
117
138
|
});
|
|
139
|
+
var importTrialRequestSchema = z4.object({
|
|
140
|
+
productId: z4.string(),
|
|
141
|
+
deviceName: z4.string(),
|
|
142
|
+
deviceSignature: z4.string(),
|
|
143
|
+
expiresAt: z4.date(),
|
|
144
|
+
customerId: z4.string().optional(),
|
|
145
|
+
lastValidation: z4.date().optional(),
|
|
146
|
+
createdAt: z4.date().optional()
|
|
147
|
+
});
|
|
118
148
|
|
|
119
149
|
// src/activationRequests/models.ts
|
|
120
150
|
var ActivationRequestStatus = /* @__PURE__ */ ((ActivationRequestStatus2) => {
|
|
@@ -160,16 +190,10 @@ var CustomerEndpoints = class {
|
|
|
160
190
|
const response = await this.api.fetch(`/api/customers/${idOrEmail}`);
|
|
161
191
|
return customerSchema.parse(response.data);
|
|
162
192
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
constructor(api) {
|
|
168
|
-
this.api = api;
|
|
169
|
-
}
|
|
170
|
-
async validate(licenseId, activationId) {
|
|
171
|
-
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/validate`, "POST");
|
|
172
|
-
return licenseActivationSchema.parse(response.data);
|
|
193
|
+
async import(customer) {
|
|
194
|
+
const request = importCustomerRequestSchema.parse(customer);
|
|
195
|
+
const response = await this.api.fetch(`/api/customers/import`, "POST", request);
|
|
196
|
+
return customerSchema.parse(response.data);
|
|
173
197
|
}
|
|
174
198
|
};
|
|
175
199
|
|
|
@@ -301,6 +325,42 @@ var MoonbaseApi = class {
|
|
|
301
325
|
}
|
|
302
326
|
};
|
|
303
327
|
|
|
328
|
+
// src/licenses/endpoints.ts
|
|
329
|
+
var LicenseEndpoints = class {
|
|
330
|
+
constructor(api) {
|
|
331
|
+
this.api = api;
|
|
332
|
+
}
|
|
333
|
+
async query(opts) {
|
|
334
|
+
const response = await this.api.fetch(`/api/licenses?${objectToQuery(opts)}`);
|
|
335
|
+
return paged(licenseSchema).parse(response.data);
|
|
336
|
+
}
|
|
337
|
+
async get(licenseId) {
|
|
338
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}`);
|
|
339
|
+
return licenseSchema.parse(response.data);
|
|
340
|
+
}
|
|
341
|
+
async import(license) {
|
|
342
|
+
const request = importLicenseRequestSchema.parse(license);
|
|
343
|
+
const response = await this.api.fetch(`/api/licenses/import`, "POST", request);
|
|
344
|
+
return licenseSchema.parse(response.data);
|
|
345
|
+
}
|
|
346
|
+
async revoke(licenseId) {
|
|
347
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/revoke`, "POST");
|
|
348
|
+
return licenseSchema.parse(response.data);
|
|
349
|
+
}
|
|
350
|
+
async queryActivations(licenseId, opts) {
|
|
351
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations?${objectToQuery(opts)}`);
|
|
352
|
+
return paged(licenseActivationSchema).parse(response.data);
|
|
353
|
+
}
|
|
354
|
+
async validateActivation(licenseId, activationId) {
|
|
355
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/validate`, "POST");
|
|
356
|
+
return licenseActivationSchema.parse(response.data);
|
|
357
|
+
}
|
|
358
|
+
async revokeActivation(licenseId, activationId) {
|
|
359
|
+
const response = await this.api.fetch(`/api/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
|
|
360
|
+
return licenseActivationSchema.parse(response.data);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
304
364
|
// src/products/endpoints.ts
|
|
305
365
|
var ProductEndpoints = class {
|
|
306
366
|
constructor(api) {
|
|
@@ -325,6 +385,11 @@ var TrialEndpoints = class {
|
|
|
325
385
|
const response = await this.api.fetch(`/api/trials/${productId}/request`, "POST", target);
|
|
326
386
|
return trialSchema.parse(response.data);
|
|
327
387
|
}
|
|
388
|
+
async import(trial) {
|
|
389
|
+
const request = importTrialRequestSchema.parse(trial);
|
|
390
|
+
const response = await this.api.fetch(`/api/customers/import`, "POST", request);
|
|
391
|
+
return trialSchema.parse(response.data);
|
|
392
|
+
}
|
|
328
393
|
};
|
|
329
394
|
|
|
330
395
|
// src/index.ts
|
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.112",
|
|
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",
|