-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Osorio
committed
Jul 3, 2024
1 parent
8a9cd4c
commit 051559c
Showing
16 changed files
with
321 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
!/README_EN.md | ||
!/package.json | ||
!/cjs/**/* | ||
!/types/**/* | ||
!/esm/**/* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Redoc } from "./index"; | ||
import { Redoc } from "./redoc"; | ||
|
||
module.exports = Redoc; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { Redoc } from "./index.js"; | ||
import { Redoc } from "./redoc.js"; | ||
|
||
export default Redoc |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="./File.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace Addenda { | ||
type ReplaceOptions = { | ||
[key: string]: string; | ||
} | ||
} | ||
|
||
class Addenda extends File { | ||
constructor(); | ||
|
||
replaceValues(content: string, options?: Addenda.ReplaceOptions | null): string; | ||
|
||
getFileContent(replaceValues: Addenda.ReplaceOptions): Promise<string>; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/// <reference types="node" /> | ||
/// <reference path="./Service.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace Assets { | ||
|
||
type AssetType = 'folder' | 'image'; | ||
|
||
interface Asset { | ||
path: string; | ||
created_at: string, | ||
updated_at: string, | ||
type: AssetType, | ||
name: string, | ||
metadata: object, | ||
tags: Array<object>, | ||
parent_id: string, | ||
} | ||
|
||
interface Folder extends Asset { | ||
folder_items_count: number, | ||
} | ||
|
||
interface Image extends Asset { | ||
image_type: string, | ||
image_size: number, | ||
url: string, | ||
url_small: string | ||
} | ||
|
||
namespace Service { | ||
|
||
interface BasicParams { | ||
path: string; | ||
} | ||
|
||
interface FetchParams extends BasicParams { | ||
path: string; | ||
options?: Network.Request.Options; | ||
} | ||
|
||
interface PutParams extends BasicParams { | ||
file: File.Result; | ||
} | ||
|
||
interface DeleteParams extends BasicParams {} | ||
|
||
} | ||
} | ||
|
||
class Assets { | ||
service: Service; | ||
|
||
constructor(service: Service); | ||
|
||
get(path: string): Promise<Assets.Image>; | ||
|
||
delete(path: string): Promise<void>; | ||
|
||
list(path: string, options: Network.Request.Pagination.Options): Promise<Network.Request.Pagination.Response<Assets.Asset>>; | ||
|
||
put(path: string, source: string | Buffer): Promise<Assets.Asset>; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// <reference path="./File.d.ts" /> | ||
/// <reference path="./Pdf.d.ts" /> | ||
/// <reference path="./Addenda.d.ts" /> | ||
/// <reference path="./Service.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace Cfdi { | ||
type Metadata = { | ||
[key: string]: string; | ||
} | ||
|
||
namespace Convert { | ||
interface Params { | ||
file: File.Result; | ||
payload?: Pdf.Payload; | ||
} | ||
} | ||
} | ||
|
||
class Cfdi extends File { | ||
pdf: Pdf | null; | ||
service: Service; | ||
addenda: Addenda | null; | ||
addendaReplaceValues: Addenda.ReplaceOptions | null; | ||
|
||
constructor(service: Service); | ||
|
||
setAddenda(addenda: Addenda, replaceValues?: any): void; | ||
|
||
toPdf(payload?: Pdf.Payload): Promise<Pdf>; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/// <reference types="node" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace File { | ||
interface Result { | ||
content: string | Buffer; | ||
type: string; | ||
} | ||
} | ||
|
||
class File { | ||
filePath: string | null; | ||
fileBuffer: Buffer | null; | ||
fileContent: string | null; | ||
|
||
constructor(); | ||
|
||
fromFile(filePath: string): this; | ||
|
||
fromBuffer(fileBuffer: Buffer): this; | ||
|
||
fromString(fileContent: string): this; | ||
|
||
getFile(): Promise<{ | ||
content: string; | ||
type: string; | ||
} | { | ||
content: Buffer; | ||
type: string; | ||
}>; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference path="./File.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
namespace Network { | ||
namespace Request { | ||
|
||
interface Options { | ||
headers?: { [key: string]: any }; | ||
body?: { [key: string]: any } | FormData; | ||
params?: { [key: string]: any }; | ||
isForm?: boolean; | ||
isBufferResponse?: boolean; | ||
} | ||
|
||
namespace Pagination { | ||
|
||
interface Options { | ||
nextToken?: string; | ||
limit?: number; | ||
} | ||
|
||
interface Response<T> { | ||
data: Array<T>; | ||
pagination: { | ||
limit: number; | ||
has_more: boolean; | ||
next_token: string | null | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/// <reference path="./File.d.ts" /> | ||
/// <reference path="./Cfdi.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace Pdf { | ||
|
||
interface ConstructorParams { | ||
buffer: Buffer; | ||
transactionId: string; | ||
totalPages: number; | ||
totalTime: number; | ||
metadata: Cfdi.Metadata | ||
} | ||
|
||
interface Payload { | ||
style_pdf?: string; | ||
format?: string; | ||
addenda?: string; | ||
} | ||
} | ||
|
||
class Pdf { | ||
buffer: Buffer; | ||
transactionId: string; | ||
totalPages: number; | ||
totalTime: number; | ||
metadata: Cfdi.Metadata; | ||
|
||
constructor({ buffer, transactionId, totalPages, totalTime, metadata }: Pdf.ConstructorParams); | ||
|
||
toBuffer(): Buffer; | ||
|
||
getTransactionId(): string; | ||
|
||
getTotalPages(): number; | ||
|
||
getTotalTimeMs(): number; | ||
|
||
getMetadata(): Cfdi.Metadata; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// <reference types="node" /> | ||
/// <reference path="./Global.d.ts" /> | ||
/// <reference path="./Cfdi.d.ts" /> | ||
/// <reference path="./Assets.d.ts" /> | ||
|
||
declare module 'redocmx' { | ||
namespace Redoc { | ||
|
||
namespace Service { | ||
interface ConstructorParams { | ||
apiKey: string; | ||
apiUrl?: string; | ||
} | ||
} | ||
|
||
class Service { | ||
apiKey?: string; | ||
apiUrl?: string; | ||
|
||
constructor(config?: string | Service.ConstructorParams); | ||
|
||
cfdisConvert({ file, payload }: Cfdi.Convert.Params): Promise<Pdf.ConstructorParams>; | ||
|
||
fetchAssets({ path, options }: Assets.Service.FetchParams): Promise<Network.Request.Pagination.Response<Assets.Asset>>; | ||
|
||
putAsset({ path, file }: Assets.Service.PutParams): Promise<Assets.Asset>; | ||
|
||
deleteAsset({ path }: Assets.Service.BasicParams): Promise<void>; | ||
|
||
_request(endpoint: string, method: string, config?: Network.Request.Options): Promise<{ | ||
code: number; | ||
data: any; | ||
headers: Headers; | ||
}>; | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
///<reference path='./Addenda.d.ts' /> | ||
///<reference path='./Assets.d.ts' /> | ||
///<reference path='./Cfdi.d.ts' /> | ||
///<reference path='./File.d.ts' /> | ||
///<reference path='./Pdf.d.ts' /> | ||
///<reference path='./Service.d.ts' /> | ||
|
||
declare module 'redocmx' { | ||
// Added to in other modules, referenced above. | ||
export namespace Redoc { | ||
interface ConstructorParams { | ||
apiKey: string; | ||
apiUrl?: string; | ||
} | ||
} | ||
|
||
export class Redoc { | ||
static Redoc: typeof Redoc; | ||
|
||
constructor(config: string | Redoc.ConstructorParams); | ||
|
||
apiKey?: string; | ||
service?: Redoc.Service; | ||
|
||
get cfdi(): Redoc.Cfdi; | ||
get addenda(): Redoc.Addenda; | ||
get assets(): Redoc.Assets; | ||
} | ||
|
||
export default Redoc; | ||
} |