@luanxdd/meowgallery 0.0.0-stage → 0.4.0
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/README.md +99 -2
- package/dist/client.d.ts +15 -0
- package/dist/client.js +32 -0
- package/dist/client.js.map +1 -0
- package/dist/core/transport.d.ts +9 -0
- package/dist/core/transport.js +166 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/error.d.ts +12 -0
- package/dist/error.js +15 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/models/access.d.ts +19 -0
- package/dist/models/access.js +2 -0
- package/dist/models/access.js.map +1 -0
- package/dist/models/media.d.ts +16 -0
- package/dist/models/media.js +2 -0
- package/dist/models/media.js.map +1 -0
- package/dist/models/options.d.ts +16 -0
- package/dist/models/options.js +2 -0
- package/dist/models/options.js.map +1 -0
- package/dist/models/post.d.ts +12 -0
- package/dist/models/post.js +2 -0
- package/dist/models/post.js.map +1 -0
- package/dist/node/save.d.ts +8 -0
- package/dist/node/save.js +46 -0
- package/dist/node/save.js.map +1 -0
- package/dist/node/stream.d.ts +6 -0
- package/dist/node/stream.js +16 -0
- package/dist/node/stream.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/resources/access.d.ts +9 -0
- package/dist/resources/access.js +19 -0
- package/dist/resources/access.js.map +1 -0
- package/dist/resources/item.d.ts +25 -0
- package/dist/resources/item.js +50 -0
- package/dist/resources/item.js.map +1 -0
- package/dist/resources/media.d.ts +8 -0
- package/dist/resources/media.js +17 -0
- package/dist/resources/media.js.map +1 -0
- package/dist/resources/posts.d.ts +9 -0
- package/dist/resources/posts.js +14 -0
- package/dist/resources/posts.js.map +1 -0
- package/dist/resources/publication.d.ts +20 -0
- package/dist/resources/publication.js +45 -0
- package/dist/resources/publication.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -4
package/README.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MeowGallery
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Publicações, imagens, vídeos e áudio em uma interface pequena e organizada.
|
|
4
|
+
TypeScript, ESM, Node.js 22+ e navegadores modernos. Sem dependências de produção.
|
|
5
|
+
|
|
6
|
+
## Instalar
|
|
7
|
+
|
|
8
|
+
Após publicar esta versão: `npm install @luanxdd/meowgallery@^0.4.0`.
|
|
9
|
+
Antes da publicação, instale o arquivo `luanxdd-meowgallery-0.4.0.tgz` incluído no ZIP.
|
|
10
|
+
|
|
11
|
+
## Uma publicação
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { MeowGallery } from "@luanxdd/meowgallery";
|
|
15
|
+
|
|
16
|
+
const gallery = new MeowGallery({
|
|
17
|
+
baseUrl: "https://gallery.kairogg.com.br",
|
|
18
|
+
token: process.env.MEOWGALLERY_KEY!,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const post = await gallery.posts.resolve(url);
|
|
22
|
+
|
|
23
|
+
console.log(post.author.name, post.caption);
|
|
24
|
+
console.log(post.video?.url);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Reutilize uma instância por configuração de autenticação. `post.items` preserva a ordem original; `post.images` e `post.videos` selecionam tipos; `post.video` é o primeiro vídeo ou `undefined`. `post.audio` contém a faixa separada quando disponível, ou `null`.
|
|
28
|
+
|
|
29
|
+
## Pronto para bots
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { streamMedia } from "@luanxdd/meowgallery/node";
|
|
33
|
+
|
|
34
|
+
if (post.video) {
|
|
35
|
+
const stream = await streamMedia(post.video, {
|
|
36
|
+
signal: AbortSignal.timeout(60_000),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Passe stream ao método de envio do framework.
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
O stream começa sem aguardar o arquivo inteiro e sem gravar em disco. O framework pode precisar preparar ou armazenar a mídia por conta própria. Consuma o stream ou encerre com `stream.destroy()`.
|
|
44
|
+
|
|
45
|
+
Para frameworks que aceitam URL, use `post.video.url`: é o link temporário protegido, não a origem da rede social. Não acrescente a chave da API a esse link.
|
|
46
|
+
|
|
47
|
+
## Mídia
|
|
48
|
+
|
|
49
|
+
| Operação | Resultado |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `item.url` | Link protegido |
|
|
52
|
+
| `item.expired` | Se o link já expirou |
|
|
53
|
+
| `item.open(options)` | Response com status e cabeçalhos |
|
|
54
|
+
| `item.stream(options)` | Web Stream |
|
|
55
|
+
| `item.toJSON()` | Metadados serializáveis |
|
|
56
|
+
|
|
57
|
+
`open` e `stream` aceitam `signal` e `range`, como `{ range: "bytes=0-1023" }`. Consuma ou cancele cada corpo. Não há Buffer completo automático.
|
|
58
|
+
|
|
59
|
+
Para gravar explicitamente no consumidor:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { saveMedia } from "@luanxdd/meowgallery/node";
|
|
63
|
+
|
|
64
|
+
if (post.video) {
|
|
65
|
+
await saveMedia(post.video, "./video.mp4", {
|
|
66
|
+
maxBytes: 64 * 1024 * 1024,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
A gravação é atômica, não sobrescreve destinos e remove arquivos parciais. Fotos e áudio permanecem separados; não há conversão para MP4. Confira `mimeType` ao escolher a extensão.
|
|
72
|
+
|
|
73
|
+
## Acesso, erros e expiração
|
|
74
|
+
|
|
75
|
+
`gallery.access.create(input)`, `list()` e `revoke(id)` exigem Owner. Bots precisam dos escopos `captures:read` e `delivery:read`. `sources:authenticated` permite usar a sessão Instagram configurada. Nunca exponha chaves de bots ou Owner no frontend.
|
|
76
|
+
|
|
77
|
+
OAuth aceita `token: async () => auth.getAccessToken()`; login e renovação pertencem ao provedor de identidade. A função é chamada antes de cada operação autenticada.
|
|
78
|
+
|
|
79
|
+
`MeowGalleryError` contém `code`, `status`, `requestId` e `retryAfter`. Operações aceitam `signal: AbortSignal.timeout(30_000)`.
|
|
80
|
+
|
|
81
|
+
Links expiram. Resolva o post novamente para obter links novos; use `{ refresh: true }` se a origem expirar antes do link. Não há repetição automática de POST nem cache de credenciais na SDK.
|
|
82
|
+
|
|
83
|
+
## Compatibilidade
|
|
84
|
+
|
|
85
|
+
`gallery.capture(url)` retorna dados simples. `gallery.download(item)` e os métodos antigos de credenciais permanecem disponíveis.
|
|
86
|
+
|
|
87
|
+
`gallery.posts.resolve(url)` retorna `Publication`, compatível estruturalmente com `Capture`, com itens `MediaItem`. `post.toJSON()` e `JSON.stringify(post)` produzem dados sem transporte ou token.
|
|
88
|
+
|
|
89
|
+
`streamMedia(gallery, item)` e `saveMedia(gallery, item, destination)` continuam funcionando.
|
|
90
|
+
|
|
91
|
+
## Desenvolvimento
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm ci
|
|
95
|
+
npm run check
|
|
96
|
+
npm test
|
|
97
|
+
npm pack
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`core` contém transporte; `models`, contratos; `resources`, operações e objetos; `node`, adaptação e arquivos. Aliases internos nativos ficam em `package.json#imports`; o consumidor não precisa configurar aliases. A entrada `/node` não deve entrar em bundles de navegador.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Access } from "#resources/access";
|
|
2
|
+
import { MediaLibrary } from "#resources/media";
|
|
3
|
+
import { Posts } from "#resources/posts";
|
|
4
|
+
import type { CaptureOptions, CredentialInput, DeliveryOptions, Media, MeowGalleryOptions, RequestOptions } from "#types";
|
|
5
|
+
export declare class MeowGallery {
|
|
6
|
+
readonly posts: Posts;
|
|
7
|
+
readonly media: MediaLibrary;
|
|
8
|
+
readonly access: Access;
|
|
9
|
+
constructor(options: MeowGalleryOptions);
|
|
10
|
+
capture(url: string, options?: CaptureOptions): Promise<import("#types").Capture>;
|
|
11
|
+
download(media: Media, options?: DeliveryOptions): Promise<Response>;
|
|
12
|
+
createCredential(input: CredentialInput, options?: RequestOptions): Promise<import("#types").CreatedCredential>;
|
|
13
|
+
listCredentials(options?: RequestOptions): Promise<import("#types").Credential[]>;
|
|
14
|
+
revokeCredential(id: string, options?: RequestOptions): Promise<void>;
|
|
15
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Transport } from "#core/transport";
|
|
2
|
+
import { Access } from "#resources/access";
|
|
3
|
+
import { MediaLibrary } from "#resources/media";
|
|
4
|
+
import { Posts } from "#resources/posts";
|
|
5
|
+
export class MeowGallery {
|
|
6
|
+
posts;
|
|
7
|
+
media;
|
|
8
|
+
access;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
const transport = new Transport(options);
|
|
11
|
+
this.media = new MediaLibrary(transport);
|
|
12
|
+
this.posts = new Posts(transport, this.media);
|
|
13
|
+
this.access = new Access(transport);
|
|
14
|
+
}
|
|
15
|
+
async capture(url, options = {}) {
|
|
16
|
+
const publication = await this.posts.resolve(url, options);
|
|
17
|
+
return publication.toJSON();
|
|
18
|
+
}
|
|
19
|
+
download(media, options = {}) {
|
|
20
|
+
return this.media.open(media, options);
|
|
21
|
+
}
|
|
22
|
+
createCredential(input, options = {}) {
|
|
23
|
+
return this.access.create(input, options);
|
|
24
|
+
}
|
|
25
|
+
listCredentials(options = {}) {
|
|
26
|
+
return this.access.list(options);
|
|
27
|
+
}
|
|
28
|
+
revokeCredential(id, options = {}) {
|
|
29
|
+
return this.access.revoke(id, options);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iB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O,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Media, MeowGalleryOptions, RequestOptions } from "#types";
|
|
2
|
+
export declare class Transport {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(options: MeowGalleryOptions);
|
|
5
|
+
download(media: Media, options?: RequestOptions & {
|
|
6
|
+
readonly range?: string;
|
|
7
|
+
}): Promise<Response>;
|
|
8
|
+
request<T>(method: string, path: string, body: unknown, options: RequestOptions): Promise<T>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { MeowGalleryError } from "#error";
|
|
2
|
+
export class Transport {
|
|
3
|
+
#origin;
|
|
4
|
+
#token;
|
|
5
|
+
#fetch;
|
|
6
|
+
#timeout;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
const url = new URL(options.baseUrl);
|
|
9
|
+
const local = ["localhost", "127.0.0.1"].includes(url.hostname);
|
|
10
|
+
if ((url.protocol !== "https:" &&
|
|
11
|
+
!(options.allowLocalHttp && local && url.protocol === "http:")) ||
|
|
12
|
+
url.username ||
|
|
13
|
+
url.password ||
|
|
14
|
+
url.pathname !== "/" ||
|
|
15
|
+
url.search ||
|
|
16
|
+
url.hash) {
|
|
17
|
+
throw new TypeError("baseUrl deve ser uma origem HTTPS válida.");
|
|
18
|
+
}
|
|
19
|
+
this.#origin = url.origin;
|
|
20
|
+
this.#token = options.token;
|
|
21
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
22
|
+
this.#timeout = options.timeoutMs ?? 35_000;
|
|
23
|
+
if (!Number.isSafeInteger(this.#timeout) ||
|
|
24
|
+
this.#timeout < 1 ||
|
|
25
|
+
this.#timeout > 300_000) {
|
|
26
|
+
throw new TypeError("timeoutMs deve estar entre 1 e 300000.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async download(media, options = {}) {
|
|
30
|
+
const url = new URL(media.delivery.url);
|
|
31
|
+
if (url.origin !== this.#origin ||
|
|
32
|
+
!/^\/v1\/delivery\/[A-Za-z0-9_-]+$/.test(url.pathname) ||
|
|
33
|
+
url.username ||
|
|
34
|
+
url.password ||
|
|
35
|
+
url.search ||
|
|
36
|
+
url.hash) {
|
|
37
|
+
throw new TypeError("O link de entrega não pertence a esta MeowGallery.");
|
|
38
|
+
}
|
|
39
|
+
const expires = Date.parse(media.delivery.expiresAt);
|
|
40
|
+
if (!Number.isFinite(expires) || expires <= Date.now()) {
|
|
41
|
+
throw new MeowGalleryError("O link expirou. Solicite a publicação novamente.", { code: "delivery_expired", status: 410 });
|
|
42
|
+
}
|
|
43
|
+
const headers = new Headers();
|
|
44
|
+
if (options.range) {
|
|
45
|
+
headers.set("Range", options.range);
|
|
46
|
+
}
|
|
47
|
+
const response = await this.#send(url.href, {
|
|
48
|
+
headers,
|
|
49
|
+
signal: this.#signal(options.signal, 300_000),
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw await this.#failure(response);
|
|
53
|
+
}
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
async request(method, path, body, options) {
|
|
57
|
+
const token = typeof this.#token === "function" ? await this.#token() : this.#token;
|
|
58
|
+
if (!token || /[\r\n]/.test(token)) {
|
|
59
|
+
throw new TypeError("Token de autenticação inválido.");
|
|
60
|
+
}
|
|
61
|
+
const headers = new Headers({
|
|
62
|
+
Accept: "application/json",
|
|
63
|
+
Authorization: `Bearer ${token}`,
|
|
64
|
+
});
|
|
65
|
+
const init = {
|
|
66
|
+
method,
|
|
67
|
+
headers,
|
|
68
|
+
signal: this.#signal(options.signal, this.#timeout),
|
|
69
|
+
};
|
|
70
|
+
if (body !== undefined) {
|
|
71
|
+
headers.set("Content-Type", "application/json");
|
|
72
|
+
init.body = JSON.stringify(body);
|
|
73
|
+
}
|
|
74
|
+
const response = await this.#send(`${this.#origin}${path}`, init);
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
throw await this.#failure(response);
|
|
77
|
+
}
|
|
78
|
+
if (response.status === 204) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const envelope = await this.#json(response);
|
|
82
|
+
if (!envelope || typeof envelope !== "object" || !("data" in envelope)) {
|
|
83
|
+
throw new MeowGalleryError("Resposta inesperada do serviço.", {
|
|
84
|
+
code: "invalid_response",
|
|
85
|
+
status: response.status,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return envelope.data;
|
|
89
|
+
}
|
|
90
|
+
#signal(signal, timeout) {
|
|
91
|
+
const deadline = AbortSignal.timeout(timeout);
|
|
92
|
+
return signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
93
|
+
}
|
|
94
|
+
async #send(url, init) {
|
|
95
|
+
try {
|
|
96
|
+
return await this.#fetch(url, {
|
|
97
|
+
...init,
|
|
98
|
+
redirect: "error",
|
|
99
|
+
credentials: "omit",
|
|
100
|
+
cache: "no-store",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
throw new MeowGalleryError(init.signal?.aborted
|
|
105
|
+
? "Solicitação cancelada ou expirada."
|
|
106
|
+
: "Não foi possível conectar à MeowGallery.", { code: init.signal?.aborted ? "request_aborted" : "network_error" });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async #failure(response) {
|
|
110
|
+
const body = (await this.#json(response).catch(() => null));
|
|
111
|
+
const retryHeader = response.headers.get("retry-after");
|
|
112
|
+
const retry = retryHeader === null ? NaN : Number(retryHeader);
|
|
113
|
+
return new MeowGalleryError(typeof body?.error?.message === "string"
|
|
114
|
+
? body.error.message
|
|
115
|
+
: "A solicitação não foi concluída.", {
|
|
116
|
+
code: typeof body?.error?.code === "string"
|
|
117
|
+
? body.error.code
|
|
118
|
+
: "http_error",
|
|
119
|
+
status: response.status,
|
|
120
|
+
requestId: response.headers.get("x-request-id"),
|
|
121
|
+
retryAfter: Number.isFinite(retry) && retry >= 0 ? retry : null,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async #json(response) {
|
|
125
|
+
const reader = response.body?.getReader();
|
|
126
|
+
if (!reader) {
|
|
127
|
+
throw new MeowGalleryError("Resposta vazia do serviço.", {
|
|
128
|
+
code: "invalid_response",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const chunks = [];
|
|
132
|
+
let size = 0;
|
|
133
|
+
try {
|
|
134
|
+
for (;;) {
|
|
135
|
+
const { done, value } = await reader.read();
|
|
136
|
+
if (done) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
size += value.byteLength;
|
|
140
|
+
if (size > 1_048_576) {
|
|
141
|
+
await reader.cancel();
|
|
142
|
+
throw new Error("Response limit exceeded");
|
|
143
|
+
}
|
|
144
|
+
chunks.push(value);
|
|
145
|
+
}
|
|
146
|
+
const joined = new Uint8Array(size);
|
|
147
|
+
let offset = 0;
|
|
148
|
+
for (const chunk of chunks) {
|
|
149
|
+
joined.set(chunk, offset);
|
|
150
|
+
offset += chunk.byteLength;
|
|
151
|
+
}
|
|
152
|
+
return JSON.parse(new TextDecoder().decode(joined));
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw new MeowGalleryError("Resposta inválida ou interrompida do serviço.", {
|
|
156
|
+
code: "invalid_response",
|
|
157
|
+
status: response.status,
|
|
158
|
+
requestId: response.headers.get("x-request-id"),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
reader.releaseLock();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAO1C,MAAM,OAAO,SAAS;IACX,OAAO,CAAS;IAChB,MA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AAG,SAAS,EAAE,CAAC;oBACrB,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;oBACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;gBAC7C,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,MAAM,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;YAC7B,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAY,CAAC;QACjE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACxB,+CAA+C,EAC/C;gBACE,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;aAChD,CACF,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class MeowGalleryError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly requestId: string | null;
|
|
5
|
+
readonly retryAfter: number | null;
|
|
6
|
+
constructor(message: string, details: {
|
|
7
|
+
code: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
requestId?: string | null;
|
|
10
|
+
retryAfter?: number | null;
|
|
11
|
+
});
|
|
12
|
+
}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class MeowGalleryError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
status;
|
|
4
|
+
requestId;
|
|
5
|
+
retryAfter;
|
|
6
|
+
constructor(message, details) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "MeowGalleryError";
|
|
9
|
+
this.code = details.code;
|
|
10
|
+
this.status = details.status ?? 0;
|
|
11
|
+
this.requestId = details.requestId ?? null;
|
|
12
|
+
this.retryAfter = details.retryAfter ?? null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAS;IACb,MAAM,CAAS;IACf,SAAS,CAAgB;IACzB,UAAU,CAAgB;IAEnC,YACE,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;IAC/C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Scope = "captures:read" | "delivery:read" | "sources:authenticated";
|
|
2
|
+
export interface CredentialInput {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly scopes: readonly Scope[];
|
|
5
|
+
readonly requestsPerMinute: number;
|
|
6
|
+
readonly subject?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Credential {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly scopes: readonly Scope[];
|
|
12
|
+
readonly requestsPerMinute: number;
|
|
13
|
+
readonly isAdmin: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CreatedCredential extends Omit<CredentialInput, "subject"> {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly key: string | null;
|
|
18
|
+
readonly subject: string | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/models/access.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Media {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly kind: "image" | "video" | "audio";
|
|
4
|
+
readonly mimeType: string;
|
|
5
|
+
readonly width: number | null;
|
|
6
|
+
readonly height: number | null;
|
|
7
|
+
readonly quality: {
|
|
8
|
+
readonly selection: "best_available";
|
|
9
|
+
readonly hd: boolean | null;
|
|
10
|
+
readonly verified: boolean;
|
|
11
|
+
};
|
|
12
|
+
readonly delivery: {
|
|
13
|
+
readonly url: string;
|
|
14
|
+
readonly expiresAt: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/models/media.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RequestOptions {
|
|
2
|
+
readonly signal?: AbortSignal;
|
|
3
|
+
}
|
|
4
|
+
export interface MeowGalleryOptions {
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
readonly token: string | (() => string | Promise<string>);
|
|
7
|
+
readonly timeoutMs?: number;
|
|
8
|
+
readonly allowLocalHttp?: boolean;
|
|
9
|
+
readonly fetch?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export interface CaptureOptions extends RequestOptions {
|
|
12
|
+
readonly refresh?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DeliveryOptions extends RequestOptions {
|
|
15
|
+
readonly range?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/models/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Media } from "#models/media";
|
|
2
|
+
export interface Capture {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly platform: "instagram" | "tiktok";
|
|
5
|
+
readonly caption: string;
|
|
6
|
+
readonly author: {
|
|
7
|
+
readonly username: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
};
|
|
10
|
+
readonly items: readonly Media[];
|
|
11
|
+
readonly audio: Media | null;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../src/models/post.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MeowGallery } from "#client";
|
|
2
|
+
import { MediaItem } from "#resources/item";
|
|
3
|
+
import type { Media, RequestOptions } from "#types";
|
|
4
|
+
export interface SaveOptions extends RequestOptions {
|
|
5
|
+
readonly maxBytes?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function saveMedia(media: MediaItem, destination: string, options?: SaveOptions): Promise<string>;
|
|
8
|
+
export declare function saveMedia(client: MeowGallery, media: Media, destination: string, options?: SaveOptions): Promise<string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createWriteStream } from "node:fs";
|
|
2
|
+
import { link, mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { Readable, Transform } from "node:stream";
|
|
5
|
+
import { pipeline } from "node:stream/promises";
|
|
6
|
+
import { MediaItem } from "#resources/item";
|
|
7
|
+
export async function saveMedia(source, mediaOrDestination, destinationOrOptions, legacyOptions = {}) {
|
|
8
|
+
const destination = source instanceof MediaItem
|
|
9
|
+
? mediaOrDestination
|
|
10
|
+
: destinationOrOptions;
|
|
11
|
+
const options = source instanceof MediaItem
|
|
12
|
+
? destinationOrOptions ?? {}
|
|
13
|
+
: legacyOptions;
|
|
14
|
+
const target = resolve(destination);
|
|
15
|
+
const directory = await mkdtemp(join(dirname(target), ".meowgallery-"));
|
|
16
|
+
const temporary = join(directory, "media");
|
|
17
|
+
const limit = options.maxBytes ?? 256 * 1024 * 1024;
|
|
18
|
+
if (!Number.isSafeInteger(limit) || limit <= 0) {
|
|
19
|
+
await rm(directory, { recursive: true, force: true });
|
|
20
|
+
throw new TypeError("maxBytes deve ser um inteiro positivo.");
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const response = source instanceof MediaItem
|
|
24
|
+
? await source.open(options)
|
|
25
|
+
: await source.download(mediaOrDestination, options);
|
|
26
|
+
if (!response.body) {
|
|
27
|
+
throw new Error("O serviço retornou uma mídia vazia.");
|
|
28
|
+
}
|
|
29
|
+
let total = 0;
|
|
30
|
+
const bounded = new Transform({
|
|
31
|
+
transform(chunk, _encoding, callback) {
|
|
32
|
+
total += chunk.length;
|
|
33
|
+
callback(total > limit
|
|
34
|
+
? new Error("A mídia excede o limite de tamanho.")
|
|
35
|
+
: null, chunk);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
await pipeline(Readable.fromWeb(response.body), bounded, createWriteStream(temporary, { flags: "wx", mode: 0o600 }), { signal: options.signal });
|
|
39
|
+
await link(temporary, target);
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
await rm(directory, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/node/save.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoB5C,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA+B,EAC/B,kBAAkC,EAClC,oBAA2C,EAC3C,aAAa,GAAgB,EAAE;IAE/B,MAAM,WAAW,GAAG,MAAM,YAAY,SAAS;QAC7C,CAAC,CAAC,kBAA4B;QAC9B,CAAC,CAAC,oBAA8B,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,YAAY,SAAS;QACzC,CAAC,CAAC,oBAA+C,IAAI,EAAE;QACvD,CAAC,CAAC,aAAa,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,IAAI,GAAG,GAAG,IAAI,GAAG,I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AC;IAChB,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import type { MeowGallery } from "#client";
|
|
3
|
+
import { MediaItem } from "#resources/item";
|
|
4
|
+
import type { DeliveryOptions, Media } from "#types";
|
|
5
|
+
export declare function streamMedia(media: MediaItem, options?: DeliveryOptions): Promise<Readable>;
|
|
6
|
+
export declare function streamMedia(client: MeowGallery, media: Media, options?: DeliveryOptions): Promise<Readable>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import { MediaItem } from "#resources/item";
|
|
3
|
+
export async function streamMedia(source, mediaOrOptions = {}, legacyOptions = {}) {
|
|
4
|
+
const options = source instanceof MediaItem
|
|
5
|
+
? mediaOrOptions
|
|
6
|
+
: legacyOptions;
|
|
7
|
+
const stream = source instanceof MediaItem
|
|
8
|
+
? await source.stream(options)
|
|
9
|
+
: await source.media.stream(mediaOrOptions, options);
|
|
10
|
+
return Readable.fromWeb(stream, {
|
|
11
|
+
objectMode: false,
|
|
12
|
+
highWaterMark: 64 * 1024,
|
|
13
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/node/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA+B,EAC/B,cAAc,GAA4B,EAAE,EAC5C,aAAa,GAAoB,EAAE;IAEnC,MAAM,OAAO,GAAG,MAAM,YAAY,SAAS;QACzC,CAAC,CAAC,cAAiC;QACnC,CAAC,CAAC,aAAa,CAAC;IAClB,MAAM,MAAM,GAAG,MAAM,YAAY,SAAS;QACxC,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC9B,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAAuB,EAAE,OAAO,CAAC,CAAC;IAEhE,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAoC,EAAE;QAC5D,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,EAAE,GAAG,IAAI;QACxB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/node.d.ts
ADDED
package/dist/node.js
ADDED
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Transport } from "#core/transport";
|
|
2
|
+
import type { CreatedCredential, Credential, CredentialInput, RequestOptions } from "#types";
|
|
3
|
+
export declare class Access {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
create(input: CredentialInput, options?: RequestOptions): Promise<CreatedCredential>;
|
|
7
|
+
list(options?: RequestOptions): Promise<Credential[]>;
|
|
8
|
+
revoke(id: string, options?: RequestOptions): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class Access {
|
|
2
|
+
#transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.#transport = transport;
|
|
5
|
+
}
|
|
6
|
+
create(input, options = {}) {
|
|
7
|
+
return this.#transport.request("POST", "/v1/credentials", input, options);
|
|
8
|
+
}
|
|
9
|
+
list(options = {}) {
|
|
10
|
+
return this.#transport.request("GET", "/v1/credentials", undefined, options);
|
|
11
|
+
}
|
|
12
|
+
revoke(id, options = {}) {
|
|
13
|
+
if (!/^[0-9a-f-]{36}$/i.test(id)) {
|
|
14
|
+
throw new TypeError("Identificador de credencial inválido.");
|
|
15
|
+
}
|
|
16
|
+
return this.#transport.request("DELETE", `/v1/credentials/${id}`, undefined, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/resources/access.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,MAAM;IACR,UAAU,CAAY;IAE/B,YAAY,SAAoB;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,MAAM,CACJ,KAAsB,EACtB,OAAO,GAAmB,EAAE;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,CAAC,OAAO,GAAmB,EAAE;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,OAAO,GAAmB,EAAE;QAC7C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAC5B,QAAQ,EACR,mBAAmB,EAAE,EAAE,EACvB,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MediaLibrary } from "#resources/media";
|
|
2
|
+
import type { DeliveryOptions, Media } from "#types";
|
|
3
|
+
export declare class MediaItem implements Media {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(data: Media, library: MediaLibrary);
|
|
6
|
+
get id(): string;
|
|
7
|
+
get kind(): "audio" | "image" | "video";
|
|
8
|
+
get mimeType(): string;
|
|
9
|
+
get width(): number | null;
|
|
10
|
+
get height(): number | null;
|
|
11
|
+
get quality(): {
|
|
12
|
+
readonly selection: "best_available";
|
|
13
|
+
readonly hd: boolean | null;
|
|
14
|
+
readonly verified: boolean;
|
|
15
|
+
};
|
|
16
|
+
get delivery(): {
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly expiresAt: string;
|
|
19
|
+
};
|
|
20
|
+
get url(): string;
|
|
21
|
+
get expired(): boolean;
|
|
22
|
+
open(options?: DeliveryOptions): Promise<Response>;
|
|
23
|
+
stream(options?: DeliveryOptions): Promise<ReadableStream<Uint8Array>>;
|
|
24
|
+
toJSON(): Media;
|
|
25
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class MediaItem {
|
|
2
|
+
#data;
|
|
3
|
+
#library;
|
|
4
|
+
constructor(data, library) {
|
|
5
|
+
this.#data = Object.freeze({
|
|
6
|
+
...data,
|
|
7
|
+
delivery: Object.freeze({ ...data.delivery }),
|
|
8
|
+
quality: Object.freeze({ ...data.quality }),
|
|
9
|
+
});
|
|
10
|
+
this.#library = library;
|
|
11
|
+
}
|
|
12
|
+
get id() {
|
|
13
|
+
return this.#data.id;
|
|
14
|
+
}
|
|
15
|
+
get kind() {
|
|
16
|
+
return this.#data.kind;
|
|
17
|
+
}
|
|
18
|
+
get mimeType() {
|
|
19
|
+
return this.#data.mimeType;
|
|
20
|
+
}
|
|
21
|
+
get width() {
|
|
22
|
+
return this.#data.width;
|
|
23
|
+
}
|
|
24
|
+
get height() {
|
|
25
|
+
return this.#data.height;
|
|
26
|
+
}
|
|
27
|
+
get quality() {
|
|
28
|
+
return this.#data.quality;
|
|
29
|
+
}
|
|
30
|
+
get delivery() {
|
|
31
|
+
return this.#data.delivery;
|
|
32
|
+
}
|
|
33
|
+
get url() {
|
|
34
|
+
return this.delivery.url;
|
|
35
|
+
}
|
|
36
|
+
get expired() {
|
|
37
|
+
const expires = Date.parse(this.delivery.expiresAt);
|
|
38
|
+
return !Number.isFinite(expires) || expires <= Date.now();
|
|
39
|
+
}
|
|
40
|
+
open(options = {}) {
|
|
41
|
+
return this.#library.open(this, options);
|
|
42
|
+
}
|
|
43
|
+
stream(options = {}) {
|
|
44
|
+
return this.#library.stream(this, options);
|
|
45
|
+
}
|
|
46
|
+
toJSON() {
|
|
47
|
+
return this.#data;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../src/resources/item.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,SAAS;IACX,KAAK,CAAQ;IACb,QAAQ,CAAe;IAEhC,YAAY,IAAW,EAAE,OAAqB;QAC5C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YACzB,GAAG,IAAI;YACP,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;SAC5C,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEpD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAED,IAAI,CAAC,OAAO,GAAoB,EAAE;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,OAAO,GAAoB,EAAE;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transport } from "#core/transport";
|
|
2
|
+
import type { DeliveryOptions, Media } from "#types";
|
|
3
|
+
export declare class MediaLibrary {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
open(media: Media, options?: DeliveryOptions): Promise<Response>;
|
|
7
|
+
stream(media: Media, options?: DeliveryOptions): Promise<ReadableStream<Uint8Array>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class MediaLibrary {
|
|
2
|
+
#transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.#transport = transport;
|
|
5
|
+
}
|
|
6
|
+
open(media, options = {}) {
|
|
7
|
+
return this.#transport.download(media, options);
|
|
8
|
+
}
|
|
9
|
+
async stream(media, options = {}) {
|
|
10
|
+
const response = await this.open(media, options);
|
|
11
|
+
if (!response.body) {
|
|
12
|
+
throw new Error("O serviço retornou uma mídia vazia.");
|
|
13
|
+
}
|
|
14
|
+
return response.body;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/resources/media.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IACd,UAAU,CAAY;IAE/B,YAAY,SAAoB;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,IAAI,CAAC,KAAY,EAAE,OAAO,GAAoB,EAAE;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAY,EACZ,OAAO,GAAoB,EAAE;QAE7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEjD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Transport } from "#core/transport";
|
|
2
|
+
import type { MediaLibrary } from "#resources/media";
|
|
3
|
+
import { Publication } from "#resources/publication";
|
|
4
|
+
import type { CaptureOptions } from "#types";
|
|
5
|
+
export declare class Posts {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(transport: Transport, media: MediaLibrary);
|
|
8
|
+
resolve(url: string, options?: CaptureOptions): Promise<Publication>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Publication } from "#resources/publication";
|
|
2
|
+
export class Posts {
|
|
3
|
+
#transport;
|
|
4
|
+
#media;
|
|
5
|
+
constructor(transport, media) {
|
|
6
|
+
this.#transport = transport;
|
|
7
|
+
this.#media = media;
|
|
8
|
+
}
|
|
9
|
+
async resolve(url, options = {}) {
|
|
10
|
+
const data = await this.#transport.request("POST", "/v1/captures", options.refresh ? { url, refresh: true } : { url }, options);
|
|
11
|
+
return new Publication(data, this.#media);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=posts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posts.js","sourceRoot":"","sources":["../../src/resources/posts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,MAAM,OAAO,KAAK;IACP,UAAU,CAAY;IACtB,MAAM,CAAe;IAE9B,YAAY,SAAoB,EAAE,KAAmB;QACnD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,OAAO,GAAmB,EAAE;QACrD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CACxC,MAAM,EACN,cAAc,EACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAClD,OAAO,CACR,CAAC;QAEF,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MediaItem } from "#resources/item";
|
|
2
|
+
import type { MediaLibrary } from "#resources/media";
|
|
3
|
+
import type { Capture } from "#types";
|
|
4
|
+
export declare class Publication implements Capture {
|
|
5
|
+
#private;
|
|
6
|
+
readonly items: readonly MediaItem[];
|
|
7
|
+
readonly images: readonly MediaItem[];
|
|
8
|
+
readonly videos: readonly MediaItem[];
|
|
9
|
+
readonly audio: MediaItem | null;
|
|
10
|
+
constructor(data: Capture, media: MediaLibrary);
|
|
11
|
+
get id(): string;
|
|
12
|
+
get platform(): "instagram" | "tiktok";
|
|
13
|
+
get caption(): string;
|
|
14
|
+
get author(): {
|
|
15
|
+
readonly username: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
};
|
|
18
|
+
get video(): MediaItem | undefined;
|
|
19
|
+
toJSON(): Capture;
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MediaItem } from "#resources/item";
|
|
2
|
+
export class Publication {
|
|
3
|
+
#data;
|
|
4
|
+
items;
|
|
5
|
+
images;
|
|
6
|
+
videos;
|
|
7
|
+
audio;
|
|
8
|
+
constructor(data, media) {
|
|
9
|
+
this.#data = Object.freeze({
|
|
10
|
+
...data,
|
|
11
|
+
author: Object.freeze({ ...data.author }),
|
|
12
|
+
});
|
|
13
|
+
this.items = Object.freeze(data.items.map((item) => new MediaItem(item, media)));
|
|
14
|
+
this.images = Object.freeze(this.items.filter((item) => item.kind === "image"));
|
|
15
|
+
this.videos = Object.freeze(this.items.filter((item) => item.kind === "video"));
|
|
16
|
+
this.audio = data.audio ? new MediaItem(data.audio, media) : null;
|
|
17
|
+
Object.freeze(this);
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return this.#data.id;
|
|
21
|
+
}
|
|
22
|
+
get platform() {
|
|
23
|
+
return this.#data.platform;
|
|
24
|
+
}
|
|
25
|
+
get caption() {
|
|
26
|
+
return this.#data.caption;
|
|
27
|
+
}
|
|
28
|
+
get author() {
|
|
29
|
+
return this.#data.author;
|
|
30
|
+
}
|
|
31
|
+
get video() {
|
|
32
|
+
return this.videos[0];
|
|
33
|
+
}
|
|
34
|
+
toJSON() {
|
|
35
|
+
return {
|
|
36
|
+
id: this.id,
|
|
37
|
+
platform: this.platform,
|
|
38
|
+
caption: this.caption,
|
|
39
|
+
author: this.author,
|
|
40
|
+
items: this.items.map((item) => item.toJSON()),
|
|
41
|
+
audio: this.audio?.toJSON() ?? null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=publication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publication.js","sourceRoot":"","sources":["../../src/resources/publication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAW;IACb,KAAK,CAAU;IACf,KAAK,CAAuB;IAC5B,MAAM,CAAuB;IAC7B,MAAM,CAAuB;IAC7B,KAAK,CAAmB;IAEjC,YAAY,IAAa,EAAE,KAAmB;QAC5C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YACzB,GAAG,IAAI;YACP,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,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I,IAAI;SACpC,CAAC;IACJ,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { Media } from "#models/media";
|
|
2
|
+
export type { Capture } from "#models/post";
|
|
3
|
+
export type { Scope, Credential, CredentialInput, CreatedCredential, } from "#models/access";
|
|
4
|
+
export type { RequestOptions, MeowGalleryOptions, CaptureOptions, DeliveryOptions, } from "#models/options";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luanxdd/meowgallery",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Uma interface simples para capturar e entregar mídias com MeowGallery.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./node": {
|
|
20
|
+
"types": "./dist/node.d.ts",
|
|
21
|
+
"import": "./dist/node.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"imports": {
|
|
25
|
+
"#types": {
|
|
26
|
+
"types": "./dist/types.d.ts",
|
|
27
|
+
"default": "./dist/types.js"
|
|
28
|
+
},
|
|
29
|
+
"#error": {
|
|
30
|
+
"types": "./dist/error.d.ts",
|
|
31
|
+
"default": "./dist/error.js"
|
|
32
|
+
},
|
|
33
|
+
"#client": {
|
|
34
|
+
"types": "./dist/client.d.ts",
|
|
35
|
+
"default": "./dist/client.js"
|
|
36
|
+
},
|
|
37
|
+
"#*": {
|
|
38
|
+
"types": "./dist/*.d.ts",
|
|
39
|
+
"default": "./dist/*.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
46
|
+
"prepack": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"@types/node": "^24.0.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
}
|
|
55
|
+
}
|