@luanxdd/meowgallery 0.2.0 → 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.
Files changed (48) hide show
  1. package/README.md +50 -63
  2. package/dist/client.d.ts +11 -10
  3. package/dist/client.js +20 -169
  4. package/dist/client.js.map +1 -1
  5. package/dist/core/transport.d.ts +9 -0
  6. package/dist/core/transport.js +166 -0
  7. package/dist/core/transport.js.map +1 -0
  8. package/dist/index.d.ts +3 -1
  9. package/dist/index.js +2 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/models/access.d.ts +19 -0
  12. package/dist/models/access.js +2 -0
  13. package/dist/models/access.js.map +1 -0
  14. package/dist/models/media.d.ts +16 -0
  15. package/dist/models/media.js +2 -0
  16. package/dist/models/media.js.map +1 -0
  17. package/dist/models/options.d.ts +16 -0
  18. package/dist/models/options.js +2 -0
  19. package/dist/models/options.js.map +1 -0
  20. package/dist/models/post.d.ts +12 -0
  21. package/dist/models/post.js +2 -0
  22. package/dist/models/post.js.map +1 -0
  23. package/dist/node/save.d.ts +8 -0
  24. package/dist/node/save.js +46 -0
  25. package/dist/node/save.js.map +1 -0
  26. package/dist/node/stream.d.ts +6 -0
  27. package/dist/node/stream.js +16 -0
  28. package/dist/node/stream.js.map +1 -0
  29. package/dist/node.d.ts +3 -6
  30. package/dist/node.js +2 -36
  31. package/dist/node.js.map +1 -1
  32. package/dist/resources/access.d.ts +9 -0
  33. package/dist/resources/access.js +19 -0
  34. package/dist/resources/access.js.map +1 -0
  35. package/dist/resources/item.d.ts +25 -0
  36. package/dist/resources/item.js +50 -0
  37. package/dist/resources/item.js.map +1 -0
  38. package/dist/resources/media.d.ts +8 -0
  39. package/dist/resources/media.js +17 -0
  40. package/dist/resources/media.js.map +1 -0
  41. package/dist/resources/posts.d.ts +9 -0
  42. package/dist/resources/posts.js +14 -0
  43. package/dist/resources/posts.js.map +1 -0
  44. package/dist/resources/publication.d.ts +20 -0
  45. package/dist/resources/publication.js +45 -0
  46. package/dist/resources/publication.js.map +1 -0
  47. package/dist/types.d.ts +4 -56
  48. package/package.json +7 -3
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=media.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=options.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=post.js.map
@@ -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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,EAAE,CAC3B,CAAC;QACF,MAAM,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC;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 CHANGED
@@ -1,6 +1,3 @@
1
- import type { MeowGallery } from "#client";
2
- import type { Media, RequestOptions } from "#types";
3
- export interface SaveOptions extends RequestOptions {
4
- readonly maxBytes?: number;
5
- }
6
- export declare function saveMedia(client: MeowGallery, media: Media, destination: string, options?: SaveOptions): Promise<string>;
1
+ export { saveMedia } from "#node/save";
2
+ export type { SaveOptions } from "#node/save";
3
+ export { streamMedia } from "#node/stream";
package/dist/node.js CHANGED
@@ -1,37 +1,3 @@
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
- export async function saveMedia(client, media, destination, options = {}) {
7
- const target = resolve(destination);
8
- const directory = await mkdtemp(join(dirname(target), ".meowgallery-"));
9
- const temporary = join(directory, "media");
10
- const limit = options.maxBytes ?? 256 * 1024 * 1024;
11
- if (!Number.isSafeInteger(limit) || limit <= 0) {
12
- await rm(directory, { recursive: true, force: true });
13
- throw new TypeError("maxBytes deve ser um inteiro positivo.");
14
- }
15
- try {
16
- const response = await client.download(media, options);
17
- if (!response.body) {
18
- throw new Error("O serviço retornou uma mídia vazia.");
19
- }
20
- let total = 0;
21
- const bounded = new Transform({
22
- transform(chunk, _encoding, callback) {
23
- total += chunk.length;
24
- callback(total > limit
25
- ? new Error("A mídia excede o limite de tamanho.")
26
- : null, chunk);
27
- },
28
- });
29
- await pipeline(Readable.fromWeb(response.body), bounded, createWriteStream(temporary, { flags: "wx", mode: 0o600 }), { signal: options.signal });
30
- await link(temporary, target);
31
- return target;
32
- }
33
- finally {
34
- await rm(directory, { recursive: true, force: true });
35
- }
36
- }
1
+ export { saveMedia } from "#node/save";
2
+ export { streamMedia } from "#node/stream";
37
3
  //# sourceMappingURL=node.js.map
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.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;AAShD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAmB,EACnB,KAAY,EACZ,WAAmB,EACnB,OAAO,GAAgB,EAAE;IAEzB,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,IAAI,CAAC;IACpD,IAAI,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AAC;IACxD,CAAC;AACH,CAAC"}
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,CA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AAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9C,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI;SACpC,CAAC;IACJ,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -1,56 +1,4 @@
1
- export type Scope = "captures:read" | "delivery:read" | "sources:authenticated";
2
- export interface Media {
3
- readonly id: string;
4
- readonly kind: "image" | "video" | "audio";
5
- readonly mimeType: string;
6
- readonly width: number | null;
7
- readonly height: number | null;
8
- readonly quality: {
9
- readonly selection: "best_available";
10
- readonly hd: boolean | null;
11
- readonly verified: boolean;
12
- };
13
- readonly delivery: {
14
- readonly url: string;
15
- readonly expiresAt: string;
16
- };
17
- }
18
- export interface Capture {
19
- readonly id: string;
20
- readonly platform: "instagram" | "tiktok";
21
- readonly caption: string;
22
- readonly author: {
23
- readonly username: string;
24
- readonly name: string;
25
- };
26
- readonly items: readonly Media[];
27
- readonly audio: Media | null;
28
- }
29
- export interface CredentialInput {
30
- readonly name: string;
31
- readonly scopes: readonly Scope[];
32
- readonly requestsPerMinute: number;
33
- readonly subject?: string;
34
- }
35
- export interface Credential {
36
- readonly id: string;
37
- readonly name: string;
38
- readonly scopes: readonly Scope[];
39
- readonly requestsPerMinute: number;
40
- readonly isAdmin: boolean;
41
- }
42
- export interface CreatedCredential extends Omit<CredentialInput, "subject"> {
43
- readonly id: string;
44
- readonly key: string | null;
45
- readonly subject: string | null;
46
- }
47
- export interface RequestOptions {
48
- readonly signal?: AbortSignal;
49
- }
50
- export interface MeowGalleryOptions {
51
- readonly baseUrl: string;
52
- readonly token: string | (() => string | Promise<string>);
53
- readonly timeoutMs?: number;
54
- readonly allowLocalHttp?: boolean;
55
- readonly fetch?: typeof fetch;
56
- }
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luanxdd/meowgallery",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Uma interface simples para capturar e entregar mídias com MeowGallery.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -33,6 +33,10 @@
33
33
  "#client": {
34
34
  "types": "./dist/client.d.ts",
35
35
  "default": "./dist/client.js"
36
+ },
37
+ "#*": {
38
+ "types": "./dist/*.d.ts",
39
+ "default": "./dist/*.js"
36
40
  }
37
41
  },
38
42
  "scripts": {
@@ -42,8 +46,8 @@
42
46
  "prepack": "npm run build"
43
47
  },
44
48
  "devDependencies": {
45
- "@types/node": "^24.0.0",
46
- "typescript": "7.0.2"
49
+ "typescript": "7.0.2",
50
+ "@types/node": "^24.0.0"
47
51
  },
48
52
  "publishConfig": {
49
53
  "access": "public"