paste.gg 1.0.1 → 1.0.5

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.
@@ -1,3 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxyXG4gKiBDb3B5cmlnaHQgwqkgU2VyZW5Nb2R6MjEgMjAxOCAtIDIwMjAgQWxsIFJpZ2h0cyBSZXNlcnZlZC5cclxuICogVW5hdXRob3JpemVkIGRpc3RyaWJ1dGlvbiBvZiBhbnkgY29kZSB3aXRoaW4gdGhpcyBwcm9qZWN0IG1heSByZXN1bHQgaW4gY29uc2VxdWVuY2VzIGNob3NlbiBieSB0aGUgQm9hcmQgTWVtYmVycy5cclxuICogUmVmZXIgdG8gdGhlIFJFQURNRSBmb3IgbW9yZSBpbmZvcm1hdGlvbi5cclxuICovXHJcblxyXG5leHBvcnQgdHlwZSBJSGVhZGVyID0ge1xyXG4gIFwiQ29udGVudC1UeXBlXCI/OiBzdHJpbmc7XHJcbiAgQXV0aG9yaXphdGlvbj86IHN0cmluZztcclxufVxyXG5cclxuZXhwb3J0IGludGVyZmFjZSBQYXN0ZUdHT3B0aW9ucyB7XHJcbiAgYmFzZVVybDogc3RyaW5nO1xyXG4gIHZlcnNpb246IG51bWJlcjtcclxufVxyXG5cclxuZXhwb3J0IGludGVyZmFjZSBQYXN0ZU91dHB1dCB7XHJcbiAgc3RhdHVzOiBzdHJpbmc7XHJcbiAgcmVzdWx0Pzoge1xyXG4gICAgaWQ6IHN0cmluZztcclxuICAgIG5hbWU/OiBzdHJpbmc7XHJcbi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jtcclxuICAgIGhpZ2hsaWdodF9sYW5ndWFnZT86IHN0cmluZztcclxuICAgIHZhbHVlOiBzdHJpbmc7XHJcbiAgfVxyXG59Il19
1
+ "use strict";
2
+ /*
3
+ * Copyright © SerenModz21 2018 - 2021 All Rights Reserved.
4
+ * Unauthorized distribution of any code within this project may result in consequences chosen.
5
+ * Refer to the README for more information.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Methods = void 0;
9
+ var Methods;
10
+ (function (Methods) {
11
+ Methods["GET"] = "GET";
12
+ Methods["POST"] = "POST";
13
+ Methods["DELETE"] = "DELETE";
14
+ Methods["PATCH"] = "PATCH";
15
+ })(Methods = exports.Methods || (exports.Methods = {}));
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7OztHQUlHOzs7QUFFSCxJQUFZLE9BS1g7QUFMRCxXQUFZLE9BQU87SUFDakIsc0JBQVcsQ0FBQTtJQUNYLHdCQUFhLENBQUE7SUFDYiw0QkFBaUIsQ0FBQTtJQUNqQiwwQkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFMVyxPQUFPLEdBQVAsZUFBTyxLQUFQLGVBQU8sUUFLbEIiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQ29weXJpZ2h0IMKpIFNlcmVuTW9kejIxIDIwMTggLSAyMDIxIEFsbCBSaWdodHMgUmVzZXJ2ZWQuXG4gKiBVbmF1dGhvcml6ZWQgZGlzdHJpYnV0aW9uIG9mIGFueSBjb2RlIHdpdGhpbiB0aGlzIHByb2plY3QgbWF5IHJlc3VsdCBpbiBjb25zZXF1ZW5jZXMgY2hvc2VuLlxuICogUmVmZXIgdG8gdGhlIFJFQURNRSBmb3IgbW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cmZhY2UgUG9zdFxuICBleHRlbmRzIFBpY2s8UmVzdWx0LCBcIm5hbWVcIiB8IFwiZGVzY3JpcHRpb25cIiB8IFwidmlzaWJpbGl0eVwiIHwgXCJleHBpcmVzXCI+IHtcbiAgZmlsZXM6IEZpbGVPdXRbXTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBVcGRhdGUgZXh0ZW5kcyBQaWNrPFJlc3VsdCwgXCJuYW1lXCI+IHtcbiAgZGVzY3JpcHRpb246IHN0cmluZztcbn1cblxuZXhwb3J0IGludGVyZmFjZSBGaWxlIHtcbiAgaWQ6IHN0cmluZztcbiAgbmFtZTogc3RyaW5nO1xuICBoaWdobGlnaHRfbGFuZ3VhZ2U/OiBzdHJpbmc7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgRmlsZU91dCB7XG4gIG5hbWU/OiBzdHJpbmc7XG4gIGNvbnRlbnQ6IENvbnRlbnQ7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQ29udGVudCBleHRlbmRzIFBpY2s8RmlsZSwgXCJoaWdobGlnaHRfbGFuZ3VhZ2VcIj4ge1xuICBmb3JtYXQ6IFwidGV4dFwiIHwgXCJiYXNlNjRcIiB8IFwiZ3ppcFwiIHwgXCJ4elwiO1xuICB2YWx1ZTogc3RyaW5nO1xufVxuIl19
package/package.json CHANGED
@@ -1,29 +1,37 @@
1
- {
2
- "name": "paste.gg",
3
- "version": "1.0.1",
4
- "description": "A wrapper for the paste.gg api",
5
- "main": "dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "author": "Seren_Modz 21",
8
- "repository": "SerenModz21/paste.gg",
9
- "bugs": "https://github.com/SerenModz21/paste.gg",
10
- "license": "MIT",
11
- "keywords": [
12
- "paste.gg",
13
- "api",
14
- "wrapper"
15
- ],
16
- "scripts": {
17
- "build": "rimraf ./dist && tsc",
18
- "prepublishOnly": "yarn build"
19
- },
20
- "devDependencies": {
21
- "@types/node": "^14.14.14",
22
- "@types/node-fetch": "^2.5.7",
23
- "rimraf": "^3.0.2",
24
- "typescript": "^4.1.3"
25
- },
26
- "dependencies": {
27
- "node-fetch": "^2.6.1"
28
- }
29
- }
1
+ {
2
+ "name": "paste.gg",
3
+ "version": "1.0.5",
4
+ "description": "An easy-to-use library for interacting with the Paste.GG API. Contains examples, strong JSDocs, TypeScript types, and support for Node.js 12+. Works in both JavaScript and TypeScript.",
5
+ "main": "./dist/index.js",
6
+ "typings": "./typings/index.d.ts",
7
+ "license": "MIT",
8
+ "author": "Seren_Modz 21",
9
+ "homepage": "https://github.com/SerenModz21/paste.gg#readme",
10
+ "repository": "git://github.com/SerenModz21/paste.gg.git",
11
+ "bugs": {
12
+ "url": "https://github.com/SerenModz21/paste.gg/issues"
13
+ },
14
+ "keywords": [
15
+ "paste.gg",
16
+ "api",
17
+ "wrapper"
18
+ ],
19
+ "scripts": {
20
+ "build": "rimraf ./dist && tsc",
21
+ "test": "ts-node test/index.ts",
22
+ "prepublishOnly": "yarn build"
23
+ },
24
+ "dependencies": {
25
+ "node-fetch": "2.6.7"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^16.6.1",
29
+ "@types/node-fetch": "^2.5.10",
30
+ "rimraf": "^3.0.2",
31
+ "typescript": "^4.3.5"
32
+ },
33
+ "engines": {
34
+ "node": ">=12.0.0",
35
+ "yarn": ">=1.0.0"
36
+ }
37
+ }
@@ -0,0 +1,172 @@
1
+ import { Options, Output, Post, Update } from "./interfaces";
2
+ /**
3
+ * The main class for interacting with the Paste.gg API
4
+ */
5
+ declare class PasteGG {
6
+ #private;
7
+ readonly options: Options;
8
+ readonly version: string;
9
+ /**
10
+ * Create a new instance of PasteGG
11
+ * @param {string} auth Optional auth key
12
+ * @param {Options} options Options for the paste server
13
+ * @class PasteGG
14
+ * @public
15
+ * @example
16
+ * // If you want to be anonymous
17
+ * const pasteGG = new PasteGG()
18
+ *
19
+ * // If you want to use an api key
20
+ * const pasteGG = new PasteGG("apiKeyHere")
21
+ */
22
+ constructor(auth?: string, options?: Options);
23
+ /**
24
+ * Make a request to the API.
25
+ * @param {keyof typeof Methods} method
26
+ * @param {string} path
27
+ * @param {object} body
28
+ * @param {string} key
29
+ * @returns {Promise<T>}
30
+ * @private
31
+ */
32
+ private _request;
33
+ /**
34
+ * Get an existing paste.
35
+ * @see https://github.com/ascclemens/paste/blob/master/api.md#get-pastesid
36
+ * @param {string} id The ID of the paste.
37
+ * @param {boolean} full Includes the contents of files if true.
38
+ * @returns {Promise<Output>}
39
+ * @public
40
+ * @example
41
+ * // if you would like to exclude file contents
42
+ * await pasteGG.get("idHere")
43
+ *
44
+ * // If you would like to include file contents
45
+ * await pasteGG.get("idHere", true)
46
+ */
47
+ get(id: string, full?: boolean): Promise<Output>;
48
+ /**
49
+ * Create a new paste.
50
+ * @see https://github.com/ascclemens/paste/blob/master/api.md#post-pastes
51
+ * @param {Post} input The information to create the paste with.
52
+ * @returns {Promise<Output>}
53
+ * @public
54
+ * @example
55
+ * await pasteGG.post({
56
+ * name: "Paste name", // Optional
57
+ * description: "Paste description", // Optional
58
+ * expires: "2020-12-21T02:25:56.428Z", // Optional (must be a UTC ISO 8601 string)
59
+ * files: [{
60
+ * name: "file.txt", // Optional
61
+ * content: {
62
+ * format: "text",
63
+ * value: "This is where the file content will go"
64
+ * }
65
+ * }]
66
+ * })
67
+ */
68
+ post(input: Post): Promise<Output>;
69
+ /**
70
+ * Deletes an existing paste.
71
+ * @see https://github.com/ascclemens/paste/blob/master/api.md#delete-pastesid
72
+ * @param {string} id The ID of the paste to delete.
73
+ * @param {string} [key] Auth key or deletion key (leave blank if you have set the auth key in the constructor)
74
+ * @returns {Promise<Output | void>}
75
+ * @public
76
+ * @example
77
+ * // Delete with deletion key
78
+ * await pasteGG.delete("idHere", "deletionKeyHere")
79
+ *
80
+ * // Delete with auth key if not set in constructor
81
+ * await pasteGG.delete("idHere", "authKeyHere")
82
+ *
83
+ * // Leave blank if auth key is in the class constructor
84
+ * await pasteGG.delete("idHere")
85
+ */
86
+ delete(id: string, key?: string): Promise<Output | void>;
87
+ /**
88
+ * Update an existing paste.
89
+ * @see https://github.com/ascclemens/paste/blob/master/api.md#patch-pastesid
90
+ * @param {string} id The ID for the paste to update.
91
+ * @param {Update} options The options you wish to update.
92
+ * @returns {Promise<Output | void>}
93
+ * @public
94
+ * @example
95
+ * await pasteGG.update("idHere", {
96
+ * name: "new name", // Optional (if you want to remove the name)
97
+ * description: "new description"
98
+ * })
99
+ */
100
+ update(id: string, options: Update): Promise<Output | void>;
101
+ }
102
+ export { PasteGG };
103
+ export default PasteGG;
104
+ /**
105
+ * The header options
106
+ * @typedef {IHeader} IHeader
107
+ * @property {string} [Content-Type] The request content type
108
+ * @property {string} [Authorization] Authorization for the request
109
+ */
110
+ /**
111
+ * @typedef {Options} Options
112
+ * @property {string} [baseUrl=https://api.paste.gg] The base URL of the API
113
+ * @property {string} [mainUrl=https://paste.gg] The URL of the main website
114
+ * @property {number} [version=1] The version of the API
115
+ */
116
+ /**
117
+ * @typedef {Result} Result
118
+ * @property {string} id The ID of the created paste
119
+ * @property {string} [name] The name of the created paste
120
+ * @property {string} [url] The URL for the result
121
+ * @property {Author} [author] The author of the paste
122
+ * @property {string} [description] The description of the created paste
123
+ * @property {public | unlisted | private} [visibility=unlisted] The visibility of the created paste
124
+ * @property {string} created_at The date the paste was created
125
+ * @property {string} updated_at The date the paste was last updated
126
+ * @property {string} [expires] The date when the paste expires
127
+ * @property {File[]} [files] The files used in the created paste
128
+ * @property {string} [deletion_key] The deletion key of the created paste
129
+ */
130
+ /**
131
+ * @typedef {Output} Output
132
+ * @property {string} status The output status
133
+ * @property {Result} [result] The result data object
134
+ * @property {string} [error] The error key
135
+ * @property {string} [message] The error message
136
+ */
137
+ /**
138
+ * @typedef {Post} Post
139
+ * @property {string} [name] The name of the paste
140
+ * @property {string} [description] The description of the paste (must be less than 25 KiB)
141
+ * @property {public | unlisted | private} [visibility=unlisted] The visibility of the paste
142
+ * @property {string} [expires] The expiration date of the paste (must be a UTC ISO 8601 string)
143
+ * @property {FileOut[]} files Array of files to add to the paste (at least one file)
144
+ */
145
+ /**
146
+ * @typedef {Author} Author
147
+ * @property {string} [id] The ID of the author
148
+ * @property {string} [username] The username of the author
149
+ * @property {string} [name] The name of the author
150
+ */
151
+ /**
152
+ * @typedef {Update} Update
153
+ * @property {string} [name] The new name of the post
154
+ * @property {string} description The new description of the post
155
+ */
156
+ /**
157
+ * @typedef {File} File
158
+ * @property {string} id The ID of the file
159
+ * @property {string} name The name of the file
160
+ * @property {string | null} highlight_language The syntax highlighting language used
161
+ */
162
+ /**
163
+ * @typedef {Content} Content
164
+ * @property {text | base64 | gzip | xz} format The format of the file
165
+ * @property {string} [highlight_language] The syntax highlighting language to use
166
+ * @property {string} value The value of the file contents
167
+ */
168
+ /**
169
+ * @typedef {FileOut} FileOut
170
+ * @property {string} [name] The name of the file
171
+ * @property {Content} content The content of the file
172
+ */
@@ -0,0 +1,58 @@
1
+ export declare enum Methods {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ DELETE = "DELETE",
5
+ PATCH = "PATCH"
6
+ }
7
+ export declare type IHeader = {
8
+ "Content-Type"?: string;
9
+ Authorization?: string;
10
+ };
11
+ export interface Options {
12
+ baseUrl: string;
13
+ mainUrl: string;
14
+ version: number;
15
+ }
16
+ export interface Result {
17
+ id: string;
18
+ name?: string;
19
+ url?: string;
20
+ author?: Author;
21
+ description?: string;
22
+ visibility?: "public" | "unlisted" | "private";
23
+ created_at: string;
24
+ updated_at: string;
25
+ expires?: string;
26
+ files?: File[];
27
+ deletion_key?: string;
28
+ }
29
+ export interface Output {
30
+ status: string;
31
+ result?: Result;
32
+ error?: string;
33
+ message?: string;
34
+ }
35
+ export interface Author {
36
+ id?: string;
37
+ username?: string;
38
+ name?: string;
39
+ }
40
+ export interface Post extends Pick<Result, "name" | "description" | "visibility" | "expires"> {
41
+ files: FileOut[];
42
+ }
43
+ export interface Update extends Pick<Result, "name"> {
44
+ description: string;
45
+ }
46
+ export interface File {
47
+ id: string;
48
+ name: string;
49
+ highlight_language?: string;
50
+ }
51
+ export interface FileOut {
52
+ name?: string;
53
+ content: Content;
54
+ }
55
+ export interface Content extends Pick<File, "highlight_language"> {
56
+ format: "text" | "base64" | "gzip" | "xz";
57
+ value: string;
58
+ }
@@ -1,28 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <DBN-PSQL>
4
- <case-options enabled="true">
5
- <option name="KEYWORD_CASE" value="lower" />
6
- <option name="FUNCTION_CASE" value="lower" />
7
- <option name="PARAMETER_CASE" value="lower" />
8
- <option name="DATATYPE_CASE" value="lower" />
9
- <option name="OBJECT_CASE" value="preserve" />
10
- </case-options>
11
- <formatting-settings enabled="false" />
12
- </DBN-PSQL>
13
- <DBN-SQL>
14
- <case-options enabled="true">
15
- <option name="KEYWORD_CASE" value="lower" />
16
- <option name="FUNCTION_CASE" value="lower" />
17
- <option name="PARAMETER_CASE" value="lower" />
18
- <option name="DATATYPE_CASE" value="lower" />
19
- <option name="OBJECT_CASE" value="preserve" />
20
- </case-options>
21
- <formatting-settings enabled="false">
22
- <option name="STATEMENT_SPACING" value="one_line" />
23
- <option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
24
- <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
25
- </formatting-settings>
26
- </DBN-SQL>
27
- </code_scheme>
28
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>