@getpagr/cli 1.0.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/LICENSE +21 -0
- package/README.md +412 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +63 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/init.d.ts +15 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +337 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +52 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/login.d.ts +14 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +201 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/login.test.d.ts +2 -0
- package/dist/commands/login.test.d.ts.map +1 -0
- package/dist/commands/login.test.js +34 -0
- package/dist/commands/login.test.js.map +1 -0
- package/dist/commands/remove.d.ts +13 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +43 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/upload.d.ts +53 -0
- package/dist/commands/upload.d.ts.map +1 -0
- package/dist/commands/upload.js +186 -0
- package/dist/commands/upload.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +52 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +140 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +10 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/meta.d.ts +5 -0
- package/dist/lib/meta.d.ts.map +1 -0
- package/dist/lib/meta.js +35 -0
- package/dist/lib/meta.js.map +1 -0
- package/dist/lib/meta.test.d.ts +2 -0
- package/dist/lib/meta.test.d.ts.map +1 -0
- package/dist/lib/meta.test.js +81 -0
- package/dist/lib/meta.test.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { buildCliLoginUrl, validateCallbackPayload } from './login.js';
|
|
3
|
+
describe('buildCliLoginUrl', () => {
|
|
4
|
+
it('builds a /cli URL with callback and state', () => {
|
|
5
|
+
vi.stubEnv('PAGR_APP_URL', 'https://app.getpagr.co');
|
|
6
|
+
const url = new URL(buildCliLoginUrl('http://127.0.0.1:51234/callback', 'state-123'));
|
|
7
|
+
expect(url.origin).toBe('https://app.getpagr.co');
|
|
8
|
+
expect(url.pathname).toBe('/cli');
|
|
9
|
+
expect(url.searchParams.get('callback')).toBe('http://127.0.0.1:51234/callback');
|
|
10
|
+
expect(url.searchParams.get('state')).toBe('state-123');
|
|
11
|
+
vi.unstubAllEnvs();
|
|
12
|
+
});
|
|
13
|
+
it('normalizes custom app URLs to /cli', () => {
|
|
14
|
+
vi.stubEnv('PAGR_APP_URL', 'https://app.getpagr.co/settings?cli=1');
|
|
15
|
+
const url = new URL(buildCliLoginUrl('http://127.0.0.1:51234/callback', 'state-123'));
|
|
16
|
+
expect(url.toString()).toContain('https://app.getpagr.co/cli?');
|
|
17
|
+
vi.unstubAllEnvs();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('validateCallbackPayload', () => {
|
|
21
|
+
it('returns the API key for a matching state', () => {
|
|
22
|
+
const body = new URLSearchParams({ state: 'abc', key: 'pagr_secret' });
|
|
23
|
+
expect(validateCallbackPayload(body, 'abc')).toBe('pagr_secret');
|
|
24
|
+
});
|
|
25
|
+
it('rejects mismatched state', () => {
|
|
26
|
+
const body = new URLSearchParams({ state: 'wrong', key: 'pagr_secret' });
|
|
27
|
+
expect(() => validateCallbackPayload(body, 'abc')).toThrow('state did not match');
|
|
28
|
+
});
|
|
29
|
+
it('rejects invalid API keys', () => {
|
|
30
|
+
const body = new URLSearchParams({ state: 'abc', key: 'not-valid' });
|
|
31
|
+
expect(() => validateCallbackPayload(body, 'abc')).toThrow('valid API key');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=login.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.test.js","sourceRoot":"","sources":["../../src/commands/login.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEtE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAA;QACpD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAAC,CAAA;QAErF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;QACjD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;QAChF,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACvD,EAAE,CAAC,aAAa,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,uCA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-0,0 +1,13 @@
|
|
|
1
|
+
export declare const removeCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly slug: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "Slug to delete";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly yes: {
|
|
8
|
+
readonly type: "boolean";
|
|
9
|
+
readonly alias: "y";
|
|
10
|
+
readonly description: "Skip confirmation prompt";
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/commands/remove.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;;;;;;;;;EA2BxB,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline/promises';
|
|
2
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
3
|
+
import { defineCommand } from 'citty';
|
|
4
|
+
import { deleteFile } from '../lib/api.js';
|
|
5
|
+
import { getApiKey, getWorkerUrl } from '../lib/config.js';
|
|
6
|
+
export const removeCommand = defineCommand({
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'rm',
|
|
9
|
+
description: 'Delete a Pagr file',
|
|
10
|
+
alias: 'delete',
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
slug: {
|
|
14
|
+
type: 'positional',
|
|
15
|
+
description: 'Slug to delete',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
yes: {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
alias: 'y',
|
|
21
|
+
description: 'Skip confirmation prompt',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ args }) {
|
|
25
|
+
if (!args.yes && !await confirmDelete(args.slug)) {
|
|
26
|
+
console.log('Delete cancelled.');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await deleteFile(args.slug, getApiKey(), getWorkerUrl());
|
|
30
|
+
console.log(`Deleted: ${args.slug}`);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
async function confirmDelete(slug) {
|
|
34
|
+
const rl = createInterface({ input, output });
|
|
35
|
+
try {
|
|
36
|
+
const answer = (await rl.question(`Delete ${slug}? This cannot be undone. [y/N] `)).trim().toLowerCase();
|
|
37
|
+
return answer === 'y' || answer === 'yes';
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
rl.close();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=remove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src/commands/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE1D,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;IACzC,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,oBAAoB;QACjC,KAAK,EAAE,QAAQ;KAChB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,IAAI;SACf;QACD,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,0BAA0B;SACxC;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACjD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;YAChC,OAAM;QACR,CAAC;QAED,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;QACxD,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACtC,CAAC;CACF,CAAC,CAAA;AAEF,KAAK,UAAU,aAAa,CAAC,IAAY;IACvC,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,IAAI,iCAAiC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;QACxG,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK,CAAA;IAC3C,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAA;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const uploadCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly file: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "HTML file to upload";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly slug: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly alias: "s";
|
|
10
|
+
readonly description: "Custom slug for the URL (Pro/Team)";
|
|
11
|
+
readonly valueHint: "slug";
|
|
12
|
+
};
|
|
13
|
+
readonly title: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly alias: "t";
|
|
16
|
+
readonly description: "Override the page title";
|
|
17
|
+
readonly valueHint: "title";
|
|
18
|
+
};
|
|
19
|
+
readonly ttl: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly alias: "e";
|
|
22
|
+
readonly description: "Expiry: never | 24h | 7d | 30d | 1-visit";
|
|
23
|
+
readonly valueHint: "ttl";
|
|
24
|
+
};
|
|
25
|
+
readonly password: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly alias: "p";
|
|
28
|
+
readonly description: "Password-protect the page (Pro/Team)";
|
|
29
|
+
readonly valueHint: "password";
|
|
30
|
+
};
|
|
31
|
+
readonly 'hide-banner': {
|
|
32
|
+
readonly type: "boolean";
|
|
33
|
+
readonly description: "Hide the \"Hosted on Pagr\" banner (Pro/Team)";
|
|
34
|
+
};
|
|
35
|
+
readonly update: {
|
|
36
|
+
readonly type: "boolean";
|
|
37
|
+
readonly alias: "u";
|
|
38
|
+
readonly description: "Force update mode — fails if slug does not exist";
|
|
39
|
+
};
|
|
40
|
+
readonly inject: {
|
|
41
|
+
readonly type: "boolean";
|
|
42
|
+
readonly description: "Inject <meta name=\"pagr-slug\"> into the file after upload";
|
|
43
|
+
};
|
|
44
|
+
readonly 'no-open': {
|
|
45
|
+
readonly type: "boolean";
|
|
46
|
+
readonly description: "Skip opening the URL in your browser";
|
|
47
|
+
};
|
|
48
|
+
readonly 'no-copy': {
|
|
49
|
+
readonly type: "boolean";
|
|
50
|
+
readonly description: "Skip copying the URL to clipboard";
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsJxB,CAAA"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { platform } from 'node:os';
|
|
5
|
+
import { defineCommand } from 'citty';
|
|
6
|
+
import { uploadFile, updateFile, updateFileById, checkSlugOwnership } from '../lib/api.js';
|
|
7
|
+
import { getApiKey, getWorkerUrl } from '../lib/config.js';
|
|
8
|
+
import { extractPagrSlug, extractPagrId, injectPagrSlug, injectPagrId } from '../lib/meta.js';
|
|
9
|
+
export const uploadCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: 'upload',
|
|
12
|
+
description: 'Upload an HTML file to Pagr',
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
file: {
|
|
16
|
+
type: 'positional',
|
|
17
|
+
description: 'HTML file to upload',
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
slug: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
alias: 's',
|
|
23
|
+
description: 'Custom slug for the URL (Pro/Team)',
|
|
24
|
+
valueHint: 'slug',
|
|
25
|
+
},
|
|
26
|
+
title: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
alias: 't',
|
|
29
|
+
description: 'Override the page title',
|
|
30
|
+
valueHint: 'title',
|
|
31
|
+
},
|
|
32
|
+
ttl: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
alias: 'e',
|
|
35
|
+
description: 'Expiry: never | 24h | 7d | 30d | 1-visit',
|
|
36
|
+
valueHint: 'ttl',
|
|
37
|
+
},
|
|
38
|
+
password: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
alias: 'p',
|
|
41
|
+
description: 'Password-protect the page (Pro/Team)',
|
|
42
|
+
valueHint: 'password',
|
|
43
|
+
},
|
|
44
|
+
'hide-banner': {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
description: 'Hide the "Hosted on Pagr" banner (Pro/Team)',
|
|
47
|
+
},
|
|
48
|
+
update: {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
alias: 'u',
|
|
51
|
+
description: 'Force update mode — fails if slug does not exist',
|
|
52
|
+
},
|
|
53
|
+
inject: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
description: 'Inject <meta name="pagr-slug"> into the file after upload',
|
|
56
|
+
},
|
|
57
|
+
'no-open': {
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
description: 'Skip opening the URL in your browser',
|
|
60
|
+
},
|
|
61
|
+
'no-copy': {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
description: 'Skip copying the URL to clipboard',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
async run({ args }) {
|
|
67
|
+
const apiKey = getApiKey();
|
|
68
|
+
const workerUrl = getWorkerUrl();
|
|
69
|
+
let html;
|
|
70
|
+
try {
|
|
71
|
+
html = readFileSync(args.file, 'utf-8');
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
console.error(`Cannot read file: ${args.file}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const metaSlug = extractPagrSlug(html);
|
|
78
|
+
const metaDocumentId = extractPagrId(html);
|
|
79
|
+
const slug = args.slug ?? metaSlug;
|
|
80
|
+
const shouldUpdate = args.update || (metaDocumentId !== null) || (metaSlug !== null && !args.slug);
|
|
81
|
+
try {
|
|
82
|
+
let result;
|
|
83
|
+
if (shouldUpdate && metaDocumentId) {
|
|
84
|
+
result = await updateFileById({
|
|
85
|
+
html,
|
|
86
|
+
documentId: metaDocumentId,
|
|
87
|
+
title: args.title,
|
|
88
|
+
hideBanner: args['hide-banner'],
|
|
89
|
+
password: args.password,
|
|
90
|
+
apiKey,
|
|
91
|
+
workerUrl,
|
|
92
|
+
});
|
|
93
|
+
console.log(`Updated: ${result.url}`);
|
|
94
|
+
}
|
|
95
|
+
else if (shouldUpdate && slug) {
|
|
96
|
+
const owned = await checkSlugOwnership(slug, apiKey, workerUrl);
|
|
97
|
+
if (!owned) {
|
|
98
|
+
console.error(`Slug "${slug}" not found or not owned by you. Use \`pagr upload\` without --update to create a new file.`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
result = await updateFile({
|
|
102
|
+
html,
|
|
103
|
+
slug,
|
|
104
|
+
title: args.title,
|
|
105
|
+
hideBanner: args['hide-banner'],
|
|
106
|
+
password: args.password,
|
|
107
|
+
apiKey,
|
|
108
|
+
workerUrl,
|
|
109
|
+
});
|
|
110
|
+
console.log(`Updated: ${result.url}`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
result = await uploadFile({
|
|
114
|
+
html,
|
|
115
|
+
slug: args.slug,
|
|
116
|
+
title: args.title,
|
|
117
|
+
ttl: args.ttl,
|
|
118
|
+
hideBanner: args['hide-banner'],
|
|
119
|
+
password: args.password,
|
|
120
|
+
apiKey,
|
|
121
|
+
workerUrl,
|
|
122
|
+
});
|
|
123
|
+
console.log(`Published: ${result.url}`);
|
|
124
|
+
if (args.inject || metaSlug === null) {
|
|
125
|
+
let updated = injectPagrSlug(html, result.slug);
|
|
126
|
+
if (result.documentId) {
|
|
127
|
+
updated = injectPagrId(updated, result.documentId);
|
|
128
|
+
}
|
|
129
|
+
writeFileSync(args.file, updated, 'utf-8');
|
|
130
|
+
if (result.documentId) {
|
|
131
|
+
console.log(`Injected <meta name="pagr-id" content="${result.documentId}"> and <meta name="pagr-slug" content="${result.slug}"> into ${basename(args.file)}`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
console.log(`Injected <meta name="pagr-slug" content="${result.slug}"> into ${basename(args.file)}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!args['no-copy']) {
|
|
139
|
+
const copied = await copyToClipboard(result.url);
|
|
140
|
+
if (copied)
|
|
141
|
+
console.log('URL copied to clipboard');
|
|
142
|
+
}
|
|
143
|
+
if (!args['no-open']) {
|
|
144
|
+
openUrl(result.url);
|
|
145
|
+
}
|
|
146
|
+
if (process.env.CI) {
|
|
147
|
+
console.log(`PAGR_SLUG=${result.slug}`);
|
|
148
|
+
console.log(`PAGR_URL=${result.url}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
function openUrl(url) {
|
|
158
|
+
const os = platform();
|
|
159
|
+
if (os === 'darwin') {
|
|
160
|
+
spawn('open', [url], { stdio: 'ignore', detached: true }).unref();
|
|
161
|
+
}
|
|
162
|
+
else if (os === 'win32') {
|
|
163
|
+
spawn('cmd', ['/c', 'start', '', url], { stdio: 'ignore', detached: true }).unref();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
spawn('xdg-open', [url], { stdio: 'ignore', detached: true }).unref();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async function copyToClipboard(value) {
|
|
170
|
+
const os = platform();
|
|
171
|
+
if (os === 'darwin' || os === 'win32') {
|
|
172
|
+
return trySpawnCopy(os === 'darwin' ? 'pbcopy' : 'clip', [], value);
|
|
173
|
+
}
|
|
174
|
+
if (await trySpawnCopy('xclip', ['-selection', 'clipboard'], value))
|
|
175
|
+
return true;
|
|
176
|
+
return trySpawnCopy('xsel', ['--clipboard', '--input'], value);
|
|
177
|
+
}
|
|
178
|
+
function trySpawnCopy(command, args, value) {
|
|
179
|
+
return new Promise((resolve) => {
|
|
180
|
+
const child = spawn(command, args, { stdio: ['pipe', 'ignore', 'ignore'] });
|
|
181
|
+
child.on('error', () => resolve(false));
|
|
182
|
+
child.on('close', (code) => resolve(code === 0));
|
|
183
|
+
child.stdin.end(value);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,QAAQ,EA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AO,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAChF,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAA;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,IAAc,EAAE,KAAa;IAClE,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC3E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QACvC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAA;QAChD,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineCommand, runMain } from 'citty';
|
|
3
|
+
import { uploadCommand } from './commands/upload.js';
|
|
4
|
+
import { configCommand } from './commands/config.js';
|
|
5
|
+
import { initCommand } from './commands/init.js';
|
|
6
|
+
import { loginCommand } from './commands/login.js';
|
|
7
|
+
import { listCommand } from './commands/list.js';
|
|
8
|
+
import { removeCommand } from './commands/remove.js';
|
|
9
|
+
const main = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: 'pagr',
|
|
12
|
+
version: '1.0.0',
|
|
13
|
+
description: 'Pagr CLI - publish HTML files and get instant shareable links',
|
|
14
|
+
},
|
|
15
|
+
subCommands: {
|
|
16
|
+
login: loginCommand,
|
|
17
|
+
upload: uploadCommand,
|
|
18
|
+
ls: listCommand,
|
|
19
|
+
rm: removeCommand,
|
|
20
|
+
config: configCommand,
|
|
21
|
+
init: initCommand,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
runMain(main);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,IAAI,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,+DAA+D;KAC7E;IACD,WAAW,EAAE;QACX,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;QACrB,EAAE,EAAE,WAAW;QACf,EAAE,EAAE,aAAa;QACjB,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,WAAW;KAClB;CACF,CAAC,CAAA;AAEF,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
interface UploadResult {
|
|
2
|
+
slug: string;
|
|
3
|
+
url: string;
|
|
4
|
+
documentId?: string;
|
|
5
|
+
updated?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface FileListItem {
|
|
8
|
+
slug: string;
|
|
9
|
+
url: string;
|
|
10
|
+
title: string;
|
|
11
|
+
size: number;
|
|
12
|
+
created: string;
|
|
13
|
+
plan: 'free' | 'pro' | 'team';
|
|
14
|
+
views: number;
|
|
15
|
+
}
|
|
16
|
+
interface UploadOptions {
|
|
17
|
+
html: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
slug?: string;
|
|
20
|
+
ttl?: string;
|
|
21
|
+
hideBanner?: boolean;
|
|
22
|
+
password?: string;
|
|
23
|
+
apiKey: string;
|
|
24
|
+
workerUrl: string;
|
|
25
|
+
}
|
|
26
|
+
interface UpdateOptions {
|
|
27
|
+
html: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
hideBanner?: boolean;
|
|
31
|
+
password?: string;
|
|
32
|
+
apiKey: string;
|
|
33
|
+
workerUrl: string;
|
|
34
|
+
}
|
|
35
|
+
interface UpdateByIdOptions {
|
|
36
|
+
html: string;
|
|
37
|
+
documentId: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
hideBanner?: boolean;
|
|
40
|
+
password?: string;
|
|
41
|
+
apiKey: string;
|
|
42
|
+
workerUrl: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function uploadFile(opts: UploadOptions): Promise<UploadResult>;
|
|
45
|
+
export declare function updateFile(opts: UpdateOptions): Promise<UploadResult>;
|
|
46
|
+
export declare function updateFileById(opts: UpdateByIdOptions): Promise<UploadResult>;
|
|
47
|
+
export declare function checkSlugOwnership(slug: string, apiKey: string, workerUrl: string): Promise<boolean>;
|
|
48
|
+
export declare function listFiles(apiKey: string, workerUrl: string, limit?: number): Promise<FileListItem[]>;
|
|
49
|
+
export declare function deleteFile(slug: string, apiKey: string, workerUrl: string): Promise<void>;
|
|
50
|
+
export declare function renameFile(slug: string, nextSlug: string, apiKey: string, workerUrl: string, title?: string): Promise<UploadResult>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAmC3E;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA8B3E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8BnF;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1G;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAYvG;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU/F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAEzI"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export async function uploadFile(opts) {
|
|
2
|
+
const headers = {
|
|
3
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
4
|
+
'Authorization': `Bearer ${opts.apiKey}`,
|
|
5
|
+
};
|
|
6
|
+
if (opts.title)
|
|
7
|
+
headers['X-Pagr-Title'] = opts.title;
|
|
8
|
+
if (opts.ttl)
|
|
9
|
+
headers['X-Pagr-TTL'] = opts.ttl;
|
|
10
|
+
if (opts.hideBanner)
|
|
11
|
+
headers['X-Pagr-Hide-Banner'] = 'true';
|
|
12
|
+
const res = await fetch(`${opts.workerUrl}/api/upload`, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers,
|
|
15
|
+
body: opts.html,
|
|
16
|
+
});
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
19
|
+
throw new Error(err.error ?? `Upload failed with status ${res.status}`);
|
|
20
|
+
}
|
|
21
|
+
const uploaded = await res.json();
|
|
22
|
+
const needsPatch = (opts.slug && opts.slug !== uploaded.slug) || opts.password;
|
|
23
|
+
if (needsPatch) {
|
|
24
|
+
return patchFileMeta({
|
|
25
|
+
slug: uploaded.slug,
|
|
26
|
+
...(opts.slug && opts.slug !== uploaded.slug ? { nextSlug: opts.slug } : {}),
|
|
27
|
+
title: opts.title,
|
|
28
|
+
password: opts.password,
|
|
29
|
+
apiKey: opts.apiKey,
|
|
30
|
+
workerUrl: opts.workerUrl,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return uploaded;
|
|
34
|
+
}
|
|
35
|
+
export async function updateFile(opts) {
|
|
36
|
+
const headers = {
|
|
37
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
38
|
+
'Authorization': `Bearer ${opts.apiKey}`,
|
|
39
|
+
};
|
|
40
|
+
if (opts.title)
|
|
41
|
+
headers['X-Pagr-Title'] = opts.title;
|
|
42
|
+
if (opts.hideBanner !== undefined)
|
|
43
|
+
headers['X-Pagr-Hide-Banner'] = String(opts.hideBanner);
|
|
44
|
+
const res = await fetch(`${opts.workerUrl}/api/upload/${opts.slug}`, {
|
|
45
|
+
method: 'PUT',
|
|
46
|
+
headers,
|
|
47
|
+
body: opts.html,
|
|
48
|
+
});
|
|
49
|
+
if (res.status === 404) {
|
|
50
|
+
throw new Error(`File with slug "${opts.slug}" not found or not owned by you.`);
|
|
51
|
+
}
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
54
|
+
throw new Error(err.error ?? `Update failed with status ${res.status}`);
|
|
55
|
+
}
|
|
56
|
+
const result = await res.json();
|
|
57
|
+
if (opts.password) {
|
|
58
|
+
await patchFileMeta({ slug: result.slug, password: opts.password, apiKey: opts.apiKey, workerUrl: opts.workerUrl });
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
export async function updateFileById(opts) {
|
|
63
|
+
const headers = {
|
|
64
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
65
|
+
'Authorization': `Bearer ${opts.apiKey}`,
|
|
66
|
+
};
|
|
67
|
+
if (opts.title)
|
|
68
|
+
headers['X-Pagr-Title'] = opts.title;
|
|
69
|
+
if (opts.hideBanner !== undefined)
|
|
70
|
+
headers['X-Pagr-Hide-Banner'] = String(opts.hideBanner);
|
|
71
|
+
const res = await fetch(`${opts.workerUrl}/api/upload/id/${opts.documentId}`, {
|
|
72
|
+
method: 'PUT',
|
|
73
|
+
headers,
|
|
74
|
+
body: opts.html,
|
|
75
|
+
});
|
|
76
|
+
if (res.status === 404) {
|
|
77
|
+
throw new Error(`Document "${opts.documentId}" not found or not owned by you.`);
|
|
78
|
+
}
|
|
79
|
+
if (!res.ok) {
|
|
80
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
81
|
+
throw new Error(err.error ?? `Update failed with status ${res.status}`);
|
|
82
|
+
}
|
|
83
|
+
const result = await res.json();
|
|
84
|
+
if (opts.password) {
|
|
85
|
+
await patchFileMeta({ slug: result.slug, password: opts.password, apiKey: opts.apiKey, workerUrl: opts.workerUrl });
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
export async function checkSlugOwnership(slug, apiKey, workerUrl) {
|
|
90
|
+
const res = await fetch(`${workerUrl}/api/files/${encodeURIComponent(slug)}`, {
|
|
91
|
+
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
92
|
+
});
|
|
93
|
+
if (res.status === 404)
|
|
94
|
+
return false;
|
|
95
|
+
return res.ok;
|
|
96
|
+
}
|
|
97
|
+
export async function listFiles(apiKey, workerUrl, limit = 100) {
|
|
98
|
+
const res = await fetch(`${workerUrl}/api/files?limit=${limit}`, {
|
|
99
|
+
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
100
|
+
});
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
103
|
+
throw new Error(err.error ?? `List failed with status ${res.status}`);
|
|
104
|
+
}
|
|
105
|
+
const data = await res.json();
|
|
106
|
+
return data.files;
|
|
107
|
+
}
|
|
108
|
+
export async function deleteFile(slug, apiKey, workerUrl) {
|
|
109
|
+
const res = await fetch(`${workerUrl}/api/files/${slug}`, {
|
|
110
|
+
method: 'DELETE',
|
|
111
|
+
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
112
|
+
});
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
115
|
+
throw new Error(err.error ?? `Delete failed with status ${res.status}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export async function renameFile(slug, nextSlug, apiKey, workerUrl, title) {
|
|
119
|
+
return patchFileMeta({ slug, nextSlug, title, apiKey, workerUrl });
|
|
120
|
+
}
|
|
121
|
+
async function patchFileMeta(opts) {
|
|
122
|
+
const res = await fetch(`${opts.workerUrl}/api/files/${opts.slug}`, {
|
|
123
|
+
method: 'PATCH',
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
'Authorization': `Bearer ${opts.apiKey}`,
|
|
127
|
+
},
|
|
128
|
+
body: JSON.stringify({
|
|
129
|
+
...(opts.nextSlug ? { slug: opts.nextSlug } : {}),
|
|
130
|
+
...(opts.title ? { title: opts.title } : {}),
|
|
131
|
+
...(opts.password !== undefined ? { password: opts.password } : {}),
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
if (!res.ok) {
|
|
135
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
136
|
+
throw new Error(err.error ?? `Metadata update failed with status ${res.status}`);
|
|
137
|
+
}
|
|
138
|
+
return res.json();
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAmB;IAClD,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,0BAA0B;QAC1C,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;KACzC,CAAA;IACD,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,KAAK,CAAA;IACpD,IAAI,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,GAAG,CAAA;IAC9C,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAA;IAE3D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,aAAa,EAAE;QACtD,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAA;IAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAuB,CAAA;QAC3F,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,6BAA6B,GAAG,CAAC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AAK,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAuB,CAAA;QAC3F,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,sCAAsC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAA2B,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface PagrConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
workerUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function readConfig(): PagrConfig;
|
|
6
|
+
export declare function writeConfig(config: PagrConfig): void;
|
|
7
|
+
export declare function getApiKey(): string;
|
|
8
|
+
export declare function getWorkerUrl(): string;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAOA,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,IAAI,UAAU,CAOvC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAKpD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAKrC"}
|