@arisnetxsolutions/quantum-core-sdk 1.0.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 +100 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +49 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js +1 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# QuantumCore SDK 📦
|
|
2
|
+
|
|
3
|
+
Type-safe TypeScript library for consuming content from your QuantumCore Headless CMS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
npm install @quantum-core/sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
By default the SDK will look for an environment variable named `QUANTUMCORE_API_URL`; you can also pass the `baseUrl` option directly when creating a client. This makes it easy to configure different endpoints per environment.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# example .env file in your project root
|
|
16
|
+
QUANTUMCORE_API_URL=http://localhost:3310/api/v1
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { QuantumCore } from '@quantum-core/sdk';
|
|
21
|
+
|
|
22
|
+
// explicit URL
|
|
23
|
+
const cms = new QuantumCore({
|
|
24
|
+
apiKey: 'your_api_key_here',
|
|
25
|
+
baseUrl: 'https://api.quantum.core.arisnetxsolutions.com/api/v1'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// or rely on .env / process.env
|
|
29
|
+
const cms2 = new QuantumCore({
|
|
30
|
+
apiKey: 'your_api_key_here'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const posts = await cms2.blog.getAll();
|
|
34
|
+
const images = await cms2.gallery.getAll();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
- **Full Type Safety**: All responses are fully typed.
|
|
39
|
+
- **Axios-based**: Reliable and customizable HTTP client.
|
|
40
|
+
- **Simplified API**: Simple methods for blog and gallery content.
|
|
41
|
+
|
|
42
|
+
## Publishing to npm
|
|
43
|
+
When you're ready to release a new version of the SDK, follow these steps:
|
|
44
|
+
|
|
45
|
+
1. **Update the version** in `packages/sdk/package.json` (use semantic versioning).
|
|
46
|
+
make sure the `name` field is set to `@quantum-core/sdk` so you publish to the
|
|
47
|
+
scoped namespace rather than the global `sdk` package. Note that the scope
|
|
48
|
+
must exist: either create an **organization** called `quantum-core` on
|
|
49
|
+
<https://www.npmjs.com/org> or use `npm org create quantum-core` (if you have a
|
|
50
|
+
paid account). You will also need to be a member of that org. If the scope does
|
|
51
|
+
not exist the publish attempt will return a 404 with "Scope not found".
|
|
52
|
+
Alternatively, if you don't want a scope you can choose an unscoped name like
|
|
53
|
+
`@quantumcoresdk` or simply `quantum-core-sdk`.
|
|
54
|
+
2. Run `npm run build` from `packages/sdk` to ensure `dist/` is up to date.
|
|
55
|
+
3. Log in to npm if you haven't already:
|
|
56
|
+
```bash
|
|
57
|
+
cd packages/sdk
|
|
58
|
+
npm login
|
|
59
|
+
```
|
|
60
|
+
4. Publish the package:
|
|
61
|
+
```bash
|
|
62
|
+
npm publish --access public
|
|
63
|
+
```
|
|
64
|
+
The `--access public` flag is still required for scoped packages. If your npm
|
|
65
|
+
account has two‑factor authentication enabled you'll encounter a 403 unless you
|
|
66
|
+
either:
|
|
67
|
+
|
|
68
|
+
* run `npm login` and enter the one‑time 2FA code when prompted (interactive). You
|
|
69
|
+
can also supply the OTP during publish with `npm publish --otp=<code>`.
|
|
70
|
+
* or, for automation or CI, create a **publish token** with `automation=publish`
|
|
71
|
+
and `bypass 2fa` from your npm account settings and export it as `NPM_TOKEN`.
|
|
72
|
+
For example:
|
|
73
|
+
```bash
|
|
74
|
+
export NPM_TOKEN="<your-token>"
|
|
75
|
+
npm publish --access public
|
|
76
|
+
```
|
|
77
|
+
(on Windows `setx NPM_TOKEN "<your-token>"` or use the appropriate method).
|
|
78
|
+
|
|
79
|
+
The error message in your last attempt:
|
|
80
|
+
|
|
81
|
+
> npm error 403 Forbidden - Two-factor authentication or granular access token
|
|
82
|
+
> with bypass 2fa enabled is required to publish packages.
|
|
83
|
+
|
|
84
|
+
indicates the credentials used by the CLI did not have bypass permission; the
|
|
85
|
+
login command you ran (`npm login automation=publish, bypass 2fa`) does not
|
|
86
|
+
actually attach a token to subsequent requests, which is why the publish still
|
|
87
|
+
failed. Use a real token or interactive login/OTP approach instead.
|
|
88
|
+
|
|
89
|
+
Also be sure you don't accidentally publish your local `.env` file – the
|
|
90
|
+
included `.npmignore` now explicitly lists `.env` to prevent that.
|
|
91
|
+
|
|
92
|
+
> The package name (`@quantum-core/sdk`) is scoped, so `--access public` is required
|
|
93
|
+
> for public registries. You can also run `npm version patch|minor|major` to bump the
|
|
94
|
+
> version and automatically create a git tag before publishing.
|
|
95
|
+
>
|
|
96
|
+
> Make sure you have access to the `@quantum-core` scope on npm (ask the org owner to
|
|
97
|
+
> add you if necessary). If 2FA is enabled, either publish with a token that allows
|
|
98
|
+
> bypassing 2FA or use `npm login` + one‑time code.
|
|
99
|
+
>
|
|
100
|
+
>Your changes should be committed and tagged in Git before publishing.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Post, Image, SDKConfig } from './types';
|
|
2
|
+
export declare class QuantumCore {
|
|
3
|
+
private api;
|
|
4
|
+
constructor(config: SDKConfig);
|
|
5
|
+
blog: {
|
|
6
|
+
getAll: () => Promise<Post[]>;
|
|
7
|
+
getById: (id: number) => Promise<Post>;
|
|
8
|
+
};
|
|
9
|
+
gallery: {
|
|
10
|
+
getAll: () => Promise<Image[]>;
|
|
11
|
+
};
|
|
12
|
+
admin: {
|
|
13
|
+
posts: {
|
|
14
|
+
getAll: () => Promise<Post[]>;
|
|
15
|
+
create: (data: Partial<Post>) => Promise<Post>;
|
|
16
|
+
delete: (id: number) => Promise<any>;
|
|
17
|
+
};
|
|
18
|
+
images: {
|
|
19
|
+
getAll: () => Promise<Image[]>;
|
|
20
|
+
upload: (formData: FormData) => Promise<Image>;
|
|
21
|
+
delete: (id: number) => Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
getStats: () => Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export * from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
// load variables from .env in development or when running locally
|
|
4
|
+
dotenv.config();
|
|
5
|
+
export class QuantumCore {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.blog = {
|
|
8
|
+
getAll: async () => {
|
|
9
|
+
const response = await this.api.get('/content/posts');
|
|
10
|
+
return response.data;
|
|
11
|
+
},
|
|
12
|
+
getById: async (id) => {
|
|
13
|
+
const response = await this.api.get(`/content/posts/${id}`);
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.gallery = {
|
|
18
|
+
getAll: async () => {
|
|
19
|
+
const response = await this.api.get('/content/images');
|
|
20
|
+
return response.data;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Admin Management Methods
|
|
24
|
+
this.admin = {
|
|
25
|
+
posts: {
|
|
26
|
+
getAll: async () => (await this.api.get('/admin/posts')).data,
|
|
27
|
+
create: async (data) => (await this.api.post('/admin/posts', data)).data,
|
|
28
|
+
delete: async (id) => (await this.api.delete(`/admin/posts/${id}`)).data,
|
|
29
|
+
},
|
|
30
|
+
images: {
|
|
31
|
+
getAll: async () => (await this.api.get('/admin/images')).data,
|
|
32
|
+
upload: async (formData) => (await this.api.post('/admin/images', formData)).data,
|
|
33
|
+
delete: async (id) => (await this.api.delete(`/admin/images/${id}`)).data,
|
|
34
|
+
},
|
|
35
|
+
getStats: async () => (await this.api.get('/admin/stats')).data,
|
|
36
|
+
};
|
|
37
|
+
// allow overriding via config, otherwise use env var, with fallback
|
|
38
|
+
const baseURL = config.baseUrl ||
|
|
39
|
+
process.env.QUANTUMCORE_API_URL ||
|
|
40
|
+
'http://localhost:3000/api/v1';
|
|
41
|
+
this.api = axios.create({
|
|
42
|
+
baseURL,
|
|
43
|
+
headers: {
|
|
44
|
+
'X-API-KEY': config.apiKey
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export * from './types';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface Post {
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
metaTitle?: string;
|
|
6
|
+
metaDesc?: string;
|
|
7
|
+
projectId: number;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Image {
|
|
12
|
+
id: number;
|
|
13
|
+
url: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
metaTitle?: string;
|
|
16
|
+
metaDesc?: string;
|
|
17
|
+
projectId: number;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SDKConfig {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arisnetxsolutions/quantum-core-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npx tsc",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"axios": "^1.13.6",
|
|
17
|
+
"dotenv": "^16.0.0",
|
|
18
|
+
"typescript": "^5.9.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^25.4.0"
|
|
22
|
+
}
|
|
23
|
+
}
|