@chanomhub/sdk 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.js +55 -0
- package/dist/__tests__/client.test.js.map +1 -0
- package/dist/__tests__/imageUrl.test.d.ts +2 -0
- package/dist/__tests__/imageUrl.test.d.ts.map +1 -0
- package/dist/__tests__/imageUrl.test.js +89 -0
- package/dist/__tests__/imageUrl.test.js.map +1 -0
- package/dist/__tests__/mocks/handlers.d.ts +2 -0
- package/dist/__tests__/mocks/handlers.d.ts.map +1 -0
- package/dist/__tests__/mocks/handlers.js +104 -0
- package/dist/__tests__/mocks/handlers.js.map +1 -0
- package/dist/__tests__/mocks/server.d.ts +2 -0
- package/dist/__tests__/mocks/server.d.ts.map +1 -0
- package/dist/__tests__/mocks/server.js +7 -0
- package/dist/__tests__/mocks/server.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +8 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +73 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -0
- package/dist/next.d.ts +30 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +84 -0
- package/dist/next.js.map +1 -0
- package/dist/repositories/articleRepository.d.ts +30 -0
- package/dist/repositories/articleRepository.d.ts.map +1 -0
- package/dist/repositories/articleRepository.js +265 -0
- package/dist/repositories/articleRepository.js.map +1 -0
- package/dist/repositories/index.d.ts +5 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +9 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/transforms/imageUrl.d.ts +17 -0
- package/dist/transforms/imageUrl.d.ts.map +1 -0
- package/dist/transforms/imageUrl.js +70 -0
- package/dist/transforms/imageUrl.js.map +1 -0
- package/dist/types/article.d.ts +87 -0
- package/dist/types/article.d.ts.map +1 -0
- package/dist/types/article.js +6 -0
- package/dist/types/article.js.map +1 -0
- package/dist/types/common.d.ts +67 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +6 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chanomhub API SDK
|
|
3
|
+
*
|
|
4
|
+
* A framework-agnostic TypeScript SDK for interacting with the Chanomhub API.
|
|
5
|
+
* Works with Next.js, React Native, Node.js, and browser environments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createChanomhubClient } from '@/lib/chanomhub-sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Basic usage
|
|
12
|
+
* const sdk = createChanomhubClient();
|
|
13
|
+
* const articles = await sdk.articles.getByTag('renpy');
|
|
14
|
+
*
|
|
15
|
+
* // With authentication
|
|
16
|
+
* const sdk = createChanomhubClient({ token: 'your-jwt-token' });
|
|
17
|
+
* const article = await sdk.articles.getBySlug('my-article');
|
|
18
|
+
*
|
|
19
|
+
* // With custom config
|
|
20
|
+
* const sdk = createChanomhubClient({
|
|
21
|
+
* apiUrl: 'https://api.chanomhub.online',
|
|
22
|
+
* cdnUrl: 'https://cdn.chanomhub.com',
|
|
23
|
+
* token: 'jwt-token',
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* For Next.js server components, use the helper from './next':
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createServerClient } from '@/lib/chanomhub-sdk/next';
|
|
30
|
+
* const sdk = await createServerClient(); // Reads token from cookies
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
import { type GraphQLFetcher } from './client';
|
|
34
|
+
import { type ArticleRepository } from './repositories';
|
|
35
|
+
import { type ChanomhubConfig } from './config';
|
|
36
|
+
export * from './types';
|
|
37
|
+
export * from './config';
|
|
38
|
+
export { resolveImageUrl } from './transforms/imageUrl';
|
|
39
|
+
/** Chanomhub SDK Client interface */
|
|
40
|
+
export interface ChanomhubClient {
|
|
41
|
+
/** Article operations */
|
|
42
|
+
articles: ArticleRepository;
|
|
43
|
+
/** Raw GraphQL fetcher for custom queries */
|
|
44
|
+
graphql: GraphQLFetcher;
|
|
45
|
+
/** SDK configuration */
|
|
46
|
+
config: ChanomhubConfig;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a Chanomhub API client
|
|
50
|
+
*
|
|
51
|
+
* This is the main entry point for the SDK. It creates a client that can be
|
|
52
|
+
* used to interact with the Chanomhub API.
|
|
53
|
+
*
|
|
54
|
+
* @param config - Configuration options
|
|
55
|
+
* @param config.apiUrl - API base URL (default: https://api.chanomhub.online)
|
|
56
|
+
* @param config.cdnUrl - CDN base URL for images (default: https://cdn.chanomhub.com)
|
|
57
|
+
* @param config.token - JWT authentication token (optional)
|
|
58
|
+
* @param config.defaultCacheSeconds - Default cache duration in seconds (default: 3600)
|
|
59
|
+
* @returns ChanomhubClient with articles repository and raw graphql fetcher
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Public access
|
|
64
|
+
* const sdk = createChanomhubClient();
|
|
65
|
+
*
|
|
66
|
+
* // With authentication
|
|
67
|
+
* const sdk = createChanomhubClient({ token: 'your-jwt-token' });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function createChanomhubClient(config?: Partial<ChanomhubConfig>): ChanomhubClient;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a client with authentication token
|
|
73
|
+
* Convenience function for authenticated requests
|
|
74
|
+
*
|
|
75
|
+
* @param token - JWT authentication token
|
|
76
|
+
* @param config - Optional configuration overrides
|
|
77
|
+
* @returns ChanomhubClient
|
|
78
|
+
*/
|
|
79
|
+
export declare function createAuthenticatedClient(token: string, config?: Partial<ChanomhubConfig>): ChanomhubClient;
|
|
80
|
+
export default createChanomhubClient;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhE,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC5B,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,6CAA6C;IAC7C,OAAO,EAAE,cAAc,CAAC;IACxB,wBAAwB;IACxB,MAAM,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,eAAe,CAc5F;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,eAAe,CAM/G;AAGD,eAAe,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chanomhub API SDK
|
|
4
|
+
*
|
|
5
|
+
* A framework-agnostic TypeScript SDK for interacting with the Chanomhub API.
|
|
6
|
+
* Works with Next.js, React Native, Node.js, and browser environments.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createChanomhubClient } from '@/lib/chanomhub-sdk';
|
|
11
|
+
*
|
|
12
|
+
* // Basic usage
|
|
13
|
+
* const sdk = createChanomhubClient();
|
|
14
|
+
* const articles = await sdk.articles.getByTag('renpy');
|
|
15
|
+
*
|
|
16
|
+
* // With authentication
|
|
17
|
+
* const sdk = createChanomhubClient({ token: 'your-jwt-token' });
|
|
18
|
+
* const article = await sdk.articles.getBySlug('my-article');
|
|
19
|
+
*
|
|
20
|
+
* // With custom config
|
|
21
|
+
* const sdk = createChanomhubClient({
|
|
22
|
+
* apiUrl: 'https://api.chanomhub.online',
|
|
23
|
+
* cdnUrl: 'https://cdn.chanomhub.com',
|
|
24
|
+
* token: 'jwt-token',
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* For Next.js server components, use the helper from './next':
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { createServerClient } from '@/lib/chanomhub-sdk/next';
|
|
31
|
+
* const sdk = await createServerClient(); // Reads token from cookies
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
37
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
38
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(o, k2, desc);
|
|
41
|
+
}) : (function(o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
o[k2] = m[k];
|
|
44
|
+
}));
|
|
45
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
46
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.resolveImageUrl = void 0;
|
|
50
|
+
exports.createChanomhubClient = createChanomhubClient;
|
|
51
|
+
exports.createAuthenticatedClient = createAuthenticatedClient;
|
|
52
|
+
const client_1 = require("./client");
|
|
53
|
+
const repositories_1 = require("./repositories");
|
|
54
|
+
const config_1 = require("./config");
|
|
55
|
+
// Re-export types
|
|
56
|
+
__exportStar(require("./types"), exports);
|
|
57
|
+
__exportStar(require("./config"), exports);
|
|
58
|
+
var imageUrl_1 = require("./transforms/imageUrl");
|
|
59
|
+
Object.defineProperty(exports, "resolveImageUrl", { enumerable: true, get: function () { return imageUrl_1.resolveImageUrl; } });
|
|
60
|
+
/**
|
|
61
|
+
* Creates a Chanomhub API client
|
|
62
|
+
*
|
|
63
|
+
* This is the main entry point for the SDK. It creates a client that can be
|
|
64
|
+
* used to interact with the Chanomhub API.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Configuration options
|
|
67
|
+
* @param config.apiUrl - API base URL (default: https://api.chanomhub.online)
|
|
68
|
+
* @param config.cdnUrl - CDN base URL for images (default: https://cdn.chanomhub.com)
|
|
69
|
+
* @param config.token - JWT authentication token (optional)
|
|
70
|
+
* @param config.defaultCacheSeconds - Default cache duration in seconds (default: 3600)
|
|
71
|
+
* @returns ChanomhubClient with articles repository and raw graphql fetcher
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Public access
|
|
76
|
+
* const sdk = createChanomhubClient();
|
|
77
|
+
*
|
|
78
|
+
* // With authentication
|
|
79
|
+
* const sdk = createChanomhubClient({ token: 'your-jwt-token' });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
function createChanomhubClient(config = {}) {
|
|
83
|
+
const fullConfig = {
|
|
84
|
+
...config_1.DEFAULT_CONFIG,
|
|
85
|
+
...config,
|
|
86
|
+
};
|
|
87
|
+
const graphql = (0, client_1.createGraphQLClient)(fullConfig);
|
|
88
|
+
const articles = (0, repositories_1.createArticleRepository)(graphql);
|
|
89
|
+
return {
|
|
90
|
+
articles,
|
|
91
|
+
graphql,
|
|
92
|
+
config: fullConfig,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a client with authentication token
|
|
97
|
+
* Convenience function for authenticated requests
|
|
98
|
+
*
|
|
99
|
+
* @param token - JWT authentication token
|
|
100
|
+
* @param config - Optional configuration overrides
|
|
101
|
+
* @returns ChanomhubClient
|
|
102
|
+
*/
|
|
103
|
+
function createAuthenticatedClient(token, config = {}) {
|
|
104
|
+
return createChanomhubClient({
|
|
105
|
+
...config,
|
|
106
|
+
token,
|
|
107
|
+
defaultCacheSeconds: 0, // Disable cache for authenticated requests
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// Default export
|
|
111
|
+
exports.default = createChanomhubClient;
|
|
112
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;;;;;;;;;;;AA2CH,sDAcC;AAUD,8DAMC;AAvED,qCAAoE;AACpE,iDAAiF;AACjF,qCAAgE;AAEhE,kBAAkB;AAClB,0CAAwB;AACxB,2CAAyB;AACzB,kDAAwD;AAA/C,2GAAA,eAAe,OAAA;AAYxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,qBAAqB,CAAC,SAAmC,EAAE;IACvE,MAAM,UAAU,GAAoB;QAChC,GAAG,uBAAc;QACjB,GAAG,MAAM;KACZ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAAC,UAAU,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,IAAA,sCAAuB,EAAC,OAAO,CAAC,CAAC;IAElD,OAAO;QACH,QAAQ;QACR,OAAO;QACP,MAAM,EAAE,UAAU;KACrB,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAAC,KAAa,EAAE,SAAmC,EAAE;IAC1F,OAAO,qBAAqB,CAAC;QACzB,GAAG,MAAM;QACT,KAAK;QACL,mBAAmB,EAAE,CAAC,EAAE,2CAA2C;KACtE,CAAC,CAAC;AACP,CAAC;AAED,iBAAiB;AACjB,kBAAe,qBAAqB,CAAC"}
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chanomhub SDK - Next.js Helpers
|
|
3
|
+
*
|
|
4
|
+
* Optional module for Next.js-specific functionality.
|
|
5
|
+
* Import from '@/lib/chanomhub-sdk/next' only in Next.js projects.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // In a Next.js Server Component
|
|
10
|
+
* import { createServerClient } from '@/lib/chanomhub-sdk/next';
|
|
11
|
+
*
|
|
12
|
+
* const sdk = await createServerClient();
|
|
13
|
+
* const articles = await sdk.articles.getAll();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { type ChanomhubClient, type ChanomhubConfig } from './index';
|
|
17
|
+
/**
|
|
18
|
+
* Creates a server-side Chanomhub client for Next.js
|
|
19
|
+
* Automatically reads authentication token from cookies
|
|
20
|
+
*
|
|
21
|
+
* @param config - Optional configuration overrides
|
|
22
|
+
* @returns Promise<ChanomhubClient>
|
|
23
|
+
*/
|
|
24
|
+
export declare function createServerClient(config?: Partial<ChanomhubConfig>): Promise<ChanomhubClient>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the current auth token from Next.js cookies
|
|
27
|
+
* Useful when you need to pass the token to client components
|
|
28
|
+
*/
|
|
29
|
+
export declare function getAuthToken(): Promise<string | undefined>;
|
|
30
|
+
//# sourceMappingURL=next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5F;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAYxG;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAIhE"}
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chanomhub SDK - Next.js Helpers
|
|
4
|
+
*
|
|
5
|
+
* Optional module for Next.js-specific functionality.
|
|
6
|
+
* Import from '@/lib/chanomhub-sdk/next' only in Next.js projects.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // In a Next.js Server Component
|
|
11
|
+
* import { createServerClient } from '@/lib/chanomhub-sdk/next';
|
|
12
|
+
*
|
|
13
|
+
* const sdk = await createServerClient();
|
|
14
|
+
* const articles = await sdk.articles.getAll();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.createServerClient = createServerClient;
|
|
52
|
+
exports.getAuthToken = getAuthToken;
|
|
53
|
+
const index_1 = require("./index");
|
|
54
|
+
/**
|
|
55
|
+
* Creates a server-side Chanomhub client for Next.js
|
|
56
|
+
* Automatically reads authentication token from cookies
|
|
57
|
+
*
|
|
58
|
+
* @param config - Optional configuration overrides
|
|
59
|
+
* @returns Promise<ChanomhubClient>
|
|
60
|
+
*/
|
|
61
|
+
async function createServerClient(config = {}) {
|
|
62
|
+
var _a;
|
|
63
|
+
// Dynamic import to avoid bundling next/headers in non-Next.js environments
|
|
64
|
+
const { cookies } = await Promise.resolve().then(() => __importStar(require('next/headers')));
|
|
65
|
+
const cookieStore = await cookies();
|
|
66
|
+
const token = (_a = cookieStore.get('token')) === null || _a === void 0 ? void 0 : _a.value;
|
|
67
|
+
return (0, index_1.createChanomhubClient)({
|
|
68
|
+
...config,
|
|
69
|
+
token,
|
|
70
|
+
// Disable cache when authenticated
|
|
71
|
+
defaultCacheSeconds: token ? 0 : config.defaultCacheSeconds,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the current auth token from Next.js cookies
|
|
76
|
+
* Useful when you need to pass the token to client components
|
|
77
|
+
*/
|
|
78
|
+
async function getAuthToken() {
|
|
79
|
+
var _a;
|
|
80
|
+
const { cookies } = await Promise.resolve().then(() => __importStar(require('next/headers')));
|
|
81
|
+
const cookieStore = await cookies();
|
|
82
|
+
return (_a = cookieStore.get('token')) === null || _a === void 0 ? void 0 : _a.value;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../next.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWH,gDAYC;AAMD,oCAIC;AA/BD,mCAA4F;AAE5F;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CAAC,SAAmC,EAAE;;IAC1E,4EAA4E;IAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,wDAAa,cAAc,GAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,MAAA,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,0CAAE,KAAK,CAAC;IAE9C,OAAO,IAAA,6BAAqB,EAAC;QACzB,GAAG,MAAM;QACT,KAAK;QACL,mCAAmC;QACnC,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;KAC9D,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,YAAY;;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,wDAAa,cAAc,GAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,OAAO,MAAA,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,0CAAE,KAAK,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chanomhub SDK - Article Repository
|
|
3
|
+
*/
|
|
4
|
+
import type { GraphQLFetcher } from '../client';
|
|
5
|
+
import type { Article, ArticleListItem, ArticleListOptions, ArticleWithDownloads } from '../types/article';
|
|
6
|
+
export interface ArticleRepository {
|
|
7
|
+
/** Get paginated list of articles */
|
|
8
|
+
getAll(options?: ArticleListOptions): Promise<ArticleListItem[]>;
|
|
9
|
+
/** Get articles by tag */
|
|
10
|
+
getByTag(tag: string, options?: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
}): Promise<ArticleListItem[]>;
|
|
13
|
+
/** Get articles by platform */
|
|
14
|
+
getByPlatform(platform: string, options?: {
|
|
15
|
+
limit?: number;
|
|
16
|
+
}): Promise<ArticleListItem[]>;
|
|
17
|
+
/** Get articles by category */
|
|
18
|
+
getByCategory(category: string, options?: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
}): Promise<ArticleListItem[]>;
|
|
21
|
+
/** Get single article by slug */
|
|
22
|
+
getBySlug(slug: string, language?: string): Promise<Article | null>;
|
|
23
|
+
/** Get article with downloads */
|
|
24
|
+
getWithDownloads(slug: string, language?: string): Promise<ArticleWithDownloads>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates an article repository with the given GraphQL client
|
|
28
|
+
*/
|
|
29
|
+
export declare function createArticleRepository(fetcher: GraphQLFetcher): ArticleRepository;
|
|
30
|
+
//# sourceMappingURL=articleRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"articleRepository.d.ts","sourceRoot":"","sources":["../../repositories/articleRepository.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAsH3G,MAAM,WAAW,iBAAiB;IAChC,qCAAqC;IACrC,MAAM,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEjE,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEhF,+BAA+B;IAC/B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE1F,+BAA+B;IAC/B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE1F,iCAAiC;IACjC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAEpE,iCAAiC;IACjC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,GAAG,iBAAiB,CAiLlF"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chanomhub SDK - Article Repository
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createArticleRepository = createArticleRepository;
|
|
7
|
+
// GraphQL Fragments for reuse
|
|
8
|
+
const ARTICLE_LIST_FIELDS = `
|
|
9
|
+
id
|
|
10
|
+
title
|
|
11
|
+
slug
|
|
12
|
+
description
|
|
13
|
+
ver
|
|
14
|
+
createdAt
|
|
15
|
+
updatedAt
|
|
16
|
+
mainImage
|
|
17
|
+
coverImage
|
|
18
|
+
favoritesCount
|
|
19
|
+
favorited
|
|
20
|
+
status
|
|
21
|
+
sequentialCode
|
|
22
|
+
engine {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
}
|
|
26
|
+
author {
|
|
27
|
+
name
|
|
28
|
+
image
|
|
29
|
+
}
|
|
30
|
+
creators {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
}
|
|
34
|
+
tags {
|
|
35
|
+
id
|
|
36
|
+
name
|
|
37
|
+
}
|
|
38
|
+
platforms {
|
|
39
|
+
id
|
|
40
|
+
name
|
|
41
|
+
}
|
|
42
|
+
categories {
|
|
43
|
+
id
|
|
44
|
+
name
|
|
45
|
+
}
|
|
46
|
+
images {
|
|
47
|
+
id
|
|
48
|
+
url
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const ARTICLE_FULL_FIELDS = `
|
|
52
|
+
id
|
|
53
|
+
title
|
|
54
|
+
slug
|
|
55
|
+
description
|
|
56
|
+
body
|
|
57
|
+
ver
|
|
58
|
+
createdAt
|
|
59
|
+
updatedAt
|
|
60
|
+
status
|
|
61
|
+
engine {
|
|
62
|
+
id
|
|
63
|
+
name
|
|
64
|
+
}
|
|
65
|
+
mainImage
|
|
66
|
+
backgroundImage
|
|
67
|
+
coverImage
|
|
68
|
+
favorited
|
|
69
|
+
favoritesCount
|
|
70
|
+
sequentialCode
|
|
71
|
+
images {
|
|
72
|
+
id
|
|
73
|
+
url
|
|
74
|
+
}
|
|
75
|
+
author {
|
|
76
|
+
name
|
|
77
|
+
bio
|
|
78
|
+
image
|
|
79
|
+
backgroundImage
|
|
80
|
+
following
|
|
81
|
+
socialMediaLinks {
|
|
82
|
+
platform
|
|
83
|
+
url
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
creators {
|
|
87
|
+
id
|
|
88
|
+
name
|
|
89
|
+
}
|
|
90
|
+
tags {
|
|
91
|
+
id
|
|
92
|
+
name
|
|
93
|
+
}
|
|
94
|
+
platforms {
|
|
95
|
+
id
|
|
96
|
+
name
|
|
97
|
+
}
|
|
98
|
+
categories {
|
|
99
|
+
id
|
|
100
|
+
name
|
|
101
|
+
}
|
|
102
|
+
mods {
|
|
103
|
+
id
|
|
104
|
+
name
|
|
105
|
+
description
|
|
106
|
+
creditTo
|
|
107
|
+
downloadLink
|
|
108
|
+
version
|
|
109
|
+
status
|
|
110
|
+
categories {
|
|
111
|
+
id
|
|
112
|
+
name
|
|
113
|
+
}
|
|
114
|
+
images {
|
|
115
|
+
id
|
|
116
|
+
url
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
/**
|
|
121
|
+
* Creates an article repository with the given GraphQL client
|
|
122
|
+
*/
|
|
123
|
+
function createArticleRepository(fetcher) {
|
|
124
|
+
async function getAll(options = {}) {
|
|
125
|
+
const { limit = 12, offset = 0, status = 'PUBLISHED', filter = {} } = options;
|
|
126
|
+
// Build filter string
|
|
127
|
+
const filterParts = [];
|
|
128
|
+
if (filter.tag)
|
|
129
|
+
filterParts.push(`tag: "${filter.tag}"`);
|
|
130
|
+
if (filter.platform)
|
|
131
|
+
filterParts.push(`platform: "${filter.platform}"`);
|
|
132
|
+
if (filter.category)
|
|
133
|
+
filterParts.push(`category: "${filter.category}"`);
|
|
134
|
+
if (filter.author)
|
|
135
|
+
filterParts.push(`author: "${filter.author}"`);
|
|
136
|
+
if (filter.favorited !== undefined)
|
|
137
|
+
filterParts.push(`favorited: ${filter.favorited}`);
|
|
138
|
+
const filterArg = filterParts.length > 0 ? `filter: { ${filterParts.join(', ')} }, ` : '';
|
|
139
|
+
const query = `query GetArticles {
|
|
140
|
+
articles(${filterArg}limit: ${limit}, offset: ${offset}, status: ${status}) {
|
|
141
|
+
${ARTICLE_LIST_FIELDS}
|
|
142
|
+
}
|
|
143
|
+
}`;
|
|
144
|
+
const { data, errors } = await fetcher(query, {}, {
|
|
145
|
+
operationName: 'GetArticles',
|
|
146
|
+
});
|
|
147
|
+
if (errors || !data) {
|
|
148
|
+
console.error('Failed to fetch articles:', errors);
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
return data.articles || [];
|
|
152
|
+
}
|
|
153
|
+
async function getByTag(tag, options = {}) {
|
|
154
|
+
const { limit = 50 } = options;
|
|
155
|
+
const query = `query GetArticlesByTag($tag: String!) {
|
|
156
|
+
articles(filter: { tag: $tag }, status: PUBLISHED, limit: ${limit}) {
|
|
157
|
+
${ARTICLE_LIST_FIELDS}
|
|
158
|
+
}
|
|
159
|
+
}`;
|
|
160
|
+
const { data, errors } = await fetcher(query, { tag }, {
|
|
161
|
+
operationName: 'GetArticlesByTag',
|
|
162
|
+
});
|
|
163
|
+
if (errors || !data) {
|
|
164
|
+
console.error('Failed to fetch articles by tag:', errors);
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
return data.articles || [];
|
|
168
|
+
}
|
|
169
|
+
async function getByPlatform(platform, options = {}) {
|
|
170
|
+
const { limit = 50 } = options;
|
|
171
|
+
const query = `query GetArticlesByPlatform($platform: String!) {
|
|
172
|
+
articles(filter: { platform: $platform }, status: PUBLISHED, limit: ${limit}) {
|
|
173
|
+
${ARTICLE_LIST_FIELDS}
|
|
174
|
+
}
|
|
175
|
+
}`;
|
|
176
|
+
const { data, errors } = await fetcher(query, { platform }, {
|
|
177
|
+
operationName: 'GetArticlesByPlatform',
|
|
178
|
+
});
|
|
179
|
+
if (errors || !data) {
|
|
180
|
+
console.error('Failed to fetch articles by platform:', errors);
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
return data.articles || [];
|
|
184
|
+
}
|
|
185
|
+
async function getByCategory(category, options = {}) {
|
|
186
|
+
const { limit = 50 } = options;
|
|
187
|
+
const query = `query GetArticlesByCategory($category: String!) {
|
|
188
|
+
articles(filter: { category: $category }, status: PUBLISHED, limit: ${limit}) {
|
|
189
|
+
${ARTICLE_LIST_FIELDS}
|
|
190
|
+
}
|
|
191
|
+
}`;
|
|
192
|
+
const { data, errors } = await fetcher(query, { category }, {
|
|
193
|
+
operationName: 'GetArticlesByCategory',
|
|
194
|
+
});
|
|
195
|
+
if (errors || !data) {
|
|
196
|
+
console.error('Failed to fetch articles by category:', errors);
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
return data.articles || [];
|
|
200
|
+
}
|
|
201
|
+
async function getBySlug(slug, language) {
|
|
202
|
+
const query = `query GetArticleBySlug($slug: String!, $language: String) {
|
|
203
|
+
article(slug: $slug, language: $language) {
|
|
204
|
+
${ARTICLE_FULL_FIELDS}
|
|
205
|
+
}
|
|
206
|
+
}`;
|
|
207
|
+
const { data, errors } = await fetcher(query, { slug, language }, {
|
|
208
|
+
operationName: 'GetArticleBySlug',
|
|
209
|
+
});
|
|
210
|
+
if (errors || !data) {
|
|
211
|
+
console.error('Failed to fetch article by slug:', errors);
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
return data.article || null;
|
|
215
|
+
}
|
|
216
|
+
async function getWithDownloads(slug, language) {
|
|
217
|
+
const query = `query GetArticleWithDownloads($slug: String!, $language: String, $downloadsArticleId: Int) {
|
|
218
|
+
article(slug: $slug, language: $language) {
|
|
219
|
+
${ARTICLE_FULL_FIELDS}
|
|
220
|
+
}
|
|
221
|
+
downloads(articleId: $downloadsArticleId) {
|
|
222
|
+
id
|
|
223
|
+
name
|
|
224
|
+
url
|
|
225
|
+
isActive
|
|
226
|
+
vipOnly
|
|
227
|
+
createdAt
|
|
228
|
+
}
|
|
229
|
+
officialDownloadSources(articleId: $downloadsArticleId) {
|
|
230
|
+
id
|
|
231
|
+
name
|
|
232
|
+
url
|
|
233
|
+
status
|
|
234
|
+
}
|
|
235
|
+
}`;
|
|
236
|
+
// First get article to get its ID
|
|
237
|
+
const articleResult = await getBySlug(slug, language);
|
|
238
|
+
if (!articleResult) {
|
|
239
|
+
return { article: null, downloads: null };
|
|
240
|
+
}
|
|
241
|
+
const { data, errors } = await fetcher(query, { slug, language, downloadsArticleId: articleResult.id }, { operationName: 'GetArticleWithDownloads' });
|
|
242
|
+
if (errors || !data) {
|
|
243
|
+
console.error('Failed to fetch article with downloads:', errors);
|
|
244
|
+
return { article: articleResult, downloads: null };
|
|
245
|
+
}
|
|
246
|
+
// Combine data
|
|
247
|
+
if (data.article) {
|
|
248
|
+
data.article.downloads = data.downloads || [];
|
|
249
|
+
data.article.officialDownloadSources = data.officialDownloadSources || [];
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
article: data.article || articleResult,
|
|
253
|
+
downloads: data.downloads || null,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
getAll,
|
|
258
|
+
getByTag,
|
|
259
|
+
getByPlatform,
|
|
260
|
+
getByCategory,
|
|
261
|
+
getBySlug,
|
|
262
|
+
getWithDownloads,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=articleRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"articleRepository.js","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R,aAAa;QACb,aAAa;QACb,SAAS;QACT,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chanomhub SDK - Repositories Index
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createArticleRepository = void 0;
|
|
7
|
+
var articleRepository_1 = require("./articleRepository");
|
|
8
|
+
Object.defineProperty(exports, "createArticleRepository", { enumerable: true, get: function () { return articleRepository_1.createArticleRepository; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../repositories/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAAsF;AAA7E,4HAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image URL Transformation
|
|
3
|
+
*
|
|
4
|
+
* Transforms filename-only URLs to full CDN URLs
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Resolves an image URL.
|
|
8
|
+
* - If it's just a filename (e.g., "abc.jpg"), prepends the CDN base URL
|
|
9
|
+
* - If it's already a full URL, returns it as-is
|
|
10
|
+
* - Handles null/undefined gracefully
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveImageUrl(imageUrl: string | null | undefined, cdnUrl: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Deep transforms all image URLs in an object/array recursively.
|
|
15
|
+
*/
|
|
16
|
+
export declare function transformImageUrlsDeep<T>(data: T, cdnUrl: string): T;
|
|
17
|
+
//# sourceMappingURL=imageUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageUrl.d.ts","sourceRoot":"","sources":["../../transforms/imageUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlG;AAUD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAqCpE"}
|