gallery-magazine 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Factory Publishing Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ The content distributed via the Gallery Magazine API remains the property of
24
+ Factory Publishing Ltd and is subject to the licensing terms at
25
+ https://gallery.je/AGENTS.md — the MIT license above applies to this SDK code
26
+ only, not to retrieved article text, images or metadata.
package/README.md CHANGED
@@ -1,3 +1,94 @@
1
- # Temporary Holding Version
1
+ # gallery-magazine
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official JavaScript SDK and CLI for the **Gallery Magazine** public API
4
+ (<https://gallery.je>) — Jersey's life and style magazine, in print since 2004.
5
+
6
+ The API is read-only, requires no authentication, and covers every published
7
+ article, author, category, topic and print issue. Under the hood this package
8
+ is a thin typed wrapper around the public JSON endpoints documented at
9
+ <https://gallery.je/developers> and the OpenAPI spec at
10
+ <https://gallery.je/api/openapi.json>.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install gallery-magazine
16
+ ```
17
+
18
+ Node 18+ for the built-in `fetch`. For older runtimes, pass a `fetch` in the
19
+ client options.
20
+
21
+ ## SDK
22
+
23
+ ```ts
24
+ import { GalleryClient } from "gallery-magazine";
25
+
26
+ const gallery = new GalleryClient();
27
+
28
+ const { articles } = await gallery.listArticles({ limit: 10 });
29
+ for (const a of articles) {
30
+ console.log(`${a.publishedAt?.slice(0, 10)} — ${a.title}`);
31
+ }
32
+
33
+ const article = await gallery.getArticle("into-the-blue");
34
+ console.log(article.title, article.author);
35
+
36
+ const { topics } = await gallery.listTopics();
37
+ ```
38
+
39
+ ### Methods
40
+
41
+ - `listArticles({ limit?, offset?, status?, categoryId? })`
42
+ - `listFeaturedArticles()`
43
+ - `getArticle(slug)`
44
+ - `listCategories()`
45
+ - `listTopics()`
46
+ - `getTopic(slug)`
47
+ - `listAuthors()`
48
+ - `listAuthorDirectory()`
49
+ - `getAuthor(slug)`
50
+ - `getSitemap()`
51
+
52
+ ### Options
53
+
54
+ ```ts
55
+ new GalleryClient({
56
+ baseUrl: "https://gallery.je", // defaults to production
57
+ fetch: customFetch, // optional; defaults to global fetch
58
+ headers: { "User-Agent": "…" }, // merged with defaults
59
+ });
60
+ ```
61
+
62
+ Errors on non-2xx responses throw `GalleryApiError` (`status`, `body`, `message`).
63
+
64
+ ## CLI
65
+
66
+ The same package installs a `gallery` binary.
67
+
68
+ ```bash
69
+ npx gallery list-articles --limit=5
70
+ npx gallery get-article into-the-blue
71
+ npx gallery list-topics
72
+ npx gallery get-topic jersey-weddings | jq '.articles[].title'
73
+ ```
74
+
75
+ Every subcommand prints JSON to stdout; pipe through `jq` for the shape you
76
+ want. `gallery help` lists every command.
77
+
78
+ ## Content formats beyond JSON
79
+
80
+ - **Markdown** — every article has a `.md` twin at `/article/<slug>.md`.
81
+ Agents sending `Accept: text/markdown` or identifying as `Claude-User` /
82
+ `ChatGPT-User` / `PerplexityBot` get markdown by content negotiation.
83
+ - **RSS 2.0** — full-content feed at `/rss.xml`; per-category at
84
+ `/feeds/<slug>.rss`.
85
+ - **XML sitemap** — `/sitemap.xml` and `/news-sitemap.xml`.
86
+
87
+ See `/.well-known/api-catalog` and `/.well-known/ard.json` for machine-readable
88
+ discovery.
89
+
90
+ ## License
91
+
92
+ MIT. Content fetched via this SDK is published by Factory Publishing Ltd;
93
+ cite with the canonical article URL and attribute to the named author — see
94
+ <https://gallery.je/AGENTS.md>.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ // `gallery` — CLI wrapper around GalleryClient. Every subcommand prints
3
+ // JSON to stdout; errors to stderr with a non-zero exit code. Designed
4
+ // for `jq` pipelines and quick API exploration.
5
+ import { GalleryClient, GalleryApiError } from "./index.js";
6
+ const USAGE = `Gallery Magazine CLI — public read-only API for gallery.je
7
+
8
+ Usage: gallery <command> [args]
9
+
10
+ Commands:
11
+ list-articles [--limit=N] [--category=ID] Most-recent articles
12
+ get-article <slug> One article with author + tags
13
+ list-featured Pinned / featured articles
14
+ list-categories Editorial sections
15
+ list-topics Topic hubs (tags with 3+ articles)
16
+ get-topic <slug> One topic's articles
17
+ list-authors All authors
18
+ list-author-directory Authors with article counts
19
+ get-author <slug> One author profile
20
+ sitemap Full JSON sitemap
21
+ version Print CLI version
22
+
23
+ Options:
24
+ --base=<url> Override API base (default https://gallery.je)
25
+ --limit=<n> Pagination size
26
+ --category=<id> Filter by category id
27
+
28
+ Each command prints JSON to stdout. Pipe to jq for exploration:
29
+ gallery list-articles --limit=5 | jq '.articles[].title'
30
+ `;
31
+ const PKG_VERSION = "0.1.0";
32
+ function parseArgs(argv) {
33
+ const positional = [];
34
+ const flags = {};
35
+ for (const a of argv) {
36
+ const m = /^--([^=]+)(?:=(.*))?$/.exec(a);
37
+ if (m)
38
+ flags[m[1]] = m[2] ?? "true";
39
+ else
40
+ positional.push(a);
41
+ }
42
+ return { positional, flags };
43
+ }
44
+ async function main() {
45
+ const [, , cmd, ...rest] = process.argv;
46
+ const { positional, flags } = parseArgs(rest);
47
+ const client = new GalleryClient({ baseUrl: flags.base });
48
+ try {
49
+ switch (cmd) {
50
+ case "list-articles": {
51
+ const out = await client.listArticles({
52
+ limit: flags.limit ? Number(flags.limit) : undefined,
53
+ categoryId: flags.category,
54
+ });
55
+ console.log(JSON.stringify(out, null, 2));
56
+ break;
57
+ }
58
+ case "get-article": {
59
+ if (!positional[0])
60
+ throw new Error("usage: gallery get-article <slug>");
61
+ console.log(JSON.stringify(await client.getArticle(positional[0]), null, 2));
62
+ break;
63
+ }
64
+ case "list-featured": {
65
+ console.log(JSON.stringify(await client.listFeaturedArticles(), null, 2));
66
+ break;
67
+ }
68
+ case "list-categories": {
69
+ console.log(JSON.stringify(await client.listCategories(), null, 2));
70
+ break;
71
+ }
72
+ case "list-topics": {
73
+ console.log(JSON.stringify(await client.listTopics(), null, 2));
74
+ break;
75
+ }
76
+ case "get-topic": {
77
+ if (!positional[0])
78
+ throw new Error("usage: gallery get-topic <slug>");
79
+ console.log(JSON.stringify(await client.getTopic(positional[0]), null, 2));
80
+ break;
81
+ }
82
+ case "list-authors": {
83
+ console.log(JSON.stringify(await client.listAuthors(), null, 2));
84
+ break;
85
+ }
86
+ case "list-author-directory": {
87
+ console.log(JSON.stringify(await client.listAuthorDirectory(), null, 2));
88
+ break;
89
+ }
90
+ case "get-author": {
91
+ if (!positional[0])
92
+ throw new Error("usage: gallery get-author <slug>");
93
+ console.log(JSON.stringify(await client.getAuthor(positional[0]), null, 2));
94
+ break;
95
+ }
96
+ case "sitemap": {
97
+ console.log(JSON.stringify(await client.getSitemap(), null, 2));
98
+ break;
99
+ }
100
+ case "version":
101
+ case "--version":
102
+ case "-v": {
103
+ console.log(PKG_VERSION);
104
+ break;
105
+ }
106
+ case undefined:
107
+ case "help":
108
+ case "--help":
109
+ case "-h": {
110
+ console.log(USAGE);
111
+ break;
112
+ }
113
+ default: {
114
+ console.error(`unknown command: ${cmd}\n`);
115
+ console.error(USAGE);
116
+ process.exit(2);
117
+ }
118
+ }
119
+ }
120
+ catch (err) {
121
+ if (err instanceof GalleryApiError) {
122
+ console.error(`gallery: ${err.message}`);
123
+ if (err.body)
124
+ console.error(JSON.stringify(err.body, null, 2));
125
+ }
126
+ else {
127
+ console.error(`gallery: ${err.message || err}`);
128
+ }
129
+ process.exit(1);
130
+ }
131
+ }
132
+ main();
133
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,wEAAwE;AACxE,uEAAuE;AACvE,gDAAgD;AAEhD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBb,CAAC;AAEF,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC;YAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;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I,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,YAAa,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,116 @@
1
+ export declare const GALLERY_ORIGIN = "https://gallery.je";
2
+ export interface GalleryClientOptions {
3
+ /** Base URL. Defaults to the production origin. */
4
+ baseUrl?: string;
5
+ /** Override the fetch implementation. Defaults to the global one. */
6
+ fetch?: typeof globalThis.fetch;
7
+ /** Extra headers to send with every request. */
8
+ headers?: Record<string, string>;
9
+ }
10
+ export interface ListArticlesOptions {
11
+ limit?: number;
12
+ offset?: number;
13
+ status?: "published" | "draft";
14
+ categoryId?: string;
15
+ }
16
+ /**
17
+ * The shapes below are deliberately minimal — every public endpoint
18
+ * returns additional fields and may grow more over time. Callers can
19
+ * narrow with their own types; these are the stable load-bearing keys.
20
+ */
21
+ export interface Article {
22
+ id: string;
23
+ slug: string;
24
+ title: string;
25
+ excerpt?: string | null;
26
+ content?: string;
27
+ featuredImage?: string | null;
28
+ publishedAt?: string | null;
29
+ updatedAt?: string | null;
30
+ authorId?: string | null;
31
+ categoryId?: string | null;
32
+ [key: string]: unknown;
33
+ }
34
+ export interface Category {
35
+ id: string;
36
+ slug: string;
37
+ name: string;
38
+ description?: string | null;
39
+ parentId?: string | null;
40
+ [key: string]: unknown;
41
+ }
42
+ export interface Topic {
43
+ slug: string;
44
+ name: string;
45
+ articleCount: number;
46
+ }
47
+ export interface Author {
48
+ id: string;
49
+ slug: string;
50
+ name: string;
51
+ bio?: string | null;
52
+ photoUrl?: string | null;
53
+ avatar?: string | null;
54
+ defaultRole?: string | null;
55
+ [key: string]: unknown;
56
+ }
57
+ export interface Pagination {
58
+ total: number;
59
+ limit: number;
60
+ offset: number;
61
+ hasMore?: boolean;
62
+ [key: string]: unknown;
63
+ }
64
+ export declare class GalleryApiError extends Error {
65
+ readonly status: number;
66
+ readonly body: unknown;
67
+ constructor(status: number, body: unknown, message: string);
68
+ }
69
+ export declare class GalleryClient {
70
+ private readonly baseUrl;
71
+ private readonly fetchImpl;
72
+ private readonly headers;
73
+ constructor(options?: GalleryClientOptions);
74
+ private get;
75
+ /** Paginated article index. */
76
+ listArticles(options?: ListArticlesOptions): Promise<{
77
+ articles: Article[];
78
+ pagination?: Pagination;
79
+ }>;
80
+ /** Pinned / featured articles for the home surface. */
81
+ listFeaturedArticles(): Promise<{
82
+ articles: Article[];
83
+ }>;
84
+ /** Fetch a single article by slug (returns author, category, tags). */
85
+ getArticle(slug: string): Promise<Article>;
86
+ /** Editorial categories (top-level sections). */
87
+ listCategories(): Promise<{
88
+ categories: Category[];
89
+ }>;
90
+ /** Topic hubs — tags with 3+ published articles. */
91
+ listTopics(): Promise<{
92
+ topics: Topic[];
93
+ }>;
94
+ /** One topic with its articles. */
95
+ getTopic(slug: string): Promise<{
96
+ topic: {
97
+ slug: string;
98
+ name: string;
99
+ };
100
+ articles: Article[];
101
+ }>;
102
+ /** All authors on the system. */
103
+ listAuthors(): Promise<{
104
+ authors: Author[];
105
+ }>;
106
+ /** Public author directory (with article counts + category breakdown). */
107
+ listAuthorDirectory(): Promise<{
108
+ authors: Author[];
109
+ }>;
110
+ /** One author profile by slug. */
111
+ getAuthor(slug: string): Promise<Author>;
112
+ /** JSON sitemap — categories, articles, authors, issues, topics. */
113
+ getSitemap(): Promise<unknown>;
114
+ }
115
+ export default GalleryClient;
116
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,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CAAA;KAAE,CAAC;IAIxD,uEAAuE;IACvE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C,iDAAiD;IACjD,cAAc,IAAI,OAAO,CAAC;QAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;IAIrD,oDAAoD;IACpD,UAAU,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IAI1C,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAI/F,iCAAiC;IACjC,WAAW,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAI7C,0EAA0E;IAC1E,mBAAmB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAIrD,kCAAkC;IAClC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxC,oEAAoE;IACpE,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAG/B;AAED,eAAe,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ // gallery-magazine — official SDK for the Gallery Magazine public API.
2
+ //
3
+ // Gallery is Jersey's life and style magazine, in print since 2004. The
4
+ // public API under https://gallery.je/api is read-only and requires no
5
+ // authentication. This client wraps every public endpoint in a typed
6
+ // method and leaves transport to the global `fetch`.
7
+ //
8
+ // Quickstart:
9
+ //
10
+ // import { GalleryClient } from "gallery-magazine";
11
+ //
12
+ // const gallery = new GalleryClient();
13
+ // const { articles } = await gallery.listArticles({ limit: 10 });
14
+ // for (const a of articles) console.log(a.title);
15
+ export const GALLERY_ORIGIN = "https://gallery.je";
16
+ export class GalleryApiError extends Error {
17
+ status;
18
+ body;
19
+ constructor(status, body, message) {
20
+ super(message);
21
+ this.name = "GalleryApiError";
22
+ this.status = status;
23
+ this.body = body;
24
+ }
25
+ }
26
+ export class GalleryClient {
27
+ baseUrl;
28
+ fetchImpl;
29
+ headers;
30
+ constructor(options = {}) {
31
+ this.baseUrl = (options.baseUrl ?? GALLERY_ORIGIN).replace(/\/$/, "");
32
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
33
+ if (!this.fetchImpl) {
34
+ throw new Error("GalleryClient: no fetch implementation. Pass one in options.fetch or run on Node 18+.");
35
+ }
36
+ this.headers = {
37
+ Accept: "application/json",
38
+ "User-Agent": "gallery-magazine-sdk/0.1",
39
+ ...options.headers,
40
+ };
41
+ }
42
+ async get(path) {
43
+ const url = `${this.baseUrl}${path}`;
44
+ const res = await this.fetchImpl(url, { headers: this.headers });
45
+ if (!res.ok) {
46
+ let body = null;
47
+ try {
48
+ body = await res.json();
49
+ }
50
+ catch {
51
+ try {
52
+ body = await res.text();
53
+ }
54
+ catch {
55
+ /* ignore */
56
+ }
57
+ }
58
+ throw new GalleryApiError(res.status, body, `GET ${path} → HTTP ${res.status}`);
59
+ }
60
+ return (await res.json());
61
+ }
62
+ /** Paginated article index. */
63
+ listArticles(options = {}) {
64
+ const q = new URLSearchParams();
65
+ if (options.limit != null)
66
+ q.set("limit", String(options.limit));
67
+ if (options.offset != null)
68
+ q.set("offset", String(options.offset));
69
+ if (options.status)
70
+ q.set("status", options.status);
71
+ if (options.categoryId)
72
+ q.set("categoryId", options.categoryId);
73
+ const suffix = q.toString() ? `?${q}` : "";
74
+ return this.get(`/api/articles${suffix}`);
75
+ }
76
+ /** Pinned / featured articles for the home surface. */
77
+ listFeaturedArticles() {
78
+ return this.get(`/api/articles/featured`);
79
+ }
80
+ /** Fetch a single article by slug (returns author, category, tags). */
81
+ getArticle(slug) {
82
+ return this.get(`/api/articles/${encodeURIComponent(slug)}`);
83
+ }
84
+ /** Editorial categories (top-level sections). */
85
+ listCategories() {
86
+ return this.get(`/api/categories`);
87
+ }
88
+ /** Topic hubs — tags with 3+ published articles. */
89
+ listTopics() {
90
+ return this.get(`/api/topics`);
91
+ }
92
+ /** One topic with its articles. */
93
+ getTopic(slug) {
94
+ return this.get(`/api/topic/${encodeURIComponent(slug)}`);
95
+ }
96
+ /** All authors on the system. */
97
+ listAuthors() {
98
+ return this.get(`/api/authors`);
99
+ }
100
+ /** Public author directory (with article counts + category breakdown). */
101
+ listAuthorDirectory() {
102
+ return this.get(`/api/authors/directory`);
103
+ }
104
+ /** One author profile by slug. */
105
+ getAuthor(slug) {
106
+ return this.get(`/api/authors/by-slug/${encodeURIComponent(slug)}`);
107
+ }
108
+ /** JSON sitemap — categories, articles, authors, issues, topics. */
109
+ getSitemap() {
110
+ return this.get(`/api/sitemap`);
111
+ }
112
+ }
113
+ export default GalleryClient;
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,qEAAqE;AACrE,qDAAqD;AACrD,EAAE;AACF,cAAc;AACd,EAAE;AACF,sDAAsD;AACtD,EAAE;AACF,yCAAyC;AACzC,oEAAoE;AACpE,oDAAoD;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAuEnD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,MAAM,CAAS;IACf,IAAI,CAAU;IAEvB,YAAY,MAAc,EAAE,IAAa,EAAE,OAAe;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAA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CAAC;IACjC,CAAC;IAED,mCAAmC;IACnC,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,iCAAiC;IACjC,WAAW;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,0EAA0E;IAC1E,mBAAmB;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,kCAAkC;IAClC,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,wBAAwB,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,oEAAoE;IACpE,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "gallery-magazine",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Official JavaScript SDK + CLI for the Gallery Magazine (gallery.je) public read-only API — Jersey's life and style magazine, since 2004.",
5
+ "keywords": [
6
+ "gallery",
7
+ "gallery-magazine",
8
+ "jersey",
9
+ "channel-islands",
10
+ "news",
11
+ "magazine",
12
+ "api",
13
+ "sdk",
14
+ "cli",
15
+ "rss",
16
+ "articles"
17
+ ],
18
+ "homepage": "https://gallery.je",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/factoryjersey/Gallery.git",
22
+ "directory": "sdk"
23
+ },
24
+ "bugs": {
25
+ "email": "editorial@gallery.je",
26
+ "url": "https://github.com/factoryjersey/Gallery/issues"
27
+ },
28
+ "author": "Factory Publishing Ltd <editorial@gallery.je> (https://gallery.je)",
29
+ "license": "MIT",
30
+ "type": "module",
31
+ "main": "dist/index.js",
32
+ "types": "dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
37
+ }
38
+ },
39
+ "bin": {
40
+ "gallery": "dist/cli.js"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "LICENSE"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "prepublishOnly": "npm run build"
50
+ },
51
+ "engines": {
52
+ "node": ">=18"
53
+ },
54
+ "devDependencies": {
55
+ "typescript": "^5.4.0"
56
+ }
57
+ }