@timbrix/sdk 0.1.0 → 0.3.1
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.d.mts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +47 -2
- package/dist/index.mjs +46 -2
- package/package.json +9 -5
package/dist/index.d.mts
CHANGED
|
@@ -390,6 +390,24 @@ interface ListProductsFilters {
|
|
|
390
390
|
sku?: string;
|
|
391
391
|
productKey?: number;
|
|
392
392
|
}
|
|
393
|
+
type TipoPersona = "fisica" | "moral" | "ambas";
|
|
394
|
+
interface RegimenFiscal {
|
|
395
|
+
codigo: string;
|
|
396
|
+
descripcion: string;
|
|
397
|
+
tipoPersona: TipoPersona;
|
|
398
|
+
}
|
|
399
|
+
interface UsoCfdi {
|
|
400
|
+
codigo: string;
|
|
401
|
+
descripcion: string;
|
|
402
|
+
tipoPersona: TipoPersona;
|
|
403
|
+
}
|
|
404
|
+
interface ListRegimenesParams {
|
|
405
|
+
tipoPersona?: TipoPersona;
|
|
406
|
+
}
|
|
407
|
+
interface ListUsosCfdiParams {
|
|
408
|
+
tipoPersona?: TipoPersona;
|
|
409
|
+
regimen?: string;
|
|
410
|
+
}
|
|
393
411
|
interface TimbrixError {
|
|
394
412
|
statusCode: number;
|
|
395
413
|
message: string | string[];
|
|
@@ -586,6 +604,21 @@ declare class ProductsResource {
|
|
|
586
604
|
delete(organizationId: string, productId: string): Promise<void>;
|
|
587
605
|
}
|
|
588
606
|
|
|
607
|
+
declare class SatResource {
|
|
608
|
+
private http;
|
|
609
|
+
constructor(http: KyInstance);
|
|
610
|
+
/**
|
|
611
|
+
* List régimenes fiscales from the SAT catalog
|
|
612
|
+
* Calls GET /sat/regimenes-fiscales
|
|
613
|
+
*/
|
|
614
|
+
regimenes(params?: ListRegimenesParams): Promise<RegimenFiscal[]>;
|
|
615
|
+
/**
|
|
616
|
+
* List usos CFDI from the SAT catalog
|
|
617
|
+
* Calls GET /sat/usos-cfdi
|
|
618
|
+
*/
|
|
619
|
+
usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
|
|
620
|
+
}
|
|
621
|
+
|
|
589
622
|
declare class UsersResource {
|
|
590
623
|
private http;
|
|
591
624
|
constructor(http: KyInstance);
|
|
@@ -653,6 +686,7 @@ declare class Timbrix {
|
|
|
653
686
|
readonly customers: CustomersResource;
|
|
654
687
|
readonly oauth: OAuthResource;
|
|
655
688
|
readonly products: ProductsResource;
|
|
689
|
+
readonly sat: SatResource;
|
|
656
690
|
constructor(config?: TimbrixConfig);
|
|
657
691
|
/**
|
|
658
692
|
* Update authentication strategy (useful for CLI when token changes)
|
|
@@ -681,4 +715,4 @@ declare class ApiKeyAuth implements AuthStrategy {
|
|
|
681
715
|
applyAuth(options: Options): Options;
|
|
682
716
|
}
|
|
683
717
|
|
|
684
|
-
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type LegalAddress, type ListProductsFilters, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
|
718
|
+
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type LegalAddress, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -390,6 +390,24 @@ interface ListProductsFilters {
|
|
|
390
390
|
sku?: string;
|
|
391
391
|
productKey?: number;
|
|
392
392
|
}
|
|
393
|
+
type TipoPersona = "fisica" | "moral" | "ambas";
|
|
394
|
+
interface RegimenFiscal {
|
|
395
|
+
codigo: string;
|
|
396
|
+
descripcion: string;
|
|
397
|
+
tipoPersona: TipoPersona;
|
|
398
|
+
}
|
|
399
|
+
interface UsoCfdi {
|
|
400
|
+
codigo: string;
|
|
401
|
+
descripcion: string;
|
|
402
|
+
tipoPersona: TipoPersona;
|
|
403
|
+
}
|
|
404
|
+
interface ListRegimenesParams {
|
|
405
|
+
tipoPersona?: TipoPersona;
|
|
406
|
+
}
|
|
407
|
+
interface ListUsosCfdiParams {
|
|
408
|
+
tipoPersona?: TipoPersona;
|
|
409
|
+
regimen?: string;
|
|
410
|
+
}
|
|
393
411
|
interface TimbrixError {
|
|
394
412
|
statusCode: number;
|
|
395
413
|
message: string | string[];
|
|
@@ -586,6 +604,21 @@ declare class ProductsResource {
|
|
|
586
604
|
delete(organizationId: string, productId: string): Promise<void>;
|
|
587
605
|
}
|
|
588
606
|
|
|
607
|
+
declare class SatResource {
|
|
608
|
+
private http;
|
|
609
|
+
constructor(http: KyInstance);
|
|
610
|
+
/**
|
|
611
|
+
* List régimenes fiscales from the SAT catalog
|
|
612
|
+
* Calls GET /sat/regimenes-fiscales
|
|
613
|
+
*/
|
|
614
|
+
regimenes(params?: ListRegimenesParams): Promise<RegimenFiscal[]>;
|
|
615
|
+
/**
|
|
616
|
+
* List usos CFDI from the SAT catalog
|
|
617
|
+
* Calls GET /sat/usos-cfdi
|
|
618
|
+
*/
|
|
619
|
+
usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
|
|
620
|
+
}
|
|
621
|
+
|
|
589
622
|
declare class UsersResource {
|
|
590
623
|
private http;
|
|
591
624
|
constructor(http: KyInstance);
|
|
@@ -653,6 +686,7 @@ declare class Timbrix {
|
|
|
653
686
|
readonly customers: CustomersResource;
|
|
654
687
|
readonly oauth: OAuthResource;
|
|
655
688
|
readonly products: ProductsResource;
|
|
689
|
+
readonly sat: SatResource;
|
|
656
690
|
constructor(config?: TimbrixConfig);
|
|
657
691
|
/**
|
|
658
692
|
* Update authentication strategy (useful for CLI when token changes)
|
|
@@ -681,4 +715,4 @@ declare class ApiKeyAuth implements AuthStrategy {
|
|
|
681
715
|
applyAuth(options: Options): Options;
|
|
682
716
|
}
|
|
683
717
|
|
|
684
|
-
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type LegalAddress, type ListProductsFilters, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
|
718
|
+
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type LegalAddress, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
OAuthResource: () => OAuthResource,
|
|
39
39
|
OrganizationsResource: () => OrganizationsResource,
|
|
40
40
|
ProductsResource: () => ProductsResource,
|
|
41
|
+
SatResource: () => SatResource,
|
|
41
42
|
Timbrix: () => Timbrix,
|
|
42
43
|
UsersResource: () => UsersResource,
|
|
43
44
|
WebhooksResource: () => WebhooksResource
|
|
@@ -52,6 +53,7 @@ var BearerAuth = class {
|
|
|
52
53
|
constructor(token) {
|
|
53
54
|
this.token = token;
|
|
54
55
|
}
|
|
56
|
+
token;
|
|
55
57
|
getHeaders() {
|
|
56
58
|
return {
|
|
57
59
|
Authorization: `Bearer ${this.token}`
|
|
@@ -71,6 +73,7 @@ var ApiKeyAuth = class {
|
|
|
71
73
|
constructor(apiKey) {
|
|
72
74
|
this.apiKey = apiKey;
|
|
73
75
|
}
|
|
76
|
+
apiKey;
|
|
74
77
|
getHeaders() {
|
|
75
78
|
return {
|
|
76
79
|
"X-API-Key": this.apiKey
|
|
@@ -92,6 +95,7 @@ var ApiKeysResource = class {
|
|
|
92
95
|
constructor(http) {
|
|
93
96
|
this.http = http;
|
|
94
97
|
}
|
|
98
|
+
http;
|
|
95
99
|
/**
|
|
96
100
|
* List all API keys for an organization
|
|
97
101
|
*/
|
|
@@ -145,6 +149,7 @@ var AuthResource = class {
|
|
|
145
149
|
constructor(http) {
|
|
146
150
|
this.http = http;
|
|
147
151
|
}
|
|
152
|
+
http;
|
|
148
153
|
/**
|
|
149
154
|
* Login with email and password. Returns an access token.
|
|
150
155
|
*/
|
|
@@ -164,6 +169,7 @@ var CustomersResource = class {
|
|
|
164
169
|
constructor(http) {
|
|
165
170
|
this.http = http;
|
|
166
171
|
}
|
|
172
|
+
http;
|
|
167
173
|
/**
|
|
168
174
|
* List all customers for an organization
|
|
169
175
|
*/
|
|
@@ -205,6 +211,7 @@ var OAuthResource = class {
|
|
|
205
211
|
constructor(http) {
|
|
206
212
|
this.http = http;
|
|
207
213
|
}
|
|
214
|
+
http;
|
|
208
215
|
// ─── App Management ─────────────────────────────────────────────────────────
|
|
209
216
|
/**
|
|
210
217
|
* Create a new OAuth application. Client secret is returned only once.
|
|
@@ -293,6 +300,7 @@ var OrganizationsResource = class {
|
|
|
293
300
|
constructor(http) {
|
|
294
301
|
this.http = http;
|
|
295
302
|
}
|
|
303
|
+
http;
|
|
296
304
|
/**
|
|
297
305
|
* Create a new organization
|
|
298
306
|
*/
|
|
@@ -366,6 +374,7 @@ var ProductsResource = class {
|
|
|
366
374
|
constructor(http) {
|
|
367
375
|
this.http = http;
|
|
368
376
|
}
|
|
377
|
+
http;
|
|
369
378
|
/**
|
|
370
379
|
* List products for an organization, with optional filters
|
|
371
380
|
*/
|
|
@@ -409,11 +418,43 @@ var ProductsResource = class {
|
|
|
409
418
|
}
|
|
410
419
|
};
|
|
411
420
|
|
|
421
|
+
// src/resources/sat.ts
|
|
422
|
+
var SatResource = class {
|
|
423
|
+
constructor(http) {
|
|
424
|
+
this.http = http;
|
|
425
|
+
}
|
|
426
|
+
http;
|
|
427
|
+
/**
|
|
428
|
+
* List régimenes fiscales from the SAT catalog
|
|
429
|
+
* Calls GET /sat/regimenes-fiscales
|
|
430
|
+
*/
|
|
431
|
+
async regimenes(params) {
|
|
432
|
+
const searchParams = {};
|
|
433
|
+
if (params?.tipoPersona) searchParams.tipoPersona = params.tipoPersona;
|
|
434
|
+
return this.http.get("sat/regimenes-fiscales", {
|
|
435
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
436
|
+
}).json();
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* List usos CFDI from the SAT catalog
|
|
440
|
+
* Calls GET /sat/usos-cfdi
|
|
441
|
+
*/
|
|
442
|
+
async usosCfdi(params) {
|
|
443
|
+
const searchParams = {};
|
|
444
|
+
if (params?.tipoPersona) searchParams.tipoPersona = params.tipoPersona;
|
|
445
|
+
if (params?.regimen) searchParams.regimen = params.regimen;
|
|
446
|
+
return this.http.get("sat/usos-cfdi", {
|
|
447
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
448
|
+
}).json();
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
412
452
|
// src/resources/users.ts
|
|
413
453
|
var UsersResource = class {
|
|
414
454
|
constructor(http) {
|
|
415
455
|
this.http = http;
|
|
416
456
|
}
|
|
457
|
+
http;
|
|
417
458
|
/**
|
|
418
459
|
* Get the currently authenticated user
|
|
419
460
|
*/
|
|
@@ -445,6 +486,7 @@ var WebhooksResource = class {
|
|
|
445
486
|
constructor(http) {
|
|
446
487
|
this.http = http;
|
|
447
488
|
}
|
|
489
|
+
http;
|
|
448
490
|
/**
|
|
449
491
|
* List all webhooks for an organization
|
|
450
492
|
*/
|
|
@@ -505,8 +547,9 @@ var Timbrix = class {
|
|
|
505
547
|
customers;
|
|
506
548
|
oauth;
|
|
507
549
|
products;
|
|
550
|
+
sat;
|
|
508
551
|
constructor(config = {}) {
|
|
509
|
-
const baseUrl = config.baseUrl || "http://localhost:3001
|
|
552
|
+
const baseUrl = config.baseUrl || "http://localhost:3001";
|
|
510
553
|
if (config.bearerToken) {
|
|
511
554
|
this.authStrategy = new BearerAuth(config.bearerToken);
|
|
512
555
|
} else if (config.apiKey) {
|
|
@@ -519,7 +562,7 @@ var Timbrix = class {
|
|
|
519
562
|
},
|
|
520
563
|
hooks: {
|
|
521
564
|
beforeRequest: [
|
|
522
|
-
(request) => {
|
|
565
|
+
({ request }) => {
|
|
523
566
|
if (this.authStrategy) {
|
|
524
567
|
const authHeaders = this.authStrategy.getHeaders();
|
|
525
568
|
Object.entries(authHeaders).forEach(([key, value]) => {
|
|
@@ -538,6 +581,7 @@ var Timbrix = class {
|
|
|
538
581
|
this.customers = new CustomersResource(this.http);
|
|
539
582
|
this.oauth = new OAuthResource(this.http);
|
|
540
583
|
this.products = new ProductsResource(this.http);
|
|
584
|
+
this.sat = new SatResource(this.http);
|
|
541
585
|
}
|
|
542
586
|
/**
|
|
543
587
|
* Update authentication strategy (useful for CLI when token changes)
|
|
@@ -568,6 +612,7 @@ var Timbrix = class {
|
|
|
568
612
|
OAuthResource,
|
|
569
613
|
OrganizationsResource,
|
|
570
614
|
ProductsResource,
|
|
615
|
+
SatResource,
|
|
571
616
|
Timbrix,
|
|
572
617
|
UsersResource,
|
|
573
618
|
WebhooksResource
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ var BearerAuth = class {
|
|
|
6
6
|
constructor(token) {
|
|
7
7
|
this.token = token;
|
|
8
8
|
}
|
|
9
|
+
token;
|
|
9
10
|
getHeaders() {
|
|
10
11
|
return {
|
|
11
12
|
Authorization: `Bearer ${this.token}`
|
|
@@ -25,6 +26,7 @@ var ApiKeyAuth = class {
|
|
|
25
26
|
constructor(apiKey) {
|
|
26
27
|
this.apiKey = apiKey;
|
|
27
28
|
}
|
|
29
|
+
apiKey;
|
|
28
30
|
getHeaders() {
|
|
29
31
|
return {
|
|
30
32
|
"X-API-Key": this.apiKey
|
|
@@ -46,6 +48,7 @@ var ApiKeysResource = class {
|
|
|
46
48
|
constructor(http) {
|
|
47
49
|
this.http = http;
|
|
48
50
|
}
|
|
51
|
+
http;
|
|
49
52
|
/**
|
|
50
53
|
* List all API keys for an organization
|
|
51
54
|
*/
|
|
@@ -99,6 +102,7 @@ var AuthResource = class {
|
|
|
99
102
|
constructor(http) {
|
|
100
103
|
this.http = http;
|
|
101
104
|
}
|
|
105
|
+
http;
|
|
102
106
|
/**
|
|
103
107
|
* Login with email and password. Returns an access token.
|
|
104
108
|
*/
|
|
@@ -118,6 +122,7 @@ var CustomersResource = class {
|
|
|
118
122
|
constructor(http) {
|
|
119
123
|
this.http = http;
|
|
120
124
|
}
|
|
125
|
+
http;
|
|
121
126
|
/**
|
|
122
127
|
* List all customers for an organization
|
|
123
128
|
*/
|
|
@@ -159,6 +164,7 @@ var OAuthResource = class {
|
|
|
159
164
|
constructor(http) {
|
|
160
165
|
this.http = http;
|
|
161
166
|
}
|
|
167
|
+
http;
|
|
162
168
|
// ─── App Management ─────────────────────────────────────────────────────────
|
|
163
169
|
/**
|
|
164
170
|
* Create a new OAuth application. Client secret is returned only once.
|
|
@@ -247,6 +253,7 @@ var OrganizationsResource = class {
|
|
|
247
253
|
constructor(http) {
|
|
248
254
|
this.http = http;
|
|
249
255
|
}
|
|
256
|
+
http;
|
|
250
257
|
/**
|
|
251
258
|
* Create a new organization
|
|
252
259
|
*/
|
|
@@ -320,6 +327,7 @@ var ProductsResource = class {
|
|
|
320
327
|
constructor(http) {
|
|
321
328
|
this.http = http;
|
|
322
329
|
}
|
|
330
|
+
http;
|
|
323
331
|
/**
|
|
324
332
|
* List products for an organization, with optional filters
|
|
325
333
|
*/
|
|
@@ -363,11 +371,43 @@ var ProductsResource = class {
|
|
|
363
371
|
}
|
|
364
372
|
};
|
|
365
373
|
|
|
374
|
+
// src/resources/sat.ts
|
|
375
|
+
var SatResource = class {
|
|
376
|
+
constructor(http) {
|
|
377
|
+
this.http = http;
|
|
378
|
+
}
|
|
379
|
+
http;
|
|
380
|
+
/**
|
|
381
|
+
* List régimenes fiscales from the SAT catalog
|
|
382
|
+
* Calls GET /sat/regimenes-fiscales
|
|
383
|
+
*/
|
|
384
|
+
async regimenes(params) {
|
|
385
|
+
const searchParams = {};
|
|
386
|
+
if (params?.tipoPersona) searchParams.tipoPersona = params.tipoPersona;
|
|
387
|
+
return this.http.get("sat/regimenes-fiscales", {
|
|
388
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
389
|
+
}).json();
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* List usos CFDI from the SAT catalog
|
|
393
|
+
* Calls GET /sat/usos-cfdi
|
|
394
|
+
*/
|
|
395
|
+
async usosCfdi(params) {
|
|
396
|
+
const searchParams = {};
|
|
397
|
+
if (params?.tipoPersona) searchParams.tipoPersona = params.tipoPersona;
|
|
398
|
+
if (params?.regimen) searchParams.regimen = params.regimen;
|
|
399
|
+
return this.http.get("sat/usos-cfdi", {
|
|
400
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
401
|
+
}).json();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
|
|
366
405
|
// src/resources/users.ts
|
|
367
406
|
var UsersResource = class {
|
|
368
407
|
constructor(http) {
|
|
369
408
|
this.http = http;
|
|
370
409
|
}
|
|
410
|
+
http;
|
|
371
411
|
/**
|
|
372
412
|
* Get the currently authenticated user
|
|
373
413
|
*/
|
|
@@ -399,6 +439,7 @@ var WebhooksResource = class {
|
|
|
399
439
|
constructor(http) {
|
|
400
440
|
this.http = http;
|
|
401
441
|
}
|
|
442
|
+
http;
|
|
402
443
|
/**
|
|
403
444
|
* List all webhooks for an organization
|
|
404
445
|
*/
|
|
@@ -459,8 +500,9 @@ var Timbrix = class {
|
|
|
459
500
|
customers;
|
|
460
501
|
oauth;
|
|
461
502
|
products;
|
|
503
|
+
sat;
|
|
462
504
|
constructor(config = {}) {
|
|
463
|
-
const baseUrl = config.baseUrl || "http://localhost:3001
|
|
505
|
+
const baseUrl = config.baseUrl || "http://localhost:3001";
|
|
464
506
|
if (config.bearerToken) {
|
|
465
507
|
this.authStrategy = new BearerAuth(config.bearerToken);
|
|
466
508
|
} else if (config.apiKey) {
|
|
@@ -473,7 +515,7 @@ var Timbrix = class {
|
|
|
473
515
|
},
|
|
474
516
|
hooks: {
|
|
475
517
|
beforeRequest: [
|
|
476
|
-
(request) => {
|
|
518
|
+
({ request }) => {
|
|
477
519
|
if (this.authStrategy) {
|
|
478
520
|
const authHeaders = this.authStrategy.getHeaders();
|
|
479
521
|
Object.entries(authHeaders).forEach(([key, value]) => {
|
|
@@ -492,6 +534,7 @@ var Timbrix = class {
|
|
|
492
534
|
this.customers = new CustomersResource(this.http);
|
|
493
535
|
this.oauth = new OAuthResource(this.http);
|
|
494
536
|
this.products = new ProductsResource(this.http);
|
|
537
|
+
this.sat = new SatResource(this.http);
|
|
495
538
|
}
|
|
496
539
|
/**
|
|
497
540
|
* Update authentication strategy (useful for CLI when token changes)
|
|
@@ -521,6 +564,7 @@ export {
|
|
|
521
564
|
OAuthResource,
|
|
522
565
|
OrganizationsResource,
|
|
523
566
|
ProductsResource,
|
|
567
|
+
SatResource,
|
|
524
568
|
Timbrix,
|
|
525
569
|
UsersResource,
|
|
526
570
|
WebhooksResource
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timbrix/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "TypeScript SDK for Timbrix API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -22,14 +22,18 @@
|
|
|
22
22
|
"sdk"
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"ky": "^
|
|
30
|
+
"ky": "^2.0.2"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"tsup": "^8.5.1",
|
|
30
|
-
"typescript": "^
|
|
31
|
-
"@repo/
|
|
32
|
-
"@repo/
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"@repo/typescript-config": "0.1.0",
|
|
36
|
+
"@repo/eslint-config": "0.1.1"
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|